vipruby 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vipruby.rb +28 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 359e366d563097e007962688c29d365f5490af19
4
- data.tar.gz: 9d36ccc7aae5e4c2cf02d7810e09c3abadf0d8b5
3
+ metadata.gz: 6ab3ab1dd63ac844fa16b523cf7d5f1e38a38ddb
4
+ data.tar.gz: efd96f3f8ffcc7c96d56618ae049e966dc960d0f
5
5
  SHA512:
6
- metadata.gz: d0abe38028c4841923727268975c72681ef27ab3f721cf151a724a63b2836ec9d1332fd98ec5173f9db7180c99e95d046e76882d924c148c12ece6067dc9f4e5
7
- data.tar.gz: 7f733c432d3b79b839b4c8dc36350a8ed1ea9ded721f896e11454a67a9a4b1aa9ea2a8ed4f7b7ec2d750ad9b3556d649fa527fa095673214fe4a7245dcc929bb
6
+ metadata.gz: 8a38f49600d6fff79abcf53665b8c1b79ed974ed9c9589a3bd55e1e14ae0fa4c1e9c1f36cc7d61371e95f407e34e8f62bbc1101d56fef354639d3c5e4911ca02
7
+ data.tar.gz: d9549c81092763a364767c70d89835b738dfc4eab0b977fca5386a30cd7c37eda1b50032e5100dd73084c71a840f084b09f8db6b7817f7ad935afde5683fd948
@@ -3,10 +3,9 @@ require 'json'
3
3
 
4
4
  class Vipruby
5
5
  attr_accessor :tenant_uid, :auth_token, :base_url, :verify_cert
6
- SSL_VERSION = 'TLSv1'
6
+ #SSL_VERSION = 'TLSv1'
7
7
 
8
8
  def initialize(base_url,user_name,password,verify_cert)
9
- #add condition later for trusted certs (This ignores)
10
9
  @base_url = base_url
11
10
  @verify_cert = to_boolean(verify_cert)
12
11
  @auth_token = get_auth_token(user_name,password)
@@ -62,18 +61,40 @@ class Vipruby
62
61
  end
63
62
  end
64
63
 
65
- def get_hosts
66
- JSON.parse(RestClient::Request.execute(method: :get,url: "#{@base_url}/tenants/#{@tenant_uid}/hosts",
64
+ def get_all_hosts
65
+ JSON.parse(RestClient::Request.execute(method: :get,
66
+ url: "#{@base_url}/tenants/#{@tenant_uid}/hosts",
67
+ verify_ssl: @verify_cert,
68
+ headers: {
69
+ :'X-SDS-AUTH-TOKEN' => @auth_token,
70
+ accept: :json
71
+ }))
72
+ end
73
+
74
+ def get_host(host_href)
75
+ JSON.parse(RestClient::Request.execute(method: :get,
76
+ url: "#{base_url}#{host_href}",
77
+ verify_ssl: @verify_cert,
78
+ headers: {
79
+ :'X-SDS-AUTH-TOKEN' => @auth_token,
80
+ content_type: 'application/json',
81
+ accept: :json
82
+ }))
83
+ end
84
+
85
+ def deactivate_host(host_href)
86
+ JSON.parse(RestClient::Request.execute(method: :post,
87
+ url: "#{base_url}#{host_href}/deactivate",
67
88
  verify_ssl: @verify_cert,
68
89
  headers: {
69
90
  :'X-SDS-AUTH-TOKEN' => @auth_token,
91
+ content_type: 'application/json',
70
92
  accept: :json
71
93
  }))
72
94
  end
73
95
 
74
96
  def add_host_and_initiators(host)
75
- new_host = add_host(host.generate_json)
76
- add_initiators(host.generate_initiators_json,new_host['resource']['link']['href'])
97
+ add_initiators(host.generate_initiators_json,add_host(host.generate_json)['resource']['link']['href'])
77
98
  end
78
99
 
79
100
  def host_exists?(hostname)
@@ -91,7 +112,7 @@ class Vipruby
91
112
  end
92
113
 
93
114
  def to_boolean(str)
94
- str.downcase == 'true'
115
+ str.to_s.downcase == "true"
95
116
  end
96
117
 
97
118
  private :login, :get_auth_token, :get_tenant_uid, :to_boolean
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vipruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig J Smith