def test_create_host(self): # Change delimiter to whatever you want, of course # in other tests mac_addr = generate_mac(":") "Create new host" # TODO need to create env, architecture, domain etc. args = { "name": generate_name(6), "environment-id": 1, "architecture-id": 1, "domain-id": 1, "puppet-proxy-id": 1, "operatingsystem-id": 1, "partition-table-id": 1, "mac": mac_addr() } Host().create(args)
def test_return_type(self): """Tests if generate mac returns a unicode string""" self.assertIsInstance(generate_mac(), unicode)
def generate(self): return generate_mac(self.delimiter)
def make_host(options=None): """ Usage:: hammer host create [OPTIONS] Options:: --architecture ARCHITECTURE_NAME Architecture name --architecture-id ARCHITECTURE_ID --ask-root-password ASK_ROOT_PW One of true/false, yes/no, 1/0. --build BUILD One of true/false, yes/no, 1/0. Default: "true" --compute-attributes COMPUTE_ATTRS Compute resource attributes. Comma-separated list of key=value. --compute-profile COMPUTE_PROFILE_NAME Name to search by --compute-profile-id COMPUTE_PROFILE_ID --compute-resource COMPUTE_RESOURCE_NAME Compute resource name --compute-resource-id COMPUTE_RESOURCE --domain DOMAIN_NAME Domain name --domain-id DOMAIN_ID --enabled ENABLED One of true/false, yes/no, 1/0. Default: "true" --environment ENVIRONMENT_NAME Environment name --environment-id ENVIRONMENT_ID --hostgroup HOSTGROUP_NAME Hostgroup name --hostgroup-id HOSTGROUP_ID --image-id IMAGE_ID --interface INTERFACE Interface parameters. Comma-separated list of key=value. Can be specified multiple times. --ip IP not required if using a subnet with dhcp proxy --location LOCATION_NAME Location name --location-id LOCATION_ID --mac MAC not required if its a virtual machine --managed MANAGED One of true/false, yes/no, 1/0. Default: "true" --medium MEDIUM_NAME Medium name --medium-id MEDIUM_ID --model MODEL_NAME Model name --model-id MODEL_ID --name NAME --operatingsystem-id OPERATINGSYSTEM_ID --organization ORGANIZATION_NAME Organization name --organization-id ORGANIZATION_ID --owner-id OWNER_ID --parameters PARAMS Host parameters. Comma-separated list of key=value. --partition-table-id PARTITION_TABLE_ID --progress-report-id PROGRESS_REPORT_ID UUID to track orchestration tasks status, GET /api/orchestration/:UUID/tasks --provision-method METHOD One of 'build', 'image' --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 --root-password ROOT_PW --sp-subnet-id SP_SUBNET_ID --subnet SUBNET_NAME Subnet name --subnet-id SUBNET_ID --volume VOLUME Volume parameters Comma-separated list of key=value. Can be specified multiple times. """ # Check for required options required_options = ( 'architecture-id', 'domain-id', 'environment-id', 'medium-id', 'operatingsystem-id', 'partition-table-id', 'puppet-proxy-id', ) if options is None: raise CLIFactoryError( 'Options {0} are required'.format(', '.join(required_options)) ) missing_options = [ option for option in required_options if options.get(option) is None ] if missing_options: raise CLIFactoryError( 'Options {0} are required'.format(', '.join(missing_options)) ) args = { u'architecture': None, u'architecture-id': None, u'ask-root-password': None, u'build': None, u'compute-attributes': None, u'compute-profile': None, u'compute-profile-id': None, u'compute-resource': None, u'compute-resource-id': None, u'domain': None, u'domain-id': None, u'enabled': None, u'environment': None, u'environment-id': None, u'hostgroup': None, u'hostgroup-id': None, u'image-id': None, u'interface': None, u'ip': generate_ipaddr(), u'location': None, u'location-id': None, u'mac': generate_mac(), u'managed': None, u'medium': None, u'medium-id': None, u'model': None, u'model-id': None, u'name': generate_string('alpha', 10), u'operatingsystem-id': None, u'organization': None, u'organization-id': None, u'owner-id': None, u'parameters': None, u'partition-table-id': None, u'progress-report-id': None, u'provision-method': 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'root-password': generate_string('alpha', 8), u'sp-subnet-id': None, u'subnet': None, u'subnet-id': None, u'volume': None, } args = update_dictionary(args, options) args.update(create_object(Host, args)) return args