示例#1
0
 def __init__(self, on_shared_storage):
     self._logger = logging.getLogger(__name__)
     openrc = common.read_config('keystone_authtoken')
     self._nova = client.Client(2,
                                openrc['admin_user'],
                                openrc['admin_password'],
                                openrc['admin_tenant_name'],
                                openrc['auth_uri'])
     self._on_shared_storage = on_shared_storage
示例#2
0
    def __init__(self):
        self._logger = logging.getLogger(__name__)

        conf = common.read_config("default")

        self._exchange = conf["exchange"]
        self._nova = NovaWrapper(conf["on_shared_storage"])

        credentials = pika.PlainCredentials(conf["user"], conf["password"])

        connection = None
        for host in conf["hosts"]:
            try:
                connection = pika.BlockingConnection(
                    pika.ConnectionParameters(host=host, port=conf["port"], credentials=credentials)
                )
                self._logger.info("Connected to %s", str(host))
                break
            except Exception as err:
                self._logger.warning("Cannot connect to host %s", host)
                self._logger.debug(str(err))

        self._channel = connection.channel()
        self._channel.exchange_declare(exchange=conf["exchange"], type="direct", auto_delete=True)