Merge pull request #4335 from itaylor/master

Google Driver: Add support for fully qualified network and subnetwork names
This commit is contained in:
David Gageot
2018-01-28 09:50:54 -08:00
committed by GitHub
+11 -2
View File
@@ -235,6 +235,13 @@ func (c *ComputeUtil) instance() (*raw.Instance, error) {
func (c *ComputeUtil) createInstance(d *Driver) error {
log.Infof("Creating instance")
var net string
if strings.Contains(d.Network, "/networks/") {
net = d.Network
} else {
net = c.globalURL + "/networks/" + d.Network
}
instance := &raw.Instance{
Name: c.instanceName,
Description: "docker host vm",
@@ -249,7 +256,7 @@ func (c *ComputeUtil) createInstance(d *Driver) error {
},
NetworkInterfaces: []*raw.NetworkInterface{
{
Network: c.globalURL + "/networks/" + d.Network,
Network: net,
},
},
Tags: &raw.Tags{
@@ -266,7 +273,9 @@ func (c *ComputeUtil) createInstance(d *Driver) error {
},
}
if c.subnetwork != "" {
if strings.Contains(c.subnetwork, "/subnetworks/") {
instance.NetworkInterfaces[0].Subnetwork = c.subnetwork
} else if c.subnetwork != "" {
instance.NetworkInterfaces[0].Subnetwork = "projects/" + c.project + "/regions/" + c.region() + "/subnetworks/" + c.subnetwork
}