From 692bd3ea03f91e6e745f6f457739aca73b8f6765 Mon Sep 17 00:00:00 2001
From: Valeriy Ponomaryov <vponomaryov@mirantis.com>
Date: Thu, 7 Apr 2016 12:13:46 +0300
Subject: [PATCH] Fix creation of Neutron network in Devstack

Manila Devstack plugin creates admin network for Generic driver
using env var "TENANT_ID". And after its removal in Devstack
Manila fails to create Neutron network and fails on migration
tests that use results of this network creation.

Make Manila get ID of required project calling 'openstack client'
to avoid such error.

Change-Id: I43b18b2d2f2e69a150cd3e29ac84426550a6e40d
Closes-Bug: #1566826
---
 devstack/plugin.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/devstack/plugin.sh b/devstack/plugin.sh
index 490ed76973..4c0e1a05ab 100755
--- a/devstack/plugin.sh
+++ b/devstack/plugin.sh
@@ -296,8 +296,9 @@ function create_service_share_servers {
             else
                 if is_service_enabled neutron; then
                     if [ $created_admin_network == false ]; then
-                        admin_net_id=$(neutron net-create --tenant-id $TENANT_ID admin_net | grep ' id ' | get_field 2)
-                        admin_subnet_id=$(neutron subnet-create --tenant-id $TENANT_ID --ip_version 4 --no-gateway --name admin_subnet --subnetpool None $admin_net_id $FIXED_RANGE | grep ' id ' | get_field 2)
+                        project_id=$(openstack project show $SERVICE_PROJECT_NAME -c id -f value)
+                        admin_net_id=$(neutron net-create --tenant-id $project_id admin_net | grep ' id ' | get_field 2)
+                        admin_subnet_id=$(neutron subnet-create --tenant-id $project_id --ip_version 4 --no-gateway --name admin_subnet --subnetpool None $admin_net_id $FIXED_RANGE | grep ' id ' | get_field 2)
                         created_admin_network=true
                     fi
                     iniset $MANILA_CONF $BE admin_network_id $admin_net_id