'Helper function for make_image_tarball that does the work.
Note that the work happens on the instance itself. So this function
builds a remote command that it then executes on the prototype instance.'

def __extract_image_tarball_helper(self):

    print 'Creating    image    tarball.'
    tar_path = self.options.tarball_uri
    tar_name = os.path.basename(tar_path)
    remote_script = ['sudo    mkdir    /mnt/exportdisk', 'sudo    mkfs.ext4    -F    /dev/disk/by-id/google-export-disk', 'sudo    mount    -t    ext4    -o    discard,defaults    /dev/disk/by-id/google-export-disk    /mnt/exportdisk', 'sudo    mkdir    /mnt/snapshotdisk', 'sudo    mount    /dev/disk/by-id/google-snapshot-disk    /mnt/snapshotdisk', 'cd    /mnt/snapshotdisk', 'sudo    rm    -rf    home/*', 'sudo    rm    -rf    tmp/*', 'if    [[    -f    root/.ssh/authorized_keys    ]];    then    sudo    cat    /dev/null    >    root/.ssh/authorized_keys;    fi', 'sudo    find    var/log    -type    f    -exec    rm    {}    \\;', 'sudo    dd    if=/dev/disk/by-id/google-snapshot-disk    of=/mnt/exportdisk/disk.raw    bs=4096', 'cd    /mnt/exportdisk', 'sudo    tar    czvf    {tar_name}    disk.raw'.format(tar_name=tar_name), 'gsutil    -q    cp    /mnt/exportdisk/{tar_name}    {output_path}'.format(tar_name=tar_name, output_path=tar_path)]
    command = ';    '.join(remote_script)
    print 'Running:    {0}'.format(command)
    check_run_quick('gcloud    {account}    compute    ssh    --command="{command}"    --project    {project}    --zone    {zone}    {instance}'.format(account=self.__gcloud_account_arg, command=command.replace('"', '\\"'), project=self.__project, zone=self.__zone, instance=self.__instance))
