Ejemplo n.º 1
0
 def setUp(self):
     super(ListenerTestCase, self).setUp()
     self.jinja_cfg = jinja_cfg.JinjaTemplater(base_amp_path=BASE_AMP_PATH,
                                               base_crt_dir=BASE_CRT_PATH)
     self.mock_platform = mock.patch("distro.id").start()
     self.mock_platform.return_value = "ubuntu"
     self.test_listener = listener.Listener()
Ejemplo n.º 2
0
    def __init__(self):
        self.app = flask.Flask(__name__)
        self._osutils = osutils.BaseOS.get_os_util()
        self._keepalived = keepalived.Keepalived()
        self._listener = listener.Listener()
        self._udp_listener = (
            udp_listener_base.UdpListenerApiServerBase.get_server_driver())
        self._bgpserver = bgp_base.BgpServer.get_bgpserver()
        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=PATH_PREFIX +
                              '/listeners/<amphora_id>/<listener_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 +
                              '/listeners/<listener_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 +
                              '/listeners/<listener_id>/<action>',
                              view_func=self.start_stop_listener,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/listeners/<listener_id>',
                              view_func=self.delete_listener,
                              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 + '/listeners/<listener_id>',
                              view_func=self.get_listener_status,
                              methods=['GET'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/listeners/<listener_id>'
                              '/certificates/<filename>',
                              view_func=self.upload_certificate,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/listeners/<listener_id>'
                              '/certificates/<filename>',
                              view_func=self.get_certificate_md5,
                              methods=['GET'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/listeners/<listener_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'])

        self.app.add_url_rule(rule=PATH_PREFIX + '/bgp/upload',
                              view_func=self.upload_bgp_config,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/bgp/<action>',
                              view_func=self.manage_service_bgp,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/bgp/register_amphora',
                              view_func=self.bgp_register_amphora,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/bgp/unregister_amphora',
                              view_func=self.bgp_unregister_amphora,
                              methods=['PUT'])
        self.app.add_url_rule(rule=PATH_PREFIX + '/bgp/status',
                              view_func=self.get_bgpserver_status,
                              methods=['GET'])