Class: IbmPowerHmc::Connection
- Inherits:
-
Object
- Object
- IbmPowerHmc::Connection
- Defined in:
- lib/ibm_power_hmc/apis/connection.rb,
lib/ibm_power_hmc/apis/pcm.rb,
lib/ibm_power_hmc/apis/sem.rb,
lib/ibm_power_hmc/apis/uom.rb,
lib/ibm_power_hmc/apis/templates.rb
Overview
HMC REST Client connection.
Defined Under Namespace
Classes: HttpError, HttpNotFound
Class Method Summary collapse
-
.format_time(time) ⇒ String
Convert ruby time to HMC time format.
Instance Method Summary collapse
-
#capture_lpar(lpar_uuid, sys_uuid, template_name, sync = true) ⇒ IbmPowerHmc::HmcJob
Capture partition configuration as template.
-
#chcomgmt(sys_uuid, status) ⇒ IbmPowerHmc::HmcJob
Change the co-management settings for a managed system.
-
#cli_run(hmc_uuid, cmd, sync = true) ⇒ IbmPowerHmc::HmcJob
Run a CLI command on the HMC as a job.
-
#cluster(cl_uuid) ⇒ IbmPowerHmc::Cluster
Retrieve information about a cluster.
-
#clusters(permissive = true) ⇒ Array<IbmPowerHmc::Cluster>
Retrieve the list of clusters managed by the HMC.
-
#format_time(time) ⇒ String
Convert ruby time to HMC time format.
-
#groups ⇒ Array<IbmPowerHmc::Group>
Retrieve the list of groups defined on the HMC.
-
#grow_lu(cl_uuid, lu_uuid, capacity) ⇒ IbmPowerHmc::HmcJob
Increase the size of a logical unit in a cluster.
-
#initialize(host: , password: , username: "hscroot", port: 12_443, validate_ssl: true, timeout: 60) ⇒ Connection
constructor
Create a new HMC connection.
-
#logoff ⇒ Object
Close the session.
-
#logon ⇒ String
Establish a trusted session with the Web Services APIs.
-
#lpar(lpar_uuid, sys_uuid = nil, group_name = nil) ⇒ IbmPowerHmc::LogicalPartition
Retrieve information about a logical partition.
-
#lpar_delete(lpar_uuid) ⇒ Object
Delete a logical partition.
-
#lpar_metrics(sys_uuid: , lpar_uuid: , start_ts: nil, end_ts: nil, no_samples: nil, aggregated: false) ⇒ Array<Hash>
Retrieve metrics for a logical partition.
-
#lpar_migrate(lpar_uuid, target_sys_name, sync = true) ⇒ Object
Migrate a logical partition to another managed system.
-
#lpar_migrate_validate(lpar_uuid, target_sys_name, sync = true) ⇒ Object
Validate if a logical partition can be migrated to another managed system.
-
#lpar_quick_property(lpar_uuid, property_name) ⇒ String
Retrieve a quick property of a logical partition.
-
#lpars(sys_uuid = nil, search = nil, group_name = nil) ⇒ Array<IbmPowerHmc::LogicalPartition>
Retrieve the list of logical partitions managed by the HMC.
-
#lpars_quick(sys_uuid = nil) ⇒ Array<Hash>
Retrieve the list of logical partitions managed by the HMC (using Quick API).
-
#managed_system(sys_uuid, group_name = nil) ⇒ IbmPowerHmc::ManagedSystem
Retrieve information about a managed system.
-
#managed_system_metrics(sys_uuid: , start_ts: nil, end_ts: nil, no_samples: nil, aggregated: false) ⇒ Array<Hash>
Retrieve metrics for a managed system.
-
#managed_system_pcm_preferences(sys_uuid) ⇒ IbmPowerHmc::ManagedSystemPcmPreference
Return Performance and Capacity Monitor preferences for a Managed System.
-
#managed_system_quick(sys_uuid, property = nil) ⇒ Hash
Retrieve information about a managed system (using Quick API).
-
#managed_systems(search = nil, group_name = nil) ⇒ Array<IbmPowerHmc::ManagedSystem>
Retrieve the list of systems managed by the HMC.
-
#managed_systems_quick ⇒ Array<Hash>
Retrieve the list of systems managed by the HMC (using Quick API).
-
#management_console ⇒ IbmPowerHmc::ManagementConsole
Retrieve information about the management console.
-
#modify_object(headers = {}, attempts = 5) ⇒ Object
Post an IbmPowerHmc::AbstractRest object iteratively using ETag.
-
#network_adapter_lpar(lpar_uuid, netadap_uuid = nil) ⇒ Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter
Retrieve one or all virtual ethernet network adapters attached to a logical partition.
-
#network_adapter_lpar_create(lpar_uuid, sys_uuid, vswitch_uuid, **args) ⇒ IbmPowerHmc::ClientNetworkAdapter
Create a virtual ethernet network adapter attached to a logical partition.
-
#network_adapter_lpar_delete(lpar_uuid, netadap_uuid) ⇒ Object
Delete a virtual ethernet network adapter attached to a logical partition.
-
#network_adapter_vios(vios_uuid, netadap_uuid = nil) ⇒ Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter
Retrieve one or all virtual ethernet network adapters attached to a Virtual I/O Server.
-
#next_events(wait = true) ⇒ Array<IbmPowerHmc::Event>
Retrieve a list of events that occured since last call.
-
#pcm_preferences ⇒ Array<IbmPowerHmc::ManagementConsolePcmPreference>
Retrieve global Performance and Capacity Monitor preferences for the HMC.
-
#phyp_metrics(sys_uuid: , start_ts: nil, end_ts: nil, short_term: false) ⇒ Array<Hash>
Retrieve PowerVM metrics for a given managed system.
-
#poweroff_lpar(lpar_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power off a logical partition.
-
#poweroff_managed_system(sys_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power off a managed system.
-
#poweroff_vios(vios_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power off a virtual I/O server.
-
#poweron_lpar(lpar_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power on a logical partition.
-
#poweron_managed_system(sys_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power on a managed system.
-
#poweron_vios(vios_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power on a virtual I/O server.
-
#remove_connection(hmc_uuid, sys_uuid, sync = true) ⇒ IbmPowerHmc::HmcJob
Remove a managed system from the management console.
-
#request(method, url, headers = {}, payload = nil) ⇒ RestClient::Response
Perform a REST API request.
-
#schema(type) ⇒ REXML::Document
Retrieve the XML schema file for a given object type.
-
#serviceable_events(status = nil) ⇒ Array<IbmPowerHmc::ServiceableEvent>
Retrieve serviceable events from the HMC.
-
#shared_memory_pool(sys_uuid, pool_uuid = nil) ⇒ Array<IbmPowerHmc::SharedMemoryPool>, IbmPowerHmc::SharedMemoryPool
Retrieve information about Shared Memory Pools.
-
#shared_processor_pool(sys_uuid, pool_uuid = nil) ⇒ Array<IbmPowerHmc::SharedProcessorPool>, IbmPowerHmc::SharedProcessorPool
Retrieve information about Shared Processor Pools.
-
#sriov_elp_lpar(lpar_uuid, sriov_elp_uuid = nil) ⇒ Array<IbmPowerHmc::SRIOVEthernetLogicalPort>, IbmPowerHmc::SRIOVEthernetLogicalPort
Retrieve one or all SR-IOV ethernet logical ports attached to a logical partition.
-
#sriov_elp_vios(vios_uuid, sriov_elp_uuid = nil) ⇒ Array<IbmPowerHmc::SRIOVEthernetLogicalPort>, IbmPowerHmc::SRIOVEthernetLogicalPort
Retrieve one or all SR-IOV ethernet logical ports attached to a Virtual I/O Server.
-
#ssp(ssp_uuid) ⇒ IbmPowerHmc::SharedStoragePool
Retrieve information about a shared storage pool.
-
#ssps(permissive = true) ⇒ Array<IbmPowerHmc::SharedStoragePool>
Retrieve the list of shared storage pools managed by the HMC.
-
#template(template_uuid) ⇒ IbmPowerHmc::PartitionTemplate
Retrieve details for a particular partition template.
-
#template_check(template_uuid, target_sys_uuid, sync = true) ⇒ IbmPowerHmc::HmcJob
Start Template Check job (first of three steps to deploy an LPAR from a Template).
-
#template_copy(template_uuid, new_name) ⇒ IbmPowerHmc::PartitionTemplate
Copy existing template to a new one.
-
#template_deploy(draft_template_uuid, target_sys_uuid, sync = true) ⇒ IbmPowerHmc::HmcJob
Start Template Deploy job (last of three steps to deploy an LPAR from a Template).
-
#template_modify(template_uuid, changes) ⇒ Object
Modify a template.
-
#template_provision(template_uuid, target_sys_uuid, changes) ⇒ String
Deploy Logical Partition from a Template (performs Check, Transform and Deploy steps in a single method).
-
#template_transform(draft_template_uuid, target_sys_uuid, sync = true) ⇒ IbmPowerHmc::HmcJob
Start Template Transform job (second of three steps to deploy an LPAR from a Template).
-
#templates(draft = false) ⇒ Array<IbmPowerHmc::PartitionTemplate>
Retrieve the list of partition templates.
-
#templates_summary(draft = false) ⇒ Array<IbmPowerHmc::PartitionTemplateSummary>
Retrieve the list of partition template summaries.
-
#tier(tier_uuid, ssp_uuid = nil, group_name = nil) ⇒ IbmPowerHmc::Tier
Retrieve information about a tier.
-
#tiers(group_name = nil, permissive = true) ⇒ Array<IbmPowerHmc::Tier>
Retrieve the list of tiers that are part of shared storage pools managed by the HMC.
-
#usertask(uuid = true) ⇒ Hash
Retrieve details of an event of type “user task”.
-
#vfc_client_adapter(lpar_uuid, adap_uuid = nil) ⇒ Array<IbmPowerHmc::VirtualFibreChannelClientAdapter>, IbmPowerHmc::VirtualFibreChannelClientAdapter
Retrieve one or all virtual Fibre Channel storage client adapters attached to a logical partition.
-
#vios(vios_uuid, sys_uuid = nil, group_name = nil) ⇒ IbmPowerHmc::VirtualIOServer
Retrieve information about a virtual I/O server.
-
#vioses(sys_uuid = nil, search = nil, group_name = nil, permissive = true) ⇒ Array<IbmPowerHmc::VirtualIOServer>
Retrieve the list of virtual I/O servers managed by the HMC.
-
#vioses_quick(sys_uuid = nil) ⇒ Array<Hash>
Retrieve the list of virtual I/O servers managed by the HMC (using Quick API).
-
#virtual_network(vnet_uuid, sys_uuid) ⇒ IbmPowerHmc::VirtualNetwork
Retrieve information about a virtual network.
-
#virtual_networks(sys_uuid) ⇒ Array<IbmPowerHmc::VirtualNetwork>
Retrieve the list of virtual networks from a specified managed system.
-
#virtual_switch(vswitch_uuid, sys_uuid) ⇒ IbmPowerHmc::VirtualSwitch
Retrieve information about a virtual switch.
-
#virtual_switches(sys_uuid) ⇒ Array<IbmPowerHmc::VirtualSwitch>
Retrieve the list of virtual switches from a specified managed system.
-
#vnic_dedicated(lpar_uuid, vnic_uuid = nil) ⇒ Array<IbmPowerHmc::VirtualNICDedicated>, IbmPowerHmc::VirtualNICDedicated
Retrieve one or all dedicated virtual network interface controller (vNIC) attached to a logical partition.
-
#volume_group(vios_uuid, vg_uuid) ⇒ IbmPowerHmc::VolumeGroup
Retrieve information about a volume group on a virtual I/O server.
-
#volume_groups(vios_uuid) ⇒ Array<IbmPowerHmc::VolumeGroup>
Retrieve the list of volume groups available on a virtual I/O server.
-
#vscsi_client_adapter(lpar_uuid, adap_uuid = nil) ⇒ Array<IbmPowerHmc::VirtualSCSIClientAdapter>, IbmPowerHmc::VirtualSCSIClientAdapter
Retrieve one or all virtual SCSI storage client adapters attached to a logical partition.
Constructor Details
#initialize(host: , password: , username: "hscroot", port: 12_443, validate_ssl: true, timeout: 60) ⇒ Connection
Create a new HMC connection.
23 24 25 26 27 28 29 30 |
# File 'lib/ibm_power_hmc/apis/connection.rb', line 23 def initialize(host:, password:, username: "hscroot", port: 12_443, validate_ssl: true, timeout: 60) @hostname = "#{host}:#{port}" @username = username @password = password @verify_ssl = validate_ssl @api_session_token = nil @timeout = timeout end |
Class Method Details
.format_time(time) ⇒ String
Convert ruby time to HMC time format.
131 132 133 |
# File 'lib/ibm_power_hmc/apis/pcm.rb', line 131 def self.format_time(time) time.utc.xmlschema end |
Instance Method Details
#capture_lpar(lpar_uuid, sys_uuid, template_name, sync = true) ⇒ IbmPowerHmc::HmcJob
Capture partition configuration as template.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 46 def capture_lpar(lpar_uuid, sys_uuid, template_name, sync = true) # Need to include session token in payload so make sure we are logged in logon if @api_session_token.nil? method_url = "/rest/api/templates/PartitionTemplate/do/capture" params = { "TargetUuid" => lpar_uuid, "NewTemplateName" => template_name, "ManagedSystemUuid" => sys_uuid, "K_X_API_SESSION_MEMENTO" => @api_session_token } job = HmcJob.new(self, method_url, "Capture", "PartitionTemplate", params) job.run if sync job end |
#chcomgmt(sys_uuid, status) ⇒ IbmPowerHmc::HmcJob
Change the co-management settings for a managed system.
688 689 690 691 692 693 694 695 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 688 def chcomgmt(sys_uuid, status) operation = status == "rel" ? "ReleaseController" : "RequestController" method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/do/#{operation}" params = {} params["coManagementControllerStatus"] = status unless status == "rel" HmcJob.new(self, method_url, operation, "ManagedSystem", params).tap(&:run) end |
#cli_run(hmc_uuid, cmd, sync = true) ⇒ IbmPowerHmc::HmcJob
Run a CLI command on the HMC as a job.
704 705 706 707 708 709 710 711 712 713 714 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 704 def cli_run(hmc_uuid, cmd, sync = true) method_url = "/rest/api/uom/ManagementConsole/#{hmc_uuid}/do/CLIRunner" params = { "cmd" => cmd, "acknowledgeThisAPIMayGoAwayInTheFuture" => "true", } job = HmcJob.new(self, method_url, "CLIRunner", "ManagementConsole", params) job.run if sync job end |
#cluster(cl_uuid) ⇒ IbmPowerHmc::Cluster
Retrieve information about a cluster.
484 485 486 487 488 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 484 def cluster(cl_uuid) method_url = "/rest/api/uom/Cluster/#{cl_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:Cluster) end |
#clusters(permissive = true) ⇒ Array<IbmPowerHmc::Cluster>
Retrieve the list of clusters managed by the HMC.
473 474 475 476 477 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 473 def clusters(permissive = true) method_url = "/rest/api/uom/Cluster#{'?ignoreError=true' if permissive}" response = request(:get, method_url) FeedParser.new(response.body).objects(:Cluster) end |
#format_time(time) ⇒ String
Convert ruby time to HMC time format.
131 132 133 |
# File 'lib/ibm_power_hmc/apis/pcm.rb', line 131 def self.format_time(time) time.utc.xmlschema end |
#groups ⇒ Array<IbmPowerHmc::Group>
Retrieve the list of groups defined on the HMC. A logical partition, a virtual I/O server or a managed system can be associated with multiple group tags.
266 267 268 269 270 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 266 def groups method_url = "/rest/api/uom/Group" response = request(:get, method_url) FeedParser.new(response.body).objects(:Group) end |
#grow_lu(cl_uuid, lu_uuid, capacity) ⇒ IbmPowerHmc::HmcJob
Increase the size of a logical unit in a cluster.
723 724 725 726 727 728 729 730 731 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 723 def grow_lu(cl_uuid, lu_uuid, capacity) method_url = "/rest/api/uom/Cluster/#{cl_uuid}/do/GrowLogicalUnit" params = { "LogicalUnitUDID" => lu_uuid, "Capacity" => capacity } HmcJob.new(self, method_url, "GrowLogicalUnit", "Cluster", params).tap(&:run) end |
#logoff ⇒ Object
Close the session.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ibm_power_hmc/apis/connection.rb', line 59 def logoff # Don't want to trigger automatic logon here! return if @api_session_token.nil? method_url = "/rest/api/web/Logon" begin request(:delete, method_url) rescue # Ignore exceptions as this is best effort attempt to log off. end @api_session_token = nil end |
#logon ⇒ String
Establish a trusted session with the Web Services APIs.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ibm_power_hmc/apis/connection.rb', line 36 def logon method_url = "/rest/api/web/Logon" headers = { :content_type => "application/vnd.ibm.powervm.web+xml; type=LogonRequest" } doc = REXML::Document.new("") doc.add_element("LogonRequest", "schemaVersion" => "V1_1_0") doc.root.add_namespace(WEB_XMLNS) doc.root.add_element("UserID").text = @username doc.root.add_element("Password").text = @password @api_session_token = "" response = request(:put, method_url, headers, doc.to_s) doc = REXML::Document.new(response.body) elem = doc.elements["LogonResponse/X-API-Session"] raise Error, "LogonResponse/X-API-Session not found" if elem.nil? @api_session_token = elem.text end |
#lpar(lpar_uuid, sys_uuid = nil, group_name = nil) ⇒ IbmPowerHmc::LogicalPartition
Retrieve information about a logical partition.
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 94 def lpar(lpar_uuid, sys_uuid = nil, group_name = nil) if sys_uuid.nil? method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}" else method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/LogicalPartition/#{lpar_uuid}" end method_url += "?group=#{group_name}" unless group_name.nil? response = request(:get, method_url) Parser.new(response.body).object(:LogicalPartition) end |
#lpar_delete(lpar_uuid) ⇒ Object
Delete a logical partition.
174 175 176 177 178 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 174 def lpar_delete(lpar_uuid) method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}" request(:delete, method_url) # Returns HTTP 204 if ok end |
#lpar_metrics(sys_uuid: , lpar_uuid: , start_ts: nil, end_ts: nil, no_samples: nil, aggregated: false) ⇒ Array<Hash>
Retrieve metrics for a logical partition.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ibm_power_hmc/apis/pcm.rb', line 104 def lpar_metrics(sys_uuid:, lpar_uuid:, start_ts: nil, end_ts: nil, no_samples: nil, aggregated: false) type = aggregated ? "AggregatedMetrics" : "ProcessedMetrics" method_url = "/rest/api/pcm/ManagedSystem/#{sys_uuid}/LogicalPartition/#{lpar_uuid}/#{type}" query = {} query["StartTS"] = self.class.format_time(start_ts) unless start_ts.nil? query["EndTS"] = self.class.format_time(end_ts) unless end_ts.nil? query["NoOfSamples"] = no_samples unless no_samples.nil? method_url += "?" + query.map { |h| h.join("=") }.join("&") unless query.empty? response = request(:get, method_url) FeedParser.new(response.body).entries do |entry| link = entry.elements["link"] next if link.nil? href = link.attributes["href"] next if href.nil? response = request(:get, href) JSON.parse(response.body) end.compact end |
#lpar_migrate(lpar_uuid, target_sys_name, sync = true) ⇒ Object
Migrate a logical partition to another managed system.
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 158 def lpar_migrate(lpar_uuid, target_sys_name, sync = true) # Need to include session token in payload so make sure we are logged in logon if @api_session_token.nil? method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/do/Migrate" params = { "TargetManagedSystemName" => target_sys_name } HmcJob.new(self, method_url, "Migrate", "LogicalPartition", params).tap do |job| job.run if sync end end |
#lpar_migrate_validate(lpar_uuid, target_sys_name, sync = true) ⇒ Object
Validate if a logical partition can be migrated to another managed system.
140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 140 def lpar_migrate_validate(lpar_uuid, target_sys_name, sync = true) # Need to include session token in payload so make sure we are logged in logon if @api_session_token.nil? method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/do/MigrateValidate" params = { "TargetManagedSystemName" => target_sys_name } HmcJob.new(self, method_url, "MigrateValidate", "LogicalPartition", params).tap do |job| job.run if sync end end |
#lpar_quick_property(lpar_uuid, property_name) ⇒ String
Retrieve a quick property of a logical partition.
126 127 128 129 130 131 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 126 def lpar_quick_property(lpar_uuid, property_name) method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/quick/#{property_name}" response = request(:get, method_url) response.body[1..-2] end |
#lpars(sys_uuid = nil, search = nil, group_name = nil) ⇒ Array<IbmPowerHmc::LogicalPartition>
Retrieve the list of logical partitions managed by the HMC.
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 75 def lpars(sys_uuid = nil, search = nil, group_name = nil) if sys_uuid.nil? method_url = "/rest/api/uom/LogicalPartition" method_url += "/search/(#{ERB::Util.url_encode(search)})" unless search.nil? else method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/LogicalPartition" end method_url += "?group=#{group_name}" unless group_name.nil? response = request(:get, method_url) FeedParser.new(response.body).objects(:LogicalPartition) end |
#lpars_quick(sys_uuid = nil) ⇒ Array<Hash>
Retrieve the list of logical partitions managed by the HMC (using Quick API).
110 111 112 113 114 115 116 117 118 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 110 def lpars_quick(sys_uuid = nil) if sys_uuid.nil? method_url = "/rest/api/uom/LogicalPartition/quick/All" else method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/LogicalPartition/quick/All" end response = request(:get, method_url) JSON.parse(response.body) end |
#managed_system(sys_uuid, group_name = nil) ⇒ IbmPowerHmc::ManagedSystem
Retrieve information about a managed system.
38 39 40 41 42 43 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 38 def managed_system(sys_uuid, group_name = nil) method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}" method_url += "?group=#{group_name}" unless group_name.nil? response = request(:get, method_url) Parser.new(response.body).object(:ManagedSystem) end |
#managed_system_metrics(sys_uuid: , start_ts: nil, end_ts: nil, no_samples: nil, aggregated: false) ⇒ Array<Hash>
Retrieve metrics for a managed system.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ibm_power_hmc/apis/pcm.rb', line 66 def managed_system_metrics(sys_uuid:, start_ts: nil, end_ts: nil, no_samples: nil, aggregated: false) type = aggregated ? "AggregatedMetrics" : "ProcessedMetrics" method_url = "/rest/api/pcm/ManagedSystem/#{sys_uuid}/#{type}" query = {} query["StartTS"] = self.class.format_time(start_ts) unless start_ts.nil? query["EndTS"] = self.class.format_time(end_ts) unless end_ts.nil? query["NoOfSamples"] = no_samples unless no_samples.nil? method_url += "?" + query.map { |h| h.join("=") }.join("&") unless query.empty? response = request(:get, method_url) FeedParser.new(response.body).entries do |entry| category = entry.elements["category"] next if category.nil? term = category.attributes["term"] next if term.nil? || term != "ManagedSystem" link = entry.elements["link"] next if link.nil? href = link.attributes["href"] next if href.nil? response = request(:get, href) JSON.parse(response.body) end.compact end |
#managed_system_pcm_preferences(sys_uuid) ⇒ IbmPowerHmc::ManagedSystemPcmPreference
Return Performance and Capacity Monitor preferences for a Managed System.
24 25 26 |
# File 'lib/ibm_power_hmc/apis/pcm.rb', line 24 def managed_system_pcm_preferences(sys_uuid) pcm_preferences.first.managed_system_preferences.find { |p| p.id.eql?(sys_uuid) } end |
#managed_system_quick(sys_uuid, property = nil) ⇒ Hash
Retrieve information about a managed system (using Quick API).
61 62 63 64 65 66 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 61 def managed_system_quick(sys_uuid, property = nil) method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/quick" method_url += "/#{property}" unless property.nil? response = request(:get, method_url) JSON.parse(response.body) end |
#managed_systems(search = nil, group_name = nil) ⇒ Array<IbmPowerHmc::ManagedSystem>
Retrieve the list of systems managed by the HMC.
24 25 26 27 28 29 30 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 24 def managed_systems(search = nil, group_name = nil) method_url = "/rest/api/uom/ManagedSystem" method_url += "/search/(#{ERB::Util.url_encode(search)})" unless search.nil? method_url += "?group=#{group_name}" unless group_name.nil? response = request(:get, method_url) FeedParser.new(response.body).objects(:ManagedSystem) end |
#managed_systems_quick ⇒ Array<Hash>
Retrieve the list of systems managed by the HMC (using Quick API).
49 50 51 52 53 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 49 def managed_systems_quick method_url = "/rest/api/uom/ManagedSystem/quick/All" response = request(:get, method_url) JSON.parse(response.body) end |
#management_console ⇒ IbmPowerHmc::ManagementConsole
Retrieve information about the management console.
11 12 13 14 15 16 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 11 def management_console method_url = "/rest/api/uom/ManagementConsole" response = request(:get, method_url) # This request returns a feed with a single entry. FeedParser.new(response.body).objects(:ManagementConsole).first end |
#modify_object(headers = {}, attempts = 5) ⇒ Object
Post an IbmPowerHmc::AbstractRest object iteratively using ETag.
176 177 178 |
# File 'lib/ibm_power_hmc/apis/connection.rb', line 176 def modify_object(headers = {}, attempts = 5, &block) modify_object_url(nil, headers, attempts, &block) end |
#network_adapter_lpar(lpar_uuid, netadap_uuid = nil) ⇒ Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter
Retrieve one or all virtual ethernet network adapters attached to a logical partition.
324 325 326 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 324 def network_adapter_lpar(lpar_uuid, netadap_uuid = nil) network_adapter("LogicalPartition", lpar_uuid, netadap_uuid) end |
#network_adapter_lpar_create(lpar_uuid, sys_uuid, vswitch_uuid, **args) ⇒ IbmPowerHmc::ClientNetworkAdapter
Create a virtual ethernet network adapter attached to a logical partition.
359 360 361 362 363 364 365 366 367 368 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 359 def network_adapter_lpar_create(lpar_uuid, sys_uuid, vswitch_uuid, **args) method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/ClientNetworkAdapter" headers = { :content_type => "application/vnd.ibm.powervm.uom+xml; type=ClientNetworkAdapter" } args[:vswitch_href] = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualSwitch/#{vswitch_uuid}" netadap = ClientNetworkAdapter.marshal(args) response = request(:put, method_url, headers, netadap.xml.to_s) Parser.new(response.body).object(:ClientNetworkAdapter) end |
#network_adapter_lpar_delete(lpar_uuid, netadap_uuid) ⇒ Object
Delete a virtual ethernet network adapter attached to a logical partition.
375 376 377 378 379 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 375 def network_adapter_lpar_delete(lpar_uuid, netadap_uuid) method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/ClientNetworkAdapter/#{netadap_uuid}" request(:delete, method_url) # Returns HTTP 204 if ok end |
#network_adapter_vios(vios_uuid, netadap_uuid = nil) ⇒ Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter
Retrieve one or all virtual ethernet network adapters attached to a Virtual I/O Server.
334 335 336 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 334 def network_adapter_vios(vios_uuid, netadap_uuid = nil) network_adapter("VirtualIOServer", vios_uuid, netadap_uuid) end |
#next_events(wait = true) ⇒ Array<IbmPowerHmc::Event>
Retrieve a list of events that occured since last call.
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 738 def next_events(wait = true) method_url = "/rest/api/uom/Event" response = nil loop do response = request(:get, method_url) # The HMC waits 10 seconds before returning 204 if there is no event. # There is a hidden "?timeout=X" option but it does not always work. # It will return "REST026C Maximum number of event requests exceeded" # after a while. break if response.code != 204 || !wait end FeedParser.new(response.body).objects(:Event).map do |e| data = e.data.split("/") unless e.data.nil? if !data.nil? && data.length >= 2 && data[-2].eql?("UserTask") e.usertask = usertask(data.last) end e end.compact end |
#pcm_preferences ⇒ Array<IbmPowerHmc::ManagementConsolePcmPreference>
Retrieve global Performance and Capacity Monitor preferences for the HMC.
12 13 14 15 16 17 |
# File 'lib/ibm_power_hmc/apis/pcm.rb', line 12 def pcm_preferences method_url = "/rest/api/pcm/preferences" response = request(:get, method_url) FeedParser.new(response.body).objects(:ManagementConsolePcmPreference) end |
#phyp_metrics(sys_uuid: , start_ts: nil, end_ts: nil, short_term: false) ⇒ Array<Hash>
Retrieve PowerVM metrics for a given managed system.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ibm_power_hmc/apis/pcm.rb', line 36 def phyp_metrics(sys_uuid:, start_ts: nil, end_ts: nil, short_term: false) type = short_term ? "ShortTermMonitor" : "LongTermMonitor" method_url = "/rest/api/pcm/ManagedSystem/#{sys_uuid}/RawMetrics/#{type}" query = {} query["StartTS"] = self.class.format_time(start_ts) unless start_ts.nil? query["EndTS"] = self.class.format_time(end_ts) unless end_ts.nil? method_url += "?" + query.map { |h| h.join("=") }.join("&") unless query.empty? response = request(:get, method_url) FeedParser.new(response.body).entries do |entry| link = entry.elements["link"] next if link.nil? href = link.attributes["href"] next if href.nil? response = request(:get, href) JSON.parse(response.body) end.compact end |
#poweroff_lpar(lpar_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power off a logical partition.
603 604 605 606 607 608 609 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 603 def poweroff_lpar(lpar_uuid, params = {}, sync = true) method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/do/PowerOff" job = HmcJob.new(self, method_url, "PowerOff", "LogicalPartition", params) job.run if sync job end |
#poweroff_managed_system(sys_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power off a managed system.
659 660 661 662 663 664 665 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 659 def poweroff_managed_system(sys_uuid, params = {}, sync = true) method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/do/PowerOff" job = HmcJob.new(self, method_url, "PowerOff", "ManagedSystem", params) job.run if sync job end |
#poweroff_vios(vios_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power off a virtual I/O server.
631 632 633 634 635 636 637 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 631 def poweroff_vios(vios_uuid, params = {}, sync = true) method_url = "/rest/api/uom/VirtualIOServer/#{vios_uuid}/do/PowerOff" job = HmcJob.new(self, method_url, "PowerOff", "VirtualIOServer", params) job.run if sync job end |
#poweron_lpar(lpar_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power on a logical partition.
590 591 592 593 594 595 596 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 590 def poweron_lpar(lpar_uuid, params = {}, sync = true) method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/do/PowerOn" job = HmcJob.new(self, method_url, "PowerOn", "LogicalPartition", params) job.run if sync job end |
#poweron_managed_system(sys_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power on a managed system.
646 647 648 649 650 651 652 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 646 def poweron_managed_system(sys_uuid, params = {}, sync = true) method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/do/PowerOn" job = HmcJob.new(self, method_url, "PowerOn", "ManagedSystem", params) job.run if sync job end |
#poweron_vios(vios_uuid, params = {}, sync = true) ⇒ IbmPowerHmc::HmcJob
Power on a virtual I/O server.
618 619 620 621 622 623 624 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 618 def poweron_vios(vios_uuid, params = {}, sync = true) method_url = "/rest/api/uom/VirtualIOServer/#{vios_uuid}/do/PowerOn" job = HmcJob.new(self, method_url, "PowerOn", "VirtualIOServer", params) job.run if sync job end |
#remove_connection(hmc_uuid, sys_uuid, sync = true) ⇒ IbmPowerHmc::HmcJob
Remove a managed system from the management console.
674 675 676 677 678 679 680 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 674 def remove_connection(hmc_uuid, sys_uuid, sync = true) method_url = "/rest/api/uom/ManagementConsole/#{hmc_uuid}/ManagedSystem/#{sys_uuid}/do/RemoveConnection" job = HmcJob.new(self, method_url, "RemoveConnection", "ManagedSystem") job.run if sync job end |
#request(method, url, headers = {}, payload = nil) ⇒ RestClient::Response
Perform a REST API request.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/ibm_power_hmc/apis/connection.rb', line 142 def request(method, url, headers = {}, payload = nil) logon if @api_session_token.nil? reauth = false # Check for relative URLs url = "https://#{@hostname}#{url}" if url.start_with?("/") begin headers = headers.merge("X-API-Session" => @api_session_token) RestClient::Request.execute( :method => method, :url => url, :verify_ssl => @verify_ssl, :payload => payload, :headers => headers, :timeout => @timeout ) rescue RestClient::Exception => e raise HttpNotFound.new(e), "Not found" if e.http_code == 404 # Do not retry on failed logon attempts. if e.http_code == 401 && @api_session_token != "" && !reauth # Try to reauth. reauth = true logon retry end raise HttpError.new(e), "REST request failed" end end |
#schema(type) ⇒ REXML::Document
Retrieve the XML schema file for a given object type.
95 96 97 98 99 |
# File 'lib/ibm_power_hmc/apis/connection.rb', line 95 def schema(type) method_url = "/rest/api/web/schema/#{type}.xsd" response = request(:get, method_url) REXML::Document.new(response.body) end |
#serviceable_events(status = nil) ⇒ Array<IbmPowerHmc::ServiceableEvent>
Retrieve serviceable events from the HMC.
13 14 15 16 17 18 |
# File 'lib/ibm_power_hmc/apis/sem.rb', line 13 def serviceable_events(status = nil) method_url = "/rest/api/sem/ServiceableEvent" method_url += "?status=#{status}" unless status.nil? response = request(:get, method_url) FeedParser.new(response.body).objects(:ServiceableEvent) end |
#shared_memory_pool(sys_uuid, pool_uuid = nil) ⇒ Array<IbmPowerHmc::SharedMemoryPool>, IbmPowerHmc::SharedMemoryPool
Retrieve information about Shared Memory Pools.
571 572 573 574 575 576 577 578 579 580 581 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 571 def shared_memory_pool(sys_uuid, pool_uuid = nil) if pool_uuid.nil? method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/SharedMemoryPool" response = request(:get, method_url) FeedParser.new(response.body).objects(:SharedMemoryPool) else method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/SharedMemoryPool/#{pool_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:SharedMemoryPool) end end |
#shared_processor_pool(sys_uuid, pool_uuid = nil) ⇒ Array<IbmPowerHmc::SharedProcessorPool>, IbmPowerHmc::SharedProcessorPool
Retrieve information about Shared Processor Pools.
553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 553 def shared_processor_pool(sys_uuid, pool_uuid = nil) if pool_uuid.nil? method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/SharedProcessorPool" response = request(:get, method_url) FeedParser.new(response.body).objects(:SharedProcessorPool) else method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/SharedProcessorPool/#{pool_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:SharedProcessorPool) end end |
#sriov_elp_lpar(lpar_uuid, sriov_elp_uuid = nil) ⇒ Array<IbmPowerHmc::SRIOVEthernetLogicalPort>, IbmPowerHmc::SRIOVEthernetLogicalPort
Retrieve one or all SR-IOV ethernet logical ports attached to a logical partition.
387 388 389 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 387 def sriov_elp_lpar(lpar_uuid, sriov_elp_uuid = nil) sriov_elp("LogicalPartition", lpar_uuid, sriov_elp_uuid) end |
#sriov_elp_vios(vios_uuid, sriov_elp_uuid = nil) ⇒ Array<IbmPowerHmc::SRIOVEthernetLogicalPort>, IbmPowerHmc::SRIOVEthernetLogicalPort
Retrieve one or all SR-IOV ethernet logical ports attached to a Virtual I/O Server.
397 398 399 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 397 def sriov_elp_vios(vios_uuid, sriov_elp_uuid = nil) sriov_elp("VirtualIOServer", vios_uuid, sriov_elp_uuid) end |
#ssp(ssp_uuid) ⇒ IbmPowerHmc::SharedStoragePool
Retrieve information about a shared storage pool.
506 507 508 509 510 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 506 def ssp(ssp_uuid) method_url = "/rest/api/uom/SharedStoragePool/#{ssp_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:SharedStoragePool) end |
#ssps(permissive = true) ⇒ Array<IbmPowerHmc::SharedStoragePool>
Retrieve the list of shared storage pools managed by the HMC.
495 496 497 498 499 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 495 def ssps(permissive = true) method_url = "/rest/api/uom/SharedStoragePool#{'?ignoreError=true' if permissive}" response = request(:get, method_url) FeedParser.new(response.body).objects(:SharedStoragePool) end |
#template(template_uuid) ⇒ IbmPowerHmc::PartitionTemplate
Retrieve details for a particular partition template.
32 33 34 35 36 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 32 def template(template_uuid) method_url = "/rest/api/templates/PartitionTemplate/#{template_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:PartitionTemplate) end |
#template_check(template_uuid, target_sys_uuid, sync = true) ⇒ IbmPowerHmc::HmcJob
Start Template Check job (first of three steps to deploy an LPAR from a Template).
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 68 def template_check(template_uuid, target_sys_uuid, sync = true) # Need to include session token in payload so make sure we are logged in logon if @api_session_token.nil? method_url = "/rest/api/templates/PartitionTemplate/#{template_uuid}/do/check" params = { "TargetUuid" => target_sys_uuid, "K_X_API_SESSION_MEMENTO" => @api_session_token } job = HmcJob.new(self, method_url, "Check", "PartitionTemplate", params) job.run if sync job end |
#template_copy(template_uuid, new_name) ⇒ IbmPowerHmc::PartitionTemplate
Copy existing template to a new one.
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 160 def template_copy(template_uuid, new_name) method_url = "/rest/api/templates/PartitionTemplate" headers = { :content_type => "application/vnd.ibm.powervm.templates+xml;type=PartitionTemplate" } original = template(template_uuid) original.name = new_name response = request(:put, method_url, headers, original.xml.to_s) Parser.new(response.body).object(:PartitionTemplate) end |
#template_deploy(draft_template_uuid, target_sys_uuid, sync = true) ⇒ IbmPowerHmc::HmcJob
Start Template Deploy job (last of three steps to deploy an LPAR from a Template).
108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 108 def template_deploy(draft_template_uuid, target_sys_uuid, sync = true) # Need to include session token in payload so make sure we are logged in logon if @api_session_token.nil? method_url = "/rest/api/templates/PartitionTemplate/#{draft_template_uuid}/do/deploy" params = { "TargetUuid" => target_sys_uuid, "TemplateUuid" => draft_template_uuid, "K_X_API_SESSION_MEMENTO" => @api_session_token } job = HmcJob.new(self, method_url, "Deploy", "PartitionTemplate", params) job.run if sync job end |
#template_modify(template_uuid, changes) ⇒ Object
Modify a template.
141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 141 def template_modify(template_uuid, changes) method_url = "/rest/api/templates/PartitionTemplate/#{template_uuid}" # Templates have no href so need to use modify_object_url. modify_object_url(method_url) do template(template_uuid).tap do |obj| changes.each do |key, value| obj.send("#{key}=", value) end end end end |
#template_provision(template_uuid, target_sys_uuid, changes) ⇒ String
Deploy Logical Partition from a Template (performs Check, Transform and Deploy steps in a single method).
129 130 131 132 133 134 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 129 def template_provision(template_uuid, target_sys_uuid, changes) draft_uuid = template_check(template_uuid, target_sys_uuid).results["TEMPLATE_UUID"] template_transform(draft_uuid, target_sys_uuid) template_modify(draft_uuid, changes) template_deploy(draft_uuid, target_sys_uuid).results["PartitionUuid"] end |
#template_transform(draft_template_uuid, target_sys_uuid, sync = true) ⇒ IbmPowerHmc::HmcJob
Start Template Transform job (second of three steps to deploy an LPAR from a Template).
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 88 def template_transform(draft_template_uuid, target_sys_uuid, sync = true) # Need to include session token in payload so make sure we are logged in logon if @api_session_token.nil? method_url = "/rest/api/templates/PartitionTemplate/#{draft_template_uuid}/do/transform" params = { "TargetUuid" => target_sys_uuid, "K_X_API_SESSION_MEMENTO" => @api_session_token } job = HmcJob.new(self, method_url, "Transform", "PartitionTemplate", params) job.run if sync job end |
#templates(draft = false) ⇒ Array<IbmPowerHmc::PartitionTemplate>
Retrieve the list of partition templates.
21 22 23 24 25 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 21 def templates(draft = false) method_url = "/rest/api/templates/PartitionTemplate?detail=full#{'&draft=false' unless draft}" response = request(:get, method_url) FeedParser.new(response.body).objects(:PartitionTemplate) end |
#templates_summary(draft = false) ⇒ Array<IbmPowerHmc::PartitionTemplateSummary>
Retrieve the list of partition template summaries.
10 11 12 13 14 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 10 def templates_summary(draft = false) method_url = "/rest/api/templates/PartitionTemplate#{'?draft=false' unless draft}" response = request(:get, method_url) FeedParser.new(response.body).objects(:PartitionTemplateSummary) end |
#tier(tier_uuid, ssp_uuid = nil, group_name = nil) ⇒ IbmPowerHmc::Tier
Retrieve information about a tier.
535 536 537 538 539 540 541 542 543 544 545 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 535 def tier(tier_uuid, ssp_uuid = nil, group_name = nil) if ssp_uuid.nil? method_url = "/rest/api/uom/Tier/#{tier_uuid}" else method_url = "/rest/api/uom/SharedStoragePool/#{ssp_uuid}/Tier/#{tier_uuid}" end method_url += "?group=#{group_name}" unless group_name.nil? response = request(:get, method_url) Parser.new(response.body).object(:Tier) end |
#tiers(group_name = nil, permissive = true) ⇒ Array<IbmPowerHmc::Tier>
Retrieve the list of tiers that are part of shared storage pools managed by the HMC.
518 519 520 521 522 523 524 525 526 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 518 def tiers(group_name = nil, permissive = true) method_url = "/rest/api/uom/Tier" query = {} query["group"] = group_name unless group_name.nil? query["ignoreError"] = "true" if permissive method_url += "?" + query.map { |h| h.join("=") }.join("&") unless query.empty? response = request(:get, method_url) FeedParser.new(response.body).objects(:Tier) end |
#usertask(uuid = true) ⇒ Hash
Retrieve details of an event of type “user task”.
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ibm_power_hmc/apis/connection.rb', line 77 def usertask(uuid) method_url = "/rest/api/ui/UserTask/#{uuid}" response = request(:get, method_url) j = JSON.parse(response.body) if j['status'].eql?("Completed") case j['key'] when "TEMPLATE_PARTITION_SAVE", "TEMPLATE_PARTITION_SAVE_AS", "TEMPLATE_PARTITION_CAPTURE" j['template_uuid'] = templates_summary.find { |t| t.name.eql?(j['labelParams'].first) }&.uuid end end j end |
#vfc_client_adapter(lpar_uuid, adap_uuid = nil) ⇒ Array<IbmPowerHmc::VirtualFibreChannelClientAdapter>, IbmPowerHmc::VirtualFibreChannelClientAdapter
Retrieve one or all virtual Fibre Channel storage client adapters attached to a logical partition.
456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 456 def vfc_client_adapter(lpar_uuid, adap_uuid = nil) if adap_uuid.nil? method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualFibreChannelClientAdapter" response = request(:get, method_url) FeedParser.new(response.body).objects(:VirtualFibreChannelClientAdapter) else method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualFibreChannelClientAdapter/#{adap_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:VirtualFibreChannelClientAdapter) end end |
#vios(vios_uuid, sys_uuid = nil, group_name = nil) ⇒ IbmPowerHmc::VirtualIOServer
Retrieve information about a virtual I/O server.
211 212 213 214 215 216 217 218 219 220 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 211 def vios(vios_uuid, sys_uuid = nil, group_name = nil) if sys_uuid.nil? method_url = "/rest/api/uom/VirtualIOServer/#{vios_uuid}" else method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualIOServer/#{vios_uuid}" end method_url += "?group=#{group_name}" unless group_name.nil? response = request(:get, method_url) Parser.new(response.body).object(:VirtualIOServer) end |
#vioses(sys_uuid = nil, search = nil, group_name = nil, permissive = true) ⇒ Array<IbmPowerHmc::VirtualIOServer>
Retrieve the list of virtual I/O servers managed by the HMC.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 188 def vioses(sys_uuid = nil, search = nil, group_name = nil, permissive = true) if sys_uuid.nil? method_url = "/rest/api/uom/VirtualIOServer" method_url += "/search/(#{ERB::Util.url_encode(search)})" unless search.nil? else method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualIOServer" end query = {} query["group"] = group_name unless group_name.nil? query["ignoreError"] = "true" if permissive method_url += "?" + query.map { |h| h.join("=") }.join("&") unless query.empty? response = request(:get, method_url) FeedParser.new(response.body).objects(:VirtualIOServer) end |
#vioses_quick(sys_uuid = nil) ⇒ Array<Hash>
Retrieve the list of virtual I/O servers managed by the HMC (using Quick API).
227 228 229 230 231 232 233 234 235 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 227 def vioses_quick(sys_uuid = nil) if sys_uuid.nil? method_url = "/rest/api/uom/VirtualIOServer/quick/All" else method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualIOServer/quick/All" end response = request(:get, method_url) JSON.parse(response.body) end |
#virtual_network(vnet_uuid, sys_uuid) ⇒ IbmPowerHmc::VirtualNetwork
Retrieve information about a virtual network.
312 313 314 315 316 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 312 def virtual_network(vnet_uuid, sys_uuid) method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualNetwork/#{vnet_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:VirtualNetwork) end |
#virtual_networks(sys_uuid) ⇒ Array<IbmPowerHmc::VirtualNetwork>
Retrieve the list of virtual networks from a specified managed system.
300 301 302 303 304 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 300 def virtual_networks(sys_uuid) method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualNetwork" response = request(:get, method_url) FeedParser.new(response.body).objects(:VirtualNetwork) end |
#virtual_switch(vswitch_uuid, sys_uuid) ⇒ IbmPowerHmc::VirtualSwitch
Retrieve information about a virtual switch.
289 290 291 292 293 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 289 def virtual_switch(vswitch_uuid, sys_uuid) method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualSwitch/#{vswitch_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:VirtualSwitch) end |
#virtual_switches(sys_uuid) ⇒ Array<IbmPowerHmc::VirtualSwitch>
Retrieve the list of virtual switches from a specified managed system.
277 278 279 280 281 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 277 def virtual_switches(sys_uuid) method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualSwitch" response = request(:get, method_url) FeedParser.new(response.body).objects(:VirtualSwitch) end |
#vnic_dedicated(lpar_uuid, vnic_uuid = nil) ⇒ Array<IbmPowerHmc::VirtualNICDedicated>, IbmPowerHmc::VirtualNICDedicated
Retrieve one or all dedicated virtual network interface controller (vNIC) attached to a logical partition.
420 421 422 423 424 425 426 427 428 429 430 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 420 def vnic_dedicated(lpar_uuid, vnic_uuid = nil) if vnic_uuid.nil? method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualNICDedicated" response = request(:get, method_url) FeedParser.new(response.body).objects(:VirtualNICDedicated) else method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualNICDedicated/#{vnic_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:VirtualNICDedicated) end end |
#volume_group(vios_uuid, vg_uuid) ⇒ IbmPowerHmc::VolumeGroup
Retrieve information about a volume group on a virtual I/O server.
254 255 256 257 258 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 254 def volume_group(vios_uuid, vg_uuid) method_url = "/rest/api/uom/VirtualIOServer/#{vios_uuid}/VolumeGroup/#{vg_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:VolumeGroup) end |
#volume_groups(vios_uuid) ⇒ Array<IbmPowerHmc::VolumeGroup>
Retrieve the list of volume groups available on a virtual I/O server.
242 243 244 245 246 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 242 def volume_groups(vios_uuid) method_url = "/rest/api/uom/VirtualIOServer/#{vios_uuid}/VolumeGroup" response = request(:get, method_url) FeedParser.new(response.body).objects(:VolumeGroup) end |
#vscsi_client_adapter(lpar_uuid, adap_uuid = nil) ⇒ Array<IbmPowerHmc::VirtualSCSIClientAdapter>, IbmPowerHmc::VirtualSCSIClientAdapter
Retrieve one or all virtual SCSI storage client adapters attached to a logical partition.
438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 438 def vscsi_client_adapter(lpar_uuid, adap_uuid = nil) if adap_uuid.nil? method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualSCSIClientAdapter" response = request(:get, method_url) FeedParser.new(response.body).objects(:VirtualSCSIClientAdapter) else method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualSCSIClientAdapter/#{adap_uuid}" response = request(:get, method_url) Parser.new(response.body).object(:VirtualSCSIClientAdapter) end end |