Пример #1
0
    def __init__(self):

        # Read config values
        midonet_conf = cfg.CONF.MIDONET
        midonet_uri = midonet_conf.midonet_uri
        admin_user = midonet_conf.username
        admin_pass = midonet_conf.password
        admin_project_id = midonet_conf.project_id
        provider_router_id = midonet_conf.provider_router_id
        metadata_router_id = midonet_conf.metadata_router_id
        mode = midonet_conf.mode

        self.mido_api = api.MidonetApi(midonet_uri,
                                       admin_user,
                                       admin_pass,
                                       project_id=admin_project_id)
        self.client = midonet_lib.MidoClient(self.mido_api)

        if provider_router_id and metadata_router_id:
            # get MidoNet provider router and metadata router
            self.provider_router = self.client.get_router(provider_router_id)
            self.metadata_router = self.client.get_router(metadata_router_id)

        elif not provider_router_id or not metadata_router_id:
            if mode == 'dev':
                msg = _('No provider router and metadata device ids found. '
                        'But skipping because running in dev env.')
                LOG.debug(msg)
            else:
                msg = _('provider_router_id and metadata_router_id '
                        'should be configured in the plugin config file')
                LOG.exception(msg)
                raise MidonetPluginException(msg=msg)

        db.configure_db()
Пример #2
0
    def __init__(self):

        # Read config values
        midonet_conf = cfg.CONF.MIDONET
        midonet_uri = midonet_conf.midonet_uri
        admin_user = midonet_conf.username
        admin_pass = midonet_conf.password
        admin_project_id = midonet_conf.project_id
        provider_router_id = midonet_conf.provider_router_id
        mode = midonet_conf.mode

        self.mido_api = api.MidonetApi(midonet_uri, admin_user,
                                       admin_pass,
                                       project_id=admin_project_id)
        self.client = midonet_lib.MidoClient(self.mido_api)

        if provider_router_id:
            self.provider_router = self.client.get_router(provider_router_id)
        else:
            msg = _('provider_router_id should be configured in the plugin '
                    'config file')
            LOG.exception(msg)
            raise MidonetPluginException(msg=msg)

        db.configure_db()
Пример #3
0
 def __init__(self):
     self.config = cfg.CONF.MIDONET
     self.mn_api = api.MidonetApi(self.config.midonet_uri,
                                  self.config.username,
                                  self.config.password,
                                  project_id=self.config.project_id)
     self.n_ctx = ncntxt.get_admin_context()
Пример #4
0
def get_mido_api():
    global mido_api
    if mido_api == None:
        mido_api = api.MidonetApi(CONF.MIDONET.midonet_uri,
                                  CONF.MIDONET.username, CONF.MIDONET.password,
                                  CONF.MIDONET.project_id)

    return mido_api
Пример #5
0
    def __init__(self, conf):
        super(MidonetInterfaceDriver, self).__init__(conf)
        # Read config values
        midonet_conf = conf.MIDONET
        midonet_uri = midonet_conf.midonet_uri
        admin_user = midonet_conf.username
        admin_pass = midonet_conf.password
        admin_project_id = midonet_conf.project_id

        self.mido_api = api.MidonetApi(midonet_uri, admin_user,
                                       admin_pass,
                                       project_id=admin_project_id)
Пример #6
0
    def __init__(self):

        # Read config values
        midonet_conf = cfg.CONF.MIDONET
        midonet_uri = midonet_conf.midonet_uri
        admin_user = midonet_conf.username
        admin_pass = midonet_conf.password
        admin_project_id = midonet_conf.project_id
        provider_router_id = midonet_conf.provider_router_id
        metadata_router_id = midonet_conf.metadata_router_id
        mode = midonet_conf.mode

        self.mido_api = api.MidonetApi(midonet_uri,
                                       admin_user,
                                       admin_pass,
                                       project_id=admin_project_id)

        # get MidoNet provider router and metadata router
        if provider_router_id and metadata_router_id:
            self.provider_router = self.mido_api.get_router(provider_router_id)
            self.metadata_router = self.mido_api.get_router(metadata_router_id)

        # for dev purpose only
        elif mode == 'dev':
            msg = _('No provider router and metadata device ids found. '
                    'But skipping because running in dev env.')
            LOG.debug(msg)
        else:
            msg = _('provider_router_id and metadata_router_id '
                    'should be configured in the plugin config file')
            LOG.exception(msg)
            raise MidonetPluginException(msg=msg)

        self.chain_manager = midonet_lib.ChainManager(self.mido_api)
        self.pg_manager = midonet_lib.PortGroupManager(self.mido_api)
        self.rule_manager = midonet_lib.RuleManager(self.mido_api)

        db.configure_db()
Пример #7
0
    def __init__(self):
        # Read config values
        midonet_conf = cfg.CONF.MIDONET
        midonet_uri = midonet_conf.midonet_uri
        admin_user = midonet_conf.username
        admin_pass = midonet_conf.password
        admin_project_id = midonet_conf.project_id
        self.provider_router_id = midonet_conf.provider_router_id
        self.provider_router = None

        self.mido_api = api.MidonetApi(midonet_uri, admin_user,
                                       admin_pass,
                                       project_id=admin_project_id)
        self.client = midonet_lib.MidoClient(self.mido_api)

        # self.provider_router_id should have been set.
        if self.provider_router_id is None:
            msg = _('provider_router_id should be configured in the plugin '
                    'config file')
            LOG.exception(msg)
            raise MidonetPluginException(msg=msg)

        self.setup_rpc()
        db.configure_db()
#!/usr/bin/env python

import logging
import time

from midonetclient import api

logging.basicConfig(level=logging.DEBUG)

args = {
    'base_uri': "http://127.0.0.1:8080",
    #'base_uri': "http://127.0.0.1:8080/midonet",
    #'base_uri': "http://127.0.0.1:8080/midonet-api",
    'username': '******',
    'password': '******',
    'project_id': 'service',
}

mido = api.MidonetApi(**args)

for h in mido.get_hosts():
    print h.get_name()

time.sleep(2)

for h in mido.get_hosts():
    print h.get_name()