
This adds a new IP manager driver for configuring addresses and routes via keepalived instead of directly. It used when the logical resource is configured to be highly-available, according to configuration pushed by the orchestrator. We rely on a 'ha_resource' flag attached to the main config dict to enable it, and use specific HA config about peers and cluster priority contained in the 'ha_config' section of the main config. The resulting keepalived cluster contains a VRRP instance for each interface, with the exception of the management interface. Partially-implements: blueprint appliance-ha Change-Id: I5ababa41d65642b00f6b808197af9b2a59ebc67a
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
# Copyright 2014 DreamHost, LLC
|
|
#
|
|
# Author: DreamHost, LLC
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
|
|
"""Set up the API server application instance
|
|
"""
|
|
import flask
|
|
|
|
from astara_router.api import v1
|
|
from astara_router.debug import handle_traceback
|
|
from astara_router.manager import manager
|
|
|
|
app = flask.Flask(__name__)
|
|
app.register_blueprint(v1.base.blueprint)
|
|
app.register_blueprint(v1.system.blueprint)
|
|
app.register_blueprint(v1.firewall.blueprint)
|
|
app.register_blueprint(v1.status.blueprint)
|
|
app.register_error_handler(500, handle_traceback)
|
|
|
|
|
|
@app.before_request
|
|
def attach_config():
|
|
'''
|
|
Attach any configuration before instantiating API
|
|
'''
|
|
pass
|
|
|
|
|
|
def main():
|
|
# TODO(mark): make this use a config file ie
|
|
# app.config.from_object('astara_router.config.Default')
|
|
# manager.state_path = app.config['STATE_PATH']
|
|
|
|
addr = str(manager.ip_mgr.get_interfaces()[0].addresses[0])
|
|
app.run(host=addr,
|
|
port=5000)
|