-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matthias Lee
committed
Jun 12, 2011
1 parent
8d57b5c
commit 38f15b0
Showing
11 changed files
with
147 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -53,7 +53,7 @@ def desc_detail(self): | |
|
||
|
||
|
||
def statys(self): | ||
def status(self): | ||
return self.status | ||
|
||
def running(self): | ||
|
@@ -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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |