Class: Bulldog

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Bulldog.



7
8
9
10
11
12
# File 'lib/heybulldog.rb', line 7

def initialize(base_url,user_name,password,verify_cert)
  @verify_cert = to_boolean(verify_cert)
  @user_name = user_name
  @password = password
  @base_url = base_url
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



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

def base_url
  @base_url
end

#passwordObject

Returns the value of attribute password.



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

def password
  @password
end

#user_nameObject

Returns the value of attribute user_name.



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

def user_name
  @user_name
end

#verify_certObject

Returns the value of attribute verify_cert.



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

def verify_cert
  @verify_cert
end

Instance Method Details

#create_snapshot(ancestor_vol_id, snap_vol_name, folder_id = nil) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/heybulldog.rb', line 147

def create_snapshot(ancestor_vol_id,snap_vol_name,folder_id=nil)
  
  payload = {}
  args = method(__method__).parameters.map { |arg| arg[1] }
  args.map.each do |arg| 
    payload[arg.to_s.gsub(/_/,'-')] = eval arg.to_s unless (eval arg.to_s).nil?
  end
  
   JSON.parse(RestClient::Request.execute(method: :post,
     url: "#{@base_url}/api/json/types/snapshots",
     verify_ssl: @verify_cert,
     payload: payload.to_json,
     user: @user_name,
     password: @password,
     headers: {
       content_type: 'application/json',
       accept: :json
     }))
end

#create_snapshot_from_folder(source_folder_id, suffix, folder_id = nil) ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/heybulldog.rb', line 187

def create_snapshot_from_folder(source_folder_id,suffix,folder_id=nil)
  
  payload = {}
  args = method(__method__).parameters.map { |arg| arg[1] }
  args.map.each do |arg| 
    payload[arg.to_s.gsub(/_/,'-')] = eval arg.to_s unless (eval arg.to_s).nil?
  end
  
   JSON.parse(RestClient::Request.execute(method: :post,
     url: "#{@base_url}/api/json/types/snapshots",
     verify_ssl: @verify_cert,
     payload: payload.to_json,
     user: @user_name,
     password: @password,
     headers: {
       content_type: 'application/json',
       accept: :json
     }))
end

#delete_snapshot(snap_href) ⇒ Object



207
208
209
210
211
212
213
214
# File 'lib/heybulldog.rb', line 207

def delete_snapshot(snap_href)
  RestClient::Request.execute(method: :delete,
    url: snap_href,
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    )
end

#get_cluster(cluster_href) ⇒ JSON

Get cluster deatils

Returns:

  • (JSON)

    returns a JSON collection of cluster details

Author:

  • Craig J Smith



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/heybulldog.rb', line 34

def get_cluster(cluster_href)
  JSON.parse(RestClient::Request.execute(method: :get,
    url: cluster_href,
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#get_clustersJSON

Get all Clusters

Returns:

  • (JSON)

    returns a JSON collection of all Clusters HREF and Name information

Author:

  • Craig J Smith



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/heybulldog.rb', line 18

def get_clusters
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{@base_url}/api/json/types/clusters",
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#get_initiator_groupsObject



216
217
218
219
220
221
222
223
224
225
226
# File 'lib/heybulldog.rb', line 216

def get_initiator_groups
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{@base_url}/api/json/types/initiator-groups",
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#get_snapshot(snap_href) ⇒ Object



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

def get_snapshot(snap_href)
  JSON.parse(RestClient::Request.execute(method: :get,
    url: snap_href,
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#get_snapshotsObject



135
136
137
138
139
140
141
142
143
144
145
# File 'lib/heybulldog.rb', line 135

def get_snapshots
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{@base_url}/api/json/types/snapshots",
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#get_target_groupsObject



248
249
250
251
252
253
254
255
256
257
258
# File 'lib/heybulldog.rb', line 248

def get_target_groups
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{@base_url}/api/json/types/target-groups",
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#get_volume(vol_href) ⇒ JSON

Get an individual volumes’s details

Parameters:

  • vol_href (STRING)

    HREF value of a volume

Returns:

  • (JSON)

    returns detailed volume information

Author:

  • Craig J Smith



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/heybulldog.rb', line 99

def get_volume(vol_href)
  JSON.parse(RestClient::Request.execute(method: :get,
    url: vol_href,
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#get_volume_by_id(vol_id) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/heybulldog.rb', line 111

def get_volume_by_id(vol_id)
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{@base_url}/api/json/types/volumes/#{vol_id}",
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#get_volumesJSON

Get all Volumes and Snapshots

Returns:

  • (JSON)

    returns a JSON collection of all Volume HREF and Name information

Author:

  • Craig J Smith



82
83
84
85
86
87
88
89
90
91
92
# File 'lib/heybulldog.rb', line 82

def get_volumes
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{@base_url}/api/json/types/volumes",
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#get_xbrick(xbrick_href) ⇒ JSON

Get X-Brick deatils

Returns:

  • (JSON)

    returns a JSON collection of X-Brick details

Author:

  • Craig J Smith



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/heybulldog.rb', line 66

def get_xbrick(xbrick_href)
  JSON.parse(RestClient::Request.execute(method: :get,
    url: xbrick_href,
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#get_xbricksJSON

Get all X-Bricks

Returns:

  • (JSON)

    returns a JSON collection of all X-Bricks HREF and Name information

Author:

  • Craig J Smith



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/heybulldog.rb', line 50

def get_xbricks
  JSON.parse(RestClient::Request.execute(method: :get,
    url: "#{@base_url}/api/json/types/bricks",
    headers: {
      accept: :json
    },
    verify_ssl: @verify_cert,
    user: @user_name,
    password: @password
    ))
end

#map_lun(vol_id, ig_id, lun = nil, tg_id = nil) ⇒ Object



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/heybulldog.rb', line 228

def map_lun(vol_id,ig_id,lun=nil,tg_id=nil)

  payload = {}
  args = method(__method__).parameters.map { |arg| arg[1] }
  args.map.each do |arg| 
    payload[arg.to_s.gsub(/_/,'-')] = eval arg.to_s unless (eval arg.to_s).nil?
  end
  
   JSON.parse(RestClient::Request.execute(method: :post,
     url: "#{@base_url}/api/json/types/lun-maps",
     verify_ssl: @verify_cert,
     payload: payload.to_json,
     user: @user_name,
     password: @password,
     headers: {
       content_type: 'application/json',
       accept: :json
     }))
end

#refresh_snapshot_group(cluster_id, from_consistency_group_id, to_snapshot_set_id) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/heybulldog.rb', line 167

def refresh_snapshot_group(cluster_id,from_consistency_group_id,to_snapshot_set_id)

  payload = {}
  args = method(__method__).parameters.map { |arg| arg[1] }
  args.map.each do |arg| 
    payload[arg.to_s.gsub(/_/,'-')] = eval arg.to_s unless (eval arg.to_s).nil?
  end

   JSON.parse(RestClient::Request.execute(method: :post,
     url: "#{@base_url}/api/json/types/snapshots",
     verify_ssl: @verify_cert,
     payload: payload.to_json,
     user: @user_name,
     password: @password,
     headers: {
       content_type: 'application/json',
       accept: :json
     }))
end

#to_boolean(str) ⇒ Object



284
285
286
# File 'lib/heybulldog.rb', line 284

def to_boolean(str)
  str.to_s.downcase == "true"
end