Class: IbmPowerHmc::Connection
- Inherits:
-
Object
- Object
- IbmPowerHmc::Connection
- Defined in:
- lib/ibm_power_hmc/apis/connection.rb,
lib/ibm_power_hmc/utils.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, delete_vios_mappings: false) ⇒ Object
Delete a logical partition.
-
#lpar_delete_vios_mappings(lpar_uuid) ⇒ Object
Delete VIOS VSCSI and VFC mappings associated to a given 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.
692 693 694 695 696 697 698 699 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 692 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.
708 709 710 711 712 713 714 715 716 717 718 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 708 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.
488 489 490 491 492 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 488 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.
477 478 479 480 481 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 477 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.
270 271 272 273 274 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 270 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.
727 728 729 730 731 732 733 734 735 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 727 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, delete_vios_mappings: false) ⇒ Object
Delete a logical partition.
175 176 177 178 179 180 181 182 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 175 def lpar_delete(lpar_uuid, delete_vios_mappings: false) method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}" lpar_delete_vios_mappings(lpar_uuid) if delete_vios_mappings request(:delete, method_url) # Returns HTTP 204 if ok end |
#lpar_delete_vios_mappings(lpar_uuid) ⇒ Object
Delete VIOS VSCSI and VFC mappings associated to a given logical partition.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ibm_power_hmc/utils.rb', line 9 def lpar_delete_vios_mappings(lpar_uuid) vscsi_client_adapter(lpar_uuid).concat(vfc_client_adapter(lpar_uuid)).group_by(&:vios_uuid).each do |vios_uuid, adapters| modify_object do vios(vios_uuid, nil, "ViosSCSIMapping,ViosFCMapping").tap do |vios| adapters.collect(&:server).each do |server| case server when VirtualSCSIServerAdapter vios.vscsi_mapping_delete!(server.location) when VirtualFibreChannelServerAdapter vios.vfc_mapping_delete!(server.location) end end end end end 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.
328 329 330 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 328 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.
363 364 365 366 367 368 369 370 371 372 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 363 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.
379 380 381 382 383 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 379 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.
338 339 340 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 338 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.
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 742 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.
607 608 609 610 611 612 613 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 607 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.
663 664 665 666 667 668 669 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 663 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.
635 636 637 638 639 640 641 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 635 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.
594 595 596 597 598 599 600 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 594 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.
650 651 652 653 654 655 656 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 650 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.
622 623 624 625 626 627 628 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 622 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.
678 679 680 681 682 683 684 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 678 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.
575 576 577 578 579 580 581 582 583 584 585 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 575 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.
557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 557 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.
391 392 393 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 391 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.
401 402 403 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 401 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.
510 511 512 513 514 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 510 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.
499 500 501 502 503 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 499 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.
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 146 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.
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/ibm_power_hmc/apis/templates.rb', line 127 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).
33 34 35 36 37 38 |
# File 'lib/ibm_power_hmc/utils.rb', line 33 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.
539 540 541 542 543 544 545 546 547 548 549 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 539 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.
522 523 524 525 526 527 528 529 530 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 522 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.
460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 460 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.
215 216 217 218 219 220 221 222 223 224 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 215 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.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 192 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).
231 232 233 234 235 236 237 238 239 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 231 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.
316 317 318 319 320 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 316 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.
304 305 306 307 308 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 304 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.
293 294 295 296 297 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 293 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.
281 282 283 284 285 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 281 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.
424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 424 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.
258 259 260 261 262 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 258 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.
246 247 248 249 250 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 246 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.
442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/ibm_power_hmc/apis/uom.rb', line 442 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 |