예제 #1
0
def instanceKill(instance_name):
    """
    Kill one instance
    """

    utils.print_header('killing ' + instance_name)

    command = 'gcloud -q compute instances ' + \
        'delete ' + instance_name

    P = utils.exec_commandAsync(command)
    return P
예제 #2
0
def instanceLaunch(instance_name,
                   commonmode='ro',
                   withcommondata=True,
                   withlocaldata=True,
                   preemptible=False):

    instanceListClean()

    utils.print_header('starting ' + instance_name)

    startupFile = getStartupFile()

    startupFileDump(
        startupFile,
        withcommondata=withcommondata, withlocaldata=withlocaldata)

    command = 'gcloud compute instances ' + \
        'create ' + instance_name + ' ' \
        '--image ' + image_name + ' ' \
        '--scopes storage-full'

    if preemptible:
        command = command + ' --preemptible'

    if withcommondata:
        command = command + \
            ' --disk name=' + diskcommonname + \
            ',device-name=sdb,mode=' + commonmode

    if withlocaldata:
        if not(useSSD):
            command = command + \
                ' --disk name=' + diskLocalDataName(instance_name) + ',' + \
                'device-name=sdc,mode=rw'
        else:
            command = command + \
                ' --local-ssd interface=SCSI'

    command = command + \
        ' --metadata-from-file startup-script={0} '.format(startupFile)

    command = command + \
        '  --machine-type ' + machinetype + ' '

    P = utils.exec_commandAsync(command)

    return P