Skip to content

Commit 2f394bf

Browse files
committed
azure: add --azure-hyper-v-generation flag
Add a new flag to allow specifying the Hyper-V generation (V1 or V2) when creating Azure images. This enables support for both Gen1 and Gen2 image creation.
1 parent 0c07cef commit 2f394bf

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

mantle/cmd/kola/kola.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ func writeProps() error {
308308
Location string `json:"location"`
309309
Size string `json:"size"`
310310
AvailabilityZone string `json:"availability_zone"`
311+
HyperVGeneration string `json:"hyper_v_generation"`
311312
}
312313
type DO struct {
313314
Region string `json:"region"`
@@ -364,6 +365,7 @@ func writeProps() error {
364365
Location: kola.AzureOptions.Location,
365366
Size: kola.AzureOptions.Size,
366367
AvailabilityZone: kola.AzureOptions.AvailabilityZone,
368+
HyperVGeneration: kola.AzureOptions.HyperVGeneration,
367369
},
368370
DO: DO{
369371
Region: kola.DOOptions.Region,

mantle/cmd/kola/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func init() {
101101
sv(&kola.AzureOptions.Location, "azure-location", "westus", "Azure location (default \"westus\"")
102102
sv(&kola.AzureOptions.Size, "azure-size", "Standard_D2_v2", "Azure machine size (default \"Standard_D2_v2\")")
103103
sv(&kola.AzureOptions.AvailabilityZone, "azure-availability-zone", "1", "Azure Availability Zone (default \"1\")")
104+
sv(&kola.AzureOptions.HyperVGeneration, "azure-hyper-v-generation", "V1", "Azure Hyper-V Generation (default \"V1\")")
104105

105106
// do-specific options
106107
sv(&kola.DOOptions.ConfigPath, "do-config-file", "", "DigitalOcean config file (default \"~/"+auth.DOConfigPath+"\")")

mantle/cmd/ore/azure/azure.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var (
3434

3535
azureCredentials string
3636
azureLocation string
37+
azureHyperVGen string
3738

3839
api *azure.API
3940
)
@@ -44,6 +45,7 @@ func init() {
4445
sv := Azure.PersistentFlags().StringVar
4546
sv(&azureCredentials, "azure-credentials", "", "Azure credentials file location (default \"~/"+auth.AzureCredentialsPath+"\")")
4647
sv(&azureLocation, "azure-location", "westus", "Azure location (default \"westus\")")
48+
sv(&azureHyperVGen, "azure-hyper-v-generation", "V1", "Azure Hypervisor Generation")
4749
}
4850

4951
func preauth(cmd *cobra.Command, args []string) error {
@@ -52,6 +54,7 @@ func preauth(cmd *cobra.Command, args []string) error {
5254
a, err := azure.New(&azure.Options{
5355
AzureCredentials: azureCredentials,
5456
Location: azureLocation,
57+
HyperVGeneration: azureHyperVGen,
5558
})
5659
if err != nil {
5760
plog.Fatalf("Failed to create Azure API: %v", err)

mantle/platform/api/azure/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (a *API) CreateImage(name, resourceGroup, blobURI string) (armcompute.Image
2828
Name: &name,
2929
Location: &a.opts.Location,
3030
Properties: &armcompute.ImageProperties{
31-
HyperVGeneration: to.Ptr(armcompute.HyperVGenerationTypesV1),
31+
HyperVGeneration: to.Ptr(armcompute.HyperVGenerationTypes(a.opts.HyperVGeneration)),
3232
StorageProfile: &armcompute.ImageStorageProfile{
3333
OSDisk: &armcompute.ImageOSDisk{
3434
OSType: to.Ptr(armcompute.OperatingSystemTypesLinux),

mantle/platform/api/azure/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type Options struct {
3333
Size string
3434
Location string
3535
AvailabilityZone string
36+
HyperVGeneration string
3637

3738
SubscriptionName string
3839
SubscriptionID string

0 commit comments

Comments
 (0)