NSXP: expose path_to_id method

Change-Id: Ib42d3f0765adea04dbc6ab9fc5fe4bee6d3e7dee
This commit is contained in:
Kobi Samoray 2019-01-28 13:13:18 +02:00
parent ccd682d774
commit c943979f97
2 changed files with 20 additions and 4 deletions

View File

@ -31,6 +31,7 @@ from vmware_nsxlib.v3 import utils
from vmware_nsxlib.v3.policy import constants
from vmware_nsxlib.v3.policy import core_defs
from vmware_nsxlib.v3.policy import transaction as trans
from vmware_nsxlib.v3.policy import utils as p_utils
LOG = logging.getLogger(__name__)
@ -259,9 +260,6 @@ class NsxPolicyResourceBase(object):
else:
self.policy_api.create_or_update(policy_def)
def _path_to_id(self, path):
return path.split('/')[-1]
class NsxPolicyDomainApi(NsxPolicyResourceBase):
"""NSX Policy Domain."""
@ -1520,7 +1518,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase):
segment = self.get(segment_id, tenant=tenant)
tz_path = segment.get('transport_zone_path')
if tz_path:
return self._path_to_id(tz_path)
return p_utils.path_to_id(tz_path)
class NsxPolicySegmentPortApi(NsxPolicyResourceBase):

View File

@ -0,0 +1,18 @@
# Copyright 2019 VMware, Inc.
# All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
def path_to_id(path):
return path.split('/')[-1]