Class: Puppet::NetDev::CE::SystemApi
- Defined in:
- lib/puppet/provider/ce/api/system/system_api.rb
Instance Method Summary collapse
- #get_sysname ⇒ Object
-
#initialize ⇒ SystemApi
constructor
A new instance of SystemApi.
- #set_sysname(resource) ⇒ Object
Constructor Details
#initialize ⇒ SystemApi
Returns a new instance of SystemApi.
22 23 24 |
# File 'lib/puppet/provider/ce/api/system/system_api.rb', line 22 def initialize super() end |
Instance Method Details
#get_sysname ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puppet/provider/ce/api/system/system_api.rb', line 26 def get_sysname sysname_array = [] session = Puppet::NetDev::CE::Device.session get_sysname_xml = '<rpc><get><filter type="subtree"><system xmlns="http://www.huawei.com/netconf/vrp" format-version="1.0" content-version="1.0"><systemInfo><sysName></sysName></systemInfo></system></filter></get></rpc>' sysname_elem = session.rpc.do_config(get_sysname_xml).first_element_child.first_element_child sysname_doc = Nokogiri::XML(sysname_elem.to_s) sysname = sysname_doc.xpath('/systemInfo/sysName').text property_hash = { name: sysname } property_hash[:system_name] = sysname sysname_array << property_hash sysname_array end |
#set_sysname(resource) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/puppet/provider/ce/api/system/system_api.rb', line 42 def set_sysname(resource) session = Puppet::NetDev::CE::Device.session set_sysname_xml = '<rpc><edit-config><target><running/></target><default-operation>merge</default-operation><error-option>rollback-on-error</error-option><config><system xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0"><systemInfo><sysName>' + (resource[:name]).to_s + '</sysName></systemInfo></system></config></edit-config></rpc>' session.rpc.do_config(set_sysname_xml) end |