示例#1
0
def rsyncOnAllNodesLocalhostToLocalAsync(sourcedir, targetdir, options=None):
    """
    Run a command on all nodes
    """

    listnodes, nodes = instanceListAll()

    allnodes = listnodes['all']

    listP = []

    if options is None:
        options = ['-la']
    else:
        options = ['la'] + options

    for nodename in allnodes:

        node = nodes[nodename]
        externalIp = node['externalIp']

        p = utils.rsyncLocalhostToOtherAsync(
            externalIp, sourcedir, targetdir, options)
        listP.append(p)

    utils.waitTermination(listP)
示例#2
0
def sshKeysDeploy():
    """ Deploy key ssh """

    (listnodes, nodes) = instanceListAll()

    os.system("eval `ssh-agent -s`")
    os.system("ssh-add")

    # prepare authentification forwarding
    os.system("eval `ssh-agent`")
    os.system("ssh-add ~/.ssh/google_compute_engine")

    allnodes = listnodes['all']

    listP = []

    for nodename in allnodes:

        utils.print_header('Generating SSH Keys for ' + nodename)

        # get node info
        node = nodes[nodename]

        externalIp = node['externalIp']

        listCommand = []
        listCommand.append("rm -rf .ssh/id_rsa*")
        listCommand.append("ssh-keygen -q -t rsa -N \"\" -f ~/.ssh/id_rsa")
        listCommand.append("cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys")
        listCommand.append("chmod 0600 ~/.ssh/authorized_keys")

        listCommand.append("echo \"StrictHostKeyChecking no\" >> .ssh/config")
        listCommand.append("chmod 600  .ssh/config")

        if nodename == 'cluster-data-master' or True:
            for nameother in allnodes:

                if nameother == nodename:
                    pass
                else:
                    localCommand = "ssh-copy-id -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa {0}@{1}".format(
                        username, nameother)

                    listCommand.append(localCommand)
        else:

            nameother = 'cluster-data-master'
            localCommand = "ssh-copy-id -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa {0}@{1}".format(
                username, nameother)

            listCommand.append(localCommand)

        command = ';'.join(listCommand)

        # Execute command
        P = utils.sshAsync(externalIp, command)
        listP.append(P)

    utils.waitTermination(listP)
示例#3
0
def mainLaunchMasterCommonWritable():
    P = instanceLaunch(
        instanceNameMaster(),
        withcommondata=True,
        withlocaldata=True,
        commonmode='rw')

    utils.waitTermination([P])
示例#4
0
def clusterCreateDiskLocalData():
    listP = []
    P = diskLocalDataCreate(instanceNameMaster())
    listP.append(P)
    for iSlave in slaveRange:
        P = diskLocalDataCreate(instanceNameSlave(iSlave))

        listP.append(P)

    utils.waitTermination(listP)
示例#5
0
def instanceKillAll():
    """
    Kill all instances
    """

    instanceListClean()

    (listnodes, nodes) = instanceListAll()

    listP = []
    for instance in listnodes['all']:
        P = instanceKill(instance)

        listP.append(P)

    utils.waitTermination(listP)
示例#6
0
def runOnAllNodesAsync(command):
    """
    Run a command on all nodes
    """

    listnodes, nodes = instanceListAll()

    allnodes = listnodes['all']

    listP = []

    for nodename in allnodes:

        utils.print_header('ON [' + nodename + '] running: ' + command)
        node = nodes[nodename]
        externalIp = node['externalIp']
        P = utils.sshAsync(externalIp, command)
        listP.append(P)

    utils.waitTermination(listP)
示例#7
0
def clusterLaunch(withcommondata=True, withlocaldata=True):
    """Launch cluster of data"""

    listP = []

    P = instanceLaunch(instanceNameMaster(),
                       withcommondata=withcommondata,
                       withlocaldata=withlocaldata)

    listP.append(P)
    for iSlave in slaveRange:

        preemptible = (iSlave >= nNotPreemtible)

        P = instanceLaunch(instanceNameSlave(iSlave),
                           withcommondata=withcommondata,
                           withlocaldata=withlocaldata,
                           preemptible=preemptible)

        listP.append(P)

    utils.waitTermination(listP)
    time.sleep(timeOutLaunch)
示例#8
0
def mainLaunchMasterNaked():
    P = instanceLaunch(
        instanceNameMaster(),
        withcommondata=False, withlocaldata=False)

    utils.waitTermination([P])