Ejemplo n.º 1
0
 def test_create_bay_with_invalid_flavor(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     mock_valid_os_res.side_effect = exception.FlavorNotFound('test-flavor')
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(mock_valid_os_res.called)
     self.assertEqual(404, response.status_int)
Ejemplo n.º 2
0
 def test_create_baymodel_with_no_exist_flavor(self,
                                               mock_image_data):
     self.mock_valid_os_res.side_effect = exception.FlavorNotFound("flavor")
     mock_image_data.return_value = {'name': 'mock_name',
                                     'os_distro': 'fedora-atomic'}
     bdict = apiutils.baymodel_post_data()
     response = self.post_json('/baymodels', bdict, expect_errors=True)
     self.assertEqual(400, response.status_int)
Ejemplo n.º 3
0
 def test_replace_baymodel_with_no_exist_flavor_id(self):
     self.mock_valid_os_res.side_effect = exception.FlavorNotFound("aaa")
     response = self.patch_json('/baymodels/%s' % self.baymodel.uuid,
                                [{'path': '/flavor_id', 'value': 'aaa',
                                  'op': 'replace'}],
                                expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_code)
     self.assertTrue(response.json['errors'])
Ejemplo n.º 4
0
def validate_flavor(cli, flavor):
    """Validate flavor"""

    if flavor is None:
        return
    flavor_list = cli.nova().flavors.list()
    for f in flavor_list:
        if f.name == flavor or f.id == flavor:
            return
    raise exception.FlavorNotFound(flavor=flavor)
Ejemplo n.º 5
0
def validate_flavor(cli, flavor):
    """Validate flavor"""

    flavor_id = None
    flavor_list = cli.nova().flavors.list()
    for f in flavor_list:
        if f.name == flavor or f.id == flavor:
            flavor_id = f.id
            break
    if flavor_id is None:
        raise exception.FlavorNotFound(flavor=flavor)
Ejemplo n.º 6
0
def validate_flavor(cli, flavor):
    """Validate flavor.

    If flavor is None, skip the validation and using the default value
    from the heat template.
    """

    if flavor is None:
        return
    flavor_list = cli.nova().flavors.list()
    for f in flavor_list:
        if f.name == flavor or f.id == flavor:
            return
    raise exception.FlavorNotFound(flavor=flavor)