65b55d8f9b
This revert some of commit 63073104665ee4597cf3b7aa8dc2295a8a7db794, specifically the changes made to the API since those changes were never merged in Nova. Resolves bug 1145768. Change-Id: I8f83c5a33cfed0c3a659f5221b8b2e730ca9463f
67 lines
2.3 KiB
Python
67 lines
2.3 KiB
Python
from novaclient.v1_1 import hosts
|
|
from tests.v1_1 import fakes
|
|
from tests import utils
|
|
|
|
|
|
cs = fakes.FakeClient()
|
|
|
|
|
|
class HostsTest(utils.TestCase):
|
|
|
|
def test_describe_resource(self):
|
|
hs = cs.hosts.get('host')
|
|
cs.assert_called('GET', '/os-hosts/host')
|
|
[self.assertTrue(isinstance(h, hosts.Host)) for h in hs]
|
|
|
|
def test_list_host(self):
|
|
hs = cs.hosts.list_all()
|
|
cs.assert_called('GET', '/os-hosts')
|
|
[self.assertTrue(isinstance(h, hosts.Host)) for h in hs]
|
|
[self.assertEqual(h.zone, 'nova1') for h in hs]
|
|
|
|
def test_list_host_with_zone(self):
|
|
hs = cs.hosts.list_all('nova')
|
|
cs.assert_called('GET', '/os-hosts?zone=nova')
|
|
[self.assertTrue(isinstance(h, hosts.Host)) for h in hs]
|
|
[self.assertEqual(h.zone, 'nova') for h in hs]
|
|
|
|
def test_update_enable(self):
|
|
host = cs.hosts.get('sample_host')[0]
|
|
values = {"status": "enabled"}
|
|
result = host.update(values)
|
|
cs.assert_called('PUT', '/os-hosts/sample_host', values)
|
|
self.assertTrue(isinstance(result, hosts.Host))
|
|
|
|
def test_update_maintenance(self):
|
|
host = cs.hosts.get('sample_host')[0]
|
|
values = {"maintenance_mode": "enable"}
|
|
result = host.update(values)
|
|
cs.assert_called('PUT', '/os-hosts/sample_host', values)
|
|
self.assertTrue(isinstance(result, hosts.Host))
|
|
|
|
def test_update_both(self):
|
|
host = cs.hosts.get('sample_host')[0]
|
|
values = {"status": "enabled",
|
|
"maintenance_mode": "enable"}
|
|
result = host.update(values)
|
|
cs.assert_called('PUT', '/os-hosts/sample_host', values)
|
|
self.assertTrue(isinstance(result, hosts.Host))
|
|
|
|
def test_host_startup(self):
|
|
host = cs.hosts.get('sample_host')[0]
|
|
result = host.startup()
|
|
cs.assert_called(
|
|
'POST', '/os-hosts/sample_host/action', {'startup': None})
|
|
|
|
def test_host_reboot(self):
|
|
host = cs.hosts.get('sample_host')[0]
|
|
result = host.reboot()
|
|
cs.assert_called(
|
|
'POST', '/os-hosts/sample_host/action', {'reboot': None})
|
|
|
|
def test_host_shutdown(self):
|
|
host = cs.hosts.get('sample_host')[0]
|
|
result = host.shutdown()
|
|
cs.assert_called(
|
|
'POST', '/os-hosts/sample_host/action', {'shutdown': None})
|