<s> from lxml import etree <EOL> from ncclient . xml_ import * <EOL> from ncclient . operations . rpc import RPC <EOL> class DisplayCommand ( RPC ) : <EOL> def request ( self , cmds ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( cmds , list ) : <EOL> cmd = '<STR_LIT:\n>' . join ( cmds ) <EOL> elif isinstance ( cmds , str ) or isinstance ( cmds , unicode ) : <EOL> cmd = cmds <EOL> node = etree . Element ( qualify ( '<STR_LIT>' , BASE_NS_1_0 ) ) <EOL> etree . SubElement ( node , qualify ( '<STR_LIT>' , <EOL> BASE_NS_1_0 ) ) . text = cmd <EOL> return self . _request ( node ) <EOL> class ConfigCommand ( RPC ) : <EOL> def request ( self , cmds ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( cmds , list ) : <EOL> cmd = '<STR_LIT:\n>' . join ( cmds ) <EOL> elif isinstance ( cmds , str ) or isinstance ( cmds , unicode ) : <EOL> cmd = cmds <EOL> node = etree . Element ( qualify ( '<STR_LIT>' , BASE_NS_1_0 ) ) <EOL> etree . SubElement ( node , qualify ( '<STR_LIT>' , <EOL> BASE_NS_1_0 ) ) . text = cmd <EOL> return self . _request ( node ) <EOL> class Action ( RPC ) : <EOL> def request ( self , action = None ) : <EOL> node = new_ele ( "<STR_LIT:action>" ) <EOL> node . append ( validated_element ( action ) ) <EOL> return self . _request ( node ) <EOL> class Save ( RPC ) : <EOL> def request ( self , filename = None ) : <EOL> node = new_ele ( '<STR_LIT>' ) <EOL> sub_ele ( node , '<STR_LIT:file>' ) . text = filename <EOL> return self . _request ( node ) <EOL> class Rollback ( RPC ) : <EOL> def request ( self , filename = None ) : <EOL> node = new_ele ( '<STR_LIT>' ) <EOL> sub_ele ( node , '<STR_LIT:file>' ) . text = filename <EOL> return self . _request ( node ) </s>
