<s> from functools import wraps <EOL> import time <EOL> from oslo_log import log as logging <EOL> from neutron . api . v2 import attributes <EOL> LOG = logging . getLogger ( __name__ ) <EOL> MAX_ATTEMPTS = <NUM_LIT:4> <EOL> SECONDS_BETWEEN_ATTEMPTS = <NUM_LIT:3> <EOL> BACKOFF_MULTIPLIER = <NUM_LIT:2> <EOL> def retry ( ExceptionToCheck , tries = MAX_ATTEMPTS , delay = SECONDS_BETWEEN_ATTEMPTS , <EOL> backoff = BACKOFF_MULTIPLIER ) : <EOL> """<STR_LIT>""" <EOL> def deco_retry ( f ) : <EOL> @ wraps ( f ) <EOL> def f_retry ( * args , ** kwargs ) : <EOL> mtries , mdelay = tries , delay <EOL> while mtries > <NUM_LIT:1> : <EOL> try : <EOL> return f ( * args , ** kwargs ) <EOL> except ExceptionToCheck as e : <EOL> LOG . debug ( "<STR_LIT>" , <EOL> { '<STR_LIT>' : str ( e ) , '<STR_LIT>' : mdelay } ) <EOL> time . sleep ( mdelay ) <EOL> mtries -= <NUM_LIT:1> <EOL> mdelay *= backoff <EOL> return f ( * args , ** kwargs ) <EOL> return f_retry <EOL> return deco_retry <EOL> class PluggingDriverUtilsMixin ( object ) : <EOL> def _mgmt_subnet_spec ( self , context , mgmt_context ) : <EOL> ip_addr = mgmt_context . get ( '<STR_LIT>' , <EOL> attributes . ATTR_NOT_SPECIFIED ) <EOL> if ip_addr and ip_addr != attributes . ATTR_NOT_SPECIFIED : <EOL> nw = self . _core_plugin . get_network ( context , <EOL> mgmt_context [ '<STR_LIT>' ] ) <EOL> ips = [ { '<STR_LIT>' : ip_addr , '<STR_LIT>' : nw [ '<STR_LIT>' ] [ <NUM_LIT:0> ] } ] <EOL> else : <EOL> ips = attributes . ATTR_NOT_SPECIFIED <EOL> return ips </s>
