Module: ViprVcenter
- Included in:
- Vipr
- Defined in:
- lib/vipruby/objects/vcenter.rb
Overview
The Following vCenter calls will get vCenter information for all tenants
Instance Method Summary collapse
-
#add_vcenter(fqdn_or_ip = nil, name = nil, user_name = nil, password = nil, port = nil, tenant = nil, auth = nil, cert = nil) ⇒ Hash
Add a vCenters to a specified tenant.
-
#check_vcenter(vcenter_id = nil) ⇒ Boolean
private
Error Handling method to check for Missing vCenter ID param.
-
#check_vcenter_object_hash(vcenter_search_hash = nil) ⇒ Boolean
private
Error Handling method to check for Missing vCenter Object param.
-
#check_vcenter_post(fqdn_or_ip = nil, name = nil, user_name = nil, password = nil) ⇒ Boolean
private
Error Handling method to check for Missing Param.
-
#delete_vcenter(vcenter_id = nil, auth = nil, cert = nil) ⇒ Hash
Delete a vCenter from any tenant based on vCenter ID.
-
#find_vcenter_object(vcenter_search_hash = nil, auth = nil, cert = nil) ⇒ Hash
Search for vCenters matching a specific parameter.
-
#get_all_vcenters(auth = nil, cert = nil) ⇒ Hash
Retrive all vCenter Servers registered for all tenants.
-
#get_vcenter(vcenter_id = nil, auth = nil, cert = nil) ⇒ Hash
Retrieve information for a single vCenter server using the uid.
-
#get_vcenter_clusters(vcenter_id = nil, auth = nil, cert = nil) ⇒ Hash
Retrieve Cluster information for a single vCenter server using the uid.
-
#get_vcenter_datacenters(vcenter_id = nil, auth = nil, cert = nil) ⇒ Hash
Retrieve Datacenter information for a single vCenter server using the uid.
-
#get_vcenter_hosts(vcenter_id = nil, auth = nil, cert = nil) ⇒ Hash
Retrieve Host information for a single vCenter server using the uid.
Instance Method Details
#add_vcenter(fqdn_or_ip = nil, name = nil, user_name = nil, password = nil, port = nil, tenant = nil, auth = nil, cert = nil) ⇒ Hash
Add a vCenters to a specified tenant
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/vipruby/objects/vcenter.rb', line 92 def add_vcenter(fqdn_or_ip=nil, name=nil, user_name=nil, password=nil, port=nil, tenant=nil, auth=nil, cert=nil) check_vcenter_post(fqdn_or_ip, name, user_name, password) port.nil? ? port = '443' : port = port payload = { ip_address: fqdn_or_ip, name: name, port_number: port, user_name: user_name, password: password }.to_json rest_post(payload, "#{@base_url}/tenants/#{@tenant_uid}/vcenters", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert) end |
#check_vcenter(vcenter_id = nil) ⇒ Boolean (private)
Error Handling method to check for Missing vCenter ID param. If the pass fails, an error exception is raised
129 130 131 132 133 |
# File 'lib/vipruby/objects/vcenter.rb', line 129 def check_vcenter(vcenter_id=nil) if vcenter_id == nil raise "Missing vCenter ID param (vcenter_id)" end end |
#check_vcenter_object_hash(vcenter_search_hash = nil) ⇒ Boolean (private)
Error Handling method to check for Missing vCenter Object param. If the pass fails, an error exception is raised
141 142 143 144 145 |
# File 'lib/vipruby/objects/vcenter.rb', line 141 def check_vcenter_object_hash(vcenter_search_hash=nil) if vcenter_search_hash == nil raise "Missing vCenter Object to search as a param" end end |
#check_vcenter_post(fqdn_or_ip = nil, name = nil, user_name = nil, password = nil) ⇒ Boolean (private)
Error Handling method to check for Missing Param. If the pass fails, an error exception is raised
156 157 158 159 160 |
# File 'lib/vipruby/objects/vcenter.rb', line 156 def check_vcenter_post(fqdn_or_ip=nil, name=nil, user_name=nil, password=nil) if fqdn_or_ip == nil || name == nil || user_name == nil || password == nil raise "Missing a Required Param of fqdn_or_ip, name, port, user_name, or password" end end |
#delete_vcenter(vcenter_id = nil, auth = nil, cert = nil) ⇒ Hash
Delete a vCenter from any tenant based on vCenter ID
113 114 115 116 117 118 |
# File 'lib/vipruby/objects/vcenter.rb', line 113 def delete_vcenter(vcenter_id=nil, auth=nil, cert=nil) check_vcenter(vcenter_id) payload = { }.to_json rest_post(payload, "#{@base_url}/compute/vcenters/#{vcenter_id}/deactivate", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert) end |
#find_vcenter_object(vcenter_search_hash = nil, auth = nil, cert = nil) ⇒ Hash
Search for vCenters matching a specific parameter
73 74 75 76 |
# File 'lib/vipruby/objects/vcenter.rb', line 73 def find_vcenter_object(vcenter_search_hash=nil, auth=nil, cert=nil) check_vcenter_object_hash(vcenter_search_hash) rest_get("#{@base_url}/compute/vcenters/search?name=#{vcenter_search_hash}", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert) end |
#get_all_vcenters(auth = nil, cert = nil) ⇒ Hash
Retrive all vCenter Servers registered for all tenants
10 11 12 |
# File 'lib/vipruby/objects/vcenter.rb', line 10 def get_all_vcenters(auth=nil, cert=nil) rest_get("#{@base_url}/compute/vcenters/bulk", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert) end |
#get_vcenter(vcenter_id = nil, auth = nil, cert = nil) ⇒ Hash
Retrieve information for a single vCenter server using the uid
22 23 24 25 |
# File 'lib/vipruby/objects/vcenter.rb', line 22 def get_vcenter(vcenter_id=nil, auth=nil, cert=nil) check_vcenter(vcenter_id) rest_get("#{@base_url}/compute/vcenters/#{vcenter_id}", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert) end |
#get_vcenter_clusters(vcenter_id = nil, auth = nil, cert = nil) ⇒ Hash
Retrieve Cluster information for a single vCenter server using the uid
48 49 50 51 |
# File 'lib/vipruby/objects/vcenter.rb', line 48 def get_vcenter_clusters(vcenter_id=nil, auth=nil, cert=nil) check_vcenter(vcenter_id) rest_get("#{@base_url}/compute/vcenters/#{vcenter_id}/clusters", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert) end |
#get_vcenter_datacenters(vcenter_id = nil, auth = nil, cert = nil) ⇒ Hash
Retrieve Datacenter information for a single vCenter server using the uid
61 62 63 64 |
# File 'lib/vipruby/objects/vcenter.rb', line 61 def get_vcenter_datacenters(vcenter_id=nil, auth=nil, cert=nil) check_vcenter(vcenter_id) rest_get("#{@base_url}/compute/vcenters/#{vcenter_id}/vcenter-data-centers", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert) end |
#get_vcenter_hosts(vcenter_id = nil, auth = nil, cert = nil) ⇒ Hash
Retrieve Host information for a single vCenter server using the uid
35 36 37 38 |
# File 'lib/vipruby/objects/vcenter.rb', line 35 def get_vcenter_hosts(vcenter_id=nil, auth=nil, cert=nil) check_vcenter(vcenter_id) rest_get("#{@base_url}/compute/vcenters/#{vcenter_id}/hosts", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert) end |