Esempio n. 1
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
Esempio n. 2
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
        )
Esempio n. 3
0
    def run(self):
        name = self.get_option("name")
        label = self.get_option("label")
        description = self.get_option("description")

        org = self.api.create(name, label, description)
        test_record(org, _("Successfully created org [ %s ]") % name, _("Could not create org [ %s ]") % name)
Esempio n. 4
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_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)
        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

        response = self.api.update(system_uuid, updates)

        test_record(response,
            _("Successfully updated system [ %s ]") % system['name'],
            _("Could not update system [ %s ]") % system['name']
        )
Esempio n. 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_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)
        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

        response = self.api.update(system_uuid, updates)

        test_record(response,
                    _("Successfully updated system [ %s ]") % system['name'],
                    _("Could not update system [ %s ]") % system['name'])
Esempio n. 6
0
    def run(self):
        name = self.get_option('name')
        description = self.get_option('description')

        org = self.api.create(name, description)
        test_record(org,
                    _("Successfully created org [ %s ]") % name,
                    _("Could not create org [ %s ]") % name)
Esempio n. 7
0
    def run(self):
        name = self.get_option('name')
        desc = self.get_option('desc')

        role = self.api.create(name, desc)
        test_record(role,
                    _("Successfully created user role [ %s ]") % name,
                    _("Could not create user role [ %s ]") % name)
Esempio n. 8
0
    def run(self):
        name = self.get_option('name')
        desc = self.get_option('desc')

        role = self.api.create(name, desc)
        test_record(role,
            _("Successfully created user role [ %s ]") % name,
            _("Could not create user role [ %s ]") % name
        )
Esempio n. 9
0
    def run(self):
        name        = self.get_option('name')
        description = self.get_option('description')

        org = self.api.create(name, description)
        test_record(org,
            _("Successfully created org [ %s ]") % name,
            _("Could not create org [ %s ]") % name
        )
Esempio n. 10
0
    def run(self):
        org = self.get_option('org')
        name = self.get_option('name')
        description = self.get_option('description')
        packages = self.parse_packages(self.get_option('packages'))

        new_filter = self.api.create(org, name, description, packages)

        test_record(new_filter,
                    _("Successfully created filter [ %s ]") % name,
                    _("Could not create filter [ %s ]") % name)
Esempio n. 11
0
    def run(self):
        org_name = self.get_option('org')
        name = self.get_option('name')
        description = self.get_option('description')
        max_systems = self.get_option('max_systems')

        system_group = self.api.create(org_name, name, description, max_systems)

        test_record(system_group,
            _("Successfully created system group [ %s ]") % system_group['name'],
            _("Could not create system group [ %s ]") % name
        )
Esempio n. 12
0
    def run(self):
        org = self.get_option('org')
        name = self.get_option('name')
        description = self.get_option('description')
        packages = self.parse_packages(self.get_option('packages'))

        new_filter = self.api.create(org, name, description, packages)

        test_record(new_filter,
            _("Successfully created filter [ %s ]") % name,
            _("Could not create filter [ %s ]") % name
        )
Esempio n. 13
0
    def run(self):
        name = self.get_option('name')
        description = self.get_option('description')
        orgName = self.get_option('org')
        priorName = self.get_option('prior')
        env = self.get_option('env')

        priorId = self.get_prior_id(orgName, priorName)

        env = self.api.create(orgName, name, description, priorId)
        test_record(env,
                    _("Successfully created environment [ %s ]") % name,
                    _("Could not create environment [ %s ]") % name)
Esempio n. 14
0
    def run(self):
        name        = self.get_option('name')
        description = self.get_option('description')
        orgName     = self.get_option('org')
        priorName   = self.get_option('prior')

        priorId = self.get_prior_id(orgName, priorName)

        env = self.api.create(orgName, name, description, priorId)
        test_record(env,
            _("Successfully created environment [ %s ]") % name,
            _("Could not create environment [ %s ]") % name
        )
Esempio n. 15
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
Esempio n. 16
0
    def run(self):
        org_name = self.get_option('org')
        name = self.get_option('name')
        description = self.get_option('description')
        max_systems = self.get_option('max_systems')

        system_group = self.api.create(org_name, name, description,
                                       max_systems)

        test_record(
            system_group,
            _("Successfully created system group [ %s ]") %
            system_group['name'],
            _("Could not create system group [ %s ]") % name)
Esempio n. 17
0
    def run(self):
        org_name = self.get_option('org')
        name = self.get_option('name')
        new_name = self.get_option('new_name')
        description = self.get_option('description')
        max_systems = self.get_option('max_systems')
        
        source_system_group = get_system_group(org_name, name)
        new_system_group = self.api.copy(org_name, source_system_group["id"], new_name, description, max_systems)

        test_record(new_system_group,
            _("Successfully copied system group [ %s ] to [ %s ]") % 
                       (source_system_group['name'], new_system_group['name']),
            _("Could not create system group [ %s ]") % new_name
        )
Esempio n. 18
0
    def run(self):
        name        = self.get_option('name')
        org_name    = self.get_option('org')
        description = self.get_option('description')
        interval    = self.get_option('interval')
        date        = self.get_option('date')
        time        = self.get_option('time')

        sync_date = self.parse_datetime(date, time)

        plan = self.api.create(org_name, name, sync_date, interval, description)
        test_record(plan,
            _("Successfully created synchronization plan [ %s ]") % name,
            _("Could not create synchronization plan [ %s ]") % name
        )
Esempio n. 19
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
Esempio n. 20
0
class Create(GpgKeyAction):

    description = _('create a GPG key')

    def setup_parser(self, parser):
        parser.add_option('--name', dest='name',
                               help=_("GPG key name (required)"))
        parser.add_option('--org', dest='org',
                               help=_("name of organization (required)"))
        parser.add_option('--file', dest='file',
                               help=_("file with public GPG key, if not\
                                 specified, standard input will be used"))

    def check_options(self, validator):
        validator.require(('name', 'org'))

    def run(self):
        orgName = self.get_option('org')
        keyName = self.get_option('name')
        try:
            content = self.read_content(True)
        except IOError as (c,m):
            print m
            return os.EX_DATAERR

        key = self.api.create(orgName, keyName, content)
        test_record(key,
            _("Successfully created GPG key [ %s ]") % keyName,
            _("Could not create GPG key [ %s ]") % keyName
        )
Esempio n. 21
0
    def run(self):
        name = self.get_option('name')
        org_name = self.get_option('org')
        description = self.get_option('description')
        interval = self.get_option('interval')
        date = self.get_option('date')
        time = self.get_option('time')

        sync_date = self.parse_datetime(date, time)

        plan = self.api.create(org_name, name, sync_date, interval,
                               description)
        test_record(
            plan,
            _("Successfully created synchronization plan [ %s ]") % name,
            _("Could not create synchronization plan [ %s ]") % name)
Esempio n. 22
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 {})

        environment_id = None
        if environment_name is not None:
            environment_id = get_environment(org, environment_name)["id"]
        system = self.api.register(name, org, environment_id, activation_keys, "system", release, sla, facts=facts)

        test_record(
            system, _("Successfully registered system [ %s ]") % name, _("Could not register system [ %s ]") % name
        )
Esempio n. 23
0
    def run(self):
        name = self.get_option("name")
        desc = self.get_option("description")
        orgName = self.get_option("org")
        parentName = self.get_option("parent")

        env = get_library(orgName)

        if parentName != None:
            parentId = self.get_parent_id(orgName, env["name"], parentName)
        else:
            parentId = None

        template = self.api.create(env["id"], name, desc, parentId)
        test_record(
            template, _("Successfully created template [ %s ]") % name, _("Could not create template [ %s ]") % name
        )
Esempio n. 24
0
    def run(self):
        role_name = self.get_option('user_role')
        name = self.get_option('name')
        desc = self.get_option('desc')
        org_name = self.get_option('org')
        scope = self.get_option('scope')
        verbs = self.get_option('verbs')
        tags = self.get_option('tags')

        tag_ids = self.tags_to_ids(tags, org_name, scope)

        role = get_role(role_name)

        permission = self.api.create(role['id'], name, desc, scope, verbs, tag_ids, org_name)
        test_record(permission,
            _("Successfully created permission [ %s ] for user role [ %s ]") % (name, role['name']),
            _("Could not create permission [ %s ]") % name
        )
Esempio n. 25
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')

        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)
        test_record(user,
            _("Successfully created user [ %s ]") % username,
            _("Could not create user [ %s ]") % username
        )
Esempio n. 26
0
    def run(self):
        name    = self.get_option('name')
        desc    = self.get_option('description')
        orgName = self.get_option('org')
        parentName = self.get_option('parent')

        env = get_library(orgName)

        if parentName != None:
            parentId = self.get_parent_id(orgName, env['name'], parentName)
        else:
            parentId = None

        template = self.api.create(env["id"], name, desc, parentId)
        test_record(template,
            _("Successfully created template [ %s ]") % name,
            _("Could not create template [ %s ]") % name
        )
Esempio n. 27
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 {})

        environment_id = None
        if environment_name is not None:
            environment_id = get_environment(org, environment_name)['id']
        system = self.api.register(name, org, environment_id, activation_keys, 'system', release, sla, facts=facts)

        test_record(system,
            _("Successfully registered system [ %s ]") % name,
            _("Could not register system [ %s ]") % name
        )
Esempio n. 28
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')
        keyname = self.get_option('keyname')
        value = self.get_option('value')

        system = get_system(org_name, sys_name, env_name, sys_uuid)

        custom_info_api = CustomInfoAPI()

        response = custom_info_api.add_custom_info("system", system['id'], keyname, value)

        ident = sys_uuid if sys_uuid else sys_name

        test_record(response,
            _("Successfully added Custom Information [ %s : %s ] to System [ %s ]") % (keyname, value, ident),
            _("Could not add Custom Information [ %s : %s ] to System [ %s ]") % (keyname, value, ident)
        )
Esempio n. 29
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')
        keyname = self.get_option('keyname')
        new_value = self.get_option('value')

        system = get_system(org_name, sys_name, env_name, sys_uuid)

        custom_info_api = CustomInfoAPI()

        response = custom_info_api.update_custom_info("system", system['id'], keyname, new_value)

        ident = sys_uuid if sys_uuid else sys_name

        test_record(response,
            _("Successfully updated Custom Information [ %s ] for System [ %s ]") % (keyname, ident),
            _("Could not update Custom Information [ %s ] for System [ %s ]") % (keyname, ident)
        )
Esempio n. 30
0
    def run(self):
        role_name = self.get_option('user_role')
        name = self.get_option('name')
        desc = self.get_option('desc')
        org_name = self.get_option('org')
        scope = self.get_option('scope')
        verbs = self.get_option('verbs')
        tags = self.get_option('tags')

        tag_ids = self.tags_to_ids(tags, org_name, scope)

        role = get_role(role_name)

        permission = self.api.create(role['id'], name, desc, scope, verbs,
                                     tag_ids, org_name)
        test_record(
            permission,
            _("Successfully created permission [ %s ] for user role [ %s ]") %
            (name, role['name']),
            _("Could not create permission [ %s ]") % name)
Esempio n. 31
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
        )
Esempio n. 32
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)
Esempio n. 33
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")

        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"]

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

        test_record(
            response,
            _("Successfully updated system [ %s ]") % system["name"],
            _("Could not update system [ %s ]") % system["name"],
        )
Esempio n. 34
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 {})

        environment_id = None
        if environment_name is not None:
            environment_id = get_environment(org, environment_name)['id']
        system = self.api.register(name,
                                   org,
                                   environment_id,
                                   activation_keys,
                                   'system',
                                   release,
                                   sla,
                                   facts=facts)

        test_record(system,
                    _("Successfully registered system [ %s ]") % name,
                    _("Could not register system [ %s ]") % name)
Esempio n. 35
0
class Update(GpgKeyAction):

    description = _('update a GPG key')

    def setup_parser(self, parser):
        parser.add_option('--name', dest='name',
                               help=_("GPG key name (required)"))
        parser.add_option('--org', dest='org',
                               help=_("name of organization (required)"))
        parser.add_option('--new_name', dest='new_name',
                              help=_("new template name"))
        parser.add_option('--file', dest='file',
                               help=_("file with public GPG key"))
        parser.add_option('--new_content', dest='new_content', action='store_true',
                               help=_("prompt for new content of the key"))


    def check_options(self, validator):
        validator.require(('name', 'org'))

    def run(self):
        orgName = self.get_option('org')
        keyName = self.get_option('name')
        newKeyName = self.get_option('new_name')

        try:
            content = self.read_content(self.get_option('new_content'))
        except IOError as (c,m):
            print m
            return os.EX_DATAERR

        key_id = self.get_key_id()
        if not key_id:
            print >> sys.stderr, _("Could not find GPG key [ %s ]") % keyName
            return os.EX_DATAERR

        key = self.api.update(key_id, newKeyName, content)
        test_record(key,
            _("Successfully updated GPG key [ %s ]") % keyName,
            _("Could not updated GPG key [ %s ]") % keyName
        )
Esempio n. 36
0
 def create(self, name, orgName, description, url):
     prov = self.api.create(name, orgName, description, "Custom", url)
     test_record(prov,
                 _("Successfully created provider [ %s ]") % name,
                 _("Could not create provider [ %s ]") % name)
Esempio n. 37
0
 def create(self, name, orgName, description, url):
     prov = self.api.create(name, orgName, description, "Custom", url)
     test_record(prov,
         _("Successfully created provider [ %s ]") % name,
         _("Could not create provider [ %s ]") % name
     )