Class: AMT::Service::NetworkAdministration

Inherits:
Basic
  • Object
show all
Defined in:
lib/amt/service/network_administration.rb,
lib/amt/service/network_administration/structures.rb

Overview

The Network Administration Service enables administrators to configure network parameters. This service implements all AMT 5.0 methods sans 802.1x related ones.

Defined Under Namespace

Classes: IPParameters, InterfaceDescriptor, LinkPolicy, VlanParameters

Instance Attribute Summary

Attributes inherited from Basic

#host, #port

Instance Method Summary collapse

Methods inherited from Basic

#initialize, #soap_call

Constructor Details

This class inherits a constructor from AMT::Service::Basic

Instance Method Details

#enumerate_interfacesObject

Return an array of handles (integers) to all known interfaces of the AMT device.

Supported by AMT 2.5 and later.



111
112
113
114
115
# File 'lib/amt/service/network_administration.rb', line 111

def enumerate_interfaces
  soap_call('EnumerateInterfaces').process do |node|
    node.xpath('./ns:InterfaceHandles/text()').collect {|n| n.to_i }
  end
end

#get_domain_nameObject

Return the domain name of the AMT device.

Supported by AMT 2.0 and later.



50
51
52
# File 'lib/amt/service/network_administration.rb', line 50

def get_domain_name
  soap_call('GetDomainName').process {|node| node.xpath('./ns:DomainName/text()').to_s}
end

#get_host_nameObject

Return the host name of the AMT device.

Supported by AMT 1.0 and later.



31
32
33
# File 'lib/amt/service/network_administration.rb', line 31

def get_host_name
  soap_call('GetHostName').process {|node| node.xpath('./ns:HostName/text()').to_s}
end

#get_interface_settings(interface_handle) ⇒ Object

Return the settings of the interface specified by interface_handle as an instance of InterfaceDescriptor.

Supported by AMT 2.5 and later.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/amt/service/network_administration.rb', line 122

def get_interface_settings(interface_handle)
  soap_call('GetInterfaceSettings') do |msg|
    msg.add('ns:InterfaceHandle', interface_handle)
  end.process do |node|
    result = InterfaceDescriptor.new
    result.hardware_description = node.xpath('./ns:InterfaceDescriptor/ns:HardwareAddressDescription/text()').to_s
    result.mac = node.xpath('./ns:InterfaceDescriptor/ns:MACAddress/text()').to_s.gsub('-', ':').upcase
    result.interface_mode = node.xpath('./ns:InterfaceDescriptor/ns:InterfaceMode/text()').to_s
    result.link_policy = LinkPolicy.new(node.xpath('./ns:InterfaceDescriptor/ns:LinkPolicy/text()').to_i)
    result.dhcp_enabled = node.xpath('./ns:InterfaceDescriptor/ns:DhcpEnabled/text()').to_boolean
    if node.xpath('./ns:InterfaceDescriptor/ns:IPv4Parameters')
      ipp = result.ip_parameters = IPParameters.new
      ipp.ip = IPAddr.new(node.xpath('./ns:InterfaceDescriptor/ns:IPv4Parameters/ns:LocalAddress/text()').to_i, Socket::AF_INET)
      ipp.mask = IPAddr.new(node.xpath('./ns:InterfaceDescriptor/ns:IPv4Parameters/ns:SubnetMask/text()').to_i, Socket::AF_INET)
      ipp.gateway = IPAddr.new(node.xpath('./ns:InterfaceDescriptor/ns:IPv4Parameters/ns:DefaultGatewayAddress/text()').to_i, Socket::AF_INET)
      ipp.primary_dns = IPAddr.new(node.xpath('./ns:InterfaceDescriptor/ns:IPv4Parameters/ns:PrimaryDnsAddress/text()').to_i, Socket::AF_INET)
      ipp.secondary_dns = IPAddr.new(node.xpath('./ns:InterfaceDescriptor/ns:IPv4Parameters/ns:SecondaryDnsAddress/text()').to_i, Socket::AF_INET)
    end
    result
  end
end

#get_ping_responseObject

Return whether ICMP ping responses are enabled on the AMT device.

Supported by AMT 1.0 and later.



103
104
105
# File 'lib/amt/service/network_administration.rb', line 103

def get_ping_response
  soap_call('GetPingResponse').process {|node| node.xpath('./ns:enabled/text()').to_boolean}
end

#get_vlan_parameters(interface_handle = nil) ⇒ Object

Return the VLAN parameters of the default interface or the one specified by interface_handle as instance of the VlanParameters class.

Supported by AMT 1.0 and later. Not supported in 2.5, 2.6 and 4.0.



79
80
81
82
83
84
85
86
87
88
# File 'lib/amt/service/network_administration.rb', line 79

def get_vlan_parameters(interface_handle = nil)
  soap_call('GetVlanParameters') do |msg|
    msg.add('ns:InterfaceHandle', interface_handle) if interface_handle
  end.process do |node|
    vp = VlanParameters.new
    vp.enabled = node.xpath('./ns:VlanMode/text()').to_boolean
    vp.tag = node.xpath('./ns:VlanTag/text()').to_i if vp.enabled
    vp
  end
end

#set_domain_name(name) ⇒ Object

Set the domain name of the AMT device to name.

Note: You also need to call SecurityAdministration#commit_changes for the changes to actually take effect.

Supported by AMT 2.0 and later.



42
43
44
# File 'lib/amt/service/network_administration.rb', line 42

def set_domain_name(name)
  soap_call('SetDomainName') {|msg| msg.add('ns:DomainName', name)}.process
end

#set_host_name(name) ⇒ Object

Set the host name of the AMT device to name.

Note: You also need to call SecurityAdministration#commit_changes for the changes to actually take effect.

Supported by AMT 1.0 and later.



23
24
25
# File 'lib/amt/service/network_administration.rb', line 23

def set_host_name(name)
  soap_call('SetHostName') {|msg| msg.add('ns:HostName', name)}.process
end

#set_interface_settings(interface_handle, interface_mode, link_policy, ip_parameters = nil) ⇒ Object

Set the interface parameters for the network interface identified by interface_handle.

interface_handle

The handle to the network interface that should be configured.

interface_mode

Has to be either SEPARATE_MAC_ADDRESS or SHARED_MAC_ADDRESS.

link_policy

The link policy (an instance of LinkPolicy) that should be set.

ip_parameters

If not specified (ie. nil), the interface is configured via DHCP. Otherwise this needs to be an instance of IPParameters.

Note: You also need to call SecurityAdministration#commit_changes for the changes to actually take effect.

Supported by AMT 2.5 and later.



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/amt/service/network_administration.rb', line 157

def set_interface_settings(interface_handle, interface_mode, link_policy, ip_parameters = nil)
  unless interface_mode == 'SEPARATE_MAC_ADDRESS' || interface_mode == 'SHARED_MAC_ADDRESS'
    raise ArgumentError, "interface_mode is invalid: #{interface_mode}"
  end
  soap_call('SetInterfaceSettings') do |msg|
    msg.add('ns:InterfaceHandle', interface_handle)
    msg.add('ns:InterfaceDescriptor') do |ifd|
      ifd.add('ns:InterfaceMode', interface_mode)
      ifd.add('ns:LinkPolicy', link_policy.value)
      ifd.add('ns:IPv4Parameters') do |ipp|
        ipp.add('ns:LocalAddress', ip_parameters.ip.to_i)
        ipp.add('ns:SubnetMask', ip_parameters.mask.to_i)
        ipp.add('ns:DefaultGatewayAddress', ip_parameters.gateway.to_i)
        ipp.add('ns:PrimaryDnsAddress', ip_parameters.primary_dns.to_i)
        ipp.add('ns:SecondaryDnsAddress', ip_parameters.secondary_dns.to_i)
      end if ip_parameters
    end
  end.process
end

#set_ping_response(enabled) ⇒ Object

Set the behaviour of the AMT device regarding ICMP ping responses. If enabled is true, ping responses will be enabled and else disabled.

Supported by AMT 1.0 and later.



95
96
97
# File 'lib/amt/service/network_administration.rb', line 95

def set_ping_response(enabled)
  soap_call('SetPingResponse') {|msg| msg.add('ns:enabled', enabled)}.process
end

#set_vlan_parameters(enabled, tag, interface_handle = nil) ⇒ Object

Set VLAN parameters (mode and vlan tag).

enabled

Boolean defining whether the VLAN support should be enabled on the AMT device.

tag

The VLAN tag (VLAN ID) to be set.

interface_handle

An optional interface handle for specifying the LAN interface to which the VLAN parameters should be applied.

Note: You also need to call SecurityAdministration#commit_changes for the changes to actually take effect.

Supported by AMT 1.0 and later. Not supported in 2.5, 2.6 and 4.0.



66
67
68
69
70
71
72
# File 'lib/amt/service/network_administration.rb', line 66

def set_vlan_parameters(enabled, tag, interface_handle = nil)
  soap_call('SetVlanParameters') do |msg|
    msg.add('ns:InterfaceHandle', interface_handle) if interface_handle
    msg.add('ns:VlanMode', enabled)
    msg.add('ns:VlanTag', tag)
  end.process
end