示例#1
0
    def loadDeploySchema(self):

        xmlparse = XMLParse(
            xml_file_path=DEPLOY_DESIGN_FILE_URL['DeploySchema'])
        deploySchema = xmlparse.query('DeploySchema')
        for schema in deploySchema:
            targetInstanceList = schema[0]._children
            containerInstanceList = schema[1]._children
            targetInstanceContainerInstanceMapping = schema[2]._children
            self.deploySchemaList.append(
                DeploySchema(targetInstList=targetInstanceList,
                             containerInstList=containerInstanceList,
                             targetRoleMapping=self.loadTargetRoleMapping(),
                             targetInstContainerMapping=
                             targetInstanceContainerInstanceMapping,
                             schema_name=self.xmlcmdbobserver.getDataCenter()
                             [0].attrib['name']))
        return
示例#2
0
	def importTargetList(self):
		xmlparse = XMLParse(xml_file_path=DEPLOY_DESIGN_FILE_URL['Target'])
		for target in xmlparse.query('Target'):
			targetProviderList = []
			componentName = target.attrib['SpecName']
			componentVersion = target.attrib['specVersion']
			runtime_type = target._children[0]._children[0]._children[1].\
				_children[1]._children[0].attrib['Type']

			for element in target._children:
				if element.tag == 'TargetProvider':
					targetProviderList.append(element)

			targetProvider = targetProviderList
			self.targetList.append(DeployTarget(componentName = componentName,
												componentVersion = componentVersion,
												runtime_type = runtime_type,
												targetProvider = targetProvider))
示例#3
0
    def loadDeploySchema(self):

        xmlparse = XMLParse(xml_file_path=DEPLOY_DESIGN_FILE_URL["DeploySchema"])
        deploySchema = xmlparse.query("DeploySchema")
        for schema in deploySchema:
            targetInstanceList = schema[0]._children
            containerInstanceList = schema[1]._children
            targetInstanceContainerInstanceMapping = schema[2]._children
            self.deploySchemaList.append(
                DeploySchema(
                    targetInstList=targetInstanceList,
                    containerInstList=containerInstanceList,
                    targetRoleMapping=self.loadTargetRoleMapping(),
                    targetInstContainerMapping=targetInstanceContainerInstanceMapping,
                    schema_name=self.xmlcmdbobserver.getDataCenter()[0].attrib["name"],
                )
            )
        return
示例#4
0
class XMLCMDBObserver(EnvResouceObserver):
	
	def __init__(self):
		self.xmlparse = XMLParse(
			xml_file_path=DEPLOY_DESIGN_FILE_URL['EnvResource'])
		
	def getResource(self, tagname):
		return [element for element in self.xmlparse.query(tagname)]

	def getDataCenter(self):
		return self.getResource('DataCenter')

	def getNetwork(self):
		return self.getResource('Network')
	

	def getHostlist(self):
		return self.getResource('Host')

	def getHostByContainerUID(self, containerUID):

		for host in self.getHostlist():

			containers = host.findall("./Software/Containers")

			for container in containers:

				for ref in container._children:

					if ref.text != None and containerUID == getoutCurlyBraces(ref.text):

						return host
	
	def getHostByUID(self, UID):
		hosts = self.getHostlist()
		#print hosts
		for host in hosts:
			#print host
			if host.attrib['ResourceUID'] == UID:
				return host

	def getContainerlist(self):
		return self.getResource('Container')
示例#5
0
class XMLCMDBObserver(EnvResouceObserver):
    def __init__(self):
        self.xmlparse = XMLParse(
            xml_file_path=DEPLOY_DESIGN_FILE_URL['EnvResource'])

    def getResource(self, tagname):
        return [element for element in self.xmlparse.query(tagname)]

    def getDataCenter(self):
        return self.getResource('DataCenter')

    def getNetwork(self):
        return self.getResource('Network')

    def getHostlist(self):
        return self.getResource('Host')

    def getHostByContainerUID(self, containerUID):

        for host in self.getHostlist():

            containers = host.findall("./Software/Containers")

            for container in containers:

                for ref in container._children:

                    if ref.text != None and containerUID == getoutCurlyBraces(
                            ref.text):

                        return host

    def getHostByUID(self, UID):
        hosts = self.getHostlist()
        #print hosts
        for host in hosts:
            #print host
            if host.attrib['ResourceUID'] == UID:
                return host

    def getContainerlist(self):
        return self.getResource('Container')
示例#6
0
	def getTargetNameByUID(self, UID):
		xmlparse = XMLParse(xml_file_path=DEPLOY_DESIGN_FILE_URL['Target'])
		for target in  xmlparse.query('Target'):
			
			if UID == target.attrib['TargetUID']:
				return target.attrib['SpecName']
示例#7
0
 def loadTargetRoleMapping(self):
     xmlparse = XMLParse(xml_file_path=DEPLOY_DESIGN_FILE_URL["TargetRoleMapping"])
     targetRoleMapping = xmlparse.query("TargetToRoleMapping")
     return targetRoleMapping[0]._children
示例#8
0
 def loadRole2Devices(self):
     xmlparse = XMLParse(
         xml_file_path=DEPLOY_DESIGN_FILE_URL['Role2DeviceMapping'])
     return xmlparse.query('MappingItem')
示例#9
0
文件: role.py 项目: jamesduan/devops
 def load_roles(self):
     xmlparse = XMLParse(xml_file_path=DEPLOY_DESIGN_FILE_URL['Role'])
     return xmlparse.query('Role')
示例#10
0
文件: role.py 项目: jamesduan/devops
	def load_roles(self):
		xmlparse = XMLParse(xml_file_path=DEPLOY_DESIGN_FILE_URL['Role'])
		return xmlparse.query('Role')
示例#11
0
	def __init__(self):
		self.xmlparse = XMLParse(
			xml_file_path=DEPLOY_DESIGN_FILE_URL['EnvResource'])
示例#12
0
 def __init__(self):
     self.xmlparse = XMLParse(
         xml_file_path=DEPLOY_DESIGN_FILE_URL['EnvResource'])
示例#13
0
 def loadTargetRoleMapping(self):
     xmlparse = XMLParse(
         xml_file_path=DEPLOY_DESIGN_FILE_URL['TargetRoleMapping'])
     targetRoleMapping = xmlparse.query('TargetToRoleMapping')
     return targetRoleMapping[0]._children
示例#14
0
	def loadRole2Devices(self):
		xmlparse = XMLParse(xml_file_path=DEPLOY_DESIGN_FILE_URL['Role2DeviceMapping'])
		return xmlparse.query('MappingItem')