Exemple #1
0
 def test_duplicate_flavorids_fail(self):
     """Ensures that flavorid duplicates raise ApiError"""
     flavorid = 'flavor1'
     instance_types.create('name one', 256, 1, 120, flavorid)
     self.assertRaises(exception.ApiError,
                       instance_types.create,
                       'name two', 256, 1, 120, flavorid)
Exemple #2
0
 def test_duplicate_names_fail(self):
     """Ensures that name duplicates raise ApiError"""
     name = 'some_name'
     instance_types.create(name, 256, 1, 120, 'flavor1')
     self.assertRaises(exception.ApiError,
                       instance_types.create,
                       name, 256, 1, 120, 'flavor2')
Exemple #3
0
    def create(self, req, body):
        name = body["flavor"].get("name")
        memory_mb = body["flavor"].get("memory_mb")
        vcpus = body["flavor"].get("vcpus")
        local_gb = body["flavor"].get("local_gb")
        flavorid = body["flavor"].get("flavorid")
        swap = body["flavor"].get("swap", 0)
        rxtx_factor = body["flavor"].get("rxtx_factor", 1)

        context = req.environ["engine.context"]
        flavor = instance_types.create(name, memory_mb, vcpus, local_gb, flavorid, swap, rxtx_factor)
        builder = self._get_view_builder(req)
        values = builder.show(req, flavor)
        return dict(flavor=values)
Exemple #4
0
    def create(self, req, body):
        name = body['flavor'].get('name')
        memory_mb = body['flavor'].get('memory_mb')
        vcpus = body['flavor'].get('vcpus')
        local_gb = body['flavor'].get('local_gb')
        flavorid = body['flavor'].get('flavorid')
        swap = body['flavor'].get('swap', 0)
        rxtx_factor = body['flavor'].get('rxtx_factor', 1)

        context = req.environ['engine.context']
        flavor = instance_types.create(name, memory_mb, vcpus, local_gb,
                                       flavorid, swap, rxtx_factor)
        builder = self._get_view_builder(req)
        values = builder.show(req, flavor)
        return dict(flavor=values)
Exemple #5
0
    def test_instance_type_create_then_delete(self):
        """Ensure instance types can be created"""
        name = 'Small Flavor'
        flavorid = 'flavor1'

        original_list = instance_types.get_all_types()

        # create new type and make sure values stick
        inst_type = instance_types.create(name, 256, 1, 120, flavorid)
        inst_type_id = inst_type['id']
        self.assertEqual(inst_type['flavorid'], flavorid)
        self.assertEqual(inst_type['name'], name)
        self.assertEqual(inst_type['memory_mb'], 256)
        self.assertEqual(inst_type['vcpus'], 1)
        self.assertEqual(inst_type['local_gb'], 120)
        self.assertEqual(inst_type['swap'], 0)
        self.assertEqual(inst_type['rxtx_factor'], 1)

        # make sure new type shows up in list
        new_list = instance_types.get_all_types()
        self.assertNotEqual(len(original_list), len(new_list),
                            'instance type was not created')

        # destroy instance and make sure deleted flag is set to True
        instance_types.destroy(name)
        inst_type = instance_types.get_instance_type(inst_type_id)
        self.assertEqual(1, inst_type["deleted"])

        # deleted instance should not be in list anymoer
        new_list = instance_types.get_all_types()
        self.assertEqual(original_list, new_list)

        # ensure instances are gone after purge
        instance_types.purge(name)
        new_list = instance_types.get_all_types()
        self.assertEqual(original_list, new_list,
                         'instance type not purged')