
from oslo_log import log as logging

from neutron.plugins.ml2 import driver_api as api

LOG = logging.getLogger(__name__)


class NuageSubnetExtensionDriver(api.ExtensionDriver):
    _supported_extension_alias = 'nuage-subnet'

    def initialize(self):
        pass

    @property
    def extension_alias(self):
        return self._supported_extension_alias

    def process_create_subnet(self, plugin_context, data, result):
        result['net_partition'] = data['net_partition']
        result['nuagenet'] = data['nuagenet']

    def extend_subnet_dict(self, session, db_data, result):
        return result


from oslo_log import log as logging

from neutron.plugins.ml2 import driver_api as api
from nuage_neutron.plugins.common import nuagedb

LOG = logging.getLogger(__name__)


class NuageSubnetExtensionDriver(api.ExtensionDriver):
    _supported_extension_alias = 'nuage-subnet'

    def initialize(self):
        pass

    @property
    def extension_alias(self):
        return self._supported_extension_alias

    def process_create_subnet(self, plugin_context, data, result):
        result['net_partition'] = data['net_partition']
        result['nuagenet'] = data['nuagenet']

    def extend_subnet_dict(self, session, db_data, result):
        subnet_mapping = nuagedb.get_subnet_l2dom_by_id(session, result['id'])
        if subnet_mapping:
            result['vsd_managed'] = subnet_mapping['nuage_managed_subnet']
        else:
            result['vsd_managed'] = False
        return result

Add 'vsd_managed' to the GET subnet response for ML2
Add 'vsd_managed' to the GET subnet response for ML2

This commit looks up the related nuage_subnet_l2dom_mapping in the database
and uses the nuage_managed_subnet field to fill in 'vsd_managed'. False by
default.

Change-Id: I68957fe3754dc9f1ccf2b6a2b09a762fccd17a89
Closes-Bug: OPENSTACK-1504

  
  from oslo_log import log as logging
  
  from neutron.plugins.ml2 import driver_api as api
+ from nuage_neutron.plugins.common import nuagedb
  
  LOG = logging.getLogger(__name__)
  
  
  class NuageSubnetExtensionDriver(api.ExtensionDriver):
      _supported_extension_alias = 'nuage-subnet'
  
      def initialize(self):
          pass
  
      @property
      def extension_alias(self):
          return self._supported_extension_alias
  
      def process_create_subnet(self, plugin_context, data, result):
          result['net_partition'] = data['net_partition']
          result['nuagenet'] = data['nuagenet']
  
      def extend_subnet_dict(self, session, db_data, result):
+         subnet_mapping = nuagedb.get_subnet_l2dom_by_id(session, result['id'])
+         if subnet_mapping:
+             result['vsd_managed'] = subnet_mapping['nuage_managed_subnet']
+         else:
+             result['vsd_managed'] = False
          return result
  
Add 'vsd_managed' to the GET subnet response for ML2
## Code Before:

from oslo_log import log as logging

from neutron.plugins.ml2 import driver_api as api

LOG = logging.getLogger(__name__)


class NuageSubnetExtensionDriver(api.ExtensionDriver):
    _supported_extension_alias = 'nuage-subnet'

    def initialize(self):
        pass

    @property
    def extension_alias(self):
        return self._supported_extension_alias

    def process_create_subnet(self, plugin_context, data, result):
        result['net_partition'] = data['net_partition']
        result['nuagenet'] = data['nuagenet']

    def extend_subnet_dict(self, session, db_data, result):
        return result

## Instruction:
Add 'vsd_managed' to the GET subnet response for ML2
## Code After:

from oslo_log import log as logging

from neutron.plugins.ml2 import driver_api as api
from nuage_neutron.plugins.common import nuagedb

LOG = logging.getLogger(__name__)


class NuageSubnetExtensionDriver(api.ExtensionDriver):
    _supported_extension_alias = 'nuage-subnet'

    def initialize(self):
        pass

    @property
    def extension_alias(self):
        return self._supported_extension_alias

    def process_create_subnet(self, plugin_context, data, result):
        result['net_partition'] = data['net_partition']
        result['nuagenet'] = data['nuagenet']

    def extend_subnet_dict(self, session, db_data, result):
        subnet_mapping = nuagedb.get_subnet_l2dom_by_id(session, result['id'])
        if subnet_mapping:
            result['vsd_managed'] = subnet_mapping['nuage_managed_subnet']
        else:
            result['vsd_managed'] = False
        return result
