示例#1
0
 def delete(self, request, tenant_id, id):
     """ Destroys the portprofile with the given id """
     try:
         self._plugin.delete_portprofile(tenant_id, id)
         return exc.HTTPOk()
     except exception.PortProfileNotFound as exp:
         return faults.Fault(faults.PortprofileNotFound(exp))
示例#2
0
 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))
示例#3
0
    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))
示例#4
0
    def associate_portprofile(self, request, tenant_id, id):
        """ associate a portprofile to the port """
        content_type = request.best_match_content_type()

        try:
            req_params = \
                self._parse_request_params(request,
                                           self._assignprofile_ops_param_list)
        except exc.HTTPError as exp:
            return faults.Fault(exp)
        net_id = req_params['network-id'].strip()
        port_id = req_params['port-id'].strip()
        try:
            self._plugin.associate_portprofile(tenant_id, net_id, port_id, id)
            return exc.HTTPOk()
        except exception.PortProfileNotFound as exp:
            return faults.Fault(faults.PortprofileNotFound(exp))
        except qexception.PortNotFound as exp:
            return faults.Fault(faults.PortNotFound(exp))
示例#5
0
    def update(self, request, tenant_id, id):
        """ Updates the name for the portprofile with the given id """
        try:
            body = self._deserialize(request.body, request.get_content_type())
            req_body = \
                self._prepare_request_body(body,
                                           self._portprofile_ops_param_list)
            req_params = req_body[self._resource_name]
        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))
示例#6
0
 def disassociate_portprofile(self, request, tenant_id, id):
     """ Disassociate a portprofile from a port """
     content_type = request.best_match_content_type()
     try:
         body = self._deserialize(request.body, content_type)
         req_body = \
             self._prepare_request_body(body,
                                        self._assignprofile_ops_param_list)
         req_params = req_body[self._resource_name]
     except exc.HTTPError as exp:
         return faults.Fault(exp)
     net_id = req_params['network-id'].strip()
     port_id = req_params['port-id'].strip()
     try:
         self._plugin.disassociate_portprofile(tenant_id, net_id, port_id,
                                               id)
         return exc.HTTPOk()
     except exception.PortProfileNotFound as exp:
         return faults.Fault(faults.PortprofileNotFound(exp))
     except qexception.PortNotFound as exp:
         return faults.Fault(faults.PortNotFound(exp))