def populateCloud(self, cloud, component, topology): if (cloud is None): cloud = StackOps.cloud() if (component is not None): cloud.add_component(component) if (topology is not None): cloud.set_topology(topology) return cloud
def createNode(self,cloud): machine = Machine() operatingsystem = OperatingSystem() # CPU Info type_list = machine.getCPUType() speed_list = machine.getCPUSpeed() cpu_list = [] for name, speed in map(None, type_list, speed_list): cpu_list.append(self.populateCPU(name, int(speed.split(".")[0]), 1)) cpus = self.populateCPUs(cpu_list) # Memory memory = machine.getMemoryAvailable() # Network nic_list = [] iface_list = machine.getIfaceList() for iface in iface_list: nic_list.append(self.populateNIC(iface, "", machine.getIfaceVendorList(iface))) nics = self.populateNICs(nic_list) # Partitions partition_list = [] blockdev_list = machine.getBlockDeviceList() for blockdev in blockdev_list: partition_list.append(self.populatePartition(blockdev["mountpoint"], blockdev["device"], blockdev["size"], blockdev["used"])) partitions = self.populatePartitions(partition_list) # Hardware information hardware = self.populateHardware(cpus, memory, nics, machine.getVirtualization(), partitions) # OS information # uname description uname = operatingsystem.getUname() # network configuration hostname = operatingsystem.getHostname() nameserver_list = operatingsystem.getNameservers() iface_list = operatingsystem.getNetworkConfiguration() network = self.populateNetwork(hostname, nameserver_list, iface_list) os = self.populateOS(uname, network) # Software information software = self.populateSoftware(os) # Cloud components if (cloud is None): cloud = StackOps.cloud() # Node information node = self.populateNode(hardware, software, cloud) node.export(sys.stdout, 0) return node