Merge "test_floating_ips_admin_actions: clean up floating ip"
diff --git a/devstack/README.rst b/devstack/README.rst
new file mode 100644
index 0000000..e605fcf
--- /dev/null
+++ b/devstack/README.rst
@@ -0,0 +1,21 @@
+====================
+Enabling in Devstack
+====================
+
+**WARNING**: the stack.sh script must be run in a disposable VM that is not
+being created automatically, see the README.md file in the "devstack"
+repository.  See contrib/vagrant to create a vagrant VM.
+
+1. Download DevStack::
+
+    git clone https://git.openstack.org/openstack-dev/devstack.git
+    cd devstack
+
+2. Add this repo as an external repository::
+
+     > cat local.conf
+     [[local|localrc]]
+     enable_plugin neutron-tempest-plugin https://git.openstack.org/openstack/neutron-tempest-plugin
+
+3. run ``stack.sh``
+
diff --git a/devstack/plugin.sh b/devstack/plugin.sh
new file mode 100644
index 0000000..a2009ea
--- /dev/null
+++ b/devstack/plugin.sh
@@ -0,0 +1,13 @@
+# install_neutron_tempest_plugin
+function install_neutron_tempest_plugin {
+    setup_dev_lib "neutron-tempest-plugin"
+}
+
+if [[ "$1" == "stack" ]]; then
+    case "$2" in
+        install)
+            echo_summary "Installing neutron-tempest-plugin"
+            install_neutron_tempest_plugin
+            ;;
+    esac
+fi
diff --git a/devstack/settings b/devstack/settings
new file mode 100644
index 0000000..614376f
--- /dev/null
+++ b/devstack/settings
@@ -0,0 +1,3 @@
+GITREPO["neutron-tempest-plugin"]=${NEUTRON_TEMPEST_REPO:-${GIT_BASE}/openstack/neutron-tempest-plugin.git}
+GITDIR["neutron-tempest-plugin"]=$DEST/neutron-tempest-plugin
+GITBRANCH["neutron-tempest-plugin"]=master
diff --git a/neutron_tempest_plugin/api/admin/test_external_network_extension.py b/neutron_tempest_plugin/api/admin/test_external_network_extension.py
index b59d10e..cd4635c 100644
--- a/neutron_tempest_plugin/api/admin/test_external_network_extension.py
+++ b/neutron_tempest_plugin/api/admin/test_external_network_extension.py
@@ -110,6 +110,47 @@
         body = self.admin_client.show_network(net_id)['network']
         self.assertTrue(body['router:external'])
 
+    @decorators.idempotent_id('beddbe9d-304c-4577-8bbe-9b61d0a449b4')
+    def test_external_conversion_on_policy_delete(self):
+        net_id = self._create_network(external=False)['id']
+        policy = self.admin_client.create_rbac_policy(
+            object_type='network', object_id=net_id,
+            action='access_as_external',
+            target_tenant='*')
+        body = self.admin_client.show_network(net_id)['network']
+        self.assertTrue(body['router:external'])
+        self.admin_client.delete_rbac_policy(policy['rbac_policy']['id'])
+        body = self.admin_client.show_network(net_id)['network']
+        self.assertFalse(body['router:external'])
+
+    @decorators.idempotent_id('fb938b8e-d1d2-4bf8-823a-1b3c79c98a25')
+    def test_external_conversion_on_one_policy_delete(self):
+        net_id = self._create_network(external=False)['id']
+        self.admin_client.create_rbac_policy(
+            object_type='network', object_id=net_id,
+            action='access_as_external',
+            target_tenant=self.admin_client.tenant_id)
+        body = self.admin_client.show_network(net_id)['network']
+        self.assertTrue(body['router:external'])
+        policy2 = self.admin_client.create_rbac_policy(
+            object_type='network', object_id=net_id,
+            action='access_as_external',
+            target_tenant=self.client2.tenant_id)
+        self.admin_client.delete_rbac_policy(policy2['rbac_policy']['id'])
+        body = self.admin_client.show_network(net_id)['network']
+        self.assertTrue(body['router:external'])
+
+    @decorators.idempotent_id('046aff1a-3962-4e2b-9a3b-93a24f255fd0')
+    def test_external_network_on_shared_policy_delete(self):
+        net_id = self._create_network(external=True)['id']
+        policy = self.admin_client.create_rbac_policy(
+            object_type='network', object_id=net_id,
+            action='access_as_shared',
+            target_tenant='*')
+        self.admin_client.delete_rbac_policy(policy['rbac_policy']['id'])
+        body = self.admin_client.show_network(net_id)['network']
+        self.assertTrue(body['router:external'])
+
     @decorators.idempotent_id('01364c50-bfb6-46c4-b44c-edc4564d61cf')
     def test_policy_allows_tenant_to_allocate_floatingip(self):
         net = self._create_network(external=False)
diff --git a/playbooks/neutron-tempest-plugin-api/run.yaml b/playbooks/neutron-tempest-plugin-api/run.yaml
index 3470bd4..12638cc 100644
--- a/playbooks/neutron-tempest-plugin-api/run.yaml
+++ b/playbooks/neutron-tempest-plugin-api/run.yaml
@@ -27,23 +27,13 @@
         cmd: |
           set -e
           set -x
-          cat << 'EOF' >>"/tmp/dg-local.conf"
-          [[local|localrc]]
-          TEMPEST_PLUGINS='/opt/stack/new/neutron-tempest-plugin'
-          EOF
-        executable: /bin/bash
-        chdir: '{{ ansible_user_dir }}/workspace'
-      environment: '{{ zuul | zuul_legacy_vars }}'
-
-    - shell:
-        cmd: |
-          set -e
-          set -x
           export PYTHONUNBUFFERED=true
           export DEVSTACK_GATE_TEMPEST=1
+          export DEVSTACK_GATE_TEMPEST_ALL_PLUGINS=1
           export DEVSTACK_GATE_NEUTRON=1
           export DEVSTACK_GATE_EXERCISES=0
           export DEVSTACK_GATE_TEMPEST_REGEX="neutron_tempest_plugin.api"
+          export DEVSTACK_LOCAL_CONFIG="enable_plugin neutron-tempest-plugin git://git.openstack.org/openstack/neutron-tempest-plugin"
           export BRANCH_OVERRIDE=default
           if [ "$BRANCH_OVERRIDE" != "default" ] ; then
               export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
diff --git a/playbooks/neutron-tempest-plugin-dvr-multinode-scenario/run.yaml b/playbooks/neutron-tempest-plugin-dvr-multinode-scenario/run.yaml
index d68747c..c2d33a9 100644
--- a/playbooks/neutron-tempest-plugin-dvr-multinode-scenario/run.yaml
+++ b/playbooks/neutron-tempest-plugin-dvr-multinode-scenario/run.yaml
@@ -27,23 +27,13 @@
         cmd: |
           set -e
           set -x
-          cat << 'EOF' >>"/tmp/dg-local.conf"
-          [[local|localrc]]
-          TEMPEST_PLUGINS='/opt/stack/new/neutron-tempest-plugin'
-          EOF
-        executable: /bin/bash
-        chdir: '{{ ansible_user_dir }}/workspace'
-      environment: '{{ zuul | zuul_legacy_vars }}'
-
-    - shell:
-        cmd: |
-          set -e
-          set -x
           export PYTHONUNBUFFERED=true
           export DEVSTACK_GATE_TEMPEST=1
+          export DEVSTACK_GATE_TEMPEST_ALL_PLUGINS=1
           export DEVSTACK_GATE_NEUTRON=1
           export DEVSTACK_GATE_CONFIGDRIVE=0
           export DEVSTACK_GATE_TEMPEST_REGEX="(neutron_tempest_plugin.scenario)"
+          export DEVSTACK_LOCAL_CONFIG="enable_plugin neutron-tempest-plugin git://git.openstack.org/openstack/neutron-tempest-plugin"
           export TEMPEST_CONCURRENCY=2
           # Test DVR works multinode
           export DEVSTACK_GATE_NEUTRON_DVR=1
diff --git a/playbooks/neutron-tempest-plugin-scenario-linuxbridge/run.yaml b/playbooks/neutron-tempest-plugin-scenario-linuxbridge/run.yaml
index f2be130..65e8b12 100644
--- a/playbooks/neutron-tempest-plugin-scenario-linuxbridge/run.yaml
+++ b/playbooks/neutron-tempest-plugin-scenario-linuxbridge/run.yaml
@@ -31,7 +31,6 @@
           [[local|localrc]]
           Q_AGENT=linuxbridge
           PHYSICAL_NETWORK=default
-          TEMPEST_PLUGINS='/opt/stack/new/neutron-tempest-plugin'
 
           EOF
         executable: /bin/bash
@@ -44,9 +43,11 @@
           set -x
           export PYTHONUNBUFFERED=true
           export DEVSTACK_GATE_TEMPEST=1
+          export DEVSTACK_GATE_TEMPEST_ALL_PLUGINS=1
           export DEVSTACK_GATE_NEUTRON=1
           export DEVSTACK_GATE_EXERCISES=0
           export DEVSTACK_GATE_TEMPEST_REGEX="(neutron_tempest_plugin.scenario)"
+          export DEVSTACK_LOCAL_CONFIG="enable_plugin neutron-tempest-plugin git://git.openstack.org/openstack/neutron-tempest-plugin"
           export BRANCH_OVERRIDE=default
           if [ "$BRANCH_OVERRIDE" != "default" ] ; then
               export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE