def _iterate(self, items): infoList = [] for item in items: info = CloudInfo() info.populate(item) infoList.append(info) return infoList
def _vmDetail(self, vmId): res = self.cloud.getVmInfo(int(vmId)) vm = Util.etree_from_text(res) if self.portTranslationClient: self.portTranslationClient.addPortTranslationToSingleVmInfo(vm) info = CloudInfo() info.populate(vm) self._addHostnameElement(info) return info
def testPopulate(self): xml = ''' <root> <level1> <id1>ID1</id1> <level2> <level3> <id3>ID3</id3> </level3> </level2> <id4>ID4</id4> </level1> </root> ''' root = etree.fromstring(xml) info = CloudInfo() info.populate(root) self.assertEqual('ID1',info.level1_id1) self.assertEqual('ID3',info.level1_level2_level3_id3) self.assertEqual('ID4',info.level1_id4)
def _nodeDetail(self, nodeId): res = self.cloud.getHostInfo(int(nodeId)) host = Util.etree_from_text(res) info = CloudInfo() info.populate(host) return info