Example #1
0
 def __init__(self):
     super(NeutronNotifier, self).__init__()
     self.neutron = None
     self.event_handlers = {
         nt_ev.DeleteLBMemberEvent: self.mark_invalid_lb_member
     }
     hub.spawn(self._get_neutron_client)
Example #2
0
    def edge_phy_switch_port_down(self, ev):
        msg = ev.msg
        tunnel_ip_list = msg.get('tunnel_ip')
        dpid = msg.get('dpid')
        port_no = msg.get('port_no')
        status = msg.get('status')
        self.LOG.debug("switch %s port %s down, affected tunnel_ip: %s",
                       dpid, port_no, tunnel_ip_list)

        for tunnel_ip in tunnel_ip_list:
            # get affected tunnel agent by tunnel ip
            ovs_agent = self.send_request(GetOVSAgentRequest(tunnel_ip)).msg
            if not ovs_agent:
                self.LOG.warning("ovs agent not found(tunnel_ip=%s)", tunnel_ip)
                continue

            # get hypervisor/phy server by agent.hostname
            host = ovs_agent.host
            hypervisor = self.send_request(GetHypervisorRequest(host)).msg
            if not hypervisor:
                self.LOG.warning("hypervisor not found(hypervisor=%s)", host)
                continue
            self.LOG.debug("hypervisor [%s] with instances: %s",
                           host, hypervisor.servers.keys())

            # TODO: call novaclient methods directly to find specific
            #       servers/instances, will be a bottleneck.
            for server_uuid in hypervisor.servers:
                hub.spawn(self._thread_edge_phy_switch_down, server_uuid)
Example #3
0
 def update_lb_member(self, ev, body):
     lb_members = ev.msg
     self.LOG.info("update load balance pool members: %s with body %s",
                   [v.id for k, v in lb_members.items()], body)
     for ip, lb_member in lb_members.items():
         hub.spawn(self.neutron.neutron_client.update_member,
                   member=lb_member.id,
                   body=body)
Example #4
0
 def __init__(self):
     super(Scheduler, self).__init__()
     self.neutron = None
     self.nova = None
     self.event_handlers = {
         sc_ev.EdgePhySwitchDownEvent: self.edge_phy_switch_down,
         sc_ev.EdgePhySwitchPortDownEvent: self.edge_phy_switch_port_down
     }
     hub.spawn(self._get_neutron_client)
     hub.spawn(self._get_nova_client)
Example #5
0
    def __init__(self):
        super(NovaCollector, self).__init__()
        self.pull_instance_interval = \
            CONF.nova_collector.pull_instance_interval

        self.nova = None
        self.hypervisors = {}
        self.event_handlers = {
            cl_ev.GetHypervisorRequest: self.reply_hypervisor
        }
        hub.spawn(self._get_nova_client)
Example #6
0
    def thread(self, function, *args, **kwargs):
        """run function by greenthread.

        :param function:
        """
        self.threads.append(
            hub.spawn(function, *args, **kwargs))
Example #7
0
    def __init__(self):
        super(NeutronCollector, self).__init__()
        self.pull_agent_interval = \
            CONF.neutron_collector.pull_agent_interval
        self.pull_lb_member_interval = \
            CONF.neutron_collector.pull_lb_member_interval
        print(self.pull_agent_interval)

        self.neutron = None
        self._agents = None
        self._lb_members = None
        self.ovs_agents = {}
        self.lbaas_agents = {}
        self.lb_members = {}
        self.event_handlers = {
            cl_ev.GetOVSAgentRequest: self.reply_ovs_agents,
            cl_ev.GetLBMemberRequest: self.reply_lb_members
        }
        hub.spawn(self._get_neutron_client)
Example #8
0
    def run_service(self):
        wsgi_services = {}
        for name, app in self.apps.items():
            if app.wsgi_controller is None:
                continue
            wsgi_services[app.wsgi_controller] = app

        if len(wsgi_services) == 0:
            return

        wsgi_app = WSGIApplication()
        for controller, app in wsgi_services.items():
            wsgi_app.register(controller, data={app.__class__.__name__: app})

        wsgi_srv = WSGIServer(wsgi_app)
        wsgi_thread = hub.spawn(wsgi_srv)
        self.service_thread.append(wsgi_thread)
Example #9
0
 def delete_lb_member(self, ev):
     lb_members = ev.msg
     self.LOG.info("remove load balance pool members: %s",
                   [v.id for k, v in lb_members.items()])
     for ip, lb_member in lb_members.items():
         hub.spawn(self.neutron.neutron_client.delete_member, lb_member.id)