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

Instance Method Details

#boot_order_precision_exists(handle:, **kwargs) ⇒ FalseClass, ...

Check if boot order precision match

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • kwargs (Hash)

Returns:

  • (FalseClass, String, nil)

    if LsbootDevPrecision mo not found

  • (FalseClass, String, LsbootDevPrecision)

    if settings do not match

  • (TrueClass, nil, LsbootDevPrecision)

    if settings 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.

Examples:

boot_order_precision_set(handle: ImcHandle,
                        reboot_on_update: false,
                        reapply: false,
                        configured_boot_mode: "Uefi",
                        boot_devices: [{"order" => '1', "device-type" => "vmedia", "name" => "vmedia"},
                        {"order" => '2', "device-type" => "hdd", "name" => "hdd"}]

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • reboot_on_update (TrueClass, FalseClass) (defaults to: false)
  • reapply (TrueClass, FalseClass) (defaults to: false)
  • configured_boot_mode (String) (defaults to: "Legacy")

    Configured boot mode, ex. “Legacy”, “Uefi”, “None”

  • boot_devices (Array<Hash>) (defaults to: Array.new)

    format [=> ‘1’, “device-type” => “vmedia”, “name” => “vmedia”, => ‘2’, “device-type” => “hdd”, “name” => “hdd”] boot-order(string): Order boot-device-type(string): “hdd”, “iscsi”, “pchstorage”, “pxe”,

    "san", "sdcard", "uefishell", "usb",
    "vmedia"
    

    boot-device-name(string): Unique label for the boot device

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (LsBootDevPrecision)


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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (Array<Hash>)


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

Examples:

Turns on locator led on the server (for non-C3260 platforms)

get_locator_led_status(handle: ImcHandle)

Turns on locator led on the specified server (for C3260 platforms)

get_locator_led_status(handle: ImcHandle, :server_id => 1)

Turns on locator led on the chassis (for C3260 platforms)

get_locator_led_status(handle: ImcHandle, :chassis_id => 1)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • kwargs (Hash)

    key=>value paired arguments

Returns:

  • (string)

    status of locator led



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_modelsObject

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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms.

Returns:

  • (CommIpmiLan)


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.

Examples:

if ipmi_enable(handle) then puts "IPMI Enable" end

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • priv (String) (defaults to: CommIpmiLanConsts::PRIV_ADMIN)

    Optional privilege level: “admin”, “user”, or “read-only”

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (CommIpmiLan)

Raises:

  • (ValueError)

    if privilege or key is invalid



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (TrueClass, FalseClass)

    true if enable, else false



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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

Examples:

is_ldap_enabled(handle: handle)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

Returns:

  • (TrueClass, FalseClass)


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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

Returns:

  • (TrueClass, FalseClass)

    true if enabled, else false



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

Returns:

  • (TrueClass, FalseClass)

    true if strong password in 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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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

Examples:

kvm_setup(handle: ImcHandle,
               max_sessions: 4,
               port: 4000,
               encrypt: true,
               mirror_locally: false)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • max_sessions (Integer) (defaults to: 1)

    Max no. of sessions allowed (1-4)

  • port (Integer) (defaults to: 2068)

    Port used for kvm communication

  • encrypt (TrueClass, FalseClass) (defaults to: false)

    Encrypt video information sent over kvm

  • mirror_locally (TrueClass, FalseClass) (defaults to: false)

    Mirror the kvm session on local monitor

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (CommKvm)


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

Returns:

  • (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

Returns:

  • (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

Examples:

ldap_configure(handle: handle, enabled: true,
                    basedn: 'DC=LAB,DC=cisco,DC=com',
                    domain: 'LAB.cisco.com',
                    timeout: 20, group_auth: true,
                    bind_dn: 'CN=administrator,CN=Users,DC=LAB,DC=cisco,DC=com',
                    password: 'abcdefg', ldap_servers: ldap_servers)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • enabled (TrueClass, FalseClass) (defaults to: false)

    true to enable LDAP

  • basedn (String) (defaults to: nil)

    Represents the Base Distinguished Name. Describes where to load users and groups from. It must be in the ‘dc=domain,dc=com’ format for Active Directory servers.

  • domain (String) (defaults to: nil)

    The domain that all users must be in.

  • encryption (TrueClass, FalseClass) (defaults to: true)

    true to enable encryption

  • timeout (Integer) (defaults to: 60)

    The number of seconds the Cisco IMC waits until the LDAP search operation times out. Value must be between [0-180]

  • user_search_precedence (String) (defaults to: 'local-user-db')

    Preference to search in local user db versus ldap user db, valid values [‘local-user-db’, ‘ldap-user-db’]

  • bind_method (String) (defaults to: 'login-credentials')

    valid values [‘login-credentials’, ‘configured-credentials’, ‘anonymous’]

  • bind_dn (String) (defaults to: nil)

    Represents the distinguished name (DN) of the user. This field is applicable only for bind_method=‘configured-credentials’

  • password (String) (defaults to: nil)

    The password of the user. This field is applicable only for bind_method=‘configured-credentials’

  • filter (String) (defaults to: 'sAMAccountName')

    Represents the filter attribute in the schema on the LDAP server.

  • attribute (String) (defaults to: 'CiscoAvPair')

    Represents the role and locale information. Should match the attribute specified on the LDAP server.

  • group_attribute (String) (defaults to: 'memberOf')

    Represents the group attribute in the schema on the LDAP server.

  • group_nested_search (Integer) (defaults to: 128)

    Represents the depth of a nested group search

  • group_auth (TrueClass, FalseClass) (defaults to: false)

    Enables authentication at the group level for LDAP users that are not found in the local user database.

  • ldap_servers (Array) (defaults to: [])

    Represents the list of preconfigured LDAP server. List of Hash in the format:-

    [{:id => 1, :ip => "192.168.1.1", :port => 300},
     {:id => 2, :ip => "192.168.1.2", :port => 400}]
    
  • locate_directory_using_dns (TrueClass, FalseClass) (defaults to: false)
  • dns_domain_source (String) (defaults to: 'extracted-domain')

    Represents the method to obtain domain name

    ‘extracted-domain’, ‘configured-domain’, ‘extracted-configured-domain’
  • dns_search_domain (String) (defaults to: nil)

    Domain name to be used for DNS query. Disabled when domain_name_source=‘extracted-domain’

  • dns_search_forest (String) (defaults to: nil)

    Forest name to used for DNS query. Disabled when domain_name_source=‘extracted-domain’

  • kwargs (Hash)

    Key-Value paired arguments. Reserved for future use

Returns:

  • (AaaLdap)

Raises:

  • (ImcOperationError)

    when AaaLdap object doesn’t exist



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

Examples:

ldap_role_group_get(handle: handle, domain: 'abcd.pqrs.com', name: 'abcd')

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • domain (String)

    The LDAP server domain the group resides in.

  • name (String)

    The name of the group in the LDAP server database.

  • kwargs (Hash)

    Key-Value paired arguments for future use

Returns:

  • (AaaLdapRoleGroup)


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

Examples:

match, mo = ldap_settings_exist(
                     handle: handle, :enabled => true,
                     :basedn => 'DC=LAB,DC=cisco,DC=com',
                     :domain => 'LAB.cisco.com',
                     :timeout => 20, :group_auth => true,
                     :bind_dn => 'CN=administrator,CN=Users,DC=LAB,DC=cisco,DC=com',
                     :password => 'abcdefg', :ldap_servers=>ldap_servers)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • kwargs (Hash)

    Key-Value paired arguments

Returns:

  • (TrueClass, AaaLdap)

    if settings match

  • (FalseClass, nil)

    if settings doen’t match



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

Note:

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.

Examples:

1

local_user_exists(handle, name, pwd, priv)

2

local_user_exists(handle, name)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • name (String)

    username of the local user.

  • pwd (String)

    password for the local user.

  • priv (String) (defaults to: "read-only")

    Priviledge of the local user. Values could be “admin”, “read-only” or “user”.

Returns:

  • (AaaUser)

    AaaUser object corresponding to the user created.

Raises:

  • (Exception)

    if limit on the number of users has exceeded.



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • name (String)

    username of the local user to be deleted.

Returns:

  • (nil)

Raises:

  • (ImcOperationError)

    if the user is not found.



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

Examples:

local_user_exists(handle: handle, :user => "abc", :priv => "admin")

Parameters:

  • handle (ImcHandle) (defaults to: nil)

    ImcHandle class object.

  • kwargs (Hash)

    key-value paired arguments used for user attributes

Returns:

  • (TrueClass, AaaUser)

    if the user exists with the properties

  • (FalseClass, nil)

    if the user doen’t exist with the properties



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • name (String)

    username of the local user to be modified.

  • kwargs (Hash)

    key-value paired arguments

Returns:

  • (AaaUser)

    AaaUser object corresponding to the user modified.

Raises:

  • (Exception)

    When the user not found.



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

Examples:

Turns off locator led on the server (for non-C3260 platforms)

locator_led_off(handle: ImcHandle)

Turns off locator led on the specified server (for C3260 platforms)

locator_led_off(handle: ImcHandle, :server_id => 1)

Turns off locator led on the chassis (for C3260 platforms)

locator_led_off(handle: ImcHandle, :chassis_id => 1)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • kwargs (Hash)

    key=>value paired arguments

Returns:

  • (nil)


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

Examples:

Turns on locator led on the server (for non-C3260 platforms)

locator_led_on(handle: ImcHandle)

Turns on locator led on the specified server (for C3260 platforms)

locator_led_on(handle: ImcHandle, :server_id => 1)

Turns on locator led on the chassis (for C3260 platforms)

locator_led_on(handle: ImcHandle, :chassis_id => 1)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • kwargs (Hash)

    key=>value paired arguments

Returns:

  • (nil)


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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

Returns:

  • (CommNtpProvider)


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

Note:

Upto 4 ntp servers can be specified.

Enables NTP and configures the NTP servers provided

Examples:

ntp_enable(handle: handle,
            ntp_servers = [{:id => 1, :ip => "192.168.1.1"},
            {:id => 2, :ip => "192.168.1.2"}]

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • ntp_servers (Array) (defaults to: Array.new)

    List of dictionaries in the format [=> 1, :ip => “192.168.1.1”, => 2, :ip => “192.168.1.2”]

Returns:

  • (CommNtpProvider)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • ntp_servers (Array) (defaults to: Array.new)

    List of NTP servers in the format [“192.168.1.1”, “192.168.1.2”]

Returns:

  • (CommNtpProvider)


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

Note:

Upto 4 ntp servers can be specified.

Modifies the configured NTP servers

Examples:

ntp_servers_modify(handle: handle,
            ntp_servers = [{:id => 1, :ip => "192.168.1.1"},
            {:id => 2, :ip => "192.168.1.2"},
            {:id => 3, :ip => ""}]

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • ntp_servers (Array) (defaults to: Array.new)

    List of dictionaries in the format [=> 1, :ip => “192.168.1.1”, => 2, :ip => “192.168.1.2”]

Returns:

  • (CommNtpProvider)


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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • kwargs (Hash)

    key-value paired arguments

Returns:

  • (TrueClass, CommNtpProvider)

    if settings match

  • (FalseClass, CommNtpProvider)

    if settings don’t match



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • kwargs (Hash)

    key-value paired arguments

Returns:

  • (TrueClass, AaaUserPasswordExpiration)

    if policy exists.

  • (FalseClass, nil)

    if policy doesn’t exist.



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • password_expiry_duration (Integer)

    The time period after which the set password expires.

  • password_history (Integer) (defaults to: 0)

    Specifies in number of instances,

  • password_notification_period (Integer) (defaults to: 15)

    Specifies in number of days,

  • password_grace_period (Integer) (defaults to: 0)

    Specifies in number of days,

Returns:

  • (AaaUserPasswordExpiration)

    Modified AaaUserPasswordExpiration object.



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

Examples:

mo = physical_drive_get(handle: imcHandle, controller_type: 'SAS',
                        controller_slot: 'HBA',
                        drive_slot: 4)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • controller_type (String)

    Controller type ex. ‘SAS’

  • controller_slot (String)

    Controller slot name/number ex. “MEZZ”,“0”-“9”, “HBA”

  • drive_slot (Integer)

    Slot in which the drive resides

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (StorageLocalDisk)


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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

Examples:

server_power_cycle(handle: ImcHandle)
server_power_cycle(handle: ImcHandle, timeout: 120, interval: 10)
server_power_cycle(handle: ImcHandle, server_id: 2, timeout: 60)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • timeout (Integer) (defaults to: 120)

    timeout in seconds

  • interval (Integer) (defaults to: 5)
  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

  • kwargs (Hash)

    key=>value paired arguments

Returns:

  • (ComputeRackUnit)

    for non C3260 platforms

  • (ComputeServerNode)

    for C3260 platforms



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

Examples:

server_power_down(handle: ImcHandle)
server_power_down(handle: ImcHandle, timeout: 120, interval: 10)
server_power_down(handle: ImcHandle, server_id: 2, timeout: 60)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • timeout (Integer) (defaults to: 60)

    timeout in seconds

  • interval (Integer) (defaults to: 5)
  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

  • kwargs (Hash)

    key=>value paired arguments

Returns:

  • (ComputeRackUnit)

    for non C3260 platforms

  • (ComputeServerNode)

    for C3260 platforms



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

Examples:

server_power_down_gracefully(handle: ImcHandle)
server_power_down_gracefully(handle: ImcHandle, timeout: 120, interval: 10)
server_power_down_gracefully(handle: ImcHandle, server_id: 2, timeout: 60)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • timeout (Integer) (defaults to: 120)

    timeout in seconds

  • interval (Integer) (defaults to: 5)
  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

  • kwargs (Hash)

    key=>value paired arguments

Returns:

  • (ComputeRackUnit)

    for non C3260 platforms

  • (ComputeServerNode)

    for C3260 platforms



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

Note:

If server_id is not specified, this will assume server_id=“1”

This method will return the oper power status of the rack server

Examples:

For classic or non-C3260 series servers:-
server_power_state_get(handle)
For modular or C3260 series servers, server_id should also be passed in the params:-
server_power_state_get(handle: handle, server_id: 1)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (String)

    Oper Power state

Raises:

  • (ImcOperationError)


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.

Examples:

server_power_up(handle: ImcHandle)
server_power_up(handle: ImcHandle, timeout: 120, interval: 10)
server_power_up(handle: ImcHandle, server_id: 2, timeout: 60)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • timeout (Integer) (defaults to: 60)

    timeout in seconds

  • interval (Integer) (defaults to: 5)
  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

  • kwargs (Hash)

    key=>value paired arguments

Returns:

  • (ComputeRackUnit)

    for non C3260 platforms

  • (ComputeServerNode)

    for C3260 platforms



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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

Examples:

server_standard_power_cap_set(handle,
                            correction_time: 5,
                            corrective_action: "alert")
server_standard_power_cap_set(handle, throttle: true,
                            power_limit: 200, correction_time: 5,
                            corrective_action: "alert, shutdown")

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • throttle (TrueClass, FalseClass) (defaults to: false)

    Power limit in Watts. Range can be retrieved from min_power and max_power fields of PowerBudget object

  • correction_time (Integer) (defaults to: 3)

    Time in seconds before power_limit is enforced and corrective action is taken. Range (1-600)s

  • corrective_action (String) (defaults to: "alert")

    valid values [“none”,“alert”,“shutdown”,“alert,shutdown”]

  • hard_cap (TrueClass, FalseClass) (defaults to: false)

    Enable hard power cap

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (StandardPowerProfile)



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • controller_type (String)

    Controller type ex. ‘SAS’

  • controller_slot (String)

    Controller slot name/number ex. “MEZZ”,“0”-“9”, “HBA”

  • virtual_drive_name (String) (defaults to: nil)

    Name of the virtual drive

  • raid_level (Integer) (defaults to: nil)

    raid level ex. 0, 1, 5, 6, 10, 50, 60 Raid 0 Simple striping. Raid 1 Simple mirroring. Raid 5 Striping with parity. Raid 6 Striping with two parity drives. Raid 10 Spanned mirroring. Raid 50 Spanned striping with parity. Raid 60 Spanned striping with two parity drives.

  • drive_group (Array<Array>) (defaults to: nil)

    list of drives

    [1]
    [1,2]
    [1,2],
  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • enable (TrueClass, FalseClass) (defaults to: false)

    setting to true will enable strong password.

Returns:

  • (AaaUserPolicy)

    modified AaaUserPolicy object.



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer) (defaults to: 1)

    ServerId to be specified for C3260 platforms

  • kwargs (Hash)

    key-value paired arguments.

Returns:

  • (TrueClass, SolIf)

    if settings match

  • (FalseClass, SolIf)

    if settings don’t match



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • speed (String)

    valid values - “9600”, “19200”, “38400”, “57600”, “115200”

  • comport (Strong)

    valid values :- “com0”, “com1”

  • ssh_port (Integer) (defaults to: nil)

    port for ssh

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (SolIf)


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

Examples:

tag_chassis(handle: ImcHandle, tag: "Row21-Rack10-Slot10")

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • tag (String)

    Label to be used to tag the asset

Returns:

  • (EquipmentChassis)


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

Examples:

tag_server(handle: ImcHandle, tag: "Row21-Rack10-Slot10")

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • tag (String)

    Label to be used to tag the asset

Returns:

  • (ComputeRackUnit)


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

Returns:

  • (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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • controller_type (String)

    Controller type ex. ‘SAS’

  • controller_slot (String)

    Controller slot name/number ex. “MEZZ”,“0”-“9”, “HBA”

  • virtual_drive_name (String)

    Name of the virtual drive

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (StorageVirtualDrive)

    if virtual drive found.

  • (nil)

    if virtual drive not found.



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

Examples:

virtual_drive_create(handle: imcHandle,
                    drive_group: [[2]],
                    controller_slot: 'MEZZ')

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • drive_group (Array<Array>)

    list of drives

    [1]
    [1,2]
    [1,2],
  • controller_type (String)

    Controller type ex. ‘SAS’

  • controller_slot (String)

    Controller slot name/number ex. “MEZZ”,“0”-“9”, “HBA”

  • virtual_drive_name (String) (defaults to: nil)

    Name of the virtual drive

  • raid_level (Integer) (defaults to: 0)

    raid level ex. 0, 1, 5, 6, 10, 50, 60 Raid 0 Simple striping. Raid 1 Simple mirroring. Raid 5 Striping with parity. Raid 6 Striping with two parity drives. Raid 10 Spanned mirroring. Raid 50 Spanned striping with parity. Raid 60 Spanned striping with two parity drives.

  • access_policy (String) (defaults to: "read-write")

    Access-policy for the virtual drive, ex. [‘read-write’, ‘read-only’, ‘hidden’, ‘default’, ‘blocked’]

  • read_policy (String) (defaults to: "no-read-ahead")
  • disk_cache_policy (String) (defaults to: "unchanged")
  • write_policy (String) (defaults to: "Write Through")
  • strip_size (String) (defaults to: "64k")
  • size (defaults to: nil)
  • self_encrypt (TrueClass, FalseClass) (defaults to: false)

    encrypt the virtual drive if the underlying controller and physical drive support it

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (StorageVirtualDrive)


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

Examples:

virtual_drive_delete(handle: imc,
                     controller_slot: 'MEZZ',
                     virtual_drive_name: "RAID0_1")

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • controller_type (String)

    Controller type ex. ‘SAS’

  • controller_slot (String)

    Controller slot name/number ex. “MEZZ”,“0”-“9”, “HBA”

  • virtual_drive_name (String)

    Name of the virtual drive

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms



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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • controller_type (String)

    Controller type ex. ‘SAS’

  • controller_slot (String)

    Controller slot name/number ex. “MEZZ”,“0”-“9”, “HBA”

  • virtual_drive_name (String)

    Name of the virtual drive

  • server_id (Integer) (defaults to: 1)

    Server Id to be specified for C3260 platforms

Returns:

  • (TrueClass, StorageVirtualDrive)

    if virtual drive exists.

  • (FalseClass, nil)

    if virtual drive doesn’t exist.



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