Beispiel #1
0
 def get_valid_data(self, **extra):
     default = {
         'service_settings': ServiceSettingsFactory.get_url(self.settings),
         'project': ProjectFactory.get_url(self.project),
         'region': factories.RegionFactory.get_url(self.region),
         'image': factories.ImageFactory.get_url(self.image),
         'size': factories.SizeFactory.get_url(self.size),
         'name': 'valid-name',
     }
     default.update(extra)
     return default
Beispiel #2
0
    def create_volume(self, **extra):
        payload = {
            'name': 'Test volume',
            'service_settings': ServiceSettingsFactory.get_url(self.settings),
            'project': ProjectFactory.get_url(self.fixture.project),
            'size': 10240,
        }
        payload.update(extra)

        url = factories.VolumeFactory.get_list_url()
        return self.client.post(url, payload)
 def _create_request_(
     self, name, disk=1024, memory=1, cpu=2, add_payload=None, install_longhorn=False
 ):
     add_payload = add_payload or {}
     payload = {
         'name': name,
         'service_settings': ServiceSettingsFactory.get_url(self.fixture.settings),
         'project': ProjectFactory.get_url(self.fixture.project),
         'tenant_settings': openstack_tenant_factories.OpenStackTenantServiceSettingsFactory.get_url(
             self.fixture.tenant_settings
         ),
         'nodes': [
             {
                 'subnet': openstack_tenant_factories.SubNetFactory.get_url(
                     self.subnet
                 ),
                 'system_volume_size': disk,
                 'memory': memory,
                 'cpu': cpu,
                 'roles': ['worker'],
             },
             {
                 'subnet': openstack_tenant_factories.SubNetFactory.get_url(
                     self.subnet
                 ),
                 'system_volume_size': disk,
                 'memory': memory,
                 'cpu': cpu,
                 'roles': ['controlplane', 'worker'],
             },
             {
                 'subnet': openstack_tenant_factories.SubNetFactory.get_url(
                     self.subnet
                 ),
                 'system_volume_size': disk,
                 'memory': memory,
                 'cpu': cpu,
                 'roles': ['controlplane', 'etcd'],
             },
             {
                 'subnet': openstack_tenant_factories.SubNetFactory.get_url(
                     self.subnet
                 ),
                 'system_volume_size': disk,
                 'memory': memory,
                 'cpu': cpu,
                 'roles': ['worker'],
             },
         ],
         'install_longhorn': install_longhorn,
     }
     payload.update(add_payload)
     return self.client.post(self.url, payload)
 def get_valid_payload(self):
     return {
         'name':
         'Test project',
         'key':
         'TST',
         'template':
         self.fixture.jira_project_template_url,
         'service_settings':
         ServiceSettingsFactory.get_url(self.fixture.service_settings),
         'project':
         ProjectFactory.get_url(self.fixture.project),
     }
 def test_manager_can_not_see_secret_fields(self, mocked_backend):
     ServiceSettingsFactory(
         shared=True,
         type='Azure',
         name='Azure service',
         customer=self.fixture.customer,
         options=self.valid_payload['options'],
     )
     self.client.force_authenticate(self.fixture.manager)
     response = self.client.get(self.url)
     response_options = response.data[0]['options']
     for key in self.valid_payload['options'].keys():
         self.assertFalse(key in response_options)
 def setUp(self):
     self.fixture = ProjectFixture()
     self.url = ServiceSettingsFactory.get_list_url()
     self.valid_payload = {
         'type': 'Azure',
         'name': 'Azure service',
         'customer': CustomerFactory.get_url(self.fixture.customer),
         'options': {
             'tenant_id': uuid.uuid4().hex,
             'client_id': uuid.uuid4().hex,
             'client_secret': uuid.uuid4().hex,
             'subscription_id': uuid.uuid4().hex,
         },
     }
 def _get_valid_payload(self):
     return {
         'size':
         factories.SizeFactory.get_url(self.fixture.size),
         'image':
         factories.ImageFactory.get_url(self.fixture.image),
         'region':
         factories.RegionFactory.get_url(self.fixture.region),
         'service_settings':
         ServiceSettingsFactory.get_url(self.fixture.service_settings),
         'project':
         ProjectFactory.get_url(self.fixture.project),
         'name':
         'aws-instance-name',
     }
Beispiel #8
0
    def test_create_instance_with_data_volumes_with_different_names(self):
        flavor = factories.FlavorFactory(settings=self.settings)
        flavor_url = factories.FlavorFactory.get_url(flavor)
        subnet_url = factories.SubNetFactory.get_url(self.fixture.subnet)
        url = factories.InstanceFactory.get_list_url()

        payload = {
            'name':
            'test-instance',
            'image':
            self.image_url,
            'service_settings':
            ServiceSettingsFactory.get_url(self.settings),
            'project':
            ProjectFactory.get_url(self.fixture.project),
            'flavor':
            flavor_url,
            'system_volume_size':
            20480,
            'internal_ips_set': [{
                'subnet': subnet_url
            }],
            'data_volumes': [
                {
                    'size': 1024,
                    'type': factories.VolumeTypeFactory.get_url(),
                },
                {
                    'size': 1024 * 3,
                    'type': factories.VolumeTypeFactory.get_url(),
                },
            ],
        }

        response = self.client.post(url, payload)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED,
                         response.data)

        data_volumes_names = [
            v['name'] for v in response.data['volumes'] if not v['bootable']
        ]
        self.assertEqual(
            set(['test-instance-data-3', 'test-instance-data-2']),
            set(data_volumes_names),
        )
Beispiel #9
0
    def test_volume_image_name_populated_on_instance_creation(self):
        flavor = factories.FlavorFactory(settings=self.settings)
        flavor_url = factories.FlavorFactory.get_url(flavor)
        subnet_url = factories.SubNetFactory.get_url(self.fixture.subnet)
        url = factories.InstanceFactory.get_list_url()

        payload = {
            'name': 'test-instance',
            'image': self.image_url,
            'service_settings': ServiceSettingsFactory.get_url(self.settings),
            'project': ProjectFactory.get_url(self.fixture.project),
            'flavor': flavor_url,
            'system_volume_size': 20480,
            'internal_ips_set': [{
                'subnet': subnet_url
            }],
        }

        response = self.client.post(url, payload)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED,
                         response.data)

        system_volume = response.data['volumes'][0]
        self.assertEqual(system_volume['image_name'], self.image.name)
Beispiel #10
0
 def setUp(self):
     self.fixture = ProjectFixture()
     self.url = ServiceSettingsFactory.get_list_url()
Beispiel #11
0
 def service_settings(self):
     return ServiceSettingsFactory(type='Amazon', customer=self.customer)