コード例 #1
0
    def run(self):
        # HaproxyConfBuilder
        # from the current haproxy config
        # update config
        # replace the config

        #def add(self, protocol, port, instances=[]):
        #instance = {hostname , port, protocol=None )
        builder = ConfBuilderHaproxy(CONF_FILE)
        instances = []

        for host in self.__listener.instances():
            instance = {
                'hostname': host,
                'port': self.__listener.instance_port(),
                'protocol': self.__listener.instance_protocol()
            }
            instances.append(instance)
        try:
            comment = None
            if self.__listener.loadbalancer() is not None:
                comment = "lb-%s" % self.__listener.loadbalancer()
            builder.add(protocol=self.__listener.protocol(),
                        port=self.__listener.port(),
                        instances=instances,
                        cookie_name=self.__listener.app_cookie_name(),
                        cookie_expire=self.__listener.lb_cookie_expiration(),
                        comment=comment).build(CONF_FILE)
        except Exception, err:
            self.__status = ProxyAction.STATUS_ERROR
            servo.log.error('failed to add new frontend to the config: %s' %
                            err)
            return
コード例 #2
0
 def run(self):
     builder = ConfBuilderHaproxy(CONF_FILE)
     portToRemove = self.__listener.port()
     try: 
         builder.remove_protocol_port(portToRemove).build(CONF_FILE)
     except Exception, err:
         self.__status =ProxyAction.STATUS_ERROR
         raise Exception("failed to remove the port from the haproxy config: %s" % err)
コード例 #3
0
    def run(self):
        # HaproxyConfBuilder 
        # from the current haproxy config
        # update config
        # replace the config
        
        #def add(self, protocol, port, instances=[]):
        #instance = {hostname , port, protocol=None )
        builder = ConfBuilderHaproxy(CONF_FILE, self.__listener.loadbalancer()) 
        instances = []

        for host in self.__listener.instances():
            instance = {'hostname':host, 'port': self.__listener.instance_port(), 'protocol': self.__listener.instance_protocol()}
            instances.append(instance)

        #in case of https/ssl protocol, download server certificate from EUARE
        if (self.__listener.protocol() == 'https' or self.__listener.protocol() == 'ssl') and self.__listener.ssl_cert_arn() != None:
            try:
                f = FloppyCredential() 
            except Exception, err:
                raise Exception('failed to get credentials from floppy: %s' % err)
 
            try:
                access_key_id = config.get_access_key_id()
                secret_access_key = config.get_secret_access_key()
                security_token = config.get_security_token()
                con = servo.ws.connect_euare(aws_access_key_id = access_key_id, aws_secret_access_key=secret_access_key, security_token=security_token)
                cert_arn = self.__listener.ssl_cert_arn().strip()
                cert= con.download_server_certificate(f.get_instance_pub_key(), f.get_instance_pk(), f.get_iam_pub_key(), f.get_iam_token(), cert_arn)
            except Exception, err:
                raise Exception('failed to download the server certificate: %s' % err)
コード例 #4
0
    def run(self):
        # HaproxyConfBuilder 
        # from the current haproxy config
        # update config
        # replace the config
        
        #def add(self, protocol, port, instances=[]):
        #instance = {hostname , port, protocol=None )
        builder = ConfBuilderHaproxy(CONF_FILE) 
        instances = []

        for host in self.__listener.instances():
            instance = {'hostname':host, 'port': self.__listener.instance_port(), 'protocol': self.__listener.instance_protocol()}
            instances.append(instance)
        try: 
            comment=None
            if self.__listener.loadbalancer() is not None:
                comment="lb-%s" % self.__listener.loadbalancer()
            builder.add(protocol=self.__listener.protocol(), port=self.__listener.port(), instances=instances, cookie_name=self.__listener.app_cookie_name(), cookie_expire=self.__listener.lb_cookie_expiration(), comment=comment).build(CONF_FILE)
        except Exception, err:
            self.__status =ProxyAction.STATUS_ERROR
            servo.log.error('failed to add new frontend to the config: %s' % err)
            return