Пример #1
0
 def create_port(self, context, port):
     session = context.session
     with session.begin(subtransactions=True):
         p = port['port']
         port = super(NuagePlugin, self).create_port(context, port)
         device_owner = port.get('device_owner', None)
         if (device_owner
                 and device_owner not in constants.AUTO_CREATE_PORT_OWNERS):
             if 'fixed_ips' not in port or len(port['fixed_ips']) == 0:
                 return self._extend_port_dict_binding(context, port)
             subnet_id = port['fixed_ips'][0]['subnet_id']
             subnet_mapping = nuagedb.get_subnet_l2dom_by_id(
                 session, subnet_id)
             if subnet_mapping:
                 static_ip = False
                 if (attributes.is_attr_set(p['fixed_ips'])
                         and 'ip_address' in p['fixed_ips'][0]):
                     static_ip = True
                 nuage_vport_id = None
                 nuage_vif_id = None
                 port_mapping = nuagedb.add_port_vport_mapping(
                     session, port['id'], nuage_vport_id, nuage_vif_id,
                     static_ip)
                 port_prefix = constants.NOVA_PORT_OWNER_PREF
                 if port['device_owner'].startswith(port_prefix):
                     #This request is coming from nova
                     try:
                         self._create_update_port(context, port,
                                                  port_mapping,
                                                  subnet_mapping)
                     except Exception:
                         with excutils.save_and_reraise_exception():
                             super(NuagePlugin,
                                   self).delete_port(context, port['id'])
     return self._extend_port_dict_binding(context, port)
Пример #2
0
 def create_port(self, context, port):
     session = context.session
     with session.begin(subtransactions=True):
         p = port["port"]
         port = super(NuagePlugin, self).create_port(context, port)
         device_owner = port.get("device_owner", None)
         if device_owner and device_owner not in constants.AUTO_CREATE_PORT_OWNERS:
             if "fixed_ips" not in port or len(port["fixed_ips"]) == 0:
                 return self._extend_port_dict_binding(context, port)
             subnet_id = port["fixed_ips"][0]["subnet_id"]
             subnet_mapping = nuagedb.get_subnet_l2dom_by_id(session, subnet_id)
             if subnet_mapping:
                 static_ip = False
                 if attributes.is_attr_set(p["fixed_ips"]) and "ip_address" in p["fixed_ips"][0]:
                     static_ip = True
                 nuage_vport_id = None
                 nuage_vif_id = None
                 port_mapping = nuagedb.add_port_vport_mapping(
                     session, port["id"], nuage_vport_id, nuage_vif_id, static_ip
                 )
                 port_prefix = constants.NOVA_PORT_OWNER_PREF
                 if port["device_owner"].startswith(port_prefix):
                     # This request is coming from nova
                     try:
                         self._create_update_port(context, port, port_mapping, subnet_mapping)
                     except Exception:
                         with excutils.save_and_reraise_exception():
                             super(NuagePlugin, self).delete_port(context, port["id"])
     return self._extend_port_dict_binding(context, port)