Class: IbmPowerHmc::Connection

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(host: , password: , username: "hscroot", port: 12_443, validate_ssl: true, timeout: 60) ⇒ Connection

Create a new HMC connection.

Parameters:

  • host (String) (defaults to: )

    Hostname of the HMC.

  • password (String) (defaults to: )

    Password.

  • username (String) (defaults to: "hscroot")

    User name.

  • port (Integer) (defaults to: 12_443)

    TCP port number.

  • validate_ssl (Boolean) (defaults to: true)

    Verify SSL certificates.

  • timeout (Integer) (defaults to: 60)

    The default HTTP timeout in seconds.



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.

Parameters:

  • time (Time)

    The ruby time to convert.

Returns:

  • (String)

    The time in HMC 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.

Parameters:

  • lpar_uuid (String)

    The UUID of the logical partition.

  • sys_uuid (String)

    The UUID of the managed system.

  • template_name (String)

    The name to be given for the new template.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • sys_uuid (String)

    The UUID of the managed system.

  • status (String)

    The new co-management status (“rel”, “norm”, “keep”).

Returns:



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.

Parameters:

  • hmc_uuid (String)

    The UUID of the management console.

  • cmd (String)

    The command to run.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • cl_uuid (String)

    The UUID of the cluster.

Returns:



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.

Parameters:

  • permissive (Boolean) (defaults to: true)

    Ignore errors generated from bad clusters.

Returns:



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.

Parameters:

  • time (Time)

    The ruby time to convert.

Returns:

  • (String)

    The time in HMC format.



131
132
133
# File 'lib/ibm_power_hmc/apis/pcm.rb', line 131

def self.format_time(time)
  time.utc.xmlschema
end

#groupsArray<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.

Returns:



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.

Parameters:

  • cl_uuid (String)

    The UUID of the cluster.

  • lu_uuid (String)

    The UUID of the logical unit.

  • capacity (Float)

    The new logical unit size (in GB).

Returns:



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

#logoffObject

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

#logonString

Establish a trusted session with the Web Services APIs.

Returns:

  • (String)

    The X-API-Session token.

Raises:



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.

Parameters:

  • lpar_uuid (String)

    The UUID of the logical partition.

  • sys_uuid (String) (defaults to: nil)

    The UUID of the managed system.

  • group_name (String) (defaults to: nil)

    The extended group attributes.

Returns:



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.

Parameters:

  • lpar_uuid (String)

    The UUID of the logical partition to delete.



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.

Parameters:

  • sys_uuid (String) (defaults to: )

    The managed system UUID.

  • lpar_uuid (String) (defaults to: )

    The logical partition UUID.

  • start_ts (Time) (defaults to: nil)

    Start timestamp.

  • end_ts (Time) (defaults to: nil)

    End timestamp.

  • no_samples (Integer) (defaults to: nil)

    Number of samples.

  • aggregated (Boolean) (defaults to: false)

    Retrieve aggregated metrics (default to Processed).

Returns:

  • (Array<Hash>)

    The metrics for the 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.

Parameters:

  • lpar_uuid (String)

    The UUID of the logical partition to migrate.

  • target_sys_name (String)

    The managed system to migrate partition to.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.



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.

Parameters:

  • lpar_uuid (String)

    The UUID of the logical partition to migrate.

  • target_sys_name (String)

    The managed system to migrate partition to.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Raises:

  • (IbmPowerHmc::JobFailed)

    if validation fails



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.

Parameters:

  • lpar_uuid (String)

    The UUID of the logical partition.

  • property_name (String)

    The quick property name.

Returns:

  • (String)

    The quick property value.



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.

Parameters:

  • sys_uuid (String) (defaults to: nil)

    The UUID of the managed system.

  • search (String) (defaults to: nil)

    The optional search criteria.

  • group_name (String) (defaults to: nil)

    The extended group attributes.

Returns:



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).

Parameters:

  • sys_uuid (String) (defaults to: nil)

    The UUID of the managed system.

Returns:

  • (Array<Hash>)

    The list of logical partitions.



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.

Parameters:

  • sys_uuid (String)

    The UUID of the managed system.

  • group_name (String) (defaults to: nil)

    The extended group attributes.

Returns:



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.

Parameters:

  • sys_uuid (String) (defaults to: )

    The managed system UUID.

  • start_ts (Time) (defaults to: nil)

    Start timestamp.

  • end_ts (Time) (defaults to: nil)

    End timestamp.

  • no_samples (Integer) (defaults to: nil)

    Number of samples.

  • aggregated (Boolean) (defaults to: false)

    Retrieve aggregated metrics (default to Processed).

Returns:

  • (Array<Hash>)

    The metrics for the 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.

Parameters:

  • sys_uuid (String)

    The managed system UUID.

Returns:



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).

Parameters:

  • sys_uuid (String)

    The UUID of the managed system.

  • property (String) (defaults to: nil)

    The quick property name (optional).

Returns:

  • (Hash)

    The managed system.



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.

Parameters:

  • search (String) (defaults to: nil)

    The optional search criteria.

  • group_name (String) (defaults to: nil)

    The extended group attributes.

Returns:



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_quickArray<Hash>

Retrieve the list of systems managed by the HMC (using Quick API).

Returns:

  • (Array<Hash>)

    The list of managed systems.



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_consoleIbmPowerHmc::ManagementConsole

Retrieve information about the management console.

Returns:



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.

Parameters:

  • headers (Hash) (defaults to: {})

    HTTP headers.

  • attempts (Integer) (defaults to: 5)

    Maximum number of retries.

Yield Returns:



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.

Parameters:

  • lpar_uuid (String)

    UUID of the logical partition.

  • netadap_uuid (String) (defaults to: nil)

    UUID of the adapter to match (returns all adapters if omitted).

Returns:



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.

Parameters:

  • lpar_uuid (String)

    UUID of the logical partition.

  • sys_uuid (String)

    UUID of the managed system of the virtual switch.

  • vswitch_uuid (String)

    UUID of the virtual switch.

  • args (Hash)

    The network adapter properties.

Returns:



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.

Parameters:

  • lpar_uuid (String)

    UUID of the logical partition.

  • netadap_uuid (String)

    UUID of the adapter to delete.



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.

Parameters:

  • vios_uuid (String)

    UUID of the Virtual I/O Server.

  • netadap_uuid (String) (defaults to: nil)

    UUID of the adapter to match (returns all adapters if omitted).

Returns:



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.

Parameters:

  • wait (Boolean) (defaults to: true)

    If no event is available, block until new events occur.

Returns:



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_preferencesArray<IbmPowerHmc::ManagementConsolePcmPreference>

Retrieve global Performance and Capacity Monitor preferences for the HMC.

Returns:



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.

Parameters:

  • sys_uuid (String) (defaults to: )

    The managed system UUID.

  • start_ts (Time) (defaults to: nil)

    Start timestamp.

  • end_ts (Time) (defaults to: nil)

    End timestamp.

  • short_term (Boolean) (defaults to: false)

    Retrieve short term monitor metrics (default to long term).

Returns:

  • (Array<Hash>)

    The PowerVM metrics for the 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.

Parameters:

  • lpar_uuid (String)

    The UUID of the logical partition.

  • params (Hash) (defaults to: {})

    Job parameters.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • sys_uuid (String)

    The UUID of the managed system.

  • params (Hash) (defaults to: {})

    Job parameters.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • vios_uuid (String)

    The UUID of the virtual I/O server.

  • params (Hash) (defaults to: {})

    Job parameters.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • lpar_uuid (String)

    The UUID of the logical partition.

  • params (Hash) (defaults to: {})

    Job parameters.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • sys_uuid (String)

    The UUID of the managed system.

  • params (Hash) (defaults to: {})

    Job parameters.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • vios_uuid (String)

    The UUID of the virtual I/O server.

  • params (Hash) (defaults to: {})

    Job parameters.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • hmc_uuid (String)

    The UUID of the management console.

  • sys_uuid (String)

    The UUID of the managed system.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • method (String)

    The HTTP method.

  • url (String)

    The method URL.

  • headers (Hash) (defaults to: {})

    HTTP headers.

  • payload (String) (defaults to: nil)

    HTTP request payload.

Returns:

  • (RestClient::Response)

    The response from the HMC.



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.

Parameters:

  • type (String)

    The object type (e.g. “LogicalPartition”, “inc/Types”)

Returns:

  • (REXML::Document)

    The XML schema file.



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.

Parameters:

  • status (String) (defaults to: nil)

    Query only events in that state.

Returns:



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.

Parameters:

  • sys_uuid (String)

    The UUID of the managed system.

  • pool_uuid (String) (defaults to: nil)

    The UUID of the shared memory pool (return all pools if omitted)

Returns:



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.

Parameters:

  • sys_uuid (String)

    The UUID of the managed system.

  • pool_uuid (String) (defaults to: nil)

    The UUID of the shared processor pool (return all pools if omitted)

Returns:



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.

Parameters:

  • lpar_uuid (String)

    UUID of the logical partition.

  • sriov_elp_uuid (String) (defaults to: nil)

    UUID of the port to match (returns all ports if omitted).

Returns:



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.

Parameters:

  • vios_uuid (String)

    UUID of the Virtual I/O Server.

  • sriov_elp_uuid (String) (defaults to: nil)

    UUID of the port to match (returns all ports if omitted).

Returns:



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.

Parameters:

  • ssp_uuid (String)

    The UUID of the shared storage pool.

Returns:



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.

Parameters:

  • permissive (Boolean) (defaults to: true)

    Ignore errors generated from bad clusters.

Returns:



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.

Parameters:

  • template_uuid (String)

    UUID of the partition template.

Returns:



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).

Parameters:

  • template_uuid (String)

    The UUID of the Template to deploy an LPAR from.

  • target_sys_uuid (String)

    The UUID of the Managed System to deploy the LPAR on.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • template_uuid (String)

    UUID of the partition template to copy.

  • new_name (String)

    Name of the new template.

Returns:



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).

Parameters:

  • draft_template_uuid (String)

    The UUID of the Draft Template created by the Template Check job.

  • target_sys_uuid (String)

    The UUID of the Managed System to deploy the LPAR on.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • template_uuid (String)

    UUID of the partition template to modify.

  • changes (Hash)

    Hash of changes to make.



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).

Parameters:

  • template_uuid (String)

    The UUID of the Template to deploy an LPAR from.

  • target_sys_uuid (String)

    The UUID of the Managed System to deploy the LPAR on.

  • changes (Hash)

    Modifications to apply to the Template before deploying Logical Partition.

Returns:

  • (String)

    The UUID of the deployed Logical Partition.



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).

Parameters:

  • draft_template_uuid (String)

    The UUID of the Draft Template created by the Template Check job.

  • target_sys_uuid (String)

    The UUID of the Managed System to deploy the LPAR on.

  • sync (Boolean) (defaults to: true)

    Start the job and wait for its completion.

Returns:



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.

Parameters:

  • draft (Boolean) (defaults to: false)

    Retrieve draft templates as well

Returns:



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.

Parameters:

  • draft (Boolean) (defaults to: false)

    Retrieve draft templates as well

Returns:



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.

Parameters:

  • tier_uuid (String)

    The UUID of the tier.

  • ssp_uuid (String) (defaults to: nil)

    The UUID of the shared storage pool.

  • group_name (String) (defaults to: nil)

    The extended group attributes.

Returns:



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.

Parameters:

  • group_name (String) (defaults to: nil)

    The extended group attributes.

  • permissive (Boolean) (defaults to: true)

    Ignore errors generated from bad clusters.

Returns:



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”.

Parameters:

  • uuid (String) (defaults to: true)

    UUID of user task.

Returns:

  • (Hash)

    Hash of user task attributes.



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.

Parameters:

  • lpar_uuid (String)

    UUID of the logical partition.

  • adap_uuid (String) (defaults to: nil)

    UUID of the adapter to match (returns all adapters if omitted).

Returns:



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.

Parameters:

  • vios_uuid (String)

    The UUID of the virtual I/O server.

  • sys_uuid (String) (defaults to: nil)

    The UUID of the managed system.

  • group_name (String) (defaults to: nil)

    The extended group attributes.

Returns:



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.

Parameters:

  • sys_uuid (String) (defaults to: nil)

    The UUID of the managed system.

  • search (String) (defaults to: nil)

    The optional search criteria.

  • group_name (String) (defaults to: nil)

    The extended group attributes.

  • permissive (Boolean) (defaults to: true)

    Skip virtual I/O servers that have error conditions.

Returns:



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).

Parameters:

  • sys_uuid (String) (defaults to: nil)

    The UUID of the managed system.

Returns:

  • (Array<Hash>)

    The list of virtual I/O servers.



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.

Parameters:

  • vnet_uuid (String)

    The UUID of the virtual network.

  • sys_uuid (String)

    The UUID of the managed system.

Returns:



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.

Parameters:

  • sys_uuid (String)

    The UUID of the managed system.

Returns:



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.

Parameters:

  • vswitch_uuid (String)

    The UUID of the virtual switch.

  • sys_uuid (String)

    The UUID of the managed system.

Returns:



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.

Parameters:

  • sys_uuid (String)

    The UUID of the managed system.

Returns:



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.

Parameters:

  • lpar_uuid (String)

    UUID of the logical partition.

  • vnic_uuid (String) (defaults to: nil)

    UUID of the vNIC to match (returns all vNICs if omitted).

Returns:



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.

Parameters:

  • vios_uuid (String)

    The UUID of the virtual I/O server.

  • vg_uuid (String)

    The UUID of the volume group.

Returns:



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.

Parameters:

  • vios_uuid (String)

    The UUID of the virtual I/O server.

Returns:



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.

Parameters:

  • lpar_uuid (String)

    UUID of the logical partition.

  • adap_uuid (String) (defaults to: nil)

    UUID of the adapter to match (returns all adapters if omitted).

Returns:



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