Merge "Replace git.openstack.org URLs with opendev.org URLs"
diff --git a/neutron_tempest_plugin/api/test_routers.py b/neutron_tempest_plugin/api/test_routers.py
index 4637dd6..5c98c8b 100644
--- a/neutron_tempest_plugin/api/test_routers.py
+++ b/neutron_tempest_plugin/api/test_routers.py
@@ -251,7 +251,8 @@
     required_extensions = ['dvr', 'l3-ha']
 
     @decorators.idempotent_id('644d7a4a-01a1-4b68-bb8d-0c0042cb1729')
-    def test_convert_centralized_router(self):
+    def test_convert_distributed_router_back_to_centralized(self):
+        # Convert a centralized router to distributed firstly
         router_args = {'tenant_id': self.client.tenant_id,
                        'distributed': False, 'ha': False}
         router = self.admin_client.create_router(
@@ -266,6 +267,14 @@
         self.assertTrue(update_body['router']['distributed'])
         show_body = self.admin_client.show_router(router['id'])
         self.assertTrue(show_body['router']['distributed'])
+        self.assertFalse(show_body['router']['ha'])
+        # Then convert the distributed router back to centralized
+        update_body = self.admin_client.update_router(router['id'],
+                                                      distributed=False)
+        self.assertFalse(update_body['router']['distributed'])
+        show_body = self.admin_client.show_router(router['id'])
+        self.assertFalse(show_body['router']['distributed'])
+        self.assertFalse(show_body['router']['ha'])
         show_body = self.client.show_router(router['id'])
         self.assertNotIn('distributed', show_body['router'])
         self.assertNotIn('ha', show_body['router'])
diff --git a/neutron_tempest_plugin/config.py b/neutron_tempest_plugin/config.py
index df07042..05142d8 100644
--- a/neutron_tempest_plugin/config.py
+++ b/neutron_tempest_plugin/config.py
@@ -86,6 +86,13 @@
     # Options for special, "advanced" image like e.g. Ubuntu. Such image can be
     # used in tests which require some more advanced tool than available in
     # Cirros
+    cfg.BoolOpt('default_image_is_advanced',
+                default=False,
+                help='Default image is an image which supports features '
+                     'that Cirros does not, like Ubuntu or CentOS supporting '
+                     'advanced features. '
+                     'If this is set to True, "advanced_image_ref" option '
+                     'is not required to be set.'),
     cfg.StrOpt('advanced_image_ref',
                default=None,
                help='Valid advanced image uuid to be used in tests. '
diff --git a/neutron_tempest_plugin/scenario/test_mtu.py b/neutron_tempest_plugin/scenario/test_mtu.py
index 71a77f4..df730c6 100644
--- a/neutron_tempest_plugin/scenario/test_mtu.py
+++ b/neutron_tempest_plugin/scenario/test_mtu.py
@@ -46,11 +46,24 @@
             secgroup_id=cls.secgroup['security_group']['id'])
         cls.create_pingable_secgroup_rule(
             secgroup_id=cls.secgroup['security_group']['id'])
+        if CONF.neutron_plugin_options.default_image_is_advanced:
+            cls.use_advanced_image = False
+            cls.username = CONF.validation.image_ssh_user
+        else:
+            cls.use_advanced_image = True
+            cls.username = CONF.neutron_plugin_options.advanced_image_ssh_user
 
     def create_pingable_vm(self, net, keypair, secgroup):
+        if self.use_advanced_image:
+            flavor_ref = CONF.neutron_plugin_options.advanced_image_flavor_ref
+            image_ref = CONF.neutron_plugin_options.advanced_image_ref
+        else:
+            flavor_ref = CONF.compute.flavor_ref
+            image_ref = CONF.compute.image_ref
+
         server = self.create_server(
-            flavor_ref=CONF.neutron_plugin_options.advanced_image_flavor_ref,
-            image_ref=CONF.neutron_plugin_options.advanced_image_ref,
+            flavor_ref=flavor_ref,
+            image_ref=image_ref,
             key_name=keypair['name'],
             networks=[{'uuid': net['id']}],
             security_groups=[{'name': secgroup[
@@ -107,24 +120,22 @@
                                                 self.keypair, self.secgroup)
         server_ssh_client1 = ssh.Client(
             self.floating_ips[0]['floating_ip_address'],
-            CONF.neutron_plugin_options.advanced_image_ssh_user,
-            pkey=self.keypair['private_key'])
+            self.username, pkey=self.keypair['private_key'])
         server2, fip2 = self.create_pingable_vm(self.networks[1],
                                                 self.keypair, self.secgroup)
         server_ssh_client2 = ssh.Client(
             self.floating_ips[0]['floating_ip_address'],
-            CONF.neutron_plugin_options.advanced_image_ssh_user,
-            pkey=self.keypair['private_key'])
+            self.username, pkey=self.keypair['private_key'])
         for fip in (fip1, fip2):
             self.check_connectivity(
                 fip['floating_ip_address'],
-                CONF.neutron_plugin_options.advanced_image_ssh_user,
-                self.keypair['private_key'])
+                self.username, self.keypair['private_key'])
         return server_ssh_client1, fip1, server_ssh_client2, fip2
 
     @testtools.skipUnless(
-          CONF.neutron_plugin_options.advanced_image_ref,
-          "Advanced image is required to run this test.")
+        (CONF.neutron_plugin_options.advanced_image_ref or
+         CONF.neutron_plugin_options.default_image_is_advanced),
+        "Advanced image is required to run this test.")
     @decorators.idempotent_id('3d73ec1a-2ec6-45a9-b0f8-04a273d9d344')
     def test_connectivity_min_max_mtu(self):
         server_ssh_client, _, _, fip2 = self._create_setup()
@@ -202,24 +213,22 @@
                                                 self.keypair, self.secgroup)
         server_ssh_client1 = ssh.Client(
             self.floating_ips[0]['floating_ip_address'],
-            CONF.neutron_plugin_options.advanced_image_ssh_user,
-            pkey=self.keypair['private_key'])
+            self.username, pkey=self.keypair['private_key'])
         server2, fip2 = self.create_pingable_vm(self.networks[1],
                                                 self.keypair, self.secgroup)
         server_ssh_client2 = ssh.Client(
             self.floating_ips[0]['floating_ip_address'],
-            CONF.neutron_plugin_options.advanced_image_ssh_user,
-            pkey=self.keypair['private_key'])
+            self.username, pkey=self.keypair['private_key'])
         for fip in (fip1, fip2):
             self.check_connectivity(
                 fip['floating_ip_address'],
-                CONF.neutron_plugin_options.advanced_image_ssh_user,
-                self.keypair['private_key'])
+                self.username, self.keypair['private_key'])
         return server_ssh_client1, fip1, server_ssh_client2, fip2
 
     @testtools.skipUnless(
-          CONF.neutron_plugin_options.advanced_image_ref,
-          "Advanced image is required to run this test.")
+        (CONF.neutron_plugin_options.advanced_image_ref or
+         CONF.neutron_plugin_options.default_image_is_advanced),
+        "Advanced image is required to run this test.")
     @decorators.idempotent_id('bc470200-d8f4-4f07-b294-1b4cbaaa35b9')
     def test_connectivity_min_max_mtu(self):
         server_ssh_client, _, _, fip2 = self._create_setup()
diff --git a/neutron_tempest_plugin/scenario/test_trunk.py b/neutron_tempest_plugin/scenario/test_trunk.py
index 7ca5d29..6d855f1 100644
--- a/neutron_tempest_plugin/scenario/test_trunk.py
+++ b/neutron_tempest_plugin/scenario/test_trunk.py
@@ -244,20 +244,27 @@
             self._wait_for_trunk(vm.trunk)
             self._assert_has_ssh_connectivity(vm1.ssh_client)
 
-    @testtools.skipUnless(CONF.neutron_plugin_options.advanced_image_ref,
-                          "Advanced image is required to run this test.")
+    @testtools.skipUnless(
+        (CONF.neutron_plugin_options.advanced_image_ref or
+         CONF.neutron_plugin_options.default_image_is_advanced),
+        "Advanced image is required to run this test.")
     @decorators.idempotent_id('a8a02c9b-b453-49b5-89a2-cce7da66aafb')
     def test_subport_connectivity(self):
         vlan_tag = 10
         vlan_network = self.create_network()
         vlan_subnet = self.create_subnet(network=vlan_network, gateway=None)
 
-        vm1 = self._create_server_with_trunk_port(subport_network=vlan_network,
-                                                  segmentation_id=vlan_tag,
-                                                  use_advanced_image=True)
-        vm2 = self._create_server_with_trunk_port(subport_network=vlan_network,
-                                                  segmentation_id=vlan_tag,
-                                                  use_advanced_image=True)
+        use_advanced_image = (
+            not CONF.neutron_plugin_options.default_image_is_advanced)
+
+        vm1 = self._create_server_with_trunk_port(
+            subport_network=vlan_network,
+            segmentation_id=vlan_tag,
+            use_advanced_image=use_advanced_image)
+        vm2 = self._create_server_with_trunk_port(
+            subport_network=vlan_network,
+            segmentation_id=vlan_tag,
+            use_advanced_image=use_advanced_image)
 
         for vm in [vm1, vm2]:
             self._configure_vlan_subport(vm=vm,
@@ -278,7 +285,8 @@
             vm2.subport['fixed_ips'][0]['ip_address'])
 
     @testtools.skipUnless(
-        CONF.neutron_plugin_options.advanced_image_ref,
+        (CONF.neutron_plugin_options.advanced_image_ref or
+         CONF.neutron_plugin_options.default_image_is_advanced),
         "Advanced image is required to run this test.")
     @testtools.skipUnless(
         CONF.neutron_plugin_options.q_agent == "linuxbridge",
@@ -290,11 +298,14 @@
         vlan_subnet = self.create_subnet(vlan_network)
         self.create_router_interface(self.router['id'], vlan_subnet['id'])
 
+        use_advanced_image = (
+            not CONF.neutron_plugin_options.default_image_is_advanced)
+
         # Create servers
         trunk_network_server = self._create_server_with_trunk_port(
             subport_network=vlan_network,
             segmentation_id=vlan_tag,
-            use_advanced_image=True)
+            use_advanced_image=use_advanced_image)
         normal_network_server = self._create_server_with_network(self.network)
         vlan_network_server = self._create_server_with_network(vlan_network)