def do_info(self, args): try: doParser = self.arg_info() doArgs = doParser.parse_args(shlex.split(args)) allPimages = self.api.Users(doArgs.account).Pimages.Get() userAppliances = self.api.Users(doArgs.account).Appliances.Getall() printer.out("Getting published image with id [" + doArgs.id + "] ...") Exist = False for item in allPimages.publishImages.publishImage: if item.dbId == doArgs.id: printer.out("Published image informations :") for item2 in userAppliances.appliances.appliance: if item.applianceUri == item2.uri: os = item2.distributionName + " " + item2.archName if item.published: published = "Yes" else: published = "No" Exist = True table = Texttable(200) table.set_cols_align(["l", "l"]) table.add_row(["Name", item.name]) table.add_row(["ID", item.dbId]) table.add_row(["Cloud", item.format]) table.add_row(["Version", item.version]) table.add_row(["Revision", item.revision]) table.add_row(["Uri", item.uri]) table.add_row(["OS", os]) table.add_row(["Template ID", extractId(item.uri)]) table.add_row(["Generated Image Id", extractId(item.imageUri)]) table.add_row(["Created", item.created.strftime("%Y-%m-%d %H:%M:%S")]) table.add_row(["Size", size(item.size)]) table.add_row(["Description", item.description]) table.add_row(["Published", published]) table.add_row(["Published Cloud Id", item.cloudId]) print table.draw() + "\n" if not Exist: printer.out("Published image with ID [" + doArgs.id + "] was not found.") return 0 except ArgumentParserError as e: printer.out("ERROR: In Arguments: " + str(e), printer.ERROR) self.help_info() except Exception as e: return handle_uforge_exception(e)
def do_info(self, args): try: doParser = self.arg_info() doArgs = doParser.parse_args(shlex.split(args)) userAppliance = self.api.Users(doArgs.account).Appliances(doArgs.id).Get() printer.out("Informations about [" + userAppliance.name + "]:") table = Texttable(200) table.set_cols_align(["l", "l"]) table.add_row(["Name", userAppliance.name]) table.add_row(["Id", userAppliance.dbId]) table.add_row(["Version", userAppliance.version]) table.add_row(["Uri", userAppliance.uri]) table.add_row(["Created", userAppliance.created.strftime("%Y-%m-%d %H:%M:%S")]) table.add_row(["Last Modified", userAppliance.created.strftime("%Y-%m-%d %H:%M:%S")]) table.add_row(["Last Package Update", userAppliance.lastPkgUpdate.strftime("%Y-%m-%d %H:%M:%S")]) table.add_row(["Available OS Updates", userAppliance.nbUpdates]) if userAppliance.shared: shared = "Yes" else: shared = "No" table.add_row(["Shared", shared]) if userAppliance.imported: imported = "Yes" else: imported = "No" table.add_row(["Cloned from App Store", imported]) table.add_row(["Description", userAppliance.description]) print table.draw() + "\n" printer.out("OS Profile", printer.INFO) table = Texttable(200) table.set_cols_align(["l", "l"]) table.add_row(["OS", userAppliance.distributionName + " " + userAppliance.archName]) if userAppliance.osProfile is not None: table.add_row(["OS Profile Type", userAppliance.osProfile.name]) else: table.add_row(["OS Profile", "None"]) if userAppliance.osProfile is not None: packagesUri = extractId(userAppliance.osProfile.packagesUri, operation=False) allPkgs = self.api.Users(doArgs.account).Appliances(packagesUri[1]).Osprofile(packagesUri[0]).Pkgs.Getall() table.add_row(["# OS Packages", str(len(allPkgs.pkgs.pkg))]) if userAppliance.osProfile is not None: pkgsTotalSize = 0 for pkg in allPkgs.pkgs.pkg: pkgsTotalSize = pkgsTotalSize + pkg.size osTotalSize = pkgsTotalSize + userAppliance.size else: osTotalSize = userAppliance.size table.add_row(["Total OS Profile Size", size(osTotalSize)]) pkgNumber = 0 allPkgs = generics_utils.order_list_object_by(allPkgs.pkgs.pkg, "name") if doArgs.all: for pkg in allPkgs: pkgNumber = pkgNumber + 1 table.add_row(["Packages N " + str(pkgNumber), pkg.name + " " + pkg.version + " " + pkg.arch + " (" + size(pkg.size) + ")"]) print table.draw() + "\n" printer.out("Install Settings", printer.INFO) table = Texttable(200) table.set_cols_align(["l", "l"]) if userAppliance.installProfile.adminPasswordAuto: table.add_row(["Password", userAppliance.installProfile.adminPassword]) else: table.add_row(["Password", "asked during first boot or install"]) if userAppliance.installProfile.internetSettingsAuto: table.add_row(["Internet Settings", "DHCP"]) else: table.add_row(["Internet Settings", "asked during first boot or install"]) if userAppliance.installProfile.skipLicenses: table.add_row(["Licensing", "skipped"]) else: table.add_row(["Licensing", "shown at first boot or install"]) if userAppliance.installProfile.timezoneAuto: table.add_row(["Time Zone", userAppliance.installProfile.timezone]) else: table.add_row(["Time Zone", "asked during first boot or install"]) if userAppliance.installProfile.partitionTable.disks.disk is not None: diskNumber = 0 for disk in userAppliance.installProfile.partitionTable.disks.disk: diskNumber = diskNumber + 1 table.add_row(["Disk " + str(diskNumber), disk.name + " " + str(disk.size) + " MB " + disk.partitionType]) if disk.partitions.partition is not None: partitionNumber = 0 for partition in disk.partitions.partition: partitionNumber = partitionNumber + 1 if partition.fstype is not None: fstype = partition.fstype else: fstype = "" if partition.mpoint is not None: mpoint = partition.mpoint else: mpoint = "" if partition.label is not None: label = partition.label else: label = "" if partition.growable: growable = "grow" else: growable = "" table.add_row(["Partition " + str(partitionNumber), disk.name + partition.name + " " + str(partition.partitionSize) + " MB " + fstype + " " + mpoint + " " + label + " " + growable]) if partition.logicalPartitions.logicalPartition is not None: logicalPartitionNumber = 0 for logicalPartition4 in partition.logicalPartitions.logicalPartition: logicalPartitionNumber = logicalPartitionNumber + 1 if logicalPartition4.fstype is not None: fstype2 = logicalPartition4.fstype else: fstype2 = "" if logicalPartition4.mpoint is not None: mpoint2 = logicalPartition4.mpoint else: mpoint2 = "" if logicalPartition4.label is not None: label2 = logicalPartition4.label else: label2 = "" if logicalPartition4.growable: growable2 = "grow" else: growable2 = "" table.add_row(["Logical Partition " + str(logicalPartitionNumber), logicalPartition4.name + " " + str(logicalPartition4.partitionSize) + " MB " + fstype2 + " " + mpoint2 + " " + label2 + " " + growable2]) print table.draw() + "\n" printer.out("Projects", printer.INFO) table = Texttable(200) table.set_cols_align(["l", "l"]) allProjects = self.api.Users(doArgs.account).Appliances(userAppliance.dbId).Projects.Getall() if allProjects is None: totalProjects = "0" else: totalProjects = str(len(allProjects.projects.project)) table.add_row(["# Projects", totalProjects]) if doArgs.all and totalProjects != "0": projectNumber = 0 for project in allProjects.projects.project: projectNumber = projectNumber + 1 table.add_row(["Project N " + str(projectNumber), project.name + " " + project.version + " (" + project.size + " bytes)"]) print table.draw() + "\n" printer.out("My Software", printer.INFO) table = Texttable(200) table.set_cols_align(["l", "l"]) allSoftware = self.api.Users(doArgs.account).Appliances(userAppliance.dbId).Mysoftware.Getall() if allSoftware is None: totalSoftwares = "0" else: totalSoftwares = str(len(allSoftware.mySoftwareList.mySoftware)) table.add_row(["# Custom Software", totalSoftwares]) if doArgs.all and totalSoftwares != "0": softwareNumber = 0 for software in allSoftware.mySoftwareList.mySoftware: softwareNumber = softwareNumber + 1 table.add_row(["Project N " + str(softwareNumber), software.name + " " + software.version + " (" + software.size + " bytes)"]) print table.draw() + "\n" printer.out("Configuration", printer.INFO) table = Texttable(200) table.set_cols_align(["l", "l"]) if userAppliance.oasPackageUri is None: table.add_row(["OAS Pkg Uploaded", "no"]) else: Oas = self.api.Users(doArgs.account).Appliances(userAppliance.dbId).Oas(extractId(userAppliance.oasPackageUri)).Get() if not Oas.uploaded: table.add_row(["OAS Pkg Uploaded", "no"]) else: table.add_row(["OAS Pkg Uploaded", "yes"]) table.add_row(["OAS Pkg", Oas.name]) table.add_row(["OAS Pkg Size", size(Oas.size)]) if Oas.licenseUploaded: table.add_row(["OAS Licence Uploaded", "yes"]) else: table.add_row(["OAS Licence Uploaded", "no"]) if userAppliance.bootScriptsUri is None: table.add_row(["# Boot Scripts", "0"]) else: bootScripts = self.api.Users(doArgs.account).Appliances(userAppliance.dbId).Bootscripts(extractId(userAppliance.bootScriptsUri)).Getall() table.add_row(["# Boot Scripts", str(len(bootScripts.bootScripts.bootScript))]) bootScriptsNumber = 0 for item in bootScripts.bootScripts.bootScript: bootScriptsNumber = bootScriptsNumber + 1 table.add_row(["Boot Script N 1 Details", item.name + " " + item.bootType]) print table.draw() + "\n" return 0 except ArgumentParserError as e: printer.out("ERROR: In Arguments: " + str(e), printer.ERROR) self.help_info() except Exception as e: return handle_uforge_exception(e)