OSC: Remove VPNAAS V2 calls to neutronclient

Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/886822
Actually the new SDK release is the dependency, so bump
minimum SDK version to 1.5.0.

Change-Id: I1933dceb3dc28b464e6e9c4ce468abbd03a00ba4
Related-Bug: #1999774
This commit is contained in:
elajkat 2023-06-21 15:56:28 +02:00
parent c4e8d90c0f
commit 396432ab06
12 changed files with 446 additions and 377 deletions

View File

@ -32,9 +32,19 @@ _attr_map = (
('type', 'Type', column_util.LIST_BOTH),
('endpoints', 'Endpoints', column_util.LIST_BOTH),
('description', 'Description', column_util.LIST_LONG_ONLY),
('tenant_id', 'Project', column_util.LIST_LONG_ONLY),
('project_id', 'Project', column_util.LIST_LONG_ONLY),
)
_attr_map_dict = {
'id': 'ID',
'name': 'Name',
'type': 'Type',
'endpoints': 'Endpoints',
'description': 'Description',
'tenant_id': 'Project',
'project_id': 'Project',
}
def _get_common_parser(parser):
parser.add_argument(
@ -83,23 +93,22 @@ class CreateEndpointGroup(command.ShowOne):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
attrs = _get_common_attrs(self.app.client_manager, parsed_args)
if parsed_args.name:
attrs['name'] = str(parsed_args.name)
attrs['type'] = parsed_args.type
if parsed_args.type == 'subnet':
_subnet_ids = [client.find_resource(
'subnet',
_subnet_ids = [client.find_subnet(
endpoint,
cmd_resource='subnet')['id']
for endpoint in parsed_args.endpoints]
ignore_missing=False)['id']
for endpoint in parsed_args.endpoints]
attrs['endpoints'] = _subnet_ids
else:
attrs['endpoints'] = parsed_args.endpoints
obj = client.create_endpoint_group(
{'endpoint_group': attrs})['endpoint_group']
columns, display_columns = column_util.get_columns(obj, _attr_map)
obj = client.create_vpn_endpoint_group(**attrs)
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
obj, _attr_map_dict, ['location', 'tenant_id'])
data = utils.get_dict_properties(obj, columns)
return display_columns, data
@ -117,15 +126,13 @@ class DeleteEndpointGroup(command.Command):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
result = 0
for endpoint in parsed_args.endpoint_group:
try:
endpoint_id = client.find_resource(
'endpoint_group',
endpoint,
cmd_resource='endpoint_group')['id']
client.delete_endpoint_group(endpoint_id)
endpoint_id = client.find_vpn_endpoint_group(
endpoint, ignore_missing=False)['id']
client.delete_vpn_endpoint_group(endpoint_id)
except Exception as e:
result += 1
LOG.error(_("Failed to delete endpoint group with "
@ -153,8 +160,8 @@ class ListEndpointGroup(command.Lister):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
obj = client.list_endpoint_groups()['endpoint_groups']
client = self.app.client_manager.network
obj = client.vpn_endpoint_groups()
headers, columns = column_util.get_column_definitions(
_attr_map, long_listing=parsed_args.long)
return (headers, (utils.get_dict_properties(s, columns) for s in obj))
@ -177,17 +184,15 @@ class SetEndpointGroup(command.Command):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
attrs = _get_common_attrs(self.app.client_manager,
parsed_args, is_create=False)
if parsed_args.name:
attrs['name'] = str(parsed_args.name)
endpoint_id = client.find_resource(
'endpoint_group', parsed_args.endpoint_group,
cmd_resource='endpoint_group')['id']
endpoint_id = client.find_vpn_endpoint_group(
parsed_args.endpoint_group, ignore_missing=False)['id']
try:
client.update_endpoint_group(endpoint_id,
{'endpoint_group': attrs})
client.update_vpn_endpoint_group(endpoint_id, **attrs)
except Exception as e:
msg = (_("Failed to set endpoint group "
"%(endpoint_group)s: %(e)s")
@ -207,11 +212,11 @@ class ShowEndpointGroup(command.ShowOne):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
endpoint_id = client.find_resource(
'endpoint_group', parsed_args.endpoint_group,
cmd_resource='endpoint_group')['id']
obj = client.show_endpoint_group(endpoint_id)['endpoint_group']
columns, display_columns = column_util.get_columns(obj, _attr_map)
client = self.app.client_manager.network
endpoint_id = client.find_vpn_endpoint_group(
parsed_args.endpoint_group, ignore_missing=False)['id']
obj = client.get_vpn_endpoint_group(endpoint_id)
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
obj, _attr_map_dict, ['location', 'tenant_id'])
data = utils.get_dict_properties(obj, columns)
return (display_columns, data)

View File

@ -38,10 +38,24 @@ _attr_map = (
('description', 'Description', column_util.LIST_LONG_ONLY),
('phase1_negotiation_mode', 'Phase1 Negotiation Mode',
column_util.LIST_LONG_ONLY),
('tenant_id', 'Project', column_util.LIST_LONG_ONLY),
('project_id', 'Project', column_util.LIST_LONG_ONLY),
('lifetime', 'Lifetime', column_util.LIST_LONG_ONLY),
)
_attr_map_dict = {
'id': 'ID',
'name': 'Name',
'auth_algorithm': 'Authentication Algorithm',
'encryption_algorithm': 'Encryption Algorithm',
'ike_version': 'IKE Version',
'pfs': 'Perfect Forward Secrecy (PFS)',
'phase1_negotiation_mode': 'Phase1 Negotiation Mode',
'lifetime': 'Lifetime',
'description': 'Description',
'tenant_id': 'Project',
'project_id': 'Project',
}
def _convert_to_lowercase(string):
return string.lower()
@ -89,7 +103,7 @@ def _get_common_attrs(client_manager, parsed_args, is_create=True):
attrs = {}
if is_create:
if 'project' in parsed_args and parsed_args.project is not None:
attrs['tenant_id'] = osc_utils.find_project(
attrs['project_id'] = osc_utils.find_project(
client_manager.identity,
parsed_args.project,
parsed_args.project_domain,
@ -126,12 +140,13 @@ class CreateIKEPolicy(command.ShowOne):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
attrs = _get_common_attrs(self.app.client_manager, parsed_args)
if parsed_args.name:
attrs['name'] = str(parsed_args.name)
obj = client.create_ikepolicy({'ikepolicy': attrs})['ikepolicy']
columns, display_columns = column_util.get_columns(obj, _attr_map)
obj = client.create_vpn_ike_policy(**attrs)
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
obj, _attr_map_dict, ['location', 'tenant_id', 'units', 'value'])
data = utils.get_dict_properties(obj, columns)
return display_columns, data
@ -149,13 +164,13 @@ class DeleteIKEPolicy(command.Command):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
result = 0
for ike in parsed_args.ikepolicy:
try:
ike_id = client.find_resource(
'ikepolicy', ike, cmd_resource='ikepolicy')['id']
client.delete_ikepolicy(ike_id)
ike_id = client.find_vpn_ike_policy(ike,
ignore_missing=False)['id']
client.delete_vpn_ike_policy(ike_id)
except Exception as e:
result += 1
LOG.error(_("Failed to delete IKE policy with "
@ -182,8 +197,8 @@ class ListIKEPolicy(command.Lister):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
obj = client.list_ikepolicies()['ikepolicies']
client = self.app.client_manager.network
obj = client.vpn_ike_policies()
headers, columns = column_util.get_column_definitions(
_attr_map, long_listing=parsed_args.long)
return (headers, (utils.get_dict_properties(s, columns) for s in obj))
@ -206,16 +221,15 @@ class SetIKEPolicy(command.Command):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
attrs = _get_common_attrs(self.app.client_manager,
parsed_args, is_create=False)
if parsed_args.name:
attrs['name'] = parsed_args.name
ike_id = client.find_resource(
'ikepolicy', parsed_args.ikepolicy,
cmd_resource='ikepolicy')['id']
ike_id = client.find_vpn_ike_policy(parsed_args.ikepolicy,
ignore_missing=False)['id']
try:
client.update_ikepolicy(ike_id, {'ikepolicy': attrs})
client.update_vpn_ike_policy(ike_id, **attrs)
except Exception as e:
msg = (_("Failed to set IKE policy '%(ike)s': %(e)s")
% {'ike': parsed_args.ikepolicy, 'e': e})
@ -234,11 +248,11 @@ class ShowIKEPolicy(command.ShowOne):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
ike_id = client.find_resource(
'ikepolicy', parsed_args.ikepolicy,
cmd_resource='ikepolicy')['id']
obj = client.show_ikepolicy(ike_id)['ikepolicy']
columns, display_columns = column_util.get_columns(obj, _attr_map)
client = self.app.client_manager.network
ike_id = client.find_vpn_ike_policy(parsed_args.ikepolicy,
ignore_missing=False)['id']
obj = client.get_vpn_ike_policy(ike_id)
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
obj, _attr_map_dict, ['location', 'tenant_id', 'units', 'value'])
data = utils.get_dict_properties(obj, columns)
return (display_columns, data)

View File

@ -41,14 +41,14 @@ _attr_map = (
('peer_address', 'Peer Address', column_util.LIST_BOTH),
('auth_mode', 'Authentication Algorithm', column_util.LIST_BOTH),
('status', 'Status', column_util.LIST_BOTH),
('tenant_id', 'Project', column_util.LIST_LONG_ONLY),
('project_id', 'Project', column_util.LIST_LONG_ONLY),
('peer_cidrs', 'Peer CIDRs', column_util.LIST_LONG_ONLY),
('vpnservice_id', 'VPN Service', column_util.LIST_LONG_ONLY),
('ipsecpolicy_id', 'IPSec Policy', column_util.LIST_LONG_ONLY),
('ikepolicy_id', 'IKE Policy', column_util.LIST_LONG_ONLY),
('mtu', 'MTU', column_util.LIST_LONG_ONLY),
('initiator', 'Initiator', column_util.LIST_LONG_ONLY),
('admin_state_up', 'State', column_util.LIST_LONG_ONLY),
('is_admin_state_up', 'State', column_util.LIST_LONG_ONLY),
('description', 'Description', column_util.LIST_LONG_ONLY),
('psk', 'Pre-shared Key', column_util.LIST_LONG_ONLY),
('route_mode', 'Route Mode', column_util.LIST_LONG_ONLY),
@ -57,8 +57,33 @@ _attr_map = (
('local_ep_group_id', 'Local Endpoint Group ID',
column_util.LIST_LONG_ONLY),
('peer_ep_group_id', 'Peer Endpoint Group ID', column_util.LIST_LONG_ONLY),
('dpd', 'DPD', column_util.LIST_LONG_ONLY),
)
_attr_map_dict = {
'id': 'ID',
'name': 'Name',
'peer_address': 'Peer Address',
'auth_mode': 'Authentication Algorithm',
'status': 'Status',
'peer_cidrs': 'Peer CIDRs',
'vpnservice_id': 'VPN Service',
'ipsecpolicy_id': 'IPSec Policy',
'ikepolicy_id': 'IKE Policy',
'mtu': 'MTU',
'initiator': 'Initiator',
'is_admin_state_up': 'State',
'psk': 'Pre-shared Key',
'route_mode': 'Route Mode',
'local_id': 'Local ID',
'peer_id': 'Peer ID',
'local_ep_group_id': 'Local Endpoint Group ID',
'peer_ep_group_id': 'Peer Endpoint Group ID',
'description': 'Description',
'project_id': 'Project',
'dpd': 'DPD',
}
def _convert_to_lowercase(string):
return string.lower()
@ -122,7 +147,7 @@ def _get_common_attrs(client_manager, parsed_args, is_create=True):
attrs = {}
if is_create:
if 'project' in parsed_args and parsed_args.project is not None:
attrs['tenant_id'] = osc_utils.find_project(
attrs['project_id'] = osc_utils.find_project(
client_manager.identity,
parsed_args.project,
parsed_args.project_domain,
@ -141,16 +166,12 @@ def _get_common_attrs(client_manager, parsed_args, is_create=True):
vpn_utils.validate_dpd_dict(parsed_args.dpd)
attrs['dpd'] = parsed_args.dpd
if parsed_args.local_endpoint_group:
_local_epg = client_manager.neutronclient.find_resource(
'endpoint_group',
parsed_args.local_endpoint_group,
cmd_resource='endpoint_group')['id']
_local_epg = client_manager.network.find_vpn_endpoint_group(
parsed_args.local_endpoint_group)['id']
attrs['local_ep_group_id'] = _local_epg
if parsed_args.peer_endpoint_group:
_peer_epg = client_manager.neutronclient.find_resource(
'endpoint_group',
parsed_args.peer_endpoint_group,
cmd_resource='endpoint_group')['id']
_peer_epg = client_manager.network.find_vpn_endpoint_group(
parsed_args.peer_endpoint_group)['id']
attrs['peer_ep_group_id'] = _peer_epg
if parsed_args.peer_cidrs:
attrs['peer_cidrs'] = parsed_args.peer_cidrs
@ -203,25 +224,19 @@ class CreateIPsecSiteConnection(command.ShowOne):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
attrs = _get_common_attrs(self.app.client_manager, parsed_args)
if parsed_args.vpnservice:
_vpnservice_id = client.find_resource(
'vpnservice',
parsed_args.vpnservice,
cmd_resource='vpnservice')['id']
_vpnservice_id = client.find_vpn_service(
parsed_args.vpnservice, ignore_missing=False)['id']
attrs['vpnservice_id'] = _vpnservice_id
if parsed_args.ikepolicy:
_ikepolicy_id = client.find_resource(
'ikepolicy',
parsed_args.ikepolicy,
cmd_resource='ikepolicy')['id']
_ikepolicy_id = client.find_vpn_ike_policy(
parsed_args.ikepolicy, ignore_missing=False)['id']
attrs['ikepolicy_id'] = _ikepolicy_id
if parsed_args.ipsecpolicy:
_ipsecpolicy_id = client.find_resource(
'ipsecpolicy',
parsed_args.ipsecpolicy,
cmd_resource='ipsecpolicy')['id']
_ipsecpolicy_id = client.find_vpn_ipsec_policy(
parsed_args.ipsecpolicy, ignore_missing=False)['id']
attrs['ipsecpolicy_id'] = _ipsecpolicy_id
if parsed_args.peer_id:
attrs['peer_id'] = parsed_args.peer_id
@ -239,9 +254,10 @@ class CreateIPsecSiteConnection(command.ShowOne):
if not parsed_args.peer_cidrs and not parsed_args.local_endpoint_group:
message = _("You must specify endpoint groups or peer CIDR(s)")
raise exceptions.CommandError(message)
obj = client.create_ipsec_site_connection(
{'ipsec_site_connection': attrs})['ipsec_site_connection']
columns, display_columns = column_util.get_columns(obj, _attr_map)
obj = client.create_vpn_ipsec_site_connection(**attrs)
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
obj, _attr_map_dict, ['location', 'tenant_id', 'action',
'timeout', 'interval'])
data = utils.get_dict_properties(obj, columns, formatters=_formatters)
return display_columns, data
@ -259,15 +275,13 @@ class DeleteIPsecSiteConnection(command.Command):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
result = 0
for ipsec_conn in parsed_args.ipsec_site_connection:
try:
ipsec_con_id = client.find_resource(
'ipsec_site_connection',
ipsec_conn,
cmd_resource='ipsec_site_connection')['id']
client.delete_ipsec_site_connection(ipsec_con_id)
ipsec_con_id = client.find_vpn_ipsec_site_connection(
ipsec_conn, ignore_missing=False)['id']
client.delete_vpn_ipsec_site_connection(ipsec_con_id)
except Exception as e:
result += 1
LOG.error(_("Failed to delete IPsec site connection with "
@ -296,8 +310,8 @@ class ListIPsecSiteConnection(command.Lister):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
obj = client.list_ipsec_site_connections()['ipsec_site_connections']
client = self.app.client_manager.network
obj = client.vpn_ipsec_site_connections()
headers, columns = column_util.get_column_definitions(
_attr_map, long_listing=parsed_args.long)
return (headers, (utils.get_dict_properties(
@ -328,7 +342,7 @@ class SetIPsecSiteConnection(command.Command):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
attrs = _get_common_attrs(self.app.client_manager,
parsed_args, is_create=False)
if parsed_args.peer_id:
@ -337,13 +351,10 @@ class SetIPsecSiteConnection(command.Command):
attrs['peer_address'] = parsed_args.peer_address
if parsed_args.name:
attrs['name'] = parsed_args.name
ipsec_conn_id = client.find_resource(
'ipsec_site_connection', parsed_args.ipsec_site_connection,
cmd_resource='ipsec_site_connection')['id']
ipsec_conn_id = client.find_vpn_ipsec_site_connection(
parsed_args.ipsec_site_connection, ignore_missing=False)['id']
try:
client.update_ipsec_site_connection(
ipsec_conn_id,
{'ipsec_site_connection': attrs})
client.update_vpn_ipsec_site_connection(ipsec_conn_id, **attrs)
except Exception as e:
msg = (_("Failed to set IPsec site "
"connection '%(ipsec_conn)s': %(e)s")
@ -363,12 +374,12 @@ class ShowIPsecSiteConnection(command.ShowOne):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
ipsec_site_id = client.find_resource(
'ipsec_site_connection', parsed_args.ipsec_site_connection,
cmd_resource='ipsec_site_connection')['id']
obj = client.show_ipsec_site_connection(
ipsec_site_id)['ipsec_site_connection']
columns, display_columns = column_util.get_columns(obj, _attr_map)
client = self.app.client_manager.network
ipsec_site_id = client.find_vpn_ipsec_site_connection(
parsed_args.ipsec_site_connection, ignore_missing=False)['id']
obj = client.get_vpn_ipsec_site_connection(ipsec_site_id)
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
obj, _attr_map_dict, ['location', 'tenant_id', 'action',
'timeout', 'interval'])
data = utils.get_dict_properties(obj, columns, formatters=_formatters)
return (display_columns, data)

View File

@ -37,10 +37,23 @@ _attr_map = (
('encryption_algorithm', 'Encryption Algorithm', column_util.LIST_BOTH),
('pfs', 'Perfect Forward Secrecy (PFS)', column_util.LIST_LONG_ONLY),
('description', 'Description', column_util.LIST_LONG_ONLY),
('tenant_id', 'Project', column_util.LIST_LONG_ONLY),
('project_id', 'Project', column_util.LIST_LONG_ONLY),
('lifetime', 'Lifetime', column_util.LIST_LONG_ONLY),
)
_attr_map_dict = {
'id': 'ID',
'name': 'Name',
'auth_algorithm': 'Authentication Algorithm',
'encapsulation_mode': 'Encapsulation Mode',
'transform_protocol': 'Transform Protocol',
'encryption_algorithm': 'Encryption Algorithm',
'pfs': 'Perfect Forward Secrecy (PFS)',
'lifetime': 'Lifetime',
'description': 'Description',
'project_id': 'Project',
}
def _convert_to_lowercase(string):
return string.lower()
@ -87,7 +100,7 @@ def _get_common_attrs(client_manager, parsed_args, is_create=True):
attrs = {}
if is_create:
if 'project' in parsed_args and parsed_args.project is not None:
attrs['tenant_id'] = osc_utils.find_project(
attrs['project_id'] = osc_utils.find_project(
client_manager.identity,
parsed_args.project,
parsed_args.project_domain,
@ -124,12 +137,14 @@ class CreateIPsecPolicy(command.ShowOne):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
attrs = _get_common_attrs(self.app.client_manager, parsed_args)
if parsed_args.name:
attrs['name'] = str(parsed_args.name)
obj = client.create_ipsecpolicy({'ipsecpolicy': attrs})['ipsecpolicy']
columns, display_columns = column_util.get_columns(obj, _attr_map)
obj = client.create_vpn_ipsec_policy(**attrs)
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
obj, _attr_map_dict, ['location', 'tenant_id',
'phase1_negotiation_mode', 'units', 'value'])
data = utils.get_dict_properties(obj, columns)
return display_columns, data
@ -147,13 +162,13 @@ class DeleteIPsecPolicy(command.Command):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
result = 0
for ipsec in parsed_args.ipsecpolicy:
try:
ipsec_id = client.find_resource(
'ipsecpolicy', ipsec, cmd_resource='ipsecpolicy')['id']
client.delete_ipsecpolicy(ipsec_id)
ipsec_id = client.find_vpn_ipsec_policy(
ipsec, ignore_missing=False)['id']
client.delete_vpn_ipsec_policy(ipsec_id)
except Exception as e:
result += 1
LOG.error(_("Failed to delete IPsec policy with "
@ -181,8 +196,8 @@ class ListIPsecPolicy(command.Lister):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
obj = client.list_ipsecpolicies()['ipsecpolicies']
client = self.app.client_manager.network
obj = client.vpn_ipsec_policies()
headers, columns = column_util.get_column_definitions(
_attr_map, long_listing=parsed_args.long)
return (headers, (utils.get_dict_properties(s, columns) for s in obj))
@ -205,16 +220,15 @@ class SetIPsecPolicy(command.Command):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
attrs = _get_common_attrs(self.app.client_manager,
parsed_args, is_create=False)
if parsed_args.name:
attrs['name'] = str(parsed_args.name)
ipsec_id = client.find_resource(
'ipsecpolicy', parsed_args.ipsecpolicy,
cmd_resource='ipsecpolicy')['id']
ipsec_id = client.find_vpn_ipsec_policy(
parsed_args.ipsecpolicy, ignore_missing=False)['id']
try:
client.update_ipsecpolicy(ipsec_id, {'ipsecpolicy': attrs})
client.update_vpn_ipsec_policy(ipsec_id, **attrs)
except Exception as e:
msg = (_("Failed to set IPsec policy '%(ipsec)s': %(e)s")
% {'ipsec': parsed_args.ipsecpolicy, 'e': e})
@ -233,11 +247,12 @@ class ShowIPsecPolicy(command.ShowOne):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
ipsec_id = client.find_resource(
'ipsecpolicy', parsed_args.ipsecpolicy,
cmd_resource='ipsecpolicy')['id']
obj = client.show_ipsecpolicy(ipsec_id)['ipsecpolicy']
columns, display_columns = column_util.get_columns(obj, _attr_map)
client = self.app.client_manager.network
ipsec_id = client.find_vpn_ipsec_policy(
parsed_args.ipsecpolicy, ignore_missing=False)['id']
obj = client.get_vpn_ipsec_policy(ipsec_id)
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
obj, _attr_map_dict, ['location', 'tenant_id',
'phase1_negotiation_mode', 'units', 'value'])
data = utils.get_dict_properties(obj, columns)
return (display_columns, data)

View File

@ -32,12 +32,24 @@ _attr_map = (
('router_id', 'Router', column_util.LIST_BOTH),
('subnet_id', 'Subnet', column_util.LIST_BOTH),
('flavor_id', 'Flavor', column_util.LIST_BOTH),
('admin_state_up', 'State', column_util.LIST_BOTH),
('is_admin_state_up', 'State', column_util.LIST_BOTH),
('status', 'Status', column_util.LIST_BOTH),
('description', 'Description', column_util.LIST_LONG_ONLY),
('tenant_id', 'Project', column_util.LIST_LONG_ONLY),
('project_id', 'Project', column_util.LIST_LONG_ONLY),
)
_attr_map_dict = {
'id': 'ID',
'name': 'Name',
'router_id': 'Router',
'subnet_id': 'Subnet',
'flavor_id': 'Flavor',
'is_admin_state_up': 'State',
'status': 'Status',
'description': 'Description',
'project_id': 'Project',
}
def _get_common_parser(parser):
parser.add_argument(
@ -70,7 +82,7 @@ def _get_common_attrs(client_manager, parsed_args, is_create=True):
attrs = {}
if is_create:
if 'project' in parsed_args and parsed_args.project is not None:
attrs['tenant_id'] = osc_utils.find_project(
attrs['project_id'] = osc_utils.find_project(
client_manager.identity,
parsed_args.project,
parsed_args.project_domain,
@ -113,16 +125,18 @@ class CreateVPNService(command.ShowOne):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
attrs = _get_common_attrs(self.app.client_manager, parsed_args)
if parsed_args.name:
attrs['name'] = str(parsed_args.name)
if parsed_args.router:
_router_id = self.app.client_manager.network.find_router(
parsed_args.router).id
_router_id = client.find_router(parsed_args.router,
ignore_missing=False).id
attrs['router_id'] = _router_id
obj = client.create_vpnservice({'vpnservice': attrs})['vpnservice']
columns, display_columns = column_util.get_columns(obj, _attr_map)
obj = client.create_vpn_service(**attrs)
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
obj, _attr_map_dict, ['location', 'tenant_id', 'external_v4_ip',
'external_v6_ip'])
data = utils.get_dict_properties(obj, columns)
return display_columns, data
@ -140,13 +154,13 @@ class DeleteVPNService(command.Command):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
result = 0
for vpn in parsed_args.vpnservice:
try:
vpn_id = client.find_resource(
'vpnservice', vpn, cmd_resource='vpnservice')['id']
client.delete_vpnservice(vpn_id)
vpn_id = client.find_vpn_service(vpn,
ignore_missing=False)['id']
client.delete_vpn_service(vpn_id)
except Exception as e:
result += 1
LOG.error(_("Failed to delete VPN service with "
@ -174,8 +188,8 @@ class ListVPNService(command.Lister):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
obj = client.list_vpnservices()['vpnservices']
client = self.app.client_manager.network
obj = client.vpn_services()
headers, columns = column_util.get_column_definitions(
_attr_map, long_listing=parsed_args.long)
return (headers, (utils.get_dict_properties(s, columns) for s in obj))
@ -198,16 +212,15 @@ class SetVPNSercice(command.Command):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
client = self.app.client_manager.network
attrs = _get_common_attrs(self.app.client_manager,
parsed_args, is_create=False)
if parsed_args.name:
attrs['name'] = str(parsed_args.name)
vpn_id = client.find_resource(
'vpnservice', parsed_args.vpnservice,
cmd_resource='vpnservice')['id']
vpn_id = client.find_vpn_service(parsed_args.vpnservice,
ignore_missing=False)['id']
try:
client.update_vpnservice(vpn_id, {'vpnservice': attrs})
client.update_vpn_service(vpn_id, **attrs)
except Exception as e:
msg = (_("Failed to set vpn service '%(vpn)s': %(e)s")
% {'vpn': parsed_args.vpnservice, 'e': e})
@ -226,11 +239,12 @@ class ShowVPNService(command.ShowOne):
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.neutronclient
vpn_id = client.find_resource(
'vpnservice', parsed_args.vpnservice,
cmd_resource='vpnservice')['id']
obj = client.show_vpnservice(vpn_id)['vpnservice']
columns, display_columns = column_util.get_columns(obj, _attr_map)
client = self.app.client_manager.network
vpn_id = client.find_vpn_service(parsed_args.vpnservice,
ignore_missing=False)['id']
obj = client.get_vpn_service(vpn_id)
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
obj, _attr_map_dict, ['location', 'tenant_id', 'external_v4_ip',
'external_v6_ip'])
data = utils.get_dict_properties(obj, columns)
return (display_columns, data)

View File

@ -29,6 +29,17 @@ class TestDeleteVPNaaS(test_fakes.TestNeutronClientOSCV2):
def test_delete_with_one_resource(self):
target = self.resource['id']
def _mock_vpnaas(*args, **kwargs):
return {'id': args[0]}
self.networkclient.find_vpn_endpoint_group.side_effect = _mock_vpnaas
self.networkclient.find_vpn_ipsec_site_connection.side_effect = \
_mock_vpnaas
self.networkclient.find_vpn_ike_policy.side_effect = _mock_vpnaas
self.networkclient.find_vpn_ipsec_policy.side_effect = _mock_vpnaas
self.networkclient.find_vpn_service.side_effect = _mock_vpnaas
arglist = [target]
verifylist = [(self.res, [target])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -40,12 +51,14 @@ class TestDeleteVPNaaS(test_fakes.TestNeutronClientOSCV2):
def test_delete_with_multiple_resources(self):
def _mock_vpnaas(*args, **kwargs):
self.assertEqual(self.res, args[0])
self.assertIsNotNone(args[1])
self.assertEqual({'cmd_resource': self.res}, kwargs)
return {'id': args[1]}
return {'id': args[0]}
self.neutronclient.find_resource.side_effect = _mock_vpnaas
self.networkclient.find_vpn_endpoint_group.side_effect = _mock_vpnaas
self.networkclient.find_vpn_ipsec_site_connection.side_effect = \
_mock_vpnaas
self.networkclient.find_vpn_ike_policy.side_effect = _mock_vpnaas
self.networkclient.find_vpn_ipsec_policy.side_effect = _mock_vpnaas
self.networkclient.find_vpn_service.side_effect = _mock_vpnaas
target1 = 'target1'
target2 = 'target2'
@ -66,7 +79,19 @@ class TestDeleteVPNaaS(test_fakes.TestNeutronClientOSCV2):
arglist = [target1]
verifylist = [(self.res, [target1])]
self.neutronclient.find_resource.side_effect = [
self.networkclient.find_vpn_ipsec_site_connection.side_effect = [
target1, exceptions.CommandError
]
self.networkclient.find_vpn_endpoint_group.side_effect = [
target1, exceptions.CommandError
]
self.networkclient.find_vpn_ike_policy.side_effect = [
target1, exceptions.CommandError
]
self.networkclient.find_vpn_service.side_effect = [
target1, exceptions.CommandError
]
self.networkclient.find_vpn_ipsec_policy.side_effect = [
target1, exceptions.CommandError
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -114,7 +139,7 @@ class TestSetVPNaaS(test_fakes.TestNeutronClientOSCV2):
result = self.cmd.take_action(parsed_args)
self.mocked.assert_called_once_with(
target, {self.res: {'name': update}})
target, **{'name': update})
self.assertIsNone(result)
def test_set_description(self):
@ -129,7 +154,7 @@ class TestSetVPNaaS(test_fakes.TestNeutronClientOSCV2):
result = self.cmd.take_action(parsed_args)
self.mocked.assert_called_once_with(
target, {self.res: {'description': update}})
target, **{'description': update})
self.assertIsNone(result)
@ -139,13 +164,14 @@ class TestShowVPNaaS(test_fakes.TestNeutronClientOSCV2):
target = self.resource['id']
def _mock_vpnaas(*args, **kwargs):
if self.neutronclient.find_resource.call_count == 1:
self.assertEqual(self.res, args[0])
self.assertEqual(self.resource['id'], args[1])
self.assertEqual({'cmd_resource': self.res}, kwargs)
return {'id': args[1]}
return {'id': args[0]}
self.neutronclient.find_resource.side_effect = _mock_vpnaas
self.networkclient.find_vpn_endpoint_group.side_effect = _mock_vpnaas
self.networkclient.find_vpn_ipsec_site_connection.side_effect = \
_mock_vpnaas
self.networkclient.find_vpn_ike_policy.side_effect = _mock_vpnaas
self.networkclient.find_vpn_ipsec_policy.side_effect = _mock_vpnaas
self.networkclient.find_vpn_service.side_effect = _mock_vpnaas
arglist = [target]
verifylist = [(self.res, target)]

View File

@ -15,10 +15,15 @@
#
import collections
import copy
from unittest import mock
import uuid
from openstack.network.v2 import vpn_endpoint_group as vpn_epg
from openstack.network.v2 import vpn_ike_policy as vpn_ikep
from openstack.network.v2 import vpn_ipsec_policy as vpn_ipsecp
from openstack.network.v2 import vpn_ipsec_site_connection as vpn_sitec
from openstack.network.v2 import vpn_service
class FakeVPNaaS(object):
@ -31,7 +36,14 @@ class FakeVPNaaS(object):
A OrderedDict faking the vpnaas resource
"""
self.ordered.update(attrs)
return copy.deepcopy(self.ordered)
if 'IKEPolicy' == self.__class__.__name__:
return vpn_ikep.VpnIkePolicy(**self.ordered)
if 'IPSecPolicy' == self.__class__.__name__:
return vpn_ipsecp.VpnIpsecPolicy(**self.ordered)
if 'VPNService' == self.__class__.__name__:
return vpn_service.VpnService(**self.ordered)
if 'EndpointGroup' == self.__class__.__name__:
return vpn_epg.VpnEndpointGroup(**self.ordered)
def bulk_create(self, attrs=None, count=2):
"""Create multiple fake vpnaas resources
@ -74,7 +86,7 @@ class IKEPolicy(FakeVPNaaS):
('pfs', 'group5'),
('description', 'my-desc-' + uuid.uuid4().hex),
('phase1_negotiation_mode', 'main'),
('tenant_id', 'tenant-id-' + uuid.uuid4().hex),
('project_id', 'project-id-' + uuid.uuid4().hex),
('lifetime', {'units': 'seconds', 'value': 3600}),
))
@ -93,7 +105,7 @@ class IPSecPolicy(FakeVPNaaS):
('encryption_algorithm', 'aes-128'),
('pfs', 'group5'),
('description', 'my-desc-' + uuid.uuid4().hex),
('tenant_id', 'tenant-id-' + uuid.uuid4().hex),
('project_id', 'project-id-' + uuid.uuid4().hex),
('lifetime', {'units': 'seconds', 'value': 3600}),
))
@ -112,7 +124,7 @@ class VPNService(FakeVPNaaS):
('admin_state_up', True),
('status', 'ACTIVE'),
('description', 'my-desc-' + uuid.uuid4().hex),
('tenant_id', 'tenant-id-' + uuid.uuid4().hex),
('project_id', 'project-id-' + uuid.uuid4().hex),
))
@ -127,7 +139,7 @@ class EndpointGroup(FakeVPNaaS):
('type', 'cidr'),
('endpoints', ['10.0.0.0/24', '20.0.0.0/24']),
('description', 'my-desc-' + uuid.uuid4().hex),
('tenant_id', 'tenant-id-' + uuid.uuid4().hex),
('project_id', 'project-id-' + uuid.uuid4().hex),
))
@ -141,7 +153,7 @@ class IPsecSiteConnection(object):
A dictionary with all attributes
:return:
A Dictionary with id, name, peer_address, auth_mode, status,
tenant_id, peer_cidrs, vpnservice_id, ipsecpolicy_id,
project_id, peer_cidrs, vpnservice_id, ipsecpolicy_id,
ikepolicy_id, mtu, initiator, admin_state_up, description,
psk, route_mode, local_id, peer_id, local_ep_group_id,
peer_ep_group_id
@ -155,7 +167,7 @@ class IPsecSiteConnection(object):
'peer_address': '192.168.2.10',
'auth_mode': '',
'status': '',
'tenant_id': 'tenant-id-' + uuid.uuid4().hex,
'project_id': 'project-id-' + uuid.uuid4().hex,
'peer_cidrs': [],
'vpnservice_id': 'vpnservice-id-' + uuid.uuid4().hex,
'ipsecpolicy_id': 'ipsecpolicy-id-' + uuid.uuid4().hex,
@ -174,4 +186,4 @@ class IPsecSiteConnection(object):
# Overwrite default attributes.
conn_attrs.update(attrs)
return copy.deepcopy(conn_attrs)
return vpn_sitec.VpnIPSecSiteConnection(**conn_attrs)

View File

@ -14,7 +14,6 @@
# under the License.
#
import copy
from unittest import mock
from osc_lib.tests import utils as tests_utils
@ -36,12 +35,12 @@ def _generate_data(ordered_dict=None, data=None):
source = ordered_dict if ordered_dict else _endpoint_group
if data:
source.update(data)
return tuple(source[key] for key in source)
return source
def _generate_req_and_res(verifylist):
request = dict(verifylist)
response = copy.deepcopy(_endpoint_group)
response = _endpoint_group
for key, val in verifylist:
converted = CONVERT_MAP.get(key, key)
del request[key]
@ -55,25 +54,25 @@ class TestEndpointGroup(test_fakes.TestNeutronClientOSCV2):
def check_results(self, headers, data, exp_req, is_list=False):
if is_list:
req_body = {self.res_plural: [exp_req]}
req_body = {self.res_plural: list(exp_req)}
else:
req_body = {self.res: exp_req}
self.mocked.assert_called_once_with(req_body)
self.assertEqual(self.ordered_headers, headers)
req_body = exp_req
self.mocked.assert_called_once_with(**req_body)
self.assertEqual(self.ordered_headers, tuple(sorted(headers)))
self.assertEqual(self.ordered_data, data)
def setUp(self):
super(TestEndpointGroup, self).setUp()
def _mock_endpoint_group(*args, **kwargs):
self.neutronclient.find_resource.assert_called_once_with(
self.res, self.resource['id'], cmd_resource='endpoint_group')
return {'id': args[1]}
self.networkclient.find_vpn_endpoint_group.assert_called_once_with(
self.resource['id'], ignore_missing=False)
return {'id': args[0]}
self.neutronclient.find_resource.side_effect = mock.Mock(
self.networkclient.find_vpn_endpoint_group.side_effect = mock.Mock(
side_effect=_mock_endpoint_group)
osc_utils.find_project = mock.Mock()
osc_utils.find_project.id = _endpoint_group['tenant_id']
osc_utils.find_project.id = _endpoint_group['project_id']
self.res = 'endpoint_group'
self.res_plural = 'endpoint_groups'
self.resource = _endpoint_group
@ -99,7 +98,7 @@ class TestEndpointGroup(test_fakes.TestNeutronClientOSCV2):
_endpoint_group['endpoints'],
_endpoint_group['id'],
_endpoint_group['name'],
_endpoint_group['tenant_id'],
_endpoint_group['project_id'],
_endpoint_group['type'],
)
self.ordered_columns = (
@ -107,7 +106,7 @@ class TestEndpointGroup(test_fakes.TestNeutronClientOSCV2):
'endpoints',
'id',
'name',
'tenant_id',
'project_id',
'type',
)
@ -116,9 +115,9 @@ class TestCreateEndpointGroup(TestEndpointGroup, common.TestCreateVPNaaS):
def setUp(self):
super(TestCreateEndpointGroup, self).setUp()
self.neutronclient.create_endpoint_group = mock.Mock(
return_value={self.res: _endpoint_group})
self.mocked = self.neutronclient.create_endpoint_group
self.networkclient.create_vpn_endpoint_group = mock.Mock(
return_value=_endpoint_group)
self.mocked = self.networkclient.create_vpn_endpoint_group
self.cmd = endpoint_group.CreateEndpointGroup(self.app, self.namespace)
def _update_expect_response(self, request, response):
@ -144,7 +143,7 @@ class TestCreateEndpointGroup(TestEndpointGroup, common.TestCreateVPNaaS):
description = args.get('description') or 'my-desc'
endpoint_type = args.get('type') or 'cidr'
endpoints = args.get('endpoints') or ['10.0.0.0/24', '20.0.0.0/24']
tenant_id = args.get('tenant_id') or 'my-tenant'
tenant_id = args.get('project_id') or 'my-tenant'
arglist = [
'--description', description,
'--type', endpoint_type,
@ -186,9 +185,8 @@ class TestDeleteEndpointGroup(TestEndpointGroup, common.TestDeleteVPNaaS):
def setUp(self):
super(TestDeleteEndpointGroup, self).setUp()
self.neutronclient.delete_endpoint_group = mock.Mock(
return_value={self.res: _endpoint_group})
self.mocked = self.neutronclient.delete_endpoint_group
self.networkclient.delete_vpn_endpoint_group = mock.Mock()
self.mocked = self.networkclient.delete_vpn_endpoint_group
self.cmd = endpoint_group.DeleteEndpointGroup(self.app, self.namespace)
@ -212,9 +210,9 @@ class TestListEndpointGroup(TestEndpointGroup):
_endpoint_group['endpoints'],
)
self.neutronclient.list_endpoint_groups = mock.Mock(
return_value={self.res_plural: [_endpoint_group]})
self.mocked = self.neutronclient.list_endpoint_groups
self.networkclient.vpn_endpoint_groups = mock.Mock(
return_value=[_endpoint_group])
self.mocked = self.networkclient.vpn_endpoint_groups
def test_list_with_long_option(self):
arglist = ['--long']
@ -224,7 +222,6 @@ class TestListEndpointGroup(TestEndpointGroup):
self.mocked.assert_called_once_with()
self.assertEqual(list(self.headers), headers)
self.assertEqual([self.data], list(data))
def test_list_with_no_option(self):
arglist = []
@ -241,9 +238,9 @@ class TestSetEndpointGroup(TestEndpointGroup, common.TestSetVPNaaS):
def setUp(self):
super(TestSetEndpointGroup, self).setUp()
self.neutronclient.update_endpoint_group = mock.Mock(
return_value={self.res: _endpoint_group})
self.mocked = self.neutronclient.update_endpoint_group
self.networkclient.update_vpn_endpoint_group = mock.Mock(
return_value=_endpoint_group)
self.mocked = self.networkclient.update_vpn_endpoint_group
self.cmd = endpoint_group.SetEndpointGroup(self.app, self.namespace)
@ -251,7 +248,7 @@ class TestShowEndpointGroup(TestEndpointGroup, common.TestShowVPNaaS):
def setUp(self):
super(TestShowEndpointGroup, self).setUp()
self.neutronclient.show_endpoint_group = mock.Mock(
return_value={self.res: _endpoint_group})
self.mocked = self.neutronclient.show_endpoint_group
self.networkclient.get_vpn_endpoint_group = mock.Mock(
return_value=_endpoint_group)
self.mocked = self.networkclient.get_vpn_endpoint_group
self.cmd = endpoint_group.ShowEndpointGroup(self.app, self.namespace)

View File

@ -14,7 +14,6 @@
# under the License.
#
import copy
from unittest import mock
from osc_lib.tests import utils as tests_utils
@ -28,7 +27,7 @@ from neutronclient.tests.unit.osc.v2.vpnaas import fakes
_ikepolicy = fakes.IKEPolicy().create()
CONVERT_MAP = {
'project': 'tenant_id',
'project': 'project_id',
}
@ -36,12 +35,12 @@ def _generate_data(ordered_dict=None, data=None):
source = ordered_dict if ordered_dict else _ikepolicy
if data:
source.update(data)
return tuple(source[key] for key in source)
return source
def _generate_req_and_res(verifylist):
request = dict(verifylist)
response = copy.deepcopy(_ikepolicy)
response = _ikepolicy
for key, val in verifylist:
converted = CONVERT_MAP.get(key, key)
del request[key]
@ -55,25 +54,25 @@ class TestIKEPolicy(test_fakes.TestNeutronClientOSCV2):
def check_results(self, headers, data, exp_req, is_list=False):
if is_list:
req_body = {self.res_plural: [exp_req]}
req_body = {self.res_plural: list(exp_req)}
else:
req_body = {self.res: exp_req}
self.mocked.assert_called_once_with(req_body)
self.assertEqual(self.ordered_headers, headers)
req_body = exp_req
self.mocked.assert_called_once_with(**req_body)
self.assertEqual(self.ordered_headers, tuple(sorted(headers)))
self.assertEqual(self.ordered_data, data)
def setUp(self):
super(TestIKEPolicy, self).setUp()
def _mock_ikepolicy(*args, **kwargs):
self.neutronclient.find_resource.assert_called_once_with(
self.res, self.resource['id'], cmd_resource='ikepolicy')
return {'id': args[1]}
self.networkclient.find_vpn_ike_policy.assert_called_once_with(
self.resource['id'], ignore_missing=False)
return {'id': args[0]}
self.neutronclient.find_resource.side_effect = mock.Mock(
self.networkclient.find_vpn_ike_policy.side_effect = mock.Mock(
side_effect=_mock_ikepolicy)
osc_utils.find_project = mock.Mock()
osc_utils.find_project.id = _ikepolicy['tenant_id']
osc_utils.find_project.id = _ikepolicy['project_id']
self.res = 'ikepolicy'
self.res_plural = 'ikepolicies'
self.resource = _ikepolicy
@ -112,7 +111,7 @@ class TestIKEPolicy(test_fakes.TestNeutronClientOSCV2):
_ikepolicy['name'],
_ikepolicy['pfs'],
_ikepolicy['phase1_negotiation_mode'],
_ikepolicy['tenant_id'],
_ikepolicy['project_id'],
)
self.ordered_columns = (
'auth_algorithm',
@ -124,7 +123,7 @@ class TestIKEPolicy(test_fakes.TestNeutronClientOSCV2):
'name',
'pfs',
'phase1_negotiation_mode',
'tenant_id',
'project_id',
)
@ -132,9 +131,9 @@ class TestCreateIKEPolicy(TestIKEPolicy, common.TestCreateVPNaaS):
def setUp(self):
super(TestCreateIKEPolicy, self).setUp()
self.neutronclient.create_ikepolicy = mock.Mock(
return_value={self.res: _ikepolicy})
self.mocked = self.neutronclient.create_ikepolicy
self.networkclient.create_vpn_ike_policy = mock.Mock(
return_value=_ikepolicy)
self.mocked = self.networkclient.create_vpn_ike_policy
self.cmd = ikepolicy.CreateIKEPolicy(self.app, self.namespace)
def _update_expect_response(self, request, response):
@ -146,9 +145,8 @@ class TestCreateIKEPolicy(TestIKEPolicy, common.TestCreateVPNaaS):
A OrderedDict of request body
"""
# Update response body
self.neutronclient.create_ikepolicy.return_value = \
{self.res: dict(response)}
osc_utils.find_project.return_value.id = response['tenant_id']
self.networkclient.create_vpn_ikepolicy.return_value = response
osc_utils.find_project.return_value.id = response['project_id']
# Update response(finally returns 'data')
self.data = _generate_data(ordered_dict=response)
self.ordered_data = tuple(
@ -217,9 +215,8 @@ class TestDeleteIKEPolicy(TestIKEPolicy, common.TestDeleteVPNaaS):
def setUp(self):
super(TestDeleteIKEPolicy, self).setUp()
self.neutronclient.delete_ikepolicy = mock.Mock(
return_value={self.res: _ikepolicy})
self.mocked = self.neutronclient.delete_ikepolicy
self.networkclient.delete_vpn_ike_policy = mock.Mock()
self.mocked = self.networkclient.delete_vpn_ike_policy
self.cmd = ikepolicy.DeleteIKEPolicy(self.app, self.namespace)
@ -247,9 +244,9 @@ class TestListIKEPolicy(TestIKEPolicy):
_ikepolicy['pfs'],
)
self.neutronclient.list_ikepolicies = mock.Mock(
return_value={self.res_plural: [_ikepolicy]})
self.mocked = self.