Exemplo n.º 1
0
 def list(self, args):
     """ List all available virtual datacenters """
     try:
         cloud = self._context.getCloudService()
         vdcs = cloud.listVirtualDatacenters()
         pprint_vdcs(vdcs)
     except (AbiquoException, AuthorizationException), ex:
         print "Error: %s" % ex.getMessage()
Exemplo n.º 2
0
    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()