def setup_resource_class(self): if not self.test_resource_class: self.test_resource_class = self.db.create_resource_class( ResourceClass( name='test resource class', service_type='compute', ))
def get_all(self): """Retrieve a list of all Resource Classes.""" result = [] for rc in pecan.request.dbapi.get_resource_classes(None): result.append(ResourceClass.convert(rc, pecan.request.host_url)) return result
def setUp(self): super(TestDataCenters, self).setUp() self.rc = self.db.create_resource_class(ResourceClass( name='t1', service_type='compute', )) self.racks = []
def setUp(self): super(TestFlavors, self).setUp() self.rc = self.db.create_resource_class( ResourceClass( name='flavor_test_resource_class', service_type='compute', ))
def setUp(self): super(TestResourceClasses, self).setUp() self.rc = self.db.create_resource_class( ResourceClass( name='test resource class', service_type='compute', )) self.racks = []
def put(self, resource_class_id, resource_class): try: result = pecan.request.dbapi.update_resource_class( resource_class_id, resource_class) # # TODO(mfojtik): Update the HEAT template at this point # except Exception as e: LOG.exception(e) raise wsme.exc.ClientSideError(_("Invalid data")) return ResourceClass.convert(result, pecan.request.host_url)
def post(self, resource_class): """Create a new Resource Class.""" try: result = pecan.request.dbapi.create_resource_class(resource_class) #create in nova any flavors included in this resource_class creation #for flav in result.flavors: #nova_flavor_uuid = self.flavors.nova.create_flavor(flav, result.name) #pecan.request.dbapi.update_flavor_nova_uuid(flav.id, nova_flavor_uuid) except Exception as e: LOG.exception(e) raise wsme.exc.ClientSideError(_("Invalid data")) # 201 Created require Location header pointing to newly created # resource # # FIXME(mfojtik): For some reason, Pecan does not return 201 here # as configured above # rc = ResourceClass.convert(result, pecan.request.host_url) pecan.response.headers['Location'] = str(rc.links[0].href) pecan.response.status_code = 201 return rc
def get_one(self, resource_class_id): """Retrieve information about the given Resource Class.""" dbapi = pecan.request.dbapi resource_class = dbapi.get_resource_class(resource_class_id) return ResourceClass.convert(resource_class, pecan.request.host_url)