Пример #1
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('env')
        prodName = self.get_option('product')
        listDisabled = self.has_option('disabled')

        self.printer.add_column('id')
        self.printer.add_column('name')
        self.printer.add_column('package_count')
        self.printer.add_column('last_sync', formatter=format_sync_time)

        if prodName and envName:
            env  = get_environment(orgName, envName)
            prod = get_product(orgName, prodName)

            self.printer.set_header(_("Repo List For Org %s Environment %s Product %s") %
                (orgName, env["name"], prodName))
            repos = self.api.repos_by_env_product(env["id"], prod["id"], None, listDisabled)
            self.printer.print_items(repos)

        elif prodName:
            prod = get_product(orgName, prodName)
            self.printer.set_header(_("Repo List for Product %s in Org %s ") %
                (prodName, orgName))
            repos = self.api.repos_by_product(orgName, prod["id"], listDisabled)
            self.printer.print_items(repos)

        else:
            env  = get_environment(orgName, envName)
            self.printer.set_header(_("Repo List For Org %s Environment %s") %
                (orgName, env["name"]))
            repos = self.api.repos_by_org_env(orgName,  env["id"], listDisabled)
            self.printer.print_items(repos)

        return os.EX_OK
Пример #2
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('env')
        prodName = self.get_option('product')
        listDisabled = self.has_option('disabled')

        self.printer.add_column('id')
        self.printer.add_column('name')
        self.printer.add_column('package_count')
        self.printer.add_column('last_sync', formatter=format_sync_time)

        if prodName and envName:
            env  = get_environment(orgName, envName)
            prod = get_product(orgName, prodName)

            self.printer.set_header(_("Repo List For Org %s Environment %s Product %s") %
                (orgName, env["name"], prodName))
            repos = self.api.repos_by_env_product(env["id"], prod["id"], None, listDisabled)
            self.printer.print_items(repos)

        elif prodName:
            prod = get_product(orgName, prodName)
            self.printer.set_header(_("Repo List for Product %s in Org %s ") %
                (prodName, orgName))
            repos = self.api.repos_by_product(orgName, prod["id"], listDisabled)
            self.printer.print_items(repos)

        else:
            env  = get_environment(orgName, envName)
            self.printer.set_header(_("Repo List For Org %s Environment %s") %
                (orgName, env["name"]))
            repos = self.api.repos_by_org_env(orgName,  env["id"], listDisabled)
            self.printer.print_items(repos)

        return os.EX_OK
Пример #3
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        dist_name = self.get_option('name')
        new_name = self.get_option('new_name')
        new_environment_name = self.get_option('new_environment')
        new_description = self.get_option('description')
        dist_uuid = self.get_option('uuid')

        distributor = get_distributor(org_name, dist_name, env_name, dist_uuid)
        new_environment = get_environment(org_name, new_environment_name)

        updates = {}
        if new_name:
            updates['name'] = new_name
        if new_description:
            updates['description'] = new_description
        if new_environment_name:
            new_environment = get_environment(org_name, new_environment_name)
            updates['environment_id'] = new_environment['id']

        response = self.api.update(distributor['uuid'], updates)

        test_record(response,
            _("Successfully updated distributor [ %s ]") % distributor['name'],
            _("Could not update distributor [ %s ]") % distributor['name']
        )
Пример #4
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        dist_name = self.get_option('name')
        new_name = self.get_option('new_name')
        new_environment_name = self.get_option('new_environment')
        new_description = self.get_option('description')
        dist_uuid = self.get_option('uuid')

        distributor = get_distributor(org_name, dist_name, env_name, dist_uuid)
        new_environment = get_environment(org_name, new_environment_name)

        updates = {}
        if new_name:
            updates['name'] = new_name
        if new_description:
            updates['description'] = new_description
        if new_environment_name:
            new_environment = get_environment(org_name, new_environment_name)
            updates['environment_id'] = new_environment['id']

        response = self.api.update(distributor['uuid'], updates)

        test_record(
            response,
            _("Successfully updated distributor [ %s ]") % distributor['name'],
            _("Could not update distributor [ %s ]") % distributor['name'])
Пример #5
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        sys_name = self.get_option('name')
        new_name = self.get_option('new_name')
        new_environment_name = self.get_option('new_environment')
        new_description = self.get_option('description')
        new_location = self.get_option('location')
        new_release = self.get_option('release')
        new_sla = self.get_option('sla')

        system = get_system(org_name, sys_name, env_name)
        new_environment = get_environment(org_name, new_environment_name)
        system_uuid = system['uuid']

        updates = {}
        if new_name: updates['name'] = new_name
        if new_description: updates['description'] = new_description
        if new_location: updates['location'] = new_location
        if new_release: updates['releaseVer'] = new_release
        if new_sla: updates['serviceLevel'] = new_sla
        if new_environment_name:
            new_environment = get_environment(org_name, new_environment_name)
            updates['environment_id'] = new_environment['id']
            
        response = self.api.update(system_uuid, updates)

        test_record(response,
            _("Successfully updated system [ %s ]") % system['name'],
            _("Could not update system [ %s ]") % system['name']
        )
Пример #6
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']
Пример #7
0
 def __init__(self, org_name, env_name, type_in):
     self.org_name = org_name
     self.env_name = env_name
     self.type = type_in
     # Use current env if we are doing a deletion otherwise use the prior
     if self.type == 'deletion':
         self.env_name = get_environment(org_name, env_name)['name']
     else:
         self.env_name = get_environment(org_name, env_name)['prior']
Пример #8
0
    def run(self):
        orgName = self.get_option("org")
        envName = self.get_option("environment")
        prodName = self.get_option("product")
        prodLabel = self.get_option("product_label")
        prodId = self.get_option("product_id")
        listDisabled = self.has_option("disabled")
        content_view_name = self.get_option("view_name")
        content_view_label = self.get_option("view_label")
        content_view_id = self.get_option("view_id")

        batch_add_columns(
            self.printer,
            {"id": _("ID")},
            {"name": _("Name")},
            {"label": _("Label")},
            {"content_type": _("Type")},
            {"package_count": _("Package Count")},
            {"puppet_module_count": _("Puppet Module Count")},
        )

        self.printer.add_column("last_sync", _("Last Sync"), formatter=format_sync_time)

        if content_view_name or content_view_label or content_view_id:
            content_view = get_content_view(orgName, content_view_label, content_view_name, content_view_id)
            content_view_id = content_view["id"]

        prodIncluded = prodName or prodLabel or prodId
        if prodIncluded and envName:
            env = get_environment(orgName, envName)
            prod = get_product(orgName, prodName, prodLabel, prodId)

            self.printer.set_header(
                _("Repo List For Org %(org_name)s Environment %(env_name)s Product %(prodName)s")
                % {"org_name": orgName, "env_name": env["name"], "prodName": prodName}
            )
            repos = self.api.repos_by_env_product(env["id"], prod["id"], None, listDisabled, content_view_id)
            self.printer.print_items(repos)

        elif prodIncluded:
            prod = get_product(orgName, prodName, prodLabel, prodId)
            self.printer.set_header(
                _("Repo List for Product %(prodName)s in Org %(orgName)s ") % {"prodName": prodName, "orgName": orgName}
            )
            repos = self.api.repos_by_product(orgName, prod["id"], listDisabled)
            self.printer.print_items(repos)

        else:
            env = get_environment(orgName, envName)
            self.printer.set_header(
                _("Repo List For Org %(orgName)s Environment %(env_name)s")
                % {"orgName": orgName, "env_name": env["name"]}
            )
            repos = self.api.repos_by_org_env(orgName, env["id"], listDisabled, content_view_id)
            self.printer.print_items(repos)

        return os.EX_OK
Пример #9
0
 def __init__(self, org_name, env_name, type_in):
     self.org_name = org_name
     self.env_name = env_name
     self.type = type_in
     # Use current env if we are doing a deletion otherwise use the prior
     if self.type == 'deletion':
         self.env_name = get_environment(org_name, env_name)['name']
     else:
         self.env_name = get_environment(org_name, env_name)['prior']
Пример #10
0
def create_data(numorgs, numsystems, numproducts, singleorg):
    # Setup connection to Katello
    admin = AdminCLI()
    admin.setup_parser()
    admin.opts, admin.args = admin.parser.parse_args([])
    admin.setup_server()
    admin._username = "******"
    admin._password = "******"
    org_names = []
    if (singleorg):
        # If we pass in a single org name
        # we just load all the data into that.
        org_names.append(singleorg)
    else:
        # Otherwise just create fake orgs
        orgapi = OrganizationAPI()
        print "Creating [%s] Orgs" % numorgs
        for i in range(numorgs):
            name = "Org-%s" % randomString()
            org_names.append(name)
            print "[%s] Creating org with name [%s]" % (i, name)
            orgapi.create(name, "description")

    # create envs
    envapi = EnvironmentAPI()

    for i in range(len(org_names)):
        print "[%s] Creating DEV/TEST/STAGE in org: [%s]" % (i, org_names[i])
        libraryId = get_environment(org_names[i], "Library")["id"]
        print "Library ID: %s" % libraryId
        envids = [libraryId]
        for x in range(len(ENVIRONMENTS)):
            existing_env = get_environment(org_names[i], ENVIRONMENTS[x])
            if not existing_env:
                e = envapi.create(org_names[i], ENVIRONMENTS[x], "Desc",
                                  envids[x])
                envids.append(e["id"])
            else:
                envids.append(existing_env["id"])

    ## Create systems
    print "Creating [%s] Systems in each org and assigning to random envs" % numsystems
    for i in range(len(org_names)):
        systemapi = SystemAPI()
        for x in range(numsystems):
            system_name = "System-%s" % randomString()
            randenv = random.choice(ENVIRONMENTS)
            print "Registering system: [%s] in environment: [%s]" % (
                system_name, randenv)
            system = systemapi.register(system_name, org_names[i], randenv, [],
                                        'system')
            print "[%s] Created system: %s" % (x, system["name"])
Пример #11
0
def create_data(numorgs, numsystems, numproducts, singleorg):
    # Setup connection to Katello
    admin = AdminCLI()
    admin.setup_parser()
    admin.opts, admin.args = admin.parser.parse_args([])
    admin.setup_server()
    admin._username = "******"
    admin._password = "******"
    org_names = []
    if (singleorg):
        # If we pass in a single org name 
        # we just load all the data into that.
        org_names.append(singleorg)
    else:
        # Otherwise just create fake orgs
        orgapi = OrganizationAPI()
        print "Creating [%s] Orgs" % numorgs 
        for i in range(numorgs):
            name = "Org-%s"  % randomString()
            org_names.append(name)
            print "[%s] Creating org with name [%s]" % (i, name)
            orgapi.create(name, "description")
        
    # create envs
    envapi = EnvironmentAPI()

    for i in range(len(org_names)):
        print "[%s] Creating DEV/TEST/STAGE in org: [%s]" % (i, org_names[i])
        libraryId = get_environment(org_names[i], "Library")["id"]
        print "Library ID: %s" % libraryId
        envids = [libraryId]
        for x in range(len(ENVIRONMENTS)):
            existing_env = get_environment(org_names[i], ENVIRONMENTS[x])
            if not existing_env:
                e = envapi.create(org_names[i], ENVIRONMENTS[x], "Desc", envids[x])
                envids.append(e["id"])
            else:
                envids.append(existing_env["id"])

    ## Create systems
    print "Creating [%s] Systems in each org and assigning to random envs" % numsystems 
    for i in range(len(org_names)):
        systemapi = SystemAPI()
        for x in range(numsystems):
            system_name = "System-%s" % randomString()
            randenv = random.choice(ENVIRONMENTS)
            print "Registering system: [%s] in environment: [%s]" % (system_name, randenv)
            system = systemapi.register(system_name, org_names[i], randenv, [], 'system')
            print "[%s] Created system: %s" % (x, system["name"])
Пример #12
0
    def run(self):
        name = self.get_option('name')
        org = self.get_option('org')
        environment_name = self.get_option('environment')
        activation_keys = self.get_option('activationkey')
        release = self.get_option('release')
        sla = self.get_option('sla')
        facts = dict(self.get_option('fact') or {})
        view_name = self.get_option("view_name")
        view_label = self.get_option("view_label")
        view_id = self.get_option("view_id")

        environment_id = None
        if environment_name is not None:
            environment_id = get_environment(org, environment_name)['id']

        if view_label or view_name:
            view = get_content_view(org, view_label, view_name)
            view_id = view["id"]

        system = self.api.register(name, org, environment_id, activation_keys,
                                   'system', release, sla, facts, view_id)

        test_record(system,
                    _("Successfully registered system [ %s ]") % name,
                    _("Could not register system [ %s ]") % name)
Пример #13
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        sys_name = self.get_option('name')
        sys_uuid = self.get_option('uuid')

        self.printer.set_header(_("Remote tasks"))

        environment = get_environment(org_name, env_name)
        tasks = self.api.tasks(org_name, environment["id"], sys_name, sys_uuid)

        for t in tasks:
            t['result'] = "\n" + t['result_description']

        self.printer.add_column('uuid', _("Task ID"))
        self.printer.add_column('system_name', _("System"))
        self.printer.add_column('description', _("Action"))
        self.printer.add_column('created_at',
                                _("Started"),
                                formatter=format_date,
                                show_with=printer.VerboseStrategy)
        self.printer.add_column('finish_time',
                                _("Finished"),
                                formatter=format_date,
                                show_with=printer.VerboseStrategy)
        self.printer.add_column('state', _("Status"))
        self.printer.add_column('result',
                                _("Result"),
                                show_with=printer.VerboseStrategy)

        self.printer.print_items(tasks)

        return os.EX_OK
Пример #14
0
    def run(self):
        repo_id   = self.get_option('repo_id')
        repo_name = self.get_option('repo')
        org_name  = self.get_option('org')
        env_name  = self.get_option('env')
        env_id, prod_id = None, None
        prod_name = self.get_option('product')

        self.printer.add_column('id')
        self.printer.add_column('title')
        self.printer.add_column('type')

        if not repo_id:
            if repo_name:
                repo = get_repo(org_name, prod_name, repo_name, env_name)
                repo_id = repo["id"]
            else:
                env = get_environment(org_name, env_name)
                env_id = env["id"]
                if prod_name:
                    product = get_product(org_name, prod_name)
                    prod_id = product["id"]


        errata = self.api.errata_filter(repo_id=repo_id, environment_id=env_id, type=self.get_option('type'), severity=self.get_option('severity'),prod_id=prod_id)

        self.printer.set_header(_("Errata List"))
        self.printer.print_items(errata)
        return os.EX_OK
Пример #15
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        envName     = self.get_option('env')

        env = get_environment(orgName, envName)
        prod = get_product(orgName, prodName)

        returnCode = os.EX_OK

        cset = self.csapi.create(orgName, env["id"], self.create_cs_name())
        try:
            self.csapi.add_content(cset["id"], "products", {'product_id': prod['id']})
            task = self.csapi.promote(cset["id"])
            task = AsyncTask(task)

            run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the product, please wait... "))

            if task.succeeded():
                print _("Product [ %s ] promoted to environment [ %s ] " % (prodName, envName))
                returnCode = os.EX_OK
            else:
                print _("Product [ %s ] promotion failed: %s" % (prodName, format_task_errors(task.errors())) )
                returnCode = os.EX_DATAERR

        except Exception as e:
            #exception message is printed from action's main method
            raise e

        return returnCode
Пример #16
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('env')
        prov_name = self.get_option('prov')

        self.printer.add_column('id')
        self.printer.add_column('name')
        self.printer.add_column('provider_id')
        self.printer.add_column('provider_name')
        self.printer.add_column('sync_plan_name')
        self.printer.add_column('last_sync', formatter=format_date)
        self.printer.add_column('gpg_key_name', name=_("GPG key"))

        if prov_name:
            prov = get_provider(org_name, prov_name)
            if prov == None:
                return os.EX_DATAERR

            self.printer.set_header(_("Product List For Provider %s") % (prov_name))
            prods = self.api.products_by_provider(prov["id"])

        else:
            env = get_environment(org_name, env_name)
            if env == None:
                return os.EX_DATAERR

            self.printer.set_header(_("Product List For Organization %s, Environment '%s'") % (org_name, env["name"]))
            prods = self.api.products_by_env(env['id'])

        self.printer.print_items(prods)
        return os.EX_OK
Пример #17
0
 def get_systems(self, org_name, env_name, pool_id):
     query = {"pool_id": pool_id} if pool_id else {}
     if env_name is None:
         return self.api.systems_by_org(org_name, query)
     else:
         environment = get_environment(org_name, env_name)
         return self.api.systems_by_env(environment["id"], query)
Пример #18
0
    def systems_by_env(self, orgId, envName, query = {}):
        environment = get_environment(orgId, envName)
        if environment is None:
            return None

        path = "/api/environments/%s/systems" % environment["id"]
        return self.server.GET(path, query)[1]
Пример #19
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        async = self.get_option('async')
        view_label = self.get_option('label')
        view_id = self.get_option('id')
        view_name = self.get_option('name')

        view = get_content_view(org_name, view_label, view_name, view_id)

        environment = get_environment(org_name, env_name)
        env_id = environment["id"]

        task = self.api.promote(view["id"], env_id)

        if not async:
            task = AsyncTask(task)
            run_spinner_in_bg(wait_for_async_task, [task],
                    message=_("Promoting content view, please wait..."))

            return evaluate_task_status(task,
                failed = _("View [ %s ] promotion failed") % view["name"],
                ok =     _("Content view [ %(view)s ] promoted to environment [ %(env)s ]") %
                    {"view": view["name"], "env": environment["name"]},
            )

        else:
            print _("Promotion task [ %s ] was successfully created.") % (task["uuid"])
            return os.EX_OK
Пример #20
0
    def run(self):
        name = self.get_option('name')
        org = self.get_option('org')
        environment_name = self.get_option('environment')
        activation_keys = self.get_option('activationkey')
        release = self.get_option('release')
        sla = self.get_option('sla')
        facts = dict(self.get_option('fact') or {})
        view_label = self.get_option("content_view")

        environment_id = None
        if environment_name is not None:
            environment_id = get_environment(org, environment_name)['id']

        view_id = None
        if view_label is not None:
            view = get_content_view(org, view_label)
            view_id = view["id"]

        system = self.api.register(name, org, environment_id, activation_keys,
                                   'system', release, sla, facts, view_id)

        test_record(system,
            _("Successfully registered system [ %s ]") % name,
            _("Could not register system [ %s ]") % name
        )
Пример #21
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('env')
        view_label = self.get_option('label')
        view_id = self.get_option('id')
        view_name = self.get_option('name')

        view = get_content_view(org_name, view_label, view_name, view_id)
        if env_name:
            env = get_environment(org_name, env_name)
            env_id = env["id"] if env else None
        else:
            env = get_library(org_name)
            env_id = env["id"] if env else None

        view = self.api.show(org_name, view["id"], env_id)

        view["environments"] = ', '.join(str(x) for x in view["environments"])

        self.printer.add_column('id', _("ID"))
        self.printer.add_column('name', _("Name"))
        self.printer.add_column('label', _("Label"))
        self.printer.add_column('description', _("Description"), multiline=True)
        self.printer.add_column('organization', _('Org'))
        self.printer.add_column('definition', _("Definition"))
        self.printer.add_column('environments', _('Environments'),
                                multiline=True)
        self.printer.add_column('versions', _("Versions"), multiline=True)
        self.printer.add_column('repositories', _('Repos'),
                                multiline=True)

        self.printer.set_header(_("ContentView Info"))
        self.printer.print_item(view)
        return os.EX_OK
Пример #22
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('environment')
        keyName = self.get_option('name')
        keyDescription = self.get_option('description')
        usageLimit = self.get_option('usage_limit')
        view_label = self.get_option("view_label")
        view_name = self.get_option("view_name")
        view_id = self.get_option("view_id")

        if usageLimit is None:
            usageLimit = -1
        else:
            if int(usageLimit) <= 0:
                print >> sys.stderr, _(
                    "Usage limit [ %s ] must be higher than one") % usageLimit
                return os.EX_DATAERR

        environment = get_environment(orgName, envName)

        if view_name or view_label or view_id:
            view = get_content_view(orgName, view_label, view_name, view_id)
            view_id = view['id']
        else:
            view_id = None

        key = self.api.create(environment['id'], keyName, keyDescription,
                              usageLimit, view_id)
        test_record(key,
                    _("Successfully created activation key [ %s ]") % keyName,
                    _("Could not create activation key [ %s ]") % keyName)
Пример #23
0
    def run(self):
        org_name = self.get_option("org")
        env_name = self.get_option("environment")
        sys_name = self.get_option("name")
        sys_uuid = self.get_option("uuid")

        self.printer.set_header(_("Remote tasks"))

        environment = get_environment(org_name, env_name)
        tasks = self.api.tasks(org_name, environment["id"], sys_name, sys_uuid)

        for t in tasks:
            t["result"] = "\n" + t["result_description"]

        self.printer.add_column("uuid", name=_("Task ID"))
        self.printer.add_column("system_name", name=_("System"))
        self.printer.add_column("description", name=_("Action"))
        self.printer.add_column(
            "created_at", name=_("Started"), formatter=format_date, show_with=printer.VerboseStrategy
        )
        self.printer.add_column(
            "finish_time", name=_("Finished"), formatter=format_date, show_with=printer.VerboseStrategy
        )
        self.printer.add_column("state", name=_("Status"))
        self.printer.add_column("result", name=_("Result"), show_with=printer.VerboseStrategy)

        self.printer.print_items(tasks)

        return os.EX_OK
Пример #24
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        prov_name = self.get_option('prov')
        all_opt = self.get_option('all')

        self.printer.add_column('id')
        self.printer.add_column('name')
        self.printer.add_column('label')
        self.printer.add_column('provider_id')
        self.printer.add_column('provider_name')
        self.printer.add_column('sync_plan_name')
        self.printer.add_column('last_sync', formatter=format_sync_time)
        self.printer.add_column('gpg_key_name', name=_("GPG key"))

        if prov_name:
            prov = get_provider(org_name, prov_name)

            self.printer.set_header(_("Product List For Provider %s") % (prov_name))
            prods = self.api.products_by_provider(prov["id"])

        else:
            env = get_environment(org_name, env_name)

            self.printer.set_header(_("Product List For Organization %s, Environment '%s'") % (org_name, env["name"]))
            prods = self.api.products_by_env(env['id'])

        # hide marketing products by default
        if not all_opt:
            def isNotMarketingProduct(p):
                return not (("marketing_product" in p) and (p["marketing_product"]))
            prods = filter(isNotMarketingProduct, prods)

        self.printer.print_items(prods)
        return os.EX_OK
Пример #25
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        prodLabel   = self.get_option('label')
        prodId      = self.get_option('id')
        envName     = self.get_option('environment')

        env = get_environment(orgName, envName)
        prod = get_product(orgName, prodName, prodLabel, prodId)

        returnCode = os.EX_OK

        cset = self.csapi.create(orgName, env["id"], self.create_cs_name(), constants.PROMOTION)
        try:
            self.csapi.add_content(cset["id"], "products", {'product_id': prod['id']})
            task = self.csapi.apply(cset["id"])
            task = AsyncTask(task)

            run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the product, please wait... "))

            if task.succeeded():
                print _("Product [ %(prod_name)s ] promoted to environment [ %(envName)s ] " \
                    % {'prod_name':prod["name"], 'envName':envName})
                returnCode = os.EX_OK
            else:
                print _("Product [ %(prod_name)s ] promotion failed: %(task_errors)s" \
                    % {'prod_name':prod["name"], 'task_errors':format_task_errors(task.errors())} )
                returnCode = os.EX_DATAERR

        except Exception:
            #exception message is printed from action's main method
            raise

        return returnCode
Пример #26
0
    def run(self):
        org_name = self.get_option('org')
        group_name = self.get_option('name')
        env_name = self.get_option('environment')
        view_label = self.get_option('view_label')
        view_id = self.get_option('view_id')
        view_name = self.get_option('view_name')

        system_group = get_system_group(org_name, group_name)
        system_group_id = system_group['id']

        if env_name:
            environment = get_environment(org_name, env_name)
            env_id = environment["id"]
        else:
            env_id = None

        if view_name or view_id or view_label:
            view = get_content_view(org_name, view_label, view_name, view_id)
            view_id = view["id"]
        else:
            view_id = None

        group = self.api.update_systems(org_name, system_group_id, env_id,
                                        view_id)

        if group:
            print(
                _("Successfully updated systems in group [ %s ]" %
                  group["name"]))
            return os.EX_OK
        else:
            return os.EX_DATAERR
Пример #27
0
 def get_distributors(self, org_name, env_name, pool_id):
     query = {'pool_id': pool_id} if pool_id else {}
     if env_name is None:
         return self.api.distributors_by_org(org_name, query)
     else:
         environment = get_environment(org_name, env_name)
         return self.api.distributors_by_env(environment["id"], query)
Пример #28
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        prodLabel   = self.get_option('label')
        prodId      = self.get_option('id')
        envName     = self.get_option('environment')

        env = get_environment(orgName, envName)
        prod = get_product(orgName, prodName, prodLabel, prodId)


        if not self.repoapi.repos_by_product(orgName, prod['id']):
            print _("Product [ %(prod_name)s ] has no repository") % {'prod_name':prod['name']}
            return os.EX_DATAERR

        cset = self.csapi.create(orgName, env["id"], self.create_cs_name(), constants.PROMOTION)

        self.csapi.add_content(cset["id"], "products", {'product_id': prod['id']})
        task = self.csapi.apply(cset["id"])
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the product, please wait... "))

        return evaluate_task_status(task,
            failed = _("Product [ %s ] promotion failed") % prod["name"],
            ok =     _("Product [ %(prod)s ] promoted to environment [ %(env)s ]") %
                {'prod':prod["name"], 'env':envName}
        )
Пример #29
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('environment')
        csName = self.get_option('name')
        csDescription = self.get_option('description')
        csType = constants.PROMOTION

        # Check for duplicate type flags
        if self.get_option('type_promotion') and self.get_option(
                'type_deletion'):
            raise OptionValueError(constants.OPT_ERR_PROMOTION_OR_DELETE)
        if self.get_option('type_promotion'):
            csType = constants.PROMOTION
        elif self.get_option('type_deletion'):
            csType = constants.DELETION

        env = get_environment(orgName, envName)
        cset = self.api.create(orgName, env["id"], csName, csType,
                               csDescription)
        test_record(
            cset,
            _("Successfully created changeset [ %(csName)s ] for environment [ %(env_name)s ]"
              ) % {
                  'csName': csName,
                  'env_name': env["name"]
              },
            _("Could not create changeset [ %(csName)s ] for environment [ %(env_name)s ]"
              ) % {
                  'csName': csName,
                  'env_name': env["name"]
              })

        return os.EX_OK
Пример #30
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('environment')
        csName = self.get_option('name')
        csDescription = self.get_option('description')
        csType = constants.PROMOTION

        # Check for duplicate type flags
        if self.get_option('type_promotion') and self.get_option('type_deletion'):
            raise OptionValueError(constants.OPT_ERR_PROMOTION_OR_DELETE)
        if self.get_option('type_promotion'):
            csType = constants.PROMOTION
        elif self.get_option('type_deletion'):
            csType = constants.DELETION

        env = get_environment(orgName, envName)
        cset = self.api.create(orgName, env["id"], csName, csType, csDescription)
        test_record(cset,
            _("Successfully created changeset [ %(csName)s ] for environment [ %(env_name)s ]")
                % {'csName':csName, 'env_name':env["name"]},
            _("Could not create changeset [ %(csName)s ] for environment [ %(env_name)s ]")
                % {'csName':csName, 'env_name':env["name"]}
        )

        return os.EX_OK
Пример #31
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        async = self.get_option('async')
        view_label = self.get_option('label')
        view_id = self.get_option('id')
        view_name = self.get_option('name')

        view = get_content_view(org_name, view_label, view_name, view_id)

        environment = get_environment(org_name, env_name)
        env_id = environment["id"]

        task = self.api.promote(view["id"], env_id)

        if not async:
            task = AsyncTask(task)
            run_spinner_in_bg(wait_for_async_task, [task],
                    message=_("Promoting content view, please wait..."))

            return evaluate_task_status(task,
                failed = _("View [ %s ] promotion failed") % view["name"],
                ok =     _("Content view [ %(view)s ] promoted to environment [ %(env)s ]") %
                    {"view": view["name"], "env": environment["name"]},
            )

        else:
            print _("Promotion task [ %s ] was successfully created.") % (task["uuid"])
            return os.EX_OK
Пример #32
0
    def run(self):
        org_name = self.get_option('org')
        group_name = self.get_option('name')
        env_name = self.get_option('environment')
        view_label = self.get_option('view_label')
        view_id = self.get_option('view_id')
        view_name = self.get_option('view_name')

        system_group = get_system_group(org_name, group_name)
        system_group_id = system_group['id']

        if env_name:
            environment = get_environment(org_name, env_name)
            env_id = environment["id"]
        else:
            env_id = None

        if view_name or view_id or view_label:
            view = get_content_view(org_name, view_label, view_name, view_id)
            view_id = view["id"]
        else:
            view_id = None

        group = self.api.update_systems(org_name, system_group_id, env_id,
                                        view_id)

        if group:
            print (_("Successfully updated systems in group [ %s ]" % group["name"]))
            return os.EX_OK
        else:
            return os.EX_DATAERR
Пример #33
0
    def run(self):
        repo_id   = self.get_option('repo_id')
        repo_name = self.get_option('repo')
        org_name  = self.get_option('org')
        env_name  = self.get_option('environment')
        env_id, prod_id = None, None
        prod_name = self.get_option('product')

        self.printer.add_column('id')
        self.printer.add_column('title')
        self.printer.add_column('type')

        if not repo_id:
            if repo_name:
                repo = get_repo(org_name, prod_name, repo_name, env_name)
                repo_id = repo["id"]
            else:
                env = get_environment(org_name, env_name)
                env_id = env["id"]
                if prod_name:
                    product = get_product(org_name, prod_name)
                    prod_id = product["id"]


        errata = self.api.errata_filter(repo_id=repo_id, environment_id=env_id, type_in=self.get_option('type'),
            severity=self.get_option('severity'), prod_id=prod_id)

        self.printer.set_header(_("Errata List"))
        self.printer.print_items(errata)
        return os.EX_OK
Пример #34
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        sys_name = self.get_option('name')
        sys_uuid = self.get_option('uuid')

        self.printer.set_header(_("Remote tasks"))

        environment = get_environment(org_name, env_name)
        tasks = self.api.tasks(org_name, environment["id"], sys_name, sys_uuid)

        for t in tasks:
            t['result'] = "\n" + t['result_description']

        self.printer.add_column('uuid', _("Task ID"))
        self.printer.add_column('system_name', _("System"))
        self.printer.add_column('description', _("Action"))
        self.printer.add_column('created_at', _("Started"), formatter=format_date, show_with=printer.VerboseStrategy)
        self.printer.add_column('finish_time', _("Finished"), formatter=format_date, show_with=printer.VerboseStrategy)
        self.printer.add_column('state', _("Status"))
        self.printer.add_column('result', _("Result"), show_with=printer.VerboseStrategy)

        self.printer.print_items(tasks)

        return os.EX_OK
Пример #35
0
 def get_distributors(self, org_name, env_name, pool_id):
     query = {'pool_id': pool_id} if pool_id else {}
     if env_name is None:
         return self.api.distributors_by_org(org_name, query)
     else:
         environment = get_environment(org_name, env_name)
         return self.api.distributors_by_env(environment["id"], query)
Пример #36
0
    def run(self):
        orgName = self.get_option("org")
        envName = self.get_option("environment")
        keyName = self.get_option("name")
        keyDescription = self.get_option("description")
        usageLimit = self.get_option("usage_limit")
        view_label = self.get_option("view_label")
        view_name = self.get_option("view_name")
        view_id = self.get_option("view_id")

        if usageLimit is None:
            usageLimit = -1
        else:
            if int(usageLimit) <= 0:
                print >> sys.stderr, _("Usage limit [ %s ] must be higher than one") % usageLimit
                return os.EX_DATAERR

        environment = get_environment(orgName, envName)

        if view_name or view_label or view_id:
            view = get_content_view(orgName, view_label, view_name, view_id)
            view_id = view["id"]
        else:
            view_id = None

        key = self.api.create(environment["id"], keyName, keyDescription, usageLimit, view_id)
        test_record(
            key,
            _("Successfully created activation key [ %s ]") % keyName,
            _("Could not create activation key [ %s ]") % keyName,
        )
Пример #37
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        envName     = self.get_option('env')

        env = get_environment(orgName, envName)
        prod = get_product(orgName, prodName)

        returnCode = os.EX_OK

        cset = self.csapi.create(orgName, env["id"], self.create_cs_name())
        try:
            self.csapi.add_content(cset["id"], "products", {'product_id': prod['id']})
            task = self.csapi.promote(cset["id"])
            task = AsyncTask(task)

            run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the product, please wait... "))

            if task.succeeded():
                print _("Product [ %s ] promoted to environment [ %s ] " % (prodName, envName))
                returnCode = os.EX_OK
            else:
                print _("Product [ %s ] promotion failed: %s" % (prodName, format_task_errors(task.errors())) )
                returnCode = os.EX_DATAERR

        except Exception as e:
            #exception message is printed from action's main method
            raise e

        return returnCode
Пример #38
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('environment')
        keyName = self.get_option('name')
        keyDescription = self.get_option('description')
        templateName = self.get_option('template')
        usageLimit = self.get_option('usage_limit')

        if usageLimit is None:
            usageLimit = -1
        else:
            if int(usageLimit) <= 0:
                print >> sys.stderr, _("Usage limit [ %s ] must be higher than one") % usageLimit
                return os.EX_DATAERR

        environment = get_environment(orgName, envName)

        try:
            templateId = self.get_template_id(environment['id'], templateName)
        except OptionException:
            print >> sys.stderr, _("Couldn't find template '%s'") % templateName
            return os.EX_DATAERR

        key = self.api.create(environment['id'], keyName, keyDescription, usageLimit, templateId)
        test_record(key,
            _("Successfully created activation key [ %s ]") % keyName,
            _("Could not create activation key [ %s ]") % keyName
        )
Пример #39
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('environment')
        keyName = self.get_option('name')
        keyDescription = self.get_option('description')
        usageLimit = self.get_option('usage_limit')
        view_label = self.get_option('view')

        if usageLimit is None:
            usageLimit = -1
        else:
            if int(usageLimit) <= 0:
                print >> sys.stderr, _("Usage limit [ %s ] must be higher than one") % usageLimit
                return os.EX_DATAERR

        environment = get_environment(orgName, envName)

        if view_label is not None:
            view = get_content_view(orgName, view_label)
            view_id = view['id']
        else:
            view_id = None

        key = self.api.create(environment['id'], keyName, keyDescription, usageLimit, view_id)
        test_record(key,
            _("Successfully created activation key [ %s ]") % keyName,
            _("Could not create activation key [ %s ]") % keyName
        )
Пример #40
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('env')
        view_label = self.get_option('label')
        view_id = self.get_option('id')
        view_name = self.get_option('name')

        view = get_content_view(org_name, view_label, view_name, view_id)
        if env_name:
            env = get_environment(org_name, env_name)
            env_id = env["id"] if env else None
        else:
            env = get_library(org_name)
            env_id = env["id"] if env else None

        view = self.api.show(org_name, view["id"], env_id)

        self.printer.add_column('id', _("ID"))
        self.printer.add_column('name', _("Name"))
        self.printer.add_column('label', _("Label"))
        self.printer.add_column('description', _("Description"), multiline=True)
        self.printer.add_column('organization', _('Org'))
        self.printer.add_column('definition', _("Definition"))
        self.printer.add_column('environments', _('Environments'),
                                multiline=True)
        self.printer.add_column('versions', _("Versions"), multiline=True)
        self.printer.add_column('repositories', _('Repos'),
                                multiline=True)

        self.printer.set_header(_("ContentView Info"))
        self.printer.print_item(view)
        return os.EX_OK
Пример #41
0
    def run(self):
        mode = get_katello_mode()
        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')
        if mode == 'katello':
            default_environment = self.get_option('default_environment')
        elif default_organization is not None:
            default_environment = 'Library'
        no_default_environment = self.get_option('no_default_environment')
        default_locale = self.get_option('default_locale')

        if no_default_environment is True:
            environment = None
        elif default_environment is not None:
            environment = get_environment(default_organization, default_environment)
        else:
            environment = False

        user = get_user(username)

        user = self.api.update(user['id'], password, email, disabled, environment, default_locale)
        print _("Successfully updated user [ %s ]") % username
        return os.EX_OK
Пример #42
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        prodLabel   = self.get_option('label')
        prodId      = self.get_option('id')
        envName     = self.get_option('environment')

        env = get_environment(orgName, envName)
        prod = get_product(orgName, prodName, prodLabel, prodId)


        if not self.repoapi.repos_by_product(orgName, prod['id']):
            print _("Product [ %(prod_name)s ] has no repository") % {'prod_name':prod['name']}
            return os.EX_DATAERR

        cset = self.csapi.create(orgName, env["id"], self.create_cs_name(), constants.PROMOTION)

        self.csapi.add_content(cset["id"], "products", {'product_id': prod['id']})
        task = self.csapi.apply(cset["id"])
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the product, please wait... "))

        return evaluate_task_status(task,
            failed = _("Product [ %s ] promotion failed") % prod["name"],
            ok =     _("Product [ %(prod)s ] promoted to environment [ %(env)s ]") %
                {'prod':prod["name"], 'env':envName}
        )
Пример #43
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        prov_name = self.get_option('prov')
        all_opt = self.get_option('all')

        batch_add_columns(self.printer, {'id': _("ID")}, {'name': _("Name")}, \
            {'label': _("Label")}, {'provider_id': _("Provider ID")}, \
            {'provider_name': _("Provider Name")}, {'sync_plan_name': _("Sync Plan Name")})
        self.printer.add_column('last_sync', _("Last Sync"), formatter=format_sync_time)
        self.printer.add_column('gpg_key_name', _("GPG key"))

        if prov_name:
            prov = get_provider(org_name, prov_name)

            self.printer.set_header(_("Product List For Provider [ %s ]") % (prov_name))
            prods = self.api.products_by_provider(prov["id"])

        else:
            env = get_environment(org_name, env_name)

            self.printer.set_header(_("Product List For Organization %(org_name)s, Environment '%(env_name)s'") \
                % {'org_name':org_name, 'env_name':env["name"]})
            prods = self.api.products_by_env(env['id'])

        # hide marketing products by default
        if not all_opt:
            def isNotMarketingProduct(p):
                return not (("marketing_product" in p) and (p["marketing_product"]))
            prods = filter(isNotMarketingProduct, prods)

        self.printer.print_items(prods)

        return os.EX_OK
Пример #44
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        prov_name = self.get_option('prov')
        all_opt = self.get_option('all')

        batch_add_columns(self.printer, {'id': _("ID")}, {'name': _("Name")}, \
            {'label': _("Label")}, {'provider_id': _("Provider ID")}, \
            {'provider_name': _("Provider Name")}, {'sync_plan_name': _("Sync Plan Name")})
        self.printer.add_column('last_sync', _("Last Sync"), formatter=format_sync_time)
        self.printer.add_column('gpg_key_name', _("GPG key"))

        if prov_name:
            prov = get_provider(org_name, prov_name)

            self.printer.set_header(_("Product List For Provider [ %s ]") % (prov_name))
            prods = self.api.products_by_provider(prov["id"])

        else:
            env = get_environment(org_name, env_name)

            self.printer.set_header(_("Product List For Organization %(org_name)s, Environment '%(env_name)s'") \
                % {'org_name':org_name, 'env_name':env["name"]})
            prods = self.api.products_by_env(env['id'])

        # hide marketing products by default
        if not all_opt:
            def isNotMarketingProduct(p):
                return not (("marketing_product" in p) and (p["marketing_product"]))
            prods = filter(isNotMarketingProduct, prods)

        self.printer.print_items(prods)

        return os.EX_OK
Пример #45
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        sys_name = self.get_option('name')
        new_name = self.get_option('new_name')
        new_environment_name = self.get_option('new_environment')
        new_description = self.get_option('description')
        new_location = self.get_option('location')
        new_release = self.get_option('release')
        new_sla = self.get_option('sla')
        sys_uuid = self.get_option('uuid')
        view_name = self.get_option("view_name")
        view_label = self.get_option("view_label")
        view_id = self.get_option("view_id")
        remove_view = self.get_option("remove_view")

        system = get_system(org_name, sys_name, env_name, sys_uuid)
        new_environment = get_environment(org_name, new_environment_name)

        updates = {}
        if new_name:
            updates['name'] = new_name
        if new_description:
            updates['description'] = new_description
        if new_location:
            updates['location'] = new_location
        if new_release:
            updates['releaseVer'] = new_release
        if new_sla:
            updates['serviceLevel'] = new_sla
        if new_environment_name:
            new_environment = get_environment(org_name, new_environment_name)
            updates['environment_id'] = new_environment['id']

        if remove_view:
            updates["content_view_id"] = False
        elif view_label or view_name or view_id:
            updates["content_view_id"] = get_content_view(org_name, view_label,
                                                          view_name, view_id)["id"]

        response = self.api.update(system['uuid'], updates)

        test_record(response,
            _("Successfully updated system [ %s ]") % system['name'],
            _("Could not update system [ %s ]") % system['name']
        )
Пример #46
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        sys_name = self.get_option('name')
        new_name = self.get_option('new_name')
        new_environment_name = self.get_option('new_environment')
        new_description = self.get_option('description')
        new_location = self.get_option('location')
        new_release = self.get_option('release')
        new_sla = self.get_option('sla')
        sys_uuid = self.get_option('uuid')
        view_name = self.get_option("view_name")
        view_label = self.get_option("view_label")
        view_id = self.get_option("view_id")
        remove_view = self.get_option("remove_view")

        system = get_system(org_name, sys_name, env_name, sys_uuid)
        new_environment = get_environment(org_name, new_environment_name)

        updates = {}
        if new_name:
            updates['name'] = new_name
        if new_description:
            updates['description'] = new_description
        if new_location:
            updates['location'] = new_location
        if new_release:
            updates['releaseVer'] = new_release
        if new_sla is not None:
            updates['serviceLevel'] = new_sla
        if new_environment_name:
            new_environment = get_environment(org_name, new_environment_name)
            updates['environment_id'] = new_environment['id']

        if remove_view:
            updates["content_view_id"] = False
        elif view_label or view_name or view_id:
            updates["content_view_id"] = get_content_view(
                org_name, view_label, view_name, view_id)["id"]

        response = self.api.update(system['uuid'], updates)

        test_record(response,
                    _("Successfully updated system [ %s ]") % system['name'],
                    _("Could not update system [ %s ]") % system['name'])
Пример #47
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('name')

        env = get_environment(orgName, envName)

        self.api.delete(orgName, env["id"])
        print _("Successfully deleted environment [ %s ]") % envName
        return os.EX_OK
Пример #48
0
    def run(self):
        orgName     = self.get_option('org')
        envName     = self.get_option('name')

        env = get_environment(orgName, envName)

        self.api.delete(orgName, env["id"])
        print _("Successfully deleted environment [ %s ]") % envName
        return os.EX_OK
Пример #49
0
    def run(self):
        name = self.get_option('name')
        org = self.get_option('org')
        environment_name = self.get_option('environment')

        environment_id = None
        if environment_name is not None:
            environment_id = get_environment(org, environment_name)['id']

        distributor = self.api.create(name, org, environment_id, 'distributor')

        test_record(distributor,
                    _("Successfully createed distributor [ %s ]") % name,
                    _("Could not create distributor [ %s ]") % name)
Пример #50
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('environment')
        prodName = self.get_option('product')
        prodLabel = self.get_option('product_label')
        prodId = self.get_option('product_id')
        listDisabled = self.has_option('disabled')

        batch_add_columns(self.printer, {'id': _("ID")}, {'name': _("Name")}, \
            {'label': _("Label")}, {'package_count': _("Package Count")})
        self.printer.add_column('last_sync', _("Last Sync"), formatter=format_sync_time)

        prodIncluded = prodName or prodLabel or prodId
        if prodIncluded and envName:
            env  = get_environment(orgName, envName)
            prod = get_product(orgName, prodName, prodLabel, prodId)

            self.printer.set_header(_("Repo List For Org %(org_name)s Environment %(env_name)s Product %(prodName)s") %
                {'org_name':orgName, 'env_name':env["name"], 'prodName':prodName})
            repos = self.api.repos_by_env_product(env["id"], prod["id"], None, listDisabled)
            self.printer.print_items(repos)

        elif prodIncluded:
            prod = get_product(orgName, prodName, prodLabel, prodId)
            self.printer.set_header(_("Repo List for Product %(prodName)s in Org %(orgName)s ") %
                {'prodName':prodName, 'orgName':orgName})
            repos = self.api.repos_by_product(orgName, prod["id"], listDisabled)
            self.printer.print_items(repos)

        else:
            env  = get_environment(orgName, envName)
            self.printer.set_header(_("Repo List For Org %(orgName)s Environment %(env_name)s") %
                {'orgName':orgName, 'env_name':env["name"]})
            repos = self.api.repos_by_org_env(orgName,  env["id"], listDisabled)
            self.printer.print_items(repos)

        return os.EX_OK
Пример #51
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')
        usageLimit = self.get_option('usage_limit')
        add_poolids = self.get_option('add_poolid') or []
        remove_poolids = self.get_option('remove_poolid') or []
        view_label = self.get_option("view_label")
        view_name = self.get_option("view_name")
        view_id = self.get_option("view_id")
        remove_view = self.get_option("remove_view")

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

        keys = self.api.activation_keys_by_organization(orgName, keyName)
        if len(keys) == 0:
            print >> sys.stderr, _(
                "Could not find activation key [ %s ]") % keyName
            return os.EX_DATAERR
        key = keys[0]

        if remove_view:
            view_id = False
        elif view_name or view_label or view_id:
            view = get_content_view(orgName, view_label, view_name, view_id)
            view_id = view['id']
        else:
            view_id = None

        key = self.api.update(
            orgName, key['id'],
            environment['id'] if environment != None else None, newKeyName,
            keyDescription, usageLimit, view_id)

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

        if key != None:
            print _("Successfully updated activation key [ %s ]") % key['name']
            return os.EX_OK
        else:
            return os.EX_DATAERR
Пример #52
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('name')

        env = get_environment(orgName, envName)

        self.printer.add_column('id')
        self.printer.add_column('name')
        self.printer.add_column('description', multiline=True)
        self.printer.add_column('organization', _('Org'))
        self.printer.add_column('prior', _('Prior Environment'))

        self.printer.set_header(_("Environment Info"))
        self.printer.print_item(env)
        return os.EX_OK
Пример #53
0
    def run(self):
        envName = self.get_option('name')
        description = self.get_option('description')
        orgName = self.get_option('org')
        priorName = self.get_option('prior')

        env = get_environment(orgName, envName)

        if priorName != None:
            priorId = self.get_prior_id(orgName, priorName)
        else:
            priorId = None
        env = self.api.update(orgName, env["id"], envName, description,
                              priorId)
        print _("Successfully updated environment [ %s ]") % env['name']
        return os.EX_OK
Пример #54
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('env')
        csName = self.get_option('name')
        csDescription = self.get_option('description')

        env = get_environment(orgName, envName)
        cset = self.api.create(orgName, env["id"], csName, csDescription)
        test_record(
            cset,
            _("Successfully created changeset [ %s ] for environment [ %s ]") %
            (csName, env["name"]),
            _("Could not create changeset [ %s ] for environment [ %s ]") %
            (csName, env["name"]))

        return os.EX_OK
Пример #55
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
Пример #56
0
    def run(self):
        envName = self.get_option('env')
        orgName = self.get_option('org')

        environment = get_environment(orgName, envName)
        templates = self.api.templates(environment["id"])

        if not templates:
            print _("No templates found in environment [ %s ]") % environment["name"]
            return os.EX_OK
        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('parent_id')

        self.printer.set_header(_("Template List"))
        self.printer.print_items(templates)
        return os.EX_OK
Пример #57
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('env')
        verbose = self.get_option('verbose')

        env = get_environment(orgName, envName)
        changesets = self.api.changesets(orgName, env['id'])

        self.printer.add_column('id')
        self.printer.add_column('name')
        self.printer.add_column('updated_at', formatter=format_date)
        self.printer.add_column('state')
        self.printer.add_column('environment_id')
        self.printer.add_column('environment_name')
        if verbose: self.printer.add_column('description', multiline=True)

        self.printer.set_header(_("Changeset List"))
        self.printer.print_items(changesets)
        return os.EX_OK
Пример #58
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_environment = self.get_option('default_environment')
        default_locale = self.get_option('default_locale')

        if default_environment is not None:
            environment = get_environment(default_organization,
                                          default_environment)
        else:
            environment = None

        user = self.api.create(username, password, email, disabled,
                               environment, default_locale)
        test_record(user,
                    _("Successfully created user [ %s ]") % username,
                    _("Could not create user [ %s ]") % username)
Пример #59
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        sys_name = self.get_option('name')

        if sys_name:
            system = get_system(org_name, sys_name)
            releases = self.api.releases_for_system(system["uuid"])["releases"]
        else:
            environment = get_environment(org_name, env_name)
            releases = self.api.releases_for_environment(
                environment['id'])["releases"]

        releases = [{"value": r} for r in releases]

        self.printer.set_header(_("Available releases"))
        self.printer.add_column('value')

        self.printer.print_items(releases)
        return os.EX_OK
Пример #60
0
    def run(self):
        orgName = self.get_option('org')
        envName = self.get_option('env')
        keyName = self.get_option('name')
        keyDescription = self.get_option('description')
        templateName = self.get_option('template')

        environment = get_environment(orgName, envName)

        try:
            templateId = self.get_template_id(environment['id'], templateName)
        except OptionException:
            print >> sys.stderr, _(
                "Could not find template [ %s ]") % templateName
            return os.EX_DATAERR

        key = self.api.create(environment['id'], keyName, keyDescription,
                              templateId)
        test_record(key,
                    _("Successfully created activation key [ %s ]") % keyName,
                    _("Could not create activation key [ %s ]") % keyName)