Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

[Drivers/Azure] Now able to specify a priority to VMs #4536

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion drivers/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const (
flAzureDockerPort = "azure-docker-port"
flAzureLocation = "azure-location"
flAzureSize = "azure-size"
flAzurePriority = "azure-priority"
flAzureEvictionPolicy = "azure-evictionPolicy"
flAzureImage = "azure-image"
flAzureVNet = "azure-vnet"
flAzureSubnet = "azure-subnet"
Expand Down Expand Up @@ -77,6 +79,8 @@ type Driver struct {
DockerPort int
Location string
Size string
Priority string
EvictionPolicy string
Image string
VirtualNetwork string
SubnetName string
Expand Down Expand Up @@ -157,6 +161,16 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
EnvVar: "AZURE_SIZE",
Value: defaultAzureSize,
},
mcnflag.StringFlag{
Name: flAzurePriority,
Usage: "Priority for Azure Virtual Machine",
EnvVar: "AZURE_PRIORITY",
},
mcnflag.StringFlag{
Name: flAzureEvictionPolicy,
Usage: "Eviction Policy for Azure Virtual Machine",
EnvVar: "AZURE_EVICTION_POLICY",
},
mcnflag.StringFlag{
Name: flAzureImage,
Usage: "Azure virtual machine OS image",
Expand Down Expand Up @@ -267,6 +281,8 @@ func (d *Driver) SetConfigFromFlags(fl drivers.DriverOptions) error {
}

// Optional flags or Flags of other types
d.Priority = fl.String(flAzurePriority)
d.EvictionPolicy = fl.String(flAzureEvictionPolicy)
d.Environment = fl.String(flAzureEnvironment)
d.OpenPorts = fl.StringSlice(flAzurePorts)
d.PrivateIPAddr = fl.String(flAzurePrivateIPAddr)
Expand Down Expand Up @@ -390,7 +406,7 @@ func (d *Driver) Create() error {
if err := d.generateSSHKey(d.ctx); err != nil {
return err
}
err = c.CreateVirtualMachine(d.ResourceGroup, d.naming().VM(), d.Location, d.Size, d.ctx.AvailabilitySetID,
err = c.CreateVirtualMachine(d.ResourceGroup, d.naming().VM(), d.Location, d.Size, d.Priority, d.EvictionPolicy, d.ctx.AvailabilitySetID,
d.ctx.NetworkInterfaceID, d.BaseDriver.SSHUser, d.ctx.SSHPublicKey, d.Image, customData, d.ctx.StorageAccount)
return err
}
Expand Down
16 changes: 10 additions & 6 deletions drivers/azure/azureutil/azureutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,16 @@ func (a AzureClient) removeOSDiskBlob(resourceGroup, vmName, vhdURL string) erro
return err
}

func (a AzureClient) CreateVirtualMachine(resourceGroup, name, location, size, availabilitySetID, networkInterfaceID,
func (a AzureClient) CreateVirtualMachine(resourceGroup, name, location, size, priority, evictionPolicy, availabilitySetID, networkInterfaceID,
username, sshPublicKey, imageName, customData string, storageAccount *storage.AccountProperties) error {
log.Info("Creating virtual machine.", logutil.Fields{
"name": name,
"location": location,
"size": size,
"username": username,
"osImage": imageName,
"name": name,
"location": location,
"size": size,
"username": username,
"osImage": imageName,
"priority": priority,
"evictionPolicy": evictionPolicy,
})

img, err := parseImageName(imageName)
Expand Down Expand Up @@ -557,6 +559,8 @@ func (a AzureClient) CreateVirtualMachine(resourceGroup, name, location, size, a
},
OsProfile: osProfile,
StorageProfile: &compute.StorageProfile{
Priority: to.StringPtr(priority),
EvictionPolicy: to.StringPtr(evictionPolicy),
ImageReference: &compute.ImageReference{
Publisher: to.StringPtr(img.publisher),
Offer: to.StringPtr(img.offer),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.