clusterDefFile = sys.argv[nextIndex][len('--cluster-def='):]
            else:
                sys.exit('{0} is not a recognized option'.format(
                    sys.argv[nextIndex]))
            nextIndex += 1
        else:
            break

    if clusterDefFile is None:
        here = os.path.dirname(sys.argv[0])
        clusterDefFile = os.path.join(here, 'cluster.json')

    if not os.path.isfile(clusterDefFile):
        sys.exit('could not find cluster definition file: ' + clusterDefFile)

    clusterDef = clusterdef.ClusterDef(clusterDefFile)

    if nextIndex >= len(sys.argv):
        sys.exit('invalid input, please provide a command')

    cmd = sys.argv[nextIndex]
    nextIndex += 1

    if len(sys.argv) == nextIndex:
        if cmd == 'start':
            startClusterLocal()
        elif cmd == 'shutdown':
            stopCluster()
        elif cmd == 'stop':
            stopClusterLocal()
        else:
Esempio n. 2
0
        clusterDefFile = os.path.join(here, 'cluster.json')

    if not os.path.isfile(clusterDefFile):
        sys.exit('could not find cluster definition file: ' + clusterDefFile)

    with open(clusterDefFile, 'r') as f:
        tfile = tempfile.NamedTemporaryFile(delete=False)
        tfileName = tfile.name
        with tfile:
            line = f.readline()
            while (len(line) > 0):
                tfile.write(subEnvVars(line))
                line = f.readline()

    with open(tfileName, 'r') as f:
        clusterDef = clusterdef.ClusterDef(json.load(f))

    os.remove(tfileName)

    if nextIndex >= len(sys.argv):
        sys.exit('invalid input, please provide a command')

    cmd = sys.argv[nextIndex]
    nextIndex += 1

    if len(sys.argv) == nextIndex:
        if cmd == 'start':
            startClusterLocal()
        elif cmd == 'stop':
            stopCluster()
        else: