Class: Vipruby

Inherits:
Object
  • Object
show all
Defined in:
lib/vipruby.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url, user_name, password, verify_cert) ⇒ Vipruby

SSL_VERSION = ‘TLSv1’



9
10
11
12
13
14
# File 'lib/vipruby.rb', line 9

def initialize(base_url,user_name,password,verify_cert)
  @base_url = base_url
  @verify_cert = to_boolean(verify_cert)
  @auth_token = get_auth_token(user_name,password)
  @tenant_uid = get_tenant_uid['id']
end

Instance Attribute Details

#auth_tokenObject

Returns the value of attribute auth_token.



6
7
8
# File 'lib/vipruby.rb', line 6

def auth_token
  @auth_token
end

#base_urlObject

Returns the value of attribute base_url.



6
7
8
# File 'lib/vipruby.rb', line 6

def base_url
  @base_url
end

#tenant_uidObject

Returns the value of attribute tenant_uid.



6
7
8
# File 'lib/vipruby.rb', line 6

def tenant_uid
  @tenant_uid
end

#verify_certObject

Returns the value of attribute verify_cert.



6
7
8
# File 'lib/vipruby.rb', line 6

def verify_cert
  @verify_cert
end

Instance Method Details

#add_emc_block_storage(name, ip_address, port_number, user_name, password, use_ssl) ⇒ Object

EMC VMAX and VNX for block storage system version support

> For supported versions, see the EMC ViPR Support Matrix on the EMC Community Network (community.emc.com)

The EMC SMI-S Provider (a component of EMC Solutions Enabler) is required to use VMAX storage or VNX block. The following information is required to verify & add the SMI-S provider storage systems to ViPR:

> SMI-S Provider host address

> SMI-S Provider credentials (default is admin/#1Password)

> SMI-S Provider port (default is 5989)



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/vipruby.rb', line 174

def add_emc_block_storage(name, ip_address, port_number, user_name, password, use_ssl)
    emc_block_storage_xml = Nokogiri::XML::Builder.new do |xml|
      xml.storage_provider_create {
        xml.name            name
        xml.interface_type  "smis"
        xml.ip_address      ip_address
        xml.port_number     port_number
        xml.user_name       user_name
        xml.password        password
        xml.use_ssl         use_ssl
      }
    end

    JSON.parse(RestClient::Request.execute(method: :post,
       url: "#{base_url}/vdc/storage-providers",
       verify_ssl: @verify_cert,
       payload: emc_block_storage_xml.to_xml,
       headers: {
         :'X-SDS-AUTH-TOKEN' => @auth_token,
         content_type: 'application/xml',
         accept: :json
       }))
end

#add_emc_isilon_storage(name, ip_address, port_number, user_name, password) ⇒ Object

Isilon Storage System Support

> Supported Protocol: NFS, CIFS (Snapshot restore is not supported for Isilon storage systems.)

Port (default is 8080)



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/vipruby.rb', line 233

def add_emc_isilon_storage(name, ip_address, port_number, user_name, password)
    emc_isilon_storage_xml = Nokogiri::XML::Builder.new do |xml|
      xml.storage_system_create {
        xml.name name
        xml.system_type "isilon"
        xml.ip_address ip_address
        xml.port_number port_number
        xml.user_name user_name
        xml.password password
      }
    end

    JSON.parse(RestClient::Request.execute(method: :post,
       url: "#{base_url}/vdc/storage-systems",
       verify_ssl: @verify_cert,
       payload: emc_isilon_storage_xml.to_xml,
       headers: {
         :'X-SDS-AUTH-TOKEN' => @auth_token,
         content_type: 'application/xml',
         accept: :json
       }))
end

#add_emc_scaleio_storage(name, ip_address, port_number, user_name, password) ⇒ Object

Stand-alone ScaleIO support and preconfiguration requirements Supported versions: ScaleIO 1.21.0.20 or later Preconfiguration requirements:

> Protection domains are defined.

> All storage pools are defined.



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/vipruby.rb', line 287

def add_emc_scaleio_storage(name, ip_address, port_number, user_name, password)
    emc_scaleio_storage_xml = Nokogiri::XML::Builder.new do |xml|
      xml.storage_provider_create {
        xml.name name
        xml.interface_type "scaleio"
        xml.ip_address ip_address
        xml.port_number port_number
        xml.user_name user_name
        xml.password password
      }
    end

    JSON.parse(RestClient::Request.execute(method: :post,
       url: "#{base_url}/vdc/storage-providers",
       verify_ssl: @verify_cert,
       payload: emc_scaleio_storage_xml.to_xml,
       headers: {
         :'X-SDS-AUTH-TOKEN' => @auth_token,
         content_type: 'application/xml',
         accept: :json
       }))
end

#add_emc_vnx_file_storage(name, ip_address, port_number, user_name, password, smis_provider_ip, smis_port_number, smis_user_name, smis_password, smis_use_ssl) ⇒ Object

EMC VNX for File storage system support

> Supported Protocol: NFS, CIFS (Snapshot restore is not supported for Isilon storage systems.)

VNX File Control Station default port is 443 VNX File Onboard Storage Provider default port is 5988



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/vipruby.rb', line 202

def add_emc_vnx_file_storage(name, ip_address, port_number, user_name, password, smis_provider_ip, smis_port_number, smis_user_name, smis_password, smis_use_ssl)
    emc_vnx_file_storage_xml = Nokogiri::XML::Builder.new do |xml|
      xml.storage_system_create {
        xml.name              name
        xml.system_type       "vnxfile"
        xml.ip_address        ip_address
        xml.port_number       port_number
        xml.user_name         user_name
        xml.password          password
        xml.smis_provider_ip  smis_provider_ip
        xml.smis_port_number  smis_port_number
        xml.smis_user_name    smis_user_name
        xml.smis_password     smis_password
        xml.smis_use_ssl      smis_use_ssl
      }
    end

    JSON.parse(RestClient::Request.execute(method: :post,
       url: "#{base_url}/vdc/storage-systems",
       verify_ssl: @verify_cert,
       payload: emc_vnx_file_storage_xml.to_xml,
       headers: {
         :'X-SDS-AUTH-TOKEN' => @auth_token,
         content_type: 'application/xml',
         accept: :json
       }))
end

#add_emc_vplex_storage(name, ip_address, port_number, user_name, password, use_ssl) ⇒ Object

ViPR configuration requirements for VPLEX storage systems ViPR supports VPLEX in a Local or Metro configuration. VPLEX Geo configurations are not supported.



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/vipruby.rb', line 258

def add_emc_vplex_storage(name, ip_address, port_number, user_name, password, use_ssl)
    emc_vplex_storage_xml = Nokogiri::XML::Builder.new do |xml|
      xml.storage_provider_create {
        xml.name name
        xml.interface_type "vplex"
        xml.ip_address ip_address
        xml.port_number port_number
        xml.user_name user_name
        xml.password password
        xml.use_ssl
      }
    end

    JSON.parse(RestClient::Request.execute(method: :post,
       url: "#{base_url}/vdc/storage-providers",
       verify_ssl: @verify_cert,
       payload: emc_vplex_storage_xml.to_xml,
       headers: {
         :'X-SDS-AUTH-TOKEN' => @auth_token,
         content_type: 'application/xml',
         accept: :json
       }))
end

#add_hitachi_storage(name, ip_address, port_number, user_name, password, use_ssl) ⇒ Object

Hitachi Data Systems support For supported versions, see the EMC ViPR Support Matrix on the EMC Community Network (community.emc.com). Hitachi HiCommand Device Manager is required to use HDS storage with ViPR. You need to obtain the following information to configure and add the Hitachi HiCommand Device manager to ViPR:

> A host or virtual machine for HiCommand Device manager setup

> HiCommand Device Manager license, host address, credentials, and host port (default is 2001)



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/vipruby.rb', line 368

def add_hitachi_storage(name, ip_address, port_number, user_name, password, use_ssl)
    hitachi_storage_xml = Nokogiri::XML::Builder.new do |xml|
      xml.storage_provider_create {
        xml.name name
        xml.interface_type "hicommand"
        xml.ip_address ip_address
        xml.port_number port_number
        xml.user_name user_name
        xml.password password
        xml.use_ssl use_ssl
      }
    end

    JSON.parse(RestClient::Request.execute(method: :post,
       url: "#{base_url}/vdc/storage-providers",
       verify_ssl: @verify_cert,
       payload: hitachi_storage_xml.to_xml,
       headers: {
         :'X-SDS-AUTH-TOKEN' => @auth_token,
         content_type: 'application/xml',
         accept: :json
       }))
end

#add_host(host) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vipruby.rb', line 39

def add_host(host)
   JSON.parse(RestClient::Request.execute(method: :post,
     url: "#{base_url}/tenants/#{@tenant_uid}/hosts",
     verify_ssl: @verify_cert,
     payload: host,
     headers: {
       :'X-SDS-AUTH-TOKEN' => @auth_token,
       content_type: 'application/json',
       accept: :json
     }))
end

#add_host_and_initiators(host) ⇒ Object



97
98
99
# File 'lib/vipruby.rb', line 97

def add_host_and_initiators(host)
  add_initiators(host.generate_initiators_json,add_host(host.generate_json)['resource']['link']['href'])
end

#add_initiators(initiators, host_href) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/vipruby.rb', line 51

def add_initiators(initiators,host_href)
  initiators.each do |initiator|
    RestClient::Request.execute(method: :post,
      url: "#{@base_url}#{host_href}/initiators",
      verify_ssl: @verify_cert,
      payload: initiator,
      headers: {
        :'X-SDS-AUTH-TOKEN' => @auth_token,
        content_type: 'application/json',
        accept: :json
      })
  end
end

#add_netapp_storage(name, ip_address, port_number, user_name, password) ⇒ Object

NetApp Storage System Support

> Supported Protocol: NFS, CIFS



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/vipruby.rb', line 339

def add_netapp_storage(name, ip_address, port_number, user_name, password)
    netapp_storage_xml = Nokogiri::XML::Builder.new do |xml|
      xml.storage_system_create {
        xml.name name
        xml.system_type "netapp"
        xml.ip_address ip_address
        xml.port_number port_number
        xml.user_name user_name
        xml.password password
      }
    end

    JSON.parse(RestClient::Request.execute(method: :post,
       url: "#{base_url}/vdc/storage-systems",
       verify_ssl: @verify_cert,
       payload: netapp_storage_xml.to_xml,
       headers: {
         :'X-SDS-AUTH-TOKEN' => @auth_token,
         content_type: 'application/xml',
         accept: :json
       }))
end

#add_third_party_block_storage(name, ip_address, port_number, user_name, password, use_ssl) ⇒ Object

Third-party block storage provider installation requirements ViPR uses the OpenStack Block Storage (Cinder) Service to add third-party block storage systems to ViPR. For supported versions, see the EMC ViPR Support Matrix available on the EMC Community Network (community.emc.com).



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/vipruby.rb', line 313

def add_third_party_block_storage(name, ip_address, port_number, user_name, password, use_ssl)
    third_party_block_storage_xml = Nokogiri::XML::Builder.new do |xml|
      xml.storage_provider_create {
        xml.name name
        xml.interface_type "cinder"
        xml.ip_address ip_address
        xml.port_number port_number
        xml.user_name user_name
        xml.password password
        xml.use_ssl use_ssl
      }
    end

    JSON.parse(RestClient::Request.execute(method: :post,
       url: "#{base_url}/vdc/storage-providers",
       verify_ssl: @verify_cert,
       payload: third_party_block_storage_xml.to_xml,
       headers: {
         :'X-SDS-AUTH-TOKEN' => @auth_token,
         content_type: 'application/xml',
         accept: :json
       }))
end

#add_vcenter(fqdn_or_ip, name, port, user_name, password) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/vipruby.rb', line 134

def add_vcenter(fqdn_or_ip, name, port, user_name, password)
  vcenterxml = Nokogiri::XML::Builder.new do |xml|
    xml.vcenter_create {
      xml.ip_address  fqdn_or_ip
      xml.name        name
      xml.port_number port
      xml.user_name   user_name
      xml.password    password
    }
  end

  JSON.parse(RestClient::Request.execute(method: :post,
     url: "#{base_url}/tenants/#{@tenant_uid}/vcenters",
     verify_ssl: @verify_cert,
     payload: vcenterxml.to_xml,
     headers: {
       :'X-SDS-AUTH-TOKEN' => @auth_token,
       content_type: 'application/xml',
       accept: :json
     }))
end

#deactivate_host(host_href) ⇒ Object



86
87
88
89
90
91
92
93
94
95
# File 'lib/vipruby.rb', line 86

def deactivate_host(host_href)
  JSON.parse(RestClient::Request.execute(method: :post,
    url: "#{base_url}#{host_href}/deactivate",
    verify_ssl: @verify_cert,
    headers: {
      :'X-SDS-AUTH-TOKEN' => @auth_token,
      content_type: 'application/json',
      accept: :json
    }))
end

#delete_vcenter(vcenter_id) ⇒ Object



156
157
158
159
160
161
162
163
164
165
# File 'lib/vipruby.rb', line 156

def delete_vcenter(vcenter_id)
  JSON.parse(RestClient::Request.execute(method: :post,
     url: "#{base_url}/compute/vcenters/#{vcenter_id}/deactivate",
     verify_ssl: @verify_cert,
     headers: {
       :'X-SDS-AUTH-TOKEN' => @auth_token,
       content_type: 'application/json',
       accept: :json
     }))
end

#find_host_object(search_hash) ⇒ Object



105
106
107
108
109
110
111
112
113
# File 'lib/vipruby.rb', line 105

def find_host_object(search_hash)
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{@base_url}/compute/hosts/search?name=#{search_hash}",
    verify_ssl: @verify_cert,
    headers: {
      :'X-SDS-AUTH-TOKEN' => @auth_token,
      accept: :json
    }))
end

#find_vcenter_object(vcenter_search_hash) ⇒ Object



124
125
126
127
128
129
130
131
132
# File 'lib/vipruby.rb', line 124

def find_vcenter_object(vcenter_search_hash)
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{@base_url}/compute/vcenters/search?name=#{vcenter_search_hash}",
    verify_ssl: @verify_cert,
    headers: {
      :'X-SDS-AUTH-TOKEN' => @auth_token,
      accept: :json
    }))
end

#get_all_hostsObject



65
66
67
68
69
70
71
72
73
# File 'lib/vipruby.rb', line 65

def get_all_hosts
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{@base_url}/tenants/#{@tenant_uid}/hosts",
    verify_ssl: @verify_cert,
    headers: {
      :'X-SDS-AUTH-TOKEN' => @auth_token,
      accept: :json
    }))
end

#get_all_vcentersObject



115
116
117
118
119
120
121
122
# File 'lib/vipruby.rb', line 115

def get_all_vcenters
  JSON.parse(RestClient::Request.execute(method: :get,url: "#{@base_url}/compute/vcenters/bulk",
    verify_ssl: @verify_cert,
    headers: {
      :'X-SDS-AUTH-TOKEN' => @auth_token,
      accept: :json
    }))
end

#get_host(host_href) ⇒ Object



75
76
77
78
79
80
81
82
83
84
# File 'lib/vipruby.rb', line 75

def get_host(host_href)
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{base_url}#{host_href}",
    verify_ssl: @verify_cert,
    headers: {
      :'X-SDS-AUTH-TOKEN' => @auth_token,
      content_type: 'application/json',
      accept: :json
    }))
end

#host_exists?(hostname) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/vipruby.rb', line 101

def host_exists?(hostname)
  find_host_object(hostname)['resource'].any?
end