def poll_state(): """ Polls current state of Juju and MAAS :returns: list of Machine() and the Juju state :rtype: tuple (JujuState(), MaasState()) """ # Capture Juju state cmd = utils.get_command_output('juju status', combine_output=False) if cmd['ret']: raise SystemExit("Error connecting to juju: stderr: {e}".format( e=cmd['stderr'])) juju = JujuState(cmd['stdout']) maas = None if MULTI_SYSTEM: # Login to MAAS auth = MaasAuth() auth.get_api_key('root') # auth.login() # Load Client routines c = MaasClient(auth) # Capture Maas state maas = MaasState(c.nodes) c.tag_fpi(maas) c.nodes_accept_all() c.tag_name(maas) update_machine_info(juju, maas) return (juju, maas)
def poll_state(): """ Polls current state of Juju and MAAS :returns: list of Machine() and the Juju state :rtype: tuple (JujuState(), MaasState()) """ # Capture Juju state (ret, juju_stdout, juju_stderr, _) = utils.get_command_output('juju status', combine_output=False) if ret: log.debug("Juju state unknown, will re-poll in " "case bootstrap is taking a little longer to come up.") log.debug("Juju status output: {o} \n stderr: {e}".format( o=juju_stdout, e=juju_stderr)) # Stub out a juju status for now juju = JujuState('environment: local\nmachines:') else: try: juju = JujuState(juju_stdout) except: log.exception("Ignoring exception in parsing juju state.") juju = JujuState('environment: local\nmachines:') maas = None if MULTI_SYSTEM: # Login to MAAS auth = MaasAuth() auth.get_api_key('root') # auth.login() # Load Client routines c = MaasClient(auth) # Capture Maas state maas = MaasState(c.nodes) c.tag_fpi(maas) c.nodes_accept_all() c.tag_name(maas) update_machine_info(juju, maas) return (juju, maas)