Beispiel #1
0
    def delete(self, req, id):
        qs = req.environ.get("QUERY_STRING", "")
        env = urlparse.parse_qs(qs)

        purge = env.get("purge", False)

        flavor = instance_types.get_instance_type_by_flavor_id(id)
        if purge:
            instance_types.purge(flavor["name"])
        else:
            instance_types.destroy(flavor["name"])

        return exc.HTTPAccepted()
Beispiel #2
0
    def delete(self, req, id):
        qs = req.environ.get('QUERY_STRING', '')
        env = urlparse.parse_qs(qs)

        purge = env.get('purge', False)

        flavor = instance_types.get_instance_type_by_flavor_id(id)
        if purge:
            instance_types.purge(flavor['name'])
        else:
            instance_types.destroy(flavor['name'])

        return exc.HTTPAccepted()
Beispiel #3
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')