gce_vm {googleComputeEngineR}R Documentation

Create or fetch a virtual machine

Description

Pass in the instance name to fetch its object, or create the instance via gce_vm_create.

Usage

gce_vm(name, ..., project = gce_get_global_project(),
  zone = gce_get_global_zone(), open_webports = TRUE)

Arguments

name

The name of the instance

...

Arguments passed on to gce_vm_create

image_project

Project ID of where the image lies

image

Name of the image resource to return

image_family

Name of the image family to search for

disk_source

Specifies a valid URL to an existing Persistent Disk resource.

network

The name of the network interface

externalIP

An external IP you have previously reserved, leave NULL to have one assigned or "none" for no external access.

minCpuPlatform

Specify a minimum CPU platform as per https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform

project

Project ID for this request

zone

The name of the zone for this request

dry_run

whether to just create the request JSON

disk_size_gb

If not NULL, override default size of the boot disk (size in GB)

use_beta

If set to TRUE will use the beta version of the API. Should not be used for production purposes.

acceleratorCount

Number of GPUs to add to instance. If using this, you may want to instead use gce_vm_gpu which sets some defaults for GPU instances.

acceleratorType

Name of GPU to add, see gce_list_gpus

name

The name of the resource, provided by the client when initially creating the resource

canIpForward

Allows this instance to send and receive packets with non-matching destination or source IPs

description

An optional description of this resource

metadata

A named list of metadata key/value pairs assigned to this instance

scheduling

Scheduling options for this instance, such as preemptible instances

serviceAccounts

A list of service accounts, with their specified scopes, authorized for this instance

tags

A list of tags to apply to this instance

predefined_type

A predefined machine type from gce_list_machinetype

cpus

If not defining predefined_type, the number of CPUs

memory

If not defining predefined_type, amount of memory

project

Project ID for this request

zone

The name of the zone for this request

open_webports

If TRUE, will open firewall ports 80 and 443 if not open already

Details

Will get or create the instance as specified. Will wait for instance to be created if necessary.

Make sure the instance is big enough to handle what you need, for instance the default f1-micro will hang the instance when trying to install large R libraries.

Value

A gce_instance object

Creation logic

You need these parameters defined to call the right function for creation. Check the function definitions for more details.

If the VM name exists but is not running, it start the VM and return the VM object

If the VM is running, it will return the VM object

If you specify the argument template it will call gce_vm_template

If you specify one of file or cloud_init it will call gce_vm_container

Otherwise it will call gce_vm_create

Examples


## Not run: 

library(googleComputeEngineR)
## auto auth, project and zone pre-set
## list your VMs in the project/zone

the_list <- gce_list_instances()

## start an existing instance
vm <- gce_vm("markdev")

## for rstudio, you also need to specify a username and password to login
vm <- gce_vm(template = "rstudio",
             name = "rstudio-server",
             username = "mark", password = "mark1234")

## specify your own cloud-init file and pass it into gce_vm_container()
vm <- gce_vm(cloud_init = "example.yml",
             name = "test-container",
             predefined_type = "f1-micro")

## specify disk size at creation
vm <- gce_vm('my-image3', disk_size_gb = 20)



## End(Not run)


[Package googleComputeEngineR version 0.3.0 Index]