def test_36(self): with session_commit(sess_maker=self.sess_maker) as session: rq = "uuid=%s&mac=%s&os=installed" % ( posts.M03["boot-info"]["uuid"], posts.M03["boot-info"]["mac"]) i = crud.InjectLifecycle(session, request_raw_query=rq) i.apply_lifecycle_rolling(True) f = crud.FetchLifecycle(sess_maker=self.sess_maker) status = f.get_rolling_status(posts.M03["boot-info"]["mac"]) self.assertTrue(status[0]) self.assertEqual("kexec", status[1]) with session_commit(sess_maker=self.sess_maker) as session: n = crud.InjectLifecycle(session, rq) n.apply_lifecycle_rolling(False) f = crud.FetchLifecycle(sess_maker=self.sess_maker) r = f.get_rolling_status(posts.M03["boot-info"]["mac"]) self.assertFalse(r[0]) self.assertEqual("kexec", r[1]) with session_commit(sess_maker=self.sess_maker) as session: n = crud.InjectLifecycle(session, rq) n.apply_lifecycle_rolling(True, "reboot") f = crud.FetchLifecycle(sess_maker=self.sess_maker) r = f.get_rolling_status(posts.M03["boot-info"]["mac"]) self.assertTrue(r[0]) self.assertEqual("reboot", r[1]) with session_commit(sess_maker=self.sess_maker) as session: n = crud.InjectLifecycle(session, rq) n.apply_lifecycle_rolling(True, "poweroff") f = crud.FetchLifecycle(sess_maker=self.sess_maker) r = f.get_rolling_status(posts.M03["boot-info"]["mac"]) self.assertTrue(r[0]) self.assertEqual("poweroff", r[1]) with session_commit(sess_maker=self.sess_maker) as session: n = crud.InjectLifecycle(session, rq) with self.assertRaises(LookupError): n.apply_lifecycle_rolling(True, "notpossible") f = crud.FetchLifecycle(sess_maker=self.sess_maker) r = f.get_rolling_status(posts.M03["boot-info"]["mac"]) self.assertTrue(r[0]) self.assertEqual("poweroff", r[1])
def test_37(self): f = crud.FetchLifecycle(sess_maker=self.sess_maker) t = f.get_rolling_status(posts.M04["boot-info"]["mac"]) self.assertIsNone(t[0]) self.assertIsNone(t[1]) r = f.get_all_rolling_status() self.assertEqual(1, len(r))
def report_lifecycle_rolling(request_raw_query): """ Lifecycle Rolling Update Get the current policy for a given machine by UUID or MAC --- tags: - lifecycle parameters: - name: request_raw_query in: path description: Pass the mac as 'mac=<mac>' required: true type: string responses: 403: description: mac address is not parsable schema: type: dict 200: description: Rolling Update is enable schema: type: dict 403: description: Rolling Update is not enable schema: type: dict """ life = crud.FetchLifecycle(sess_maker=sess_maker) try: mac = tools.get_mac_from_raw_query(request_raw_query) except AttributeError as e: return jsonify({ "enable": None, "request_raw_query": "%s:%s" % (request_raw_query, e) }), 403 allow, strategy = life.get_rolling_status(mac) if allow is True: return jsonify({ "enable": True, "request_raw_query": request_raw_query, "strategy": strategy }), 200 elif allow is False: return jsonify({ "enable": False, "request_raw_query": request_raw_query, "strategy": strategy }), 403 return jsonify({ "enable": False, "request_raw_query": request_raw_query, "strategy": None }), 401
def test_35(self): with session_commit(sess_maker=self.sess_maker) as session: rq = "uuid=%s&mac=%s&os=installed" % ( posts.M03["boot-info"]["uuid"], posts.M03["boot-info"]["mac"]) i = crud.InjectLifecycle(session, request_raw_query=rq) i.refresh_lifecycle_coreos_install(True) f = crud.FetchLifecycle(sess_maker=self.sess_maker) self.assertTrue( f.get_coreos_install_status(posts.M03["boot-info"]["mac"])) self.assertEqual(1, len(f.get_all_coreos_install_status()))
def test_33(self): with session_commit(sess_maker=self.sess_maker) as session: rq = "uuid=%s&mac=%s&os=installed" % ( posts.M02["boot-info"]["uuid"], posts.M02["boot-info"]["mac"]) i = crud.InjectLifecycle(session, request_raw_query=rq) i.refresh_lifecycle_ignition(True) j = crud.InjectLifecycle(session, request_raw_query=rq) j.refresh_lifecycle_ignition(True) f = crud.FetchLifecycle(sess_maker=self.sess_maker) self.assertTrue( f.get_ignition_uptodate_status(posts.M02["boot-info"]["mac"]))
def lifecycle_rolling_all(): """ Lifecycle Rolling Update Get the policy list --- tags: - lifecycle responses: 200: description: Rolling Update status schema: type: list """ return jsonify( crud.FetchLifecycle( sess_maker=sess_maker).get_all_rolling_status())
def lifecycle_get_ignition_status(): """ Lifecycle Ignition Update Get the update status of all Ignition reports --- tags: - lifecycle responses: 200: description: Ignition Update status schema: type: list """ return jsonify( crud.FetchLifecycle( sess_maker=sess_maker).get_all_updated_status())
def lifecycle_get_coreos_install_status(): """ Lifecycle CoreOS Install Get all the CoreOS Install status --- tags: - lifecycle responses: 200: description: CoreOS Install status list schema: type: list """ return jsonify( crud.FetchLifecycle( sess_maker=sess_maker).get_all_coreos_install_status())