Complete API samples for Hosts extension

The API samples for Hosts extension missed power operations (shutdown, reboot
and startup) and maintenance/status operations.

Complete fix to bug 1070167

Change-Id: I07fd34e071eae9afc82f9320634df24f48623e0b
This commit is contained in:
Mauro S. M. Rodrigues 2012-11-22 14:22:52 -05:00
parent f58f2b48a1
commit c9273ab797
21 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,4 @@
{
"host": "066bf157ab50481d8c607cfe584b2230",
"power_action": "reboot"
}

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<host host="ce8c5f8cde4a46ffb01dec0788ad4dfc" power_action="reboot"/>

View File

@ -0,0 +1,4 @@
{
"host": "d2576862a2144ee6ad37d9e1938460a2",
"power_action": "shutdown"
}

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<host host="c82ca6da579440ac930ddee0e6530176" power_action="shutdown"/>

View File

@ -0,0 +1,4 @@
{
"host": "57f5de2fa5b44f14974a4f50b9ffcbf8",
"power_action": "startup"
}

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<host host="7fae168ed18140d5a785ade2ac1bd420" power_action="startup"/>

View File

@ -0,0 +1,4 @@
{
"status": "enable",
"maintenance_mode": "disable"
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<updates>
<status>enable</status>
<maintenance_mode>disable</maintenance_mode>
</updates>

View File

@ -0,0 +1,5 @@
{
"host": "0738dca90a8c43fdadd0be28715520e2",
"maintenance_mode": "off_maintenance",
"status": "enabled"
}

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<host status="enabled" maintenance_mode="off_maintenance" host="d85f05519b57457c83da18c39fa8e00d"/>

View File

@ -0,0 +1,4 @@
{
"host": "%(host_name)s",
"power_action": "reboot"
}

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<host host="%(host_name)s" power_action="reboot"/>

View File

@ -0,0 +1,4 @@
{
"host": "%(host_name)s",
"power_action": "shutdown"
}

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<host host="%(host_name)s" power_action="shutdown"/>

View File

@ -0,0 +1,4 @@
{
"host": "%(host_name)s",
"power_action": "startup"
}

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<host host="%(host_name)s" power_action="startup"/>

View File

@ -0,0 +1,4 @@
{
"status": "enable",
"maintenance_mode": "disable"
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<updates>
<status>enable</status>
<maintenance_mode>disable</maintenance_mode>
</updates>

View File

@ -0,0 +1,5 @@
{
"host": "%(host_name)s",
"maintenance_mode": "off_maintenance",
"status": "enabled"
}

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<host status="enabled" maintenance_mode="off_maintenance" host="%(host_name)s"/>

View File

@ -462,13 +462,41 @@ class FlavorsSampleXmlTest(FlavorsSampleJsonTest):
class HostsSampleJsonTest(ApiSampleTestBase):
extension_name = "nova.api.openstack.compute.contrib.hosts.Hosts"
def test_host_startup(self):
response = self._do_get('os-hosts/%s/startup' % self.compute.host)
self.assertEqual(response.status, 200)
subs = self._get_regexes()
return self._verify_response('host-get-startup', subs, response)
def test_host_reboot(self):
response = self._do_get('os-hosts/%s/reboot' % self.compute.host)
self.assertEqual(response.status, 200)
subs = self._get_regexes()
return self._verify_response('host-get-reboot', subs, response)
def test_host_shutdown(self):
response = self._do_get('os-hosts/%s/shutdown' % self.compute.host)
self.assertEqual(response.status, 200)
subs = self._get_regexes()
return self._verify_response('host-get-shutdown', subs, response)
def test_host_maintenance(self):
response = self._do_put('os-hosts/%s' % self.compute.host,
'host-put-maintenance-req', {})
self.assertEqual(response.status, 200)
subs = self._get_regexes()
return self._verify_response('host-put-maintenance-resp', subs,
response)
def test_host_get(self):
response = self._do_get('os-hosts/%s' % self.compute.host)
self.assertEqual(response.status, 200)
subs = self._get_regexes()
return self._verify_response('host-get-resp', subs, response)
def test_hosts_list(self):
response = self._do_get('os-hosts')
self.assertEqual(response.status, 200)
subs = self._get_regexes()
return self._verify_response('hosts-list-resp', subs, response)