Class: Hpe3parSdk::CPGManager
- Inherits:
-
Object
- Object
- Hpe3parSdk::CPGManager
- Defined in:
- lib/Hpe3parSdk/cpg_manager.rb
Instance Method Summary collapse
- #cpg_exists?(name) ⇒ Boolean
- #create_cpg(name, optional = nil) ⇒ Object
- #delete_cpg(name) ⇒ Object
- #get_cpg(name) ⇒ Object
- #get_cpg_available_space(name) ⇒ Object
- #get_cpgs ⇒ Object
-
#initialize(http) ⇒ CPGManager
constructor
A new instance of CPGManager.
- #modify_cpg(name, cpg_mods) ⇒ Object
Constructor Details
#initialize(http) ⇒ CPGManager
Returns a new instance of CPGManager.
16 17 18 |
# File 'lib/Hpe3parSdk/cpg_manager.rb', line 16 def initialize(http) @http = http end |
Instance Method Details
#cpg_exists?(name) ⇒ Boolean
62 63 64 65 66 67 68 69 |
# File 'lib/Hpe3parSdk/cpg_manager.rb', line 62 def cpg_exists?(name) begin get_cpg(name) return true rescue Hpe3parSdk::HTTPNotFound => ex return false end end |
#create_cpg(name, optional = nil) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/Hpe3parSdk/cpg_manager.rb', line 37 def create_cpg(name, optional = nil) info = { 'name' => name } info = Util.merge_hash(info, optional) if optional cpgs_url = '/cpgs' response = @http.post(cpgs_url, body: info) response[1] end |
#delete_cpg(name) ⇒ Object
57 58 59 60 |
# File 'lib/Hpe3parSdk/cpg_manager.rb', line 57 def delete_cpg(name) response = @http.delete("/cpgs/#{name}") response[1] end |
#get_cpg(name) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/Hpe3parSdk/cpg_manager.rb', line 29 def get_cpg(name) if name.nil? || name.strip.empty? raise 'CPG name cannot be nil or empty' else CPG.new(@http.get("/cpgs/#{name}")[1]) end end |
#get_cpg_available_space(name) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/Hpe3parSdk/cpg_manager.rb', line 50 def get_cpg_available_space(name) info = { 'cpg' => name } response = @http.post('/spacereporter', body: info) LDLayoutCapacity.new(response[1]) end |
#get_cpgs ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/Hpe3parSdk/cpg_manager.rb', line 20 def get_cpgs cpg_list=[] cpg_members = @http.get('/cpgs')[1]['members'] cpg_members.each do |cpgmember| cpg_list.push(CPG.new(cpgmember)) end cpg_list end |
#modify_cpg(name, cpg_mods) ⇒ Object
46 47 48 |
# File 'lib/Hpe3parSdk/cpg_manager.rb', line 46 def modify_cpg(name, cpg_mods) @http.put("/cpgs/#{name}", body: cpg_mods)[1] end |