Ejemplo n.º 1
0
 def __init__(self):
     self.cr = CommandRunner()
     self.console = ConsoleMode()
     self.node_view = NodeViewMode(self)
     self.lock_ticks = 0  # start in a locked state
     self.locked = False
     self.juju_state, _ = pegasus.poll_state()
     self.init_machine()
     MainLoop.__init__(self, self.node_view.target, STYLES,
                       unhandled_input=self._header_hotkeys)
Ejemplo n.º 2
0
    def refresh_states(self):
        """ Refresh states

        Make a call to refresh both juju and maas machine states

        :returns: data from the polling of services and the juju state
        :rtype: tuple (JujuState(), MaasState())
        """
        log.debug("refresh_states() about to poll_state()")
        return pegasus.poll_state()
Ejemplo n.º 3
0
 def set_relations(self):
     super(CharmNovaCompute, self).set_relations()
     juju, _ = poll_state()
     service = juju.service(self.charm_name)
     has_amqp = list(filter(lambda r: 'amqp' in r.relation_name,
                     service.relations))
     if len(has_amqp) == 0:
         log.debug("Setting amqp relation for compute.")
         ret = self.client.add_relation("{c}:amqp".format(
                                        c=self.charm_name),
                                        "rabbitmq-server:amqp")
         if ret:
             log.error("Problem relating nova-compute to rabbitmq")
             return True
         return False
Ejemplo n.º 4
0
    def wait_for_agent(self, svc_name=None):
        """ Waits for service agent to be reachable

        :rtype: Unit()
        :returns: unit if ready
        """
        if not svc_name:
            svc_name = self.charm_name
        log.debug("Checking availability for {c}.".format(c=svc_name))
        juju, _ = pegasus.poll_state()
        svc = juju.service(svc_name)
        unit = svc.unit(svc_name)
        if unit.agent_state == "started":
            return unit
        return False