diff options
author | Jan Provaznik <jprovazn@redhat.com> | 2013-07-22 09:58:40 +0200 |
---|---|---|
committer | Tomas Sedovic <tomas@sedovic.cz> | 2013-08-01 16:18:56 +0200 |
commit | c7e8b4eb437224f1cf61fa30b2718978333ff586 (patch) | |
tree | cd9991d7e39c18347e12d0f3ceb8ff1906f5f170 | |
parent | aef52248c48be7a7213bc54692fa9390e14b4fc7 (diff) | |
download | tuskar-ui-c7e8b4eb437224f1cf61fa30b2718978333ff586.tar.gz |
API integration - Flavors
This is first cut of flavors integration. With this patch
it should be possible to list flavor template and add/remove
flavors on resource classes. There are still some TODOs:
- some tests are failing
- Flavor model class is renamed to FlavorTemplate class: this
is only backend change, django files are not renamed
- capacities usage are not fixed
- ResourceClassFlavor class is still referenced on some places
- flavor max_vms is not implemented yet (though it was added into
tuskar right now)
Change-Id: I5b344c2ed564d91aa6bca3965119c4c02e029131
13 files changed, 281 insertions, 240 deletions
diff --git a/openstack_dashboard/api/tuskar.py b/openstack_dashboard/api/tuskar.py index 240d8b93..f80655ba 100644 --- a/openstack_dashboard/api/tuskar.py +++ b/openstack_dashboard/api/tuskar.py @@ -14,6 +14,7 @@ import copy import logging +import re from datetime import timedelta from random import randint @@ -49,8 +50,16 @@ class StringIdAPIResourceWrapper(base.APIResourceWrapper): def id(self): return str(self._apiresource.id) - def set_request(self, request): - self.request = request + # FIXME: self.request is required when calling some instance + # methods (e.g. list_flavors), once we really start using this request + # param (if ever), a proper request value should be set + @property + def request(self): + return getattr(self, '_request', None) + + @request.setter + def request(self, value): + setattr(self, '_request', value) class Capacity(StringIdAPIResourceWrapper): @@ -260,7 +269,6 @@ class Rack(StringIdAPIResourceWrapper): @classmethod def get(cls, request, rack_id): rack = cls(tuskarclient(request).racks.get(rack_id)) - rack.set_request(request) return rack @property @@ -426,7 +434,6 @@ class ResourceClass(StringIdAPIResourceWrapper): @classmethod def get(cls, request, resource_class_id): rc = cls(tuskarclient(request).resource_classes.get(resource_class_id)) - rc.set_request(request) return rc @classmethod @@ -437,9 +444,9 @@ class ResourceClass(StringIdAPIResourceWrapper): service_type=service_type)) @classmethod - def list(self, request): - return [ResourceClass(rc) for rc in - tuskarclient(request).resource_classes.list()] + def list(cls, request): + return [cls(rc) for rc in ( + tuskarclient(request).resource_classes.list())] @classmethod def update(cls, request, resource_class_id, **kwargs): @@ -478,62 +485,39 @@ class ResourceClass(StringIdAPIResourceWrapper): return self._all_racks @property - def resource_class_flavors(self): - """ Relation table resourceclassflavor """ - if not hasattr(self, '_resource_class_flavors'): - self._resource_class_flavors = [ResourceClassFlavor(r) for r in ( - self._apiresource.resourceclassflavor_set.all())] - return self._resource_class_flavors - - ## FIXME: this isn't currently supported by the client library, so would - ## have to be done through curl - @property def flavors_ids(self): """ List of unicode ids of flavors added to resource class """ - #return [ - # unicode(flavor.flavor.id) for flavor in ( - # self.resource_class_flavors)] - return [] + return [unicode(flavor.id) for flavor in self.list_flavors] + + # FIXME: for now, we display list of flavor templates when + # editing a resource class - we have to set id of flavor template, not + # flavor + @property + def flavortemplates_ids(self): + """ List of unicode ids of flavor templates added to resource class """ + return [unicode(ft.flavor_template.id) for ft in self.list_flavors] - ## FIXME: this isn't currently supported by the client library, so would - ## have to be done through curl @property def list_flavors(self): - """ Joined relation table resourceclassflavor and flavor together """ - #if not hasattr(self, '_flavors'): - # added_flavors = self.resource_class_flavors - # self._flavors = [] - # for f in added_flavors: - # flavor_obj = Flavor.get(self.request, f.flavor.id) - # flavor_obj.set_max_vms(f.max_vms) - # self._flavors.append(flavor_obj) - #return self._flavors - return [] + if not hasattr(self, '_flavors'): + self._flavors = [Flavor(f) for f in ( + tuskarclient(self.request).flavors.list(self.id))] + return self._flavors - ## FIXME: this isn't currently supported by the client library, so would - ## have to be done through curl @property def all_flavors(self): """ Joined relation table resourceclassflavor with all global flavors """ - #if not hasattr(self, '_all_flavors'): - # all_flavors = Flavor.list(self.request) - - # added_resourceclassflavors = \ - # self._apiresource.resourceclassflavor_set.all() - # added_flavors = {} - # for added_flavor in added_resourceclassflavors: - # added_flavors[str(added_flavor.flavor_id)] = added_flavor - - # self._all_flavors = [] - # for f in all_flavors: - # added_flavor = added_flavors.get(f.id) - # if added_flavor: - # f.set_max_vms(added_flavor.max_vms) - # self._all_flavors.append(f) - - #return self._all_flavors - return [] + if not hasattr(self, '_all_flavors'): + my_flavors = self.list_flavors + self._all_flavors = [] + for flavor in FlavorTemplate.list(self.request): + fname = "%s.%s" % (self.name, flavor.name) + f = next((f for f in my_flavors if f.name == fname), None) + if f: + flavor.set_max_vms(f.max_vms) + self._all_flavors.append(flavor) + return self._all_flavors @property def nodes(self): @@ -554,7 +538,7 @@ class ResourceClass(StringIdAPIResourceWrapper): def running_virtual_machines(self): if not hasattr(self, '_running_virtual_machines'): self._running_virtual_machines =\ - copy.deepcopy(self.resource_class_flavors) + copy.deepcopy(self.list_flavors) for vm in self._running_virtual_machines: vm.max_vms /= (vm.max_vms % 7) + 1 return self._running_virtual_machines @@ -651,25 +635,26 @@ class ResourceClass(StringIdAPIResourceWrapper): self._vm_capacity = Capacity(vm_capacity) return self._vm_capacity - ## FIXME: this will have to be done some other way def set_flavors(self, request, flavors_ids, max_vms=None): - return - # simply delete all and create new flavors, that'is - # how the horizon flavors work - #max_vms = max_vms or {} - - #for flavor_id in self.flavors_ids: - # ResourceClassFlavor.delete(request, - # self.id, - # flavor_id) - - #for flavor_id in flavors_ids: - # flavor = Flavor.get(request, flavor_id) - # ResourceClassFlavor.create( - # request, - # max_vms=max_vms.get(flavor.id), - # flavor=flavor._apiresource, - # resource_class=self._apiresource) + # FIXME: tuskar currently doesn't support setting flavors through + # resource class update (as it's done with set_racks), we have to + # delete/create them one by one + for fid in self.flavors_ids: + Flavor.delete(self.request, self.id, fid) + + # FIXME: for now, we just generate flavors from flavor templates + for ftemplate_id in flavors_ids: + ftemplate = FlavorTemplate.get(request, ftemplate_id) + capacities = [] + for c in ftemplate.capacities: + capacities.append({'name': c.name, + 'value': str(c.value), + 'unit': c.unit}) + # FIXME: tuskar uses resrouce-class-name prefix for flavors, + # e.g. m1.large, we add rc name to the template name: + tpl_name = "%s.%s" % (self.name, ftemplate.name) + Flavor.create(self.request, self.id, tpl_name, + max_vms.get(ftemplate.id, None), capacities) def set_racks(self, request, racks_ids): # FIXME: there is a bug now in tuskar, we have to remove all racks at @@ -680,7 +665,7 @@ class ResourceClass(StringIdAPIResourceWrapper): tuskarclient(request).resource_classes.update(self.id, racks=racks) -class Flavor(StringIdAPIResourceWrapper): +class FlavorTemplate(StringIdAPIResourceWrapper): """Wrapper for the Flavor object returned by the dummy model. """ @@ -695,16 +680,16 @@ class Flavor(StringIdAPIResourceWrapper): @classmethod def list(cls, request, only_free_racks=False): - return [cls(f) for f in dummymodels.Flavor.objects.all()] + return [cls(f) for f in dummymodels.FlavorTemplate.objects.all()] @classmethod def get(cls, request, flavor_id): - return cls(dummymodels.Flavor.objects.get(id=flavor_id)) + return cls(dummymodels.FlavorTemplate.objects.get(id=flavor_id)) @classmethod def create(cls, request, name, vcpu, ram, root_disk, ephemeral_disk, swap_disk): - flavor = dummymodels.Flavor(name=name) + flavor = dummymodels.FlavorTemplate(name=name) flavor.save() Capacity.create(request, flavor, 'vcpu', vcpu, '') Capacity.create(request, flavor, 'ram', ram, 'MB') @@ -756,23 +741,6 @@ class Flavor(StringIdAPIResourceWrapper): return self.capacity('swap_disk') @property - def resource_class_flavors(self): - if not hasattr(self, '_resource_class_flavors'): - self._resource_class_flavors = [ResourceClassFlavor(r) for r in ( - self._apiresource.resourceclassflavor_set.all())] - return self._resource_class_flavors - - @property - def resource_classes(self): - if not hasattr(self, '_resource_classes'): - added_flavors = self.resource_class_flavors - self._resource_classes = [] - for f in added_flavors: - self._resource_classes.append(ResourceClass(f.resource_class)) - - return self._resource_classes - - @property def running_virtual_machines(self): # arbitrary number return len(self.resource_classes) * 2 @@ -792,7 +760,7 @@ class Flavor(StringIdAPIResourceWrapper): @classmethod def update(cls, request, flavor_id, name, vcpu, ram, root_disk, ephemeral_disk, swap_disk): - f = dummymodels.Flavor.objects.get(id=flavor_id) + f = dummymodels.FlavorTemplate.objects.get(id=flavor_id) f.name = name f.save() flavor = cls(f) @@ -810,42 +778,93 @@ class Flavor(StringIdAPIResourceWrapper): @classmethod def delete(cls, request, flavor_id): - dummymodels.Flavor.objects.get(id=flavor_id).delete() - + dummymodels.FlavorTemplate.objects.get(id=flavor_id).delete() -class ResourceClassFlavor(StringIdAPIResourceWrapper): - """ FIXME this class will probably go away when connected to real API, - real API doesn't have this realtion Table as separate entity""" - """Wrapper for the ResourceClassFlavor object returned by the - dummy model. +class Flavor(StringIdAPIResourceWrapper): + """Wrapper for the Flavor object returned by Tuskar. """ + _attrs = ['name'] - _attrs = ['max_vms', 'flavor', 'resource_class'] + @classmethod + def create(cls, request, resource_class_id, name, max_vms, capacities): + return cls(tuskarclient(request).flavors.create( + resource_class_id, name=name, capacities=capacities)) + @classmethod + def delete(cls, request, resource_class_id, flavor_id): + tuskarclient(request).flavors.delete(resource_class_id, flavor_id) + + # FIXME: has to be implemented in API + # https://github.com/tuskar/tuskar/issues/43 @property - def flavor(self): - if not hasattr(self, '_flavor'): - self._flavor = self._apiresource.flavor - return self._flavor + def max_vms(self): + return 2 + # FIXME: returns flavor template for this flavor @property - def resource_class(self): - if not hasattr(self, '_resource_class'): - self._resource_class = self._apiresource.resource_class - return self._resource_class + def flavor_template(self): + # strip resource class prefix from flavor name before comparing: + fname = re.sub(r'^.*\.', '', self.name) + return next(f for f in FlavorTemplate.list(None) if ( + f.name == fname)) - @classmethod - def create(cls, request, resource_class, flavor, max_vms=0): - rc = dummymodels.ResourceClassFlavor( - max_vms=max_vms, - resource_class=resource_class, - flavor=flavor) - rc.save() - return ResourceClassFlavor(rc) + @property + def capacities(self): + if not hasattr(self, '_capacities'): + self._capacities = [Capacity(c) for c in + self._apiresource.capacities] + return self._capacities - @classmethod - def delete(cls, request, resource_class_id, flavor_id): - dummymodels.ResourceClassFlavor.objects.filter( - resource_class_id=resource_class_id, - flavor_id=flavor_id).delete() + def capacity(self, capacity_name): + key = "_%s" % capacity_name + if not hasattr(self, key): + try: + capacity = [c for c in self.capacities if ( + c.name == capacity_name)][0] + except: + # FIXME: test this + capacity = Capacity( + name=capacity_name, + value=_('Unable to retrieve ' + '(Is the flavor configured properly?)'), + unit='') + setattr(self, key, capacity) + return getattr(self, key) + + @property + def vcpu(self): + return self.capacity('vcpu') + + @property + def ram(self): + return self.capacity('ram') + + @property + def root_disk(self): + return self.capacity('root_disk') + + @property + def ephemeral_disk(self): + return self.capacity('ephemeral_disk') + + @property + def swap_disk(self): + return self.capacity('swap_disk') + + @property + def running_virtual_machines(self): + # arbitrary number + return len(self.resource_classes) * 2 + + # defines a random average of capacity - API should probably be able to + # determine average of capacity based on capacity value and obejct_id + def vms_over_time(self, start_time, end_time): + values = [] + current_time = start_time + while current_time <= end_time: + values.append({'date': current_time, + 'value': randint(0, self.running_virtual_machines)}) + current_time += timedelta(hours=1) + + return values diff --git a/openstack_dashboard/dashboards/infrastructure/fixtures/initial_data.json b/openstack_dashboard/dashboards/infrastructure/fixtures/initial_data.json index b9a80fe7..627e676c 100644 --- a/openstack_dashboard/dashboards/infrastructure/fixtures/initial_data.json +++ b/openstack_dashboard/dashboards/infrastructure/fixtures/initial_data.json @@ -1,11 +1,11 @@ [ - {"pk": 1, "model": "infrastructure.flavor", "fields": {"name": "nano"}}, - {"pk": 2, "model": "infrastructure.flavor", "fields": {"name": "micro"}}, - {"pk": 3, "model": "infrastructure.flavor", "fields": {"name": "tiny"}}, - {"pk": 4, "model": "infrastructure.flavor", "fields": {"name": "small"}}, - {"pk": 5, "model": "infrastructure.flavor", "fields": {"name": "medium"}}, - {"pk": 6, "model": "infrastructure.flavor", "fields": {"name": "large"}}, - {"pk": 7, "model": "infrastructure.flavor", "fields": {"name": "xlarge"}}, + {"pk": 1, "model": "infrastructure.flavortemplate", "fields": {"name": "nano"}}, + {"pk": 2, "model": "infrastructure.flavortemplate", "fields": {"name": "micro"}}, + {"pk": 3, "model": "infrastructure.flavortemplate", "fields": {"name": "tiny"}}, + {"pk": 4, "model": "infrastructure.flavortemplate", "fields": {"name": "small"}}, + {"pk": 5, "model": "infrastructure.flavortemplate", "fields": {"name": "medium"}}, + {"pk": 6, "model": "infrastructure.flavortemplate", "fields": {"name": "large"}}, + {"pk": 7, "model": "infrastructure.flavortemplate", "fields": {"name": "xlarge"}}, {"pk": 1, "model": "infrastructure.node", "fields": {"name": "node1", "rack": 1, "mac_address": "00-B0-D0-86-AB-F7", "ip_address": "192.168.191.11", "status": "active", "usage": "20"}}, {"pk": 2, "model": "infrastructure.node", "fields": {"name": "node2", "rack": 1, "mac_address": "00-B0-D0-86-AB-F8", "ip_address": "192.168.191.12", "status": "active", "usage": "30"}}, @@ -18,13 +18,13 @@ {"pk": 1, "model": "infrastructure.resourceclass", "fields": {"service_type": "compute", "name": "m1"}}, - {"pk": 1, "model": "infrastructure.resourceclassflavor", "fields": {"flavor": 1, "resource_class": 1, "max_vms": 128}}, - {"pk": 2, "model": "infrastructure.resourceclassflavor", "fields": {"flavor": 2, "resource_class": 1, "max_vms": 64}}, - {"pk": 3, "model": "infrastructure.resourceclassflavor", "fields": {"flavor": 3, "resource_class": 1, "max_vms": 32}}, - {"pk": 4, "model": "infrastructure.resourceclassflavor", "fields": {"flavor": 4, "resource_class": 1, "max_vms": 16}}, - {"pk": 5, "model": "infrastructure.resourceclassflavor", "fields": {"flavor": 5, "resource_class": 1, "max_vms": 8}}, - {"pk": 6, "model": "infrastructure.resourceclassflavor", "fields": {"flavor": 6, "resource_class": 1, "max_vms": 4}}, - {"pk": 7, "model": "infrastructure.resourceclassflavor", "fields": {"flavor": 7, "resource_class": 1, "max_vms": 2}}, + {"pk": 1, "model": "infrastructure.resourceclassflavor", "fields": {"flavortemplate": 1, "resource_class": 1, "max_vms": 128}}, + {"pk": 2, "model": "infrastructure.resourceclassflavor", "fields": {"flavortemplate": 2, "resource_class": 1, "max_vms": 64}}, + {"pk": 3, "model": "infrastructure.resourceclassflavor", "fields": {"flavortemplate": 3, "resource_class": 1, "max_vms": 32}}, + {"pk": 4, "model": "infrastructure.resourceclassflavor", "fields": {"flavortemplate": 4, "resource_class": 1, "max_vms": 16}}, + {"pk": 5, "model": "infrastructure.resourceclassflavor", "fields": {"flavortemplate": 5, "resource_class": 1, "max_vms": 8}}, + {"pk": 6, "model": "infrastructure.resourceclassflavor", "fields": {"flavortemplate": 6, "resource_class": 1, "max_vms": 4}}, + {"pk": 7, "model": "infrastructure.resourceclassflavor", "fields": {"flavortemplate": 7, "resource_class": 1, "max_vms": 2}}, {"pk": 1, "model": "infrastructure.capacity", "fields": {"value": 4, "unit": "GHz", "object_id": 1, "content_type": ["infrastructure", "node"], "name": "cpu"}}, {"pk": 2, "model": "infrastructure.capacity", "fields": {"value": 4, "unit": "GHz", "object_id": 2, "content_type": ["infrastructure", "node"], "name": "cpu"}}, @@ -47,45 +47,45 @@ {"pk": 19, "model": "infrastructure.capacity", "fields": {"value": 90, "unit": "Gbps", "object_id": 4, "content_type": ["infrastructure", "node"], "name": "network"}}, {"pk": 20, "model": "infrastructure.capacity", "fields": {"value": 90, "unit": "Gbps", "object_id": 5, "content_type": ["infrastructure", "node"], "name": "network"}}, - {"pk": 21, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "", "object_id": 1, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}}, - {"pk": 22, "model": "infrastructure.capacity", "fields": {"value": 64, "unit": "MB", "object_id": 1, "content_type": ["infrastructure", "flavor"], "name": "ram"}}, - {"pk": 23, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 1, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}}, - {"pk": 24, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 1, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}}, - {"pk": 25, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 1, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}}, + {"pk": 21, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "", "object_id": 1, "content_type": ["infrastructure", "flavortemplate"], "name": "vcpu"}}, + {"pk": 22, "model": "infrastructure.capacity", "fields": {"value": 64, "unit": "MB", "object_id": 1, "content_type": ["infrastructure", "flavortemplate"], "name": "ram"}}, + {"pk": 23, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 1, "content_type": ["infrastructure", "flavortemplate"], "name": "root_disk"}}, + {"pk": 24, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 1, "content_type": ["infrastructure", "flavortemplate"], "name": "ephemeral_disk"}}, + {"pk": 25, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 1, "content_type": ["infrastructure", "flavortemplate"], "name": "swap_disk"}}, - {"pk": 26, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "", "object_id": 2, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}}, - {"pk": 27, "model": "infrastructure.capacity", "fields": {"value": 128, "unit": "MB", "object_id": 2, "content_type": ["infrastructure", "flavor"], "name": "ram"}}, - {"pk": 28, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 2, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}}, - {"pk": 29, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 2, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}}, - {"pk": 30, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 2, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}}, + {"pk": 26, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "", "object_id": 2, "content_type": ["infrastructure", "flavortemplate"], "name": "vcpu"}}, + {"pk": 27, "model": "infrastructure.capacity", "fields": {"value": 128, "unit": "MB", "object_id": 2, "content_type": ["infrastructure", "flavortemplate"], "name": "ram"}}, + {"pk": 28, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 2, "content_type": ["infrastructure", "flavortemplate"], "name": "root_disk"}}, + {"pk": 29, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 2, "content_type": ["infrastructure", "flavortemplate"], "name": "ephemeral_disk"}}, + {"pk": 30, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 2, "content_type": ["infrastructure", "flavortemplate"], "name": "swap_disk"}}, - {"pk": 31, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "", "object_id": 3, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}}, - {"pk": 32, "model": "infrastructure.capacity", "fields": {"value": 512, "unit": "MB", "object_id": 3, "content_type": ["infrastructure", "flavor"], "name": "ram"}}, - {"pk": 33, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "GB", "object_id": 3, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}}, - {"pk": 34, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 3, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}}, - {"pk": 35, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 3, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}}, + {"pk": 31, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "", "object_id": 3, "content_type": ["infrastructure", "flavortemplate"], "name": "vcpu"}}, + {"pk": 32, "model": "infrastructure.capacity", "fields": {"value": 512, "unit": "MB", "object_id": 3, "content_type": ["infrastructure", "flavortemplate"], "name": "ram"}}, + {"pk": 33, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "GB", "object_id": 3, "content_type": ["infrastructure", "flavortemplate"], "name": "root_disk"}}, + {"pk": 34, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 3, "content_type": ["infrastructure", "flavortemplate"], "name": "ephemeral_disk"}}, + {"pk": 35, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 3, "content_type": ["infrastructure", "flavortemplate"], "name": "swap_disk"}}, - {"pk": 36, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "", "object_id": 4, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}}, - {"pk": 37, "model": "infrastructure.capacity", "fields": {"value": 2048, "unit": "MB", "object_id": 4, "content_type": ["infrastructure", "flavor"], "name": "ram"}}, - {"pk": 38, "model": "infrastructure.capacity", "fields": {"value": 20, "unit": "GB", "object_id": 4, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}}, - {"pk": 39, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 4, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}}, - {"pk": 40, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 4, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}}, + {"pk": 36, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "", "object_id": 4, "content_type": ["infrastructure", "flavortemplate"], "name": "vcpu"}}, + {"pk": 37, "model": "infrastructure.capacity", "fields": {"value": 2048, "unit": "MB", "object_id": 4, "content_type": ["infrastructure", "flavortemplate"], "name": "ram"}}, + {"pk": 38, "model": "infrastructure.capacity", "fields": {"value": 20, "unit": "GB", "object_id": 4, "content_type": ["infrastructure", "flavortemplate"], "name": "root_disk"}}, + {"pk": 39, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 4, "content_type": ["infrastructure", "flavortemplate"], "name": "ephemeral_disk"}}, + {"pk": 40, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 4, "content_type": ["infrastructure", "flavortemplate"], "name": "swap_disk"}}, - {"pk": 41, "model": "infrastructure.capacity", "fields": {"value": 2, "unit": "", "object_id": 5, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}}, - {"pk": 42, "model": "infrastructure.capacity", "fields": {"value": 4096, "unit": "MB", "object_id": 5, "content_type": ["infrastructure", "flavor"], "name": "ram"}}, - {"pk": 43, "model": "infrastructure.capacity", "fields": {"value": 40, "unit": "GB", "object_id": 5, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}}, - {"pk": 44, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 5, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}}, - {"pk": 45, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 5, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}}, + {"pk": 41, "model": "infrastructure.capacity", "fields": {"value": 2, "unit": "", "object_id": 5, "content_type": ["infrastructure", "flavortemplate"], "name": "vcpu"}}, + {"pk": 42, "model": "infrastructure.capacity", "fields": {"value": 4096, "unit": "MB", "object_id": 5, "content_type": ["infrastructure", "flavortemplate"], "name": "ram"}}, + {"pk": 43, "model": "infrastructure.capacity", "fields": {"value": 40, "unit": "GB", "object_id": 5, "content_type": ["infrastructure", "flavortemplate"], "name": "root_disk"}}, + {"pk": 44, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 5, "content_type": ["infrastructure", "flavortemplate"], "name": "ephemeral_disk"}}, + {"pk": 45, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 5, "content_type": ["infrastructure", "flavortemplate"], "name": "swap_disk"}}, - {"pk": 46, "model": "infrastructure.capacity", "fields": {"value": 4, "unit": "", "object_id": 6, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}}, - {"pk": 47, "model": "infrastructure.capacity", "fields": {"value": 8192, "unit": "MB", "object_id": 6, "content_type": ["infrastructure", "flavor"], "name": "ram"}}, - {"pk": 48, "model": "infrastructure.capacity", "fields": {"value": 80, "unit": "GB", "object_id": 6, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}}, - {"pk": 49, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 6, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}}, - {"pk": 50, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 6, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}}, + {"pk": 46, "model": "infrastructure.capacity", "fields": {"value": 4, "unit": "", "object_id": 6, "content_type": ["infrastructure", "flavortemplate"], "name": "vcpu"}}, + {"pk": 47, "model": "infrastructure.capacity", "fields": {"value": 8192, "unit": "MB", "object_id": 6, "content_type": ["infrastructure", "flavortemplate"], "name": "ram"}}, + {"pk": 48, "model": "infrastructure.capacity", "fields": {"value": 80, "unit": "GB", "object_id": 6, "content_type": ["infrastructure", "flavortemplate"], "name": "root_disk"}}, + {"pk": 49, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 6, "content_type": ["infrastructure", "flavortemplate"], "name": "ephemeral_disk"}}, + {"pk": 50, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 6, "content_type": ["infrastructure", "flavortemplate"], "name": "swap_disk"}}, - {"pk": 51, "model": "infrastructure.capacity", "fields": {"value": 8, "unit": "", "object_id": 7, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}}, - {"pk": 52, "model": "infrastructure.capacity", "fields": {"value": 16384, "unit": "MB", "object_id": 7, "content_type": ["infrastructure", "flavor"], "name": "ram"}}, - {"pk": 53, "model": "infrastructure.capacity", "fields": {"value": 160, "unit": "GB", "object_id": 7, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}}, - {"pk": 54, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 7, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}}, - {"pk": 55, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 7, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}} + {"pk": 51, "model": "infrastructure.capacity", "fields": {"value": 8, "unit": "", "object_id": 7, "content_type": ["infrastructure", "flavortemplate"], "name": "vcpu"}}, + {"pk": 52, "model": "infrastructure.capacity", "fields": {"value": 16384, "unit": "MB", "object_id": 7, "content_type": ["infrastructure", "flavortemplate"], "name": "ram"}}, + {"pk": 53, "model": "infrastructure.capacity", "fields": {"value": 160, "unit": "GB", "object_id": 7, "content_type": ["infrastructure", "flavortemplate"], "name": "root_disk"}}, + {"pk": 54, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 7, "content_type": ["infrastructure", "flavortemplate"], "name": "ephemeral_disk"}}, + {"pk": 55, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 7, "content_type": ["infrastructure", "flavortemplate"], "name": "swap_disk"}} ] diff --git a/openstack_dashboard/dashboards/infrastructure/models.py b/openstack_dashboard/dashboards/infrastructure/models.py index 0a7c101c..f552ce9a 100644 --- a/openstack_dashboard/dashboards/infrastructure/models.py +++ b/openstack_dashboard/dashboards/infrastructure/models.py @@ -30,9 +30,9 @@ class Capacity(models.Model): unit = models.CharField(max_length=10) -class Flavor(models.Model): +class FlavorTemplate(models.Model): class Meta: - db_table = 'infrastructure_flavor' + db_table = 'infrastructure_flavortemplate' name = models.CharField(max_length=50, unique=True) capacities = generic.GenericRelation(Capacity) @@ -81,6 +81,7 @@ class ResourceClassFlavor(models.Model): class Meta: db_table = 'infrastructure_resourceclass_flavors' - flavor = models.ForeignKey('Flavor') + # ResourceClass db model is not used anymore + flavortemplate = models.ForeignKey('FlavorTemplate') resource_class = models.ForeignKey('ResourceClass') max_vms = models.PositiveIntegerField(max_length=50, null=True) diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/forms.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/forms.py index 633f1048..aed17d17 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/forms.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/forms.py @@ -53,7 +53,7 @@ class CreateFlavor(forms.SelfHandlingForm): name = cleaned_data.get('name') flavor_id = self.initial.get('flavor_id', None) try: - flavors = api.tuskar.Flavor.list(self.request) + flavors = api.tuskar.FlavorTemplate.list(self.request) except: flavors = [] msg = _('Unable to get flavor list') @@ -70,7 +70,7 @@ class CreateFlavor(forms.SelfHandlingForm): def handle(self, request, data): try: - flavor = api.tuskar.Flavor.create( + flavor = api.tuskar.FlavorTemplate.create( request, data['name'], data['vcpu'], @@ -90,7 +90,7 @@ class EditFlavor(CreateFlavor): def handle(self, request, data): try: - flavor = api.tuskar.Flavor.update( + flavor = api.tuskar.FlavorTemplate.update( self.request, self.initial['flavor_id'], data['name'], diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tables.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tables.py index 5be4683a..973074a6 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tables.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tables.py @@ -30,7 +30,7 @@ class DeleteFlavors(tables.DeleteAction): data_type_plural = _("Flavors") def delete(self, request, obj_id): - api.tuskar.Flavor.delete(request, obj_id) + api.tuskar.FlavorTemplate.delete(request, obj_id) class CreateFlavor(tables.LinkAction): diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py index 9120172f..e0ca0e3b 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py @@ -6,15 +6,15 @@ from openstack_dashboard import api from openstack_dashboard.test import helpers as test -class FlavorsTests(test.BaseAdminViewTests): +class FlavorTemplatesTests(test.BaseAdminViewTests): - @test.create_stubs({api.tuskar.Flavor: ('list', 'create')}) + @test.create_stubs({api.tuskar.FlavorTemplate: ('list', 'create')}) def test_create_flavor(self): flavor = self.tuskar_flavors.first() - api.tuskar.Flavor.list( + api.tuskar.FlavorTemplate.list( IsA(http.HttpRequest)).AndReturn([]) - api.tuskar.Flavor.create(IsA(http.HttpRequest), + api.tuskar.FlavorTemplate.create(IsA(http.HttpRequest), flavor.name, 0, 0, 0, 0, 0).AndReturn(flavor) self.mox.ReplayAll() @@ -36,11 +36,11 @@ class FlavorsTests(test.BaseAdminViewTests): self.assertRedirectsNoFollow( resp, reverse('horizon:infrastructure:resource_management:index')) - @test.create_stubs({api.tuskar.Flavor: ('list', 'update', 'get')}) + @test.create_stubs({api.tuskar.FlavorTemplate: ('list', 'update', 'get')}) def test_edit_flavor_get(self): flavor = self.tuskar_flavors.first() # has no extra spec - api.tuskar.Flavor.get(IsA(http.HttpRequest), + api.tuskar.FlavorTemplate.get(IsA(http.HttpRequest), flavor.id).AndReturn(flavor) self.mox.ReplayAll() @@ -52,17 +52,17 @@ class FlavorsTests(test.BaseAdminViewTests): self.assertTemplateUsed( resp, "infrastructure/resource_management/flavors/edit.html") - @test.create_stubs({api.tuskar.Flavor: ('list', 'update', 'get')}) + @test.create_stubs({api.tuskar.FlavorTemplate: ('list', 'update', 'get')}) def test_edit_flavor_post(self): flavor = self.tuskar_flavors.first() # has no extra spec - api.tuskar.Flavor.list( + api.tuskar.FlavorTemplate.list( IsA(http.HttpRequest)).AndReturn(self.tuskar_flavors.list()) - api.tuskar.Flavor.update(IsA(http.HttpRequest), + api.tuskar.FlavorTemplate.update(IsA(http.HttpRequest), flavor.id, flavor.name, 0, 0, 0, 0, 0).AndReturn(flavor) - api.tuskar.Flavor.get(IsA(http.HttpRequest), + api.tuskar.FlavorTemplate.get(IsA(http.HttpRequest), flavor.id).AndReturn(flavor) self.mox.ReplayAll() @@ -82,13 +82,13 @@ class FlavorsTests(test.BaseAdminViewTests): self.assertRedirectsNoFollow( resp, reverse('horizon:infrastructure:resource_management:index')) - @test.create_stubs({api.tuskar.Flavor: ('list', 'delete')}) + @test.create_stubs({api.tuskar.FlavorTemplate: ('list', 'delete')}) def test_delete_flavor(self): flavor = self.tuskar_flavors.first() - api.tuskar.Flavor.list(IsA(http.HttpRequest)).\ + api.tuskar.FlavorTemplate.list(IsA(http.HttpRequest)).\ AndReturn(self.tuskar_flavors.list()) - api.tuskar.Flavor.delete(IsA(http.HttpRequest), flavor.id) + api.tuskar.FlavorTemplate.delete(IsA(http.HttpRequest), flavor.id) self.mox.ReplayAll() form_data = {'action': 'flavors__delete__%s' % flavor.id} @@ -99,13 +99,13 @@ class FlavorsTests(test.BaseAdminViewTests): self.assertRedirectsNoFollow( res, reverse('horizon:infrastructure:resource_management:index')) - @test.create_stubs({api.tuskar.Flavor: ('get',)}) + @test.create_stubs({api.tuskar.FlavorTemplate: ('get',)}) def test_detail_flavor(self): flavor = self.tuskar_flavors.first() - api.tuskar.Flavor.get(IsA(http.HttpRequest), + api.tuskar.FlavorTemplate.get(IsA(http.HttpRequest), flavor.id).AndReturn(flavor) - api.tuskar.Flavor.resource_classes = self. \ + api.tuskar.FlavorTemplate.resource_classes = self. \ tuskar_resource_classes self.mox.ReplayAll() diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py index 670fef83..3b9e3436 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py @@ -57,7 +57,7 @@ class EditView(forms.ModalFormView): def get_initial(self): try: - flavor = api.tuskar.Flavor.get( + flavor = api.tuskar.FlavorTemplate.get( self.request, self.kwargs['flavor_id']) except: exceptions.handle(self.request, @@ -84,7 +84,7 @@ class DetailView(tabs.TabView): if not hasattr(self, "_flavor"): try: flavor_id = self.kwargs['flavor_id'] - flavor = api.tuskar.Flavor.get(self.request, flavor_id) + flavor = api.tuskar.FlavorTemplate.get(self.request, flavor_id) except: redirect = reverse('horizon:infrastructure:' 'resource_management:index') @@ -106,7 +106,7 @@ class ActiveInstancesDataView(View): def get(self, request, *args, **kwargs): try: - flavor = api.tuskar.Flavor.get( + flavor = api.tuskar.FlavorTemplate.get( self.request, self.kwargs['flavor_id']) values = flavor.vms_over_time( datetime.now() - timedelta(days=7), datetime.now()) diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/workflows.py b/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/workflows.py index 29181952..87c920a5 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/workflows.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/workflows.py @@ -118,12 +118,13 @@ class CreateResourceClassInfoAndFlavors(workflows.TableStep): # TODO: lsmola ugly interface, rewrite self._tables['flavors'].active_multi_select_values = \ - resource_class.flavors_ids + resource_class.flavortemplates_ids all_flavors = resource_class.all_flavors else: - all_flavors = api.tuskar.Flavor.list(self.workflow.request) - except: + all_flavors = api.tuskar.FlavorTemplate.list( + self.workflow.request) + except Exception, ex: all_flavors = [] exceptions.handle(self.workflow.request, _('Unable to retrieve resource flavors list.')) @@ -257,10 +258,10 @@ class UpdateResourceClass(ResourceClassWorkflowMixin, workflows.Workflow): def _update_resource_class_info(self, request, data): try: return api.tuskar.ResourceClass.update( - request, - data['resource_class_id'], - name=data['name'], - service_type=data['service_type']) + request, + data['resource_class_id'], + name=data['name'], + service_type=data['service_type']) except: redirect = self.get_failure_url() exceptions.handle(request, diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/tabs.py b/openstack_dashboard/dashboards/infrastructure/resource_management/tabs.py index 8c960e7f..a4800022 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/tabs.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/tabs.py @@ -62,7 +62,7 @@ class FlavorsTab(tabs.TableTab): def get_flavors_data(self): try: - flavors = tuskar.Flavor.list(self.request) + flavors = tuskar.FlavorTemplate.list(self.request) except: flavors = [] exceptions.handle(self.request, diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html index 532b1cb1..e3664beb 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html @@ -107,7 +107,7 @@ <h4>{% trans "Virtual Capacity" %}</h4> <hr class="header_rule"> <dl> - {% for flavor_count in resource_class.resource_class_flavors %} + {% for flavor_count in resource_class.list_flavors %} <dt>{{ flavor_count.flavor.name }}</dt> <dd>{{ flavor_count.max_vms }}</dd> {% endfor %} diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/tests.py b/openstack_dashboard/dashboards/infrastructure/resource_management/tests.py index a5ed9455..2535a5b4 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/tests.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/tests.py @@ -32,16 +32,17 @@ class ResourceManagementTests(test.BaseAdminViewTests): 'list', 'list_racks', 'nodes'), - api.tuskar.Flavor: ( + api.tuskar.FlavorTemplate: ( 'list',), api.tuskar.Rack: ( 'list',)}) def test_index(self): - # Flavor stubs + # FlavorTemplate stubs flavors = self.tuskar_flavors.list() - api.tuskar.Flavor.list(IsA(http.HttpRequest)).AndReturn(flavors) - # Flavor stubs end + api.tuskar.FlavorTemplate.list(IsA(http.HttpRequest)).AndReturn( + flavors) + # FlavorTemplate stubs end # ResourceClass stubs all_resource_classes = self.tuskar_resource_classes.list() @@ -69,9 +70,9 @@ class ResourceManagementTests(test.BaseAdminViewTests): self.assertTemplateUsed( res, 'infrastructure/resource_management/index.html') - # Flavor asserts + # FlavorTemplate asserts self.assertItemsEqual(res.context['flavors_table'].data, flavors) - # Flavor asserts end + # FlavorTemplate asserts end # ResourceClass asserts self.assertItemsEqual(res.context['resource_classes_table'].data, diff --git a/openstack_dashboard/test/api_tests/tuskar_tests.py b/openstack_dashboard/test/api_tests/tuskar_tests.py index eb56c8d0..c5d05207 100644 --- a/openstack_dashboard/test/api_tests/tuskar_tests.py +++ b/openstack_dashboard/test/api_tests/tuskar_tests.py @@ -28,13 +28,6 @@ import openstack_dashboard.dashboards.infrastructure.models as dummymodels class TuskarApiTests(test.APITestCase): - def setUp(self): - super(TuskarApiTests, self).setUp() - # FIXME: I'm not sure this is sustainable - # dummy data are seeded from fixtures - self.rclass1 = dummymodels.ResourceClass.objects.get(name='m1') - self.flavor1 = dummymodels.Flavor.objects.get(name='nano') - def test_resource_class_list(self): rcs = self.tuskar_resource_classes.list() @@ -85,6 +78,7 @@ class TuskarApiTests(test.APITestCase): self.assertIsInstance(f, api.tuskar.Flavor) def test_flavor_get(self): - flavor = api.tuskar.Flavor.get(self.request, self.flavor1.id) + test_flavor = self.tuskar_flavors.first() + flavor = api.tuskar.Flavor.get(self.request, test_flavor.id) self.assertIsInstance(flavor, api.tuskar.Flavor) - self.assertEquals(flavor.name, self.flavor1.name) + self.assertEquals(flavor.name, test_flavor.name) diff --git a/openstack_dashboard/test/test_data/tuskar_data.py b/openstack_dashboard/test/test_data/tuskar_data.py index 814a8cca..fb5c85f9 100644 --- a/openstack_dashboard/test/test_data/tuskar_data.py +++ b/openstack_dashboard/test/test_data/tuskar_data.py @@ -12,7 +12,7 @@ from openstack_dashboard.api.tuskar import ( Flavor, ResourceClass, Node, - Rack, ResourceClassFlavor) + Rack, Capacity) from collections import namedtuple import openstack_dashboard.dashboards.infrastructure.models as dummymodels @@ -21,14 +21,50 @@ from .utils import TestDataContainer def data(TEST): + FlavorStruct = namedtuple('FlavorStruct', 'id name\ + capacities') + CapacityStruct = namedtuple('CapacityStruct', 'name value unit') + TEST.tuskar_flavors = TestDataContainer() + flavor_1 = Flavor(FlavorStruct( + id="1", + name='m1.tiny', + capacities=[ + Capacity(CapacityStruct( + name='vcpu', + unit='', + value='1')), + Capacity(CapacityStruct( + name='ram', + unit='MB', + value='64')), + Capacity(CapacityStruct( + name='root_disk', + unit='MB', + value='128')), + Capacity(CapacityStruct( + name='ephemeral_disk', + unit='GB', + value='0')), + Capacity(CapacityStruct( + name='swap_disk', + unit='GB', + value='0'))])) + flavor_2 = Flavor(FlavorStruct( + id="2", + name='m1.large', + capacities=[])) + TEST.tuskar_flavors.add(flavor_1, flavor_2) + # Flavors TEST.tuskar_flavors = TestDataContainer() - flavor_1 = Flavor(dummymodels.Flavor( - id="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", - name='m1.tiny')) - flavor_2 = Flavor(dummymodels.Flavor( - id="bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", - name='m1.massive')) + flavor_1 = Flavor(FlavorStruct( + id="1", + name='m1.tiny', + capacities=[])) + flavor_2 = Flavor(FlavorStruct( + id="2", + name='m1.large', + capacities=[])) TEST.tuskar_flavors.add(flavor_1, flavor_2) # Resource Classes @@ -91,17 +127,6 @@ def data(TEST): TEST.tuskar_racks.add(rack_1) - #ResourceClassFlavors - TEST.tuskar_resource_class_flavors = TestDataContainer() - resource_class_flavor_1 = ResourceClassFlavor( - dummymodels.ResourceClassFlavor( - id="1", - max_vms='16', - resource_class_id=1, - flavor_id=1)) - - TEST.tuskar_resource_class_flavors.add(resource_class_flavor_1) - # Nodes TEST.nodes = TestDataContainer() TEST.unracked_nodes = TestDataContainer() |