[openstack-dev] Manila client (v1.1.0) region support

2015-04-30 Thread Joe Meadows
Hi,

I work for Hitachi Data Systems (HDS) and am developing Manila support for our 
HNAS line of NAS server.  The HNAS server has an internal REST server so I am 
implementing the Manila API natively on the server.  For various reasons this 
is a better fit than the standard Python driver implementation.

This implementation means that each HNAS server is its own endpoint so it gets 
added to Keystone as an endpoint using the Manila service Id.  I am using 
regions to distinguish between multiple HNAS servers or other Manila endpoints. 
 Therefore, when I add each HNAS endpoint I give that endpoint a unique region 
name.

Initially this worked exactly as expected when using a Manila client that I 
installed from GitHub following the instructions at 
https://urldefense.proofpoint.com/v2/url?u=http-3A__netapp.github.io_openstack_2014_08_15_manila-2Ddevstack_d=AwIGaQc=DZ-EF4pZfxGSU6MfABwx0gr=zHvLuN-cA8dJrDKv-7gpbBCgBAKPaAzJfG6sccaIdHHNpjwlcFjsdjPhFr9XPGnVm=V37u0qx0ILzWPG7XsUs5_D2uR6KRjHYV2vSQ20UQnEAs=gagpiobFCwxAaoXUTt9lRA6-g4vNiC_VDR-TQDX8IR0e=
 .  
https://urldefense.proofpoint.com/v2/url?u=http-3A__netapp.github.io_openstack_2014_08_15_manila-2Ddevstack_d=AwIGaQc=DZ-EF4pZfxGSU6MfABwx0gr=zHvLuN-cA8dJrDKv-7gpbBCgBAKPaAzJfG6sccaIdHHNpjwlcFjsdjPhFr9XPGnVm=V37u0qx0ILzWPG7XsUs5_D2uR6KRjHYV2vSQ20UQnEAs=gagpiobFCwxAaoXUTt9lRA6-g4vNiC_VDR-TQDX8IR0e=
  For example, I could do 'manila --os-region-name HNAS1 list' and the request 
would route to the correct endpoint (i.e. HNAS server).  This Manila client 
shows version 1.0.2.

Recently I tried this setup on another developer's OpenStack installation and 
the region name was ignored, though this client also claimed to be version 
1.0.2.  Next I used pip to install python-manilaclient onto another machine, 
version 1.1.0, and again the region is ignored.

I stepped through the client code and found that when v1/client.py::__init__() 
searches for an endpoint it always takes the first one, never checking the 
region.

I made a small change which makes the client behave how I'd like it to.  If 
region is not specified it retains the original behavior of returning the first 
endpoint.  If a region is specified then it will return the first endpoint with 
a matching region.  The patch is below, my changes are between the #JAMJAM 
comments.

--- a/client.py2015-04-22 16:05:10.0 -0700
+++ b/client.py2015-04-22 16:00:56.0 -0700
@@ -142,10 +142,21 @@
 service_type)

 if service_type in catalog:
-for e_type, endpoint in catalog.get(service_type)[0].items():
-if str(e_type).lower() == str(endpoint_type).lower():
-service_catalog_url = endpoint
-break
+# JAMJAM START
+srvCat=catalog.get(service_type)
+for catalogEntry in srvCat:
+if region_name != :
+region=catalogEntry.get(region)
+if region != region_name:
+continue;
+#for e_type, endpoint in 
catalog.get(service_type)[0].items():
+# JAMJAM END
+for e_type, endpoint in catalogEntry.items():
+if str(e_type).lower() == str(endpoint_type).lower():
+service_catalog_url = endpoint
+break
+if service_catalog_url:
+break

 if not service_catalog_url:
 raise RuntimeError(Could not find Manila endpoint in catalog)

So now, the obvious questions are; Is there already a way to specify a region 
that the Manila client will honor?  Is this patch fixing something?  Is this 
not a valid use of regions for Manila?

Many thanks in advance
 Joe Meadows
 HNAS Engineering
 Hitachi Data Systems

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] Manila client (v1.1.0) region support

2015-04-30 Thread Joe Meadows
Thanks Valeriy, I filed this defect: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.launchpad.net_manila_-2Bbug_1450613d=AwIGaQc=DZ-EF4pZfxGSU6MfABwx0gr=zHvLuN-cA8dJrDKv-7gpbBCgBAKPaAzJfG6sccaIdHHNpjwlcFjsdjPhFr9XPGnVm=-5mRhr6zsbDKoOY59zZmnU58ZQwyrD4158jdisZVyYks=VFJIw949FNR9HwVoo8RtQ3v3awQmsZXd7-idSS2Ndbge=
 

Best regards,
Joe

On 04/30/2015 12:22 PM, Valeriy Ponomaryov wrote:
Hello, Joe

It is  bug, region_name is not used as should be. Feel free to file a bug for 
it.

Kind Regards
Valeriy Ponomaryov

On Thu, Apr 30, 2015 at 8:23 PM, Joe Meadows 
joe.mead...@hds.commailto:joe.mead...@hds.com wrote:
Hi,

I work for Hitachi Data Systems (HDS) and am developing Manila support for our 
HNAS line of NAS server.  The HNAS server has an internal REST server so I am 
implementing the Manila API natively on the server.  For various reasons this 
is a better fit than the standard Python driver implementation.

This implementation means that each HNAS server is its own endpoint so it gets 
added to Keystone as an endpoint using the Manila service Id.  I am using 
regions to distinguish between multiple HNAS servers or other Manila endpoints. 
 Therefore, when I add each HNAS endpoint I give that endpoint a unique region 
name.

Initially this worked exactly as expected when using a Manila client that I 
installed from GitHub following the instructions at 
https://urldefense.proofpoint.com/v2/url?u=http-3A__netapp.github.io_openstack_2014_08_15_manila-2Ddevstack_d=AwIGaQc=DZ-EF4pZfxGSU6MfABwx0gr=zHvLuN-cA8dJrDKv-7gpbBCgBAKPaAzJfG6sccaIdHHNpjwlcFjsdjPhFr9XPGnVm=-5mRhr6zsbDKoOY59zZmnU58ZQwyrD4158jdisZVyYks=bF9k5n0h1wY3sADri4vbJ2h12CcVzrCE0JYAX236xEMe=
 
https://urldefense.proofpoint.com/v2/url?u=http-3A__netapp.github.io_openstack_2014_08_15_manila-2Ddevstack_d=AwMGaQc=DZ-EF4pZfxGSU6MfABwx0gr=zHvLuN-cA8dJrDKv-7gpbBCgBAKPaAzJfG6sccaIdHHNpjwlcFjsdjPhFr9XPGnVm=V37u0qx0ILzWPG7XsUs5_D2uR6KRjHYV2vSQ20UQnEAs=gagpiobFCwxAaoXUTt9lRA6-g4vNiC_VDR-TQDX8IR0e=.
  
https://urldefense.proofpoint.com/v2/url?u=http-3A__netapp.github.io_openstack_2014_08_15_manila-2Ddevstack_d=AwMGaQc=DZ-EF4pZfxGSU6MfABwx0gr=zHvLuN-cA8dJrDKv-7gpbBCgBAKPaAzJfG6sccaIdHHNpjwlcFjsdjPhFr9XPGnVm=V37u0qx0ILzWPG7XsUs5_D2uR6KRjHYV2vSQ20UQnEAs=gagpiobFCwxAaoXUTt9lRA6-g4vNiC_VDR-TQDX8IR0e=
 For example, I could do 'manila --os-region-name HNAS1 list' and the request 
would route to the correct endpoint (i.e. HNAS server).  This Manila client 
shows version 1.0.2.

Recently I tried this setup on another developer's OpenStack installation and 
the region name was ignored, though this client also claimed to be version 
1.0.2.  Next I used pip to install python-manilaclient onto another machine, 
version 1.1.0, and again the region is ignored.

I stepped through the client code and found that when v1/client.py::__init__() 
searches for an endpoint it always takes the first one, never checking the 
region.

I made a small change which makes the client behave how I'd like it to.  If 
region is not specified it retains the original behavior of returning the first 
endpoint.  If a region is specified then it will return the first endpoint with 
a matching region.  The patch is below, my changes are between the #JAMJAM 
comments.

--- a/client.py2015-04-22 16:05:10.0 -0700
+++ b/client.py2015-04-22 16:00:56.0 -0700
@@ -142,10 +142,21 @@
 service_type)

 if service_type in catalog:
-for e_type, endpoint in catalog.get(service_type)[0].items():
-if str(e_type).lower() == str(endpoint_type).lower():
-service_catalog_url = endpoint
-break
+# JAMJAM START
+srvCat=catalog.get(service_type)
+for catalogEntry in srvCat:
+if region_name != :
+region=catalogEntry.get(region)
+if region != region_name:
+continue;
+#for e_type, endpoint in 
catalog.get(service_type)[0].items():
+# JAMJAM END
+for e_type, endpoint in catalogEntry.items():
+if str(e_type).lower() == str(endpoint_type).lower():
+service_catalog_url = endpoint
+break
+if service_catalog_url:
+break

 if not service_catalog_url:
 raise RuntimeError(Could not find Manila endpoint in catalog)

So now, the obvious questions are; Is there already a way to specify a region 
that the Manila client will honor?  Is this patch fixing something?  Is this 
not a valid use of regions for Manila?

Many thanks in advance
 Joe Meadows
 HNAS Engineering
 Hitachi Data Systems


__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: 
openstack-dev-requ