Skip to content

Commit 19926aa

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 4d65098 commit 19926aa

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

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)