def setUp(self): super(TestAPI, self).setUp() self.compute_api = api.API(self.context) self.container = objects.Container(self.context, **utils.get_test_container()) self.network = objects.Network(self.context, **utils.get_test_network())
def setUp(self): super(TestAPI, self).setUp() p = mock.patch('zun.scheduler.client.query.SchedulerClient') p.start() self.addCleanup(p.stop) self.compute_api = api.API(self.context) self.container = objects.Container(self.context, **utils.get_test_container()) self.network = objects.ZunNetwork(self.context, **utils.get_test_network())
def heal_with_rebuilding_container(self, context, container): compute_api = zun_compute.API(context) rebuild_status = [consts.CREATED, consts.RUNNING, consts.STOPPED] try: if (container.auto_heal and container.status in rebuild_status): context.project_id = container.project_id compute_api.container_rebuild(context, container) else: LOG.warning("Container %s was recorded in DB but " "missing in docker", container.uuid) container.status = consts.ERROR msg = "No such container:%s in docker" % \ (container.container_id) container.status_reason = six.text_type(msg) container.save(context) except Exception as e: LOG.warning("heal container with rebuilding failed, " "err code: %s", e)
def before(self, state): context = state.request.context state.request.compute_api = compute_api.API(context)