Re: [openstack-dev] [nova] python-novaclient region setting

2016-02-25 Thread Xav Paice
On 24 February 2016 at 22:18, Andrey Kurilin  wrote:

> Hi!
>
> >didn't work for me in this particular case because of a bug in novaclient
>
> Can you tell more about bug in novaclient or share a bug report?
>
>
Sure - https://bugs.launchpad.net/python-novaclient/+bug/1494116


> On Wed, Feb 24, 2016 at 8:42 AM, Xav Paice  wrote:
>
>> fwiw, the second part of Monty's message is in the docs, sans region - it
>> would be a fairly swift change to add that and I'll probably submit a
>> gerrit for it soon.
>>
>> Regards os_client_config,
>> http://docs.openstack.org/developer/os-client-config/ is great.
>> Unfortunately it didn't work for me in this particular case because of a
>> bug in novaclient, but that's beside the point - os_client_config is doing
>> exactly the right thing and I'm really happy with that approach in most
>> cases (and am changing some of our tooling to reflect that).
>>
>> On 24 February 2016 at 05:05, Matt Riedemann 
>> wrote:
>>
>>>
>>>
>>> On 2/22/2016 8:02 AM, Monty Taylor wrote:
>>>
 On 02/21/2016 11:40 PM, Andrey Kurilin wrote:

> Hi!
> `novaclient.client.Client` entry-point supports almost the same
> arguments as `novaclient.v2.client.Client`. The difference is only in
> api_version, so you can set up region via `novaclient.client.Client` in
> the same way as `novaclient.v2.client.Client`.
>

 The easiest way to get a properly constructed nova Client is with
 os-client-config:

 import os_client_config

 OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
 OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
 OS_PASSWORD="REDACTED"
 OS_AUTH_URL="http://auth.vexxhost.net;
 OS_REGION_NAME="ca-ymq-1"

 client = os_client_config.make_client(
  'compute',
  auth_url=OS_AUTH_URL, username=OS_USERNAME,
  password=OS_PASSWORD, project_name=OS_PROJECT_NAME,
  region_name=OS_REGION_NAME)

 The upside is that the constructor interface is the same for all of the
 rest of the client libs too (just change the first argument) - and it
 will also read in OS_ env vars or named clouds from clouds.yaml if you
 have them set.

 (The 'simplest' way is to put your auth and region information into a
 clouds.yaml file like this:


 http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations


 Such as:

 # ~/.config/openstack/clouds.yaml
 clouds:
vexxhost:
   profile: vexxhost
   auth:
 project_name: d8af8a8f-a573-48e6-898a-af333b970a2d
 username: 0b8c435b-cc4d-4e05-8a47-a2ada0539af1
 password: REDACTED
   region_name: ca-ymq-1


 And do:

 client = os_client_config.make_client('compute', cloud='vexxhost')


 If you don't want to do that for some reason but you'd like to construct
 a novaclient Client object by hand:


 from keystoneauth1 import loading
 from keystoneauth1 import session as ksa_session
 from novaclient import client as nova_client

 OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
 OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
 OS_PASSWORD="REDACTED"
 OS_AUTH_URL="http://auth.vexxhost.net;
 OS_REGION_NAME="ca-ymq-1"

 # Get the auth loader for the password auth plugin
 loader = loading.get_plugin_loader('password')
 # Construct the auth plugin
 auth_plugin = loader.load_from_options(
  auth_url=OS_AUTH_URL, username=OS_USERNAME, password=OS_PASSWORD,
  project_name=OS_PROJECT_NAME)

 # Construct a keystone session
 # Other arguments that are potentially useful here are:
 #  verify - bool, whether or not to verify SSL connection validity
 #  cert - SSL cert information
 #  timout - time in seconds to use for connection level TCP timeouts
 session = ksa_session.Session(auth_plugin)

 # Now make the client
 # Other arguments you may be interested in:
 #  service_name - if you need to specify a service name for finding the
 # right service in the catalog
 #  service_type - if the cloud in question has given a different
 # service type (should be 'compute' for nova - but
 # novaclient sets it, so it's safe to omit in most cases
 #  endpoint_override - if you want to tell it to use a different URL
 #  than what the keystone catalog returns
 #  endpoint_type - if you need to specify admin or internal
 #  endpoints rather than the default 'public'
 #  Note that in glance and barbican, this key is called
 #  'interface'
 client = nova_client.Client(
  version='2.0', # or set the specific microversion you want
  

Re: [openstack-dev] [nova] python-novaclient region setting

2016-02-24 Thread Jamie Lennox
On 23 February 2016 at 01:02, Monty Taylor  wrote:

> On 02/21/2016 11:40 PM, Andrey Kurilin wrote:
>
>> Hi!
>> `novaclient.client.Client` entry-point supports almost the same
>> arguments as `novaclient.v2.client.Client`. The difference is only in
>> api_version, so you can set up region via `novaclient.client.Client` in
>> the same way as `novaclient.v2.client.Client`.
>>
>
> The easiest way to get a properly constructed nova Client is with
> os-client-config:
>
> import os_client_config
>
> OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
> OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
> OS_PASSWORD="REDACTED"
> OS_AUTH_URL="http://auth.vexxhost.net;
> OS_REGION_NAME="ca-ymq-1"
>
> client = os_client_config.make_client(
> 'compute',
> auth_url=OS_AUTH_URL, username=OS_USERNAME,
> password=OS_PASSWORD, project_name=OS_PROJECT_NAME,
> region_name=OS_REGION_NAME)
>
> The upside is that the constructor interface is the same for all of the
> rest of the client libs too (just change the first argument) - and it will
> also read in OS_ env vars or named clouds from clouds.yaml if you have them
> set.
>
> (The 'simplest' way is to put your auth and region information into a
> clouds.yaml file like this:
>
>
> http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations
>
> Such as:
>
> # ~/.config/openstack/clouds.yaml
> clouds:
>   vexxhost:
>  profile: vexxhost
>  auth:
>project_name: d8af8a8f-a573-48e6-898a-af333b970a2d
>username: 0b8c435b-cc4d-4e05-8a47-a2ada0539af1
>password: REDACTED
>  region_name: ca-ymq-1
>
>
> And do:
>
> client = os_client_config.make_client('compute', cloud='vexxhost')
>
>
> If you don't want to do that for some reason but you'd like to construct a
> novaclient Client object by hand:
>
>
> from keystoneauth1 import loading
> from keystoneauth1 import session as ksa_session
> from novaclient import client as nova_client
>
> OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
> OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
> OS_PASSWORD="REDACTED"
> OS_AUTH_URL="http://auth.vexxhost.net;
> OS_REGION_NAME="ca-ymq-1"
>
> # Get the auth loader for the password auth plugin
> loader = loading.get_plugin_loader('password')
> # Construct the auth plugin
> auth_plugin = loader.load_from_options(
> auth_url=OS_AUTH_URL, username=OS_USERNAME, password=OS_PASSWORD,
> project_name=OS_PROJECT_NAME)
>

note that loaders here are generally things like load from config file, or
load from argparse arguments. If you are doing everything in a script like
this you would probably just use the keystoneauth1.identity.Password like

from keystoneauth1 import identity

auth_plugin = identity.Password(auth_url=)



> # Construct a keystone session
> # Other arguments that are potentially useful here are:
> #  verify - bool, whether or not to verify SSL connection validity
> #  cert - SSL cert information
> #  timout - time in seconds to use for connection level TCP timeouts
> session = ksa_session.Session(auth_plugin)
>
> # Now make the client
> # Other arguments you may be interested in:
> #  service_name - if you need to specify a service name for finding the
> # right service in the catalog
> #  service_type - if the cloud in question has given a different
> # service type (should be 'compute' for nova - but
> # novaclient sets it, so it's safe to omit in most cases
> #  endpoint_override - if you want to tell it to use a different URL
> #  than what the keystone catalog returns
> #  endpoint_type - if you need to specify admin or internal
> #  endpoints rather than the default 'public'
> #  Note that in glance and barbican, this key is called
> #  'interface'
> client = nova_client.Client(
> version='2.0', # or set the specific microversion you want
> session=session, region_name=OS_REGION_NAME)
>
> It might be clear why I prefer the os_client_config factory function
> instead - but what I prefer and what you prefer might not be the same
> thing. :)
>
> On Mon, Feb 22, 2016 at 6:11 AM, Xav Paice > > wrote:
>>
>> Hi,
>>
>> In http://docs.openstack.org/developer/python-novaclient/api.html
>> it's got some pretty clear instructions not to
>> use novaclient.v2.client.Client but I can't see another way to
>> specify the region - there's more than one in my installation, and
>> no param for region in novaclient.client.Client
>>
>> Shall I hunt down/write a blueprint for that?
>>
>>
>> __
>> OpenStack Development Mailing List (not for usage questions)
>> Unsubscribe:
>> openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
>> > 

Re: [openstack-dev] [nova] python-novaclient region setting

2016-02-24 Thread Andrey Kurilin
Hi!

>didn't work for me in this particular case because of a bug in novaclient

Can you tell more about bug in novaclient or share a bug report?

On Wed, Feb 24, 2016 at 8:42 AM, Xav Paice  wrote:

> fwiw, the second part of Monty's message is in the docs, sans region - it
> would be a fairly swift change to add that and I'll probably submit a
> gerrit for it soon.
>
> Regards os_client_config,
> http://docs.openstack.org/developer/os-client-config/ is great.
> Unfortunately it didn't work for me in this particular case because of a
> bug in novaclient, but that's beside the point - os_client_config is doing
> exactly the right thing and I'm really happy with that approach in most
> cases (and am changing some of our tooling to reflect that).
>
> On 24 February 2016 at 05:05, Matt Riedemann 
> wrote:
>
>>
>>
>> On 2/22/2016 8:02 AM, Monty Taylor wrote:
>>
>>> On 02/21/2016 11:40 PM, Andrey Kurilin wrote:
>>>
 Hi!
 `novaclient.client.Client` entry-point supports almost the same
 arguments as `novaclient.v2.client.Client`. The difference is only in
 api_version, so you can set up region via `novaclient.client.Client` in
 the same way as `novaclient.v2.client.Client`.

>>>
>>> The easiest way to get a properly constructed nova Client is with
>>> os-client-config:
>>>
>>> import os_client_config
>>>
>>> OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
>>> OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
>>> OS_PASSWORD="REDACTED"
>>> OS_AUTH_URL="http://auth.vexxhost.net;
>>> OS_REGION_NAME="ca-ymq-1"
>>>
>>> client = os_client_config.make_client(
>>>  'compute',
>>>  auth_url=OS_AUTH_URL, username=OS_USERNAME,
>>>  password=OS_PASSWORD, project_name=OS_PROJECT_NAME,
>>>  region_name=OS_REGION_NAME)
>>>
>>> The upside is that the constructor interface is the same for all of the
>>> rest of the client libs too (just change the first argument) - and it
>>> will also read in OS_ env vars or named clouds from clouds.yaml if you
>>> have them set.
>>>
>>> (The 'simplest' way is to put your auth and region information into a
>>> clouds.yaml file like this:
>>>
>>>
>>> http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations
>>>
>>>
>>> Such as:
>>>
>>> # ~/.config/openstack/clouds.yaml
>>> clouds:
>>>vexxhost:
>>>   profile: vexxhost
>>>   auth:
>>> project_name: d8af8a8f-a573-48e6-898a-af333b970a2d
>>> username: 0b8c435b-cc4d-4e05-8a47-a2ada0539af1
>>> password: REDACTED
>>>   region_name: ca-ymq-1
>>>
>>>
>>> And do:
>>>
>>> client = os_client_config.make_client('compute', cloud='vexxhost')
>>>
>>>
>>> If you don't want to do that for some reason but you'd like to construct
>>> a novaclient Client object by hand:
>>>
>>>
>>> from keystoneauth1 import loading
>>> from keystoneauth1 import session as ksa_session
>>> from novaclient import client as nova_client
>>>
>>> OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
>>> OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
>>> OS_PASSWORD="REDACTED"
>>> OS_AUTH_URL="http://auth.vexxhost.net;
>>> OS_REGION_NAME="ca-ymq-1"
>>>
>>> # Get the auth loader for the password auth plugin
>>> loader = loading.get_plugin_loader('password')
>>> # Construct the auth plugin
>>> auth_plugin = loader.load_from_options(
>>>  auth_url=OS_AUTH_URL, username=OS_USERNAME, password=OS_PASSWORD,
>>>  project_name=OS_PROJECT_NAME)
>>>
>>> # Construct a keystone session
>>> # Other arguments that are potentially useful here are:
>>> #  verify - bool, whether or not to verify SSL connection validity
>>> #  cert - SSL cert information
>>> #  timout - time in seconds to use for connection level TCP timeouts
>>> session = ksa_session.Session(auth_plugin)
>>>
>>> # Now make the client
>>> # Other arguments you may be interested in:
>>> #  service_name - if you need to specify a service name for finding the
>>> # right service in the catalog
>>> #  service_type - if the cloud in question has given a different
>>> # service type (should be 'compute' for nova - but
>>> # novaclient sets it, so it's safe to omit in most cases
>>> #  endpoint_override - if you want to tell it to use a different URL
>>> #  than what the keystone catalog returns
>>> #  endpoint_type - if you need to specify admin or internal
>>> #  endpoints rather than the default 'public'
>>> #  Note that in glance and barbican, this key is called
>>> #  'interface'
>>> client = nova_client.Client(
>>>  version='2.0', # or set the specific microversion you want
>>>  session=session, region_name=OS_REGION_NAME)
>>>
>>> It might be clear why I prefer the os_client_config factory function
>>> instead - but what I prefer and what you prefer might not be the same
>>> thing. :)
>>>
>>> On Mon, Feb 22, 2016 at 6:11 AM, Xav Paice 

Re: [openstack-dev] [nova] python-novaclient region setting

2016-02-23 Thread Xav Paice
fwiw, the second part of Monty's message is in the docs, sans region - it
would be a fairly swift change to add that and I'll probably submit a
gerrit for it soon.

Regards os_client_config,
http://docs.openstack.org/developer/os-client-config/ is great.
Unfortunately it didn't work for me in this particular case because of a
bug in novaclient, but that's beside the point - os_client_config is doing
exactly the right thing and I'm really happy with that approach in most
cases (and am changing some of our tooling to reflect that).

On 24 February 2016 at 05:05, Matt Riedemann 
wrote:

>
>
> On 2/22/2016 8:02 AM, Monty Taylor wrote:
>
>> On 02/21/2016 11:40 PM, Andrey Kurilin wrote:
>>
>>> Hi!
>>> `novaclient.client.Client` entry-point supports almost the same
>>> arguments as `novaclient.v2.client.Client`. The difference is only in
>>> api_version, so you can set up region via `novaclient.client.Client` in
>>> the same way as `novaclient.v2.client.Client`.
>>>
>>
>> The easiest way to get a properly constructed nova Client is with
>> os-client-config:
>>
>> import os_client_config
>>
>> OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
>> OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
>> OS_PASSWORD="REDACTED"
>> OS_AUTH_URL="http://auth.vexxhost.net;
>> OS_REGION_NAME="ca-ymq-1"
>>
>> client = os_client_config.make_client(
>>  'compute',
>>  auth_url=OS_AUTH_URL, username=OS_USERNAME,
>>  password=OS_PASSWORD, project_name=OS_PROJECT_NAME,
>>  region_name=OS_REGION_NAME)
>>
>> The upside is that the constructor interface is the same for all of the
>> rest of the client libs too (just change the first argument) - and it
>> will also read in OS_ env vars or named clouds from clouds.yaml if you
>> have them set.
>>
>> (The 'simplest' way is to put your auth and region information into a
>> clouds.yaml file like this:
>>
>>
>> http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations
>>
>>
>> Such as:
>>
>> # ~/.config/openstack/clouds.yaml
>> clouds:
>>vexxhost:
>>   profile: vexxhost
>>   auth:
>> project_name: d8af8a8f-a573-48e6-898a-af333b970a2d
>> username: 0b8c435b-cc4d-4e05-8a47-a2ada0539af1
>> password: REDACTED
>>   region_name: ca-ymq-1
>>
>>
>> And do:
>>
>> client = os_client_config.make_client('compute', cloud='vexxhost')
>>
>>
>> If you don't want to do that for some reason but you'd like to construct
>> a novaclient Client object by hand:
>>
>>
>> from keystoneauth1 import loading
>> from keystoneauth1 import session as ksa_session
>> from novaclient import client as nova_client
>>
>> OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
>> OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
>> OS_PASSWORD="REDACTED"
>> OS_AUTH_URL="http://auth.vexxhost.net;
>> OS_REGION_NAME="ca-ymq-1"
>>
>> # Get the auth loader for the password auth plugin
>> loader = loading.get_plugin_loader('password')
>> # Construct the auth plugin
>> auth_plugin = loader.load_from_options(
>>  auth_url=OS_AUTH_URL, username=OS_USERNAME, password=OS_PASSWORD,
>>  project_name=OS_PROJECT_NAME)
>>
>> # Construct a keystone session
>> # Other arguments that are potentially useful here are:
>> #  verify - bool, whether or not to verify SSL connection validity
>> #  cert - SSL cert information
>> #  timout - time in seconds to use for connection level TCP timeouts
>> session = ksa_session.Session(auth_plugin)
>>
>> # Now make the client
>> # Other arguments you may be interested in:
>> #  service_name - if you need to specify a service name for finding the
>> # right service in the catalog
>> #  service_type - if the cloud in question has given a different
>> # service type (should be 'compute' for nova - but
>> # novaclient sets it, so it's safe to omit in most cases
>> #  endpoint_override - if you want to tell it to use a different URL
>> #  than what the keystone catalog returns
>> #  endpoint_type - if you need to specify admin or internal
>> #  endpoints rather than the default 'public'
>> #  Note that in glance and barbican, this key is called
>> #  'interface'
>> client = nova_client.Client(
>>  version='2.0', # or set the specific microversion you want
>>  session=session, region_name=OS_REGION_NAME)
>>
>> It might be clear why I prefer the os_client_config factory function
>> instead - but what I prefer and what you prefer might not be the same
>> thing. :)
>>
>> On Mon, Feb 22, 2016 at 6:11 AM, Xav Paice >> > wrote:
>>>
>>> Hi,
>>>
>>> In http://docs.openstack.org/developer/python-novaclient/api.html
>>> it's got some pretty clear instructions not to
>>> use novaclient.v2.client.Client but I can't see another way to
>>> specify the region - there's more than one in my installation, and
>>> no param 

Re: [openstack-dev] [nova] python-novaclient region setting

2016-02-23 Thread Matt Riedemann



On 2/22/2016 8:02 AM, Monty Taylor wrote:

On 02/21/2016 11:40 PM, Andrey Kurilin wrote:

Hi!
`novaclient.client.Client` entry-point supports almost the same
arguments as `novaclient.v2.client.Client`. The difference is only in
api_version, so you can set up region via `novaclient.client.Client` in
the same way as `novaclient.v2.client.Client`.


The easiest way to get a properly constructed nova Client is with
os-client-config:

import os_client_config

OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
OS_PASSWORD="REDACTED"
OS_AUTH_URL="http://auth.vexxhost.net;
OS_REGION_NAME="ca-ymq-1"

client = os_client_config.make_client(
 'compute',
 auth_url=OS_AUTH_URL, username=OS_USERNAME,
 password=OS_PASSWORD, project_name=OS_PROJECT_NAME,
 region_name=OS_REGION_NAME)

The upside is that the constructor interface is the same for all of the
rest of the client libs too (just change the first argument) - and it
will also read in OS_ env vars or named clouds from clouds.yaml if you
have them set.

(The 'simplest' way is to put your auth and region information into a
clouds.yaml file like this:

http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations


Such as:

# ~/.config/openstack/clouds.yaml
clouds:
   vexxhost:
  profile: vexxhost
  auth:
project_name: d8af8a8f-a573-48e6-898a-af333b970a2d
username: 0b8c435b-cc4d-4e05-8a47-a2ada0539af1
password: REDACTED
  region_name: ca-ymq-1


And do:

client = os_client_config.make_client('compute', cloud='vexxhost')


If you don't want to do that for some reason but you'd like to construct
a novaclient Client object by hand:


from keystoneauth1 import loading
from keystoneauth1 import session as ksa_session
from novaclient import client as nova_client

OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
OS_PASSWORD="REDACTED"
OS_AUTH_URL="http://auth.vexxhost.net;
OS_REGION_NAME="ca-ymq-1"

# Get the auth loader for the password auth plugin
loader = loading.get_plugin_loader('password')
# Construct the auth plugin
auth_plugin = loader.load_from_options(
 auth_url=OS_AUTH_URL, username=OS_USERNAME, password=OS_PASSWORD,
 project_name=OS_PROJECT_NAME)

# Construct a keystone session
# Other arguments that are potentially useful here are:
#  verify - bool, whether or not to verify SSL connection validity
#  cert - SSL cert information
#  timout - time in seconds to use for connection level TCP timeouts
session = ksa_session.Session(auth_plugin)

# Now make the client
# Other arguments you may be interested in:
#  service_name - if you need to specify a service name for finding the
# right service in the catalog
#  service_type - if the cloud in question has given a different
# service type (should be 'compute' for nova - but
# novaclient sets it, so it's safe to omit in most cases
#  endpoint_override - if you want to tell it to use a different URL
#  than what the keystone catalog returns
#  endpoint_type - if you need to specify admin or internal
#  endpoints rather than the default 'public'
#  Note that in glance and barbican, this key is called
#  'interface'
client = nova_client.Client(
 version='2.0', # or set the specific microversion you want
 session=session, region_name=OS_REGION_NAME)

It might be clear why I prefer the os_client_config factory function
instead - but what I prefer and what you prefer might not be the same
thing. :)


On Mon, Feb 22, 2016 at 6:11 AM, Xav Paice > wrote:

Hi,

In http://docs.openstack.org/developer/python-novaclient/api.html
it's got some pretty clear instructions not to
use novaclient.v2.client.Client but I can't see another way to
specify the region - there's more than one in my installation, and
no param for region in novaclient.client.Client

Shall I hunt down/write a blueprint for that?


__

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




--
Best regards,
Andrey Kurilin.


__

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




__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: 

Re: [openstack-dev] [nova] python-novaclient region setting

2016-02-22 Thread Xav Paice
That's just what I was after - thanks for that!

On 23 February 2016 at 03:02, Monty Taylor  wrote:

> On 02/21/2016 11:40 PM, Andrey Kurilin wrote:
>
>> Hi!
>> `novaclient.client.Client` entry-point supports almost the same
>> arguments as `novaclient.v2.client.Client`. The difference is only in
>> api_version, so you can set up region via `novaclient.client.Client` in
>> the same way as `novaclient.v2.client.Client`.
>>
>
> The easiest way to get a properly constructed nova Client is with
> os-client-config:
>
> import os_client_config
>
> OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
> OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
> OS_PASSWORD="REDACTED"
> OS_AUTH_URL="http://auth.vexxhost.net;
> OS_REGION_NAME="ca-ymq-1"
>
> client = os_client_config.make_client(
> 'compute',
> auth_url=OS_AUTH_URL, username=OS_USERNAME,
> password=OS_PASSWORD, project_name=OS_PROJECT_NAME,
> region_name=OS_REGION_NAME)
>
> The upside is that the constructor interface is the same for all of the
> rest of the client libs too (just change the first argument) - and it will
> also read in OS_ env vars or named clouds from clouds.yaml if you have them
> set.
>
> (The 'simplest' way is to put your auth and region information into a
> clouds.yaml file like this:
>
>
> http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations
>
> Such as:
>
> # ~/.config/openstack/clouds.yaml
> clouds:
>   vexxhost:
>  profile: vexxhost
>  auth:
>project_name: d8af8a8f-a573-48e6-898a-af333b970a2d
>username: 0b8c435b-cc4d-4e05-8a47-a2ada0539af1
>password: REDACTED
>  region_name: ca-ymq-1
>
>
> And do:
>
> client = os_client_config.make_client('compute', cloud='vexxhost')
>
>
> If you don't want to do that for some reason but you'd like to construct a
> novaclient Client object by hand:
>
>
> from keystoneauth1 import loading
> from keystoneauth1 import session as ksa_session
> from novaclient import client as nova_client
>
> OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
> OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
> OS_PASSWORD="REDACTED"
> OS_AUTH_URL="http://auth.vexxhost.net;
> OS_REGION_NAME="ca-ymq-1"
>
> # Get the auth loader for the password auth plugin
> loader = loading.get_plugin_loader('password')
> # Construct the auth plugin
> auth_plugin = loader.load_from_options(
> auth_url=OS_AUTH_URL, username=OS_USERNAME, password=OS_PASSWORD,
> project_name=OS_PROJECT_NAME)
>
> # Construct a keystone session
> # Other arguments that are potentially useful here are:
> #  verify - bool, whether or not to verify SSL connection validity
> #  cert - SSL cert information
> #  timout - time in seconds to use for connection level TCP timeouts
> session = ksa_session.Session(auth_plugin)
>
> # Now make the client
> # Other arguments you may be interested in:
> #  service_name - if you need to specify a service name for finding the
> # right service in the catalog
> #  service_type - if the cloud in question has given a different
> # service type (should be 'compute' for nova - but
> # novaclient sets it, so it's safe to omit in most cases
> #  endpoint_override - if you want to tell it to use a different URL
> #  than what the keystone catalog returns
> #  endpoint_type - if you need to specify admin or internal
> #  endpoints rather than the default 'public'
> #  Note that in glance and barbican, this key is called
> #  'interface'
> client = nova_client.Client(
> version='2.0', # or set the specific microversion you want
> session=session, region_name=OS_REGION_NAME)
>
> It might be clear why I prefer the os_client_config factory function
> instead - but what I prefer and what you prefer might not be the same
> thing. :)
>
> On Mon, Feb 22, 2016 at 6:11 AM, Xav Paice > > wrote:
>>
>> Hi,
>>
>> In http://docs.openstack.org/developer/python-novaclient/api.html
>> it's got some pretty clear instructions not to
>> use novaclient.v2.client.Client but I can't see another way to
>> specify the region - there's more than one in my installation, and
>> no param for region in novaclient.client.Client
>>
>> Shall I hunt down/write a blueprint for that?
>>
>>
>> __
>> 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
>>
>>
>>
>>
>> --
>> Best regards,
>> Andrey Kurilin.
>>
>>
>> __
>> OpenStack Development Mailing List (not for 

Re: [openstack-dev] [nova] python-novaclient region setting

2016-02-22 Thread Monty Taylor

On 02/21/2016 11:40 PM, Andrey Kurilin wrote:

Hi!
`novaclient.client.Client` entry-point supports almost the same
arguments as `novaclient.v2.client.Client`. The difference is only in
api_version, so you can set up region via `novaclient.client.Client` in
the same way as `novaclient.v2.client.Client`.


The easiest way to get a properly constructed nova Client is with 
os-client-config:


import os_client_config

OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
OS_PASSWORD="REDACTED"
OS_AUTH_URL="http://auth.vexxhost.net;
OS_REGION_NAME="ca-ymq-1"

client = os_client_config.make_client(
'compute',
auth_url=OS_AUTH_URL, username=OS_USERNAME,
password=OS_PASSWORD, project_name=OS_PROJECT_NAME,
region_name=OS_REGION_NAME)

The upside is that the constructor interface is the same for all of the 
rest of the client libs too (just change the first argument) - and it 
will also read in OS_ env vars or named clouds from clouds.yaml if you 
have them set.


(The 'simplest' way is to put your auth and region information into a 
clouds.yaml file like this:


http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations

Such as:

# ~/.config/openstack/clouds.yaml
clouds:
  vexxhost:
 profile: vexxhost
 auth:
   project_name: d8af8a8f-a573-48e6-898a-af333b970a2d
   username: 0b8c435b-cc4d-4e05-8a47-a2ada0539af1
   password: REDACTED
 region_name: ca-ymq-1


And do:

client = os_client_config.make_client('compute', cloud='vexxhost')


If you don't want to do that for some reason but you'd like to construct 
a novaclient Client object by hand:



from keystoneauth1 import loading
from keystoneauth1 import session as ksa_session
from novaclient import client as nova_client

OS_PROJECT_NAME="d8af8a8f-a573-48e6-898a-af333b970a2d"
OS_USERNAME="0b8c435b-cc4d-4e05-8a47-a2ada0539af1"
OS_PASSWORD="REDACTED"
OS_AUTH_URL="http://auth.vexxhost.net;
OS_REGION_NAME="ca-ymq-1"

# Get the auth loader for the password auth plugin
loader = loading.get_plugin_loader('password')
# Construct the auth plugin
auth_plugin = loader.load_from_options(
auth_url=OS_AUTH_URL, username=OS_USERNAME, password=OS_PASSWORD,
project_name=OS_PROJECT_NAME)

# Construct a keystone session
# Other arguments that are potentially useful here are:
#  verify - bool, whether or not to verify SSL connection validity
#  cert - SSL cert information
#  timout - time in seconds to use for connection level TCP timeouts
session = ksa_session.Session(auth_plugin)

# Now make the client
# Other arguments you may be interested in:
#  service_name - if you need to specify a service name for finding the
# right service in the catalog
#  service_type - if the cloud in question has given a different
# service type (should be 'compute' for nova - but
# novaclient sets it, so it's safe to omit in most cases
#  endpoint_override - if you want to tell it to use a different URL
#  than what the keystone catalog returns
#  endpoint_type - if you need to specify admin or internal
#  endpoints rather than the default 'public'
#  Note that in glance and barbican, this key is called
#  'interface'
client = nova_client.Client(
version='2.0', # or set the specific microversion you want
session=session, region_name=OS_REGION_NAME)

It might be clear why I prefer the os_client_config factory function 
instead - but what I prefer and what you prefer might not be the same 
thing. :)



On Mon, Feb 22, 2016 at 6:11 AM, Xav Paice > wrote:

Hi,

In http://docs.openstack.org/developer/python-novaclient/api.html
it's got some pretty clear instructions not to
use novaclient.v2.client.Client but I can't see another way to
specify the region - there's more than one in my installation, and
no param for region in novaclient.client.Client

Shall I hunt down/write a blueprint for that?

__
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




--
Best regards,
Andrey Kurilin.


__
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




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

Re: [openstack-dev] [nova] python-novaclient region setting

2016-02-21 Thread Andrey Kurilin
Hi!
`novaclient.client.Client` entry-point supports almost the same arguments
as `novaclient.v2.client.Client`. The difference is only in api_version, so
you can set up region via `novaclient.client.Client` in the same way as
`novaclient.v2.client.Client`.

On Mon, Feb 22, 2016 at 6:11 AM, Xav Paice  wrote:

> Hi,
>
> In http://docs.openstack.org/developer/python-novaclient/api.html it's
> got some pretty clear instructions not to use novaclient.v2.client.Client
> but I can't see another way to specify the region - there's more than one
> in my installation, and no param for region in novaclient.client.Client
>
> Shall I hunt down/write a blueprint for that?
>
> __
> 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
>
>


-- 
Best regards,
Andrey Kurilin.
__
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