Class: ONVIF::DeviceManagementAction::GetNetworkInterfaces
- Inherits:
-
Action
- Object
- Action
- ONVIF::DeviceManagementAction::GetNetworkInterfaces
show all
- Defined in:
- lib/ruby_onvif_client/device_management/get_network_interfaces.rb
Instance Method Summary
collapse
Methods inherited from Action
#attribute, #callback, #create_event_onvif_message, #create_media_onvif_message, #create_ptz_onvif_message, #initialize, #send_message, #value
Constructor Details
This class inherits a constructor from ONVIF::Action
Instance Method Details
#_get_info(xml_info) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/ruby_onvif_client/device_management/get_network_interfaces.rb', line 37
def _get_info xml_info
{
name: value(xml_info, 'tt:Name'),
hw_address: value(xml_info, 'tt:HwAddress'),
mtu: value(xml_info, 'tt:MTU')
}
end
|
#_get_ipv_four(xml_ipv_four) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/ruby_onvif_client/device_management/get_network_interfaces.rb', line 67
def _get_ipv_four xml_ipv_four
puts xml_ipv_four
ipv_four = {enabled: value(xml_ipv_four, 'tt:Enabled')}
manual = []; config = {}
link_local = xml_ipv_four.xpath('tt:Config/tt:LinkLocal')
form_dhcp = xml_ipv_four.xpath('tt:Config/tt:FromDHCP')
xml_ipv_four.xpath('tt:Config//tt:Manual').each do |node|
manual << {
address: value(node, "tt:Address"),
prefix_length: value(node, "tt:PrefixLength")
}
end
config[:manual] = manual
config[:link_local] = {
address: value(link_local, "tt:Address"),
prefix_length: value(link_local, "tt:PrefixLength")
}
config[:form_dhcp] = {
address: value(form_dhcp, "tt:Address"),
prefix_length: value(form_dhcp, "tt:PrefixLength")
}
config[:dhcp] = value(xml_ipv_four, "tt:Config//tt:DHCP")
ipv_four[:config] = config
return ipv_four
end
|
#_get_ipv_six(xml_ipv_six) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/ruby_onvif_client/device_management/get_network_interfaces.rb', line 93
def _get_ipv_six xml_ipv_six
ipv_six = {enabled: value(xml_ipv_six, 'tt:Enabled')}
config = {}; manual = []; link_local = []; form_dhcp = []; form_ra = []
xml_ipv_six.xpath('tt:Config/tt:Manual').each do |node|
manual << {
address: value(node, "tt:Address"),
prefix_length: value(node, "tt:PrefixLength")
}
end
xml_ipv_six.xpath('tt:Config/tt:LinkLocal').each do |node|
link_local << {
address: value(node, "tt:Address"),
prefix_length: value(node, "tt:PrefixLength")
}
end
xml_ipv_six.xpath('tt:Config/tt:FromDHCP').each do |node|
form_dhcp << {
address: value(node, "tt:Address"),
prefix_length: value(node, "tt:PrefixLength")
}
end
xml_ipv_six.xpath('tt:Config/tt:FromRA').each do |node|
form_ra << {
address: value(node, "tt:Address"),
prefix_length: value(node, "tt:PrefixLength")
}
end
config[:manual] = manual
config[:link_local] = link_local
config[:form_dhcp] = form_dhcp
config[:form_ra] = form_ra
config[:ara] = value(xml_ipv_six, "tt:AcceptRouterAdvert")
config[:dhcp] = value(xml_ipv_six, "tt:DHCP")
ipv_six[:config] = config
return ipv_six
end
|
#_get_link(xml_link) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/ruby_onvif_client/device_management/get_network_interfaces.rb', line 45
def _get_link xml_link
admin_xml_doc = xml_link.at_xpath('tt:AdminSettings')
oper_xml_doc = xml_link.at_xpath('tt:OperSettings')
link = {}
unless admin_xml_doc.nil?
link[:admin_settings] = {
auto_negotiation: value(admin_xml_doc, "tt:AutoNegotiation"),
speed: value(admin_xml_doc, "tt:Speed"),
duplex: value(admin_xml_doc, "tt:Duplex")
}
end
unless oper_xml_doc.nil?
link[:oper_settings] = {
auto_negotiation: value(oper_xml_doc, "tt:AutoNegotiation"),
speed: value(oper_xml_doc, "tt:Speed"),
duplex: value(oper_xml_doc, "tt:Duplex")
}
end
link[:interface_type] = value(xml_link, "tt:InterfaceType") unless xml_link.at_xpath('tt:InterfaceType')
return link
end
|
#run(cb) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/ruby_onvif_client/device_management/get_network_interfaces.rb', line 6
def run cb
message = Message.new
message.body = ->(xml) do
xml.wsdl(:GetNetworkInterfaces)
end
send_message message do |success, result|
if success
xml_doc_main = Nokogiri::XML(result[:content])
interfaces = []
xml_doc_main.xpath('//tds:NetworkInterfaces').each do |xml_doc|
xml_info = xml_doc.at_xpath('tt:Info')
xml_link = xml_doc.at_xpath('tt:Link')
xml_ipv4 = xml_doc.at_xpath('tt:IPv4')
xml_ipv6 = xml_doc.at_xpath('tt:IPv6')
success_result = {
token: attribute(xml_doc, "token"),
enabled: value(xml_doc, "tt:Enabled")
}
success_result[:info] = _get_info(xml_info) unless xml_info.nil?
success_result[:link] = _get_link(xml_link) unless xml_link.nil?
success_result[:ipv4] = _get_ipv_four(xml_ipv4) unless xml_ipv4.nil?
success_result[:ipv6] = _get_ipv_six(xml_ipv6) unless xml_ipv6.nil?
interfaces << success_result
end
callback cb, success, interfaces
else
callback cb, success, result
end
end
end
|