<s> from functools import wraps <EOL> import six <EOL> import pyrax <EOL> from pyrax . client import BaseClient <EOL> import pyrax . exceptions as exc <EOL> from pyrax . manager import BaseManager <EOL> from pyrax . resource import BaseResource <EOL> import pyrax . utils as utils <EOL> def assure_parent ( fnc ) : <EOL> @ wraps ( fnc ) <EOL> def wrapped ( self , * args , ** kwargs ) : <EOL> lb = self . parent <EOL> if not lb : <EOL> exc_class = { Node : exc . UnattachedNode , <EOL> VirtualIP : exc . UnattachedVirtualIP } [ self . __class__ ] <EOL> raise exc_class ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> return fnc ( self , * args , ** kwargs ) <EOL> return wrapped <EOL> def assure_loadbalancer ( fnc ) : <EOL> @ wraps ( fnc ) <EOL> def _wrapped ( self , loadbalancer , * args , ** kwargs ) : <EOL> if not isinstance ( loadbalancer , CloudLoadBalancer ) : <EOL> loadbalancer = self . _manager . get ( loadbalancer ) <EOL> return fnc ( self , loadbalancer , * args , ** kwargs ) <EOL> return _wrapped <EOL> class CloudLoadBalancer ( BaseResource ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> self . _connection_logging = None <EOL> self . _content_caching = None <EOL> self . _session_persistence = None <EOL> self . _non_display = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> super ( CloudLoadBalancer , self ) . __init__ ( * args , ** kwargs ) <EOL> def add_nodes ( self , nodes ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . add_nodes ( self , nodes ) <EOL> def add_virtualip ( self , vip ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . add_virtualip ( self , vip ) <EOL> def get_usage ( self , start = None , end = None ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . get_usage ( self , start = start , end = end ) <EOL> def get_stats ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . get_stats ( self ) <EOL> def _add_details ( self , info ) : <EOL> """<STR_LIT>""" <EOL> for ( key , val ) in six . iteritems ( info ) : <EOL> if key == "<STR_LIT>" : <EOL> val = [ Node ( parent = self , ** nd ) for nd in val ] <EOL> elif key == "<STR_LIT>" : <EOL> val = val [ '<STR_LIT>' ] <EOL> elif key == "<STR_LIT>" : <EOL> val = val [ '<STR_LIT:name>' ] <EOL> elif key == "<STR_LIT>" : <EOL> key = "<STR_LIT>" <EOL> val = [ VirtualIP ( parent = self , ** vip ) for vip in val ] <EOL> setattr ( self , key , val ) <EOL> def update ( self , name = None , algorithm = None , protocol = None , halfClosed = None , <EOL> port = None , timeout = None , httpsRedirect = None ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . update ( self , name = name , algorithm = algorithm , <EOL> protocol = protocol , halfClosed = halfClosed , port = port , <EOL> timeout = timeout , httpsRedirect = httpsRedirect ) <EOL> def delete_node ( self , node ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . delete_node ( self , node ) <EOL> def update_node ( self , node , diff = None ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . update_node ( node , diff = diff ) <EOL> def delete_virtualip ( self , vip ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . delete_virtualip ( self , vip ) <EOL> def get_access_list ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . get_access_list ( self ) <EOL> def add_access_list ( self , access_list ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . add_access_list ( self , access_list ) <EOL> def delete_access_list ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . delete_access_list ( self ) <EOL> def delete_access_list_items ( self , item_ids ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . delete_access_list_items ( self , item_ids ) <EOL> def get_health_monitor ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . get_health_monitor ( self ) <EOL> def add_health_monitor ( self , type , delay = <NUM_LIT:10> , timeout = <NUM_LIT:10> , <EOL> attemptsBeforeDeactivation = <NUM_LIT:3> , path = "<STR_LIT:/>" , statusRegex = None , <EOL> bodyRegex = None , hostHeader = None ) : <EOL> """<STR_LIT>""" <EOL> abd = attemptsBeforeDeactivation <EOL> return self . manager . add_health_monitor ( self , type = type , delay = delay , <EOL> timeout = timeout , attemptsBeforeDeactivation = abd , <EOL> path = path , statusRegex = statusRegex , bodyRegex = bodyRegex , <EOL> hostHeader = hostHeader ) <EOL> def delete_health_monitor ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . delete_health_monitor ( self ) <EOL> def get_connection_throttle ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . get_connection_throttle ( self ) <EOL> def add_connection_throttle ( self , maxConnectionRate = None , <EOL> maxConnections = None , minConnections = None , rateInterval = None ) : <EOL> """<STR_LIT>""" <EOL> if not any ( ( maxConnectionRate , maxConnections , minConnections , <EOL> rateInterval ) ) : <EOL> return <EOL> return self . manager . add_connection_throttle ( self , <EOL> maxConnectionRate = maxConnectionRate , maxConnections = maxConnections , <EOL> minConnections = minConnections , rateInterval = rateInterval ) <EOL> def delete_connection_throttle ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . delete_connection_throttle ( self ) <EOL> def get_ssl_termination ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . get_ssl_termination ( self ) <EOL> def add_ssl_termination ( self , securePort , privatekey , certificate , <EOL> intermediateCertificate = None , enabled = True , <EOL> secureTrafficOnly = False ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . add_ssl_termination ( self , securePort = securePort , <EOL> privatekey = privatekey , certificate = certificate , <EOL> intermediateCertificate = intermediateCertificate , <EOL> enabled = enabled , secureTrafficOnly = secureTrafficOnly ) <EOL> def update_ssl_termination ( self , securePort = None , enabled = None , <EOL> secureTrafficOnly = None ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . update_ssl_termination ( self , securePort = securePort , <EOL> enabled = enabled , secureTrafficOnly = secureTrafficOnly ) <EOL> def delete_ssl_termination ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . delete_ssl_termination ( self ) <EOL> def get_metadata ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . get_metadata ( self ) <EOL> def set_metadata ( self , metadata ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . set_metadata ( self , metadata ) <EOL> def update_metadata ( self , metadata ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . update_metadata ( self , metadata ) <EOL> def delete_metadata ( self , keys = None ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . delete_metadata ( self , keys = keys ) <EOL> def get_metadata_for_node ( self , node ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . get_metadata ( self , node = node ) <EOL> def set_metadata_for_node ( self , node , metadata ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . set_metadata ( self , metadata , node = node ) <EOL> def update_metadata_for_node ( self , node , metadata ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . update_metadata ( self , metadata , node = node ) <EOL> def delete_metadata_for_node ( self , node , keys = None ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . delete_metadata ( self , keys = keys , node = node ) <EOL> def get_error_page ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . get_error_page ( self ) <EOL> def set_error_page ( self , html ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . set_error_page ( self , html ) <EOL> def clear_error_page ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . clear_error_page ( self ) <EOL> def _get_connection_logging ( self ) : <EOL> if self . _connection_logging is None : <EOL> self . _connection_logging = self . manager . get_connection_logging ( self ) <EOL> return self . _connection_logging <EOL> def _set_connection_logging ( self , val ) : <EOL> self . manager . set_connection_logging ( self , val ) <EOL> self . _connection_logging = val <EOL> def _get_content_caching ( self ) : <EOL> if self . _content_caching is None : <EOL> self . _content_caching = self . manager . get_content_caching ( self ) <EOL> return self . _content_caching <EOL> def _set_content_caching ( self , val ) : <EOL> self . manager . set_content_caching ( self , val ) <EOL> self . _content_caching = val <EOL> def _get_session_persistence ( self ) : <EOL> if self . _session_persistence is None : <EOL> self . _session_persistence = self . manager . get_session_persistence ( self ) <EOL> return self . _session_persistence <EOL> def _set_session_persistence ( self , val ) : <EOL> if val : <EOL> if not isinstance ( val , six . string_types ) or ( val . upper ( ) not in <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> raise exc . InvalidSessionPersistenceType ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % val ) <EOL> self . manager . set_session_persistence ( self , val ) <EOL> self . _session_persistence = val . upper ( ) <EOL> else : <EOL> self . manager . delete_session_persistence ( self ) <EOL> self . _session_persistence = "<STR_LIT>" <EOL> connection_logging = property ( _get_connection_logging , <EOL> _set_connection_logging , None , "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> content_caching = property ( _get_content_caching , _set_content_caching , <EOL> None , "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> session_persistence = property ( _get_session_persistence , <EOL> _set_session_persistence , None , "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class CloudLoadBalancerManager ( BaseManager ) : <EOL> def update ( self , lb , name = None , algorithm = None , protocol = None , <EOL> halfClosed = None , port = None , timeout = None , httpsRedirect = None ) : <EOL> """<STR_LIT>""" <EOL> body = { } <EOL> if name is not None : <EOL> body [ "<STR_LIT:name>" ] = name <EOL> if algorithm is not None : <EOL> body [ "<STR_LIT>" ] = algorithm <EOL> if protocol is not None : <EOL> body [ "<STR_LIT>" ] = protocol <EOL> if halfClosed is not None : <EOL> body [ "<STR_LIT>" ] = halfClosed <EOL> if port is not None : <EOL> body [ "<STR_LIT:port>" ] = port <EOL> if timeout is not None : <EOL> body [ "<STR_LIT>" ] = timeout <EOL> if httpsRedirect is not None : <EOL> body [ "<STR_LIT>" ] = httpsRedirect <EOL> if not body : <EOL> return <EOL> body = { "<STR_LIT>" : body } <EOL> uri = "<STR_LIT>" % utils . get_id ( lb ) <EOL> try : <EOL> resp , resp_body = self . api . method_put ( uri , body = body ) <EOL> except exc . ClientException as e : <EOL> message = e . message <EOL> details = e . details <EOL> if message and details : <EOL> errmsg = "<STR_LIT>" % ( message , details ) <EOL> else : <EOL> errmsg = message <EOL> raise exc . InvalidLoadBalancerParameters ( errmsg ) <EOL> return resp , resp_body <EOL> def _create_body ( self , name , port = None , protocol = None , nodes = None , <EOL> virtual_ips = None , algorithm = None , halfClosed = None , accessList = None , <EOL> connectionLogging = None , connectionThrottle = None , healthMonitor = None , <EOL> metadata = None , timeout = None , sessionPersistence = None , <EOL> httpsRedirect = None ) : <EOL> """<STR_LIT>""" <EOL> required = ( virtual_ips , port , protocol ) <EOL> if not all ( required ) : <EOL> raise exc . MissingLoadBalancerParameters ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> nodes = utils . coerce_to_list ( nodes ) <EOL> virtual_ips = utils . coerce_to_list ( virtual_ips ) <EOL> bad_conditions = [ node . condition for node in nodes <EOL> if node . condition . upper ( ) not in ( "<STR_LIT>" , "<STR_LIT>" ) ] <EOL> if bad_conditions : <EOL> raise exc . InvalidNodeCondition ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> "<STR_LIT:U+002CU+0020>" . join ( set ( bad_conditions ) ) ) <EOL> node_dicts = [ nd . to_dict ( ) for nd in nodes ] <EOL> vip_dicts = [ vip . to_dict ( ) for vip in virtual_ips ] <EOL> body = { "<STR_LIT>" : { <EOL> "<STR_LIT:name>" : name , <EOL> "<STR_LIT:port>" : port , <EOL> "<STR_LIT>" : protocol , <EOL> "<STR_LIT>" : node_dicts , <EOL> "<STR_LIT>" : vip_dicts , <EOL> "<STR_LIT>" : algorithm or "<STR_LIT>" , <EOL> "<STR_LIT>" : halfClosed , <EOL> "<STR_LIT>" : accessList , <EOL> "<STR_LIT>" : connectionLogging , <EOL> "<STR_LIT>" : connectionThrottle , <EOL> "<STR_LIT>" : healthMonitor , <EOL> "<STR_LIT>" : metadata , <EOL> "<STR_LIT>" : timeout , <EOL> "<STR_LIT>" : sessionPersistence , <EOL> "<STR_LIT>" : httpsRedirect , <EOL> } } <EOL> return body <EOL> def add_nodes ( self , lb , nodes ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( nodes , ( list , tuple ) ) : <EOL> nodes = [ nodes ] <EOL> node_dicts = [ nd . to_dict ( ) for nd in nodes ] <EOL> resp , body = self . api . method_post ( "<STR_LIT>" % lb . id , <EOL> body = { "<STR_LIT>" : node_dicts } ) <EOL> return resp , body <EOL> def delete_node ( self , loadbalancer , node ) : <EOL> """<STR_LIT>""" <EOL> lb = node . parent <EOL> if not lb : <EOL> raise exc . UnattachedNode ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> resp , body = self . api . method_delete ( "<STR_LIT>" % <EOL> ( lb . id , node . id ) ) <EOL> return resp , body <EOL> def update_node ( self , node , diff = None ) : <EOL> """<STR_LIT>""" <EOL> lb = node . parent <EOL> if not lb : <EOL> raise exc . UnattachedNode ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if diff is None : <EOL> diff = node . _diff ( ) <EOL> req_body = { "<STR_LIT>" : diff } <EOL> resp , body = self . api . method_put ( "<STR_LIT>" % <EOL> ( lb . id , node . id ) , body = req_body ) <EOL> return resp , body <EOL> def add_virtualip ( self , lb , vip ) : <EOL> """<STR_LIT>""" <EOL> resp , body = self . api . method_post ( "<STR_LIT>" % lb . id , <EOL> body = vip . to_dict ( ) ) <EOL> return resp , body <EOL> def delete_virtualip ( self , loadbalancer , vip ) : <EOL> """<STR_LIT>""" <EOL> lb = vip . parent <EOL> if not lb : <EOL> raise exc . UnattachedVirtualIP ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> resp , body = self . api . method_delete ( "<STR_LIT>" % <EOL> ( lb . id , vip . id ) ) <EOL> return resp , body <EOL> def get_access_list ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_get ( uri ) <EOL> return body . get ( "<STR_LIT>" ) <EOL> def add_access_list ( self , loadbalancer , access_list ) : <EOL> """<STR_LIT>""" <EOL> req_body = { "<STR_LIT>" : access_list } <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_post ( uri , body = req_body ) <EOL> return body <EOL> def delete_access_list ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_delete ( uri ) <EOL> return body <EOL> def delete_access_list_items ( self , loadbalancer , item_ids ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( item_ids , ( list , tuple ) ) : <EOL> item_ids = [ item_ids ] <EOL> valid_ids = [ itm [ "<STR_LIT:id>" ] for itm in self . get_access_list ( loadbalancer ) ] <EOL> bad_ids = [ str ( itm ) for itm in item_ids if itm not in valid_ids ] <EOL> if bad_ids : <EOL> raise exc . AccessListIDNotFound ( "<STR_LIT>" <EOL> "<STR_LIT>" % "<STR_LIT:U+002CU+0020>" . join ( bad_ids ) ) <EOL> items = "<STR_LIT:&>" . join ( [ "<STR_LIT>" % item_id for item_id in item_ids ] ) <EOL> uri = "<STR_LIT>" % ( <EOL> utils . get_id ( loadbalancer ) , items ) <EOL> resp , body = self . api . method_delete ( uri ) <EOL> return body <EOL> def get_health_monitor ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_get ( uri ) <EOL> return body . get ( "<STR_LIT>" , { } ) <EOL> def add_health_monitor ( self , loadbalancer , type , delay = <NUM_LIT:10> , timeout = <NUM_LIT:10> , <EOL> attemptsBeforeDeactivation = <NUM_LIT:3> , path = "<STR_LIT:/>" , statusRegex = None , <EOL> bodyRegex = None , hostHeader = None ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> req_body = { "<STR_LIT>" : { <EOL> "<STR_LIT:type>" : type , <EOL> "<STR_LIT>" : delay , <EOL> "<STR_LIT>" : timeout , <EOL> "<STR_LIT>" : attemptsBeforeDeactivation , <EOL> } } <EOL> uptype = type . upper ( ) <EOL> if uptype . startswith ( "<STR_LIT>" ) : <EOL> lb = self . _get_lb ( loadbalancer ) <EOL> if uptype != lb . protocol : <EOL> raise exc . ProtocolMismatch ( "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( type , lb . protocol ) ) <EOL> if not all ( ( path , statusRegex , bodyRegex ) ) : <EOL> raise exc . MissingHealthMonitorSettings ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> body_hm = req_body [ "<STR_LIT>" ] <EOL> body_hm [ "<STR_LIT:path>" ] = path <EOL> body_hm [ "<STR_LIT>" ] = statusRegex <EOL> body_hm [ "<STR_LIT>" ] = bodyRegex <EOL> if hostHeader : <EOL> body_hm [ "<STR_LIT>" ] = hostHeader <EOL> resp , body = self . api . method_put ( uri , body = req_body ) <EOL> return body <EOL> def delete_health_monitor ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_delete ( uri ) <EOL> def get_connection_throttle ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_get ( uri ) <EOL> return body . get ( "<STR_LIT>" , { } ) <EOL> def add_connection_throttle ( self , loadbalancer , maxConnectionRate = None , <EOL> maxConnections = None , minConnections = None , rateInterval = None ) : <EOL> """<STR_LIT>""" <EOL> settings = { } <EOL> if maxConnectionRate : <EOL> settings [ "<STR_LIT>" ] = maxConnectionRate <EOL> if maxConnections : <EOL> settings [ "<STR_LIT>" ] = maxConnections <EOL> if minConnections : <EOL> settings [ "<STR_LIT>" ] = minConnections <EOL> if rateInterval : <EOL> settings [ "<STR_LIT>" ] = rateInterval <EOL> req_body = { "<STR_LIT>" : settings } <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_put ( uri , body = req_body ) <EOL> return body <EOL> def delete_connection_throttle ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_delete ( uri ) <EOL> def get_ssl_termination ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> try : <EOL> resp , body = self . api . method_get ( uri ) <EOL> except exc . NotFound : <EOL> return { } <EOL> return body . get ( "<STR_LIT>" , { } ) <EOL> def add_ssl_termination ( self , loadbalancer , securePort , privatekey , certificate , <EOL> intermediateCertificate , enabled = True , secureTrafficOnly = False ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> req_body = { "<STR_LIT>" : { <EOL> "<STR_LIT>" : certificate , <EOL> "<STR_LIT>" : enabled , <EOL> "<STR_LIT>" : secureTrafficOnly , <EOL> "<STR_LIT>" : privatekey , <EOL> "<STR_LIT>" : intermediateCertificate , <EOL> "<STR_LIT>" : securePort , <EOL> } } <EOL> resp , body = self . api . method_put ( uri , body = req_body ) <EOL> return body <EOL> def update_ssl_termination ( self , loadbalancer , securePort = None , enabled = None , <EOL> secureTrafficOnly = None ) : <EOL> """<STR_LIT>""" <EOL> ssl_info = self . get_ssl_termination ( loadbalancer ) <EOL> if not ssl_info : <EOL> raise exc . NoSSLTerminationConfiguration ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if securePort is None : <EOL> securePort = ssl_info [ "<STR_LIT>" ] <EOL> if enabled is None : <EOL> enabled = ssl_info [ "<STR_LIT>" ] <EOL> if secureTrafficOnly is None : <EOL> secureTrafficOnly = ssl_info [ "<STR_LIT>" ] <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> req_body = { "<STR_LIT>" : { <EOL> "<STR_LIT>" : enabled , <EOL> "<STR_LIT>" : secureTrafficOnly , <EOL> "<STR_LIT>" : securePort , <EOL> } } <EOL> resp , body = self . api . method_put ( uri , body = req_body ) <EOL> return body <EOL> def delete_ssl_termination ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_delete ( uri ) <EOL> def get_metadata ( self , loadbalancer , node = None , raw = False ) : <EOL> """<STR_LIT>""" <EOL> if node : <EOL> uri = "<STR_LIT>" % ( <EOL> utils . get_id ( loadbalancer ) , utils . get_id ( node ) ) <EOL> else : <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_get ( uri ) <EOL> meta = body . get ( "<STR_LIT>" , [ ] ) <EOL> if raw : <EOL> return meta <EOL> ret = dict ( [ ( itm [ "<STR_LIT:key>" ] , itm [ "<STR_LIT:value>" ] ) for itm in meta ] ) <EOL> return ret <EOL> def set_metadata ( self , loadbalancer , metadata , node = None ) : <EOL> """<STR_LIT>""" <EOL> self . delete_metadata ( loadbalancer , node = node ) <EOL> metadata_list = [ { "<STR_LIT:key>" : key , "<STR_LIT:value>" : val } <EOL> for key , val in metadata . items ( ) ] <EOL> if node : <EOL> uri = "<STR_LIT>" % ( <EOL> utils . get_id ( loadbalancer ) , utils . get_id ( node ) ) <EOL> else : <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> req_body = { "<STR_LIT>" : metadata_list } <EOL> resp , body = self . api . method_post ( uri , body = req_body ) <EOL> return body <EOL> def update_metadata ( self , loadbalancer , metadata , node = None ) : <EOL> """<STR_LIT>""" <EOL> md = self . get_metadata ( loadbalancer , raw = True ) <EOL> id_lookup = dict ( [ ( itm [ "<STR_LIT:key>" ] , itm [ "<STR_LIT:id>" ] ) for itm in md ] ) <EOL> metadata_list = [ ] <EOL> for key , val in metadata . items ( ) : <EOL> try : <EOL> meta_id = id_lookup [ key ] <EOL> if node : <EOL> uri = "<STR_LIT>" % ( <EOL> utils . get_id ( loadbalancer ) , utils . get_id ( node ) , <EOL> meta_id ) <EOL> else : <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> req_body = { "<STR_LIT>" : { "<STR_LIT:value>" : val } } <EOL> resp , body = self . api . method_put ( uri , body = req_body ) <EOL> except KeyError : <EOL> metadata_list . append ( { "<STR_LIT:key>" : key , "<STR_LIT:value>" : val } ) <EOL> if metadata_list : <EOL> if node : <EOL> uri = "<STR_LIT>" % ( <EOL> utils . get_id ( loadbalancer ) , utils . get_id ( node ) ) <EOL> else : <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> req_body = { "<STR_LIT>" : metadata_list } <EOL> resp , body = self . api . method_post ( uri , body = req_body ) <EOL> def delete_metadata ( self , loadbalancer , keys = None , node = None ) : <EOL> """<STR_LIT>""" <EOL> if keys and not isinstance ( keys , ( list , tuple ) ) : <EOL> keys = [ keys ] <EOL> md = self . get_metadata ( loadbalancer , node = node , raw = True ) <EOL> if keys : <EOL> md = [ dct for dct in md if dct [ "<STR_LIT:key>" ] in keys ] <EOL> if not md : <EOL> return <EOL> id_list = "<STR_LIT:&>" . join ( [ "<STR_LIT>" % itm [ "<STR_LIT:id>" ] for itm in md ] ) <EOL> if node : <EOL> uri = "<STR_LIT>" % ( <EOL> utils . get_id ( loadbalancer ) , utils . get_id ( node ) , id_list ) <EOL> else : <EOL> uri = "<STR_LIT>" % ( <EOL> utils . get_id ( loadbalancer ) , id_list ) <EOL> resp , body = self . api . method_delete ( uri ) <EOL> return body <EOL> def get_error_page ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_get ( uri ) <EOL> return body <EOL> def set_error_page ( self , loadbalancer , html ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> req_body = { "<STR_LIT>" : { "<STR_LIT:content>" : html } } <EOL> resp , body = self . api . method_put ( uri , body = req_body ) <EOL> return body <EOL> def clear_error_page ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_delete ( uri ) <EOL> return body <EOL> def get_usage ( self , loadbalancer = None , start = None , end = None ) : <EOL> """<STR_LIT>""" <EOL> if start is end is None : <EOL> period = None <EOL> else : <EOL> parts = [ ] <EOL> startStr = utils . iso_time_string ( start ) <EOL> if startStr : <EOL> parts . append ( "<STR_LIT>" % startStr ) <EOL> endStr = utils . iso_time_string ( end ) <EOL> if endStr : <EOL> parts . append ( "<STR_LIT>" % endStr ) <EOL> period = "<STR_LIT:&>" . join ( parts ) . strip ( "<STR_LIT:&>" ) <EOL> if loadbalancer is None : <EOL> uri = "<STR_LIT>" <EOL> else : <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> if period : <EOL> uri = "<STR_LIT>" % ( uri , period ) <EOL> resp , body = self . api . method_get ( uri ) <EOL> return body <EOL> def get_stats ( self , loadbalancer = None ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_get ( uri ) <EOL> return body <EOL> def get_session_persistence ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_get ( uri ) <EOL> ret = body [ "<STR_LIT>" ] . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> return ret <EOL> def set_session_persistence ( self , loadbalancer , val ) : <EOL> """<STR_LIT>""" <EOL> val = val . upper ( ) <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> req_body = { "<STR_LIT>" : { <EOL> "<STR_LIT>" : val , <EOL> } } <EOL> resp , body = self . api . method_put ( uri , body = req_body ) <EOL> return body <EOL> def delete_session_persistence ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_delete ( uri ) <EOL> return body <EOL> def get_connection_logging ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_get ( uri ) <EOL> ret = body . get ( "<STR_LIT>" , { } ) . get ( "<STR_LIT>" , False ) <EOL> return ret <EOL> def set_connection_logging ( self , loadbalancer , val ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> val = str ( val ) . lower ( ) <EOL> req_body = { "<STR_LIT>" : { <EOL> "<STR_LIT>" : val , <EOL> } } <EOL> resp , body = self . api . method_put ( uri , body = req_body ) <EOL> return body <EOL> def get_content_caching ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> resp , body = self . api . method_get ( uri ) <EOL> ret = body . get ( "<STR_LIT>" , { } ) . get ( "<STR_LIT>" , False ) <EOL> return ret <EOL> def set_content_caching ( self , loadbalancer , val ) : <EOL> """<STR_LIT>""" <EOL> uri = "<STR_LIT>" % utils . get_id ( loadbalancer ) <EOL> val = str ( val ) . lower ( ) <EOL> req_body = { "<STR_LIT>" : { <EOL> "<STR_LIT>" : val , <EOL> } } <EOL> resp , body = self . api . method_put ( uri , body = req_body ) <EOL> return body <EOL> def _get_lb ( self , lb_or_id ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( lb_or_id , CloudLoadBalancer ) : <EOL> ret = lb_or_id <EOL> else : <EOL> ret = self . get ( lb_or_id ) <EOL> return ret <EOL> class Node ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , address = None , port = None , condition = None , weight = None , <EOL> status = None , parent = None , type = None , id = None ) : <EOL> if condition is None : <EOL> condition = "<STR_LIT>" <EOL> if not all ( ( address , port ) ) : <EOL> raise exc . InvalidNodeParameters ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . address = address <EOL> self . port = port <EOL> self . condition = condition <EOL> if weight is None : <EOL> weight = <NUM_LIT:1> <EOL> self . weight = weight <EOL> self . status = status <EOL> self . parent = parent <EOL> self . type = type <EOL> self . id = id <EOL> self . _original_state = self . to_dict ( ) <EOL> def __repr__ ( self ) : <EOL> tmp = "<STR_LIT>" <EOL> return tmp % ( self . type , self . condition , self . id , self . address , self . port , <EOL> self . weight ) <EOL> def __eq__ ( self , other ) : <EOL> return ( isinstance ( other , self . __class__ ) and <EOL> self . __dict__ == other . __dict__ ) <EOL> def __ne__ ( self , other ) : <EOL> return not self . __eq__ ( other ) <EOL> def to_dict ( self ) : <EOL> """<STR_LIT>""" <EOL> return { "<STR_LIT:address>" : self . address , <EOL> "<STR_LIT:port>" : self . port , <EOL> "<STR_LIT>" : self . condition , <EOL> "<STR_LIT:type>" : self . type , <EOL> "<STR_LIT:id>" : self . id , <EOL> } <EOL> def get_metadata ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . parent . get_metadata_for_node ( self ) <EOL> def set_metadata ( self , metadata ) : <EOL> """<STR_LIT>""" <EOL> return self . parent . set_metadata_for_node ( self , metadata ) <EOL> def update_metadata ( self , metadata ) : <EOL> """<STR_LIT>""" <EOL> return self . parent . update_metadata_for_node ( self , metadata ) <EOL> def delete_metadata ( self , keys = None ) : <EOL> """<STR_LIT>""" <EOL> return self . parent . delete_metadata_for_node ( self , keys = keys ) <EOL> @ assure_parent <EOL> def delete ( self ) : <EOL> """<STR_LIT>""" <EOL> self . parent . delete_node ( self ) <EOL> def _diff ( self ) : <EOL> diff_dict = { } <EOL> for att , val in self . _original_state . items ( ) : <EOL> curr = getattr ( self , att ) <EOL> if curr != val : <EOL> diff_dict [ att ] = curr <EOL> return diff_dict <EOL> @ assure_parent <EOL> def update ( self ) : <EOL> """<STR_LIT>""" <EOL> diff = self . _diff ( ) <EOL> if not diff : <EOL> return <EOL> self . parent . update_node ( self , diff ) <EOL> def get_device ( self ) : <EOL> """<STR_LIT>""" <EOL> addr = self . address <EOL> servers = [ server for server in pyrax . cloudservers . list ( ) <EOL> if addr in server . networks . get ( "<STR_LIT>" , "<STR_LIT>" ) ] <EOL> try : <EOL> return servers [ <NUM_LIT:0> ] <EOL> except IndexError : <EOL> return None <EOL> class VirtualIP ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type = None , address = None , ipVersion = None , id = None , <EOL> parent = None ) : <EOL> if type is None : <EOL> type = "<STR_LIT>" <EOL> if type . upper ( ) not in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> raise exc . InvalidVirtualIPType ( "<STR_LIT>" <EOL> "<STR_LIT>" % type ) <EOL> if not ipVersion : <EOL> ipVersion = "<STR_LIT>" <EOL> if not ipVersion . upper ( ) in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> raise exc . InvalidVirtualIPVersion ( "<STR_LIT>" <EOL> "<STR_LIT>" % ipVersion ) <EOL> self . type = type <EOL> self . address = address <EOL> self . ip_version = ipVersion <EOL> self . id = id <EOL> self . parent = parent <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( <EOL> self . type , self . id , self . address , self . ip_version ) <EOL> def to_dict ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . id : <EOL> return { "<STR_LIT:id>" : self . id } <EOL> return { "<STR_LIT:type>" : self . type , "<STR_LIT>" : self . ip_version } <EOL> @ assure_parent <EOL> def delete ( self ) : <EOL> self . parent . delete_virtualip ( self ) <EOL> class CloudLoadBalancerClient ( BaseClient ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> self . Node = Node <EOL> self . VirtualIP = VirtualIP <EOL> self . _algorithms = None <EOL> self . _protocols = None <EOL> self . _allowed_domains = None <EOL> super ( CloudLoadBalancerClient , self ) . __init__ ( * args , ** kwargs ) <EOL> def _configure_manager ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _manager = CloudLoadBalancerManager ( self , <EOL> resource_class = CloudLoadBalancer , <EOL> response_key = "<STR_LIT>" , uri_base = "<STR_LIT>" ) <EOL> def get_usage ( self , loadbalancer = None , start = None , end = None ) : <EOL> """<STR_LIT>""" <EOL> return self . _manager . get_usage ( loadbalancer = loadbalancer , start = start , <EOL> end = end ) <EOL> @ property <EOL> def allowed_domains ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _allowed_domains is None : <EOL> uri = "<STR_LIT>" <EOL> resp , body = self . method_get ( uri ) <EOL> dom_list = body [ "<STR_LIT>" ] <EOL> self . _allowed_domains = [ itm [ "<STR_LIT>" ] [ "<STR_LIT:name>" ] <EOL> for itm in dom_list ] <EOL> return self . _allowed_domains <EOL> @ property <EOL> def algorithms ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _algorithms is None : <EOL> uri = "<STR_LIT>" <EOL> resp , body = self . method_get ( uri ) <EOL> self . _algorithms = [ alg [ "<STR_LIT:name>" ] for alg in body [ "<STR_LIT>" ] ] <EOL> return self . _algorithms <EOL> @ property <EOL> def protocols ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _protocols is None : <EOL> uri = "<STR_LIT>" <EOL> resp , body = self . method_get ( uri ) <EOL> self . _protocols = [ proto [ "<STR_LIT:name>" ] for proto in body [ "<STR_LIT>" ] ] <EOL> return self . _protocols <EOL> @ assure_loadbalancer <EOL> def update ( self , loadbalancer , name = None , algorithm = None , protocol = None , <EOL> halfClosed = None , port = None , timeout = None , httpsRedirect = None ) : <EOL> """<STR_LIT>""" <EOL> return self . _manager . update ( loadbalancer , name = name , <EOL> algorithm = algorithm , protocol = protocol , halfClosed = halfClosed , <EOL> port = port , timeout = timeout , httpsRedirect = httpsRedirect ) <EOL> @ assure_loadbalancer <EOL> def add_nodes ( self , loadbalancer , nodes ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . add_nodes ( nodes ) <EOL> @ assure_loadbalancer <EOL> def add_virtualip ( self , loadbalancer , vip ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . add_virtualip ( vip ) <EOL> def delete_node ( self , node ) : <EOL> """<STR_LIT>""" <EOL> return node . delete ( ) <EOL> def update_node ( self , node ) : <EOL> """<STR_LIT>""" <EOL> return node . update ( ) <EOL> def delete_virtualip ( self , vip ) : <EOL> """<STR_LIT>""" <EOL> return vip . delete ( ) <EOL> @ assure_loadbalancer <EOL> def get_access_list ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . get_access_list ( ) <EOL> @ assure_loadbalancer <EOL> def add_access_list ( self , loadbalancer , access_list ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . add_access_list ( access_list ) <EOL> @ assure_loadbalancer <EOL> def delete_access_list ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . delete_access_list ( ) <EOL> @ assure_loadbalancer <EOL> def delete_access_list_items ( self , loadbalancer , item_ids ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . delete_access_list_items ( item_ids ) <EOL> @ assure_loadbalancer <EOL> def get_health_monitor ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . get_health_monitor ( ) <EOL> @ assure_loadbalancer <EOL> def add_health_monitor ( self , loadbalancer , type , delay = <NUM_LIT:10> , timeout = <NUM_LIT:10> , <EOL> attemptsBeforeDeactivation = <NUM_LIT:3> , path = "<STR_LIT:/>" , statusRegex = None , <EOL> bodyRegex = None , hostHeader = None ) : <EOL> """<STR_LIT>""" <EOL> abd = attemptsBeforeDeactivation <EOL> return loadbalancer . add_health_monitor ( type = type , delay = delay , <EOL> timeout = timeout , attemptsBeforeDeactivation = abd , path = path , <EOL> statusRegex = statusRegex , bodyRegex = bodyRegex , <EOL> hostHeader = hostHeader ) <EOL> @ assure_loadbalancer <EOL> def delete_health_monitor ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . delete_health_monitor ( ) <EOL> @ assure_loadbalancer <EOL> def get_connection_throttle ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . get_connection_throttle ( ) <EOL> @ assure_loadbalancer <EOL> def add_connection_throttle ( self , loadbalancer , maxConnectionRate = None , <EOL> maxConnections = None , minConnections = None , rateInterval = None ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . add_connection_throttle ( <EOL> maxConnectionRate = maxConnectionRate , maxConnections = maxConnections , <EOL> minConnections = minConnections , rateInterval = rateInterval ) <EOL> @ assure_loadbalancer <EOL> def delete_connection_throttle ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . delete_connection_throttle ( ) <EOL> @ assure_loadbalancer <EOL> def get_ssl_termination ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . get_ssl_termination ( ) <EOL> @ assure_loadbalancer <EOL> def add_ssl_termination ( self , loadbalancer , securePort , privatekey , <EOL> certificate , intermediateCertificate , enabled = True , <EOL> secureTrafficOnly = False ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . add_ssl_termination ( securePort = securePort , <EOL> privatekey = privatekey , certificate = certificate , <EOL> intermediateCertificate = intermediateCertificate , <EOL> enabled = enabled , secureTrafficOnly = secureTrafficOnly ) <EOL> @ assure_loadbalancer <EOL> def update_ssl_termination ( self , loadbalancer , securePort = None , enabled = None , <EOL> secureTrafficOnly = None ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . update_ssl_termination ( securePort = securePort , <EOL> enabled = enabled , secureTrafficOnly = secureTrafficOnly ) <EOL> @ assure_loadbalancer <EOL> def delete_ssl_termination ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . delete_ssl_termination ( ) <EOL> @ assure_loadbalancer <EOL> def get_metadata ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . get_metadata ( ) <EOL> @ assure_loadbalancer <EOL> def set_metadata ( self , loadbalancer , metadata ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . set_metadata ( metadata ) <EOL> @ assure_loadbalancer <EOL> def update_metadata ( self , loadbalancer , metadata ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . update_metadata ( metadata ) <EOL> @ assure_loadbalancer <EOL> def delete_metadata ( self , loadbalancer , keys = None ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . delete_metadata ( keys = keys ) <EOL> @ assure_loadbalancer <EOL> def get_metadata_for_node ( self , loadbalancer , node ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . get_metadata_for_node ( node ) <EOL> @ assure_loadbalancer <EOL> def set_metadata_for_node ( self , loadbalancer , node , metadata ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . set_metadata_for_node ( node , metadata ) <EOL> @ assure_loadbalancer <EOL> def update_metadata_for_node ( self , loadbalancer , node , metadata ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . update_metadata_for_node ( node , metadata ) <EOL> @ assure_loadbalancer <EOL> def delete_metadata_for_node ( self , loadbalancer , node , keys = None ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . delete_metadata_for_node ( node , keys = keys ) <EOL> @ assure_loadbalancer <EOL> def get_error_page ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . get_error_page ( ) <EOL> @ assure_loadbalancer <EOL> def set_error_page ( self , loadbalancer , html ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . set_error_page ( html ) <EOL> @ assure_loadbalancer <EOL> def clear_error_page ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . clear_error_page ( ) <EOL> @ assure_loadbalancer <EOL> def get_connection_logging ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . connection_logging <EOL> @ assure_loadbalancer <EOL> def set_connection_logging ( self , loadbalancer , val ) : <EOL> """<STR_LIT>""" <EOL> loadbalancer . connection_logging = val <EOL> @ assure_loadbalancer <EOL> def get_content_caching ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . content_caching <EOL> @ assure_loadbalancer <EOL> def set_content_caching ( self , loadbalancer , val ) : <EOL> """<STR_LIT>""" <EOL> loadbalancer . content_caching = val <EOL> @ assure_loadbalancer <EOL> def get_session_persistence ( self , loadbalancer ) : <EOL> """<STR_LIT>""" <EOL> return loadbalancer . session_persistence <EOL> @ assure_loadbalancer <EOL> def set_session_persistence ( self , loadbalancer , val ) : <EOL> """<STR_LIT>""" <EOL> loadbalancer . session_persistence = val </s>
