<s> """<STR_LIT>""" <EOL> from perfkitbenchmarker import context <EOL> from perfkitbenchmarker import errors <EOL> class BaseFirewall ( object ) : <EOL> """<STR_LIT>""" <EOL> CLOUD = None <EOL> @ classmethod <EOL> def GetFirewall ( cls ) : <EOL> """<STR_LIT>""" <EOL> if cls . CLOUD is None : <EOL> raise errors . Error ( '<STR_LIT>' ) <EOL> benchmark_spec = context . GetThreadBenchmarkSpec ( ) <EOL> if benchmark_spec is None : <EOL> raise errors . Error ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> with benchmark_spec . firewalls_lock : <EOL> key = cls . CLOUD <EOL> if key not in benchmark_spec . firewalls : <EOL> benchmark_spec . firewalls [ key ] = cls ( ) <EOL> return benchmark_spec . firewalls [ key ] <EOL> def AllowPort ( self , vm , port ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def DisallowAllPorts ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class BaseNetworkSpec ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , zone = None ) : <EOL> """<STR_LIT>""" <EOL> self . zone = zone <EOL> class BaseNetwork ( object ) : <EOL> """<STR_LIT>""" <EOL> CLOUD = None <EOL> def __init__ ( self , spec ) : <EOL> self . zone = spec . zone <EOL> @ staticmethod <EOL> def _GetNetworkSpecFromVm ( vm ) : <EOL> """<STR_LIT>""" <EOL> return BaseNetworkSpec ( zone = vm . zone ) <EOL> @ classmethod <EOL> def _GetKeyFromNetworkSpec ( cls , spec ) : <EOL> """<STR_LIT>""" <EOL> if cls . CLOUD is None : <EOL> raise errors . Error ( '<STR_LIT>' ) <EOL> return ( cls . CLOUD , spec . zone ) <EOL> @ classmethod <EOL> def GetNetwork ( cls , vm ) : <EOL> """<STR_LIT>""" <EOL> benchmark_spec = context . GetThreadBenchmarkSpec ( ) <EOL> if benchmark_spec is None : <EOL> raise errors . Error ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> spec = cls . _GetNetworkSpecFromVm ( vm ) <EOL> key = cls . _GetKeyFromNetworkSpec ( spec ) <EOL> with benchmark_spec . networks_lock : <EOL> if key not in benchmark_spec . networks : <EOL> benchmark_spec . networks [ key ] = cls ( spec ) <EOL> return benchmark_spec . networks [ key ] <EOL> def Create ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def Delete ( self ) : <EOL> """<STR_LIT>""" <EOL> pass </s>
