ciscoucs / imcsdk Goto Github PK
View Code? Open in Web Editor NEWPython SDK for Cisco IMC
License: Other
Python SDK for Cisco IMC
License: Other
Python version: 2.7.12
IMC version: 2.0(13e)
Observation:
When trying to validate settings of LDAP by doing get operation after setting one of the parameter "group_nested_search" to some value say '128', it fails because the value of this param shows 'None' and other param [x]groupNestedSearch shows value as '128.
The following code was executed -
mo.admin_state = 'enabled'
mo.attribute = 'CiscoAvPair'
mo.bind_dn = 'DC=a,DC=b,DC=c'
mo.bind_method = 'login-credentials'
mo.encryption = 'enabled'
mo.filter = 'sAMAccountName'
mo.group_attribute = 'memberOf'
mo.group_auth = 'enabled'
mo.group_nested_search = '128'
mo.ldap_server1 = '10.10.10.10'
mo.ldap_server_port1 = '3268'
mo.locate_directory_using_dns = 'no'
mo.timeout = '60'
handle.set_mo(mo)
After doing get operation, the output is -
admin_state :enabled
attribute :CiscoAvPair
basedn :
bind_dn :DC=a,DC=b,DC=c
bind_method :login-credentials
dn :sys/ldap-ext
dns_domain_source :extracted-domain
dns_search_domain :
dns_search_forest :
domain :
encryption :enabled
filter :sAMAccountName
[X]groupNestedSearch :128
group_attribute :memberOf
group_auth :enabled
group_nested_search :None
ldap_server1 :10.10.10.10
ldap_server2 :
ldap_server3 :
ldap_server4 :
ldap_server5 :
ldap_server6 :
ldap_server_port1 :3268
ldap_server_port2 :389
ldap_server_port3 :389
ldap_server_port4 :3268
ldap_server_port5 :3268
ldap_server_port6 :3268
locate_directory_using_dns :no
password :
rn :ldap-ext
status :None
timeout :60
Hi.
We've upgraded our firmware to 3.0(3a) to take advantage of new features, but now cannot connect to the CIMC using the IMCSDK library.
I've noticed that the documentation here: http://imcsdk.readthedocs.io/en/latest/history.html says it supports 3.0(1c). Do you have a plan for supporting 3.0(3a)? How can I help fix this?
I'm calling handle.login() and I get the following response immediately.
My code essentially does this:
49 self.handle = ImcHandle(hostname, username, password)
50 self.handle.login()
and here's the traceback...
Here's the traceback:
Traceback (most recent call last):
File "./my_code.py", line 50, in __init__
self.handle.login()
File "/usr/local/lib/python2.7/dist-packages/imcsdk/imchandle.py", line 94, in login
return self._login(auto_refresh, force, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/imcsdk/imcsession.py", line 571, in _login
response = self.post_elem(elem, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/imcsdk/imcsession.py", line 275, in post_elem
response_str = self.post_xml(xml_str, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/imcsdk/imcsession.py", line 226, in post_xml
response_str = self.post(uri=imc_uri, data=xml_str, read=read, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/imcsdk/imcsession.py", line 206, in post
response = self.__driver.post(uri=uri, data=data, read=read, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/imcsdk/imcdriver.py", line 264, in post
response = opener.open(request, timeout=timeout)
File "/usr/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.7/dist-packages/imcsdk/imcdriver.py", line 95, in https_open
return self.do_open(TLSConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 104] Connection reset by peer>
My system:
$ uname -a
Linux myserver 3.16.0-30-generic #40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ python --version
Python 2.7.6
$ pip freeze | grep imc
imcsdk==0.9.2.0
imcsdk/imcsdk/apis/server/boot.py
Line 208 in 8cb4439
When trying to call boot_order_precision_set from imcsdk.apis.server.boot recieve an error:
[ErrorCode]: ERR-xml-parse-error[ErrorDescription]: XML PARSING ERROR: Element 'lsbootVMedia', attribute 'state': [facet 'enumeration'] The value 'enabled' is not an element of the set {'Disabled', 'Enabled'}. Element 'lsbootVMedia', attribute 'state': 'enabled' is not a valid value of the local atomic type.
Code: Latest from github
Python version: 2.7.12
OS: Windows 10
Execute the below code:
kvm_enable(handle=handle)
Observation:
ImcException: [ErrorCode]: ERR-xml-parse-error[ErrorDescription]: XML PARSING ERROR: Element 'commKvm', attribute 'port': 'None' is not a valid value of the local atomic type. Element 'commKvm', attribute 'totalSessions': 'None' is not a valid value of the local atomic type.
Currently we don't have any option to download the tech support files locally. It would be awesome if "get_imc_tech_support" function allows us to download the techsupport files to local system as similar to "get_tech_support" function in https://github.com/CiscoUcs/ucsmsdk/blob/974e231af0fb50138648dd3d575f04373e5a0fef/ucsmsdk/utils/ucstechsupport.py
Code: Latest from github
Python version: 2.7.12
OS: Windows 10
Description:
When trying to map vmedia using a url, it throws type error.
Execute below code:
vmedia_mount_iso_uri(handle=handle, uri=uri+remote_file, user_id=username, password=password)
Observation:
Got the below error -
TypeError: vmedia_mount_create() got an unexpected keyword argument 'mount_protocol'
In vmedia.py line 310, instead of mount_protocol
it should be map
Need to be able to handle mr, patch versions in a more robust manner.
Using ImcSdk 0.7.2
when function remove_imc_managedobject() called with input either in_mo or class_id and params={"Dn": "'sys/rack-unit-1/boot-policy/vm-read-only'", "Access": 'read-only'}
It fails to remove with error:
ImcException: [ErrorCode]: ERR-xml-parse-error [ErrorDescription]: XML PARSING ERROR: Element 'lsbootVirtualMedia': The attribute 'access' is required but missing.
The function remove_imc_managedobject takes only 2 attributes 'Dn' as 'Key' and 'class_id'
please do needful and make available the updated version.
Hi Fellow Travellers,
I'm seeing the following issue when using a recent git clone of the imcsdk (post 0.9.3 to get the python 3 vmedia fixes circa 27th Feb 2018).
Whenever I try to delete vmedia I get:
"imcsdk.imcexception.ImcException: [ErrorCode]: ERR-xml-parse-error[ErrorDescription]: XML PARSING ERROR: Element 'commSavedVMediaMap': The attribute 'adminAction' is required but missing."
Obviously something has gone wrong in the mapping of Managed Objects to XML.
This is when I call vmedia.vmedia_mount_remove_all(handle) or vmedia.vmedia_mount_delete(handle, volume_name) any thoughts?
Here's a snippet of the code I'm using under python 3.6.2 MacOS High Sierra against a stand alone c240m5:
def vmedia_boot():
volume_name="myVmedia"
with ImcHandle(server, username, password) as handle:
try:
vmedia.vmedia_mount_remove_all(handle)
except ImcException as error:
print(f"Error: {error}") // This is where we get the error.
try:
vmedia.vmedia_mount_create(
handle,
volume_name,
map="www",
mount_options="",
remote_share='http://10.199.133.8:8888/images/CentOS-7-x86_64-LiveGNOME-1708/',
remote_file='CentOS-7-x86_64-LiveGNOME-1708.iso',
)
except ImcException as error:
print(f"Error: {error}")
comm_vmedia = vmedia.vmedia_enable(handle)
result = boot.boot_order_precision_set(
handle,
reboot_on_update="yes",
reapply="no",
#configured_boot_mode="Uefi",
boot_devices = [
{
"order":'1', "device-type":"vmedia",
"name": "vmedia"
}
]
)
return result
Any help hugely appreciated.
Cheers,
Dug
Code: Latest from github
Python version: 2.7.12
OS: Windows 10
Execute the below code:
obj = boot_order_precision_set(handle=handle,
configured_boot_mode='Legacy',
boot_devices=[
{'order':'1', 'device-type':'usb', 'name':'usb'},
{'order':'2', 'device-type':'san', 'name':'san'}
],
reboot_on_update=True,
reapply=True,
server_id=1)
print obj[0]
The output is -
Managed Object : LsbootDevPrecision
--------------
child_action :None
configured_boot_mode :Legacy
dn :sys/chassis-1/server-1/boot-precision
last_configured_boot_order_source:CIMC
name :boot-precision
purpose :operational
reapply :no
reboot_on_update :no
rn :boot-precision
status :None
Even if the values of reboot_on_update
and reapply
are set to True
, the output of the set mo shows both values as no
.
Following command is working with python 2.7 by returning TypeError with Python 3.6: Storage.virtual_drive_create(handle=handle,drive_group=[[1,2]],raid_level=1,controller_type="SAS",controller_slot="MRAID")
TypeError: unsupported operand type(s) for >>: 'float' and 'int'
It works if I leave the raid_level blank or set to 0
Execute the following code for firmware update -
update_imc_firmware_huu(handle=handle,
remote_ip=ip,
remote_share='nfs/sharepath/filename.iso',
share_type='nfs',
username=username,
password=password,
update_component='all')
The script throws 'invalid value exception' for stop_on_error, verify_update, cimc_secure_boot and timeout parameter which should not be passed as 'None' by default.
Code: Latest from github
Python version: 2.7.12
OS: Windows 10
Execute the below code:
sol_enable(handle=handle, speed='9600', comport='com1', ssh_port=1500, server_id=1)
Now check that values exists -
obj = sol_exists(handle=handle, speed='9600', comport='com1', ssh_port=1500)
print obj
Observation:
sol_exists
returns (False,None)
even if the values exists
ImcDriver.post() method is responsible for posting requests to the server.
Need to add timeout as a configurable option to make sure that requests timeout.
Currently, the timeout will not happen as urllib2.open calls take socket._GLOBAL_DEFAULT_TIMEOUT which is set to None.
Python version: 2.7.12
IMC models: classic / modular
Firmware: 2.0(13e)
Description:
When running backup_imc without 'entity' param on modular server, the script throws following error -
ERR-xml-parse-error[ErrorDescription]: XML PARSING ERROR: Element 'mgmtBackup': The attribute 'entity' is required but missing.
Expected:
The 'entity' param should be made mandatory so that it works both with classic and modular.
I recently attempted to add auto_refresh to imcsdk sessions and when doing so I started to see random "Authorization required" errors.
It appears that there is no locking or other concurrency protection on the cookie so it is possible for the auto refresh to take place, refresh the cookie but other consumers of the cookie may not have the updated one resulting in authorization required errors.
Seems like there needs to be some locking mechanism on the cookie so when auto_refresh starts it can lock the cookie and prevent others from using it until the auto refresh is complete or conversely if the main thread for the session is in the middle of a transaction the auto refresh has to wait for the transaction to be complete before it can do the refresh.
A common use case for vmedia is to mount an ISO from a URI. It would be handy to have a function that a user could pass a URI, and the function would break it down and dynamically determine the protocol,etc and make the correct call to vmedia_mount_add.
When running apis.server.remotepresence.vmedia_mount_remove_all, it tries to remove all the vmedia maps that it finds on the box. With the 3.0 firmware, the user is now able to 'save' unmapped vmedia for re-use later. When vmedia_mount_remove_all encounters one of these, it throws the following exception:
ImcException: [ErrorCode]: ERR-xml-parse-error[ErrorDescription]: XML PARSING ERROR: Element 'commSavedVMediaMap': The attribute 'adminAction' is required but missing.
Saved maps do no interfere with existing maps, so we should just skip over them if they are encountered.
If a server is not cleaned up properly between uses, there can exist leftover virtual media mounts. The current user has no knowledge of these mounts, and so they cannot delete them by volume name. So this function is added to allow a user to clean out all mounts to have a clean slate before adding new mounts.
Code: Latest from github
Python version: 2.7.12
OS: Windows 10
Execute the below code:
boot_order_precision_get(handle=handle, dump=True, server_id=1)
Observation:
Traceback (most recent call last):
File "c:\python27\lib\site-packages\nose\case.py", line 197, in runTest
self.test(*self.arg)
File "C:\Tanmay\PythonSDK\pysdkframework\TestSuite_ClassicImc\Nosetests\server\test_boot_order.py", line 39, in test_boot_order_precision_get_case2
server_id=1)
File "c:\python27\lib\site-packages\imcsdk-0.9.2.0-py2.7.egg\imcsdk\apis\server\boot.py", line 64, in boot_order_precision_get
device["device-type"].ljust(10),
AttributeError: 'NoneType' object has no attribute 'ljust'
-------------------- >> begin captured logging << --------------------
imc: INFO: Precision Boot Order is [Order, Type, Name]:
imc: INFO: --------------------------------------------
imc: INFO: 1 PXE pxe2
--------------------- >> end captured logging << ---------------------
Issue happens only on M5 servers if dump=True
When logging into server:
handle = ImcHandle(server, attrs["user"], attrs["password"]
The output is as follows:
handle.login()
File "/usr/local/lib/python2.7/site-packages/imcsdk/imchandle.py", line 143, in login
return self._login(auto_refresh=auto_refresh, force=force, timeout=timeout)
File "/usr/local/lib/python2.7/site-packages/imcsdk/imcsession.py", line 591, in _login
self._update_version(response)
File "/usr/local/lib/python2.7/site-packages/imcsdk/imcsession.py", line 540, in _update_version
firmware = response.out_config.child[0]
IndexError: list index out of range
Is this because this firmware isn't supported? This server is running C220M3.1.5.1c.0 (Build Date: 01/31/2013) so I can see that it is old. Where does it state which versions of BIOS are supported by IMCSDK? Thanks!
Add support for C3x60 servers
Typically the update_imc_firmware_huu
utility is used to upgrade all components on the rack server.
In order to update a single component, the update_component
field needs to be set appropriately.
The list of strings for the valid components are not present in the mometa and needs to be extracted from the huu iso.
Unbundle the huu iso and extract TOC.xml
from it.
Parse this to extract the list of available strings for specific components.
If you try to build the package ('python setup.py build') without having setuptools installed then it doesn't include all the files in the built package. The subdirectories e.g. mometa/ are all missing.
Code: Latest
Python version: 2.7.12
OS Version: Win 10
Description:
When try to create virtual drives in server having disks of different size, it throws error.
Execute the below code -
virtual_drive_create(handle=handle,
drive_group=[[1,2]],
controller_slot=str(controller[handle.ip][component][0]['pci_slot']),
controller_type=str(controller[handle.ip][component][0]['type']),
raid_level=1,
virtual_drive_name='test-raid-1',
access_policy='read-only',
read_policy='no-read-ahead',
cache_policy='cached-io',
disk_cache_policy='enabled',
write_policy='Write Through',
strip_size='64k')
Observed below error -
ImcException
------------
[Error Code]: 2003 [Error Description]: Operation failed. Input parameters are invalid
The issue seems in the logic of calculating the RAID size.
Example:
>>> bios_tokens_set(handle, tokens = {"abc": "platform_default"}, server_id=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "imcsdk/apis/server/bios.py", line 349, in bios_tokens_set
mo_table = _get_bios_mo_table(handle, tokens, server_id)
File "imcsdk/apis/server/bios.py", line 412, in _get_bios_mo_table
log.warning("Token not found: %s Platform: %s" % token,
TypeError: not enough arguments for format string
>>>```
This log warning is formatted wrong, it needs another set of parenthesis:
log.warning("Token not found: %s Platform: %s" % (token,
handle.platform))
The power up/down functions in imcsdk/apis/server/serveractions return after sending the the signal to the UCS. However, it takes a few seconds for the server to actually change its power state. So I'd like to add logic to those functions to poll the server and return after the desired power state has happened.
From init of the ManagedObject class:
if kwargs:
for prop_name, prop_value in imcgenutils.iteritems(kwargs):
if not imccoreutils.prop_exists(self, prop_name):
log.debug("Unknown property %s" % prop_name)
self.__set_prop(prop_name, prop_value)
If the prop does not exist a log message is printed but the property is still attempted to be set which causes a failure later in __set_prop
where prop.access results in an AttributeError:
if not forced:
prop = imccoreutils.get_prop_meta(self, name)
if not imccoreutils.is_writable_prop(self, name):
if getattr(self, name) is not None or \
prop.access != \
imccoremeta.MoPropertyMeta.CREATE_ONLY:
raise ValueError("%s is not a read-write property." % name)
Here is the traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "imcsdk/mometa/bios/BiosVfPackageCStateLimit.py", line 81, in __init__
ManagedObject.__init__(self, "BiosVfPackageCStateLimit", parent_mo_or_dn, **kwargs)
File "imcsdk/imcmo.py", line 99, in __init__
self.__set_prop(prop_name, prop_value)
File "imcsdk/imcmo.py", line 186, in __set_prop
prop.access != \
AttributeError: 'NoneType' object has no attribute 'access'
get_imc_tech_support does not show any progress bar while downloading. It is good to have visual progress shown to the user.
When trying backup_imc with protocol="none", the script throws following error -
[ErrorCode]: ERR-xml-parse-error[ErrorDescription]: XML PARSING ERROR: Element 'mgmtBackup', attribute 'proto': [facet 'enumeration'] The value 'none' is not an element of the set {'ftp', 'tftp', 'sftp', 'scp', 'http'}. Element 'mgmtBackup', attribute 'proto': 'none' is not a valid value of the local atomic type.
Checked with IMC firmware 2.0(8d) and 2.0(9e)
Python version: 2.7.12
IMC models: classic/modular
IMC firmware: 2.0(13e)
Description:
After running the following code, the tech support file gets generated but also an extra file with '.done' extension gets created -
get_imc_tech_support(handle=handle, remote_host=remote_host_ip, remote_file='/remote_path/filename.tar.gz', protocol='scp', username=username, password=password, component='all')
Observation:
apart from filename.tar.gz, extra file 'filename.tar.gz.done' also gets created.
Expected:
Only 'filename.tar.gz' should be created.
I'm getting:
File "/usr/lib/python3.6/site-packages/imcsdk/apis/server/storage.py", line 272, in virtual_drive_create
server_id=server_id),
File "/usr/lib/python3.6/site-packages/imcsdk/apis/server/storage.py", line 173, in _vd_max_size_get
return _bytes_to_human(max_size, output_format="MB")
File "/usr/lib/python3.6/site-packages/imcsdk/apis/server/storage.py", line 101, in _bytes_to_human
return str(size >> (10 * convert[output_format])) + ' ' + output_format
TypeError: unsupported operand type(s) for >>: 'float' and 'int'
When I try to make a RAID1 for two identical physical drives or RAID10 with 4 or 8 physical drives. RAID0 is the only level that works, and only for 1 physical drive right now.
Physical drive list for RAID1 is [[1, 2]]
.
Any ideas of how I can fix this?
EDIT: Pretty sure this is the result of Python3 handling division differently than Python2.
https://github.com/CiscoUcs/imcsdk/blob/master/imcsdk/apis/server/storage.py#L98
https://stackoverflow.com/questions/19981643/typeerror-for-on-float-and-int
Execute the following to upload certificate -
upload_cert = UploadCertificate(parent_mo_or_dn="sys/cert-mgmt",
admin_action='remote-cert-upload',
user=username,
pwd=password,
protocol='scp',
remote_server=ip,
remote_file='/path/to/file.crt'
)
handle.add_mo(upload_cert,modify_present=True)
Since this activity terminates the xml-api connection in the background, if the user tries to logout after this, the script throws the error.
To avoid the error, create a login handle with auto_refresh=True
On downgrade it appears that the admin password is reset to the default password for CIMC.
firmware_huu_update_monitor monitors an upgrade and prints status of it. After CIMC comes up on the now downgraded version, the admin password is no longer the one used to do the upgrade and firmware_huu_update_monitor reports that it failed to login to CIMC.
2019-04-19 22:14:42,063 Login to IMC, elapsed time 69s
2019-04-19 22:14:45,069 - imc - DEBUG - Login failed. Sleeping for 60 seconds
2019-04-19 22:14:45,069 Login failed. Sleeping for 60 seconds
2019-04-19 22:14:49,912 - imc - DEBUG - Login to IMC failed: [ErrorCode]: 551[ErrorDescription]: Authentication failed
2019-04-19 22:14:49,912 Login to IMC failed: [ErrorCode]: 551[ErrorDescription]: Authentication failed
This should be handled in a way that imcsdk can finish the upgrade and maybe reset the admin password to what it is expected to be.
When utilizing the imcsdk.apis.server.remotepresence.vmedia_mount_add, the following error is thrown:
In [10]: vmedia_mount_add(tooth_build,
...: volume_name='buildnode-iso.5478.2.iso',
...: device_type='cd',
...: mount_protocol='www',
...: mount_options=None,
...: remote_share='http://cloud-ci.cisco.com/job/mercury-bu
...: ild/job/build-iso-artifact-private/lastSuccessfulBuild/artifact/',
...: remote_file='buildnode-iso.5478.2.iso',
...: user_id=None,
...: password=None)
...:
...:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-10-f389d0c49d84> in <module>()
7 remote_file='buildnode-iso.5478.2.iso',
8 user_id=None,
----> 9 password=None)
10
/Users/bhouser/Development/github/britthouser/imcsdk/imcsdk/apis/server/remotepresence.py in vmedia_mount_add(handle, volume_name, device_type, mount_protocol, mount_options, remote_share, remote_file, user_id, password)
170 parent_mo_or_dn="sys/svc-ext/vmedia-svc",
171 volume_name=volume_name)
--> 172 vmediamap_mo.drive_type = device_type
173 vmediamap_mo.map = mount_protocol
174 vmediamap_mo.mount_options = mount_options
/Users/bhouser/Development/github/britthouser/imcsdk/imcsdk/imcmo.py in __setattr__(self, name, value)
133 if "prop_meta" in dir(self) and name in self.prop_meta:
134 if name in dir(self):
--> 135 self.__set_prop(name, value)
136 else:
137 if value:
/Users/bhouser/Development/github/britthouser/imcsdk/imcsdk/imcmo.py in __set_prop(self, name, value, mark_dirty, forced)
178 prop_meta.access != \
179 imccoremeta.MoPropertyMeta.CREATE_ONLY:
--> 180 raise ValueError("%s is not a read-write property." % name)
181 if not prop_meta.validate_property_value(value):
182 raise ValueError("Invalid Value Exception - "
ValueError: drive_type is not a read-write property.
In [11]:
When trying to create a tech support using "get_imc_tech_support", it throws an exception -
[ErrorCode]: ERR-xml-parse-error[ErrorDescription]: XML PARSING ERROR: Element 'sysdebugTechSupportExport', attribute 'adminState': [facet 'enumeration'] The value 'Enabled' is not an element of the set {'enabled', 'disabled'}. Element 'sysdebugTechSupportExport', attribute 'adminState': 'Enabled' is not a valid value of the atomic type 'enabledDisabled'
The issue seems to be in imtechsupport.py file at line 70. Here the value of "admin_state" should be "enabled" and not "Enabled"
When try to run backup_imc without 'passphrase' parameter, the script comes out without throwing any exception.
For IMC firmware 2.0(1a) and above, 'passphrase' is a mandatory parameter and hence it should throw an exception.
(I specifically need to set "PCI Order".)
Powering a server on/off is quicker via IPMI than via XMLAPI, which is an issue for some operators. So it would be handy to provide a function to enable/disable IPMI in a simple manner from XML, after which operator can use IPMI for power.
When polling boot_order_precision_get I always get a debug like this:
2019-02-26 21:55:47,984 - imc - DEBUG - sorted_boot_order_list:
[{'device-type': 'EFI', 'order': '1', 'name': 'EFIShell'}, {'device-type': 'HDD', 'order': '2', 'name': 'LocalDrive'}, {'device-type': 'PXE', 'order': '3', 'name': 'PxeLom0'}, {'device-type': 'PXE', 'order': '4', 'name': 'PxeVic1'}, {'device-type': 'PXE', 'order': '5', 'name': 'PxeVic1'}, {'device-type': 'PXE', 'order': '6', 'name': 'PxeVic2'}, {'device-type': 'PXE', 'order': '7', 'name': 'PxeVic2'}, {'device-type': 'PXE', 'order': '8', 'name': 'NonPolicyTarget'}]
SDK version: Latest from git
Python version: 2.7.12
IMC version: 3.0(1c)
Execute the following code snippet -
from imcsdk.apis.admin.snmp import *
from imcsdk.imchandle import ImcHandle
handle = ImcHandle(ip=ip, username=username, password=password)
handle.login()
snmp_user_add(handle=handle, name='klm', security_level='authnopriv', auth='MD5', auth_pwd='pass')
handle.logout()
Observation -
After executing the above code snippet, it throws following error -
_Traceback (most recent call last):_
_File "c:\python27\lib\site-packages\nose\case.py", line 197, in runTest_
_self.test(*self.arg)_
_File "C:\Tanmay\PythonSDK\pysdkframework\TestSuite_ClassicImc\Nosetests\test_snmp.py", line 37, in_ _test_snmp_user_add_
_snmp_user_add(handle=handle, name='klm', security_level='authnopriv', auth='MD5',_ _auth_pwd='Nbv12345')_
_File "c:\python27\lib\site-packages\imcsdk-0.9.1.0-py2.7.egg\imcsdk\apis\admin\snmp.py", line 362, in_ _snmp_user_add_
_free_user.privacy_pwd = priv_pwd_
_File "c:\python27\lib\site-packages\imcsdk-0.9.1.0-py2.7.egg\imcsdk\imcmo.py", line 138, in __setattr___
self.__set_prop(name, value)_
_File "c:\python27\lib\site-packages\imcsdk-0.9.1.0-py2.7.egg\imcsdk\imcmo.py", line 192, in_ __set_prop value))_
_ValueError: Invalid Value Exception - [CommSnmpUser]: Prop <privacy_pwd>, Value<None>._
Expected -
When security_level='authnopriv', priv_pwd should not be mandatory.
After upgraded to imcsdk to 0.9.3.0, it enforcesto value input for some attributes(eg: ‘uplinkFailover’, ‘uplinkFailbackTimeout’, etc) in vnic even 'vntag_mode' is set to 'disabled'.
If you look at codes, some attributes disallowed ‘NONE’ value, eg: ‘uplinkFailover’, ‘uplinkFailbackTimeout’, ‘vmq’, ‘trusted_class_of_service’, etc
https://github.com/CiscoUcs/imcsdk/blob/master/imcsdk/mometa/adaptor/AdaptorEthGenProfile.py
Looking at CIMC documentation, uplinkFailover and etc are only needed when VNTAG mode is enabled.
Here is the issue I tested with imcsdk 0.9.3.0. I attempted to update the vnic's vlan id, but it kept throwing error that uplink_failover cannot be 'N/A' (no value)
[root@cimc3a /]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@cimc3a /]# python
Python 2.7.13 (default, Jan 11 2018, 19:03:59)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> from imcsdk import *; from imcsdk.imchandle import ImcHandle
>>> handle = ImcHandle('192.168.1.123','admin','password'); handle.login()
True
>>> print handle.query_dn('sys/rack-unit-1/adaptor-1/general')
Managed Object : AdaptorGenProfile
--------------
child_action :None
configuration_pending :no
dn :sys/rack-unit-1/adaptor-1/general
fip_mode :Enabled
iscsi_boot_supported :True
lldp :Enabled
model :UCSC-PCIE-CSC-02
pci_link :None
pci_slot :1
product_name :UCS VIC 1225
revision :6
rn :general
serial :FCH1905799D
status :None
usnic_supported :True
vendor :Cisco Systems Inc
vendor_id :V03
vntag_mode :Disabled
>>> obj = handle.query_dn('sys/rack-unit-1/adaptor-1/host-eth-eth1/general')
>>> print obj
Managed Object : AdaptorEthGenProfile
--------------
arfs :enabled
child_action :None
dn :sys/rack-unit-1/adaptor-1/host-eth-eth1/general
nvgre :disabled
order :ANY
pci_link :0
rate_limit :OFF
rn :general
status :None
trusted_class_of_service :disabled
uplink_failback_timeout :N/A
uplink_failover :N/A
vlan :110
vlan_mode :TRUNK
vmq :disabled
vxlan :disabled
>>> setattr(obj,'vlan','111')
>>> handle.set_mo(obj)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/imcsdk/imchandle.py", line 458, in set_mo
self._commit(timeout=timeout)
File "/usr/local/lib/python2.7/site-packages/imcsdk/imchandle.py", line 517, in _commit
response = self.post_elem(elem, timeout=timeout)
File "/usr/local/lib/python2.7/site-packages/imcsdk/imcsession.py", line 287, in post_elem
response = xc.from_xml_str(response_str, self)
File "/usr/local/lib/python2.7/site-packages/imcsdk/imcxmlcodec.py", line 91, in from_xml_str
raise ex.ImcException(error_code, error_descr)
imcsdk.imcexception.ImcException: [ErrorCode]: ERR-xml-parse-error[ErrorDescription]: XML PARSING ERROR: Element 'adaptorEthGenProfile', attribute 'uplinkFailover': [facet 'enumeration'] The value 'N/A' is not an element of the set {'enabled', 'disabled', 'Enabled', 'Disabled'}. Element 'adaptorEthGenProfile', attribute 'uplinkFailover': 'N/A' is not a valid value of the atomic type 'enabledDisabled'.
>>>
>>> import imcsdk; imcsdk.__version__
'0.9.3.0'
>>>
After I downgraded to imcsdk-0.9.2.0, it is fine. it doesn't ask for those values. I could update vlan id on the vnic as an example.
[root@cimc3 /]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@cimc3 /]# python
Python 2.7.13 (default, Jan 11 2018, 19:03:59)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import imcsdk; imcsdk.__version__
'0.9.2.0'
>>> from imcsdk import *; from imcsdk.imchandle import ImcHandle
>>> handle = ImcHandle('192.168.1.123','admin','password'); handle.login()
True
>>> print handle.query_dn('sys/rack-unit-1/adaptor-1/general')
Managed Object : AdaptorGenProfile
--------------
child_action :None
configuration_pending :no
dn :sys/rack-unit-1/adaptor-1/general
fip_mode :Enabled
iscsi_boot_supported :True
lldp :Enabled
model :UCSC-PCIE-CSC-02
pci_slot :1
product_name :UCS VIC 1225
revision :6
rn :general
serial :FCH1905799D
status :None
usnic_supported :True
vendor :Cisco Systems Inc
vendor_id :V03
vntag_mode :Disabled
>>> obj = handle.query_dn('sys/rack-unit-1/adaptor-1/host-eth-eth1/general')
>>> print obj
Managed Object : AdaptorEthGenProfile
--------------
arfs :enabled
child_action :None
dn :sys/rack-unit-1/adaptor-1/host-eth-eth1/general
[X]nvgre :disabled
order :ANY
[X]pciLink :0
rate_limit :OFF
rn :general
status :None
trusted_class_of_service :disabled
uplink_failback_timeout :N/A
uplink_failover :N/A
vlan :110
vlan_mode :TRUNK
vmq :disabled
[X]vxlan :disabled
>>> setattr(obj,'vlan','111')
>>> handle.set_mo(obj)
>>> print obj
Managed Object : AdaptorEthGenProfile
--------------
arfs :enabled
child_action :None
dn :sys/rack-unit-1/adaptor-1/host-eth-eth1/general
[X]nvgre :disabled
order :ANY
[X]pciLink :0
rate_limit :OFF
rn :general
status :modified
trusted_class_of_service :disabled
uplink_failback_timeout :N/A
uplink_failover :N/A
vlan :111
vlan_mode :TRUNK
vmq :disabled
[X]vxlan :disabled
>>>
This issue may be probably happened on other classes which I haven't tested
Testing against Python2 and Python3, I have discovered that I can not import the IMCSDK in Python3.
python
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from imcsdk.imchandle import ImcHandle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/awatkins/Projects/PV2/cimc-tools/venv_py3/lib/python3.6/site-packages/imcsdk/imchandle.py", line 18, in <module>
from . import imccoreutils
File "/Users/awatkins/Projects/PV2/cimc-tools/venv_py3/lib/python3.6/site-packages/imcsdk/imccoreutils.py", line 30, in <module>
from imccoremeta import MoPropertyMeta
ModuleNotFoundError: No module named 'imccoremeta'
This is using a fresh install of imcsdk in a new virtualenv.
pip freeze
says imcsdk==0.9.2.0
workaround
I can fix this temporarily in my virtualenv by adding a dot to line 30 of imccoreutils.py immediately before the word imccoremeta
i.e.
from .imccoremeta import MoPropertyMeta
Suggested fix: consider using from __future__ import absolute_import
to handle the differences between python2 and python3 imports.
How to reproduce error:
Problem: Step 3 shows same info as Step 1
However, I know that setting boot order from below script works b/c I can confirm via the cimc web UI.
Question: Is the boot order cached somewhere ? Why does the script show stale info ?
# get boot order
import argparse
from imcsdk.imchandle import ImcHandle
from imcsdk import *
h = ImcHandle(args.host,args.username,args.password)
h.login()
boot_order = boot_order_precision_get(h,dump=False)
print boot_order
h.logout()
# set boot order
import argparse
from imcsdk.imchandle import ImcHandle
from imcsdk import *
from imcsdk.mometa.lsboot import LsbootDevPrecision
h = ImcHandle(args.host,args.username,args.password)
h.login()
boot_devices = [
[
{"order": "1", "device-type": "pxe", "name": "testpxe1"},
{"order": "2", "device-type": "hdd", "name": "testhdd2"},
],
]
boot_order_precision_set(h, boot_devices=boot_devices[0])
h.logout()
"ULTM" is not in the list of supported server prefixes. It runs the same CIMC OS as the other servers listed, but has a different product ID to distinguish its sale and use. Please include this in the list.
In function "_validate_model":
valid_model_prefixes = ["UCSC", "UCS-E", "UCSS", "HX"]
should be
valid_model_prefixes = ["UCSC", "UCS-E", "UCSS", "HX", "ULTM"]
On C3x60 servers, in addition to firmware upgrade of the entire system, firmware upgrade on a single server can also performed.
Need to support this from sdk.
C3x60 servers support operations like single server backup and import.
Need to support this from sdk.
When querying the children of the BiosSettings class on a C220-M5 running 3.1(2c) I get an object back from the server that has no matching ManagedObject class. It is put into a GenericMo object as:
GenericMo :biosVfTXTSupport
---------
dn :sys/rack-unit-1/bios/bios-settings/TXT-Support
rn :TXT-Support
vpTXTSupport :Disabled
bios_token_set is not usable due to this:
File "<stdin>", line 1, in <module>
File "imcsdk/apis/v2/server/bios.py", line 360, in bios_tokens_set
from imcsdk.imccoreutils import load_class, sanitize_xml_parsing_error
ImportError: cannot import name sanitize_xml_parsing_error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.