コード例 #1
0
ファイル: metrics.py プロジェクト: mnozary/cloudmesh
    def refresh(self, cloud_name=None):
        print "Refershing cloud %s" % cloud_name
        servers = {}
        cloud = None

        if (cloud_name is None):
            all_clouds = self.clouds.keys()
            for cloud_name in all_clouds:
                try:
                    type = self.clouds[cloud_name]['cm_type']

                    if type == 'openstack':
                        cloud = openstack(cloud_name)

                    elif type == 'eucalyptus':
                        # Where do i find the project name ? Is there a defaul
                        # one ?
                        cloud = eucalyptus(cloud_name, 'fg-82')

                    elif type == 'azure':
                        cloud = azure.cm_azure()

                    cloud.refresh()
                    self.clouds[cloud_name]['flavors'] = cloud.flavors
                    self.clouds[cloud_name]['images'] = cloud.images
                    self.clouds[cloud_name]['servers'] = cloud.servers

                except Exception, e:
                    print e
コード例 #2
0
ファイル: metrics.py プロジェクト: lee212/cloudmesh
    def refresh(self, cloud_name=None):
        print "Refershing cloud %s" % cloud_name
        servers = {}
        cloud = None

        if(cloud_name is None):
            all_clouds = self.clouds.keys()
            for cloud_name in all_clouds:
                try:
                    type = self.clouds[cloud_name]['cm_type']

                    if type == 'openstack':
                        cloud = openstack(cloud_name)

                    elif type == 'eucalyptus':
                        # Where do i find the project name ? Is there a defaul
                        # one ?
                        cloud = eucalyptus(cloud_name, 'fg-82')

                    elif type == 'azure':
                        cloud = azure.cm_azure()

                    cloud.refresh()
                    self.clouds[cloud_name]['flavors'] = cloud.flavors
                    self.clouds[cloud_name]['images'] = cloud.images
                    self.clouds[cloud_name]['servers'] = cloud.servers

                except Exception, e:
                    print e
コード例 #3
0
    def test_26_get_users_all(self):
        """testto get all information for the users"""

        for name in self.configuration.active():
            HEADING()
            cloud = openstack(name)
            cloud.refresh("users")
            print json.dumps(cloud.users, indent=4)

        assert True
コード例 #4
0
    def test_26_get_users_all(self):
        """testto get all information for the users"""

        for name in self.configuration.active():
            HEADING()
            cloud = openstack(name)
            cloud.refresh("users")
            print(json.dumps(cloud.users, indent=4))

        assert True
コード例 #5
0
    def setup(self):
        """setup the test"""
        print("CONFIG")
        self.configuration = cm_config()
        print("OK")

        self.name = 'india_juno'  # self.configuration.active()[3]
        print("ACTIVE CLOUD", self.name)

        self.cloud = openstack(self.name)
        print("PPPP")

        self.cloud.get_token()
        pp.pprint(self.cloud.user_token)
        print("LOADED CLOUD")
        """
コード例 #6
0
    def setup(self):
        """setup the test"""
        print "CONFIG"
        self.configuration = cm_config()
        print "OK"

        self.name = self.configuration.active()[0]
        print "ACTIVE CLOUD", self.name

        self.cloud = openstack(self.name)
        print "PPPP"

        self.cloud.get_token()
        pp.pprint(self.cloud.user_token)
        print "LOADED CLOUD"
        """
コード例 #7
0
    def setup(self):
        """setup the test"""
        print "CONFIG"
        self.configuration = cm_config()
        print "OK"

        self.name = self.configuration.active()[0]
        print "ACTIVE CLOUD", self.name

        self.cloud = openstack(self.name)
        print "PPPP"

        self.cloud.get_token()
        pp.pprint(self.cloud.user_token)
        print "LOADED CLOUD"

        """
コード例 #8
0
ファイル: test_compute.py プロジェクト: lee212/cloudmesh
    def setup(self):
        """setup the test"""
        print("CONFIG")
        self.configuration = cm_config()
        print("OK")

        self.name = 'india_juno'  # self.configuration.active()[3]
        print("ACTIVE CLOUD", self.name)

        self.cloud = openstack(self.name)
        print("PPPP")

        self.cloud.get_token()
        pp.pprint(self.cloud.user_token)
        print("LOADED CLOUD")

        """
コード例 #9
0
ファイル: util.py プロジェクト: rajpushkar83/cloudmesh
def ec2secgroup_openport(cloudname, port):
    cloud = None
    portnum = 0
    try:
        cloud = openstack(cloudname)
        cloud.get_token()
    except:
        print "Cloud name or credential wrong! Please check your cloudmesh.yaml file"
    try:
        portnum = int(port)
    except:
        print "Invalid port number"

    mygroup = Ec2SecurityGroup("default")
    groupid = cloud.find_security_groupid_by_name(mygroup.name)
    # print groupid
    rule = Ec2SecurityGroup.Rule(portnum, portnum)
    cloud.add_security_group_rules(groupid, [rule])
コード例 #10
0
def profile(cloud):
    
    attributes = ['Cores','FloatingIps','Instances','RAM','SecurityGroups']
    max_attributes = ['maxTotalCores','maxTotalFloatingIps','maxTotalInstances','maxTotalRAMSize','maxSecurityGroups']
    used_attributes = ['totalCoresUsed','totalFloatingIpsUsed','totalInstancesUsed','totalRAMUsed','totalSecurityGroupsUsed']
    config = cm_config()
    o = openstack(cloud)
    limits =  o.get_limits()
    data = {}
    for a,m,u in zip(attributes,max_attributes,used_attributes):
        x = json.dumps(a)
        data[x] = []
        data[x].append(['a','b'])
        data[x].append(['available', limits['absolute'][m] - limits['absolute'][u]]) 
        data[x].append(['used',limits['absolute'][u]])
        data[x] = json.dumps(data[x])
    return render_template('pie_chart.html',
                           data = data,
                           cloud = cloud
                           )
コード例 #11
0
    def test_13_delete_vms_of_user(self):
        """delete a vm of a specific user"""
        HEADING()

        self.cloud.refresh()

        user_id = self.cloud.find_user_id(force=True)
        vm_ids = self.cloud.find('user_id', user_id)
        print("userid", user_id)
        config = cm_config()
        config.data['cloudmesh']['clouds'][
            self.name]['credentials']['OS_USER_ID'] = user_id
        config.write()

        #
        # delete all vms of the user
        #
        servers = self.cloud.servers
        print(servers)

        list = self.cloud.vms_delete_user()

        self.cloud = openstack(self.cloud_label)
        self.cloud.refresh()
        self.cloud.info()

        vm_ids = self.cloud.find('user_id', user_id)
        self.cloud.info()

        time.sleep(2)
        self.cloud.refresh()

        while len(vm_ids) > 0:
            vm_ids = self.cloud.find('user_id', user_id)
            self.cloud.refresh("servers")
            self.cloud.info()
            time.sleep(1)

        print("vms", vm_ids)

        assert vm_ids == []
コード例 #12
0
    def test_13_delete_vms_of_user(self):
        """delete a vm of a specific user"""
        HEADING()

        self.cloud.refresh()

        user_id = self.cloud.find_user_id(force=True)
        vm_ids = self.cloud.find('user_id', user_id)
        print "userid", user_id
        config = cm_config()
        config.data['cloudmesh']['clouds'][self.name][
            'credentials']['OS_USER_ID'] = user_id
        config.write()

        #
        # delete all vms of the user
        #
        servers = self.cloud.servers
        print servers

        list = self.cloud.vms_delete_user()

        self.cloud = openstack(self.cloud_label)
        self.cloud.refresh()
        self.cloud.info()

        vm_ids = self.cloud.find('user_id', user_id)
        self.cloud.info()

        time.sleep(2)
        self.cloud.refresh()

        while len(vm_ids) > 0:
            vm_ids = self.cloud.find('user_id', user_id)
            self.cloud.refresh("servers")
            self.cloud.info()
            time.sleep(1)

        print "vms", vm_ids

        assert vm_ids == []
コード例 #13
0
ファイル: pie_chart_fg380.py プロジェクト: mnozary/cloudmesh
def profile(cloud):

    attributes = ['Cores', 'FloatingIps', 'Instances', 'RAM', 'SecurityGroups']
    max_attributes = ['maxTotalCores', 'maxTotalFloatingIps',
                      'maxTotalInstances', 'maxTotalRAMSize', 'maxSecurityGroups']
    used_attributes = ['totalCoresUsed', 'totalFloatingIpsUsed',
                       'totalInstancesUsed', 'totalRAMUsed', 'totalSecurityGroupsUsed']
    config = cm_config()
    o = openstack(cloud)
    limits = o.get_limits()
    data = {}
    for a, m, u in zip(attributes, max_attributes, used_attributes):
        x = json.dumps(a)
        data[x] = []
        data[x].append(['a', 'b'])
        data[x].append(
            ['available', limits['absolute'][m] - limits['absolute'][u]])
        data[x].append(['used', limits['absolute'][u]])
        data[x] = json.dumps(data[x])
    return render_template('pie_chart.html',
                           data=data,
                           cloud=cloud
                           )
コード例 #14
0
ファイル: metrics.py プロジェクト: mnozary/cloudmesh
                    elif type == 'azure':
                        cloud = azure.cm_azure()

                    cloud.refresh()
                    self.clouds[cloud_name]['flavors'] = cloud.flavors
                    self.clouds[cloud_name]['images'] = cloud.images
                    self.clouds[cloud_name]['servers'] = cloud.servers

                except Exception, e:
                    print e
        else:
            try:
                type = self.clouds[cloud_name]['cm_type']

                if type == 'openstack':
                    cloud = openstack(cloud_name)

                elif type == 'eucalyptus':
                    # Where do i find the project name ? Is there a defaul one ?
                    # this is obvious;ly wrong as the tennent comes from profile
                    # TODO EUCALYPTUS DOES NOT YET WORK

                    cloud = eucalyptus(cloud_name, 'fg-82')

                elif type == 'azure':
                    cloud = azure.cm_azure()

                cloud.refresh()
                self.clouds[cloud_name]['flavors'] = cloud.flavors
                self.clouds[cloud_name]['images'] = cloud.images
                self.clouds[cloud_name]['servers'] = cloud.servers
コード例 #15
0
ファイル: metrics.py プロジェクト: lee212/cloudmesh
                    elif type == 'azure':
                        cloud = azure.cm_azure()

                    cloud.refresh()
                    self.clouds[cloud_name]['flavors'] = cloud.flavors
                    self.clouds[cloud_name]['images'] = cloud.images
                    self.clouds[cloud_name]['servers'] = cloud.servers

                except Exception, e:
                    print e
        else:
            try:
                type = self.clouds[cloud_name]['cm_type']

                if type == 'openstack':
                    cloud = openstack(cloud_name)

                elif type == 'eucalyptus':
                    # Where do i find the project name ? Is there a defaul one ?
                    # this is obvious;ly wrong as the tennent comes from profile
                    # TODO EUCALYPTUS DOES NOT YET WORK

                    cloud = eucalyptus(cloud_name, 'fg-82')

                elif type == 'azure':
                    cloud = azure.cm_azure()

                cloud.refresh()
                self.clouds[cloud_name]['flavors'] = cloud.flavors
                self.clouds[cloud_name]['images'] = cloud.images
                self.clouds[cloud_name]['servers'] = cloud.servers
コード例 #16
0
print 70 * "-"
p.write ("abc", {"hallo": "world"})
p.update ("abc", {"moon": "sun"})
pprint (p.get("abc"))

print 70 * "-"
p.write ("abc", {"saturn": "jupiter"})
pprint (p.get("abc"))


name = "sierra_openstack_grizzly"
# name = "india_openstack_essex"

credential = p.server.config["keystone"][name]

cloud = openstack(name, credential=credential)



# cloud.refresh("flavors")

# print cloud.flavors

# pprint (cloud.get_token(credential=credential))

# pprint (cloud.get_tenants(credential))
# pprint (cloud.get_users(credential))
# pprint (cloud.get_users())


c = openstack(name)
コード例 #17
0
ファイル: test_compute.py プロジェクト: jklingin/cloudmesh
 def setup(self):
     self.configuration = cm_config()
     self.name = self.configuration.active()[0]
     print "ACTIVE CLOUD", self.name
     self.cloud = openstack(self.name)
     print "LOADED CLOUD"