def find_compatible_virtual_datacenter(context, template): """ Find a virtual datacenter compatible with the given template. """ template_type = template.getDiskFormatType() cloud = context.getCloudService() for type in HypervisorType.values(): if type.isCompatible(template_type): vdc = cloud.findVirtualDatacenter(VirtualDatacenterPredicates.type(type)) if vdc: return vdc
def find_compatible_virtual_datacenters(context, template): """ Find a virtual datacenter compatible with the template. """ cloud = context.getCloudService() all = cloud.listVirtualDatacenters( VirtualDatacenterPredicates.datacenter(template.getDatacenter())) def compatible(vdc): type = vdc.getHypervisorType() res = type.isCompatible(template.getDiskFormatType()) log.debug("%s compatible with source format: %s" % (vdc.getName(), res)) if not res: conv = template.listConversions(type, ConversionState.FINISHED) res = len(conv) > 0 log.debug("%s compatible with conversions: %s" % (vdc.getName(), res)) return res return filter(compatible, all)
def find_compatible_virtual_datacenters(context, template): """ Find a virtual datacenter compatible with the template. """ cloud = context.getCloudService() all = cloud.listVirtualDatacenters( VirtualDatacenterPredicates.datacenter(template.getDatacenter())) def compatible(vdc): type = vdc.getHypervisorType() res = type.isCompatible(template.getDiskFormatType()) log.debug("%s compatible with source format: %s" % (vdc.getName(), res)) if not res: conv = template.listConversions(type, ConversionState.FINISHED) res = len(conv) > 0 log.debug("%s compatible with conversions: %s" % (vdc.getName(), res)) return res return filter(compatible, all)
def find(self, args): """ Find a virtual datacenter given its name """ # Parse user input to get the name of the virtual datacenter parser = OptionParser(usage="vdc find <options>") parser.add_option("-n", "--name", help="The name of the virtual datacenter to find", dest="name") (options, args) = parser.parse_args(args) name = options.name if not name: parser.print_help() return # Once user input has been read, find the virtual datacenter try: cloud = self._context.getCloudService() vdc = cloud.findVirtualDatacenter( VirtualDatacenterPredicates.name(name)) if vdc: pprint_vdcs([vdc]) else: print "No virtual datacenter found with name: %s" % name except (AbiquoException, AuthorizationException), ex: print "Error: %s" % ex.getMessage()
def tiers(self, args): """ List the tiers available in a virtual datacenter """ parser = OptionParser(usage="vdc tiers <options>") parser.add_option("-n", "--name", help="The name of the virtual datacenter", dest="name") (options, args) = parser.parse_args(args) name = options.name if not name: parser.print_help() return # Once user input has been read, find the virtual datacenter try: cloud = self._context.getCloudService() vdc = cloud.findVirtualDatacenter( VirtualDatacenterPredicates.name(name)) if vdc: tiers = vdc.listStorageTiers() pprint_tiers(tiers) else: print "No virtual datacenter found with name: %s" % name except (AbiquoException, AuthorizationException), ex: print "Error: %s" % ex.getMessage()
def find_compatible_virtual_datacenters(context, type, datacenter): """ Find a virtual datacenter compatible with the type and datacenter.. """ cloud = context.getCloudService() all = cloud.listVirtualDatacenters( VirtualDatacenterPredicates.datacenter(datacenter)) return filter(lambda vdc: vdc.getHypervisorType().isCompatible(type), all)
def find_compatible_virtual_datacenters(context, type, datacenter): """ Find a virtual datacenter compatible with the type and datacenter. """ cloud = context.getCloudService() all = cloud.listVirtualDatacenters( VirtualDatacenterPredicates.datacenter(datacenter)) return filter(lambda vdc: vdc.getHypervisorType().isCompatible(type), all)