Exemple #1
0
def save(objlist, file):
    domimpl = xml.dom.getDOMImplementation()
    doc = domimpl.createDocument(None, "IPMIPrefs", None)
    main = doc.documentElement
    for obj in objlist:
        elem = doc.createElement(obj.getTag())
        obj.SaveInfo(doc, elem)
        main.appendChild(elem)
        pass
    try:
        info = os.stat(file)
        pass
    except:
        # File doesn't exist, create it.
        try:
            fd = os.open(file, os.O_WRONLY | os.O_CREAT,
                         stat.S_IRUSR | stat.S_IWUSR)
            os.close(fd)
            pass
        except:
            _oi_logging.error("Unable to create startup file " + file)
            return
        pass
    try:
        f = open(file, 'w')
        doc.writexml(f, indent='', addindent='\t', newl='\n')
        pass
    except:
        _oi_logging.error("Unable to save startup file " + file)
        pass
    return
Exemple #2
0
def GetAttrInt(attr, default):
    try:
        return int(attr.nodeValue)
    except Exception as e:
        _oi_logging.error("Error getting init parm " + attr.nodeName +
                          ": " + str(e))
        return default
Exemple #3
0
def RestoreDomains(mainhandler):
    for i in mainhandler.defaultDomains:
        name = i[0]
        attrhashes = i[1]
        other = i[2]
        connects = []
        for attrhash in attrhashes:
            if ("contype" not in attrhash):
                continue
            args = OpenIPMI.alloc_empty_args(str(attrhash["contype"]))
            if (args == None):
                continue
            for attr in attrhash.items():
                vname = str(attr[0])
                if (vname == "contype"):
                    continue
                value = str(attr[1])
                args.set_val(0, vname, value)
                pass
            connects.append(args)
            pass
        domain_id = OpenIPMI.open_domain3(name, [], connects, None, None)
        if (domain_id != None):
            DomainInfoSetup(other, domain_id)
            pass
        else:
            _oi_logging.error("Error making domain connection for " + name)
            pass
        pass
    return
Exemple #4
0
 def mc_get_event_log_enable_cb(self, mc, err, val):
     if (err):
         _oi_logging.error("Error getting MC event log enable for " +
                           self.name + ": " +
                           OpenIPMI.get_error_string(err))
         return
     self.ui.set_item_text(self.el_item, str(val != 0))
Exemple #5
0
 def Deactivate(self, event):
     oper = EntityOp(self, "deactivate")
     rv = oper.DoOp()
     if (rv != 0):
         _oi_logging.error("entity deactivation failed: " + str(rv))
         pass
     return
Exemple #6
0
 def RequestActivation(self, event):
     oper = EntityOp(self, "set_activation_requested")
     rv = oper.DoOp()
     if (rv != 0):
         _oi_logging.error("entity set activation failed: " + str(rv))
         pass
     return
Exemple #7
0
 def entity_hot_swap_get_time_cb(self, entity, err, time):
     if (err):
         _oi_logging.error("Error getting activation time: " + str(err))
         return
     gui_setdialog.SetDialog("Set " + self.name + " for " + str(self.e),
                             [time], 1, self)
     return
Exemple #8
0
 def mc_set_event_log_enable_cb(self, mc, err):
     if (err):
         _oi_logging.error("Error setting MC event log enable for" +
                           self.name + ": " +
                           OpenIPMI.get_error_string(err))
         return
     self.el_refr.DoUpdate()
     return
Exemple #9
0
def GetAttrBool(attr, default):
    if (attr.nodeValue.lower() == "true") or (attr.nodeValue == "1"):
        return True
    elif (attr.nodeValue.lower() == "false") or (attr.nodeValue == "0"):
        return False
    else:
        _oi_logging.error ("Error getting init parm " + attr.nodeName)
        pass
    return default
Exemple #10
0
 def entity_hot_swap_cb(self, entity, err, state):
     if (self.destroyed):
         return
     if (err):
         _oi_logging.error("Error getting entity hot-swap state: " +
                           str(err))
         return
     self.hot_swap_state = state
     self.ui.set_item_text(self.hotswapitem,
                           self.hot_swap + ' ' + self.hot_swap_state)
     return
Exemple #11
0
    def refresh(self):
        name_s = [""]
        node_s = [None]
        rv = self.fru.get_root_node(name_s, node_s)
        if (rv != 0):
            _oi_logging.error("unable to get FRU node: " + str(rv))
            return

        self.fru_type = name_s[0]
        self.RemoveAll()
        self.add_fru_data(self.treeroot, node_s[0], 0, None,
                          self.fru_type == "standard FRU")
        self.AfterDone()
        self.ExpandItem("")
        return
Exemple #12
0
    def __init__(self, e, name, func):
        self.e = e
        self.name = name
        self.func = func

        self.err = 0
        rv = e.entity_id.to_entity(self)
        if (rv == 0):
            rv = self.err
            pass
        if (rv):
            _oi_logging.error(
                "Error doing entity cb in activation time setter: " + str(rv))
            pass

        return
Exemple #13
0
    def __init__(self, fru, name):
        self.fru = fru
        name_s = [""]
        node_s = [None]
        rv = fru.get_root_node(name_s, node_s)
        if (rv != 0):
            _oi_logging.error("unable to get FRU node: " + str(rv))
            return

        self.fru_type = name_s[0]

        gui_treelist.TreeList.__init__(self, "FRU info for " + name, ".",
                                       [("Name", 300), ("Value", 300)])

        self.add_fru_data(self.treeroot, node_s[0], 0, None,
                          self.fru_type == "standard FRU")
        self.AfterDone()
        self.ExpandItem("")
        return
Exemple #14
0
 def restore(self, mainhandler, node):
     name = str(node.getAttribute("name"))
     if (name == ""):
         return
     connects = []
     other = OtherDomainInfo()
     for c in node.childNodes:
         if (c.nodeType == c.ELEMENT_NODE):
             if (c.nodeName == "connection"):
                 attrhash = {}
                 for i in range(0, c.attributes.length):
                     attr = c.attributes.item(i)
                     attrhash[attr.nodeName] = attr.nodeValue
                     pass
                 connects.append(attrhash)
                 pass
             elif (c.nodeName == "IPMB_rescan_time"):
                 try:
                     other.ipmb_rescan_time = int(c.getAttribute("time"))
                 except:
                     _oi_logging.error("Error restoring IPMB rescan time" +
                                       " in a domain")
                     pass
                 pass
             elif (c.nodeName == "SEL_rescan_time"):
                 try:
                     other.sel_rescan_time = int(c.getAttribute("time"))
                 except:
                     _oi_logging.error("Error restoring SEL rescan time" +
                                       " in a domain")
                     pass
                 pass
             pass
         pass
     mainhandler.defaultDomains.append([name, connects, other])
     return
Exemple #15
0
 def entity_fru_update_werr_cb(self, op, err, entity, fru):
     if (self.destroyed):
         return
     if (op == "error"):
         _oi_logging.error("Error getting entity fru: " + str(err))
     return
Exemple #16
0
 def entity_activate_cb(self, entity, err):
     if (err != 0):
         _oi_logging.error("entity activate operation failed: " + str(err))
         pass
     return