Merge "remove set_host_offline"

This commit is contained in:
Zuul
2018-10-29 11:49:39 +00:00
committed by Gerrit Code Review
2 changed files with 0 additions and 45 deletions

View File

@@ -406,38 +406,6 @@ class NovaHelper(object):
return status
def set_host_offline(self, hostname):
# See API on https://developer.openstack.org/api-ref/compute/
# especially the PUT request
# regarding this resource : /v2.1/os-hosts/{host_name}
#
# The following body should be sent :
# {
# "host": {
# "host": "65c5d5b7e3bd44308e67fc50f362aee6",
# "maintenance_mode": "off_maintenance",
# "status": "enabled"
# }
# }
# Voir ici
# https://github.com/openstack/nova/
# blob/master/nova/virt/xenapi/host.py
# set_host_enabled(self, enabled):
# Sets the compute host's ability to accept new instances.
# host_maintenance_mode(self, host, mode):
# Start/Stop host maintenance window.
# On start, it triggers guest instances evacuation.
host = self.nova.hosts.get(hostname)
if not host:
LOG.debug("host not found: %s", hostname)
return False
else:
host[0].update(
{"maintenance_mode": "disable", "status": "disable"})
return True
def create_image_from_instance(self, instance_id, image_name,
metadata={"reason": "instance_migrate"}):
"""This method creates a new image from a given instance.

View File

@@ -115,19 +115,6 @@ class TestNovaHelper(base.TestCase):
result = nova_util.stop_instance(instance_id)
self.assertFalse(result)
def test_set_host_offline(self, mock_glance, mock_cinder, mock_neutron,
mock_nova):
host = mock.MagicMock()
nova_util = nova_helper.NovaHelper()
nova_util.nova.hosts = mock.MagicMock()
nova_util.nova.hosts.get.return_value = host
result = nova_util.set_host_offline("rennes")
self.assertTrue(result)
nova_util.nova.hosts.get.return_value = None
result = nova_util.set_host_offline("rennes")
self.assertFalse(result)
@mock.patch.object(time, 'sleep', mock.Mock())
def test_resize_instance(self, mock_glance, mock_cinder,
mock_neutron, mock_nova):