Class: NetAppManageability::Client

Inherits:
Object
  • Object
show all
Includes:
OntapMethodMap
Defined in:
lib/net_app_manageability/client.rb,
lib/net_app_manageability/client_stub.rb

Constant Summary collapse

NA_STYLE_LOGIN_PASSWORD =
API::NA_STYLE_LOGIN_PASSWORD
NA_STYLE_RPC =
API::NA_STYLE_RPC
NA_STYLE_HOSTSEQUIV =
API::NA_STYLE_HOSTSEQUIV
NA_SERVER_TRANSPORT_HTTP =
API::NA_SERVER_TRANSPORT_HTTP
NA_SERVER_TRANSPORT_HTTPS =
API::NA_SERVER_TRANSPORT_HTTPS
NA_SERVER_TYPE_FILER =
API::NA_SERVER_TYPE_FILER
NA_SERVER_TYPE_NETCACHE =
API::NA_SERVER_TYPE_NETCACHE
NA_SERVER_TYPE_AGENT =
API::NA_SERVER_TYPE_AGENT
NA_SERVER_TYPE_DFM =
API::NA_SERVER_TYPE_DFM
NA_SERVER_TYPE_CLUSTER =
API::NA_SERVER_TYPE_CLUSTER

Constants included from OntapMethodMap

OntapMethodMap::METHOD_MAP

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OntapMethodMap

#map_method

Constructor Details

#initializeClient

Returns a new instance of Client.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/net_app_manageability/client.rb', line 22

def initialize(opts={}, &block)
  @options = NAMHash.new(true) do
    auth_style      NA_STYLE_LOGIN_PASSWORD
    transport_type  NA_SERVER_TRANSPORT_HTTP
    server_type     NA_SERVER_TYPE_FILER
    port            80
  end
  @options.merge!(opts)
  unless block.nil?
    block.arity < 1 ? @options.instance_eval(&block) : block.call(@options)
  end

  raise "Client: No server specified" if @options.server.nil?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/net_app_manageability/client.rb', line 78

def method_missing(method_name, *args, &block)
  cmd = map_method(method_name.to_sym)
  return super if cmd.nil?

  ah = nil
  if args.length > 0 || !block.nil?
    ah = NAMHash.new

    if args.length == 1 && args.first.kind_of?(Hash)
      ah.merge!(args.first)
    elsif args.length > 1
      ah.merge!(Hash[*args])
    end

    unless block.nil?
      block.arity < 1 ? ah.instance_eval(&block) : block.call(ah)
    end
  end

  return API.server_invoke(handle, cmd, ah)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/net_app_manageability/client.rb', line 5

def options
  @options
end

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/net_app_manageability/client.rb', line 50

def self.available?
  true
end

.error_messageObject



7
8
9
10
11
12
13
14
# File 'lib/net_app_manageability/client_stub.rb', line 7

def self.error_message
  platform = RbConfig::CONFIG["target_os"]
  if platform.include?("linux")
    "compile failed."
  else
    "not available on platform #{platform}"
  end
end

.loggerObject



70
71
72
# File 'lib/net_app_manageability/client.rb', line 70

def self.logger
  API.logger
end

.logger=(val) ⇒ Object



74
75
76
# File 'lib/net_app_manageability/client.rb', line 74

def self.logger=(val)
  API.logger = val
end

.method_missingObject



20
21
22
# File 'lib/net_app_manageability/client_stub.rb', line 20

def self.method_missing(*)
  raise "#{name} could not be loaded because #{error_message}"
end

.verboseObject



62
63
64
# File 'lib/net_app_manageability/client.rb', line 62

def self.verbose
  API.verbose
end

.verbose=(val) ⇒ Object



66
67
68
# File 'lib/net_app_manageability/client.rb', line 66

def self.verbose=(val)
  API.verbose = val
end

.wire_dumpObject



54
55
56
# File 'lib/net_app_manageability/client.rb', line 54

def self.wire_dump
  API.wire_dump
end

.wire_dump=(val) ⇒ Object



58
59
60
# File 'lib/net_app_manageability/client.rb', line 58

def self.wire_dump=(val)
  API.wire_dump = val
end

Instance Method Details

#handleObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/net_app_manageability/client.rb', line 37

def handle
  return @handle unless @handle.nil?

  @handle = API.server_open(options.server, 1, 1)
  API.server_style(@handle, options.auth_style)

  if options.auth_style == NA_STYLE_LOGIN_PASSWORD
    API.server_adminuser(@handle, options.username, options.password)
  end

  @handle
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/net_app_manageability/client.rb', line 100

def respond_to_missing?(method_name, include_private = false)
  map_method(method_name.to_sym) || super
end