|
49 | 49 | // NICTypesFlag is the flag to specify the NIC types to use in the test. |
50 | 50 | NICTypesFlag = flag.String("networkutils_nic_types", "GVNIC:1", "NIC types. Comma separated list of <NIC_TYPE>:<COUNT>. e.g. \"GVNIC:2\" or \"GVNIC:2,MRDMA:8\". If unspecified, defaults to a single GVNIC.") |
51 | 51 |
|
| 52 | + // ProvisioningModelFlag is the flag to specify the provisioning model to use when creating |
| 53 | + // instances. |
| 54 | + ProvisioningModelFlag = flag.String("networkutils_provisioning_model", "STANDARD", "Provisioning model to use when creating instances. One of [STANDARD, SPOT]. See https://docs.cloud.google.com/compute/docs/instances/provisioning-models.") |
| 55 | + |
52 | 56 | // EthtoolDriverRe is a regex to extract the driver name from the `ethtool -i` output. |
53 | 57 | EthtoolDriverRe = regexp.MustCompile(`(?m)^driver:\s*(.*)$`) |
54 | 58 |
|
@@ -268,6 +272,16 @@ func daisySubnet(index int, zone string) (*daisy.Subnetwork, error) { |
268 | 272 | }, nil |
269 | 273 | } |
270 | 274 |
|
| 275 | +func accessConfigsForNIC(nicType string) []*compute.AccessConfig { |
| 276 | + if nicType == NICTypeIRDMA || nicType == NICTypeMRDMA { |
| 277 | + return []*compute.AccessConfig{} |
| 278 | + } |
| 279 | + return []*compute.AccessConfig{&compute.AccessConfig{ |
| 280 | + Name: "External NAT", |
| 281 | + Type: "ONE_TO_ONE_NAT", |
| 282 | + }} |
| 283 | +} |
| 284 | + |
271 | 285 | // CreateMachineWithNetworksOptions contains the options for creating a machine with multiple |
272 | 286 | // network interfaces. |
273 | 287 | type CreateMachineWithNetworksOptions struct { |
@@ -304,12 +318,18 @@ func CreateMachineWithNetworks(t *imagetest.TestWorkflow, o *CreateMachineWithNe |
304 | 318 | } |
305 | 319 |
|
306 | 320 | m.NetworkInterfaces = append(m.NetworkInterfaces, &compute.NetworkInterface{ |
307 | | - NicType: nicType, |
308 | | - Network: daisyNetwork.Name, |
309 | | - Subnetwork: daisySubnet.Name, |
| 321 | + NicType: nicType, |
| 322 | + Network: daisyNetwork.Name, |
| 323 | + Subnetwork: daisySubnet.Name, |
| 324 | + AccessConfigs: accessConfigsForNIC(nicType), |
310 | 325 | }) |
311 | 326 | } |
312 | 327 |
|
| 328 | + m.Scheduling = &compute.Scheduling{ |
| 329 | + OnHostMaintenance: imagetest.MachineMaintenancePolicy(o.MachineType), |
| 330 | + ProvisioningModel: *ProvisioningModelFlag, |
| 331 | + } |
| 332 | + |
313 | 333 | return m, nil |
314 | 334 | } |
315 | 335 |
|
|
0 commit comments