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
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))
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
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')
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')
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']
def loadTargetRoleMapping(self): xmlparse = XMLParse(xml_file_path=DEPLOY_DESIGN_FILE_URL["TargetRoleMapping"]) targetRoleMapping = xmlparse.query("TargetToRoleMapping") return targetRoleMapping[0]._children
def loadRole2Devices(self): xmlparse = XMLParse( xml_file_path=DEPLOY_DESIGN_FILE_URL['Role2DeviceMapping']) return xmlparse.query('MappingItem')
def load_roles(self): xmlparse = XMLParse(xml_file_path=DEPLOY_DESIGN_FILE_URL['Role']) return xmlparse.query('Role')
def __init__(self): self.xmlparse = XMLParse( xml_file_path=DEPLOY_DESIGN_FILE_URL['EnvResource'])
def loadTargetRoleMapping(self): xmlparse = XMLParse( xml_file_path=DEPLOY_DESIGN_FILE_URL['TargetRoleMapping']) targetRoleMapping = xmlparse.query('TargetToRoleMapping') return targetRoleMapping[0]._children
def loadRole2Devices(self): xmlparse = XMLParse(xml_file_path=DEPLOY_DESIGN_FILE_URL['Role2DeviceMapping']) return xmlparse.query('MappingItem')