Class: Bulldog
- Inherits:
-
Object
- Object
- Bulldog
- Defined in:
- lib/heybulldog.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#password ⇒ Object
Returns the value of attribute password.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
-
#verify_cert ⇒ Object
Returns the value of attribute verify_cert.
Instance Method Summary collapse
- #create_snapshot(ancestor_vol_id, snap_vol_name, folder_id = nil) ⇒ Object
- #create_snapshot_from_folder(source_folder_id, suffix, folder_id = nil) ⇒ Object
- #delete_snapshot(snap_href) ⇒ Object
-
#get_cluster(cluster_href) ⇒ JSON
Get cluster deatils.
-
#get_clusters ⇒ JSON
Get all Clusters.
- #get_initiator_groups ⇒ Object
- #get_snapshot(snap_href) ⇒ Object
- #get_snapshots ⇒ Object
- #get_target_groups ⇒ Object
-
#get_volume(vol_href) ⇒ JSON
Get an individual volumes’s details.
- #get_volume_by_id(vol_id) ⇒ Object
-
#get_volumes ⇒ JSON
Get all Volumes and Snapshots.
-
#get_xbrick(xbrick_href) ⇒ JSON
Get X-Brick deatils.
-
#get_xbricks ⇒ JSON
Get all X-Bricks.
-
#initialize(base_url, user_name, password, verify_cert) ⇒ Bulldog
constructor
A new instance of Bulldog.
- #map_lun(vol_id, ig_id, lun = nil, tg_id = nil) ⇒ Object
- #refresh_snapshot_group(cluster_id, from_consistency_group_id, to_snapshot_set_id) ⇒ Object
- #to_boolean(str) ⇒ Object
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_url ⇒ Object
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/heybulldog.rb', line 5 def base_url @base_url end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/heybulldog.rb', line 5 def password @password end |
#user_name ⇒ Object
Returns the value of attribute user_name.
5 6 7 |
# File 'lib/heybulldog.rb', line 5 def user_name @user_name end |
#verify_cert ⇒ Object
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
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_clusters ⇒ JSON
Get all Clusters
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_groups ⇒ Object
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_snapshots ⇒ Object
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_groups ⇒ Object
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
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_volumes ⇒ JSON
Get all Volumes and Snapshots
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
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_xbricks ⇒ JSON
Get all X-Bricks
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 |