Esempio n. 1
0
 def setUp(self):
     super().setUp()
     self.app = flask.Flask(__name__)
     self.client = self.app.test_client()
     self._ctx = self.app.test_request_context()
     self._ctx.push()
     self.test_keepalived = keepalived.Keepalived()
Esempio n. 2
0
    def __init__(self):
        self.app = flask.Flask(__name__)
        self._osutils = osutils.BaseOS.get_os_util()
        self._keepalived = keepalived.Keepalived()
        self._loadbalancer = loadbalancer.Loadbalancer()
        self._udp_listener = (
            udp_listener_base.UdpListenerApiServerBase.get_server_driver())
        self._plug = plug.Plug(self._osutils)
        self._amphora_info = amphora_info.AmphoraInfo(self._osutils)

        register_app_error_handler(self.app)

        self.app.add_url_rule(rule='/',
                              view_func=self.version_discovery,
                              methods=['GET'])
        self.app.add_url_rule(rule=PATH_PREFIX +
                              '/loadbalancer/<amphora_id>/<lb_id>/haproxy',
                              view_func=self.upload_haproxy_config,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX +
                              '/listeners/<amphora_id>/<listener_id>'
                              '/udp_listener',
                              view_func=self.upload_udp_listener_config,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX +
                              '/loadbalancer/<lb_id>/haproxy',
                              view_func=self.get_haproxy_config,
                              methods=['GET'])
        self.app.add_url_rule(rule=PATH_PREFIX +
                              '/listeners/<listener_id>/udp_listener',
                              view_func=self.get_udp_listener_config,
                              methods=['GET'])
        self.app.add_url_rule(rule=PATH_PREFIX +
                              '/loadbalancer/<object_id>/<action>',
                              view_func=self.start_stop_lb_object,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/listeners/<object_id>',
                              view_func=self.delete_lb_object,
                              methods=['DELETE'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/config',
                              view_func=self.upload_config,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/details',
                              view_func=self.get_details,
                              methods=['GET'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/info',
                              view_func=self.get_info,
                              methods=['GET'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/listeners',
                              view_func=self.get_all_listeners_status,
                              methods=['GET'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/loadbalancer/<lb_id>'
                              '/certificates/<filename>',
                              view_func=self.upload_certificate,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/loadbalancer/<lb_id>'
                              '/certificates/<filename>',
                              view_func=self.get_certificate_md5,
                              methods=['GET'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/loadbalancer/<lb_id>'
                              '/certificates/<filename>',
                              view_func=self.delete_certificate,
                              methods=['DELETE'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/plug/vip/<vip>',
                              view_func=self.plug_vip,
                              methods=['POST'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/plug/network',
                              view_func=self.plug_network,
                              methods=['POST'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/certificate',
                              view_func=self.upload_cert,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/vrrp/upload',
                              view_func=self.upload_vrrp_config,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/vrrp/<action>',
                              view_func=self.manage_service_vrrp,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/interface/<ip_addr>',
                              view_func=self.get_interface,
                              methods=['GET'])