当前位置: 首页>>代码示例>>Python>>正文


Python Authentication.getCeilometerClient方法代码示例

本文整理汇总了Python中Authentication.getCeilometerClient方法的典型用法代码示例。如果您正苦于以下问题:Python Authentication.getCeilometerClient方法的具体用法?Python Authentication.getCeilometerClient怎么用?Python Authentication.getCeilometerClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Authentication的用法示例。


在下文中一共展示了Authentication.getCeilometerClient方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
class InstancePreReq:

    def __init__(self):

        self.aObj = Authentication("yess");
        self.nova = self.aObj.getComputeClient();
        self.neutron = self.aObj.getNeutronClient();
        self.keystone= self.aObj.getKeystoneClient();
        self.glance = self.aObj.getGlanceClient();
        self.cclient = self.aObj.getCeilometerClient();

    def getAllFlavours(self):

        obj= self.nova.flavors.list();
        flvrs=[];

        for each in obj:
            flvrs.append(each.name);

        return flvrs;

    def getAllImages(self):

        obj= self.nova.images.list();
        imgz=[];

        for each in obj:
            imgz.append(each.name);

        return imgz;

    def getAllNetworks(self):

        obj= self.nova.networks.list();
        netwrk=[];

        for each in obj:
            netwrk.append(each.label);

        return netwrk;

    def getKeypairsList(self):

        obj= self.nova.keypairs.list();
        keyz=[];

        for each in obj:
            keyz.append(each.name);

        return keyz;

    def getSecurityList(self):

        obj= self.nova.security_groups.list();
        scrty=[];

        for each in obj:
            scrty.append(each.name);

        return scrty;
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:62,代码来源:InstancePreReq.py

示例2: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
class createKey:

    def __init__(self):

        self.aObj = Authentication("msssg");
        self.nova = self.aObj.getComputeClient();
        self.neutron = self.aObj.getNeutronClient();
        self.keystone = self.aObj.getKeystoneClient();
        self.glance = self.aObj.getGlanceClient();
        self.cclient = self.aObj.getCeilometerClient();

    def createKeyPlease(self):

        keypair_name = "maKey";
        self.nova.keypairs.list();
        ts = time.time();
        st = datetime.datetime.fromtimestamp(ts).strftime('%Y%m%d%H%M%S');
        stri = keypair_name+st;
        print stri;
        self.nova.keypairs.create(name=stri)

    def getKeypairsList(self):

        obj = self.nova.keypairs.list();
        keyz = [];
        for each in obj:
            keyz.append(each.name);
        return keyz;


# obj = createKey();
# obj.createKeyPlease();
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:34,代码来源:createKey.py

示例3: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
class BillGeneratePreReq:

    def __init__(self):

        self.aObj = Authentication("yess");
        self.nova = self.aObj.getComputeClient();
        self.neutron = self.aObj.getNeutronClient();
        self.keystone= self.aObj.getKeystoneClient();
        self.glance = self.aObj.getGlanceClient();
        self.cclient = self.aObj.getCeilometerClient();
        self.dbObj = MongoDatabase();

    def getAllBillsCategories(self):

    	checki = self.dbObj.getAllBillCat();
    	if(checki==False):
    		return False
    	else:
    		return checki;

    def getAllRunningInstances(self):

    	servers = self.nova.servers.list();
    	return servers;

# obj = BillGeneratePreReq();
# obj.getAllBillsCategories();
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:29,代码来源:BillGeneratePreReq.py

示例4: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
class RouterPreReq:

    def __init__(self):

        self.aObj = Authentication("yess");
        self.nova = self.aObj.getComputeClient();
        self.neutron = self.aObj.getNeutronClient();
        self.keystone= self.aObj.getKeystoneClient();
        self.glance = self.aObj.getGlanceClient();
        self.cclient = self.aObj.getCeilometerClient();

    def getAllSubnets(self):
        subnets = self.neutron.list_subnets();
        subList=[];

        for each in subnets['subnets']:
            subList.append(each['name']);

        return subList;

    def getAllTenants(self):
        
        tenants = self.keystone.tenants.list();

        tenNames=[];
        
        for each in tenants:
            tenNames.append(each.name);

        return tenNames;

    def getAllNetworks(self):

        obj= self.nova.networks.list();
        netwrk=[];

        for each in obj:
            netwrk.append(each.label);

        return netwrk;
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:42,代码来源:RouterPreReq.py

示例5: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
class createBillCategory:

	def __init__(self,billName,flvr,price):

		self.aObj = Authentication("yess");
		self.nova = self.aObj.getComputeClient();
		self.neutron = self.aObj.getNeutronClient();
		self.keystone= self.aObj.getKeystoneClient();
		self.glance = self.aObj.getGlanceClient();
		self.cclient = self.aObj.getCeilometerClient();
		self.price=price;
		self.billName=billName;
		self.flvrNames=flvr;
		self.dbObj = MongoDatabase();

	def saveBillCategory(self):

		dicti={};
		
		try:

			for f,b in zip(self.flvrNames,self.price):
				f = f.replace(".","\uff0e");
				dicti[f]=b
		
		except:
			print 'exception..'
		
		store={"name":self.billName,"type":"flvr_based","priceList":dicti};
		print store;
		self.addToDatabase(store);

	def addToDatabase(self,data):
		self.dbObj.addBillCategory(data);


# prici={ "m1\\uff0elarge":"50","m1\\uff0esmall":"60","m1\\uff0emini":"70","m1\\uff0exlarge":"80","m1\\uff0etiny":"90" }
# obj = createBillCategory("niki_minhaj","flvr_based",prici);
# obj.saveBillCategory();
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:41,代码来源:createBillCategory.py

示例6: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
class InstanceBill:

	def __init__(self,instnc,catg):

		self.aObj = Authentication("yess");
		self.nova = self.aObj.getComputeClient();
		self.neutron = self.aObj.getNeutronClient();
		self.keystone= self.aObj.getKeystoneClient();
		self.glance = self.aObj.getGlanceClient();
		self.cclient = self.aObj.getCeilometerClient();
		self.inst = instnc;
		slef.catg = catg;

	def getInstanceID(self):

		instanceList = nova.servers.list(search_opts={'all_tenants': 1});

		for i in range(0,len(instanceList),1):
			if(instanceList[i].name==self.inst):
		    	return instncID = instanceList[i].id;

	def getTopSamples(self):

		
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:24,代码来源:InstanceBill.py

示例7: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
class makeBillPreReq:
    
    def __init__(self):

        self.aObj = Authentication("yess");
        self.nova = self.aObj.getComputeClient();
        self.neutron = self.aObj.getNeutronClient();
        self.keystone = self.aObj.getKeystoneClient();
        self.glance = self.aObj.getGlanceClient();
        self.cclient = self.aObj.getCeilometerClient();
    
    def getAllFlavours(self):

        return self.nova.flavors.list();

    def getMyFlavourDetails(self,flvrName):

	    flvrs = self.nova.flavors.list();

	    for each in flvrs:
	    	if (each.name==flvrName):
	    		return each;

		return None;
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:26,代码来源:makeBillPreReq.py

示例8: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
from pprint import pprint
from Authentication import *


authObj1=Authentication("zaib")
nova = authObj1.getComputeClient()


neutron = authObj1.getNeutronClient()


keystone = authObj1.getKeystoneClient()



cclient = authObj1.getCeilometerClient()

glance = authObj1.getGlanceClient()

class Events:
    def __init__(self):
        i=0
    def getInstanceName(self,temp):
        id=''
        traits=temp.traits
        for each2 in traits:
                if(each2['name']=='instance_id'):
                    id=each2['value']
                    break
        instanceList=nova.servers.list(search_opts={'all_tenants': 1},marker=None,limit=None)
        name=''
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:33,代码来源:Events.py

示例9: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
class Router:

        def __init__(self,arguments):

            self.aObj = Authentication("yess");
            self.nova = self.aObj.getComputeClient();
            self.neutron = self.aObj.getNeutronClient();
            self.keystone= self.aObj.getKeystoneClient();
            self.glance = self.aObj.getGlanceClient();
            self.cclient = self.aObj.getCeilometerClient();
            self.args=arguments;

        def createRouter(self):

            routerName = self.args[4];
            desiredSubnet = self.args[3];
            desiredNet = self.args[2];
            tenantName = self.args[1];


            if (self.checkDuplicate(routerName,tenantName)==False):
                
                netId=None;
                subnetId=None;
                routerId=None;


                neti = self.nova.networks.list()
                for x in neti:
                    if x.label == desiredNet:
                        netId = x.id;
                        break

                bodyVal= {
                        "router": {
                        "name": routerName,
                        "external_gateway_info":
                            {
                            "network_id": netId,
                            "enable_snat": "True",
                            },
                        "admin_state_up": "true"
                    }
                }

                subnets = self.neutron.list_subnets();
                for each in subnets['subnets']:
                    if each['name'] == desiredSubnet:
                        subnetId = each['id']

                subNeti = {"subnet_id": subnetId}
                self.neutron.create_router(body=bodyVal);
                time.sleep(1);
                rtrLists = self.neutron.list_routers();

                for each in rtrLists['routers']:
                    if each['name'] == routerName:
                            routerId = each['id']
                
                    interfaceArg = {}
                    self.neutron.add_interface_router(routerId,body=subNeti);
                    print "Router Created with name ", routerName
            else:
                print "Router Already Exists for this user"; 

        def checkDuplicate(self,myName,myTenant):

            rtrLists = self.neutron.list_routers();
            tenant = self.keystone.tenants.list();

            for each in tenant:
                if (each.name==myTenant):
                    myId = each.id;

            for each in rtrLists['routers']:
                if ( (each['tenant_id'] == myId) & (each['name'] == myName) ):
                    return True

            return False
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:81,代码来源:Router.py

示例10: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
class AlarmPreReq:

    def __init__(self):

        self.aObj = Authentication("yess");
        self.nova = self.aObj.getComputeClient();
        self.neutron = self.aObj.getNeutronClient();
        self.keystone= self.aObj.getKeystoneClient();
        self.glance = self.aObj.getGlanceClient();
        self.cclient = self.aObj.getCeilometerClient();

    def getServiceName(self,meterName):
        serviceName=''
        if(re.match(r'storage', meterName)):
            serviceName="swift"
        elif(re.match(r'image',meterName)):
            serviceName="glance"
        elif(re.match(r'volume',meterName)):
            serviceName="cinder"
        else:
            serviceName="nova"

        return serviceName

    def getAllMeters(self):

        tenantList=self.keystone.tenants.list(limit=None,marker=None)
        metersDict={}
        list1=[]
        meterList=[]
        name=''

        for each1 in tenantList:
            if(each1.name=='admin'):
                query0 = [dict(field='project_id', op='eq', value=each1.id)]
                list1=self.cclient.meters.list(q=query0,limit=2000)

        temp=[]
        novaMeters=[]
        for each in list1:
            name= self.getServiceName(each.name)
            if(name=='nova'):
                temp.append(each.name)

        novaMeters=list(set(temp))
        return novaMeters;

    def getInstances(self):
        obj= self.nova.servers.list();
        sers=[];

        for each in obj:
            sers.append(each.name);

        return sers;

    def getAllStats(self):

        statsi = ['count','max','sum','avg','min'];
        return statsi

    def getAllComparisonOperators(self):

        compOpr = ['gt','lt','ne','ge','le','eq']
        return compOpr;

    def getAllAlarmList(self):
        return self.cclient.alarms.list();

    def getAllMetersValues(self,alList):

        instanceList = self.nova.servers.list(search_opts={'all_tenants': 1});

        for i in range(0,len(alList)):
            print '>>--- aList --<<'
            instName = alList[i].description;
            mtr = alList[i].threshold_rule['meter_name'];
            val = self.getMeterValue(instName,mtr);            
            val = self.convertVal(val);         
            alList[i].severity = val;
            print '-->',val;

        return alList;

    def convertVal(self,val):

        val = str(val);

        if (val.find("['") != -1):
            
            val = val.replace("['","");
            val = val.replace("']","");
            return val;

        else:
            return val;

    def getInstanceID(self,instName):

        for i in range(0,len(instanceList),1):
#.........这里部分代码省略.........
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:103,代码来源:AlarmPreReq.py

示例11: __init__

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getCeilometerClient [as 别名]
class GenerateBill:

	def __init__(self,cat,instName):

		inst = str(instName);
		cat = str(cat);
		print 'INST ->', inst;
		print 'CATG ->', cat;
		
		self.aObj = Authentication("yess");
		self.nova = self.aObj.getComputeClient();
		self.neutron = self.aObj.getNeutronClient();
		self.keystone= self.aObj.getKeystoneClient();
		self.glance = self.aObj.getGlanceClient();
		self.cclient = self.aObj.getCeilometerClient();

		self.dbObj = MongoDatabase();
		self.cat = cat;
		self.instName = inst;

	def getInstanceStartTime(self):

		obj1=GetInstanceStartTime()
		startTime = obj1.getEventTime('admin',self.instName)
		return startTime;

	def getInstanceTotalRunningTime(self):

		startTime = self.getInstanceStartTime();
		currTime = datetime.utcnow();

		print "STime  -->> ",startTime
		print "curr   -->> ",currTime

		hmsStrt = self.getTime(startTime);
		hmsCurr = self.getTime(currTime);
		
		hours=0;
		minutes=0;
		seconds=0;

		if(len(hmsStrt)==3 & len(hmsCurr)==3):

			hrs = int(hmsStrt[0]);
			mins = int(hmsStrt[1]);
			secs = int(hmsStrt[2]);
			start = timedelta(hours=hrs,minutes=mins,seconds=secs);

			hrs = int(hmsCurr[0]);
			mins = int(hmsCurr[1]);
			secs = int(hmsCurr[2]);
			end = timedelta(hours=hrs,minutes=mins, seconds=secs)

		return end - start;

	def getTime(self,currTime):

		currTime = str(currTime);

		if ('T' in currTime):
			currTime = currTime.replace("T", " ");

		dati = currTime.split(' ');
		timi = dati[1].split('.');
		hms = timi[0].split(":");

		return hms

	def getDBTime(self,currTime):

		currTime = str(currTime);
		if ('T' in currTime):
			currTime = currTime.replace("T", " ");
		dati = currTime.split(' ');
		timi = dati[1].split('.');
		return timi[0]

	def getDate(self,currDate):

		currDate = str(currDate);

		if ('T' in currDate):
			currDate = currDate.replace("T", " ");

		dati = currDate.split(' ');		
		return dati[0]

	def getFlavourName(self):

		ser = self.nova.servers.list();
		flv = self.nova.flavors.list();

		flvName="";
		for each in ser:
			if(each.name==(self.instName)):
			    for each2 in flv:
			        if (each2.id == each.flavor['id']):
			            flvName = each2.name
			else:
				return None;
#.........这里部分代码省略.........
开发者ID:zaibi099,项目名称:InspectorCloud,代码行数:103,代码来源:GenerateBill.py


注:本文中的Authentication.getCeilometerClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。