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

Instance Method Details

#get_supported_modelsObject

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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer)

    Server Id to be specified for C3260 platforms.

Returns:

  • (CommIpmiLan)


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.

Examples:

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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • priv (String)

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

  • server_id (Integer)

    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 '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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (TrueClass, FalseClass)

    true if enable, else false



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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

Examples:

is_ldap_enabled(handle: handle)

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

Returns:

  • (TrueClass, FalseClass)


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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

Returns:

  • (TrueClass, FalseClass)

    true if enabled, else false



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

Returns:

  • (TrueClass, FalseClass)

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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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

Examples:

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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • max_sessions (Integer)

    Max no. of sessions allowed (1-4)

  • port (Integer)

    Port used for kvm communication

  • encrypt (TrueClass, FalseClass)

    Encrypt video information sent over kvm

  • mirror_locally (TrueClass, FalseClass)

    Mirror the kvm session on local monitor

  • server_id (Integer)

    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 '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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

Returns:

  • (LdapCACertificateManagement)


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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

Returns:

  • (LdapCACertificateManagement)


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

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)

    true to enable LDAP

  • basedn (String)

    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)

    The domain that all users must be in.

  • encryption (TrueClass, FalseClass)

    true to enable encryption

  • timeout (Integer)

    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)

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

  • bind_method (String)

    valid values ['login-credentials', 'configured-credentials', 'anonymous']

  • bind_dn (String)

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

  • password (String)

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

  • filter (String)

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

  • attribute (String)

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

  • group_attribute (String)

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

  • group_nested_search (Integer)

    Represents the depth of a nested group search

  • group_auth (TrueClass, FalseClass)

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

  • ldap_servers (Array)

    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)
  • dns_domain_source (String)

    Represents the method to obtain domain name

    'extracted-domain', 'configured-domain', 'extracted-configured-domain'
  • dns_search_domain (String)

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

  • dns_search_forest (String)

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

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

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


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

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)


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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

Returns:

  • (CommNtpProvider)


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

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)

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

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

    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 '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, nil)

    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 '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

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

    Specifies in number of instances,

  • password_notification_period (Integer)

    Specifies in number of days,

  • password_grace_period (Integer)

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

    Server Id to be specified for C3260 platforms

Returns:

  • (StorageLocalDisk)


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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer)

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

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (PowerBudget)


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.

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)

    timeout in seconds

  • interval (Integer)
  • server_id (Integer)

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

    timeout in seconds

  • interval (Integer)
  • server_id (Integer)

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

    timeout in seconds

  • interval (Integer)
  • server_id (Integer)

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

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

    timeout in seconds

  • interval (Integer)
  • server_id (Integer)

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

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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

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)

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

  • correction_time (Integer)

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

  • corrective_action (String)

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

  • hard_cap (TrueClass, FalseClass)

    Enable hard power cap

  • server_id (Integer)

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

    Name of the virtual drive

  • raid_level (Integer)

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

    list of drives

    [1]
    [1,2]
    [1,2],
  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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.

Parameters:

  • handle (ImcHandle)

    ImcHandle class object.

  • enable (TrueClass, FalseClass)

    setting to true will enable strong password.

Returns:

  • (AaaUserPolicy)

    modified AaaUserPolicy object.



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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (nil)


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

Parameters:

  • handle (ImcHandle)

    ImcHandle class object

  • speed (String)

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

  • comport (Strong)

    valid values :- “com0”, “com1”

  • ssh_port (Integer)

    port for ssh

  • server_id (Integer)

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


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

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)


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

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)

    Server Id to be specified for C3260 platforms

Returns:

  • (StorageVirtualDrive)

    if virtual drive found.

  • (nil)

    if virtual drive not found.



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

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)

    Name of the virtual drive

  • raid_level (Integer)

    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)

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

  • read_policy (String)
  • disk_cache_policy (String)
  • write_policy (String)
  • strip_size (String)
  • size
  • self_encrypt (TrueClass, FalseClass)

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

  • server_id (Integer)

    Server Id to be specified for C3260 platforms

Returns:

  • (StorageVirtualDrive)


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

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)

    Server Id to be specified for C3260 platforms



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.

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)

    Server Id to be specified for C3260 platforms

Returns:

  • (TrueClass, StorageVirtualDrive)

    if virtual drive exists.

  • (FalseClass, nil)

    if virtual drive doesn't exist.



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