# Path: neutron/objects/network.py
# class NetworkRBAC(rbac.RBACBaseObject):
# class NetworkDhcpAgentBinding(base.NeutronDbObject):
# class NetworkSegment(base.NeutronDbObject):
# class NetworkPortSecurity(base_ps._PortSecurity):
# class ExternalNetwork(base.NeutronDbObject):
# class Network(rbac_db.NeutronRbacObject):
# class SegmentHostMapping(base.NeutronDbObject):
# class NetworkDNSDomain(base.NeutronDbObject):
#     VERSION = '1.3'
#     VERSION = '1.1'
#     VERSION = '1.0'
#     VERSION = "1.0"
#     VERSION = '1.0'
#     VERSION = '1.1'
#     VERSION = '1.0'
#     VERSION = '1.0'
#     def obj_make_compatible(self, primitive, target_version):
#     def get_down_bindings(cls, context, cutoff):
#     def create(self):
#     def update(self):
#     def _attach_hosts(self, hosts):
#     def obj_load_attr(self, attrname):
#     def _load_hosts(self, db_obj=None):
#     def from_db_object(self, db_obj):
#     def get_objects(cls, context, _pager=None, **kwargs):
#     def create(self):
#     def update(self):
#     def _attach_qos_policy(self, qos_policy_id):
#     def _set_dns_domain(self, dns_domain):
#     def modify_fields_from_db(cls, db_obj):
#     def modify_fields_to_db(cls, fields):
#     def from_db_object(self, *objs):
#     def get_bound_project_ids(cls, context, policy_id):
#     def obj_make_compatible(self, primitive, target_version):
#     def get_net_dns_from_port(cls, context, port_id):


from neutron_lib.api.definitions import segment as extension
from neutron_lib.callbacks import events
from neutron_lib.callbacks import registry
from neutron_lib.callbacks import resources
from neutron_lib import constants
from neutron_lib.db import api as db_api
from neutron_lib.db import resource_extend
from neutron_lib.db import utils as db_utils
from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_log import helpers as log_helpers
from oslo_utils import uuidutils
from neutron.common import utils
from neutron.db import segments_db as db
from neutron import manager
from neutron.objects import base as base_obj
from neutron.objects import network
from neutron.services.segments import exceptions
            segmentation_id = segment[extension.SEGMENTATION_ID]
            if segmentation_id == constants.ATTR_NOT_SPECIFIED:
                segmentation_id = None
            name = segment['name']
            if name == constants.ATTR_NOT_SPECIFIED:
                name = None
            description = segment['description']
            if description == constants.ATTR_NOT_SPECIFIED:
                description = None
            args = {'id': segment_id,
                    'network_id': network_id,
                    'name': name,
                    'description': description,
                    db.PHYSICAL_NETWORK: physical_network,
                    db.NETWORK_TYPE: network_type,
                    db.SEGMENTATION_ID: segmentation_id}
            # Calculate the index of segment
            segment_index = 0
            segments = self.get_segments(
                context,
                filters={'network_id': [network_id]},
                fields=['segment_index'],
                sorts=[('segment_index', True)])
            if segments:
                # NOTE(xiaohhui): The new index is the last index + 1, this
                # may cause discontinuous segment_index. But segment_index
                # can functionally work as the order index for segments.
                segment_index = (segments[-1].get('segment_index') + 1)
            args['segment_index'] = segment_index


# Path: neutron/objects/network.py
# class NetworkRBAC(rbac.RBACBaseObject):
# class NetworkDhcpAgentBinding(base.NeutronDbObject):
# class NetworkSegment(base.NeutronDbObject):
# class NetworkPortSecurity(base_ps._PortSecurity):
# class ExternalNetwork(base.NeutronDbObject):
# class Network(rbac_db.NeutronRbacObject):
# class SegmentHostMapping(base.NeutronDbObject):
# class NetworkDNSDomain(base.NeutronDbObject):
#     VERSION = '1.3'
#     VERSION = '1.1'
#     VERSION = '1.0'
#     VERSION = "1.0"
#     VERSION = '1.0'
#     VERSION = '1.1'
#     VERSION = '1.0'
#     VERSION = '1.0'
#     def obj_make_compatible(self, primitive, target_version):
#     def get_down_bindings(cls, context, cutoff):
#     def create(self):
#     def update(self):
#     def _attach_hosts(self, hosts):
#     def obj_load_attr(self, attrname):
#     def _load_hosts(self, db_obj=None):
#     def from_db_object(self, db_obj):
#     def get_objects(cls, context, _pager=None, **kwargs):
#     def create(self):
#     def update(self):
#     def _attach_qos_policy(self, qos_policy_id):
#     def _set_dns_domain(self, dns_domain):
#     def modify_fields_from_db(cls, db_obj):
#     def modify_fields_to_db(cls, fields):
#     def from_db_object(self, *objs):
#     def get_bound_project_ids(cls, context, policy_id):
#     def obj_make_compatible(self, primitive, target_version):
#     def get_net_dns_from_port(cls, context, port_id):


# Path: neutron/services/segments/db.py
from neutron_lib.api.definitions import segment as extension
from neutron_lib.callbacks import events
from neutron_lib.callbacks import registry
from neutron_lib.callbacks import resources
from neutron_lib import constants
from neutron_lib.db import api as db_api
from neutron_lib.db import resource_extend
from neutron_lib.db import utils as db_utils
from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_log import helpers as log_helpers
from oslo_utils import uuidutils
from neutron.common import utils
from neutron.db import segments_db as db
from neutron import manager
from neutron.objects import base as base_obj
from neutron.objects import network
from neutron.services.segments import exceptions

            segmentation_id = segment[extension.SEGMENTATION_ID]
            if segmentation_id == constants.ATTR_NOT_SPECIFIED:
                segmentation_id = None
            name = segment['name']
            if name == constants.ATTR_NOT_SPECIFIED:
                name = None
            description = segment['description']
            if description == constants.ATTR_NOT_SPECIFIED:
                description = None
            args = {'id': segment_id,
                    'network_id': network_id,
                    'name': name,
                    'description': description,
                    db.PHYSICAL_NETWORK: physical_network,
                    db.NETWORK_TYPE: network_type,
                    db.SEGMENTATION_ID: segmentation_id}
            # Calculate the index of segment
            segment_index = 0
            segments = self.get_segments(
                context,
                filters={'network_id': [network_id]},
                fields=['segment_index'],
                sorts=[('segment_index', True)])
            if segments:
                # NOTE(xiaohhui): The new index is the last index + 1, this
                # may cause discontinuous segment_index. But segment_index
                # can functionally work as the order index for segments.
                segment_index = (segments[-1].get('segment_index') + 1)
            args['segment_index'] = segment_index


            new_segment = network.NetworkSegment(context, **args)