<s> """<STR_LIT>""" <EOL> import re <EOL> from pyeapi . api import Entity <EOL> class System ( Entity ) : <EOL> """<STR_LIT>""" <EOL> def get ( self ) : <EOL> """<STR_LIT>""" <EOL> resource = dict ( ) <EOL> resource . update ( self . _parse_hostname ( ) ) <EOL> resource . update ( self . _parse_iprouting ( ) ) <EOL> resource . update ( self . _parse_banners ( ) ) <EOL> return resource <EOL> def _parse_hostname ( self ) : <EOL> """<STR_LIT>""" <EOL> value = '<STR_LIT:localhost>' <EOL> match = re . search ( r'<STR_LIT>' , self . config , re . M ) <EOL> if match : <EOL> value = match . group ( <NUM_LIT:1> ) <EOL> return dict ( hostname = value ) <EOL> def _parse_iprouting ( self ) : <EOL> """<STR_LIT>""" <EOL> value = '<STR_LIT>' not in self . config <EOL> return dict ( iprouting = value ) <EOL> def _parse_banners ( self ) : <EOL> """<STR_LIT>""" <EOL> motd_value = login_value = None <EOL> matches = re . findall ( '<STR_LIT>' , <EOL> self . config , re . DOTALL | re . M ) <EOL> for match in matches : <EOL> if match [ <NUM_LIT:0> ] . strip ( ) == "<STR_LIT>" : <EOL> motd_value = match [ <NUM_LIT:1> ] <EOL> elif match [ <NUM_LIT:0> ] . strip ( ) == "<STR_LIT>" : <EOL> login_value = match [ <NUM_LIT:1> ] <EOL> return dict ( banner_motd = motd_value , banner_login = login_value ) <EOL> def set_hostname ( self , value = None , default = False , disable = False ) : <EOL> """<STR_LIT>""" <EOL> cmd = self . command_builder ( '<STR_LIT>' , value = value , default = default , <EOL> disable = disable ) <EOL> return self . configure ( cmd ) <EOL> def set_iprouting ( self , value = None , default = False , disable = False ) : <EOL> """<STR_LIT>""" <EOL> if value is False : <EOL> disable = True <EOL> cmd = self . command_builder ( '<STR_LIT>' , value = value , default = default , <EOL> disable = disable ) <EOL> return self . configure ( cmd ) <EOL> def set_banner ( self , banner_type , value = None , default = False , <EOL> disable = False ) : <EOL> """<STR_LIT>""" <EOL> command_string = "<STR_LIT>" % banner_type <EOL> if default is True or disable is True : <EOL> cmd = self . command_builder ( command_string , value = None , <EOL> default = default , disable = disable ) <EOL> return self . configure ( cmd ) <EOL> else : <EOL> if not value . endswith ( "<STR_LIT:\n>" ) : <EOL> value = value + "<STR_LIT:\n>" <EOL> command_input = dict ( cmd = command_string , input = value ) <EOL> return self . configure ( [ command_input ] ) <EOL> def instance ( api ) : <EOL> """<STR_LIT>""" <EOL> return System ( api ) </s>
