Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying subnetworks when you create a new VM #110

Closed
avidalfinsa opened this issue Aug 8, 2018 · 2 comments
Closed

Specifying subnetworks when you create a new VM #110

avidalfinsa opened this issue Aug 8, 2018 · 2 comments

Comments

@avidalfinsa
Copy link

When you create a new VM with gce_vm or gce_vm_create it is possible to define the network to use.

vm <- gce_vm(template = "rstudio", 
             name = "rstudio-server", 
             predefined_type = "f1-micro",
             network = "mynetwork",
             username = "rstudio", 
             password = "rstudio1234")

The problem is when you have defined subnetworks of this network because it returns an error like this:

2018-08-08 12:01:35> Creating template VM
Request failed [400]. Retrying in 1.2 seconds...
Request failed [400]. Retrying in 1.9 seconds...
2018-08-08 12:01:39> Request Status Code: 400
Scopes: https://www.googleapis.com/auth/cloud-platform
Method: service_json
Error: API returned: Invalid value for field 'resource.networkInterfaces[0]': ''. Subnetwork should be specified for custom subnetmode network

How is it possible to define the subnetwork to attach this VM to?

My subnetworks are like this:

  "network": "projects/myproject/global/networks/mynetwork",
  "privateIpGoogleAccess": false,
  "region": "projects/myproject/regions/europe-west1",
  "selfLink": "projects/myproject/regions/europe-west1/subnetworks/mysubnetwork"
@MarkEdmondson1234
Copy link
Collaborator

I've not come across this before so will need to check, I think the network interface part of the API has updated since the implementation below, so will look to update it.

gce_make_network <- function(name,
network = "default",
externalIP = NULL,
project = gce_get_global_project()){
make_ac <- function(externalIP, name){
if(!is.null(externalIP) && externalIP == "none") return(NULL)
list(
list(
natIP = jsonlite::unbox(externalIP),
type = jsonlite::unbox("ONE_TO_ONE_NAT"),
name = jsonlite::unbox(name)
)
)
}
net <- gce_get_network(network, project = project)
structure(
list(
list(
network = jsonlite::unbox(net$selfLink),
accessConfigs = make_ac(externalIP, name)
)
),
class = c("gce_networkInterface", "list")
)
}

@MarkEdmondson1234
Copy link
Collaborator

This should be fixed now in latest github version #154

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants