Top Level Namespace
Defined Under Namespace
Classes: ImcHandle
Constant Summary
- 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"
- COMM_EXT_DN =
"sys/svc-ext"
- NTP_DN =
"sys/svc-ext/ntp-svc"
- NTP_SERVER_LIST =
["ntp_server1", "ntp_server2", "ntp_server3", "ntp_server4"]
- 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
-
#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
Disables ldap certificate management.
-
#ldap_certificate_management_enable(handle:) ⇒ LdapCACertificateManagement
Enables ldap certificate management.
-
#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_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_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
#get_supported_models ⇒ Object
This api returns the list of rack server models that support power cap and power budgeting
29 30 31 |
# File '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 '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 '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 ValueError raise ValueError("#{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 '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 '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 '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 '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 '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 '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 '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 '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
Disables ldap certificate management
200 201 202 203 204 205 |
# File '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
Enables ldap certificate management
188 189 190 191 192 193 |
# File '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 '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 '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 '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 '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 '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 '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 '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
207 208 209 210 211 212 213 214 215 216 |
# File 'ImcSdk/apis/server/serveractions.rb', line 207 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
182 183 184 185 186 187 188 189 190 191 192 |
# File 'ImcSdk/apis/server/serveractions.rb', line 182 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 '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 '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 '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 '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 '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, nil 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 '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 '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
232 233 234 235 236 237 238 239 240 241 |
# File 'ImcSdk/apis/server/storage.rb', line 232 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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'ImcSdk/apis/server/storage.rb', line 64 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, 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 '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 '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_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 '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
246 247 248 249 250 251 252 |
# File 'ImcSdk/apis/server/serveractions.rb', line 246 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
228 229 230 231 232 233 234 |
# File 'ImcSdk/apis/server/serveractions.rb', line 228 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_query_by_name(handle:, controller_type:, controller_slot:, virtual_drive_name:, server_id: 1) ⇒ StorageVirtualDrive?
This method queries the virtual drive by name
30 31 32 33 34 35 36 37 38 39 40 |
# File 'ImcSdk/apis/server/storage.rb', line 30 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
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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'ImcSdk/apis/server/storage.rb', line 166 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
119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'ImcSdk/apis/server/storage.rb', line 119 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.
96 97 98 99 100 101 102 103 104 |
# File 'ImcSdk/apis/server/storage.rb', line 96 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 |