Example #1
0
 def handler_ocgs(self, line):
     if ('x_view_conf' == line):
         protocol_log.info('ocgs setting action with command: ' + line)
         nodeinfo = OcgsNodeInfo(self.nodexml)
         info = nodeinfo.getNodeInfo()
         self.terminal.write(info)
         self.terminal.nextLine()
         protocol_log.info('Success execute the getting command: ' + info.replace("\n", " | "))
     elif (line.startswith('x_modify_conf')):
         protocol_log.info('ocgs getting action with command: ' + line)
         handler = OcgsSetValue(line, self.nodexml)
         info = handler.returnRes()
         self.terminal.write(info)
         self.terminal.nextLine()
         protocol_log.info('Success execute the getting command: ' + info.replace("\n", " | "))
     elif (line.startswith("ocgslic")):
         protocol_log.info('ocgs add or remove LIC with command: ' + line)
         handler = OcgsLicAddRemove(line, self.nodexml)
         info = handler.getRes()
         self.terminal.write(info)
         self.terminal.nextLine()
         protocol_log.info('Success execute the add/remove action: ' + info.replace("\n", " | "))
     else:
         protocol_log.error('Unkown command found.')
         self.terminal.write("result=failed\nerrordesc=Command Un-supported!")
         self.terminal.nextLine()
     self.showPrompt()
Example #2
0
    def set_alarm_levels(self):
        cmds = self.line.split()
        if 1 < len(cmds) and 1 == len(cmds) % 2:
            alarms = OcgsNodeInfo(self.xml_path).get_node()['alarm']
            k_v = {}
            for i in range(1, len(cmds), 2):
                if not cmds[i].startswith('-') or not alarms.has_key('D' + cmds[i][1:]) or cmds[i + 1] not in \
                        ['Critical', 'Major', 'Minor', 'Warning']:
                    return
                k_v[cmds[i][1:]] = cmds[i + 1]

            et = ElementTree.parse(self.xml_path)

            for k, v in k_v.iteritems():
                et.find('.//D' + k).text = v

            self._write_back_xml(et)
            del self.return_str[:]
            self.return_str.append('result=successful')