Top Level Namespace
Defined Under Namespace
Classes: ImcHandle
Constant Summary collapse
- COMM_EXT_DN =
"sys/svc-ext"
- NTP_DN =
"sys/svc-ext/ntp-svc"
- NTP_SERVER_LIST =
["ntp_server1", "ntp_server2", "ntp_server3", "ntp_server4"]
- LDAP_SERVERS =
['ldap_server1', 'ldap_server2', 'ldap_server3', 'ldap_server4', 'ldap_server5', 'ldap_server6']
- LDAP_SERVER_PORTS =
['ldap_server_port1', 'ldap_server_port2', 'ldap_server_port3', 'ldap_server_port4', 'ldap_server_port5', 'ldap_server_port6']
- LDAP_DN =
"sys/ldap-ext"
- PRECISION_DEVICE_DICT =
{ :hdd => { :class_id => "LsbootHdd", :type => "LOCALHDD" }, :iscsi => { :class_id => "LsbootIscsi", :type => "ISCSI", :subtype => "ISCSI" }, :pchstorage => { :class_id => "LsbootPchStorage", :type => "PCHSTORAGE" }, :pxe => { :class_id => "LsbootPxe", :type => "PXE", :subtype => "PXE" }, :san => { :class_id => "LsbootSan", :type => "SAN", :subtype => "SAN" }, :sdcard => { :class_id => "LsbootSd", :type => "SDCARD", :subtype => "SDCARD" }, :uefishell => { :class_id => "LsbootUefiShell", :type => "UEFISHELL" }, :usb => { :class_id => "LsbootUsb", :type => "USB" }, :vmedia => { :class_id => "LsbootVMedia", :type => "VMEDIA" }, :nvme => { :class_id => "LsbootNVMe", :type => "NVME" }, }
- POLICY_DEVICE_DICT =
{ :efi => {:class_id => "LsbootEfi", :access => "read-only"}, :lan => {:class_id => "LsbootLan", :access => "read-only"}, :storage => {:class_id => "LsbootStorage", :access => "read-write"}, :cdrom => {:class_id => "LsbootVirtualMedia", :access => "read-only"}, :fdd => {:class_id => "LsbootVirtualMedia", :access => "read-write"} }
- SUPPORTED_MODELS =
This list is currently maintained manually. Ideally all such config/capabilites should come from a capability file
['UCSC-C220-M4', 'UCSC-C240-M4', 'UCSC-C3K-M4']
- SUPPORTED_VARIANTS =
['M4', 'M5']
Instance Method Summary collapse
-
#boot_order_precision_exists(handle:, **kwargs) ⇒ FalseClass, ...
Check if boot order precision match.
-
#boot_order_precision_set(handle:, reboot_on_update: false, reapply: false, configured_boot_mode: "Legacy", boot_devices: Array.new, server_id: 1) ⇒ LsBootDevPrecision
This method will set the boot order precision.
-
#boot_precision_configured_get(handle:, server_id: 1) ⇒ Array<Hash>
Get the configured boot precision settings.
-
#get_locator_led_status(handle:, **kwargs) ⇒ string
This method will return the locator led status on the server or chassis.
-
#get_supported_models ⇒ Object
This api returns the list of rack server models that support power cap and power budgeting.
-
#ipmi_disable(handle:, server_id: 1) ⇒ CommIpmiLan
Disable IPMI over LAN.
-
#ipmi_enable(handle:, priv: CommIpmiLanConsts::PRIV_ADMIN, key: '0'*40, server_id: 1) ⇒ CommIpmiLan
Enable IPMI over LAN.
-
#is_ipmi_enabled(handle:, server_id: 1) ⇒ TrueClass, FalseClass
Check if IPMI over LAN is enabled.
-
#is_kvm_enabled(handle:, server_id: 1) ⇒ nil
This method will check if kvm console access is enabled.
-
#is_ldap_enabled(handle:) ⇒ TrueClass, FalseClass
Checks if LDAP is enabled.
-
#is_ntp_enabled(handle:) ⇒ TrueClass, FalseClass
Check if NTP is enabled.
-
#is_sol_enabled(handle:, server_id: 1) ⇒ nil
This method will check if Serial over Lan connection is enabled.
-
#is_strong_password_set(handle:) ⇒ TrueClass, FalseClass
This method will check if strong password policy is enabled.
-
#kvm_disable(handle:, server_id: 1) ⇒ nil
This method will disable kvm console access.
-
#kvm_setup(handle:, max_sessions: 1, port: 2068, encrypt: false, mirror_locally: false, server_id: 1) ⇒ CommKvm
This method will setup and enable kvm console access.
- #ldap_certificate_management_disable(handle:) ⇒ LdapCACertificateManagement
- #ldap_certificate_management_enable(handle:) ⇒ LdapCACertificateManagement
-
#ldap_configure(handle:, enabled: false, basedn: nil, domain: nil, encryption: true, timeout: 60, user_search_precedence: 'local-user-db', bind_method: 'login-credentials', bind_dn: nil, password: nil, filter: 'sAMAccountName', attribute: 'CiscoAvPair', group_attribute: 'memberOf', group_nested_search: 128, group_auth: false, ldap_servers: [], locate_directory_using_dns: false, dns_domain_source: 'extracted-domain', dns_search_domain: nil, dns_search_forest: nil, **kwargs) ⇒ AaaLdap
Configures LDAP.
-
#ldap_role_group_get(handle:, domain:, name:, **kwargs) ⇒ AaaLdapRoleGroup
Gets the ldap role group based on domain and name.
-
#ldap_settings_exist(handle:, **kwargs) ⇒ TrueClass, ...
Checks if the specified LDAP settings are already applied.
-
#local_user_create(handle:, name:, pwd:, priv: "read-only") ⇒ AaaUser
This method will create a new local user and setup it’s role.
-
#local_user_delete(handle:, name:) ⇒ nil
This method deactivates the user referred to by the username passed.
-
#local_user_exists(handle: nil, **kwargs) ⇒ TrueClass, ...
This method checks if a user exists with attributes passed.
-
#local_user_modify(handle:, name:, **kwargs) ⇒ AaaUser
This method will modify the user with the username specified.
-
#locator_led_off(handle:, **kwargs) ⇒ nil
This method will turn off the locator led on the server or on the chassis.
-
#locator_led_on(handle:, **kwargs) ⇒ nil
This method will turn on the locator led on the server or chassis.
-
#ntp_disable(handle:) ⇒ CommNtpProvider
Disables NTP.
-
#ntp_enable(handle:, ntp_servers: Array.new) ⇒ CommNtpProvider
Enables NTP and configures the NTP servers provided.
-
#ntp_servers_clear(handle:, ntp_servers: Array.new) ⇒ CommNtpProvider
Clears the NTP servers provided in the arguments.
-
#ntp_servers_modify(handle:, ntp_servers: Array.new) ⇒ CommNtpProvider
Modifies the configured NTP servers.
-
#ntp_settings_match(handle:, **kwargs) ⇒ TrueClass, ...
Check if the specified NTP settings are already applied.
-
#password_expiration_exists(handle:, **kwargs) ⇒ TrueClass, ...
This method will check if the password expiration policy exists.
-
#password_expiration_set(handle:, password_expiry_duration:, password_history: 0, password_notification_period: 15, password_grace_period: 0) ⇒ AaaUserPasswordExpiration
This method sets up the password expiration policy for local users.
-
#physical_drive_get(handle:, controller_type:, controller_slot:, drive_slot:, server_id: 1) ⇒ StorageLocalDisk
Gets the physical drive.
-
#server_power_budget_get(handle:, server_id: 1) ⇒ PowerBudget
This api gets the min and max power limits for the platform, cpu and memory for this specific server.
-
#server_power_capping_disable(handle:, server_id: 1) ⇒ PowerBudget
Disables power capping feature on the server.
-
#server_power_capping_enable(handle:, server_id: 1) ⇒ PowerBudget
Enables power capping feature on the server.
-
#server_power_characterization_disable(handle:, server_id: 1) ⇒ PowerBudget
Disables power characterization.
-
#server_power_characterization_enable(handle:, server_id: 1) ⇒ PowerBudget
Enables power characterization.
-
#server_power_characterization_start(handle:, server_id: 1) ⇒ PowerBudget
Starts a power characterization run.
-
#server_power_cycle(handle:, timeout: 120, interval: 5, server_id: 1, **kwargs) ⇒ ComputeRackUnit, ComputeServerNode
This method will power cycle the rack server immediately.
-
#server_power_down(handle:, timeout: 60, interval: 5, server_id: 1, **kwargs) ⇒ ComputeRackUnit, ComputeServerNode
This method will power down the rack server, even if tasks are still running on it.
-
#server_power_down_gracefully(handle:, timeout: 120, interval: 5, server_id: 1, **kwargs) ⇒ ComputeRackUnit, ComputeServerNode
This method will power down the rack server gracefully.
-
#server_power_state_get(handle:, server_id: 1) ⇒ String
This method will return the oper power status of the rack server.
-
#server_power_up(handle:, timeout: 60, interval: 5, server_id: 1, **kwargs) ⇒ ComputeRackUnit, ComputeServerNode
This method will send the server the power up signal, and then polls the server every $interval until either $timeout or it comes online.
-
#server_standard_power_cap_disable(handle:, server_id: 1) ⇒ nil
This method disables the standard power profile.
-
#server_standard_power_cap_set(handle:, power_limit:, throttle: false, correction_time: 3, corrective_action: "alert", hard_cap: false, server_id: 1) ⇒ StandardPowerProfile
This method sets up the standard power cap configuration profile.
-
#set_as_boot_drive(handle:, controller_type:, controller_slot:, virtual_drive_name: nil, raid_level: nil, drive_group: nil, server_id: 1) ⇒ nil
Set drive as the boot drive.
-
#set_strong_password(handle:, enable: false) ⇒ AaaUserPolicy
This method will enable/disable strong password policy for users.
-
#sol_disable(handle:, server_id: 1) ⇒ nil
This method will disable Serial over Lan connection.
-
#sol_settings_exist(handle:, server_id: 1, **kwargs) ⇒ TrueClass, ...
This method will check if the specified SOL settings are already applied.
-
#sol_setup(handle:, speed:, comport:, ssh_port: nil, server_id: 1) ⇒ SolIf
This method will setup serial over lan connection.
-
#tag_chassis(handle:, tag:) ⇒ EquipmentChassis
This method will tag the chassis with the label specified.
-
#tag_server(handle:, tag:) ⇒ ComputeRackUnit
This method will tag the server with the label specified.
- #vd_name_derive(raid_level, drive_list) ⇒ string
-
#vd_query_by_name(handle:, controller_type:, controller_slot:, virtual_drive_name:, server_id: 1) ⇒ StorageVirtualDrive?
This method queries the virtual drive by name.
-
#virtual_drive_create(handle:, drive_group:, controller_type:, controller_slot:, raid_level: 0, virtual_drive_name: nil, access_policy: "read-write", read_policy: "no-read-ahead", cache_policy: "direct-io", disk_cache_policy: "unchanged", write_policy: "Write Through", strip_size: "64k", size: nil, self_encrypt: false, server_id: 1) ⇒ StorageVirtualDrive
Creates virtual drive from unused physical drives.
-
#virtual_drive_delete(handle:, controller_type:, controller_slot:, virtual_drive_name:, server_id: 1) ⇒ Object
Deletes the specified virtual drive.
-
#virtual_drive_exists(handle:, controller_type:, controller_slot:, virtual_drive_name:, server_id: 1) ⇒ TrueClass, ...
Checks if a virtual drive by the specified name exists.
Instance Method Details
#boot_order_precision_exists(handle:, **kwargs) ⇒ FalseClass, ...
Check if boot order precision match
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/ImcSdk/apis/server/bios.rb', line 154 def boot_order_precision_exists(handle:, **kwargs) server_dn = ImcCoreUtils.set_server_dn(handle, kwargs) mos = handle.query_children(in_dn: server_dn, class_id: "LsbootDevPrecision") if mos.size == 0 return false, "no Mos found", nil end mo = mos[0] args = {} if _is_valid_arg(:reboot_on_update, kwargs) reboot_on_update = kwargs.fetch(:reboot_on_update) if reboot_on_update.is_a? TrueClass or reboot_on_update.is_a? FalseClass reboot_on_update = reboot_on_update ? "yes" : "no" end args[:reboot_on_update] = reboot_on_update end if _is_valid_arg(:configured_boot_mode, kwargs) args[:configured_boot_mode] = kwargs.fetch(:configured_boot_mode) end #args = {:reboot_on_update => reboot_on_update, # :configured_boot_mode => kwargs.fetch(:configured_boot_mode, 'Uefi')} if !mo.check_prop_match(**args) return false, "parent MO property values do not match", mo end if _is_valid_arg(:boot_devices, kwargs) in_boot_order = kwargs[:boot_devices].sort_by { |x| x[:order]} configured_boot_order = boot_precision_configured_get( handle: handle, server_id: kwargs.fetch(:server_id, 1)) if in_boot_order.size != configured_boot_order.size return false, "length mismatch", mo end for i in (0..in_boot_order.size-1) if !(in_boot_order[i][:order] == configured_boot_order[i][:order] and in_boot_order[i][:'device-type'] == configured_boot_order[i][:'device-type'] and in_boot_order[i][:name] == configured_boot_order[i][:name]) return false, "dictionaries do not match", mo end end end return true, nil, mo end |
#boot_order_precision_set(handle:, reboot_on_update: false, reapply: false, configured_boot_mode: "Legacy", boot_devices: Array.new, server_id: 1) ⇒ LsBootDevPrecision
This method will set the boot order precision.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/ImcSdk/apis/server/bios.rb', line 102 def boot_order_precision_set( handle:, reboot_on_update: false, reapply: false, configured_boot_mode: "Legacy", boot_devices: Array.new, server_id: 1) # Insert version check here to gracefully handle older versions of CIMC # IMC expects the devices to be configured in sorted order boot_devices = boot_devices.sort_by { |x| x[:order] } server_dn = ImcCoreUtils.get_server_dn(handle, server_id) lsbootdevprecision_mo = LsbootDevPrecision.new(parent_mo_or_dn: server_dn) args = Hash.new args[:reboot_on_update] = "no" lsbootdevprecision_mo.reboot_on_update = "no" if reboot_on_update args[:reboot_on_update] = "yes" end args[:reapply] = "no" if reapply args[:reapply] = "yes" end args[:configured_boot_mode] = configured_boot_mode lsbootdevprecision_mo.set_prop_multiple(**args) #lsbootdevprecision_mo.set_prop(:configured_boot_mode, configured_boot_mode) handle.set_mo(mo: lsbootdevprecision_mo) boot_order_child_mos = handle.query_children(in_dn: lsbootdevprecision_mo.dn) for mo in boot_order_child_mos handle.remove_mo(mo: mo) end for device in boot_devices _add_boot_device(handle, lsbootdevprecision_mo.dn, device) end lsbootdevprecision_mo = handle.query_classid(class_id: "LsbootDevPrecision") return lsbootdevprecision_mo end |
#boot_precision_configured_get(handle:, server_id: 1) ⇒ Array<Hash>
Get the configured boot precision settings
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/ImcSdk/apis/server/bios.rb', line 207 def boot_precision_configured_get(handle:, server_id: 1) configured_boot_order = [] class_to_name_dict = {} PRECISION_DEVICE_DICT.each do |key, value| classname = value[:class_id] class_to_name_dict[classname.to_sym] = key end server_dn = ImcCoreUtils.get_server_dn(handle, server_id) pmo = LsbootDevPrecision.new(parent_mo_or_dn: server_dn) mos = handle.query_children(in_dn: pmo.dn) for mo in mos #class_id = mo.instance_variable_get("@class_id") device = {:order => mo.order, :'device-type' => class_to_name_dict[mo.instance_variable_get("@class_id").to_sym].to_s, :name => mo.name} configured_boot_order.push(device) end return configured_boot_order.sort_by {|x| x[:order]} end |
#get_locator_led_status(handle:, **kwargs) ⇒ string
This method will return the locator led status on the server or chassis
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/ImcSdk/apis/server/serveractions.rb', line 182 def get_locator_led_status(handle:, **kwargs) led_mo = nil led_status = String.new if _is_valid_arg("chassis_id", kwargs) led_mo = _get_chassis_locator_led_state(handle, kwargs) end if _is_valid_arg("server_id", kwargs) or \ handle.platform == IMC_PLATFORM::TYPE_CLASSIC led_mo = _get_server_locator_led_state(handle, kwargs) end if !led_mo.nil? led_status = led_mo.oper_state end return led_status end |
#get_supported_models ⇒ Object
This api returns the list of rack server models that support power cap and power budgeting
29 30 31 |
# File 'lib/ImcSdk/apis/server/power.rb', line 29 def get_supported_models() return SUPPORTED_MODELS end |
#ipmi_disable(handle:, server_id: 1) ⇒ CommIpmiLan
Disable IPMI over LAN.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ImcSdk/apis/admin/ipmi.rb', line 61 def ipmi_disable(handle:, server_id: 1) # Create disabled IPMI object ipmi_mo = CommIpmiLan.new(parent_mo_or_dn: _get_comm_mo_dn(handle, server_id)) ipmi_mo.set_prop(:admin_state, "disabled") # Configure IPMI object on CIMC handle.set_mo(mo: ipmi_mo) return handle.query_dn(dn: ipmi_mo.dn) end |
#ipmi_enable(handle:, priv: CommIpmiLanConsts::PRIV_ADMIN, key: '0'*40, server_id: 1) ⇒ CommIpmiLan
Enable IPMI over LAN.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ImcSdk/apis/admin/ipmi.rb', line 32 def ipmi_enable(handle:, priv: CommIpmiLanConsts::PRIV_ADMIN, key: '0'*40, server_id: 1) # Verify key is a hex number begin key.to_i(16).to_s(16) rescue raise ValueError.new("#{handle.ip}: ERROR: Encryption key is not hex number: #{key}") end # Create enabled IPMI object ipmi_mo = CommIpmiLan.new(parent_mo_or_dn: _get_comm_mo_dn(handle, server_id)) args = {:admin_state => "enabled", :priv => priv, :key => key} ipmi_mo.set_prop_multiple(**args) # Configure IPMI object on CIMC handle.set_mo(mo: ipmi_mo) return handle.query_dn(dn: ipmi_mo.dn) end |
#is_ipmi_enabled(handle:, server_id: 1) ⇒ TrueClass, FalseClass
Check if IPMI over LAN is enabled
79 80 81 82 83 84 |
# File 'lib/ImcSdk/apis/admin/ipmi.rb', line 79 def is_ipmi_enabled(handle:, server_id: 1) ipmi_mo = CommIpmiLan.new(parent_mo_or_dn:_get_comm_mo_dn(handle, server_id)) ipmi_mo = handle.query_dn(dn: ipmi_mo.dn) return (ipmi_mo.admin_state.downcase == "enabled") end |
#is_kvm_enabled(handle:, server_id: 1) ⇒ nil
This method will check if kvm console access is enabled
74 75 76 77 78 |
# File 'lib/ImcSdk/apis/server/remotepresence.rb', line 74 def is_kvm_enabled(handle:, server_id: 1) kvm_mo = CommKvm.new(parent_mo_or_dn: _get_comm_mo_dn(handle, server_id)) kvm_mo = handle.query_dn(dn: kvm_mo.dn) return(kvm_mo.admin_state.downcase == "enabled") end |
#is_ldap_enabled(handle:) ⇒ TrueClass, FalseClass
Checks if LDAP is enabled
71 72 73 74 |
# File 'lib/ImcSdk/apis/admin/ldap.rb', line 71 def is_ldap_enabled(handle:) mo = _get_mo(handle: handle, dn: LDAP_DN) return mo.admin_state.downcase == "enabled" end |
#is_ntp_enabled(handle:) ⇒ TrueClass, FalseClass
Check if NTP is enabled
128 129 130 131 |
# File 'lib/ImcSdk/apis/admin/ntp.rb', line 128 def is_ntp_enabled(handle:) mo = _get_mo(handle: handle, dn: NTP_DN) return (["true", "yes"].include? mo.ntp_enable.downcase) end |
#is_sol_enabled(handle:, server_id: 1) ⇒ nil
This method will check if Serial over Lan connection is enabled
125 126 127 128 129 |
# File 'lib/ImcSdk/apis/server/remotepresence.rb', line 125 def is_sol_enabled(handle:, server_id: 1) solif_mo = SolIf.new(parent_mo_or_dn: ImcCoreUtils.get_server_dn(handle, server_id)) solif_mo = handle.query_dn(dn: solif_mo.dn) return ["enable", "enabled"].include? solif_mo.admin_state.downcase end |
#is_strong_password_set(handle:) ⇒ TrueClass, FalseClass
This method will check if strong password policy is enabled.
42 43 44 45 46 47 48 |
# File 'lib/ImcSdk/apis/admin/user.rb', line 42 def is_strong_password_set(handle:) mos = handle.query_classid(class_id: "AaaUserPolicy") if mos.size == 0 raise ImcOperationError.new("Check Password Strength", "MO does not exist") end return (mos[0].user_password_policy == "enabled") end |
#kvm_disable(handle:, server_id: 1) ⇒ nil
This method will disable kvm console access
61 62 63 64 65 |
# File 'lib/ImcSdk/apis/server/remotepresence.rb', line 61 def kvm_disable(handle:, server_id: 1) kvm_mo = CommKvm.new(parent_mo_or_dn: _get_comm_mo_dn(handle, server_id)) kvm_mo.set_prop(:admin_state, "disabled") handle.set_mo(mo: kvm_mo) end |
#kvm_setup(handle:, max_sessions: 1, port: 2068, encrypt: false, mirror_locally: false, server_id: 1) ⇒ CommKvm
This method will setup and enable kvm console access
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ImcSdk/apis/server/remotepresence.rb', line 38 def kvm_setup(handle: , max_sessions: 1, port: 2068,\ encrypt: false, mirror_locally: false, server_id: 1) kvm_mo = CommKvm.new(parent_mo_or_dn: _get_comm_mo_dn(handle, server_id)) params = { :admin_state => "enabled", :total_sessions => max_sessions.to_s, :port => port.to_s, :encryption_state => encrypt ? "enabled" : "disabled", :local_video_state => mirror_locally ? "enabled" : "disabled" } kvm_mo.set_prop_multiple(**params) handle.set_mo(mo: kvm_mo) return kvm_mo end |
#ldap_certificate_management_disable(handle:) ⇒ LdapCACertificateManagement
200 201 202 203 204 205 |
# File 'lib/ImcSdk/apis/admin/ldap.rb', line 200 def ldap_certificate_management_disable(handle:) mo = _get_mo(handle: handle, dn: "sys/ldap-ext/ldap-ca-cert-mgmt") mo.set_prop(:binding_certificate, "disabled") handle.set_mo(mo: mo) return handle.query_dn(dn: mo.dn) end |
#ldap_certificate_management_enable(handle:) ⇒ LdapCACertificateManagement
188 189 190 191 192 193 |
# File 'lib/ImcSdk/apis/admin/ldap.rb', line 188 def ldap_certificate_management_enable(handle:) mo = _get_mo(handle: handle, dn: "sys/ldap-ext/ldap-ca-cert-mgmt") mo.set_prop(:binding_certificate, "enabled") handle.set_mo(mo: mo) return handle.query_dn(dn: mo.dn) end |
#ldap_configure(handle:, enabled: false, basedn: nil, domain: nil, encryption: true, timeout: 60, user_search_precedence: 'local-user-db', bind_method: 'login-credentials', bind_dn: nil, password: nil, filter: 'sAMAccountName', attribute: 'CiscoAvPair', group_attribute: 'memberOf', group_nested_search: 128, group_auth: false, ldap_servers: [], locate_directory_using_dns: false, dns_domain_source: 'extracted-domain', dns_search_domain: nil, dns_search_forest: nil, **kwargs) ⇒ AaaLdap
Configures LDAP
138 139 140 141 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 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/ImcSdk/apis/admin/ldap.rb', line 138 def ldap_configure(handle:, enabled: false, basedn: nil, domain: nil, encryption: true, timeout: 60, user_search_precedence: 'local-user-db', bind_method: 'login-credentials', bind_dn: nil, password: nil, filter: 'sAMAccountName', attribute: 'CiscoAvPair', group_attribute: 'memberOf', group_nested_search: 128, group_auth: false, ldap_servers: [], locate_directory_using_dns: false, dns_domain_source: 'extracted-domain', dns_search_domain: nil, dns_search_forest: nil, **kwargs) mo = _get_mo(handle: handle, dn: LDAP_DN) params = { :admin_state => enabled == true ? 'enabled' : 'disabled', :basedn => basedn, :domain => domain, :encryption => encryption == true ? 'enabled' : 'disabled', :timeout => timeout.to_s, :user_search_precedence => user_search_precedence, :bind_method => bind_method, :bind_dn => bind_dn, :password => password, :filter => filter, :attribute => attribute, :group_attribute => group_attribute, :group_nested_search => group_nested_search.to_s, :group_auth => group_auth == true ? 'enabled' : 'disabled', :locate_directory_using_dns => locate_directory_using_dns == true ? 'yes' : 'no', :dns_domain_source => dns_domain_source, :dns_search_domain => dns_search_domain, :dns_search_forest => dns_search_forest } mo.set_prop_multiple(**params) if ldap_servers _set_ldap_servers(mo, ldap_servers) end mo.set_prop_multiple(**kwargs) handle.set_mo(mo: mo) return handle.query_dn(dn: mo.dn) end |
#ldap_role_group_get(handle:, domain:, name:, **kwargs) ⇒ AaaLdapRoleGroup
Gets the ldap role group based on domain and name
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ImcSdk/apis/admin/ldap.rb', line 87 def ldap_role_group_get(handle:, domain:, name:, **kwargs) mos = handle.query_classid('AaaLdapRoleGroup') for mo in mos if mo.domain == domain and mo.name == name return mo end end return nil end |
#ldap_settings_exist(handle:, **kwargs) ⇒ TrueClass, ...
Checks if the specified LDAP settings are already applied
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ImcSdk/apis/admin/ldap.rb', line 42 def ldap_settings_exist(handle:, **kwargs) mo = _get_mo(handle: handle, dn: LDAP_DN) params = _get_ldap_params(kwargs) if !mo.check_prop_match(**params) return false, mo end if _is_valid_arg('ldap_servers', kwargs) if ! _check_ldap_server_match(mo, kwargs.delete(:ldap_servers)) return false, mo end end if !mo.check_prop_match(**kwargs) return false, mo end return true, mo end |
#local_user_create(handle:, name:, pwd:, priv: "read-only") ⇒ AaaUser
If the privileges have changed for an existing user, (1) will fail, but (2) will pass in that case.
This method will create a new local user and setup it’s role.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/ImcSdk/apis/admin/user.rb', line 112 def local_user_create(handle:, name:, pwd:, priv: "read-only") user = _get_local_user(handle, name) if !user.nil? return local_user_modify(handle: handle, name: name, :priv => priv, :account_status => AaaUserConsts::ACCOUNT_STATUS_ACTIVE) end available_user_id = _get_free_user_id(handle) new_user = AaaUser.new( parent_mo_or_dn: "sys/user-ext", id: available_user_id) args = {:name => name, :pwd => pwd, :priv => priv, :account_status => AaaUserConsts::ACCOUNT_STATUS_ACTIVE} new_user.set_prop_multiple(**args) handle.set_mo(mo: new_user) #return new_user return handle.query_dn(dn: new_user.dn) end |
#local_user_delete(handle:, name:) ⇒ nil
This method deactivates the user referred to by the username passed
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/ImcSdk/apis/admin/user.rb', line 161 def local_user_delete(handle:, name:) found_user = _get_local_user(handle, name=name) if found_user.nil? raise ImcOperationError.new("Delete Local User", "User doesn't exist") end kwargs = {} kwargs[:admin_action] = AaaUserConsts::ADMIN_ACTION_CLEAR kwargs[:account_status] = AaaUserConsts::ACCOUNT_STATUS_INACTIVE kwargs[:priv] = AaaUserConsts::PRIV_READ_ONLY found_user.set_prop_multiple(**kwargs) handle.set_mo(mo: found_user) return handle.query_dn(dn: found_user.dn) end |
#local_user_exists(handle: nil, **kwargs) ⇒ TrueClass, ...
This method checks if a user exists with attributes passed
187 188 189 190 191 192 193 194 195 |
# File 'lib/ImcSdk/apis/admin/user.rb', line 187 def local_user_exists(handle: nil, **kwargs) users = _get_local_users(handle) users.each do |user| if user.check_prop_match(**kwargs) return true, user end end return false, nil end |
#local_user_modify(handle:, name:, **kwargs) ⇒ AaaUser
This method will modify the user with the username specified
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/ImcSdk/apis/admin/user.rb', line 142 def local_user_modify(handle:, name:, **kwargs) found_user = _get_local_user(handle, name) if found_user.nil? raise ImcOperationError.new("Modify Local User", "User doesn't exist") end found_user.set_prop_multiple(**kwargs) handle.set_mo(mo: found_user) return handle.query_dn(dn: found_user.dn) end |
#locator_led_off(handle:, **kwargs) ⇒ nil
This method will turn off the locator led on the server or on the chassis
237 238 239 240 241 242 243 244 245 246 |
# File 'lib/ImcSdk/apis/server/serveractions.rb', line 237 def locator_led_off(handle:, **kwargs) if _is_valid_arg("chassis_id", kwargs) _set_chassis_locator_led_state(handle, false, kwargs) end if _is_valid_arg("server_id", kwargs) or \ handle.platform == IMC_PLATFORM::TYPE_CLASSIC _set_server_locator_led_state(handle, false, kwargs) end end |
#locator_led_on(handle:, **kwargs) ⇒ nil
This method will turn on the locator led on the server or chassis
212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/ImcSdk/apis/server/serveractions.rb', line 212 def locator_led_on(handle:, **kwargs) if _is_valid_arg("chassis_id", kwargs) _set_chassis_locator_led_state(handle, true, kwargs) end if _is_valid_arg("server_id", kwargs) or \ handle.platform == IMC_PLATFORM::TYPE_CLASSIC _set_server_locator_led_state(handle, true, kwargs) end end |
#ntp_disable(handle:) ⇒ CommNtpProvider
Disables NTP
53 54 55 56 57 58 |
# File 'lib/ImcSdk/apis/admin/ntp.rb', line 53 def ntp_disable(handle:) mo = _get_mo(handle: handle, dn: NTP_DN) mo.set_prop(:ntp_enable, "no") handle.set_mo(mo: mo) return handle.query_dn(dn: mo.dn) end |
#ntp_enable(handle:, ntp_servers: Array.new) ⇒ CommNtpProvider
Upto 4 ntp servers can be specified.
Enables NTP and configures the NTP servers provided
38 39 40 41 42 43 44 45 |
# File 'lib/ImcSdk/apis/admin/ntp.rb', line 38 def ntp_enable(handle:, ntp_servers: Array.new) mo = _get_mo(handle: handle, dn: NTP_DN) mo.set_prop(:ntp_enable, "yes") _set_ntp_servers(mo, ntp_servers) handle.set_mo(mo: mo) return handle.query_dn(dn: mo.dn) end |
#ntp_servers_clear(handle:, ntp_servers: Array.new) ⇒ CommNtpProvider
Clears the NTP servers provided in the arguments. Clears all the NTP servers, only if ntp is disabled.
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 93 |
# File 'lib/ImcSdk/apis/admin/ntp.rb', line 68 def ntp_servers_clear(handle:, ntp_servers: Array.new) mo = _get_mo(handle: handle, dn: NTP_DN) args = {} if ntp_servers.size > 0 NTP_SERVER_LIST.each do |x| ntp_server_ip = mo.instance_variable_get("@" + x ) if ntp_servers.include? ntp_server_ip args[x.to_sym] = "" end end #args = {x => "" for x in NTP_SERVER_LIST if mo.instance_variable_get("@" + x) in ntp_servers} else NTP_SERVER_LIST.each do |x| args[x.to_sym] = "" end end if ["yes", "true"].include? mo.ntp_enable.downcase and args.size == NTP_SERVER_LIST.size raise ImcOperationError.new("Clear NTP Servers", "Cannot clear all NTP servers when NTP is enabled") end mo.set_prop(:ntp_enable, mo.ntp_enable) mo.set_prop_multiple(**args) handle.set_mo(mo: mo) return handle.query_dn(dn: mo.dn) end |
#ntp_servers_modify(handle:, ntp_servers: Array.new) ⇒ CommNtpProvider
Upto 4 ntp servers can be specified.
Modifies the configured NTP servers
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ImcSdk/apis/admin/ntp.rb', line 110 def ntp_servers_modify(handle:, ntp_servers: Array.new) # While sending the modified list of servers, it is imperative to send # ntp_enable property in the request. # Hence, query the MO and reassign the same value to ntp_enable mo = _get_mo(handle: handle, dn: NTP_DN) mo.set_prop(:ntp_enable, mo.ntp_enable) _set_ntp_servers(mo, ntp_servers) handle.set_mo(mo: mo) return handle.query_dn(dn: mo.dn) end |
#ntp_settings_match(handle:, **kwargs) ⇒ TrueClass, ...
Check if the specified NTP settings are already applied
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/ImcSdk/apis/admin/ntp.rb', line 153 def ntp_settings_match(handle:, **kwargs) ntp_mo = _get_mo(handle: handle, dn: NTP_DN) if _is_valid_arg("ntp_enable", kwargs) if ntp_mo.ntp_enable != kwargs[:ntp_enable] return false, ntp_mo end end if _is_valid_arg("ntp_servers", kwargs) require "mometa/comm/CommNtpProvider" mo = CommNtpProvider.new( parent_mo_or_dn: COMM_EXT_DN) _set_ntp_servers(mo, kwargs[:ntp_servers]) if !_check_ntp_server_match(ntp_mo, mo) return false, ntp_mo end end return true, ntp_mo end |
#password_expiration_exists(handle:, **kwargs) ⇒ TrueClass, ...
This method will check if the password expiration policy exists
88 89 90 91 92 93 94 95 |
# File 'lib/ImcSdk/apis/admin/user.rb', line 88 def password_expiration_exists(handle:, **kwargs) mo = AaaUserPasswordExpiration.new(parent_mo_or_dn: "sys/user-ext") mo = handle.query_dn(dn: mo.dn) if mo.nil? return false, nil end return mo.check_prop_match(**kwargs), mo end |
#password_expiration_set(handle:, password_expiry_duration:, password_history: 0, password_notification_period: 15, password_grace_period: 0) ⇒ AaaUserPasswordExpiration
This method sets up the password expiration policy for local users
Setting this to zero will disable password expiry. the new password entered should not have been used in the past. the user will be notified before password expiry. the old password will still be valid after the password expiry
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ImcSdk/apis/admin/user.rb', line 63 def password_expiration_set(handle:, password_expiry_duration:, password_history: 0, password_notification_period: 15, password_grace_period: 0) mo = AaaUserPasswordExpiration.new(parent_mo_or_dn: "sys/user-ext") args = { :password_expiry_duration => password_expiry_duration.to_s, :password_history => password_history.to_s, :password_notification_period => password_notification_period.to_s, :password_grace_period => password_grace_period.to_s } mo.set_prop_multiple(**args) handle.set_mo(mo: mo) return handle.query_dn(dn: mo.dn) end |
#physical_drive_get(handle:, controller_type:, controller_slot:, drive_slot:, server_id: 1) ⇒ StorageLocalDisk
Gets the physical drive
251 252 253 254 255 256 257 258 259 260 |
# File 'lib/ImcSdk/apis/server/storage.rb', line 251 def physical_drive_get(handle:, controller_type:, controller_slot:, drive_slot:, server_id: 1) controller_dn = _get_controller_dn(handle, controller_type, controller_slot, server_id) drive_dn = controller_dn + '/pd-' + drive_slot.to_s return handle.query_dn(dn: drive_dn) end |
#server_power_budget_get(handle:, server_id: 1) ⇒ PowerBudget
This api gets the min and max power limits for the platform, cpu and memory for this specific server
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ImcSdk/apis/server/power.rb', line 41 def server_power_budget_get(handle: , server_id: 1) if !_is_supported_model(handle) return end power_budget_mo = handle.query_children(in_dn: ImcCoreUtils.get_server_dn(handle, server_id), class_id: "PowerBudget") if !power_budget_mo raise ImcOperationError.new("Get Power Budget", "Invalid Server Id configured") end return power_budget_mo[0] end |
#server_power_capping_disable(handle:, server_id: 1) ⇒ PowerBudget
Disables power capping feature on the server.
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ImcSdk/apis/server/power.rb', line 118 def server_power_capping_disable(handle:, server_id: 1) if !_is_supported_model(handle) return end power_budget_mo = PowerBudget.new(parent_mo_or_dn: ImcCoreUtils.get_server_dn(handle, server_id)) power_budget_mo.set_prop(:admin_state, "disabled") handle.set_mo(mo: power_budget_mo) return power_budget_mo end |
#server_power_capping_enable(handle:, server_id: 1) ⇒ PowerBudget
Enables power capping feature on the server.
101 102 103 104 105 106 107 108 109 |
# File 'lib/ImcSdk/apis/server/power.rb', line 101 def server_power_capping_enable(handle:, server_id: 1) if !_is_supported_model(handle) return end power_budget_mo = PowerBudget.new(parent_mo_or_dn: ImcCoreUtils.get_server_dn(handle, server_id)) power_budget_mo.set_prop(:admin_state, "enabled") handle.set_mo(mo: power_budget_mo) return power_budget_mo end |
#server_power_characterization_disable(handle:, server_id: 1) ⇒ PowerBudget
Disables power characterization.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ImcSdk/apis/server/power.rb', line 81 def server_power_characterization_disable(handle:, server_id: 1) if !_is_supported_model(handle) return end server_standard_power_cap_disable(handle: handle, server_id: server_id) power_budget_mo = PowerBudget.new(parent_mo_or_dn: ImcCoreUtils.get_server_dn(handle, server_id)) power_budget_mo.set_prop(:pow_char_enable, "disabled") handle.set_mo(mo: power_budget_mo) return handle.query_dn(dn: power_budget_mo.dn) end |
#server_power_characterization_enable(handle:, server_id: 1) ⇒ PowerBudget
Enables power characterization.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ImcSdk/apis/server/power.rb', line 63 def server_power_characterization_enable(handle:, server_id: 1) if !_is_supported_model(handle) return end power_budget_mo = PowerBudget.new(parent_mo_or_dn: ImcCoreUtils.get_server_dn(handle, server_id)) power_budget_mo.set_prop(:pow_char_enable, "enabled") handle.set_mo(mo: power_budget_mo) return handle.query_dn(dn: power_budget_mo.dn) end |
#server_power_characterization_start(handle:, server_id: 1) ⇒ PowerBudget
Starts a power characterization run. From 3.0(1c) onwards, server_power_characterization_enable needs to be explicitly done, before invoking this api.
201 202 203 204 205 206 207 208 209 |
# File 'lib/ImcSdk/apis/server/power.rb', line 201 def server_power_characterization_start(handle:, server_id: 1) if !_is_supported_model(handle) return end power_budget_mo = PowerBudget.new(parent_mo_or_dn: ImcCoreUtils.get_server_dn(handle, server_id)) power_budget_mo.set_prop(:admin_action, PowerBudgetConsts::ADMIN_ACTION_START_POWER_CHAR) handle.set_mo(mo: power_budget_mo) return handle.query_dn(dn: power_budget_mo.dn) end |
#server_power_cycle(handle:, timeout: 120, interval: 5, server_id: 1, **kwargs) ⇒ ComputeRackUnit, ComputeServerNode
This method will power cycle the rack server immediately.
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/ImcSdk/apis/server/serveractions.rb', line 158 def server_power_cycle(handle:, timeout: 120, interval: 5, server_id: 1, **kwargs) server_dn = ImcCoreUtils.get_server_dn(handle, server_id) _set_power_state(handle, server_dn, "cycle") # Poll until the server is powered up _wait_for_power_state(handle, "on", timeout: timeout, interval: interval, server_id: server_id) return handle.query_dn(dn: server_dn) end |
#server_power_down(handle:, timeout: 60, interval: 5, server_id: 1, **kwargs) ⇒ ComputeRackUnit, ComputeServerNode
This method will power down the rack server, even if tasks are still running on it. Then polls the server every $interval until either $timeout
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ImcSdk/apis/server/serveractions.rb', line 94 def server_power_down(handle:, timeout: 60, interval: 5, server_id: 1, **kwargs) server_dn = ImcCoreUtils.get_server_dn(handle, server_id) # Turn power off only if not already powered down if server_power_state_get(handle: handle,server_id: server_id) != "off" _set_power_state(handle, server_dn, "down") end # Poll until the server is powered up _wait_for_power_state(handle, "off", timeout: timeout, interval: interval, server_id: server_id) return handle.query_dn(dn: server_dn) end |
#server_power_down_gracefully(handle:, timeout: 120, interval: 5, server_id: 1, **kwargs) ⇒ ComputeRackUnit, ComputeServerNode
This method will power down the rack server gracefully
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/ImcSdk/apis/server/serveractions.rb', line 125 def server_power_down_gracefully(handle:, timeout: 120, interval: 5, server_id: 1, **kwargs) server_dn = ImcCoreUtils.get_server_dn(handle, server_id) # Gracefully power off only if not already powered down if server_power_state_get(handle: handle, server_id: server_id) != "off" _set_power_state(handle, server_dn, "graceful-down") end # Poll until the server is powered up _wait_for_power_state(handle, "off", timeout: timeout, interval: interval, server_id: server_id) return handle.query_dn(dn: server_dn) end |
#server_power_state_get(handle:, server_id: 1) ⇒ String
If server_id is not specified, this will assume server_id=“1”
This method will return the oper power status of the rack server
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ImcSdk/apis/server/serveractions.rb', line 31 def server_power_state_get(handle:, server_id: 1) server_dn = ImcCoreUtils.get_server_dn(handle, server_id) server_mo = handle.query_dn(dn: server_dn) if server_mo return server_mo.oper_power end raise ImcOperationError.new("Get Server Power State", "Managed Object not found for dn: #{server_dn}") end |
#server_power_up(handle:, timeout: 60, interval: 5, server_id: 1, **kwargs) ⇒ ComputeRackUnit, ComputeServerNode
This method will send the server the power up signal, and then polls the server every $interval until either $timeout or it comes online.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ImcSdk/apis/server/serveractions.rb', line 60 def server_power_up(handle:, timeout: 60, interval: 5, server_id: 1, **kwargs) server_dn = ImcCoreUtils.get_server_dn(handle, server_id) # Turn power on only if not already powered up if server_power_state_get(handle: handle,server_id: server_id) != "on" _set_power_state(handle, server_dn, "up") end # Poll until the server is powered up _wait_for_power_state(handle, "on", timeout: timeout, interval: interval, server_id: server_id) # Return object with current state return handle.query_dn(dn: server_dn) end |
#server_standard_power_cap_disable(handle:, server_id: 1) ⇒ nil
This method disables the standard power profile
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/ImcSdk/apis/server/power.rb', line 181 def server_standard_power_cap_disable(handle:, server_id: 1) if !_is_supported_model(handle) return end server_dn = ImcCoreUtils.get_server_dn(handle, server_id) power_budget_dn = server_dn + "/budget" stdpowerprof_mo = StandardPowerProfile.new(parent_mo_or_dn: power_budget_dn) stdpowerprof_mo.set_prop(:profile_enabled, "no") handle.set_mo(mo: stdpowerprof_mo) end |
#server_standard_power_cap_set(handle:, power_limit:, throttle: false, correction_time: 3, corrective_action: "alert", hard_cap: false, server_id: 1) ⇒ StandardPowerProfile
This method sets up the standard power cap configuration profile
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/ImcSdk/apis/server/power.rb', line 150 def server_standard_power_cap_set(handle:, power_limit:, throttle: false, correction_time: 3, corrective_action: "alert", hard_cap: false, server_id: 1) if !_is_supported_model(handle) return end power_budget_dn = ImcCoreUtils.get_server_dn(handle, server_id) + "/budget" stdpowerprof_mo = StandardPowerProfile.new(parent_mo_or_dn: power_budget_dn) params = { :allow_throttle => throttle ? "yes" : "no", :power_limit => power_limit.to_s, :corr_time => correction_time.to_s, :corr_action => corrective_action, :profile_enabled => "yes", :hard_cap => hard_cap ? "yes" : "no" } stdpowerprof_mo.set_prop_multiple(**params) handle.set_mo(mo: stdpowerprof_mo) return stdpowerprof_mo end |
#set_as_boot_drive(handle:, controller_type:, controller_slot:, virtual_drive_name: nil, raid_level: nil, drive_group: nil, server_id: 1) ⇒ nil
Set drive as the boot drive
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ImcSdk/apis/server/storage.rb', line 83 def set_as_boot_drive(handle:, controller_type:, controller_slot:, virtual_drive_name: nil, raid_level: nil, drive_group: nil, server_id: 1) vd_name = virtual_drive_name if vd_name.nil? vd_name = vd_name_derive(raid_level,drive_group) end vd = vd_query_by_name(handle: handle, controller_type: controller_type, controller_slot: controller_slot, virtual_drive_name: vd_name, server_id: server_id) vd.set_prop(:admin_action,"set-boot-drive") handle.set_mo(mo: vd) end |
#set_strong_password(handle:, enable: false) ⇒ AaaUserPolicy
This method will enable/disable strong password policy for users.
27 28 29 30 31 32 33 34 |
# File 'lib/ImcSdk/apis/admin/user.rb', line 27 def set_strong_password(handle:, enable: false) mos = handle.query_classid(class_id: "AaaUserPolicy") user_policy = mos[0] enable ? user_policy.set_prop(:user_password_policy, "enabled") : user_policy.set_prop(:user_password_policy, "disabled") handle.set_mo(mo: user_policy) return handle.query_dn(dn: user_policy.dn) end |
#sol_disable(handle:, server_id: 1) ⇒ nil
This method will disable Serial over Lan connection
112 113 114 115 116 |
# File 'lib/ImcSdk/apis/server/remotepresence.rb', line 112 def sol_disable(handle:, server_id: 1) solif_mo = SolIf.new(parent_mo_or_dn: ImcCoreUtils.get_server_dn(handle, server_id)) solif_mo.set_prop(:admin_state, SolIfConsts::ADMIN_STATE_DISABLE) handle.set_mo(mo: solif_mo) end |
#sol_settings_exist(handle:, server_id: 1, **kwargs) ⇒ TrueClass, ...
This method will check if the specified SOL settings are already applied.
141 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 170 |
# File 'lib/ImcSdk/apis/server/remotepresence.rb', line 141 def sol_settings_exist(handle:, server_id: 1, **kwargs) exists = true solif_mo = SolIf.new(parent_mo_or_dn: ImcCoreUtils.get_server_dn(handle, server_id)) solif_mo = handle.query_dn(dn: solif_mo.dn) if _is_valid_arg("admin_state", kwargs) if solif_mo.admin_state.downcase != kwargs[:admin_state].downcase exists = false end end if _is_valid_arg("speed", kwargs) if solif_mo.speed.to_s != kwargs[:speed].to_s exists = false end end if _is_valid_arg("comport", kwargs) if solif_mo.comport != kwargs[:comport] exists = false end end if _is_valid_arg("ssh_port", kwargs) if solif_mo.ssh_port.to_s != kwargs[:ssh_port].to_s exists = false end end return exists, solif_mo end |
#sol_setup(handle:, speed:, comport:, ssh_port: nil, server_id: 1) ⇒ SolIf
This method will setup serial over lan connection
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ImcSdk/apis/server/remotepresence.rb', line 89 def sol_setup(handle:, speed:, comport:, ssh_port: nil, server_id: 1) solif_mo = SolIf.new(parent_mo_or_dn: ImcCoreUtils.get_server_dn(handle, server_id)) params = { :admin_state => SolIfConsts::ADMIN_STATE_ENABLE, :speed => speed.to_s, :comport => comport } if !ssh_port.nil? params[:ssh_port] = ssh_port.to_s end solif_mo.set_prop_multiple(**params) handle.set_mo(mo: solif_mo) return handle.query_dn(dn: solif_mo.dn) end |
#tag_chassis(handle:, tag:) ⇒ EquipmentChassis
This method will tag the chassis with the label specified. Applicable to C3260 platforms
276 277 278 279 280 281 282 |
# File 'lib/ImcSdk/apis/server/serveractions.rb', line 276 def tag_chassis(handle:, tag:) require "mometa/equipment/EquipmentChassis" mo = EquipmentChassis.new(parent_mo_or_dn: "sys") mo.set_prop(:asset_tag, tag.to_s) handle.set_mo(mo: mo) return handle.query_dn(dn: mo.dn) end |
#tag_server(handle:, tag:) ⇒ ComputeRackUnit
This method will tag the server with the label specified. Applicable to non-C3260 platforms
258 259 260 261 262 263 264 |
# File 'lib/ImcSdk/apis/server/serveractions.rb', line 258 def tag_server(handle:, tag:) require "mometa/compute/ComputeRackUnit" mo = ComputeRackUnit.new(parent_mo_or_dn: "sys", server_id: '1') mo.set_prop(:asset_tag, tag.to_s) handle.set_mo(mo: mo) return handle.query_dn(dn: mo.dn) end |
#vd_name_derive(raid_level, drive_list) ⇒ string
34 35 36 |
# File 'lib/ImcSdk/apis/server/storage.rb', line 34 def vd_name_derive(raid_level, drive_list) return "RAID" + raid_level.to_s + "_" + _flatten_to_string(drive_list) end |
#vd_query_by_name(handle:, controller_type:, controller_slot:, virtual_drive_name:, server_id: 1) ⇒ StorageVirtualDrive?
This method queries the virtual drive by name
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ImcSdk/apis/server/storage.rb', line 49 def vd_query_by_name(handle:, controller_type:, controller_slot:, virtual_drive_name:, server_id: 1) slot_dn = _get_controller_dn(handle, controller_type, controller_slot, server_id) mos = handle.query_children(in_dn: slot_dn, class_id: "storageVirtualDrive") for mo in mos if mo.name == virtual_drive_name return mo end end return nil end |
#virtual_drive_create(handle:, drive_group:, controller_type:, controller_slot:, raid_level: 0, virtual_drive_name: nil, access_policy: "read-write", read_policy: "no-read-ahead", cache_policy: "direct-io", disk_cache_policy: "unchanged", write_policy: "Write Through", strip_size: "64k", size: nil, self_encrypt: false, server_id: 1) ⇒ StorageVirtualDrive
Creates virtual drive from unused physical drives
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/ImcSdk/apis/server/storage.rb', line 185 def virtual_drive_create(handle:, drive_group:, controller_type:, controller_slot:, raid_level: 0, virtual_drive_name: nil, access_policy: "read-write", read_policy: "no-read-ahead", cache_policy: "direct-io", disk_cache_policy: "unchanged", write_policy: "Write Through", strip_size: "64k", size: nil, self_encrypt: false, server_id: 1) slot_dn = _get_controller_dn(handle, controller_type, controller_slot, server_id) dg_str = _list_to_string(drive_group) vdn = virtual_drive_name params = {} params[:parent_mo_or_dn] = slot_dn params[:drive_group] = dg_str params[:raid_level] = raid_level.to_s params[:access_policy] = access_policy params[:read_policy] = read_policy params[:cache_policy] = cache_policy params[:disk_cache_policy] = disk_cache_policy params[:write_policy] = write_policy params[:strip_size] = strip_size if self_encrypt params[:admin_action] = "enable-self-encrypt" end params[:virtual_drive_name] = vdn.nil? ? vd_name_derive(raid_level, drive_group) : vdn params[:size] = size.nil? ? _vd_max_size_get(handle, controller_type, controller_slot, drive_group, raid_level, server_id) : size require "mometa/storage/StorageVirtualDriveCreatorUsingUnusedPhysicalDrive" #mo = vd_creator(**params) mo = StorageVirtualDriveCreatorUsingUnusedPhysicalDrive.new(**params) mo.set_prop(:admin_state, "trigger") handle.add_mo(mo: mo) return mo end |
#virtual_drive_delete(handle:, controller_type:, controller_slot:, virtual_drive_name:, server_id: 1) ⇒ Object
Deletes the specified virtual drive
138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/ImcSdk/apis/server/storage.rb', line 138 def virtual_drive_delete(handle:, controller_type:, controller_slot:, virtual_drive_name:, server_id: 1) vd = vd_query_by_name(handle: handle, controller_type: controller_type, controller_slot: controller_slot, virtual_drive_name: virtual_drive_name, server_id: server_id) handle.remove_mo(mo: vd) end |
#virtual_drive_exists(handle:, controller_type:, controller_slot:, virtual_drive_name:, server_id: 1) ⇒ TrueClass, ...
Checks if a virtual drive by the specified name exists.
115 116 117 118 119 120 121 122 123 |
# File 'lib/ImcSdk/apis/server/storage.rb', line 115 def virtual_drive_exists(handle:, controller_type:, controller_slot:, virtual_drive_name:, server_id: 1) mo = vd_query_by_name(handle: handle, controller_type: controller_type, controller_slot: controller_slot, virtual_drive_name: virtual_drive_name, server_id: server_id) return !mo.nil?, mo end |