components/openstack/neutron/files/evs/plugin.py
changeset 3524 ad6a9e0880b9
parent 2065 1c1b527dcee1
child 3998 5bd484384122
equal deleted inserted replaced
3521:958ebf9deed1 3524:ad6a9e0880b9
   525                 if key == 'enable_dhcp':
   525                 if key == 'enable_dhcp':
   526                     ipnet_props[SUBNET_IPNET_ATTRIBUTE_MAP[key]] = value
   526                     ipnet_props[SUBNET_IPNET_ATTRIBUTE_MAP[key]] = value
   527                     continue
   527                     continue
   528                 key = SUBNET_IPNET_ATTRIBUTE_MAP.get(key, key)
   528                 key = SUBNET_IPNET_ATTRIBUTE_MAP.get(key, key)
   529                 if isinstance(value, list):
   529                 if isinstance(value, list):
   530                     value = ",".join([str(val) for val in value])
   530                     value = ",".join(map(str, set(value)))
   531                     if not value:
   531                     if not value:
   532                         continue
   532                         continue
   533                 filterlist.append("%s=%s" % (key, value))
   533                 filterlist.append("%s=%s" % (key, value))
   534 
   534 
   535             if filterlist:
   535             if filterlist:
   713                 if key == 'router:external':
   713                 if key == 'router:external':
   714                     evs_props[NETWORK_EVS_ATTRIBUTE_MAP[key]] = value
   714                     evs_props[NETWORK_EVS_ATTRIBUTE_MAP[key]] = value
   715                     continue
   715                     continue
   716                 key = NETWORK_EVS_ATTRIBUTE_MAP.get(key, key)
   716                 key = NETWORK_EVS_ATTRIBUTE_MAP.get(key, key)
   717                 if isinstance(value, list):
   717                 if isinstance(value, list):
   718                     value = ",".join([str(val) for val in value])
   718                     value = ",".join(map(str, set(value)))
   719                     if not value:
   719                     if not value:
   720                         continue
   720                         continue
   721                 filterlist.append("%s=%s" % (key, value))
   721                 filterlist.append("%s=%s" % (key, value))
   722 
   722 
   723             if filterlist:
   723             if filterlist:
   927                 if key in ('device_id', 'device_owner'):
   927                 if key in ('device_id', 'device_owner'):
   928                     vport_props[PORT_VPORT_ATTRIBUTE_MAP[key]] = value
   928                     vport_props[PORT_VPORT_ATTRIBUTE_MAP[key]] = value
   929                     continue
   929                     continue
   930                 key = PORT_VPORT_ATTRIBUTE_MAP.get(key, key)
   930                 key = PORT_VPORT_ATTRIBUTE_MAP.get(key, key)
   931                 if isinstance(value, list):
   931                 if isinstance(value, list):
   932                     value = ",".join([str(val) for val in value])
   932                     value = ",".join(map(str, set(value)))
   933                     if not value:
   933                     if not value:
   934                         continue
   934                         continue
   935                 filterlist.append("%s=%s" % (key, value))
   935                 filterlist.append("%s=%s" % (key, value))
   936 
   936 
   937             if filterlist:
   937             if filterlist:
   976                                                           routers=[router_id])
   976                                                           routers=[router_id])
   977             l3_rpc_agent_api.L3AgentNotify.call(context, msg,
   977             l3_rpc_agent_api.L3AgentNotify.call(context, msg,
   978                                                 topic=topics.L3_AGENT)
   978                                                 topic=topics.L3_AGENT)
   979 
   979 
   980     @lockutils.synchronized('evs-plugin', 'neutron-')
   980     @lockutils.synchronized('evs-plugin', 'neutron-')
   981     def evs_controller_removeVPort(self, tenantname, evsname, vportuuid):
   981     def evs_controller_removeVPort(self, tenantname, evsname, vportuuid,
   982         try:
   982                                    vportname):
   983             pat = radcli.ADRGlobPattern({'name': evsname,
   983         pat = radcli.ADRGlobPattern({'name': evsname,
   984                                          'tenant': tenantname})
   984                                      'tenant': tenantname})
       
   985         try:
   985             evs = self._rc.get_object(evsbind.EVS(), pat)
   986             evs = self._rc.get_object(evsbind.EVS(), pat)
   986             evs.removeVPort(vportuuid)
   987             evs.removeVPort(vportuuid)
   987         except radcli.ObjectError as oe:
   988         except radcli.ObjectError as oe:
       
   989             # '7' corresponds to EVS' EVS_EBUSY_VPORT error code
       
   990             if oe.get_payload().err == 7:
       
   991                 # It is possible that the VM is destroyed, but EVS is unaware
       
   992                 # of it. So, try to reset the vport. If it succeeds, then call
       
   993                 # removeVPort() again.
       
   994                 try:
       
   995                     evs.resetVPort(vportname)
       
   996                     evs.removeVPort(vportuuid)
       
   997                 except:
       
   998                     # we failed one of the above operations, just return
       
   999                     # the original exception.
       
  1000                     pass
       
  1001                 else:
       
  1002                     # the reset and remove succeeded, just return.
       
  1003                     return
   988             raise EVSControllerError(oe.get_payload().errmsg)
  1004             raise EVSControllerError(oe.get_payload().errmsg)
   989 
  1005 
   990     def delete_port(self, context, id, l3_port_check=True):
  1006     def delete_port(self, context, id, l3_port_check=True):
   991         if l3_port_check:
  1007         if l3_port_check:
   992             self.prevent_l3_port_deletion(context, id)
  1008             self.prevent_l3_port_deletion(context, id)
   995         if not port:
  1011         if not port:
   996             return
  1012             return
   997         if not l3_port_check:
  1013         if not l3_port_check:
   998             self._release_l3agent_internal_port(context, port)
  1014             self._release_l3agent_internal_port(context, port)
   999         self.evs_controller_removeVPort(port['tenant_id'], port['network_id'],
  1015         self.evs_controller_removeVPort(port['tenant_id'], port['network_id'],
  1000                                         id)
  1016                                         id, port['name'])
  1001 
  1017 
  1002         # notify dhcp agent of port deletion
  1018         # notify dhcp agent of port deletion
  1003         payload = {
  1019         payload = {
  1004             'port': {
  1020             'port': {
  1005                 'network_id': port['network_id'],
  1021                 'network_id': port['network_id'],