The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/80
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 071930ce274a4b23ba81ded33a8db0285b2bf84e Mon Sep 17 00:00:00 2001 From: jpic <james...@gmail.com> Date: Thu, 19 May 2016 13:13:36 +0200 Subject: [PATCH 1/4] status is a string now --- integration/test_containers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration/test_containers.py b/integration/test_containers.py index d72d4fb..2a00121 100644 --- a/integration/test_containers.py +++ b/integration/test_containers.py @@ -98,15 +98,15 @@ def test_start_stop(self): # to test what we need. self.container.start(wait=True) - self.assertEqual('Running', self.container.status['status']) + self.assertEqual('Running', self.container.status) container = self.client.containers.get(self.container.name) - self.assertEqual('Running', container.status['status']) + self.assertEqual('Running', container.status) self.container.stop(wait=True) - self.assertEqual('Stopped', self.container.status['status']) + self.assertEqual('Stopped', self.container.status) container = self.client.containers.get(self.container.name) - self.assertEqual('Stopped', container.status['status']) + self.assertEqual('Stopped', container.status) def test_snapshot(self): """A container snapshot is made, renamed, and deleted.""" From 19319ed6f8dd38baef1d43a51b2de4a59fa5cd09 Mon Sep 17 00:00:00 2001 From: jpic <james...@gmail.com> Date: Thu, 19 May 2016 13:14:26 +0200 Subject: [PATCH 2/4] Make architecture a string type Fixes: {u'type': u'error', u'error_code': 400, u'error': u'json: cannot unmarshal number into Go value of type string'} --- integration/test_containers.py | 2 +- integration/testing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/test_containers.py b/integration/test_containers.py index 2a00121..cb0086d 100644 --- a/integration/test_containers.py +++ b/integration/test_containers.py @@ -40,7 +40,7 @@ def test_create(self): """Creates and returns a new container.""" config = { 'name': 'an-container', - 'architecture': 2, + 'architecture': '2', 'profiles': ['default'], 'ephemeral': True, 'config': {'limits.cpu': '2'}, diff --git a/integration/testing.py b/integration/testing.py index e6e3cfe..ba2d1da 100644 --- a/integration/testing.py +++ b/integration/testing.py @@ -37,7 +37,7 @@ def create_container(self): name = self.generate_object_name() machine = { 'name': name, - 'architecture': 2, + 'architecture': '2', 'profiles': ['default'], 'ephemeral': False, 'config': {'limits.cpu': '2'}, From 08ae6e3e103950af174f96013376f81123a21b33 Mon Sep 17 00:00:00 2001 From: jpic <james...@gmail.com> Date: Thu, 19 May 2016 13:17:33 +0200 Subject: [PATCH 3/4] Expect test to have created 1 container --- integration/test_containers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/integration/test_containers.py b/integration/test_containers.py index cb0086d..50d40ed 100644 --- a/integration/test_containers.py +++ b/integration/test_containers.py @@ -28,12 +28,17 @@ def test_get(self): def test_all(self): """A list of all containers is returned.""" + containers_before_create = self.client.containers.all() + name = self.create_container() self.addCleanup(self.delete_container, name) containers = self.client.containers.all() - self.assertEqual(1, len(containers)) + self.assertEqual( + len(containers_before_create) + 1, + len(containers) + ) self.assertEqual(name, containers[0].name) def test_create(self): From 933dd6fc552399bb343a05ca8023746106423b79 Mon Sep 17 00:00:00 2001 From: jpic <james...@gmail.com> Date: Thu, 19 May 2016 13:32:50 +0200 Subject: [PATCH 4/4] Fail test on HTTP error --- integration/testing.py | 4 ++++ pylxd/container.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/integration/testing.py b/integration/testing.py index ba2d1da..d7b7374 100644 --- a/integration/testing.py +++ b/integration/testing.py @@ -45,6 +45,10 @@ def create_container(self): 'alias': 'busybox'}, } result = self.lxd['containers'].post(json=machine) + + if result.status_code >= 400: + raise RuntimeError(result.json()) + operation_uuid = result.json()['operation'].split('/')[-1] result = self.lxd.operations[operation_uuid].wait.get() diff --git a/pylxd/container.py b/pylxd/container.py index 38bbe04..c0e6292 100644 --- a/pylxd/container.py +++ b/pylxd/container.py @@ -64,6 +64,9 @@ def create(cls, client, config, wait=False): """Create a new container config.""" response = client.api.containers.post(json=config) + if response.status_code >= 400: + raise RuntimeError(response.json(), config) + if wait: Operation.wait_for_operation(client, response.json()['operation']) return cls(name=config['name'])
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel