Exemplo n.º 1
0
 def doApply(self):
     if not self.validateConfig():
         QMessageBox.critical(None,
                              "Error", "Configuration has errors, not applied!",
                              QMessageBox.Ok, QMessageBox.Ok)
         return
     if self.doSave():
         utils.applyConfig(self.hutch, self.applyVerify)
Exemplo n.º 2
0
 def applyOne(self, index):
     id = self.cfglist[index.row()]['id']
     if not self.validateConfig():
         QMessageBox.critical(None,
                              "Error", "Configuration has errors, not applied!",
                              QMessageBox.Ok, QMessageBox.Ok)
         return
     if self.doSave():
         utils.applyConfig(self.hutch, self.applyVerify, id)
Exemplo n.º 3
0
def set_state(hutch, ioc, enable):
    if not utils.check_auth(pwd.getpwuid(os.getuid())[0], hutch):
        print "Not authorized!"
        sys.exit(1)
    (ft, cl, hl, vs) = utils.readConfig(hutch)
    try:
        utils.COMMITHOST = vs["COMMITHOST"]
    except:
        pass
    for c in cl:
        if c['id'] == ioc:
            c['newdisable'] = not enable
            do_commit(hutch, cl, hl, vs)
            utils.applyConfig(hutch, None, ioc)
            sys.exit(0)
    print "IOC %s not found in hutch %s!" % (ioc, hutch)
    sys.exit(1)
Exemplo n.º 4
0
def upgrade(hutch, ioc, version):
    if not utils.check_auth(pwd.getpwuid(os.getuid())[0], hutch):
        print "Not authorized!"
        sys.exit(1)
    if not utils.validateDir(version, ioc):
        print "%s does not have an st.cmd for %s!" % (version, ioc)
        sys.exit(1)
    (ft, cl, hl, vs) = utils.readConfig(hutch)
    try:
        utils.COMMITHOST = vs["COMMITHOST"]
    except:
        pass
    for c in cl:
        if c['id'] == ioc:
            c['newdir'] = version
            do_commit(hutch, cl, hl, vs)
            utils.applyConfig(hutch, None, ioc)
            sys.exit(0)
    print "IOC %s not found in hutch %s!" % (ioc, hutch)
    sys.exit(1)
Exemplo n.º 5
0
def move(hutch, ioc, hostport):
    if not utils.check_auth(pwd.getpwuid(os.getuid())[0], hutch):
        print "Not authorized!"
        sys.exit(1)
    (ft, cl, hl, vs) = utils.readConfig(hutch)
    try:
        utils.COMMITHOST = vs["COMMITHOST"]
    except:
        pass
    for c in cl:
        if c['id'] == ioc:
            hp = hostport.split(":")
            c['newhost'] = hp[0]
            if len(hp) > 1:
                c['newport'] = int(hp[1])
            if not utils.validateConfig(cl):
                print "Port conflict when moving %s to %s, not moved!" % (ioc, hostport)
                sys.exit(1)
            do_commit(hutch, cl, hl, vs)
            utils.applyConfig(hutch, None, ioc)
            sys.exit(0)
    print "IOC %s not found in hutch %s!" % (ioc, hutch)
    sys.exit(1)
Exemplo n.º 6
0
#!/usr/bin/env python
import sys
import utils

host = None


def verify_host(current, config, kill_list, start_list, restart_list):
    kill_list = [k for k in kill_list if k == host]
    start_list = [k for k in start_list if k == host]
    restart_list = [k for k in restart_list if k == host]
    return (kill_list, start_list, restart_list)


if __name__ == '__main__':
    hutch = sys.argv[1]
    if len(sys.argv) > 1:
        host = sys.argv[2]
        sys.exit(utils.applyConfig(hutch, verify_host))
    else:
        sys.exit(utils.applyConfig(hutch))