Exemple #1
0
    def find(self, args):
        """ Find a template given its name. """
        # Parse user input to get the name of the template
        parser = OptionParser(usage="template find <options>")
        parser.add_option("-n", "--name", help="The name of the template to find",
                action="store", 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 template 
        context = ContextLoader().load_context()
        try:
            admin = context.getAdministrationService()
            user = admin.getCurrentUserInfo()
            enterprise = user.getEnterprise()
            template = enterprise.findTemplate(VirtualMachineTemplatePredicates.name(name))
            if template:
                pprint_templates([template])
            else:
                print "No template found with name: %s" % name
        except (AbiquoException, AuthorizationException), ex:
            print "Error: %s" % ex.getMessage()
Exemple #2
0
    def find(self, args):
        """ Find a template given its name """
        # Parse user input to get the name of the template
        parser = OptionParser(usage="template find <options>")
        parser.add_option("-n",
                          "--name",
                          deswt="name",
                          help="The name of the template to find")
        (options, args) = parser.parse_args(args)
        name = options.name
        if not name:
            parser.print_help()
            return

        # Once user input has been read, find the template
        try:
            admin = self._context.getAdministrationService()
            enterprise = admin.getCurrentEnterprise()
            template = enterprise.findTemplate(
                VirtualMachineTemplatePredicates.name(name))
            if template:
                pprint_templates([template])
            else:
                print "No template found with name: %s" % name
        except (AbiquoException, AuthorizationException), ex:
            print "Error: %s" % ex.getMessage()
Exemple #3
0
def find_template_by_name(context, vdc, name):
    """ Finds the template with the given name. """
    template = vdc.listAvailableTemplates(VirtualMachineTemplatePredicates.name(name))
    if len(template) > 0:
        log.info("Found compatible template: %s" % template[0].getName())
        return template[0]
    else:
        log.info("No compatible template found")
        return None
Exemple #4
0
def find_template_by_name(context, vdc, name):
    """ Finds the template with the given name """
    template = vdc.findAvailableTemplate(
            VirtualMachineTemplatePredicates.name(name))
    if template:
        log.info("Found compatible template: %s" % template.getName())
    else:
        log.info("No compatible template found")

    return template
def find_template_by_name(context, vdc, name):
    """ Finds the template with the given name """
    template = vdc.findAvailableTemplate(
        VirtualMachineTemplatePredicates.name(name))
    if template:
        log.info("Found compatible template: %s" % template.getName())
    else:
        log.info("No compatible template found")

    return template
Exemple #6
0
def find_template_by_id(context, id):
    """ Find a template given its id """
    admin = context.getAdministrationService()
    enterprise = admin.getCurrentEnterprise()
    return enterprise.findTemplate(VirtualMachineTemplatePredicates.id(id))
Exemple #7
0
def find_template_by_id(context, id):
    """ Find a template given its id """
    admin = context.getAdministrationService()
    enterprise = admin.getCurrentEnterprise()
    return enterprise.findTemplate(VirtualMachineTemplatePredicates.id(id))