Merge "Fix nova host-evacuate for v2.14"
This commit is contained in:
commit
e8354f1098
@ -1980,6 +1980,19 @@ class ShellTest(utils.TestCase):
|
|||||||
self.assert_called(
|
self.assert_called(
|
||||||
'GET', '/os-hosts/sample-host/reboot')
|
'GET', '/os-hosts/sample-host/reboot')
|
||||||
|
|
||||||
|
def test_host_evacuate_v2_14(self):
|
||||||
|
self.run_command('host-evacuate hyper --target target_hyper',
|
||||||
|
api_version='2.14')
|
||||||
|
self.assert_called('GET', '/os-hypervisors/hyper/servers', pos=0)
|
||||||
|
self.assert_called('POST', '/servers/uuid1/action',
|
||||||
|
{'evacuate': {'host': 'target_hyper'}}, pos=1)
|
||||||
|
self.assert_called('POST', '/servers/uuid2/action',
|
||||||
|
{'evacuate': {'host': 'target_hyper'}}, pos=2)
|
||||||
|
self.assert_called('POST', '/servers/uuid3/action',
|
||||||
|
{'evacuate': {'host': 'target_hyper'}}, pos=3)
|
||||||
|
self.assert_called('POST', '/servers/uuid4/action',
|
||||||
|
{'evacuate': {'host': 'target_hyper'}}, pos=4)
|
||||||
|
|
||||||
def test_host_evacuate(self):
|
def test_host_evacuate(self):
|
||||||
self.run_command('host-evacuate hyper --target target_hyper')
|
self.run_command('host-evacuate hyper --target target_hyper')
|
||||||
self.assert_called('GET', '/os-hypervisors/hyper/servers', pos=0)
|
self.assert_called('GET', '/os-hypervisors/hyper/servers', pos=0)
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from novaclient import api_versions
|
||||||
from novaclient import base
|
from novaclient import base
|
||||||
from novaclient.i18n import _
|
from novaclient.i18n import _
|
||||||
from novaclient import utils
|
from novaclient import utils
|
||||||
@ -26,8 +27,15 @@ def _server_evacuate(cs, server, args):
|
|||||||
success = True
|
success = True
|
||||||
error_message = ""
|
error_message = ""
|
||||||
try:
|
try:
|
||||||
cs.servers.evacuate(server=server['uuid'], host=args.target_host,
|
on_shared_storage = getattr(args, 'on_shared_storage', None)
|
||||||
on_shared_storage=args.on_shared_storage)
|
if api_versions.APIVersion("2.14") <= cs.api_version:
|
||||||
|
# if microversion >= 2.14
|
||||||
|
cs.servers.evacuate(server=server['uuid'], host=args.target_host)
|
||||||
|
else:
|
||||||
|
# else microversion 2.0 - 2.13
|
||||||
|
cs.servers.evacuate(server=server['uuid'],
|
||||||
|
host=args.target_host,
|
||||||
|
on_shared_storage=on_shared_storage)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
success = False
|
success = False
|
||||||
error_message = _("Error while evacuating instance: %s") % e
|
error_message = _("Error while evacuating instance: %s") % e
|
||||||
@ -49,7 +57,9 @@ def _server_evacuate(cs, server, args):
|
|||||||
dest='on_shared_storage',
|
dest='on_shared_storage',
|
||||||
action="store_true",
|
action="store_true",
|
||||||
default=False,
|
default=False,
|
||||||
help=_('Specifies whether all instances files are on shared storage'))
|
help=_('Specifies whether all instances files are on shared storage'),
|
||||||
|
start_version='2.0',
|
||||||
|
end_version='2.13')
|
||||||
def do_host_evacuate(cs, args):
|
def do_host_evacuate(cs, args):
|
||||||
"""Evacuate all instances from failed host."""
|
"""Evacuate all instances from failed host."""
|
||||||
hypervisors = cs.hypervisors.search(args.host, servers=True)
|
hypervisors = cs.hypervisors.search(args.host, servers=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user