def createVM(N): username = cloudmesh.load().username() print username mesh = cloudmesh.mesh("mongo") mesh.activate(username) cloudmesh.shell("cloud on india") flavor = mesh.flavor('india', 'm1.large') image=mesh.image('india','futuregrid/ubuntu-14.04') #vm_ip=[] for i in range(0,N): result = mesh.start(cloud='india', cm_user_id=username, flavor=flavor, image=image) server = result['server']['id'] ip=mesh.assign_public_ip('india', server, username) print ip #vm_ip.append(ip) try: result = mesh.wait(ipaddr=ip, command="ls -al", interval=10, retry=5) cloudmesh.banner("INSTALLING MONGO TO THE VM "+str(ip)) result=mesh.ssh_execute(username='******',ipaddr=ip,command='ls -al',pkey=None) print result script ="scp filescript.sh ubuntu@"+ip+":/home/ubuntu/" print script os.system(script) result=mesh.ssh_execute(username='******',ipaddr=ip,command='bash -s < ./filescript.sh',pkey=None) print result result=mesh.ssh_execute(username='******',ipaddr=ip,command='ls -al',pkey=None) print result except: print "Authentication failed when connecting to %s" % ip sys.exit(1) print "All VMs Mongo Installed.. "
def __init__(self, filename='mongo-gregor.yaml'): self.username = cloudmesh.load().username() with open(filename, 'r') as f: self.config = yaml.load(f) pprint (self.config) self.data = dict(self.config['config'].items() + self.config['cloud'].items()) self.data["groupname"] = self.username + '-' + self.config['config']['group_postfix']
def setUp(self): self.cloudname = "india" if "-s" in sys.argv: self.cloudname = sys.argv[-1:][0] self.config = cloudmesh.load("user") self.username = self.config.get("cloudmesh.hpc.username")
def setUp(self): print ("setup") self.cloudname = "india" self.cloudmesh_yaml = "~/.cloudmesh/cloudmesh.yaml" self.data = { "user": cloudmesh.load().username(), "cloud": self.cloudname } r = cloudmesh.shell("cloud on {cloud}".format(**self.data)) print (r) r = cloudmesh.shell("cloud select {cloud}".format(**self.data)) print (r) r = cloudmesh.shell("project default fg82") print (r) print ("Cloud: ", self.data["cloud"]) pass
def _install_mongo(self): self.mesh = cloudmesh.mesh("mongo") username = cloudmesh.load().username() self.mesh.activate(username) print "Waiting for a minute to let VMs build and start" time.sleep(60) # Install mongoDB on all the servers print("=====Installing MongoDB on all the VMs =====") script = """ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list sudo apt-get update sudo apt-get install -y mongodb-org""" commands = script.split("\n")[1:] for ip in self.ip_list: result = self.mesh.wait(ipaddr=ip, interval=10, retry=10) print (result) for command in commands: print ('>execute', command) self.mesh.ssh_execute(ipaddr=ip, command=command)
import cloudmesh from pprint import pprint cloudmesh.logger(False) username = cloudmesh.load().username() cloudmesh.banner("INIT MONGO") mesh = cloudmesh.mesh("mongo") # # authentication as a user - username is requried # On webgui side, this is achieved by the framework, # and the username is obtined from g.user.id # # On CLI side, a global user object or username variable # should be maintained upon the start of the shell # The username could be obtained from yaml file. cloudmesh.banner("ACTIVATE") mesh.activate(username) cloudmesh.banner("GET FLAVOR") mesh.refresh(username, types=['flavors'], names=["india"]) data = mesh.flavors(cm_user_id=username, clouds=["india"]) pprint(data) cloudmesh.banner("GET IMAGE") mesh.refresh(username, types=['images'], names=["india"]) data = mesh.images(cm_user_id=username, clouds=["india"])
import cloudmesh from pprint import pprint mesh = cloudmesh.mesh("mongo") username = cloudmesh.load().username() print username mesh.activate(username) print cloudmesh.shell("cloud on india") print cloudmesh.shell("cloud list")
import cloudmesh from cloudmesh_install import config_file config = cloudmesh.load("user") def yaml_attribute_replace(filename='abc.yaml', replacements={}): """ example filename = config_file("/cloudmesh.yaml") replacements = { "cloudmesh.profile.phone": "hallo", } yaml_attribute_replace(filename,replacements) """ result = "" max_indent = 10 with open(filename, 'r') as f: content = f.read() for replacement in replacements: attributes = replacement.split('.') found = [''] * max_indent # just a high number for line in content.split('\n'): # find the indentation level
def deploy(cls, name, count = 3, ln = "ubuntu", cloud = "india", flavor = "m1.small", image = "futuresystems/ubuntu-14.04"): mesh = cloudmesh.mesh("mongo") username = cloudmesh.load().usernam() print username
def test_02_get_username(cls): HEADING() cls.username = cloudmesh.load().username()
import cloudmesh user = cloudmesh.load() print user.cloudnames()
def get_user(self): import cloudmesh config = cloudmesh.load("user") self.username = config.get("cloudmesh.hpc.username")
import cloudmesh from cloudmesh_install import config_file config = cloudmesh.load("user") def yaml_attribute_replace(filename='abc.yaml', replacements={}): """ example filename = config_file("/cloudmesh.yaml") replacements = { "cloudmesh.profile.phone": "hallo", } yaml_attribute_replace(filename,replacements) """ result = "" max_indent = 10 with open(filename, 'r') as f: content = f.read() for replacement in replacements: attributes = replacement.split('.') found = [''] * max_indent # just a high number for line in content.split('\n'): # find the indentation level indent = (len(line) - len(line.lstrip(' '))) / 2