def change_kernel(id, kernel_id): try: kernel = digitalocean.Kernel(id=int(kernel_id)) manager = get_manager() droplet = manager.get_droplet(id) droplet.change_kernel(kernel) except Exception as e: message = "Failed to change kernel for droplet %s, DO API responded: %s" % ( str(id), str(e.args)) create_log(message, 3)
def test_change_kernel(self): data = self.load_from_file('droplet_actions/change_kernel.json') responses.add(responses.POST, self.actions_url, body=data, status=201, content_type='application/json') response = self.droplet.change_kernel(digitalocean.Kernel(id=123)) self.assert_url_query_equal(responses.calls[0].request.url, self.actions_url) self.assertEqual(json.loads(responses.calls[0].request.body), {u"kernel": 123, u"type": u"change_kernel"}) self.assertEqual(response['action']['id'], 54321) self.assertEqual(response['action']['status'], "in-progress") self.assertEqual(response['action']['type'], "change_kernel") self.assertEqual(response['action']['resource_id'], 12345) self.assertEqual(response['action']['resource_type'], "droplet")