Add a flavor to the load balancer CRUD scenarios

This patch adds flavor configuration to the load balancer CRUD
scenario tests. It also updates the multinode jobs to use a
flavor configured for the active/standby topology.

Change-Id: I46c442df698f7da5bf48c404b06039477382852c
diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_load_balancer.py b/octavia_tempest_plugin/tests/scenario/v2/test_load_balancer.py
index 79f1876..3d79173 100644
--- a/octavia_tempest_plugin/tests/scenario/v2/test_load_balancer.py
+++ b/octavia_tempest_plugin/tests/scenario/v2/test_load_balancer.py
@@ -17,6 +17,7 @@
 
 from dateutil import parser
 
+from oslo_serialization import jsonutils
 from tempest import config
 from tempest.lib.common.utils import data_utils
 from tempest.lib import decorators
@@ -30,6 +31,49 @@
 
 class LoadBalancerScenarioTest(test_base.LoadBalancerBaseTest):
 
+    @classmethod
+    def resource_setup(cls):
+        """Setup resources needed by the tests."""
+        super(LoadBalancerScenarioTest, cls).resource_setup()
+
+        if cls.lb_admin_flavor_profile_client.is_version_supported(
+                cls.api_version, '2.6'):
+
+            # Create a shared flavor profile
+            flavor_profile_name = data_utils.rand_name("lb_scenario-setup")
+            flavor_data = {const.LOADBALANCER_TOPOLOGY:
+                           CONF.load_balancer.loadbalancer_topology}
+            flavor_data_json = jsonutils.dumps(flavor_data)
+
+            flavor_profile_kwargs = {
+                const.NAME: flavor_profile_name,
+                const.PROVIDER_NAME: CONF.load_balancer.provider,
+                const.FLAVOR_DATA: flavor_data_json
+            }
+
+            cls.flavor_profile = (
+                cls.lb_admin_flavor_profile_client.create_flavor_profile(
+                    **flavor_profile_kwargs))
+            cls.addClassResourceCleanup(
+                cls.lb_admin_flavor_profile_client.cleanup_flavor_profile,
+                cls.flavor_profile[const.ID])
+
+            flavor_name = data_utils.rand_name("lb_scenario-setup")
+            flavor_description = data_utils.arbitrary_string(size=255)
+
+            flavor_kwargs = {
+                const.NAME: flavor_name,
+                const.DESCRIPTION: flavor_description,
+                const.ENABLED: True,
+                const.FLAVOR_PROFILE_ID: cls.flavor_profile[const.ID]}
+
+            cls.flavor = cls.lb_admin_flavor_client.create_flavor(
+                **flavor_kwargs)
+            cls.addClassResourceCleanup(
+                cls.lb_admin_flavor_client.cleanup_a_flavor,
+                cls.flavor[const.ID])
+            cls.flavor_id = cls.flavor[const.ID]
+
     @decorators.idempotent_id('a5e2e120-4f7e-4c8b-8aac-cf09cb56711c')
     def test_load_balancer_ipv4_CRUD(self):
         self._test_load_balancer_CRUD(4)
@@ -56,6 +100,10 @@
                      const.PROVIDER: CONF.load_balancer.provider,
                      const.NAME: lb_name}
 
+        if self.lb_admin_flavor_profile_client.is_version_supported(
+                self.api_version, '2.6'):
+            lb_kwargs[const.FLAVOR_ID] = self.flavor_id
+
         self._setup_lb_network_kwargs(lb_kwargs, ip_version)
 
         lb = self.mem_lb_client.create_loadbalancer(**lb_kwargs)
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
index db5e924..991bf41 100644
--- a/zuul.d/jobs.yaml
+++ b/zuul.d/jobs.yaml
@@ -351,6 +351,7 @@
     parent: octavia-v2-dsvm-py2-scenario
     override-checkout: stable/queens
 
+# Legacy jobs for the transition to the act-stdby two node jobs
 - job:
     name: octavia-v2-dsvm-scenario-two-node
     parent: octavia-dsvm-live-two-node-base
@@ -371,6 +372,30 @@
           USE_PYTHON3: False
 
 - job:
+    name: octavia-v2-act-stdby-dsvm-scenario-two-node
+    parent: octavia-dsvm-live-two-node-base
+    vars:
+      tempest_concurrency: 2
+      tempest_test_regex: ^octavia_tempest_plugin.tests.scenario.v2
+      tox_envlist: all
+      devstack_local_conf:
+        test-config:
+          "$TEMPEST_CONFIG":
+            load_balancer:
+              loadbalancer_topology: ACTIVE_STANDBY
+
+- job:
+    name: octavia-v2-act-stdby-dsvm-py2-scenario-two-node
+    parent: octavia-v2-act-stdby-dsvm-scenario-two-node
+    host-vars:
+      controller:
+        devstack_localrc:
+          USE_PYTHON3: False
+      controller2:
+        devstack_localrc:
+          USE_PYTHON3: False
+
+- job:
     name: octavia-v2-dsvm-py2-scenario-centos-7
     parent: octavia-v2-dsvm-py2-scenario
     nodeset: devstack-single-node-centos-7
diff --git a/zuul.d/projects.yaml b/zuul.d/projects.yaml
index 2bb813e..490d68b 100644
--- a/zuul.d/projects.yaml
+++ b/zuul.d/projects.yaml
@@ -22,9 +22,9 @@
             voting: false
         - octavia-v2-dsvm-scenario-ubuntu-bionic:
             voting: false
-        - octavia-v2-dsvm-scenario-two-node:
+        - octavia-v2-act-stdby-dsvm-scenario-two-node:
             voting: false
-        - octavia-v2-dsvm-py2-scenario-two-node:
+        - octavia-v2-act-stdby-dsvm-py2-scenario-two-node:
             voting: false
         - octavia-v2-act-stdby-iptables-dsvm-scenario:
             voting: false