Exemplo n.º 1
0
def register(tunnel_zone, encapsulation, midonet_url, username, password,
             project, etcd_host, etcd_port):
    """Watches cluster store and registers the hosts into the MidoNet cluster

    It watches /midonet/agents/[uuid] keys and values and adds them to the
    specified tunnel zone
    """
    etclient = etcd.Client(host=etcd_host, port=etcd_port)
    midoclient = mc.MidonetClient(midonet_url,
                                  username,
                                  password,
                                  project_id=project)
    tz = _ensure_tunnel_zone(midoclient, tunnel_zone, encapsulation)
    uuids = set(host.get_host_id() for host in tz.get_hosts())

    current_index, uuids = _catchup(etclient, tz, uuids)
    for event in etclient.eternal_watch(KEY,
                                        index=current_index,
                                        recursive=True):
        for host in event.get_subtree(leaves_only=True):
            # TODO: get when an event is removed
            if host.key in uuids:
                logging.info('Host %s already in tunnel zone %s', host.key,
                             host.value)
            else:
                try:
                    _add_to_tunnel_zone(tunnel_zone, host.key, host.value)
                except Exception:
                    continue  # at least try to add the rest
                else:
                    uuids.add(host.key)
Exemplo n.º 2
0
    def __init__(self):
        super(MidonetMixin, self).__init__()

        # Instantiate MidoNet API client
        conf = cfg.CONF.MIDONET
        neutron_extensions.append_api_extensions_path(extensions.__path__)
        self.api_cli = client.MidonetClient(conf.midonet_uri,
                                            conf.username,
                                            conf.password,
                                            project_id=conf.project_id)

        self.setup_rpc()

        self.base_binding_dict = {
            portbindings.VIF_TYPE: portbindings.VIF_TYPE_MIDONET,
            portbindings.VNIC_TYPE: portbindings.VNIC_NORMAL,
            portbindings.VIF_DETAILS: {
                # TODO(rkukura): Replace with new VIF security details
                portbindings.CAP_PORT_FILTER:
                'security-group' in self.supported_extension_aliases
            }
        }
        self.network_scheduler = importutils.import_object(
            cfg.CONF.network_scheduler_driver)
Exemplo n.º 3
0
 def __init__(self, conf):
     self.api_cli = client.MidonetClient(conf.midonet_uri, conf.username,
                                         conf.password,
                                         project_id=conf.project_id)