forked from openstack-archive/group-based-policy
-
Notifications
You must be signed in to change notification settings - Fork 4
Orch enterprise split #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ashutosh-mishra
wants to merge
4
commits into
mitaka_21st_march_base
Choose a base branch
from
orch_enterprise_split
base: mitaka_21st_march_base
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| from gbpservice.nfp.orchestrator.db.nfp_db import NFPDbBase | ||
|
|
||
| from gbpservice.nfp.orchestrator.db import common_db_mixin | ||
| from gbpservice.nfp.orchestrator.db import nfp_db_model | ||
|
|
||
| from gbpservice.nfp.core import log as nfp_logging | ||
| LOG = nfp_logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class NFPDbBaseNSD(NFPDbBase): | ||
| def __init__(self, *args, **kwargs): | ||
| super(NFPDbBaseNSD, self).__init__(*args, **kwargs) | ||
|
|
||
| def _set_plugged_in_port_for_nfd_interface(self, session, nfd_interface_db, | ||
| interface, is_update=False): | ||
| plugged_in_port_id = interface.get('plugged_in_port_id') | ||
| if not plugged_in_port_id: | ||
| if not is_update: | ||
| nfd_interface_db.plugged_in_port_id = None | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets discuss on how to avoid the duplicate code. Looks like we have two files with enterprise stuff in enterprise file. |
||
| return | ||
| with session.begin(subtransactions=True): | ||
| port_info_db = nfp_db_model.PortInfo( | ||
| id=plugged_in_port_id['id'], | ||
| port_model=plugged_in_port_id['port_model'], | ||
| port_classification=plugged_in_port_id['port_classification'], | ||
| port_role=plugged_in_port_id['port_role']) | ||
| if is_update: | ||
| session.merge(port_info_db) | ||
| else: | ||
| session.add(port_info_db) | ||
| session.flush() | ||
| nfd_interface_db.plugged_in_port_id = port_info_db['id'] | ||
| del interface['plugged_in_port_id'] | ||
|
|
||
|
|
||
| def create_network_function_device_interface(self, session, | ||
| nfd_interface): | ||
| with session.begin(subtransactions=True): | ||
| mapped_real_port_id = nfd_interface.get('mapped_real_port_id') | ||
| nfd_interface_db = nfp_db_model.NetworkFunctionDeviceInterface( | ||
| id=(nfd_interface.get('id') or uuidutils.generate_uuid()), | ||
| tenant_id=nfd_interface['tenant_id'], | ||
| interface_position=nfd_interface['interface_position'], | ||
| mapped_real_port_id=mapped_real_port_id, | ||
| network_function_device_id=( | ||
| nfd_interface['network_function_device_id'])) | ||
| self._set_plugged_in_port_for_nfd_interface( | ||
| session, nfd_interface_db, nfd_interface) | ||
| session.add(nfd_interface_db) | ||
|
|
||
| return self._make_network_function_device_interface_dict( | ||
| nfd_interface_db) | ||
|
|
||
| def update_network_function_device_interface(self, session, | ||
| nfd_interface_id, | ||
| updated_nfd_interface): | ||
| with session.begin(subtransactions=True): | ||
| nfd_interface_db = self._get_network_function_device_interface( | ||
| session, nfd_interface_id) | ||
| self._set_plugged_in_port_for_nfd_interface( | ||
| session, nfd_interface_db, updated_nfd_interface, | ||
| is_update=True) | ||
| nfd_interface_db.update(updated_nfd_interface) | ||
| return self._make_network_function_device_interface_dict( | ||
| nfd_interface_db) | ||
|
|
||
| def delete_network_function_device_interface( | ||
| self, session, network_function_device_interface_id): | ||
| with session.begin(subtransactions=True): | ||
| network_function_device_interface_db = ( | ||
| self._get_network_function_device_interface( | ||
| session, network_function_device_interface_id)) | ||
| if network_function_device_interface_db.plugged_in_port_id: | ||
| self.delete_port_info( | ||
| session, | ||
| network_function_device_interface_db.plugged_in_port_id) | ||
| session.delete(network_function_device_interface_db) | ||
|
|
||
| def _get_network_function_device_interface(self, session, | ||
| network_function_device_id): | ||
| try: | ||
| return self._get_by_id( | ||
| session, | ||
| nfp_db_model.NetworkFunctionDeviceInterface, | ||
| network_function_device_id) | ||
| except exc.NoResultFound: | ||
| raise nfp_exc.NetworkFunctionDeviceNotFound( | ||
| network_function_device_id=network_function_device_id) | ||
|
|
||
| def get_network_function_device_interface( | ||
| self, session, network_function_device_interface_id, | ||
| fields=None): | ||
| network_function_device_interface = ( | ||
| self._get_network_function_device_interface( | ||
| session, network_function_device_interface_id)) | ||
| return self._make_network_function_device_interface_dict( | ||
| network_function_device_interface, fields) | ||
|
|
||
| def get_network_function_device_interfaces(self, session, filters=None, | ||
| fields=None, sorts=None, | ||
| limit=None, marker=None, | ||
| page_reverse=False): | ||
| marker_obj = self._get_marker_obj( | ||
| 'network_function_device_interfaces', limit, marker) | ||
| return self._get_collection( | ||
| session, | ||
| nfp_db_model.NetworkFunctionDeviceInterface, | ||
| self._make_network_function_device_interface_dict, | ||
| filters=filters, fields=fields, | ||
| sorts=sorts, limit=limit, | ||
| marker_obj=marker_obj, | ||
| page_reverse=page_reverse) | ||
|
|
||
|
|
||
| def _make_network_function_device_interface_dict(self, nfd_interface, | ||
| fields=None): | ||
| res = {'id': nfd_interface['id'], | ||
| 'tenant_id': nfd_interface['tenant_id'], | ||
| 'plugged_in_port_id': nfd_interface['plugged_in_port_id'], | ||
| 'interface_position': nfd_interface['interface_position'], | ||
| 'mapped_real_port_id': nfd_interface['mapped_real_port_id'], | ||
| 'network_function_device_id': ( | ||
| nfd_interface['network_function_device_id']), | ||
| } | ||
| return res | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| from neutron.db import model_base | ||
|
|
||
|
|
||
| class PortInfo(BASE, model_base.HasId, model_base.HasTenant): | ||
| """Represents the Port Information""" | ||
| __tablename__ = 'nfp_port_infos' | ||
|
|
||
| port_model = sa.Column(sa.Enum(nfp_constants.NEUTRON_PORT, | ||
| nfp_constants.GBP_PORT, | ||
| name='port_model')) | ||
| port_classification = sa.Column(sa.Enum(nfp_constants.PROVIDER, | ||
| nfp_constants.CONSUMER, | ||
| nfp_constants.MANAGEMENT, | ||
| nfp_constants.MONITOR, | ||
| nfp_constants.ADVANCE_SHARING, | ||
| name='port_classification')) | ||
| port_role = sa.Column(sa.Enum(nfp_constants.ACTIVE_PORT, | ||
| nfp_constants.STANDBY_PORT, | ||
| nfp_constants.MASTER_PORT, | ||
| name='port_role'), | ||
| nullable=True) | ||
|
|
||
|
|
||
|
|
||
| class NetworkFunctionDeviceInterface(BASE, model_base.HasId, model_base.HasTenant): | ||
| """Represents the Network Function Device""" | ||
| __tablename__ = 'nfp_network_function_device_interfaces' | ||
|
|
||
| plugged_in_port_id = sa.Column(sa.String(36), | ||
| sa.ForeignKey('nfp_port_infos.id', | ||
| ondelete='SET NULL'), | ||
| nullable=True) | ||
| interface_position = sa.Column(sa.Integer(), nullable=False) | ||
| mapped_real_port_id = sa.Column(sa.String(36), | ||
| sa.ForeignKey('nfp_port_infos.id', | ||
| ondelete='SET NULL'), | ||
| nullable=True) | ||
| network_function_device_id = sa.Column( | ||
| sa.String(36), | ||
| sa.ForeignKey('nfp_network_function_devices.id', | ||
| ondelete='SET NULL'), | ||
| nullable=False) | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we want to skip _NSD.py here ?
can this file be put outside of 'modules/' folder ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It its not a module, it should not be in 'modules' folder.