Class: Puppet::Util::NetworkDevice::Netapp::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/network_device/netapp/device.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, option = {}) ⇒ Device

Returns a new instance of Device.

Raises:

  • (ArgumentError)


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
36
37
38
39
# File 'lib/puppet/util/network_device/netapp/device.rb', line 10

def initialize(url, option = {})
  @url = URI.parse(url)
  redacted_url = @url.dup
  redacted_url.password = "****" if redacted_url.password

  Puppet.debug("Puppet::Device::Netapp: connecting to Netapp device #{redacted_url}")

  raise ArgumentError, "Invalid scheme #{@url.scheme}. Must be https" unless @url.scheme == 'https'
  raise ArgumentError, "no user specified" unless @url.user
  raise ArgumentError, "no password specified" unless @url.password

  @transport ||= NaServer.new(@url.host, 1, 13)
  @transport.set_admin_user(@url.user, @url.password)
  @transport.set_transport_type(@url.scheme.upcase)
  @transport.set_port(@url.port)
  if match = %r{/([^/]+)}.match(@url.path)
    @vfiler = match.captures[0]
    @transport.set_vfiler(@vfiler)
    Puppet.debug("Puppet::Device::Netapp: vfiler context has been set to #{@vfiler}")
  end
  
  result = @transport.invoke("system-get-version")
  if(result.results_errno != 0)
    r = result.results_reason
    raise Puppet::Error, "invoke system-get-version failed: #{r}"
  else
    version = result.child_get_string("version")
    Puppet.debug("Puppet::Device::Netapp: Version = #{version}")
  end
end

Instance Attribute Details

#transportObject

Returns the value of attribute transport.



8
9
10
# File 'lib/puppet/util/network_device/netapp/device.rb', line 8

def transport
  @transport
end

#urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/puppet/util/network_device/netapp/device.rb', line 8

def url
  @url
end

Instance Method Details

#factsObject



41
42
43
44
45
46
# File 'lib/puppet/util/network_device/netapp/device.rb', line 41

def facts
  @facts ||= Puppet::Util::NetworkDevice::Netapp::Facts.new(@transport)
  facts = @facts.retrieve
  
  facts
end