Skip to content

Commit

Permalink
added to github
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Lee committed Jun 12, 2011
1 parent 8d57b5c commit 38f15b0
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 3 deletions.
28 changes: 26 additions & 2 deletions CLnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def kill(self):
return -1

def desc(self):
print self.ntype,self.instID,self.instName,self.url,self.status,self.ami,self.key,self.size,self.date
print self.ntype,self.instID,self.instName,self.status,self.url,self.ami,self.key,self.size,self.date

def desc_detail(self):
print "Instance Type:\t\t"+self.ntype
Expand All @@ -53,7 +53,7 @@ def desc_detail(self):



def statys(self):
def status(self):
return self.status

def running(self):
Expand All @@ -64,3 +64,27 @@ def running(self):

def copy(self):
return CLnode(self.instID,self.instName,self.status,self.ami,self.key,self.size,self.date,self.ntype,self.url)
def deploy(self,payload,launch=False):
# COPY payload
try:
res=GF.run("scp -i ~/.ec2/pkey /home/madmaze/.ec2/pkey [email protected]:~/.ssh/")
except Exception as x:
print x, "\n", res
return -1

# EXTRACT payload
try:
res=GF.run("scp -i ~/.ec2/pkey /home/madmaze/.ec2/pkey [email protected]:~/.ssh/")
except Exception as x:
print x, "\n", res
return -1

if launch is True:
# LAUNCH Payload
try:
res=GF.run("scp -i ~/.ec2/pkey /home/madmaze/.ec2/pkey [email protected]:~/.ssh/")
except Exception as x:
print x, "\n", res
return -1


Binary file modified CLnode.pyc
Binary file not shown.
45 changes: 45 additions & 0 deletions CLnode.py~
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os
import sys
import GF

class CLnode:
instID=''
instName=''
status=''
ami=''
key=''
size=''
date=''

def __init__(self, instID='',instName='',status='',ami='',key='',size='',date=''):
self.instID=instID
self.instName=instName
self.status=status
self.ami=ami
self.key=key
self.size=size
self.date=date

def kill(self):
if self.status!="running":
print "Instance is not running, therefore will not shutdown"
return
try:
res=''
res = GF.run("ec2-terminate-instances "+self.instID)
print res
except Exception as x:
print x, "\n", res
return -1

def desc(self):
print self.instID,self.instName,self.status,self.ami,self.key,self.size,self.date

def running(self):
if self.status=="running":
return True
else:
return False

def copy(self):
return CLnode(self.instID,self.instName,self.status,self.ami,self.key,self.size,self.date)
1 change: 0 additions & 1 deletion GF.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def confirmQuestion(Question):
var=""
while var != "y" and var != "n":
var = raw_input(Question + " (y/n):" )
print var
if var == "y":
return True
else:
Expand Down
Binary file modified GF.pyc
Binary file not shown.
40 changes: 40 additions & 0 deletions GF.py~
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import sys
import time
import CLnode

#######################
# 0 = none
# 1 = info
# 2 = debug
logLevel=0
######################
nodes=[]

def run(cmd):
f=os.popen(cmd)
buf=""
for i in f.readlines():
buf+=i
return buf.strip()

def log(msg, lvl):
if logLevel >= lvl:
print msg

def addNewNodes(new):
for n in new:
exists=instExists(n)
if exists>=0:
nodes[exists]=n.copy()
else:
nodes.append(n)


def instExists(node):
cnt=0
for n in nodes:
if n.instID==node.instID:
return cnt;
cnt+=1
return -1
Empty file added README
Empty file.
Binary file removed ec2-api-tools.zip
Binary file not shown.
16 changes: 16 additions & 0 deletions manage-cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,22 @@ def getSpotRequests():
print "There are currently no nodes to kill"
for n in GF.nodes:
n.kill()
if arg == "-kill":
# ask user for confirm
foundinst=False
getRunningInstances()
var = raw_input("Which host would you like to kill?: ")
for n in GF.nodes:
if n.instName==var:
foundinst=True
if foundinst is False:
print "There is currently no instance by the ID: "+var
else:
if GF.confirmQuestion("!!This will kill the instance: "+var+"!\nAre you sure you want to continue?") is False:
sys.exit()
for n in GF.nodes:
if n.instName==var:
n.kill()

#ec2-describe-images -a | grep ami-06ad526f
#getRunningInstances()
Expand Down
5 changes: 5 additions & 0 deletions payload/runconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
masterip:192.168.1.107
deploydir:/home/ubuntu
newpkgs:
configscripts:
bootnode:
15 changes: 15 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import CLnode
import GF

for n in range(0,10):
GF.nodes.append(CLnode.CLnode(str(n),str(n),str(n),str(n)))

n2=[]

for n in range(0,15):
n2.append(CLnode.CLnode(str(n),str(n),str(n),str(n)))

GF.addNewNodes(n2)

for n in GF.nodes:
n.desc()

0 comments on commit 38f15b0

Please sign in to comment.