Exemplo n.º 1
0
 def associate_port(self, request, tenant_id, id):
     content_type = request.best_match_content_type()
     try:
         req_params = \
             self._parse_request_params(request,
                                        self._schedule_host_ops_param_list)
     except exc.HTTPError as exp:
         return faults.Fault(exp)
     instance_id = req_params['instance_id']
     instance_desc = req_params['instance_desc']
     try:
         vif = self._plugin. \
         associate_port(tenant_id, instance_id, instance_desc)
         builder = enginetenant_view.get_view_builder(request)
         result = builder.build_vif(vif)
         return result
     except qexception.PortNotFound as exp:
         return faults.Fault(faults.PortNotFound(exp))
Exemplo n.º 2
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))
Exemplo n.º 3
0
    def associate_port(self, request, tenant_id, id):
        content_type = request.best_match_content_type()
        try:
            body = self._deserialize(request.body, content_type)
            req_body = self._prepare_request_body(
                body, self._schedule_host_ops_param_list)
            req_params = req_body[self._resource_name]

        except exc.HTTPError as exp:
            return faults.Fault(exp)
        instance_id = req_params['instance_id']
        instance_desc = req_params['instance_desc']
        try:
            vif = self._plugin.associate_port(tenant_id, instance_id,
                                              instance_desc)
            builder = novatenant_view.get_view_builder(request)
            result = builder.build_vif(vif)
            return result
        except qexception.PortNotFound as exp:
            return faults.Fault(faults.PortNotFound(exp))
Exemplo n.º 4
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))