コード例 #1
0
def make_proxy(options=None):
    """
    Usage::

        hammer proxy create [OPTIONS]

    Options::

        --name NAME
        --url URL
    """

    args = {
        u'name': generate_name(),
    }

    args = update_dictionary(args, options)
    if options and 'url' in options:
        args.update(create_object(Proxy, args))
    else:
        newport = random.randint(9191, 49090)
        with default_url_on_new_port(9090, newport) as url:
            args['url'] = url
            args.update(create_object(Proxy, args))

    return args
コード例 #2
0
ファイル: factory.py プロジェクト: bluesky-sgao/robottelo
def make_lifecycle_environment(options=None):
    """
    Usage:
    hammer lifecycle-environment create [OPTIONS]

    Options:
        --organization-id ORGANIZATION_ID name of organization
        --name NAME                   name of the environment
        --description DESCRIPTION     description of the environment
        --prior PRIOR                 Name of an environment that is prior to
    the new environment in the chain. It has to be either ‘Library’ or an
    environment at the end of a chain.


    """

    # Organization ID is required
    if not options or not options.get('organization-id', None):
        raise Exception("Please provide a valid ORG ID.")
    if not options.get('prior', None):
        options['prior'] = 'Library'

    # Assigning default values for attributes
    args = {
        'organization-id': None,
        'name': generate_name(6),
        'description': None,
        'prior': None,
    }

    args = update_dictionary(args, options)
    args.update(create_object(LifecycleEnvironment, args))

    return args
コード例 #3
0
def make_model(options=None):
    """
    Usage::

        hammer model create [OPTIONS]

    Options::

        --name NAME
        --info INFO
        --vendor-class VENDOR_CLASS
        --hardware-model HARDWARE_MODEL
    """

    args = {
        u'name': generate_name(),
        u'info': None,
        u'vendor-class': None,
        u'hardware-model': None,
    }

    # Override default dictionary with updated one
    args = update_dictionary(args, options)
    args.update(create_object(Model, args))

    return args
コード例 #4
0
ファイル: factory.py プロジェクト: bluesky-sgao/robottelo
def make_product(options=None):
    """
    Usage:
        hammer product create [OPTIONS]

    Options:
        --description DESCRIPTION     Product description
        --gpg-key-id GPG_KEY_ID       Identifier of the GPG key
        --label LABEL
        --name NAME
        --organization-id ORGANIZATION_ID ID of the organization
        --sync-plan-id SYNC_PLAN_ID   Plan numeric identifier
        -h, --help                    print help
    """

    # Organization ID is a required field.
    if not options or not options.get('organization-id', None):
        raise Exception("Please provide a valid ORG ID.")

    args = {
        'name': generate_string('alpha', 20),
        'label': generate_string('alpha', 20),
        'description': generate_string('alpha', 20),
        'organization-id': None,
        'gpg-key-id': None,
        'sync-plan-id': None,
    }

    args = update_dictionary(args, options)
    args.update(create_object(Product, args))

    return args
コード例 #5
0
ファイル: factory.py プロジェクト: jhutar/robottelo
def make_product(options=None):
    """
    Usage::

        hammer product create [OPTIONS]

    Options::

        --description DESCRIPTION     Product description
        --gpg-key-id GPG_KEY_ID       Identifier of the GPG key
        --label LABEL
        --name NAME
        --organization-id ORGANIZATION_ID ID of the organization
        --sync-plan-id SYNC_PLAN_ID   Plan numeric identifier
        -h, --help                    print help
    """

    # Organization ID is a required field.
    if not options or not options.get("organization-id", None):
        raise CLIFactoryError("Please provide a valid ORG ID.")

    args = {
        u"name": generate_string("alpha", 20),
        u"label": generate_string("alpha", 20),
        u"description": generate_string("alpha", 20),
        u"organization-id": None,
        u"gpg-key-id": None,
        u"sync-plan-id": None,
    }

    args = update_dictionary(args, options)
    args.update(create_object(Product, args))

    return args
コード例 #6
0
ファイル: factory.py プロジェクト: bluesky-sgao/robottelo
def make_host_collection(options=None):
    """
    Usage:
         host-collection create [OPTIONS]

    Options:
        --description DESCRIPTION
        --max-content-hosts MAX_CONTENT_HOSTS Maximum number of content hosts
                                              in the host collection
        --name NAME                   Host Collection name
        --organization ORGANIZATION_NAME
        --organization-id ORGANIZATION_ID organization identifier
        --organization-label ORGANIZATION_LABEL
        --system-ids SYSTEM_IDS       List of system uuids to be in the
                                      host collection
                                      Comma separated list of values.
    """

    # Organization ID is required
    if not options or not options.get('organization-id', None):
        raise Exception("Please provide a valid ORGANIZATION_ID.")

    # Assigning default values for attributes
    args = {
        'description': None,
        'max-content-hosts': None,
        'name': generate_string('alpha', 15),
        'organization-id': None,
        'system-ids': None,
    }

    args = update_dictionary(args, options)
    args.update(create_object(HostCollection, args))

    return args
コード例 #7
0
ファイル: factory.py プロジェクト: bluesky-sgao/robottelo
def make_sync_plan(options=None):
    """
    Usage:
        hammer sync-plan create [OPTIONS]

    Options:
        --description DESCRIPTION     sync plan description
        --interval INTERVAL           how often synchronization should run
                                      One of ''none',', ''hourly',',
                                      ''daily',', ''weekly''
                                      Default: "none"
        --name NAME                   sync plan name
        --organization-id ORGANIZATION_ID Filter products by organization
                                      name or label
        --sync-date SYNC_DATE         start date and time of the
                                      synchronization Date and time
                                      in YYYY-MM-DD HH:MM:SS or ISO 8601 format
    """

    # Organization ID is a required field.
    if not options or not options.get('organization-id', None):
        raise Exception("Please provide a valid ORG ID.")

    args = {
        'name': generate_string('alpha', 20),
        'description': generate_string('alpha', 20),
        'organization-id': None,
        'sync-date': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
        'interval': random.choice(SYNC_INTERVAL.values()),
    }

    args = update_dictionary(args, options)
    args.update(create_object(SyncPlan, args))

    return args
コード例 #8
0
ファイル: factory.py プロジェクト: bluesky-sgao/robottelo
def make_user(options=None):
    """
    Usage:
        hammer user create [OPTIONS]

    Options:
        --login LOGIN
        --firstname FIRSTNAME
        --lastname LASTNAME
        --mail MAIL
        --admin ADMIN                 Is an admin account?
        --password PASSWORD
        --auth-source-id AUTH_SOURCE_ID
    """

    login = generate_name(6)

    # Assigning default values for attributes
    args = {
        'login': login,
        'firstname': generate_name(),
        'lastname': generate_name(),
        'mail': "*****@*****.**" % login,
        'admin': None,
        'password': generate_name(),
        'auth-source-id': 1,
    }

    args = update_dictionary(args, options)
    args.update(create_object(User, args))

    return args
コード例 #9
0
ファイル: factory.py プロジェクト: jhutar/robottelo
def make_proxy(options=None):
    """
    Usage::

        hammer proxy create [OPTIONS]

    Options::

        --name NAME
        --url URL
    """

    args = {u"name": generate_name()}

    args = update_dictionary(args, options)
    if options and "url" in options:
        args.update(create_object(Proxy, args))
    else:
        newport = random.randint(9191, 49090)
        try:
            with default_url_on_new_port(9090, newport) as url:
                args["url"] = url
                args.update(create_object(Proxy, args))
        except SSHTunnelError as err:
            raise CLIFactoryError("Failed to create ssh tunnel: {0}".format(err))

    return args
コード例 #10
0
ファイル: factory.py プロジェクト: jhutar/robottelo
def make_lifecycle_environment(options=None):
    """
    Usage::

        hammer lifecycle-environment create [OPTIONS]

    Options::

        --organization-id ORGANIZATION_ID name of organization
        --name NAME                 name of the environment
        --description DESCRIPTION   description of the environment
        --prior PRIOR               Name of an environment that is prior to
                                    the new environment in the chain. It has to
                                    be either ‘Library’ or an environment at
                                    the end of a chain.

    """

    # Organization ID is required
    if not options or not options.get("organization-id", None):
        raise CLIFactoryError("Please provide a valid ORG ID.")
    if not options.get("prior", None):
        options["prior"] = "Library"

    # Assigning default values for attributes
    args = {u"organization-id": None, u"name": generate_name(6), u"description": None, u"prior": None}

    args = update_dictionary(args, options)
    args.update(create_object(LifecycleEnvironment, args))

    return args
コード例 #11
0
def make_hostgroup(options=None):
    """
    Usage::

        hammer hostgroup create [OPTIONS]

    Options::

        --architecture ARCHITECTURE_NAME Architecture name
        --architecture-id ARCHITECTURE_ID
        --domain DOMAIN_NAME          Domain name
        --domain-id DOMAIN_ID         May be numerical id or domain name
        --environment ENVIRONMENT_NAME Environment name
        --environment-id ENVIRONMENT_ID
        --medium MEDIUM_NAME          Medium name
        --medium-id MEDIUM_ID
        --name NAME
        --operatingsystem-id OPERATINGSYSTEM_ID
        --parent-id PARENT_ID
        --ptable PTABLE_NAME          Partition table name
        --ptable-id PTABLE_ID
        --puppet-ca-proxy-id PUPPET_CA_PROXY_ID
        --puppet-proxy-id PUPPET_PROXY_ID
        --puppetclass-ids PUPPETCLASS_IDS Comma separated list of values.
        --realm REALM_NAME            Name to search by
        --realm-id REALM_ID           May be numerical id or realm name
        --subnet SUBNET_NAME          Subnet name
        --subnet-id SUBNET_ID
    """
    # Assigning default values for attributes
    args = {
        u'architecture': None,
        u'architecture-id': None,
        u'domain': None,
        u'domain-id': None,
        u'environment': None,
        u'medium': None,
        u'medium-id': None,
        u'name': generate_name(6),
        u'operatingsystem-id': None,
        u'parent-id': None,
        u'ptable': None,
        u'ptable-id': None,
        u'puppet-ca-proxy-id': None,
        u'puppet-proxy-id': None,
        u'puppetclass-ids': None,
        u'realm': None,
        u'realm-id': None,
        u'subnet': None,
        u'subnet-id': None,
    }
    args = update_dictionary(args, options)
    args.update(create_object(HostGroup, args))

    return args
コード例 #12
0
ファイル: factory.py プロジェクト: jhutar/robottelo
def make_activation_key(options=None):
    """
    Usage::

        hammer activation-key create [OPTIONS]

    Options::

        --content-view CONTENT_VIEW_NAME Content view name to search by
        --content-view-id CONTENT_VIEW_ID content view numeric identifier
        --description DESCRIPTION     description
        --lifecycle-environment LIFECYCLE_ENVIRONMENT_NAME Name to search by
        --lifecycle-environment-id LIFECYCLE_ENVIRONMENT_ID
        --max-content-hosts MAX_CONTENT_HOSTS maximum number of registered
                                              content hosts
        --name NAME                   name
        --organization ORGANIZATION_NAME Organization name to search by
        --organization-id ORGANIZATION_ID
        --organization-label ORGANIZATION_LABEL Organization label to search by
        --unlimited-content-hosts UNLIMITED_CONTENT_HOSTS can the activation
                                                          key have unlimited
                                                          content hosts
    """

    # Organization Name, Label or ID is a required field.
    if (
        not options
        or not options.get("organization", None)
        and not options.get("organization-label", None)
        and not options.get("organization-id", None)
    ):
        raise CLIFactoryError("Please provide a valid Organization.")

    args = {
        u"content-view": None,
        u"content-view-id": None,
        u"description": None,
        u"lifecycle-environment": None,
        u"lifecycle-environment-id": None,
        u"max-content-hosts": None,
        u"name": generate_name(),
        u"organization": None,
        u"organization-id": None,
        u"organization-label": None,
        u"unlimited-content-hosts": True,
    }

    # Override default dictionary with updated one
    args = update_dictionary(args, options)
    args.update(create_object(ActivationKey, args))

    return args
コード例 #13
0
ファイル: factory.py プロジェクト: connornishijima/robottelo
def core_factory(create_args, kwargs, session, page, org=None, loc=None,
                 force_context=False):
    """ Performs various factory tasks.

    Updates the ``create_args`` dictionary, calls the ``set_context`` function
    to set ``org`` and ``loc`` context and finally navigates to the entities
    page.

    :param dict create_args: Default entities arguments.
    :param kwargs: Arbitrary keyword arguments to update create_args.
    :param session: The browser session.
    :param page: The entity function for navigation.
    :param str org: The organization context to set.
    :param str loc: The location context to set.
    :param bool force_context: If True set the context again.
    :return: None.

    """
    update_dictionary(create_args, kwargs)
    if org or loc:
        set_context(session, org=org, loc=loc, force_context=force_context)
    page()
コード例 #14
0
ファイル: factory.py プロジェクト: bluesky-sgao/robottelo
def make_os(options=None):
    """
        Creates the operating system
        """
    # Assigning default values for attributes
    args = {
        'name': generate_name(6),
        'major': random.randint(0, 10),
        'minor': random.randint(0, 10),
    }

    args = update_dictionary(args, options)
    args.update(create_object(OperatingSys, args))

    return args
コード例 #15
0
def make_repository(options=None):
    """
    Usage::

        hammer repository create [OPTIONS]

    Options::

        --content-type CONTENT_TYPE   type of repo (either 'yum' or 'puppet',
                                      defaults to 'yum')
        --gpg-key GPG_KEY_NAME
        --gpg-key-id GPG_KEY_ID       id of the gpg key that will be assigned
                                      to the new repository
        --label LABEL
        --name NAME
        --organization ORGANIZATION_NAME
        --organization-id ORGANIZATION_ID
        --organization-label ORGANIZATION_LABEL
        --product PRODUCT_NAME
        --product-id PRODUCT_ID       Product the repository belongs to
        --publish-via-http ENABLE     Publish Via HTTP
                                      One of true/false, yes/no, 1/0.
        --url URL                     repository source url
    """

    # Product ID is a required field.
    if not options or not options.get('product-id', None):
        raise CLIFactoryError("Please provide a valid Product ID.")

    args = {
        u'name': generate_string('alpha', 15),
        u'label': None,
        u'content-type': u'yum',
        u'product': None,
        u'product-id': None,
        u'publish-via-http': u'true',
        u'url': u'http://omaciel.fedorapeople.org/fakerepo01/',
        u'gpg-key': None,
        u'gpg-key-id': None,
        u'organization': None,
        u'organization-id': None,
        u'organization-label': None,
    }

    args = update_dictionary(args, options)
    args.update(create_object(Repository, args))

    return args
コード例 #16
0
ファイル: factory.py プロジェクト: jhutar/robottelo
def make_role(options=None):
    """Usage::

        hammer role create [OPTIONS]

    Options::

        --name NAME
    """

    # Assigning default values for attributes
    args = {u"name": generate_name(6)}
    args = update_dictionary(args, options)
    args.update(create_object(Role, args))

    return args
コード例 #17
0
def make_partition_table(options=None):
    """
    Usage::

        hammer partition_table update [OPTIONS]

    Options::

        --file LAYOUT                 Path to a file that contains
                                      the partition layout
        --os-family OS_FAMILY
        --id ID                       resource id
        --name NAME                   resource name
        --new-name NEW_NAME           new name for the resource
        -h, --help                    print help

    Usage::

        hammer partition_table create [OPTIONS]

    Options::

        --file LAYOUT                 Path to a file that contains
                                      the partition layout
        --name NAME
        --os-family OS_FAMILY
    """
    if options is None:
        options = {}
    (_, layout) = mkstemp(text=True)
    os.chmod(layout, 0700)
    with open(layout, "w") as ptable:
        ptable.write(options.get('content', 'default ptable content'))

    args = {
        u'name': generate_name(),
        u'file': "/tmp/%s" % generate_name(),
        u'os-family': random.choice(OPERATING_SYSTEMS)
    }

    # Upload file to server
    ssh.upload_file(local_file=layout, remote_file=args['file'])

    args = update_dictionary(args, options)
    args.update(create_object(PartitionTable, args))

    return args
コード例 #18
0
ファイル: factory.py プロジェクト: bluesky-sgao/robottelo
def make_environment(options=None):
    """
    Usage:
    hammer environment create [OPTIONS]

    Options:
    --name NAME
    """
    # Assigning default values for attributes
    args = {
        'name': generate_name(6),
    }

    args = update_dictionary(args, options)
    args.update(create_object(Environment, args))

    return args
コード例 #19
0
ファイル: factory.py プロジェクト: bluesky-sgao/robottelo
def make_activation_key(options=None):
    """
    Usage:
        hammer activation-key create [OPTIONS]

    Options:
        --content-view CONTENT_VIEW_NAME
        --content-view-id CONTENT_VIEW_ID content view id
        --description DESCRIPTION     description
        --environment ENVIRONMENT_NAME
        --environment-id ENVIRONMENT_ID environment id
        --name NAME                   name
        --organization ORGANIZATION_NAME
        --organization-id ORGANIZATION_ID organization identifier
        --organization-label ORGANIZATION_LABEL
        --usage-limit USAGE_LIMIT     maximum number of registered
                                      content hosts, or 'unlimited'
    """

    # Organization Name, Label or ID is a required field.
    if (
            not options
            or not options.get('organization', None)
            and not options.get('organization-label', None)
            and not options.get('organization-id', None)):
        raise Exception("Please provide a valid Organization.")

    args = {
        'name': generate_name(),
        'description': None,
        'organization': None,
        'organization-id': None,
        'organization-label': None,
        'content-view': None,
        'content-view-id': None,
        'environment': None,
        'environment-id': None,
        'usage-limit': 'unlimited',
    }

    # Override default dictionary with updated one
    args = update_dictionary(args, options)
    args.update(create_object(ActivationKey, args))

    return args
コード例 #20
0
def make_medium(options=None):
    """
    Usage::

        hammer medium create [OPTIONS]

    Options::

        --name NAME             Name of media
        --path PATH             The path to the medium, can be a URL or a valid
                                NFS server (exclusive of the architecture)
                                for example http://mirror.centos.org/centos/
                                $version/os/$arch where $arch will be
                                substituted for the host’s actual OS
                                architecture and $version, $major and $minor
                                will be substituted for the version of the
                                operating system.
                                Solaris and Debian media may also use $release.
        --os-family OS_FAMILY   The family that the operating system belongs
                                to. Available families:
                                Archlinux
                                Debian
                                Gentoo
                                Redhat
                                Solaris
                                Suse
                                Windows
        --operatingsystem-ids OPERATINGSYSTEM_IDS
                                Comma separated list of values.
        --operatingsystem-ids OSIDS os ids
                                Comma separated list of values.

    """
    # Assigning default values for attributes
    args = {
        u'name': generate_name(6),
        u'path': 'http://%s' % (generate_string('alpha', 6)),
        u'os-family': None,
        u'operatingsystem-ids': None,
    }

    args = update_dictionary(args, options)
    args.update(create_object(Medium, args))

    return args
コード例 #21
0
def make_template(options=None):
    """
    Usage::

        hammer template create [OPTIONS]

    Options::

        --file TEMPLATE     Path to a file that contains the template
        --type TYPE         Template type. Eg. snippet, script, provision
        --name NAME         template name
        --audit-comment AUDIT_COMMENT
        --operatingsystem-ids OPERATINGSYSTEM_IDS
                            Array of operating systems ID to associate the
                            template with Comma separated list of values.

    """
    # Assigning default values for attribute
    args = {
        u'file': "/tmp/%s" % generate_name(),
        u'type': random.choice(TEMPLATE_TYPES),
        u'name': generate_name(6),
        u'audit-comment': None,
        u'operatingsystem-ids': None,
    }

    # Write content to file or random text
    if options is not None and 'content' in options.keys():
        content = options.pop('content')
    else:
        content = generate_name()

    # Special handling for template factory
    (file_handle, layout) = mkstemp(text=True)
    chmod(layout, 0700)
    with open(layout, "w") as ptable:
        ptable.write(content)
    # Upload file to server
    ssh.upload_file(local_file=layout, remote_file=args['file'])
    # End - Special handling for template factory

    args = update_dictionary(args, options)
    args.update(create_object(Template, args))

    return args
コード例 #22
0
def make_subnet(options=None):
    """
    Usage::

        hammer subnet create [OPTIONS]

    Options::

        --name NAME                   Subnet name
        --network NETWORK             Subnet network
        --mask MASK                   Netmask for this subnet
        --gateway GATEWAY             Primary DNS for this subnet
        --dns-primary DNS_PRIMARY     Primary DNS for this subnet
        --dns-secondary DNS_SECONDARY Secondary DNS for this subnet
        --from FROM                   Starting IP Address for IP auto
                                      suggestion
        --to TO                       Ending IP Address for IP auto suggestion
        --vlanid VLANID               VLAN ID for this subnet
        --domain-ids DOMAIN_IDS       Domains in which this subnet is part
                                      Comma separated list of values.
        --dhcp-id DHCP_ID             DHCP Proxy to use within this subnet
        --tftp-id TFTP_ID             TFTP Proxy to use within this subnet
        --dns-id DNS_ID               DNS Proxy to use within this subnet
    """

    args = {
        u'name': generate_name(8, 8),
        u'network': generate_ipaddr(ip3=True),
        u'mask': u'255.255.255.0',
        u'gateway': None,
        u'dns-primary': None,
        u'dns-secondary': None,
        u'from': None,
        u'to': None,
        u'vlanid': None,
        u'domain-ids': None,
        u'dhcp-id': None,
        u'tftp-id': None,
        u'dns-id': None,
    }

    args = update_dictionary(args, options)
    args.update(create_object(Subnet, args))

    return args
コード例 #23
0
def make_gpg_key(options=None):
    """
    Usage::

        hammer gpg create [OPTIONS]

    Options::

        --organization-id ORGANIZATION_ID organization identifier
        --name NAME                   identifier of the GPG Key
        --key GPG_KEY_FILE            GPG Key file
        -h, --help                    print help
    """

    # Organization ID is a required field.
    if not options or not options.get('organization-id', None):
        raise CLIFactoryError("Please provide a valid ORG ID.")

    # Create a fake gpg key file if none was provided
    if not options.get('key', None):
        (_, key_filename) = mkstemp(text=True)
        os.chmod(key_filename, 0700)
        with open(key_filename, "w") as gpg_key_file:
            gpg_key_file.write(generate_name(minimum=20, maximum=50))
    else:
        # If the key is provided get its local path and remove it from options
        # to not override the remote path
        key_filename = options.pop('key')

    args = {
        u'name': generate_name(),
        u'key': "/tmp/%s" % generate_name(),
        u'organization-id': None,
    }

    # Upload file to server
    ssh.upload_file(local_file=key_filename, remote_file=args['key'])

    args = update_dictionary(args, options)

    # gpg create returns a dict inside a list
    new_obj = create_object(GPGKey, args)
    args.update(new_obj)

    return args
コード例 #24
0
def make_compute_resource(options=None):
    """
    Usage::

        hammer compute_resource create [OPTIONS]

    Options::

        --name NAME
        --provider PROVIDER           Providers include Libvirt, Ovirt, EC2,
            Vmware, Openstack, Rackspace, GCE
        --url URL                     URL for Libvirt, Ovirt, and Openstack
        --description DESCRIPTION
        --user USER                   Username for Ovirt, EC2, Vmware,
            Openstack. Access Key for EC2.
        --password PASSWORD           Password for Ovirt, EC2, Vmware,
            Openstack. Secret key for EC2
        --uuid UUID                   for Ovirt, Vmware Datacenter
        --region REGION               for EC2 only
        --tenant TENANT               for Openstack only
        --server SERVER               for Vmware
        -h, --help                    print help
    """
    args = {
        u'name': generate_name(8, 8),
        u'provider': None,
        u'url': None,
        u'description': None,
        u'user': None,
        u'password': None,
        u'uuid': None,
        u'region': None,
        u'tenant': None,
        u'server': None
    }

    args = update_dictionary(args, options)
    if args['provider'] is None:
        args['provider'] = FOREMAN_PROVIDERS['libvirt']
        if args['url'] is None:
            args['url'] = "qemu+tcp://localhost:16509/system"
    args.update(create_object(ComputeResource, args))

    return args
コード例 #25
0
ファイル: factory.py プロジェクト: jhutar/robottelo
def make_domain(options=None):
    """
    Usage::

        hammer domain create [OPTIONS]

    Options::

        --name NAME                   The full DNS Domain name
        --dns-id DNS_ID               DNS Proxy to use within this domain
        --description DESC            Full name describing the domain
    """
    # Assigning default values for attributes
    args = {u"name": generate_name(6), u"dns-id": None, u"description": None}

    args = update_dictionary(args, options)
    args.update(create_object(Domain, args))

    return args
コード例 #26
0
ファイル: factory.py プロジェクト: jhutar/robottelo
def make_architecture(options=None):
    """
    Usage::

        hammer architecture create [OPTIONS]

    Options::

        --name NAME
        --operatingsystem-ids OPERATINGSYSTEM_IDS Operatingsystem ID’s
                                      Comma separated list of values.
    """

    args = {u"name": generate_name(), u"operatingsystem-ids": None}

    # Override default dictionary with updated one
    args = update_dictionary(args, options)
    args.update(create_object(Architecture, args))

    return args
コード例 #27
0
ファイル: factory.py プロジェクト: jhutar/robottelo
def make_org(options=None):
    """
    Usage::

        hammer organization create [OPTIONS]

    Options::

        --name NAME                   name
        --label LABEL                 unique label
        --description DESCRIPTION     description
    """

    # Assigning default values for attributes
    args = {u"name": generate_name(6), u"label": None, u"description": None}

    args = update_dictionary(args, options)
    args.update(create_object(Org, args))

    return args
コード例 #28
0
ファイル: factory.py プロジェクト: bluesky-sgao/robottelo
def make_proxy(options=None):
    """
    Usage:
        hammer proxy create [OPTIONS]

    Options:
        --name NAME
        --url URL
    """

    args = {
        'name': generate_name(),
        'url': 'http://%s:%s' % (generate_string('alpha', 6),
                                 generate_string('numeric', 4)),
    }

    args = update_dictionary(args, options)
    args.update(create_object(Proxy, args))

    return args
コード例 #29
0
ファイル: factory.py プロジェクト: jhutar/robottelo
def make_os(options=None):
    """
    Usage::

        hammer os create [OPTIONS]

    Options::

        --architecture-ids ARCH_IDS   set associated architectures
                                    Comma separated list of values.
        --config-template-ids CONFIG_TPL_IDS set associated templates
                                    Comma separated list of values.
        --description DESCRIPTION
        --family FAMILY
        --major MAJOR
        --medium-ids MEDIUM_IDS       set associated installation media
                                    Comma separated list of values.
        --minor MINOR
        --name NAME
        --ptable-ids PTABLE_IDS       set associated partition tables
                                    Comma separated list of values.
        --release-name RELEASE_NAME
    """
    # Assigning default values for attributes
    args = {
        u"architecture-ids": None,
        u"config-template-ids": None,
        u"description": None,
        u"family": None,
        u"major": random.randint(0, 10),
        u"medium-ids": None,
        u"minor": random.randint(0, 10),
        u"name": generate_name(6),
        u"ptable-ids": None,
        u"release-name": None,
    }

    args = update_dictionary(args, options)
    args.update(create_object(OperatingSys, args))

    return args
コード例 #30
0
def make_content_view(options=None):
    """
    Usage::

        hammer content-view create [OPTIONS]

    Options::

        --component-ids COMPONENT_IDS List of component content view
        version ids for composite views
                                    Comma separated list of values.
        --composite                   Create a composite content view
        --description DESCRIPTION     Description for the content view
        --label LABEL                 Content view label
        --name NAME                   Name of the content view
        --organization-id ORGANIZATION_ID Organization identifier
        --repository-ids REPOSITORY_IDS List of repository ids
                                    Comma separated list of values.
        -h, --help                    print help

    """

    # Organization ID is a required field.
    if not options or not options.get('organization-id', None):
        raise CLIFactoryError("Please provide a valid ORG ID.")

    args = {
        u'name': generate_string("alpha", 10),
        u'organization-id': None,
        u'composite': False,
        u'component-ids': None,
        u'label': None,
        u'description': None,
        u'repository-ids': None
    }

    # Override default dictionary with updated one
    args = update_dictionary(args, options)
    args.update(create_object(ContentView, args))

    return args