Esempio n. 1
0
    def run(self):
        orgName = self.get_option('org')
        keyName = self.get_option('name')

        organization = get_organization(orgName)

        keys = self.api.activation_keys_by_organization(
            organization['cp_key'], keyName)
        if len(keys) == 0:
            print >> sys.stderr, _(
                "Could not find activation key [ %s ]") % keyName
            return os.EX_DATAERR
        for akey in keys:
            akey["pools"] = "[ " + ", ".join(
                [pool["cp_id"] for pool in akey["pools"]]) + " ]"

        self.printer.add_column('id')
        self.printer.add_column('name')
        self.printer.add_column('description', multiline=True)
        self.printer.add_column('environment_id')
        self.printer.add_column('system_template_id')
        self.printer.add_column('pools',
                                multiline=True,
                                show_with=printer.VerboseStrategy)

        self.printer.set_header(_("Activation Key Info"))
        self.printer.print_item(keys[0])
        return os.EX_OK
Esempio n. 2
0
        def __init__(self, orgName, envName):
            self.orgName = orgName
            self.envName = envName

            self.orgId = get_organization(orgName)['id']
            self.envId = get_environment(orgName, envName)['id']
            self.priorEnvId = get_environment(orgName, envName)['prior_id']
            self.priorEnvName = get_environment(orgName, envName)['prior']
Esempio n. 3
0
    def run(self):
        orgName = self.get_option('org')
        keyName = self.get_option('name')

        organization = get_organization(orgName)
        if not organization: return os.EX_DATAERR

        keys = self.api.activation_keys_by_organization(organization['cp_key'], keyName)
        if len(keys) == 0:
            return os.EX_DATAERR

        self.api.delete(keys[0]['id'])
        print _("Successfully deleted activation key [ %s ]") % keyName
        return os.EX_OK
Esempio n. 4
0
    def run(self):
        orgName = self.get_option("org")
        keyName = self.get_option("name")

        organization = get_organization(orgName)

        keys = self.api.activation_keys_by_organization(organization["cp_key"], keyName)
        if len(keys) == 0:
            # TODO: not found?
            return os.EX_DATAERR

        self.api.delete(keys[0]["id"])
        print _("Successfully deleted activation key [ %s ]") % keyName
        return os.EX_OK
Esempio n. 5
0
    def run(self):
        orgName = self.get_option('org')
        keyName = self.get_option('name')

        organization = get_organization(orgName)

        keys = self.api.activation_keys_by_organization(
            organization['cp_key'], keyName)
        if len(keys) == 0:
            #TODO: not found?
            return os.EX_DATAERR

        self.api.delete(keys[0]['id'])
        print _("Successfully deleted activation key [ %s ]") % keyName
        return os.EX_OK
Esempio n. 6
0
    def run(self):
        orgName = self.get_option("org")
        keyName = self.get_option("name")
        envName = self.get_option("env")
        newKeyName = self.get_option("new_name")
        keyDescription = self.get_option("description")
        templateName = self.get_option("template")
        usageLimit = self.get_option("usage_limit")
        add_poolids = self.get_option("add_poolid") or []
        remove_poolids = self.get_option("remove_poolid") or []

        organization = get_organization(orgName)

        if envName != None:
            environment = get_environment(orgName, envName)
        else:
            environment = None

        keys = self.api.activation_keys_by_organization(organization["cp_key"], keyName)
        if len(keys) == 0:
            return os.EX_DATAERR
        key = keys[0]

        try:
            templateId = self.get_template_id(key["environment_id"], templateName)
        except OptionException:
            print >> sys.stderr, _("Could not find template [ %s ]") % (templateName)
            return os.EX_DATAERR
        key = self.api.update(
            key["id"],
            environment["id"] if environment != None else None,
            newKeyName,
            keyDescription,
            templateId,
            usageLimit,
        )

        for poolid in add_poolids:
            self.api.add_pool(key["id"], poolid)
        for poolid in remove_poolids:
            self.api.remove_pool(key["id"], poolid)

        if key != None:
            print _("Successfully updated activation key [ %s ]") % key["name"]
            return os.EX_OK
        else:
            return os.EX_DATAERR
Esempio n. 7
0
    def run(self):
        username = self.get_option('username')
        password = self.get_option('password')
        email = self.get_option('email')
        disabled = self.get_option('disabled')
        default_organization = self.get_option('default_organization')
        default_locale = self.get_option('default_locale')

        if default_organization is not None:
            organization = get_organization(default_organization)
        else:
            organization = None

        user = self.api.create(username, password, email, disabled, organization, default_locale)
        test_record(user,
            _("Successfully created user [ %s ]") % username,
            _("Could not create user [ %s ]") % username
        )
Esempio n. 8
0
    def run(self):
        orgName = self.get_option('org')
        keyName = self.get_option('name')
        envName = self.get_option('env')
        newKeyName = self.get_option('new_name')
        keyDescription = self.get_option('description')
        templateName = self.get_option('template')
        add_poolids = self.get_option('add_poolid') or []
        remove_poolids = self.get_option('remove_poolid') or []

        organization = get_organization(orgName)

        if envName != None:
            environment = get_environment(orgName, envName)
        else:
            environment = None

        keys = self.api.activation_keys_by_organization(
            organization['cp_key'], keyName)
        if len(keys) == 0:
            return os.EX_DATAERR
        key = keys[0]

        try:
            templateId = self.get_template_id(key['environment_id'],
                                              templateName)
        except OptionException:
            print >> sys.stderr, _("Could not find template [ %s ]") % (
                templateName)
            return os.EX_DATAERR
        key = self.api.update(
            key['id'], environment['id'] if environment != None else None,
            newKeyName, keyDescription, templateId)

        for poolid in add_poolids:
            self.api.add_pool(key['id'], poolid)
        for poolid in remove_poolids:
            self.api.remove_pool(key['id'], poolid)

        if key != None:
            print _("Successfully updated activation key [ %s ]") % key['name']
            return os.EX_OK
        else:
            return os.EX_DATAERR
Esempio n. 9
0
    def run(self):
        orgName = self.get_option('org')
        keyName = self.get_option('name')
        envName = self.get_option('env')
        newKeyName = self.get_option('new_name')
        keyDescription = self.get_option('description')
        templateName = self.get_option('template')
        add_poolids = self.get_option('add_poolid') or []
        remove_poolids = self.get_option('remove_poolid') or []

        organization = get_organization(orgName)
        if not organization: return os.EX_DATAERR

        if envName != None:
            environment = get_environment(orgName, envName)
            if not environment: return os.EX_DATAERR
        else:
            environment = None

        keys = self.api.activation_keys_by_organization(organization['cp_key'], keyName)
        if len(keys) == 0:
            return os.EX_DATAERR
        key = keys[0]

        try:
            templateId = self.get_template_id(key['environment_id'], templateName)
        except OptionException:
            print >> sys.stderr, _("Could not find template [ %s ]") % (templateName)
            return os.EX_DATAERR
        key = self.api.update(key['id'], environment['id'] if environment != None else None, newKeyName, keyDescription, templateId)

        for poolid in add_poolids:
            self.api.add_pool(key['id'], poolid)
        for poolid in remove_poolids:
            self.api.remove_pool(key['id'], poolid)

        if key != None:
            print _("Successfully updated activation key [ %s ]") % key['name']
            return os.EX_OK
        else:
            return os.EX_DATAERR
Esempio n. 10
0
    def run(self):
        username = self.get_option('username')
        password = self.get_option('password')
        email = self.get_option('email')
        disabled = self.get_option('disabled')
        default_organization = self.get_option('default_organization')
        no_default_organization = self.get_option('no_default_organization')
        default_locale = self.get_option('default_locale')

        if no_default_organization is True:
            organization = None
        elif default_organization is not None:
            organization = get_organization(default_organization)
        else:
            organization = False

        user = get_user(username)

        user = self.api.update(user['id'], password, email, disabled, organization, default_locale)
        print _("Successfully updated user [ %s ]") % username
        return os.EX_OK
Esempio n. 11
0
    def run(self):
        orgName = self.get_option("org")
        keyName = self.get_option("name")

        organization = get_organization(orgName)

        keys = self.api.activation_keys_by_organization(organization["cp_key"], keyName)
        if len(keys) == 0:
            print >> sys.stderr, _("Could not find activation key [ %s ]") % keyName
            return os.EX_DATAERR
        for akey in keys:
            akey["pools"] = "[ " + ", ".join([pool["cp_id"] for pool in akey["pools"]]) + " ]"

        self.printer.add_column("id")
        self.printer.add_column("name")
        self.printer.add_column("description", multiline=True)
        self.printer.add_column("environment_id")
        self.printer.add_column("system_template_id")
        self.printer.add_column("pools", multiline=True, show_with=printer.VerboseStrategy)

        self.printer.set_header(_("Activation Key Info"))
        self.printer.print_item(keys[0])
        return os.EX_OK
Esempio n. 12
0
    def run(self):
        orgName = self.get_option('org')
        keyName = self.get_option('name')

        organization = get_organization(orgName)
        if not organization: return os.EX_DATAERR

        keys = self.api.activation_keys_by_organization(organization['cp_key'], keyName)
        if len(keys) == 0:
            print >> sys.stderr, _("Could not find activation key [ %s ]") % keyName
            return os.EX_DATAERR
        for akey in keys:
            akey["pools"] = "[ "+ ", ".join([pool["cp_id"] for pool in akey["pools"]]) +" ]"

        self.printer.addColumn('id')
        self.printer.addColumn('name')
        self.printer.addColumn('description', multiline=True)
        self.printer.addColumn('environment_id')
        self.printer.addColumn('system_template_id')
        self.printer.addColumn('pools', multiline=True, show_in_grep=False)

        self.printer.setHeader(_("Activation Key Info"))
        self.printer.printItem(keys[0])
        return os.EX_OK
Esempio n. 13
0
    def run(self):
        orgName = self.get_option('org')
        keyName = self.get_option('name')

        organization = get_organization(orgName)

        keys = self.api.activation_keys_by_organization(organization['cp_key'], keyName)
        if len(keys) == 0:
            print >> sys.stderr, _("Could not find activation key [ %s ]") % keyName
            return os.EX_DATAERR
        for akey in keys:
            akey["pools"] = "[ "+ ", ".join([pool["cp_id"] for pool in akey["pools"]]) +" ]"

        self.printer.add_column('id')
        self.printer.add_column('name')
        self.printer.add_column('description', multiline=True)
        self.printer.add_column('usage_limit', value_formatter=lambda x: "unlimited" if x == -1 else x)
        self.printer.add_column('environment_id')
        self.printer.add_column('system_template_id')
        self.printer.add_column('pools', multiline=True, show_with=printer.VerboseStrategy)

        self.printer.set_header(_("Activation Key Info"))
        self.printer.print_item(keys[0])
        return os.EX_OK
Esempio n. 14
0
    def get_keys_for_organization(self, orgName):
        organization = get_organization(orgName)
        if not organization: return os.EX_DATAERR

        return self.api.activation_keys_by_organization(organization['cp_key'])
Esempio n. 15
0
 def get_keys_for_organization(self, orgName):
     organization = get_organization(orgName)
     return self.api.activation_keys_by_organization(organization["cp_key"])
Esempio n. 16
0
 def get_keys_for_organization(self, orgName):
     organization = get_organization(orgName)
     return self.api.activation_keys_by_organization(organization['cp_key'])