Updated Branches: refs/heads/trunk e1039acb6 -> f7a95f8cf
Add methods for listing availability groups to the CloudSigma driver. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/5a5e5bc5 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/5a5e5bc5 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/5a5e5bc5 Branch: refs/heads/trunk Commit: 5a5e5bc5acba2e4551956c57d252fc80937863a6 Parents: e1039ac Author: Tomaz Muraus <[email protected]> Authored: Thu Jan 30 17:13:59 2014 +0100 Committer: Tomaz Muraus <[email protected]> Committed: Thu Jan 30 17:13:59 2014 +0100 ---------------------------------------------------------------------- libcloud/compute/drivers/cloudsigma.py | 28 ++++++++++++++++++++ .../cloudsigma_2_0/drives_avail_groups.json | 15 +++++++++++ .../cloudsigma_2_0/servers_avail_groups.json | 13 +++++++++ libcloud/test/compute/test_cloudsigma_v2_0.py | 19 +++++++++++++ 4 files changed, 75 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/5a5e5bc5/libcloud/compute/drivers/cloudsigma.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/cloudsigma.py b/libcloud/compute/drivers/cloudsigma.py index c50db8b..acdb6ca 100644 --- a/libcloud/compute/drivers/cloudsigma.py +++ b/libcloud/compute/drivers/cloudsigma.py @@ -1479,6 +1479,34 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver): response = self.connection.request(action=action, method='DELETE') return response.status == httplib.NO_CONTENT + # Availability groups extension methods + + def ex_list_servers_availability_groups(self): + """ + Return which running servers share the same physical compute host. + + :return: A list of server UUIDs which share the same physical compute + host. Servers which share the same host will be stored under + the same list index. + :rtype: ``list`` of ``list`` + """ + action = '/servers/availability_groups/' + response = self.connection.request(action=action, method='GET') + return response.object + + def ex_list_drives_availability_groups(self): + """ + Return which drives share the same physical storage host. + + :return: A list of drive UUIDs which share the same physical storage + host. Drives which share the same host will be stored under + the same list index. + :rtype: ``list`` of ``list`` + """ + action = '/drives/availability_groups/' + response = self.connection.request(action=action, method='GET') + return response.object + # Tag extension methods def ex_list_tags(self): http://git-wip-us.apache.org/repos/asf/libcloud/blob/5a5e5bc5/libcloud/test/compute/fixtures/cloudsigma_2_0/drives_avail_groups.json ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/fixtures/cloudsigma_2_0/drives_avail_groups.json b/libcloud/test/compute/fixtures/cloudsigma_2_0/drives_avail_groups.json new file mode 100644 index 0000000..62706d7 --- /dev/null +++ b/libcloud/test/compute/fixtures/cloudsigma_2_0/drives_avail_groups.json @@ -0,0 +1,15 @@ +[ + [ + "ad2b0b9c-8b66-45bc-a0f8-3a8514b78406", + "e464a01b-ad2a-4bed-a4dd-30d1687560fd", + "2246e488-a1b9-4da2-af30-0b6c73a1529c", + "51a6b22f-2884-48d9-87f8-c85cb6f43c99", + "a67c932d-6766-470b-b1c5-17856e4a5b4e", + "3af58efd-8442-466f-80bf-48c5a2ee84b6", + "ab35089c-0a89-435f-aedd-eaa05fae0ef1", + "9972280b-3d74-4b0d-85de-caa0ef0117a6", + "c47bca85-0199-438c-9ae4-d308357cf22d", + "3e166706-188c-4f38-b8d5-7fc10a5019a1", + "ba47e1e9-1848-48bd-8786-9cc45744214c" + ] +] http://git-wip-us.apache.org/repos/asf/libcloud/blob/5a5e5bc5/libcloud/test/compute/fixtures/cloudsigma_2_0/servers_avail_groups.json ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/fixtures/cloudsigma_2_0/servers_avail_groups.json b/libcloud/test/compute/fixtures/cloudsigma_2_0/servers_avail_groups.json new file mode 100644 index 0000000..6a4b2a8 --- /dev/null +++ b/libcloud/test/compute/fixtures/cloudsigma_2_0/servers_avail_groups.json @@ -0,0 +1,13 @@ +[ + [ + "63456dc4-36f9-4a3f-b478-4d376b8ff5a9", + "ede05e68-c997-4aad-816a-39469fd1a562" + ], + [ + "ad8caf99-45c4-45fc-8ba7-acb8a68be66f", + "4b9e1487-0b80-4f65-9c3e-e840dde27ccd" + ], + [ + "658bafdf-8fbf-4fc6-be4f-74ecc7f0e8a5" + ] +] http://git-wip-us.apache.org/repos/asf/libcloud/blob/5a5e5bc5/libcloud/test/compute/test_cloudsigma_v2_0.py ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/test_cloudsigma_v2_0.py b/libcloud/test/compute/test_cloudsigma_v2_0.py index 0b5948f..966a072 100644 --- a/libcloud/test/compute/test_cloudsigma_v2_0.py +++ b/libcloud/test/compute/test_cloudsigma_v2_0.py @@ -356,6 +356,17 @@ class CloudSigmaAPI20BaseTestCase(object): capabilities = self.driver.ex_list_capabilities() self.assertEqual(capabilities['servers']['cpu']['min'], 250) + def test_ex_list_servers_availability_groups(self): + groups = self.driver.ex_list_servers_availability_groups() + self.assertEqual(len(groups), 3) + self.assertEqual(len(groups[0]), 2) + self.assertEqual(len(groups[2]), 1) + + def test_ex_list_drives_availability_groups(self): + groups = self.driver.ex_list_drives_availability_groups() + self.assertEqual(len(groups), 1) + self.assertEqual(len(groups[0]), 11) + def test_wait_for_drive_state_transition_timeout(self): drive = self.driver.ex_list_drives()[0] state = 'timeout' @@ -570,6 +581,14 @@ class CloudSigmaMockHttp(MockHttpTestCase): body = self.fixtures.load('capabilities.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + def _api_2_0_servers_availability_groups(self, method, url, body, headers): + body = self.fixtures.load('servers_avail_groups.json') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _api_2_0_drives_availability_groups(self, method, url, body, headers): + body = self.fixtures.load('drives_avail_groups.json') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + if __name__ == '__main__': sys.exit(unittest.main())
