def _items(self, request, tenant_id, is_detail): """ Returns a list of portprofiles. """ portprofiles = self._plugin.get_all_portprofiles(tenant_id) builder = pprofiles_view.get_view_builder(request) result = [builder.build(portprofile, is_detail)['portprofile'] for portprofile in portprofiles] return dict(portprofiles=result)
def show(self, request, tenant_id, id): """ Returns portprofile details for the given portprofile id """ try: portprofile = self._plugin.get_portprofile_details( tenant_id, id) builder = pprofiles_view.get_view_builder(request) #build response with details result = builder.build(portprofile, True) return dict(portprofiles=result) except exception.PortProfileNotFound as exp: return faults.Fault(faults.PortprofileNotFound(exp))
def create(self, request, tenant_id): """ Creates a new portprofile for a given tenant """ #look for portprofile name in request try: req_params = \ self._parse_request_params(request, self._portprofile_ops_param_list) except exc.HTTPError as exp: return faults.Fault(exp) portprofile = self._plugin.\ create_portprofile(tenant_id, req_params['portprofile_name'], req_params['qos_name']) builder = pprofiles_view.get_view_builder(request) result = builder.build(portprofile) return dict(portprofiles=result)
def update(self, request, tenant_id, id): """ Updates the name for the portprofile with the given id """ try: req_params = \ self._parse_request_params(request, self._portprofile_ops_param_list) except exc.HTTPError as exp: return faults.Fault(exp) try: portprofile = self._plugin.\ rename_portprofile(tenant_id, id, req_params['portprofile_name']) builder = pprofiles_view.get_view_builder(request) result = builder.build(portprofile, True) return dict(portprofiles=result) except exception.PortProfileNotFound as exp: return faults.Fault(faults.PortprofileNotFound(exp))