Gets Managed Object from UCS.
		
		- inMo, if provided, it acts as a parent for the present operation. It should be None unless a user wants to define a parent scope. 
		  It can be a single MO or a list containing multiple managed objects.
		- classId of the managed object/s to get.
		- params contains semicolon (;) separated list of key/value pairs(key=value), that are used as filters for selecting specific managed 
		  objects. The key should be a valid property of the managed object to be retrieved.
		- inHierarchical, Explores hierarchy if true, else returns managed objects at a single level.

def GetManagedObject(self, inMo=None, classId=None, params=None, inHierarchical=False, dumpXml=None):
		"""
		Gets Managed Object from UCS.
		
		- inMo, if provided, it acts as a parent for the present operation. It should be None unless a user wants to define a parent scope. 
		  It can be a single MO or a list containing multiple managed objects.
		- classId of the managed object/s to get.
		- params contains semicolon (;) separated list of key/value pairs(key=value), that are used as filters for selecting specific managed 
		  objects. The key should be a valid property of the managed object to be retrieved.
		- inHierarchical, Explores hierarchy if true, else returns managed objects at a single level.
		"""
		from Ucs import ClassFactory, Dn, DnSet, OrFilter, EqFilter, AndFilter, WcardFilter, FilterFilter
		from Mos import LsServer
		from UcsBase import WriteUcsWarning, WriteObject, UcsUtils, ManagedObject, AbstractFilter, UcsException, \
			UcsValidationException

		if params != None:
			keys = params.keys()
		else:
			keys = []

		if (classId != None and classId != ""):
			# ClassId param set
			metaClassId = UcsUtils.FindClassIdInMoMetaIgnoreCase(classId)
			if (metaClassId == None):
				metaClassId = classId
				moMeta = UcsMoMeta(UcsUtils.WordU(classId), UcsUtils.WordL(classId), "", "", "InputOutput",
								   ManagedObject.DUMMYDIRTY, [], [], [], [])
			else:
				moMeta = UcsUtils.GetUcsPropertyMeta(metaClassId, "Meta")

			if moMeta == None:
				raise UcsValidationException(
					'[Error]: GetManagedObject: moMeta for classId [%s] is not valid' % (classId))
			# raise Exception('[Error]: GetManagedObject: moMeta for classId [%s] is not valid' %(classId))

			# process the filter argument and make filterfilter
			orFilter = OrFilter()

			if ((inMo != None) and (isinstance(inMo, list)) and (len(inMo) > 0)):
				for mo in inMo:
					andFilter = AndFilter()
					for key in keys:
						propMoMeta = UcsUtils.IsPropertyInMetaIgnoreCase(metaClassId, key)
						if (propMoMeta != None):
							attrName = propMoMeta.xmlAttribute
						else:
							attrName = key

						eqFilter = EqFilter()
						eqFilter.Class = UcsUtils.WordL(metaClassId)
						eqFilter.Property = attrName
						eqFilter.Value = str(params[key])
						andFilter.AddChild(eqFilter)

					lkupDn = mo.getattr("Dn")
					if (lkupDn == None):
						if (isinstance(mo, LsServer) == True):
							lkupDn = "root"
						continue
					wcardFilter = WcardFilter()
					wcardFilter.Class = UcsUtils.WordL(metaClassId)
					wcardFilter.Property = UcsUtils.WordL(NamingId.DN)
					wcardFilter.Value = "^" + re.escape(lkupDn) + "/[^/]+$"
					andFilter.AddChild(wcardFilter)

					if (andFilter.GetChildCount() > 1):
						orFilter.AddChild(UcsUtils.HandleFilterMaxComponentLimit(self, andFilter))
					elif (andFilter.GetChildCount() == 1):
						for filter in andFilter.GetChild():
							if (isinstance(filter, AbstractFilter) == True):
								orFilter.AddChild(filter)

			else:
				andFilter = AndFilter()
				for key in keys:
					propMoMeta = UcsUtils.IsPropertyInMetaIgnoreCase(metaClassId, key)
					if (propMoMeta != None):
						attrName = propMoMeta.xmlAttribute
					else:
						attrName = key

					eqFilter = EqFilter()
					eqFilter.Class = UcsUtils.WordL(metaClassId)
					eqFilter.Property = attrName
					eqFilter.Value = str(params[key])
					andFilter.AddChild(eqFilter)

				if (andFilter.GetChildCount() > 1):
					orFilter.AddChild(UcsUtils.HandleFilterMaxComponentLimit(self, andFilter))
				elif (andFilter.GetChildCount() == 1):
					for filter in andFilter.GetChild():
						if (isinstance(filter, AbstractFilter) == True):
							orFilter.AddChild(filter)

			inFilter = None
			if (orFilter.GetChildCount() > 1):
				inFilter = FilterFilter()
				inFilter.AddChild(UcsUtils.HandleFilterMaxComponentLimit(self, orFilter))
			elif (orFilter.GetChildCount() == 1):
				inFilter = FilterFilter()
				for filter in orFilter.GetChild():
					if (isinstance(filter, AbstractFilter) == True):
						inFilter.AddChild(filter)

			crc = self.ConfigResolveClass(moMeta.xmlAttribute, inFilter, inHierarchical, dumpXml)
			if crc.errorCode == 0:
				moList = []
				currentMoList = crc.OutConfigs.GetChild()
				while (len(currentMoList) > 0):
					childMoList = []
					for mo in currentMoList:
						moList.append(mo)
						while (mo.GetChildCount() > 0):
							for child in mo.GetChild():
								mo.RemoveChild(child)
								if (child.__dict__.has_key('Dn')):
									if (child.Dn == None or child.Dn == ""):
										child.setattr("Dn", mo.Dn + '/' + child.Rn)
										child.MarkClean()
								else:
									child.setattr("Dn", mo.Dn + '/' + child.Rn)
									child.MarkClean()
								childMoList.append(child)
								break
					currentMoList = childMoList

				# WriteObject(moList)
				return moList
			else:
				raise UcsException(crc.errorCode, crc.errorDescr)
				# raise Exception('[Error]: GetManagedObject [Code]:' + crc.errorCode + ' [Description]:' + crc.errorDescr)
				# return None
		else:
			# Dn param set
			dnSet = DnSet()
			dn = Dn()
			for key in keys:
				if (key.lower() == "dn"):
					dn.setattr("Value", params[key])

			if (dn.getattr("Value") == None or dn.getattr("Value") == ""):
				raise UcsValidationException("classId or dn parameter is not provided.")
			# raise Exception('[Warning]: GetManagedObject: ClassId or DN is mandatory')

			dnSet.AddChild(dn)
			crDns = self.ConfigResolveDns(dnSet, inHierarchical, dumpXml)
			if (crDns.errorCode == 0):
				moList = []
				if (inHierarchical == True):
					currentMoList = crDns.OutConfigs.GetChild()
					while (len(currentMoList) > 0):
						childMoList = []
						for mo in currentMoList:
							moList.append(mo)
							while (mo.GetChildCount() > 0):
								for child in mo.GetChild():
									mo.RemoveChild(child)
									if (child.__dict__.has_key('Dn')):
										if (child.Dn == None or child.Dn == ""):
											child.setattr("Dn", mo.Dn + '/' + child.Rn)
											child.MarkClean()
									else:
										child.setattr("Dn", mo.Dn + '/' + child.Rn)
										child.MarkClean()
									childMoList.append(child)
									break
						currentMoList = childMoList
				else:
					moList = crDns.OutConfigs.GetChild()
				sortedMoList = sorted(moList, lambda x, y: cmp(x.Dn, y.Dn))
				# WriteObject(moList)
				return sortedMoList
			else:
				raise UcsException(crDns.errorCode, crDns.errorDescr)