Add floating IP to loadbalancer stack

Change-Id: I8a16edc053aad4377821481b5a927a22cabe86b7
This commit is contained in:
Federico Ressi 2021-10-11 15:45:37 +02:00
parent fff823b0c8
commit afb02539ec
2 changed files with 45 additions and 4 deletions

View File

@ -88,12 +88,21 @@ class OctaviaLoadbalancerStackFixture(heat.HeatStackFixture):
vip_network = tobiko.required_setup_fixture(OctaviaVipNetworkStackFixture) vip_network = tobiko.required_setup_fixture(OctaviaVipNetworkStackFixture)
#: Floating IP network where the Neutron floating IP are created
@property
def floating_network(self) -> str:
return self.vip_network.floating_network
@property
def has_floating_ip(self) -> bool:
return bool(self.floating_network)
ip_version = 4 ip_version = 4
provider = 'amphora' provider = 'amphora'
@property @property
def vip_subnet_id(self): def vip_subnet(self):
if self.ip_version == 4: if self.ip_version == 4:
return self.vip_network.ipv4_subnet_id return self.vip_network.ipv4_subnet_id
else: else:

View File

@ -1,4 +1,4 @@
heat_template_version: 2015-10-15 heat_template_version: newton
description: A Load Balancer description: A Load Balancer
@ -7,19 +7,46 @@ parameters:
type: string type: string
description: The provider type (amphora,ovn, etc.) description: The provider type (amphora,ovn, etc.)
vip_subnet_id: vip_subnet:
type: string type: string
description: ID of the load balancer public subnet description: ID of the load balancer public subnet
constraints: constraints:
- custom_constraint: neutron.subnet - custom_constraint: neutron.subnet
has_floating_ip:
type: boolean
description: Whenever server has floating IP associated
default: false
floating_network:
type: string
description: |
Public network for which floating IP addresses will be allocated
constraints:
- custom_constraint: neutron.network
conditions:
has_floating_ip:
get_param: has_floating_ip
resources: resources:
loadbalancer: loadbalancer:
type: OS::Octavia::LoadBalancer type: OS::Octavia::LoadBalancer
properties: properties:
vip_subnet: { get_param: vip_subnet_id } vip_subnet: { get_param: vip_subnet }
provider: { get_param: provider } provider: { get_param: provider }
floating_ip:
type: OS::Neutron::FloatingIP
description: Floating IP address to be connected to the load balancer
condition: has_floating_ip
properties:
floating_network: {get_param: floating_network}
port_id: {get_attr: [loadbalancer, vip_port_id]}
outputs: outputs:
loadbalancer_id: loadbalancer_id:
description: Load Balancer ID description: Load Balancer ID
@ -28,3 +55,8 @@ outputs:
loadbalancer_vip: loadbalancer_vip:
description: IP address of the load balancer's VIP port description: IP address of the load balancer's VIP port
value: { get_attr: [ loadbalancer, vip_address ] } value: { get_attr: [ loadbalancer, vip_address ] }
floating_ip_address:
description: Floating IP address attached to VIP address
value: { get_attr: [ floating_ip, floating_ip_address ] }
condition: has_floating_ip