def __init__(self, class_id, parent_mo_or_dn=None, **kwargs): self.__properties = {} if isinstance(parent_mo_or_dn, GenericMo): self.__parent_mo = parent_mo_or_dn self.__parent_dn = parent_mo_or_dn.dn elif isinstance(parent_mo_or_dn, str): # if (parent_mo_or_dn == "") and ("dn" in kwargs): # parent_mo_or_dn = kwargs["dn"] self.__parent_dn = parent_mo_or_dn self.__parent_mo = None elif parent_mo_or_dn is None: self.__parent_dn = "" self.__parent_mo = None else: raise ValueError("parent_mo_or_dn should be an instance of str or " "GenericMo") UcsBase.__init__(self, class_id) if kwargs: for key, value in kwargs.iteritems(): self.__dict__[key] = str(value) self.__properties[key] = str(value) if 'rn' in dir(self) and 'dn' in dir(self): pass elif 'rn' in dir(self) and 'dn' not in dir(self): if self.__parent_dn is not None and self.__parent_dn != "": self.dn = self.__parent_dn + '/' + self.rn self.__properties['dn'] = self.dn else: self.dn = self.rn self.__properties['dn'] = self.dn elif 'rn' not in dir(self) and 'dn' in dir(self): self.rn = os.path.basename(self.dn) self.__properties['rn'] = self.rn else: self.rn = "" self.dn = "" if self.__parent_mo: self.__parent_mo.child_add(self)
def __init__(self, method_id): # """ __init__ of the UcsBase class """ UcsBase.__init__(self, method_id) meta_module = ucscoreutils.load_module(method_id) self.__method_meta = getattr(meta_module, "method_meta") self.__property_meta = getattr(meta_module, "prop_meta") self.__property_map = getattr(meta_module, "prop_map") # """ instantiate class variables """ # for prop in CoreUtils.get_property_list(self._class_id): # if prop != "Meta": # self.__dict__[prop] = None for prop in self.__property_meta: self.__dict__[prop] = None self.error_code = 0 self.error_descr = None self.invocation_result = None self.response = None self.mark_clean()
def __init__(self, class_id, parent_mo_or_dn=None, **kwargs): self.__parent_mo = None self.__status = None self.__parent_dn = None self.__xtra_props = {} self.__xtra_props_dirty_mask = 0x1L self._rn_set() self._dn_set(parent_mo_or_dn) xml_attribute = self.mo_meta.xml_attribute UcsBase.__init__(self, ucsgenutils.word_u(xml_attribute)) # self.mark_dirty() if self.__parent_mo: self.__parent_mo.child_add(self) if kwargs: for prop_name, prop_value in kwargs.iteritems(): if prop_name not in self.prop_meta: log.debug("Unknown property %s" % prop_name) self.__set_prop(prop_name, prop_value)