示例#1
0
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.. "
示例#2
0
 def test_04_start_a_vm(cls):
     HEADING()
     import random
     vm_name = "nosetests_" + str(random.randint(1, 100))
     cloudmesh.shell("vm start --name={0} --cloud=india \
                     --image=futuregrid/ubuntu-14.04 \
                     --flavor=m1.small".format(vm_name))
     cls.vm.append(vm_name)
示例#3
0
 def test_04_start_a_vm(cls):
     HEADING()
     import random
     vm_name = "nosetests_"+str(random.randint(1, 100))
     cloudmesh.shell("vm start --name={0} --cloud=india \
                     --image=futuregrid/ubuntu-14.04 \
                     --flavor=m1.small".format(vm_name))
     cls.vm.append(vm_name)
示例#4
0
 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
示例#5
0
 def create(self, name, datanodes, cloud):
     print("create hadoop cluster {0}"
            " with {1} datanodes".format(name, datanodes))
     # check if groupname already exits
     for serverid in mesh.servers(clouds=[cloud],
                                  cm_user_id=username)[cloud].keys():
         server =  mesh.servers(clouds=[cloud],
                                cm_user_id=username)[cloud][serverid]
         try:
             if server["metadata"]["cm_group"] == name:
                 print("Group Name {0} already exits".format(name))
                 return
         except:
             pass
     #create a virtual cluster
     try:
         nodes = int(datanodes)
     except:
         print("DATANODES should be an integer")
         return
     nodes = nodes + 1
     print("creating a cluster with {0} nodes".format(str(nodes)))
     r = cloudmesh.shell("cluster create --count={0}"
                         "--group={1} "
                         "--ln=ubuntu".format(datanodes, name))
     #print(r)
     print("created");
     #deploy hadoop on cluster
     #DeployHadoop(name,cloud)
     
     
     return
示例#6
0
 def _ips_cluster(self):
     vms = self._vm_names_cluster()
     vms_string = ",".join(vms)
     command = 'vm ip show --names="{0}" --format=json'.format(vms_string)
     print "cm>", command
     json_data = cloudmesh.shell(command)
     ip_data = json.loads(json_data.replace('\n', ' '))
     return ip_data
示例#7
0
 def _vm_names_cluster(self):
     '''Display the list of all the VMs in the group'''
     command = 'group show {groupname} --format=json'.format(**self.data)
     print "cm>", command
     json_data = cloudmesh.shell(command)
     pprint(json_data)
     if not 'VM' in json_data:
         vm_list = []
     vms = json.loads(json_data.replace("\n"," "))            
     vm_list = vms["VM"]
     vm_list = [x.encode('UTF8') for x in vm_list]
     return vm_list
示例#8
0
    def test_09_help(self):
        HEADING()

        import cloudmesh
        cloud_commands = [
            "cloud",
            "group",
            "inventory",
            "rain",
            "storm",
            "yaml",
            "keys",
            "defaults",
            "image",
            "list",
            "register",
            "user",
            "debug",
            "project",
            "flavor",
            "init",
            "metric",
            "security_group",
            "vm",
            "loglevel",
            ]

        success = True
        for command in cloud_commands:
            execution = "help {0}".format(command)
            print("testing", execution, end=' ')
            try:
                result = cloudmesh.shell(execution)
            except Exception, e:
                success = False
                print(e)
            if "Usage" not in result:
                print(command, "ERROR", result)
                success = False
            else:
                success = success 
                print("ok")
示例#9
0
 def test_06_default_image(self):
     HEADING()
     cloudmesh.shell("cloud set image india --name=futuregrid/ubuntu-14.04")
def RemoveCluster(name):
    print(cloudmesh.shell("cluster remove %s"% (name)))
import cloudmesh
print cloudmesh.shell("vm start --cloud=india 
--image=futuresystems/ubuntu-14.04 --flavor=m1.small")
示例#12
0
 def test_10_refresh_vms(self):
     HEADING()
     cloudmesh.shell("list vm india --refresh")
示例#13
0
 def test_12_start_3_vms(self):
     HEADING()
     cloudmesh.shell("vm start --cloud=india --group=nosetests --count=3")
示例#14
0
 def test_08_list_images(self):
     HEADING()
     cloudmesh.shell("list image india --refresh")
示例#15
0
 def test_08_list_images(self):
     HEADING()
     cloudmesh.shell("list image india --refresh")
import cloudmesh

print cloudmesh.shell("cloud on india")
vmname = "mckibbenc_ex3"
print cloudmesh.shell("vm start --cloud=india --image=futuresystems/ubuntu-14.04 --flavor=m1.small --name={0}".format(vmname))
print cloudmesh.shell("vm delete {0} --cloud=india --force".format(vmname))

示例#17
0
 def test_03_select_default_cloud(self):
     HEADING()
     cloudmesh.shell("default cloud india")
示例#18
0
 def test_12_start_3_vms(self):
     HEADING()
     cloudmesh.shell("vm start --cloud=india --group=nosetests --count=3")
示例#19
0
 def test_13_delete_3_vms(self):
     HEADING()
     cloudmesh.shell("vm delete --cloud=india --group=nosetests --force")
示例#20
0
 def test_11_delete_vms(cls):
     HEADING()
     for vm_name in cls.vm:
         cloudmesh.shell("vm delete {0} --cloud=india --force".format(vm_name))
         cls.vm.remove(vm_name)
示例#21
0
 def test_10_refresh_vms(self):
     HEADING()
     cloudmesh.shell("list vm india --refresh")
示例#22
0
 def test_09_quick_start(cls):
     HEADING()
     import random
     vm_name = "nosetests_"+str(random.randint(1, 100))
     cloudmesh.shell("vm start --name={0} --cloud=india".format(vm_name))
     cls.vm.append(vm_name)
示例#23
0
import cloudmesh as cm
cm.banner('HW3 ex2')
print cm.shell('cloud list')
print cm.shell('cloud on india')
print cm.shell('cloud list')
示例#24
0
 def test_06_default_image(self):
     HEADING()
     cloudmesh.shell("cloud set image india --name=futuregrid/ubuntu-14.04")
def CreateCluster(name, count = "3", cloud = "india", flavor = "m1.small", image = "futuresystems/ubuntu-14.04", login = "******"):
    print(cloudmesh.shell("cluster create %s --count=%s --ln=%s --cloud=%s --flavor=%s --image=%s"% (name, count, login, cloud, flavor, image)))
示例#26
0
 def test_07_list_flavors(self):
     HEADING()
     cloudmesh.shell("list flavor india --refresh")
示例#27
0
 def test_05_default_flavor(self):
     HEADING()
     cloudmesh.shell("cloud set flavor india --id=2")
示例#28
0
import cloudmesh
print cloudmesh.shell("cloud list")

示例#29
0
 def test_07_list_flavors(self):
     HEADING()
     cloudmesh.shell("list flavor india --refresh")
示例#30
0
 def _execute(self, commands):
     for command in commands:
         print "cm>", command
         r = cloudmesh.shell(command)
         print r
示例#31
0
 def test_09_quick_start(cls):
     HEADING()
     import random
     vm_name = "nosetests_" + str(random.randint(1, 100))
     cloudmesh.shell("vm start --name={0} --cloud=india".format(vm_name))
     cls.vm.append(vm_name)
示例#32
0
import cloudmesh
from pprint import pprint

registeredCloud = cloudmesh.shell("cloud list")

if __name__ == '__main__':
    print registeredCloud
示例#33
0
 def test_11_delete_vms(cls):
     HEADING()
     for vm_name in cls.vm:
         cloudmesh.shell(
             "vm delete {0} --cloud=india --force".format(vm_name))
         cls.vm.remove(vm_name)
import cloudmesh

print cloudmesh.shell("version")
示例#35
0
 def test_13_delete_3_vms(self):
     HEADING()
     cloudmesh.shell("vm delete --cloud=india --group=nosetests --force")
(ENV)ubuntu@sgeheran-sgeheran-ta-cherrypy:~$ ipython
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
Type "copyright", "credits" or "license" for more information.

IPython 3.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]:  import cloudmesh

In [2]: cloudmesh.shell("cloud list")
# coding: utf-8
import cloudmesh
begin_txt = cloudmesh.shell(
    "vm start --cloud=india --image=futuresystems/ubuntu-14.04 --flavor=m1.small"
)
finish_txt = cloudmesh.shell("vm delete --cloud=india leodeana_1 --force")
f = open('leodeana_cloudmesh_ex3.txt', 'w')
f.write(str(begin_txt) + "\n" + str(finish_txt))
f.close()
示例#38
0
import cloudmesh

print cloudmesh.shell("cloud list")
print cloudmesh.shell("cloud on india")

示例#39
0
import cloudmesh

#use India cloud
print cloudmesh.shell("cloud select india")

#activate the cloud, e.g.
print cloudmesh.shell("cloud on india")

#specify default key in cm for starting VMs
#*** - ADD input for specifying cloundmesh key
print cloudmesh.shell("key default"+ cmesh-key)

#seed name for VM cluster prefixes
#*** - ADD input for vm prifixes

print cloudmesh.shell("label --prefix=test --id=1")

#assign image and flavor of VMs
print cloudmesh.shell("default image --name=futuregrid/ubuntu-14.04")
print cloudmesh.shell("default flavor --name=m1.medium")

#assign login name for machines, cluster name and number of machines  and start cluster of 3 servers
#*** - ADD input for login name

print cloudmesh.shell("cluster create --count=3 --group=test --ln=ubuntu")
You may also provide cloud name, flavor or image in the command if you don’t want to pre-set them. For example:

print cloudmesh.shell(“cluster create –count=3 –group=test0 –ln=ubuntu –cloud=india –flavor=m1.medium –
image=futuregrid/ubuntu-14.04”)

#list machines in cluster
示例#40
0
 def test_05_default_flavor(self):
     HEADING()
     cloudmesh.shell("cloud set flavor india --id=2")
示例#41
0
import cloudmesh
from pprint import pprint

#use mongo option for storage of basic information for use with cm
mesh = cloudmesh.mesh("mongo")

#get username and activate account
username = cloudmesh.load().username()
mesh.activate(username)

#register cloud
cloudmesh.shell("cloud on india")

#cache fresh images and flavors with refresh from india
mesh.refresh(username,types=['flavors', 'images'],names=["india"])

#select image and flavor
image = mesh.image('india', 'futuregrid/ubuntu-14.04')
flavor = mesh.flavor('india', 'm1.medium')
cloud =  "india"
#start vm
result = mesh.start(cloud=cloud,
                    cm_user_id=username,
                    flavor=flavor,
                    image=image)
                    
#assign public ip
server = result['server']['id']
ip=mesh.assign_public_ip('india', server, username)

#delay for ip assignment then ssh into machine
def start_vm():
    print cloudmesh.shell(
        "vm start --cloud=india --image=futuresystems/ubuntu-14.04 --flavor=m1.small --name={0}"
        .format("oliveral-supervisor3"))
def stop_vm(name):
    cloudmesh.shell("vm delete {0} --cloud=india --force".format(name))
示例#44
0
 def test_01_init(self):
     HEADING()
     cloudmesh.shell("cloud list")
示例#45
0
#
# HOW TO RUN:
# (1) PULL OUT THE REPO IN CLOUDMESH
# (2) COPY THE PLUGINS/CM_SHELL_DOCKER.PY TO CLOUMESH_CMD3/PLUGINS/
# (3) RUN THIS FILE (PYTHON DOCKER_TEST_PROCEDURE.PY)
#
##########################################################################

import cloudmesh
from pprint import pprint

mesh = cloudmesh.mesh("mongo")

# Start docker service with CLOUD
print("Starting Docker service.....................")
print cloudmesh.shell("docker service start 54.148.243.157")

# List clouds
print("Listing clouds.........................")
print cloudmesh.shell("docker service cloud list")

# List images
print("Listing available images......................")
print cloudmesh.shell("docker images list")

# Create container
print(
    "Creating container with name docker_cont_1 and image ubuntu:latest..........")
print cloudmesh.shell("docker container create docker_cont_1 ubuntu:latest")
print cloudmesh.shell("docker container create docker_cont_2 ubuntu:latest")
print cloudmesh.shell("docker container create docker_cont_3 ubuntu:latest")
示例#46
0
 def test_02_activate_cloud(self):
     HEADING()
     cloudmesh.shell("cloud on india")
import cloudmesh
from pprint import pprint

registeredCloud = cloudmesh.shell("cloud list")

if __name__ == '__main__':
	print registeredCloud
示例#48
0
 def test_03_select_default_cloud(self):
     HEADING()
     cloudmesh.shell("default cloud india")
import cloudmesh
cloudmesh.shell("help")
print cloudmesh.version()

示例#50
0
import cloudmesh
start_txt = cloudmesh.shell(
    "vm start --cloud=india --image=futuresystems/ubuntu-14.04 --flavor=m1.small"
)
terminate_txt = cloudmesh.shell("vm delete --cloud=india yhirose --force")
f = open('yhirose_cloudmesh_ex3.txt', 'w')
f.write(str(start_txt) + "\n" + str(terminate_txt))
f.close()