Skip to content

Commit

Permalink
generated new imcsdk and updated mo and meta files
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuchhuk committed Nov 27, 2024
1 parent f0efddc commit 9fd9e59
Show file tree
Hide file tree
Showing 138 changed files with 4,098 additions and 327 deletions.
57 changes: 55 additions & 2 deletions imcsdk/imcbiostables.py

Large diffs are not rendered by default.

140 changes: 137 additions & 3 deletions imcsdk/imcconstants.py

Large diffs are not rendered by default.

74 changes: 61 additions & 13 deletions imcsdk/imccoremeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,20 @@ def _set_versions(self, match_obj):
self.__patch = match_dict.get("patch")
self.__spin = match_dict.get("spin")

# for spin builds 4.0(1S52), the patch version will be None
# In this scenario assume the version to be highest patch z
if self.__spin is not None and self.__patch is None:
self.__patch = 'z'
elif self.__patch is not None and self.__mr is not None and self.__patch.isdigit() and self.__mr.isdigit():
log.debug("Interim version encountered: %s. MR version has been bumped up." % self.version)
self.__mr = str(int(self.__mr) + 1)
self.__patch = 'a'
elif self.__patch is not None and self.__patch.isalpha() and self.__spin:
log.debug("Interim version encountered: %s. patch version has been bumped up." % self.version)
self.__patch = str(chr(ord(self.__patch)+1))
# Starting LB release, Spin builds only are released.
# Spin builds version is not converted to patch build version, hence there is no need of
# handling of patch none values or spin none values while processing version.
# Patch and Spin will now be used in comparision function, and none values are handled accordingly.
# For this reason, below code is being commented out.
# if self.__patch is None:
# self.__patch = 'z'
# elif self.__patch.isdigit() and self.__mr.isdigit():
# log.debug("Interim version encountered: %s. MR version has been bumped up." % self.version)
# self.__mr = str(int(self.__mr) + 1)
# self.__patch = 'a'
# elif self.__patch.isalpha() and self.__spin:
# log.debug("Interim version encountered: %s. patch version has been bumped up." % self.version)
# self.__patch = str(chr(ord(self.__patch)+1))
return True

@property
Expand All @@ -153,6 +156,11 @@ def patch(self):
"""Getter Method of ImcVersion Class"""
return self.__patch

@property
def spin(self):
"""Getter Method of ImcVersion Class"""
return self.__spin

@property
def version(self):
"""Getter Method of UcsVersion Class"""
Expand All @@ -175,14 +183,54 @@ def compare_to(self, version):
return 1

ret = 0

# From LB release spin builds are processed.
# Hence spin comparision needs to be included
versions = [(self.__major, version.major),
(self.__minor, version.minor),
(self.__mr, version.mr),
(self.__patch, version.patch)]
(self.__mr, version.mr)]
for item in versions:
ret = self._compare(item[0], item[1])
if ret:
# If major, minor or mr are not equal then return from here only, further check not required.
return ret
# Compare Patch if patch available in both.
if self.__patch and version.patch:
if self.__patch == version.patch:
ret = 0
# If patch is also same, then nightly builds [4.0(234bS3)] have patch and spin both
# So in that case compare spin as well.
# This comparison is actually not required
# (as nightly builds are not released, and are for internal purpose only)
# but for completeness we are adding this.
if self.__spin and version.spin:
ret = self._compare(self.__spin, version.spin)
elif self.__spin:
ret = 1
elif version.spin:
ret = -1
elif self.__patch < version.patch:
ret = -1
else:
ret = 1
elif self.__spin and version.spin:
# compare spin if spin available in both.
ret = self._compare(self.__spin, version.spin)
elif (not self.__patch and self.__spin) and (version.patch and not version.spin):
# if spin available in self, and patch available in version, then consider self as greater.
# We consider spin builds as greater than patch builds, as spin builds started from LB release.
ret = 1
elif (self.__patch and not self.__spin) and (not version.patch and version.spin):
# if spin available in version, and patch available in self, then consider version as greater.
# We consider spin builds as greater than patch builds, as spin builds started from LB release.
ret = -1
elif not self.__spin and version.spin:
# If we reached here, then there is no patch, and only one have spin, consider that as greater.
ret = 1
elif self.__spin and not version.spin:
# If we reached here, then there is no patch, and only one have spin, consider that as greater.
ret = -1

return ret

def __gt__(self, version):
Expand Down
45 changes: 38 additions & 7 deletions imcsdk/imccoreutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os
import re
import logging
import sys

from . import imcgenutils
from . import mometa
Expand Down Expand Up @@ -77,12 +76,14 @@ def get_imc_obj(class_id, elem, mo_obj=None):
return imcmethod.ExternalMethod(class_id)
elif class_id in MO_CLASS_ID:
mo_class = load_class(class_id)
if sys.version_info > (3, 0):
# Python 3 code in this block
mo_class_params = inspect.getfullargspec(mo_class.__init__)[0][2:]
else:
# Python 2 code in this block
'''
In the version of python 3.12 later getargspec function is removed from inspect. Added condition to allow older python versions
to continue to use getargspec
'''
if hasattr(inspect, 'getargspec'):
mo_class_params = inspect.getargspec(mo_class.__init__)[0][2:]
else:
mo_class_params = inspect.getfullargspec(mo_class.__init__)[0][2:]
mo_class_param_dict = {}
for param in mo_class_params:
mo_class_param_dict[param] = None
Expand Down Expand Up @@ -195,7 +196,14 @@ def load_mo(elem):

mo_class_id = elem.tag
mo_class = load_class(mo_class_id)
mo_class_params = inspect.getargspec(mo_class.__init__)[0][2:]
'''
In the version of python 3.12 later getargspec function is removed from inspect. Added condition to allow older python versions
to continue to use getargspec
'''
if hasattr(inspect, 'getargspec'):
mo_class_params = inspect.getargspec(mo_class.__init__)[0][2:]
else:
mo_class_params = inspect.getfullargspec(mo_class.__init__)[0][2:]
mo_class_param_dict = {}
for param in mo_class_params:
mo_class_param_dict[param] = elem.attrib[
Expand Down Expand Up @@ -917,6 +925,17 @@ def get_dn_prefix_for_platform(handle):
else:
return ""

def is_platform_lessthan_m7(handle):
"""
This method is checks wether the platform is lessthan m7 or not, returns true if platform is m4 or m5 or m6
Args:
handle (ImcHandle)
Returns:
True/False
"""
return is_platform_m4(handle) or is_platform_m5(handle) or is_platform_m6(handle)

def is_platform_m4(handle):
return match_platform_type(handle, "M4")
Expand All @@ -927,6 +946,18 @@ def is_platform_m5(handle):
match_platform_type(handle, "C125")


def is_platform_m6(handle):
return match_platform_type(handle, "M6")


def is_platform_m7(handle):
return match_platform_type(handle, "M7")


def is_platform_m8(handle):
return match_platform_type(handle, "M8")


def match_platform_type(handle, match_string):
if handle.model:
return handle.model.find(match_string) != -1
Expand Down
18 changes: 12 additions & 6 deletions imcsdk/imcdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,20 @@ def connect(self):
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
ssl_context.options |= ssl.OP_NO_SSLv2
ssl_context.options |= ssl.OP_NO_SSLv3
if self.key_file and self.cert_file:
ssl_context.load_cert_chain(keyfile=self.key_file,
certfile=self.cert_file)
#Since python 3.6 key_file and cert_file was deprecated
#latest one for create ssl context is create_default_context
if hasattr(self, 'key_file') and hasattr(self, 'cert_file') and self.key_file and self.cert_file:
ssl_context.load_cert_chain(keyfile=self.key_file, certfile=self.cert_file)
else:
ssl.create_default_context()
self.sock = ssl_context.wrap_socket(sock)
else:
# This is the only difference; default wrap_socket uses SSLv23
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file,
ssl_version=ssl.PROTOCOL_TLSv1)
if hasattr(self, 'key_file') and hasattr(self, 'cert_file') and self.key_file and self.cert_file:
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file,ssl_version=ssl.PROTOCOL_TLSv1)
else:
self.sock = ssl.wrap_socket(sock,ssl_version=ssl.PROTOCOL_TLSv1)



class ImcDriver(object):
Expand Down Expand Up @@ -158,7 +164,7 @@ def __get_handlers(self, tls_proto=None):
tls_handler = (TLSHandler, TLS1Handler)[tls_proto == "tlsv1"]
handlers = [SmartRedirectHandler, tls_handler]
if self.__proxy:
proxy_handler = urllib.request.ProxyHandler(
proxy_handler = urllib2.request.ProxyHandler(
{'http': self.__proxy, 'https': self.__proxy})
handlers.append(proxy_handler)
return handlers
Expand Down
59 changes: 26 additions & 33 deletions imcsdk/imcfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,41 +125,34 @@ def parse_filter_str(self, filter_str):
method to parse filter string
"""

prop = pp.Word(pp.alphanums + "_", asKeyword=True).setResultsName("prop")
value = (pp.QuotedString("'")
| pp.QuotedString('"')
| pp.Word(pp.printables, excludeChars=",")
).setResultsName("value")
prop = pp.WordStart(pp.alphas) + pp.Word(pp.alphanums +
"_").setResultsName("prop")
value = (pp.QuotedString("'") | pp.QuotedString('"') | pp.Word(
pp.printables, excludeChars=",")).setResultsName("value")
types_ = pp.oneOf("re eq ne gt ge lt le").setResultsName("types")
flags = pp.Char("CI").setResultsName("flags")
flags = pp.oneOf("C I").setResultsName("flags")
comma = pp.Literal(',')

def in_quotes(exp):
# ensure matching opening and closing quotes
return ('"' + exp + '"'
| "'" + exp + "'")

type_exp = pp.Group(pp.Keyword("type")
+ pp.Literal("=")
+ in_quotes(types_)).setResultsName("type_exp")
flag_exp = pp.Group(pp.Keyword("flag")
+ pp.Literal("=")
+ in_quotes(flags)).setResultsName("flag_exp")

semi_expression = pp.Group(pp.Literal("(") +
prop + comma + value +
pp.Optional(comma + type_exp) +
pp.Optional(comma + flag_exp) +
pp.Literal(")")
).setParseAction(
self.parse_filter_obj
).setResultsName("semi_expression")

NOT, AND, OR = map(pp.Keyword, "not and or".split())
expr = pp.infixNotation(semi_expression, [
(NOT, 1, pp.opAssoc.RIGHT, self.not_operator),
(AND, 2, pp.opAssoc.LEFT, self.and_operator),
(OR, 2, pp.opAssoc.LEFT, self.or_operator)
quote = (pp.Literal("'") | pp.Literal('"')).setResultsName("quote")

type_exp = pp.Group(pp.Literal("type") + pp.Literal(
"=") + quote + types_ + quote).setResultsName("type_exp")
flag_exp = pp.Group(pp.Literal("flag") + pp.Literal(
"=") + quote + flags + quote).setResultsName("flag_exp")

semi_expression = pp.Forward()
semi_expression << pp.Group(pp.Literal("(") +
prop + comma + value +
pp.Optional(comma + type_exp) +
pp.Optional(comma + flag_exp) +
pp.Literal(")")
).setParseAction(
self.parse_filter_obj).setResultsName("semi_expression")

expr = pp.Forward()
expr << pp.operatorPrecedence(semi_expression, [
("not", 1, pp.opAssoc.RIGHT, self.not_operator),
("and", 2, pp.opAssoc.LEFT, self.and_operator),
("or", 2, pp.opAssoc.LEFT, self.or_operator)
])

result = expr.parseString(filter_str)
Expand Down
1 change: 1 addition & 0 deletions imcsdk/imchandle.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ def query_children(self, in_mo=None, in_dn=None, class_id=None,

elem = config_resolve_children(cookie=self.cookie,
class_id=meta_class_id,
dn=None, # Extra attribute added by schema. duplicate of in_dn, hence dn will always be none.
in_dn=parent_dn,
in_hierarchical=hierarchy)

Expand Down
Loading

0 comments on commit 9fd9e59

Please sign in to comment.