diff --git a/tobiko/openstack/stacks/_octavia.py b/tobiko/openstack/stacks/_octavia.py index 4c2773683..d9a3098c7 100644 --- a/tobiko/openstack/stacks/_octavia.py +++ b/tobiko/openstack/stacks/_octavia.py @@ -88,12 +88,21 @@ class OctaviaLoadbalancerStackFixture(heat.HeatStackFixture): 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 provider = 'amphora' @property - def vip_subnet_id(self): + def vip_subnet(self): if self.ip_version == 4: return self.vip_network.ipv4_subnet_id else: diff --git a/tobiko/openstack/stacks/octavia/load_balancer.yaml b/tobiko/openstack/stacks/octavia/load_balancer.yaml index d067f995d..07537b959 100644 --- a/tobiko/openstack/stacks/octavia/load_balancer.yaml +++ b/tobiko/openstack/stacks/octavia/load_balancer.yaml @@ -1,4 +1,4 @@ -heat_template_version: 2015-10-15 +heat_template_version: newton description: A Load Balancer @@ -7,19 +7,46 @@ parameters: type: string description: The provider type (amphora,ovn, etc.) - vip_subnet_id: + vip_subnet: type: string description: ID of the load balancer public subnet constraints: - 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: loadbalancer: type: OS::Octavia::LoadBalancer properties: - vip_subnet: { get_param: vip_subnet_id } + vip_subnet: { get_param: vip_subnet } 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: loadbalancer_id: description: Load Balancer ID @@ -28,3 +55,8 @@ outputs: loadbalancer_vip: description: IP address of the load balancer's VIP port 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