def set_docker_creds(context): if context.mist_config['LOCAL']: host = context.mist_config['LOCAL_DOCKER'] port = '2375' context.execute_steps(u''' Then I set the value "Docker" to field "Title" in the "cloud" add form Then I set the value "%s" to field "Host" in the "cloud" add form Then I set the value "%s" to field "Port" in the "cloud" add form ''' % (host, port)) else: host = safe_get_var('dockerhosts/godzilla', 'host', context.mist_config['CREDENTIALS']['DOCKER']['host']) port = safe_get_var('dockerhosts/godzilla', 'port', context.mist_config['CREDENTIALS']['DOCKER']['port']) context.execute_steps(u''' Then I set the value "Docker" to field "Title" in the "cloud" add form Then I set the value "%s" to field "Host" in the "cloud" add form Then I set the value "%s" to field "Port" in the "cloud" add form ''' % (host, port)) certificate = safe_get_var('dockerhosts/godzilla', 'cert', context.mist_config['CREDENTIALS']['DOCKER']['cert']) key = safe_get_var('dockerhosts/godzilla', 'key', context.mist_config['CREDENTIALS']['DOCKER']['key']) ca = safe_get_var('dockerhosts/godzilla', 'ca', context.mist_config['CREDENTIALS']['DOCKER']['ca']) set_value_to_field(context, key, 'key', 'cloud', 'add') set_value_to_field(context, certificate, 'certificate', 'cloud', 'add') set_value_to_field(context, ca, 'ca certificate', 'cloud', 'add')
def set_softlayer_creds(context): username = safe_get_var('clouds/softlayer', 'username', context.mist_config['CREDENTIALS']['SOFTLAYER']['username']) api_key = safe_get_var('clouds/softlayer', 'api_key', context.mist_config['CREDENTIALS']['SOFTLAYER']['api_key']) context.execute_steps(u''' Then I set the value "%s" to field "Username" in the "cloud" add form Then I set the value "%s" to field "API Key" in the "cloud" add form ''' % (username, api_key))
def set_nepho_creds(context): username = safe_get_var('clouds/nephoscale', 'username', context.mist_config['CREDENTIALS']['NEPHOSCALE']['username']) password = safe_get_var('clouds/nephoscale', 'password', context.mist_config['CREDENTIALS']['NEPHOSCALE']['password']) context.execute_steps(u''' Then I set the value "%s" to field "Username" in the "cloud" add form Then I set the value "%s" to field "Password" in the "cloud" add form ''' % (username, password))
def set_docker_creds(context): if context.mist_config['LOCAL']: host = context.mist_config['LOCAL_DOCKER'] port = '2375' context.execute_steps(u''' Then I set the value "Docker" to field "Title" in "cloud" add form Then I set the value "%s" to field "Host" in "cloud" add form Then I set the value "%s" to field "Port" in "cloud" add form ''' % (host, port)) else: host = safe_get_var( 'dockerhosts/godzilla', 'host', context.mist_config['CREDENTIALS']['DOCKER']['host']) port = safe_get_var( 'dockerhosts/godzilla', 'port', context.mist_config['CREDENTIALS']['DOCKER']['port']) context.execute_steps(u''' Then I set the value "Docker" to field "Title" in "cloud" add form Then I set the value "%s" to field "Host" in "cloud" add form Then I set the value "%s" to field "Port" in "cloud" add form ''' % (host, port)) certificate = safe_get_var( 'dockerhosts/godzilla', 'cert', context.mist_config['CREDENTIALS']['DOCKER']['cert']) key = safe_get_var('dockerhosts/godzilla', 'key', context.mist_config['CREDENTIALS']['DOCKER']['key']) ca = safe_get_var('dockerhosts/godzilla', 'ca', context.mist_config['CREDENTIALS']['DOCKER']['ca']) set_value_to_field(context, key, 'key', 'cloud', 'add') set_value_to_field(context, certificate, 'certificate', 'cloud', 'add') set_value_to_field(context, ca, 'ca certificate', 'cloud', 'add')
def test_list_machines_azure_arm(self, pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud( title='Azure_arm', provider='azure_arm', api_token=owner_api_token, tenant_id=safe_get_var( 'clouds/azure_arm', 'tenant_id', config.CREDENTIALS['AZURE_ARM']['tenant_id']), subscription_id=safe_get_var( 'clouds/azure_arm', 'subscription_id', config.CREDENTIALS['AZURE_ARM']['subscription_id']), key=safe_get_var('clouds/azure_arm', 'client_key', config.CREDENTIALS['AZURE_ARM']['client_key']), secret=safe_get_var( 'clouds/azure_arm', 'client_secret', config.CREDENTIALS['AZURE_ARM']['client_secret'])).post() assert_response_ok(response) cache.set('azure_arm_cloud_id', response.json()['id']) response = mist_core.list_machines(cloud_id=cache.get( 'azure_arm_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json( )) >= 0, "List Azure_arm machines did not return a proper result" print "Success!!!"
def test_create_network_ec2(self, mist_core, cache, owner_api_token, network_valid_cidr): response = mist_core.add_cloud( title='AWS', provider='ec2', api_token=owner_api_token, api_key=safe_get_var('clouds/aws_2', 'api_key', config.CREDENTIALS['EC2']['api_key']), api_secret=safe_get_var('clouds/aws_2', 'api_secret', config.CREDENTIALS['EC2']['api_secret']), region=safe_get_var( 'clouds/aws_2', 'region_id', config.CREDENTIALS['EC2']['region_id'])).post() assert_response_ok(response) cache.set('cloud_ids/ec2', response.json()['id']) response = mist_core.create_network(api_token=owner_api_token, network_params={ 'network': { 'cidr': network_valid_cidr } }, cloud_id=cache.get( 'cloud_ids/ec2', '')).post() assert_response_ok(response) cache.set('network_ids/ec2', response.json()['id']) response = mist_core.list_networks(api_token=owner_api_token, cloud_id=cache.get( 'cloud_ids/ec2', '')).get() assert_response_ok(response) print "Success!!!"
def set_docker_orchestrator_creds(context): host = safe_get_var('clouds/docker_orchestrator', 'host', context.mist_config['CREDENTIALS']['DOCKER_ORCHESTRATOR']['host']) port = safe_get_var('clouds/docker_orchestrator', 'port', context.mist_config['CREDENTIALS']['DOCKER_ORCHESTRATOR']['port']) context.execute_steps(u''' Then I set the value "Docker_Orchestrator" to field "Title" in the "cloud" add form Then I set the value "%s" to field "Host" in the "cloud" add form Then I set the value "%s" to field "Port" in the "cloud" add form ''' % (host, port))
def set_onapp_creds(context): context.execute_steps(u''' Then I set the value "%s" to field "Username" in the "cloud" add form Then I set the value "%s" to field "Password" in the "cloud" add form Then I set the value "%s" to field "Host" in the "cloud" add form And I click the "Verify SSL certificate" button with id "verify" ''' % (safe_get_var('clouds/onapp', 'username', context.mist_config['CREDENTIALS']['ONAPP']['username']), safe_get_var('clouds/onapp', 'password', context.mist_config['CREDENTIALS']['ONAPP']['password']), safe_get_var('clouds/onapp', 'host', context.mist_config['CREDENTIALS']['ONAPP']['host']),))
def set_gce_creds(context): project_id = safe_get_var('clouds/gce/mist-dev', 'project_id', context.mist_config['CREDENTIALS']['GCE']['project_id']) private_key = safe_get_var('clouds/gce/mist-dev', 'private_key', context.mist_config['CREDENTIALS']['GCE']['private_key']) context.execute_steps(u''' Then I set the value "%s" to field "Title" in the "cloud" add form Then I set the value "%s" to field "Project ID" in the "cloud" add form Then I set the value "%s" to field "Private Key" in the "cloud" add form And I click the "Enable DNS support" toggle button in the "cloud" add form ''' % ('GCE', project_id, json.dumps(private_key).replace('"', '\"')))
def set_azure_creds(context): subscription_id = safe_get_var('clouds/azure', 'subscription_id', context.mist_config['CREDENTIALS']['AZURE']['subscription_id']) certificate = safe_get_var('clouds/azure', 'certificate', context.mist_config['CREDENTIALS']['AZURE']['certificate']) context.execute_steps(u''' Then I set the value "Azure" to field "Title" in the "cloud" add form And I set the value "%s" to field "Subscription ID" in the "cloud" add form ''' % subscription_id) set_value_to_field(context, certificate, 'certificate', 'cloud', 'add') sleep(3)
def test_list_machines_azure(self, pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud(title='Azure', provider= 'azure', api_token=owner_api_token, subscription_id=safe_get_var('clouds/azure', 'subscription_id', config.CREDENTIALS['AZURE']['subscription_id']), certificate=safe_get_var('clouds/azure', 'certificate', config.CREDENTIALS['AZURE']['certificate'])).post() assert_response_ok(response) cache.set('azure_cloud_id', response.json()['id']) response = mist_core.list_machines(cloud_id=cache.get('azure_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) >= 0, "List Azure machines did not return a proper result" print "Success!!!"
def test_list_machines_softlayer(self, pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud(title='Softlayer', provider= 'softlayer', api_token=owner_api_token, username=safe_get_var('clouds/softlayer', 'username', config.CREDENTIALS['SOFTLAYER']['username']), api_key=safe_get_var('clouds/softlayer', 'api_key', config.CREDENTIALS['SOFTLAYER']['api_key'])).post() assert_response_ok(response) cache.set('softlayer_cloud_id', response.json()['id']) response = mist_core.list_machines(cloud_id=cache.get('softlayer_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) >= 0, "List Softlayer machines did not return a proper result" print "Success!!!"
def set_second_openstack_creds(context): context.execute_steps(u''' Then I set the value "%s" to field "Username" in the "cloud" edit form Then I set the value "%s" to field "Password" in the "cloud" edit form Then I set the value "%s" to field "Auth Url" in the "cloud" edit form Then I set the value "%s" to field "Tenant Name" in the "cloud" edit form ''' % (safe_get_var('clouds/openstack_2', 'username', context.mist_config['CREDENTIALS']['OPENSTACK_2']['username']), safe_get_var('clouds/openstack', 'password', context.mist_config['CREDENTIALS']['OPENSTACK_2']['password']), safe_get_var('clouds/openstack', 'auth_url', context.mist_config['CREDENTIALS']['OPENSTACK_2']['auth_url']), safe_get_var('clouds/openstack_2', 'tenant', context.mist_config['CREDENTIALS']['OPENSTACK_2']['tenant']),))
def set_softlayer_creds(context): username = safe_get_var( 'clouds/softlayer', 'username', context.mist_config['CREDENTIALS']['SOFTLAYER']['username']) api_key = safe_get_var( 'clouds/softlayer', 'api_key', context.mist_config['CREDENTIALS']['SOFTLAYER']['api_key']) context.execute_steps(u''' Then I set the value "%s" to field "Username" in "cloud" add form Then I set the value "%s" to field "API Key" in "cloud" add form ''' % (username, api_key))
def add_cloud_api_request(context, cloud): headers = {'Authorization': get_owner_api_token(context)} if cloud == 'Docker': if context.mist_config['LOCAL']: payload = { 'title': "Docker", 'provider': "docker", 'docker_host': context.mist_config['LOCAL_DOCKER'], 'docker_port': '2375', 'show_all': True } else: payload = { 'title': "Docker", 'provider': "docker", 'docker_host': safe_get_var('dockerhosts/godzilla', 'host', context.mist_config['CREDENTIALS']['DOCKER']['host']), 'docker_port': safe_get_var('dockerhosts/godzilla', 'port', context.mist_config['CREDENTIALS']['DOCKER']['port']), 'authentication': safe_get_var('dockerhosts/godzilla', 'authentication', context.mist_config['CREDENTIALS']['DOCKER']['authentication']), 'ca_cert_file': safe_get_var('dockerhosts/godzilla', 'ca', context.mist_config['CREDENTIALS']['DOCKER']['ca']), 'key_file': safe_get_var('dockerhosts/godzilla', 'key', context.mist_config['CREDENTIALS']['DOCKER']['key']), 'cert_file': safe_get_var('dockerhosts/godzilla', 'cert', context.mist_config['CREDENTIALS']['DOCKER']['cert']), 'show_all': True } elif cloud == 'Local_Monitoring': payload = { 'name': 'Key1', 'priv': safe_get_var('keys/mistio_fullstack_key', 'priv_key', context.mist_config['CREDENTIALS']['DOCKER_MONITORING']['port']) } re = requests.put(context.mist_config['MIST_URL'] + "/api/v1/keys", data=json.dumps(payload), headers=headers) key_id = re.json()['id'] payload = { 'title': "Local_Monitoring", 'provider': "bare_metal", 'monitoring': 'true', 'machine_key': key_id, 'machine_ip': 'mist_debugger' } elif cloud == 'GCE': payload = { 'title': 'GCE', 'provider': 'gce', 'project_id': safe_get_var('clouds/gce/mist-dev', 'project_id', context.mist_config['CREDENTIALS']['GCE']['project_id']), 'private_key': json.dumps(safe_get_var('clouds/gce/mist-dev', 'private_key', context.mist_config['CREDENTIALS']['GCE']['private_key'])), 'dns_enabled': True } requests.post(context.mist_config['MIST_URL'] + "/api/v1/clouds", data=json.dumps(payload), headers=headers)
def test_list_machines_aws(self, pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud(title='AWS', provider= 'ec2', api_token=owner_api_token, api_key=safe_get_var('clouds/aws_2', 'api_key', config.CREDENTIALS['EC2']['api_key']), api_secret=safe_get_var('clouds/aws_2', 'api_secret', config.CREDENTIALS['EC2']['api_secret']), region='ap-northeast-1').post() assert_response_ok(response) cache.set('aws_cloud_id', response.json()['id']) response = mist_core.list_machines(cloud_id=cache.get('aws_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) >= 0, "List AWS machines did not return a proper result" print "Success!!!"
def set_second_aws_creds(context): context.execute_steps(u''' Then I set the value "%s" to field "API KEY" in "Edit Credentials" app-form dialog Then I set the value "%s" to field "API SECRET" in "Edit Credentials" app-form dialog ''' % ( safe_get_var('clouds/aws_2', 'api_key', context.mist_config['CREDENTIALS']['AWS_2']['api_key']), safe_get_var( 'clouds/aws_2', 'api_secret', context.mist_config['CREDENTIALS']['AWS_2']['api_secret']), ))
def set_azure_arm_creds(context): context.execute_steps(u''' Then I set the value "Azure ARM" to field "Title" in the "cloud" add form Then I set the value "%s" to field "Tenant ID" in the "cloud" add form Then I set the value "%s" to field "Subscription ID" in the "cloud" add form Then I set the value "%s" to field "Client Key" in the "cloud" add form Then I set the value "%s" to field "Client Secret" in the "cloud" add form ''' % (safe_get_var('clouds/azure_arm', 'tenant_id', context.mist_config['CREDENTIALS']['AZURE_ARM']['tenant_id']), safe_get_var('clouds/azure_arm', 'subscription_id', context.mist_config['CREDENTIALS']['AZURE_ARM']['subscription_id']), safe_get_var('clouds/azure_arm', 'client_key', context.mist_config['CREDENTIALS']['AZURE_ARM']['client_key']), safe_get_var('clouds/azure_arm', 'client_secret', context.mist_config['CREDENTIALS']['AZURE_ARM']['client_secret']),))
def set_vmware_creds(context): context.execute_steps(u''' Then I set the value "VmWare" to field "Title" in the "cloud" add form Then I set the value "%s" to field "Username" in the "cloud" add form Then I set the value "%s" to field "Password" in the "cloud" add form Then I set the value "%s" to field "Organization" in the "cloud" add form Then I set the value "%s" to field "Hostname" in the "cloud" add form ''' % (safe_get_var('clouds/vmware', 'username', context.mist_config['CREDENTIALS']['VMWARE']['username']), safe_get_var('clouds/vmware', 'password', context.mist_config['CREDENTIALS']['VMWARE']['password']), safe_get_var('clouds/vmware', 'organization', context.mist_config['CREDENTIALS']['VMWARE']['organization']), safe_get_var('clouds/vmware', 'host', context.mist_config['CREDENTIALS']['VMWARE']['host']),))
def set_nepho_creds(context): username = safe_get_var( 'clouds/nephoscale', 'username', context.mist_config['CREDENTIALS']['NEPHOSCALE']['username']) password = safe_get_var( 'clouds/nephoscale', 'password', context.mist_config['CREDENTIALS']['NEPHOSCALE']['password']) context.execute_steps(u''' Then I set the value "%s" to field "Username" in "cloud" add form Then I set the value "%s" to field "Password" in "cloud" add form ''' % (username, password))
def set_rackspace_creds(context): region = safe_get_var('clouds/rackspace', 'region', context.mist_config['CREDENTIALS']['RACKSPACE']['region']) username = safe_get_var('clouds/rackspace', 'username', context.mist_config['CREDENTIALS']['RACKSPACE']['username']) api_key = safe_get_var('clouds/rackspace', 'api_key', context.mist_config['CREDENTIALS']['RACKSPACE']['api_key']) context.execute_steps(u''' Then I open the "Region" dropdown in the "cloud" add form And I wait for 1 seconds When I click the "%s" button in the "Region" dropdown in the "cloud" add form Then I set the value "Rackspace" to field "Title" in the "cloud" add form Then I set the value "%s" to field "Username" in the "cloud" add form Then I set the value "%s" to field "API Key" in the "cloud" add form ''' % (region, username, api_key))
def test_list_machines_gce(self, pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud(title='GCE', provider= 'gce', api_token=owner_api_token, project_id=safe_get_var('clouds/gce/mist-dev', 'project_id', config.CREDENTIALS['GCE']['project_id']), private_key = json.dumps(safe_get_var('clouds/gce/mist-dev', 'private_key', config.CREDENTIALS['GCE']['private_key']))).post() assert_response_ok(response) cache.set('gce_cloud_id', response.json()['id']) response = mist_core.list_machines(cloud_id=cache.get('gce_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) >= 0, "List GCE machines did not return a proper result" print "Success!!!"
def set_docker_orchestrator_creds(context): host = safe_get_var( 'clouds/docker_orchestrator', 'host', context.mist_config['CREDENTIALS']['DOCKER_ORCHESTRATOR']['host']) port = safe_get_var( 'clouds/docker_orchestrator', 'port', context.mist_config['CREDENTIALS']['DOCKER_ORCHESTRATOR']['port']) context.execute_steps(u''' Then I set the value "Docker_Orchestrator" to field "Title" in "cloud" add form Then I set the value "%s" to field "Host" in "cloud" add form Then I set the value "%s" to field "Port" in "cloud" add form ''' % (host, port))
def test_list_machines_rackspace(self, pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud(title='Rackspace', provider= 'rackspace', api_token=owner_api_token, region='dfw', username = safe_get_var('clouds/rackspace', 'username', config.CREDENTIALS['RACKSPACE']['username']), api_key = safe_get_var('clouds/rackspace', 'api_key', config.CREDENTIALS['RACKSPACE']['api_key'])).post() assert_response_ok(response) cache.set('rackspace_cloud_id', response.json()['id']) response = mist_core.list_machines(cloud_id=cache.get('rackspace_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) >= 0, "List Rackspace machines did not return a proper result" print "Success!!!"
def set_aws_creds(context): api_key = safe_get_var('clouds/aws', 'api_key', context.mist_config['CREDENTIALS']['EC2']['api_key']) api_secret = safe_get_var('clouds/aws', 'api_secret', context.mist_config['CREDENTIALS']['EC2']['api_secret']) region = safe_get_var('clouds/aws', 'region', context.mist_config['CREDENTIALS']['EC2']['region']) context.execute_steps(u''' Then I open the "Region" dropdown in the "cloud" add form And I wait for 1 seconds When I click the "%s" button in the "Region" dropdown in the "cloud" add form And I wait for 1 seconds Then I set the value "AWS" to field "Title" in the "cloud" add form And I set the value "%s" to field "API Key" in the "cloud" add form And I set the value "%s" to field "API Secret" in the "cloud" add form ''' % (region, api_key, api_secret))
def set_azure_creds(context): subscription_id = safe_get_var( 'clouds/azure', 'subscription_id', context.mist_config['CREDENTIALS']['AZURE']['subscription_id']) certificate = safe_get_var( 'clouds/azure', 'certificate', context.mist_config['CREDENTIALS']['AZURE']['certificate']) context.execute_steps(u''' Then I set the value "Azure" to field "Title" in "cloud" add form And I set the value "%s" to field "Subscription ID" in "cloud" add form ''' % subscription_id) set_value_to_field(context, certificate, 'certificate', 'cloud', 'add') sleep(3)
def set_gce_creds(context): project_id = safe_get_var( 'clouds/gce/mist-dev', 'project_id', context.mist_config['CREDENTIALS']['GCE']['project_id']) private_key = safe_get_var( 'clouds/gce/mist-dev', 'private_key', context.mist_config['CREDENTIALS']['GCE']['private_key']) context.execute_steps(u''' Then I set the value "%s" to field "Title" in "cloud" add form Then I set the value "%s" to field "Project ID" in "cloud" add form Then I set the value "%s" to field "Private Key" in "cloud" add form And I click the "Enable DNS support" button with id "app-form--dns_enabled" ''' % ('GCE', project_id, json.dumps(private_key)))
def set_gce_creds(context): project_id = safe_get_var( 'clouds/gce/mist-dev', 'project_id', context.mist_config['CREDENTIALS']['GCE']['project_id']) private_key = safe_get_var( 'clouds/gce/mist-dev', 'private_key', context.mist_config['CREDENTIALS']['GCE']['private_key']) context.execute_steps(u''' Then I set the value "%s" to field "Title" in the "cloud" add form Then I set the value "%s" to field "Project ID" in the "cloud" add form Then I set the value "%s" to field "Private Key" in the "cloud" add form And I click the "Enable DNS support" toggle button in the "cloud" add form ''' % ('Google Cloud', project_id, json.dumps(private_key).replace( '"', '\"')))
def test_list_zones(pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud('EC2', 'ec2', api_token=owner_api_token, api_key=safe_get_var('clouds/aws', 'api_key', config.CREDENTIALS['EC2']['api_key']), api_secret=safe_get_var('clouds/aws', 'api_secret', config.CREDENTIALS['EC2']['api_secret']), region='ap-northeast-1').post() assert_response_ok(response) response = mist_core.list_clouds(api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) == 1 cache.set('ec2_cloud_id', response.json()[0]['id']) response = mist_core.list_zones(cloud_id=cache.get('ec2_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) print "Success!!!"
def set_onapp_creds(context): context.execute_steps(u''' Then I set the value "%s" to field "Username" in "cloud" add form Then I set the value "%s" to field "Password" in "cloud" add form Then I set the value "%s" to field "Host" in "cloud" add form And I click the "Verify SSL certificate" button with id "verify" ''' % ( safe_get_var('clouds/onapp', 'username', context.mist_config['CREDENTIALS']['ONAPP']['username']), safe_get_var('clouds/onapp', 'password', context.mist_config['CREDENTIALS']['ONAPP']['password']), safe_get_var('clouds/onapp', 'host', context.mist_config['CREDENTIALS']['ONAPP']['host']), ))
def test_list_machines_azure_arm(self, pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud(title='Azure_arm', provider= 'azure_arm', api_token=owner_api_token, tenant_id=safe_get_var('clouds/azure_arm', 'tenant_id', config.CREDENTIALS['AZURE_ARM']['tenant_id']), subscription_id=safe_get_var('clouds/azure_arm', 'subscription_id', config.CREDENTIALS['AZURE_ARM']['subscription_id']), key=safe_get_var('clouds/azure_arm', 'client_key', config.CREDENTIALS['AZURE_ARM']['client_key']), secret=safe_get_var('clouds/azure_arm', 'client_secret', config.CREDENTIALS['AZURE_ARM']['client_secret'])).post() assert_response_ok(response) cache.set('azure_arm_cloud_id', response.json()['id']) response = mist_core.list_machines(cloud_id=cache.get('azure_arm_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) >= 0, "List Azure_arm machines did not return a proper result" print "Success!!!"
def set_maxihost_creds(context): api_key = safe_get_var( 'clouds/maxihost', 'api_token', context.mist_config['CREDENTIALS']['MAXIHOST']['api_token']) context.execute_steps(u''' Then I set the value "%s" to field "API token" in the "cloud" add form ''' % api_key)
def set_aliyun_creds(context): context.execute_steps( u''' Then I open the "Region" dropdown in the "cloud" add form Then I wait for 2 seconds Then I click the "US West 1 (Silicon Valley)" button in the "Region" dropdown in the "cloud" add form Then I wait for 1 seconds Then I set the value "Alibaba Cloud" to field "Title" in the "cloud" add form Then I set the value "%s" to field "API Key" in the "cloud" add form Then I set the value "%s" to field "API Secret" in the "cloud" add form ''' % (safe_get_var('clouds/aliyun', 'api_key', context.mist_config['CREDENTIALS']['ALIYUN']['api_key']), safe_get_var( 'clouds/aliyun', 'api_secret', context.mist_config['CREDENTIALS']['ALIYUN']['api_secret'])))
def set_packet_creds(context): api_key = safe_get_var( 'clouds/packet', 'api_key', context.mist_config['CREDENTIALS']['PACKET']['api_key']) context.execute_steps( u'Then I set the value "%s" to field "API Key" in the ' u'"cloud" add form' % api_key)
def test_list_zones(pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud(title='GCE', provider= 'gce', api_token=owner_api_token, project_id=safe_get_var('clouds/gce/mist-dev', 'project_id', config.CREDENTIALS['GCE']['project_id']), private_key = json.dumps(safe_get_var('clouds/gce/mist-dev', 'private_key', config.CREDENTIALS['GCE']['private_key'])), dns_enabled = True).post() assert_response_ok(response) response = mist_core.list_clouds(api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) == 1 cache.set('gce_cloud_id', response.json()[0]['id']) response = mist_core.list_zones(cloud_id=cache.get('gce_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) print "Success!!!"
def add_key_api_request(context, key_name): payload = { 'name': key_name, 'priv': safe_get_var('keys/api_testing_machine_private_key', 'priv_key', context.mist_config['TESTING_PRIVATE_KEY']) } headers = {'Authorization': get_owner_api_token(context)} requests.put(context.mist_config['MIST_URL'] + "/api/v1/keys" , data=json.dumps(payload), headers=headers)
def test_list_machines_linode(self, pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud(title='Linode', provider= 'linode', api_token=owner_api_token, api_key=safe_get_var('clouds/linode', 'api_key', config.CREDENTIALS['LINODE']['api_key'])).post() assert_response_ok(response) cache.set('linode_cloud_id', response.json()['id']) response = mist_core.list_machines(cloud_id=cache.get('linode_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) >= 0, "List Linode machines did not return a proper result" print "Success!!!"
def test_add_cloud_ok(pretty_print, mist_core, owner_api_token, name='Linode'): response = mist_core.add_cloud( name, 'linode', api_token=owner_api_token, api_key=safe_get_var('clouds/linode', 'api_key', config.CREDENTIALS['LINODE']['api_key'])).post() assert_response_ok(response) print "Success!!!"
def test_list_machines_digitalocean(self, pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud(title='Digital Ocean', provider= 'digitalocean', api_token=owner_api_token, token=safe_get_var('clouds/digitalocean', 'token', config.CREDENTIALS['DIGITALOCEAN']['token'])).post() assert_response_ok(response) cache.set('digitalocean_cloud_id', response.json()['id']) response = mist_core.list_machines(cloud_id=cache.get('digitalocean_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) >= 0, "List Digital Ocean machines did not return a proper result" print "Success!!!"
def set_aws_creds(context): api_key = safe_get_var( 'clouds/aws', 'api_key', context.mist_config['CREDENTIALS']['EC2']['api_key']) api_secret = safe_get_var( 'clouds/aws', 'api_secret', context.mist_config['CREDENTIALS']['EC2']['api_secret']) region = safe_get_var('clouds/aws', 'region', context.mist_config['CREDENTIALS']['EC2']['region']) context.execute_steps(u''' Then I open the "Region" drop down And I wait for 1 seconds When I click the button "%s" in the "Region" dropdown And I wait for 1 seconds Then I set the value "AWS" to field "Title" in "cloud" add form And I set the value "%s" to field "API Key" in "cloud" add form And I set the value "%s" to field "API Secret" in "cloud" add form ''' % (region, api_key, api_secret))
def set_rackspace_creds(context): region = safe_get_var( 'clouds/rackspace', 'region', context.mist_config['CREDENTIALS']['RACKSPACE']['region']) username = safe_get_var( 'clouds/rackspace', 'username', context.mist_config['CREDENTIALS']['RACKSPACE']['username']) api_key = safe_get_var( 'clouds/rackspace', 'api_key', context.mist_config['CREDENTIALS']['RACKSPACE']['api_key']) context.execute_steps(u''' Then I open the "Region" drop down And I wait for 1 seconds When I click the button "%s" in the "Region" dropdown Then I set the value "Rackspace" to field "Title" in "cloud" add form Then I set the value "%s" to field "Username" in "cloud" add form Then I set the value "%s" to field "API Key" in "cloud" add form ''' % (region, username, api_key))
def set_vmware_creds(context): context.execute_steps(u''' Then I set the value "VmWare" to field "Title" in "cloud" add form Then I set the value "%s" to field "Username" in "cloud" add form Then I set the value "%s" to field "Password" in "cloud" add form Then I set the value "%s" to field "Organization" in "cloud" add form Then I set the value "%s" to field "Hostname" in "cloud" add form ''' % ( safe_get_var('clouds/vmware', 'username', context.mist_config['CREDENTIALS']['VMWARE']['username']), safe_get_var('clouds/vmware', 'password', context.mist_config['CREDENTIALS']['VMWARE']['password']), safe_get_var( 'clouds/vmware', 'organization', context.mist_config['CREDENTIALS']['VMWARE']['organization']), safe_get_var('clouds/vmware', 'host', context.mist_config['CREDENTIALS']['VMWARE']['host']), ))
def add_key_api_request(context, key_name): payload = { 'name': key_name, 'priv': safe_get_var('keys/api_testing_machine_private_key', 'priv_key', context.mist_config['TESTING_PRIVATE_KEY']) } headers = {'Authorization': get_owner_api_token(context)} re = requests.put(context.mist_config['MIST_URL'] + "/api/v1/keys" , data=json.dumps(payload), headers=headers) assert re.status_code == 200, "Could not add key. Response was %s" % response.status_code context.mist_config['ASSOCIATED_KEY'] = re.json()['id']
def test_list_zones(pretty_print, mist_core, cache, owner_api_token): response = mist_core.add_cloud( title='GCE', provider='gce', api_token=owner_api_token, project_id=safe_get_var('clouds/gce/mist-dev', 'project_id', config.CREDENTIALS['GCE']['project_id']), private_key=json.dumps( safe_get_var('clouds/gce/mist-dev', 'private_key', config.CREDENTIALS['GCE']['private_key']))).post() assert_response_ok(response) response = mist_core.list_clouds(api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) == 1 cache.set('gce_cloud_id', response.json()[0]['id']) response = mist_core.list_zones(cloud_id=cache.get('gce_cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) print "Success!!!"
def set_kvm_creds(context): context.execute_steps(u''' Then I set the value "KVM" to field "Title" in the "cloud" add form Then I set the value "%s" to field "KVM hostname" in the "cloud" add form And I wait for 1 seconds And I open the "SSH Key" dropdown in the "cloud" add form And I wait for 2 seconds And I click the "KVMKEY" button in the "SSH Key" dropdown in the "cloud" add form And I wait for 1 seconds And I set the value "ubuntu" to field "SSH USER" in the "cloud" add form ''' % (safe_get_var('clouds/other_server', 'hostname', context.mist_config['CREDENTIALS']['KVM']['hostname']),))
def set_second_openstack_creds(context): context.execute_steps(u''' Then I set the value "%s" to field "Username" in "cloud" edit form Then I set the value "%s" to field "Password" in "cloud" edit form Then I set the value "%s" to field "Auth Url" in "cloud" edit form Then I set the value "%s" to field "Tenant Name" in "cloud" edit form ''' % ( safe_get_var( 'clouds/openstack_2', 'username', context.mist_config['CREDENTIALS']['OPENSTACK_2']['username']), safe_get_var( 'clouds/openstack', 'password', context.mist_config['CREDENTIALS']['OPENSTACK_2']['password']), safe_get_var( 'clouds/openstack', 'auth_url', context.mist_config['CREDENTIALS']['OPENSTACK_2']['auth_url']), safe_get_var( 'clouds/openstack_2', 'tenant', context.mist_config['CREDENTIALS']['OPENSTACK_2']['tenant']), ))
def set_other_server_creds(context): hostname = safe_get_var('clouds/other_server', 'hostname', context.mist_config['CREDENTIALS']['KVM']['hostname']) context.mist_config['bare_metal_host'] = hostname context.execute_steps(u''' Then I set the value "Bare Metal" to field "Cloud Title" in the "cloud" add form Then I set the value "%s" to field "Hostname" in the "cloud" add form And I wait for 1 seconds And I open the "SSH Key" dropdown in the "cloud" add form And I wait for 2 seconds And I click the "KVMKEY" button in the "SSH Key" dropdown in the "cloud" add form And I wait for 1 seconds ''' % hostname)
def test_list_images(pretty_print, mist_core, owner_api_token, cache): if config.LOCAL: response = mist_core.add_cloud(title='Docker', provider='docker', api_token=owner_api_token, docker_host=config.LOCAL_DOCKER, docker_port='2375').post() else: response = mist_core.add_cloud(title='Docker', provider='docker', api_token=owner_api_token, docker_host=safe_get_var('dockerhosts/godzilla', 'host', config.CREDENTIALS['DOCKER']['host']), docker_port=int(safe_get_var('dockerhosts/godzilla', 'port', config.CREDENTIALS['DOCKER']['port'])), authentication=safe_get_var('dockerhosts/godzilla', 'authentication', config.CREDENTIALS['DOCKER']['authentication']), ca_cert_file=safe_get_var('dockerhosts/godzilla', 'ca', config.CREDENTIALS['DOCKER']['ca']), key_file=safe_get_var('dockerhosts/godzilla', 'key', config.CREDENTIALS['DOCKER']['key']), cert_file=safe_get_var('dockerhosts/godzilla', 'cert', config.CREDENTIALS['DOCKER']['cert']), show_all=True).post() assert_response_ok(response) response = mist_core.list_clouds(api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) == 1 cache.set('cloud_id', response.json()[0]['id']) response = mist_core.list_images(cloud_id=cache.get('cloud_id',''), api_token=owner_api_token).post() assert_response_ok(response) for image in response.json(): if 'collectd' in image['name']: cache.set('image_id', image['id']) break assert len(response.json()) > 0, "No images are listed for Docker cloud" print "Success!!!"
def test_create_resources(self, pretty_print, mist_core, owner_api_token, cache): if config.LOCAL: response = mist_core.add_cloud(title='Docker', provider='docker', api_token=owner_api_token, docker_host=config.LOCAL_DOCKER, docker_port='2375').post() else: response = mist_core.add_cloud(title='Docker', provider='docker', api_token=owner_api_token, docker_host=safe_get_var('dockerhosts/godzilla', 'host', config.CREDENTIALS['DOCKER']['host']), docker_port=int(safe_get_var('dockerhosts/godzilla', 'port', config.CREDENTIALS['DOCKER']['port'])), authentication=safe_get_var('dockerhosts/godzilla', 'authentication', config.CREDENTIALS['DOCKER']['authentication']), ca_cert_file=safe_get_var('dockerhosts/godzilla', 'ca', config.CREDENTIALS['DOCKER']['ca']), key_file=safe_get_var('dockerhosts/godzilla', 'key', config.CREDENTIALS['DOCKER']['key']), cert_file=safe_get_var('dockerhosts/godzilla', 'cert', config.CREDENTIALS['DOCKER']['cert']), show_all=True).post() assert_response_ok(response) cache.set('docker_id', response.json()['id']) response = mist_core.list_images(cloud_id=cache.get('docker_id', ''), api_token=owner_api_token).post() assert_response_ok(response) for image in response.json(): if 'Ubuntu 14.04' in image['name']: cache.set('image_id', image['id']) break; for i in range(1,4): name = 'api_test_machine_%d' % random.randint(1, 10000000) cache.set('machine_%d_name' %i, name) response = mist_core.create_machine(cloud_id=cache.get('docker_id', ''), api_token=owner_api_token, key_id='', name=name, provider='', location='', image=cache.get('image_id', ''), size='').post() assert_response_ok(response) sleep(10) response = mist_core.list_machines(cloud_id=cache.get('docker_id', ''), api_token=owner_api_token).get() for machine in response.json(): if cache.get('machine_1_name','') in machine['name']: cache.set('machine_1_id', machine['id']) assert machine['state'] == 'running',\ "Machine's state is not running in the beginning of the tests" if cache.get('machine_2_name','') in machine['name']: cache.set('machine_2_id', machine['id']) assert machine['state'] == 'running',\ "Machine's state is not running in the beginning of the tests" # response = mist_core.set_machine_tags(api_token=owner_api_token, # cloud_id=cache.get('docker_id', ''), # machine_id=machine['uuid'], # tags={'key': 'schedule_test', 'value': ''}).post() # assert_response_ok(response) if cache.get('machine_3_name','') in machine['name']: cache.set('machine_3_id', machine['id']) assert machine['state'] == 'running',\ "Machine's state is not running in the beginning of the tests" print "Success!!!"
def test_list_machines(self, pretty_print, mist_core, cache, owner_api_token): if config.LOCAL: response = mist_core.add_cloud(title='Docker', provider='docker', api_token=owner_api_token, docker_host=config.LOCAL_DOCKER, docker_port='2375').post() else: response = mist_core.add_cloud(title='Docker', provider='docker', api_token=owner_api_token, docker_host=safe_get_var('dockerhosts/godzilla', 'host', config.CREDENTIALS['DOCKER']['host']), docker_port=int(safe_get_var('dockerhosts/godzilla', 'port', config.CREDENTIALS['DOCKER']['port'])), authentication=safe_get_var('dockerhosts/godzilla', 'authentication', config.CREDENTIALS['DOCKER']['authentication']), ca_cert_file=safe_get_var('dockerhosts/godzilla', 'ca', config.CREDENTIALS['DOCKER']['ca']), key_file=safe_get_var('dockerhosts/godzilla', 'key', config.CREDENTIALS['DOCKER']['key']), cert_file=safe_get_var('dockerhosts/godzilla', 'cert', config.CREDENTIALS['DOCKER']['cert']), show_all=True).post() assert_response_ok(response) cache.set('cloud_id', response.json()['id']) response = mist_core.list_machines(cloud_id=cache.get('cloud_id', ''), api_token=owner_api_token).get() assert_response_ok(response) assert len(response.json()) > 0, "List machines did not return any machines" print "Success!!!"
def add_key_for_provider(context): context.execute_steps(u''' When I visit the Keys page When I click the button "+" Then I expect the "Key" add form to be visible within max 10 seconds When I set the value "KVMKey" to field "Name" in the "key" add form ''') key = safe_get_var('clouds/other_server', 'key', context.mist_config['CREDENTIALS']['KVM']['key']) set_value_to_field(context, key, 'Private Key', 'key', 'add') context.execute_steps(u''' When I expect for the button "Add" in the "key" add form to be clickable within 9 seconds And I focus on the button "Add" in the "key" add form And I click the button "Add" in the "key" add form Then I expect the "key" page to be visible within max 7 seconds And I visit the Home page When I visit the Keys page Then "KVMKey" key should be present within 15 seconds Then I visit the Home page When I wait for the dashboard to load ''')
def test_add_cloud_ok(pretty_print, mist_core, owner_api_token, name='Docker'): if config.LOCAL: response = mist_core.add_cloud(name, provider='docker', api_token=owner_api_token, docker_host=config.LOCAL_DOCKER, docker_port='2375').post() else: response = mist_core.add_cloud(name, provider='docker', api_token=owner_api_token, docker_host=safe_get_var('dockerhosts/godzilla', 'host', config.CREDENTIALS['DOCKER']['host']), docker_port=int(safe_get_var('dockerhosts/godzilla', 'port', config.CREDENTIALS['DOCKER']['port'])), authentication=safe_get_var('dockerhosts/godzilla', 'authentication', config.CREDENTIALS['DOCKER']['authentication']), ca_cert_file=safe_get_var('dockerhosts/godzilla', 'ca', config.CREDENTIALS['DOCKER']['ca']), key_file=safe_get_var('dockerhosts/godzilla', 'key', config.CREDENTIALS['DOCKER']['key']), cert_file=safe_get_var('dockerhosts/godzilla', 'cert', config.CREDENTIALS['DOCKER']['cert']), show_all=True).post() assert_response_ok(response) print "Success!!!"
def set_do_creds(context): token = safe_get_var('clouds/digitalocean', 'token', context.mist_config['CREDENTIALS']['DIGITALOCEAN']['token']) context.execute_steps(u'Then I set the value "%s" to field "Token" in the ' u'"cloud" add form' % token)