vipruby 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vipruby.rb +28 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ab3ab1dd63ac844fa16b523cf7d5f1e38a38ddb
|
4
|
+
data.tar.gz: efd96f3f8ffcc7c96d56618ae049e966dc960d0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a38f49600d6fff79abcf53665b8c1b79ed974ed9c9589a3bd55e1e14ae0fa4c1e9c1f36cc7d61371e95f407e34e8f62bbc1101d56fef354639d3c5e4911ca02
|
7
|
+
data.tar.gz: d9549c81092763a364767c70d89835b738dfc4eab0b977fca5386a30cd7c37eda1b50032e5100dd73084c71a840f084b09f8db6b7817f7ad935afde5683fd948
|
data/lib/vipruby.rb
CHANGED
@@ -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
|
66
|
-
JSON.parse(RestClient::Request.execute(method: :get,
|
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
|
-
|
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 ==
|
115
|
+
str.to_s.downcase == "true"
|
95
116
|
end
|
96
117
|
|
97
118
|
private :login, :get_auth_token, :get_tenant_uid, :to_boolean
|