Ask Your Question
0

Openstack nova API live migrate AttributeError: _action python 2.7

asked 2017-02-28 14:11:02 -0500

enjoisno gravatar image

updated 2017-02-28 14:29:29 -0500

I am trying live migrate a server via the openstack python sdk.

from keystoneauth1.identity import v3
from keystoneauth1 import session
import json, ast

auth = v3.Password(auth_url='',
                   username='',
                   password='',
                   project_name='',
                   user_domain_id='',
                   project_domain_id='')

sess = session.Session(auth=auth)

print(sess)

from novaclient import client

nova = client.Client('2.30', session=sess)

servers = nova.servers.list()

for s in servers:
    print(s)
    # print(dir(s))
    s.live_migrate(host="oscnode1.localhost",block_migration=False,server=None)

Here is the error message I am getting

<Server: api_test_ubuntu2>
Traceback (most recent call last):
  File "C:/Users/a/PycharmProjects/openstack_api/openstack_sdk_v3.py", line 129, in <module>
    s.live_migrate(host="oscnode1.localhost",block_migration=False,server=None)
  File "C:\Python27\lib\site-packages\novaclient\api_versions.py", line 402, in substitution
    return methods[-1].func(obj, *args, **kwargs)
  File "C:\Python27\lib\site-packages\novaclient\v2\servers.py", line 1675, in live_migrate
    return self._action('os-migrateLive', server, body)
  File "C:\Python27\lib\site-packages\novaclient\base.py", line 180, in __getattr__
    raise AttributeError(k)
AttributeError: _action

I am able to connect and run other command to the nova api like nova.servers.list() and others.

I am using Python 2.7.12 on windows and python-openstackclient with python-novaclient both at the lastest versions.

Thanks for your help

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-03-01 06:54:08 -0500

sowmya gravatar image

updated 2017-03-01 07:01:00 -0500

I think the way you are calling the API is slightly incorrect try as below:

for s in servers:
    '''
      get the instance ID from the server(instance) <server ID> to be migrated 
    '''
     nova.servers.live_migrate(host="oscnode1.localhost",block_migration=False,server=<server ID>)

Reference:

live_migrate(self, server, host, block_migration):
        """
        Migrates a running instance to a new machine.

        :param server: instance id which comes from nova list.
        :param host: destination host name.
        :param block_migration: if True, do block_migration, can be set as
                                'auto'
edit flag offensive delete link more

Comments

That fixed the error and it is now working. Below is what I changed it to using the 2.0 nova api version.

nova.servers.live_migrate(host="oscnode1.localhost", block_migration=False, server=s.id, disk_over_commit=False)
enjoisno gravatar imageenjoisno ( 2017-03-01 07:38:53 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2017-02-28 14:00:21 -0500

Seen: 235 times

Last updated: Mar 01 '17