<s> """<STR_LIT>""" <EOL> from six . moves import urllib <EOL> from novaclient import api_versions <EOL> from novaclient import base <EOL> class Service ( base . Resource ) : <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % self . binary <EOL> def _add_details ( self , info ) : <EOL> dico = '<STR_LIT>' in info and info [ '<STR_LIT>' ] or info <EOL> for ( k , v ) in dico . items ( ) : <EOL> setattr ( self , k , v ) <EOL> class ServiceManager ( base . ManagerWithFind ) : <EOL> resource_class = Service <EOL> def list ( self , host = None , binary = None ) : <EOL> """<STR_LIT>""" <EOL> url = "<STR_LIT>" <EOL> filters = [ ] <EOL> if host : <EOL> filters . append ( ( "<STR_LIT:host>" , host ) ) <EOL> if binary : <EOL> filters . append ( ( "<STR_LIT>" , binary ) ) <EOL> if filters : <EOL> url = "<STR_LIT>" % ( url , urllib . parse . urlencode ( filters ) ) <EOL> return self . _list ( url , "<STR_LIT>" ) <EOL> @ api_versions . wraps ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def _update_body ( self , host , binary , disabled_reason = None ) : <EOL> body = { "<STR_LIT:host>" : host , <EOL> "<STR_LIT>" : binary } <EOL> if disabled_reason is not None : <EOL> body [ "<STR_LIT>" ] = disabled_reason <EOL> return body <EOL> @ api_versions . wraps ( "<STR_LIT>" ) <EOL> def _update_body ( self , host , binary , disabled_reason = None , <EOL> force_down = None ) : <EOL> body = { "<STR_LIT:host>" : host , <EOL> "<STR_LIT>" : binary } <EOL> if disabled_reason is not None : <EOL> body [ "<STR_LIT>" ] = disabled_reason <EOL> if force_down is not None : <EOL> body [ "<STR_LIT>" ] = force_down <EOL> return body <EOL> def enable ( self , host , binary ) : <EOL> """<STR_LIT>""" <EOL> body = self . _update_body ( host , binary ) <EOL> return self . _update ( "<STR_LIT>" , body , "<STR_LIT>" ) <EOL> def disable ( self , host , binary ) : <EOL> """<STR_LIT>""" <EOL> body = self . _update_body ( host , binary ) <EOL> return self . _update ( "<STR_LIT>" , body , "<STR_LIT>" ) <EOL> def disable_log_reason ( self , host , binary , reason ) : <EOL> """<STR_LIT>""" <EOL> body = self . _update_body ( host , binary , reason ) <EOL> return self . _update ( "<STR_LIT>" , body , "<STR_LIT>" ) <EOL> def delete ( self , service_id ) : <EOL> """<STR_LIT>""" <EOL> return self . _delete ( "<STR_LIT>" % service_id ) <EOL> @ api_versions . wraps ( "<STR_LIT>" ) <EOL> def force_down ( self , host , binary , force_down = None ) : <EOL> """<STR_LIT>""" <EOL> body = self . _update_body ( host , binary , force_down = force_down ) <EOL> return self . _update ( "<STR_LIT>" , body , "<STR_LIT>" ) </s>
