fixed customer_gateway

Signed-off-by: nik.kaluzhin <doupfish@gmail.com>
Change-Id: I1c9b790eb6ce3f9d4281d6b1306eed49043078f3
This commit is contained in:
nik.kaluzhin 2022-07-22 01:37:13 +03:00
parent ebb12611ca
commit 77d6b2fc8e
2 changed files with 15 additions and 7 deletions

View File

@ -1978,10 +1978,10 @@ class VpcCloudController(CloudController):
Information about one or more virtual private gateways.
"""
@module_and_param_types(customer_gateway, 'ip', 'vpn_connection_type',
'int')
def create_customer_gateway(self, context, ip_address, type,
bgp_asn=None):
@module_and_param_types(customer_gateway, 'vpn_connection_type',
'int', 'ip', 'ip')
def create_customer_gateway(self, context, type,
bgp_asn=None, ip_address=None, public_ip=None):
"""Provides information to EC2 API about VPN customer gateway device.
Args:

View File

@ -29,14 +29,22 @@ Validator = common.Validator
DEFAULT_BGP_ASN = 65000
def create_customer_gateway(context, ip_address, type, bgp_asn=None):
def create_customer_gateway(context, type, bgp_asn=None,
ip_address=None, public_ip=None):
if ip_address:
ip_addr = ip_address
elif (ip_address == None) and public_ip:
ip_addr = public_ip
elif (ip_address == None) and (public_ip == None):
raise exception.Unsupported("GW without ip not supported")
if bgp_asn and bgp_asn != DEFAULT_BGP_ASN:
raise exception.Unsupported("BGP dynamic routing is unsupported")
# testing output to get ec2 failures
customer_gateway = next((cgw for cgw in db_api.get_items(context, 'cgw')
if cgw['ip_address'] == ip_address), None)
if cgw['ip_address'] == ip_addr), None)
if not customer_gateway:
customer_gateway = db_api.add_item(context, 'cgw',
{'ip_address': ip_address})
{'ip_address': ip_addr})
return {'customerGateway': _format_customer_gateway(customer_gateway)}