From 0a3c8629df65cfea4a22853b2bf07e019ed91446 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Tue, 10 Aug 2021 16:14:04 +0530 Subject: [PATCH 1/7] Add table azure_compute_machine_scale_set closes #190 --- .../test-get-expected.json | 11 + .../test-get-query.sql | 3 + .../test-hydrate-expected.json | 7 + .../test-hydrate-query.sql | 3 + .../test-list-expected.json | 6 + .../test-list-query.sql | 3 + .../test-not-found-expected.json | 1 + .../test-not-found-query.sql | 3 + .../test-turbot-expected.json | 12 + .../test-turbot-query.sql | 3 + .../varable.tf | 170 +++++++++++ .../variables.json | 1 + azure/plugin.go | 1 + .../table_azure_virtual_machine_scale_set.go | 267 ++++++++++++++++++ .../tables/azure_virtual_machine_scale_set.md | 32 +++ 15 files changed, 523 insertions(+) create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/test-get-expected.json create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/test-get-query.sql create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-expected.json create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-query.sql create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/test-list-expected.json create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/test-list-query.sql create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/test-not-found-expected.json create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/test-not-found-query.sql create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/test-turbot-expected.json create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/test-turbot-query.sql create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/varable.tf create mode 100644 azure-test/tests/azure_virtual_machine_scale_set/variables.json create mode 100644 azure/table_azure_virtual_machine_scale_set.go create mode 100644 docs/tables/azure_virtual_machine_scale_set.md diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-get-expected.json b/azure-test/tests/azure_virtual_machine_scale_set/test-get-expected.json new file mode 100644 index 00000000..e97e1d89 --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/test-get-expected.json @@ -0,0 +1,11 @@ +[ + { + "id": "{{ output.resource_id.value }}", + "name": "{{ resourceName }}", + "sku_name": "Standard_F2", + "sku_tier": "Standard", + "tags": { + "Name": "{{ resourceName }}" + } + } +] \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-get-query.sql b/azure-test/tests/azure_virtual_machine_scale_set/test-get-query.sql new file mode 100644 index 00000000..ea4cf43d --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/test-get-query.sql @@ -0,0 +1,3 @@ +select name, id, sku_tier, sku_name, tags +from azure.azure_virtual_machine_scale_set +where name = '{{resourceName}}' and resource_group = '{{resourceName}}'; \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-expected.json b/azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-expected.json new file mode 100644 index 00000000..ac70494c --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-expected.json @@ -0,0 +1,7 @@ +[ + { + "id": "{{ output.resource_id.value }}", + "name": "{{ resourceName }}", + "type": "Microsoft.Compute/virtualMachineScaleSets" + } +] \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-query.sql b/azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-query.sql new file mode 100644 index 00000000..9bbac21b --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-query.sql @@ -0,0 +1,3 @@ +select name, id, type +from azure.azure_virtual_machine_scale_set +where name = '{{resourceName}}' and resource_group = '{{resourceName}}'; \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-list-expected.json b/azure-test/tests/azure_virtual_machine_scale_set/test-list-expected.json new file mode 100644 index 00000000..f2d090cd --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/test-list-expected.json @@ -0,0 +1,6 @@ +[ + { + "id": "{{ output.resource_id.value }}", + "name": "{{ resourceName }}" + } +] \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-list-query.sql b/azure-test/tests/azure_virtual_machine_scale_set/test-list-query.sql new file mode 100644 index 00000000..d3d3a107 --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/test-list-query.sql @@ -0,0 +1,3 @@ +select name, id +from azure.azure_virtual_machine_scale_set +where id = '{{ output.resource_id.value }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-not-found-expected.json b/azure-test/tests/azure_virtual_machine_scale_set/test-not-found-expected.json new file mode 100644 index 00000000..ec747fa4 --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/test-not-found-expected.json @@ -0,0 +1 @@ +null \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-not-found-query.sql b/azure-test/tests/azure_virtual_machine_scale_set/test-not-found-query.sql new file mode 100644 index 00000000..012bb404 --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/test-not-found-query.sql @@ -0,0 +1,3 @@ +select name, id +from azure.azure_virtual_machine_scale_set +where name = 'dummy{{ resourceName }}' and resource_group = '{{ resourceName }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-turbot-expected.json b/azure-test/tests/azure_virtual_machine_scale_set/test-turbot-expected.json new file mode 100644 index 00000000..9439d764 --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/test-turbot-expected.json @@ -0,0 +1,12 @@ +[ + { + "akas": [ + "{{ output.resource_aka.value }}", + "{{ output.resource_aka_lower.value }}" + ], + "tags": { + "Name": "{{ resourceName }}" + }, + "title": "{{ resourceName }}" + } +] \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-turbot-query.sql b/azure-test/tests/azure_virtual_machine_scale_set/test-turbot-query.sql new file mode 100644 index 00000000..f2bdb636 --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/test-turbot-query.sql @@ -0,0 +1,3 @@ +select title, akas, tags +from azure.azure_virtual_machine_scale_set +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/varable.tf b/azure-test/tests/azure_virtual_machine_scale_set/varable.tf new file mode 100644 index 00000000..95df9028 --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/varable.tf @@ -0,0 +1,170 @@ + +variable "resource_name" { + type = string + default = "turbot-test-20200125-create-update" + description = "Name of the resource used throughout the test." +} + +variable "azure_environment" { + type = string + default = "public" + description = "Azure environment used for the test." +} + +variable "azure_subscription" { + type = string + default = "3510ae4d-530b-497d-8f30-53b9616fc6c1" + description = "Azure subscription used for the test." +} + +provider "azurerm" { + # Cannot be passed as a variable + version = "=1.36.0" + environment = var.azure_environment + subscription_id = var.azure_subscription +} + +data "azurerm_client_config" "current" {} + +data "null_data_source" "resource" { + inputs = { + scope = "azure:///subscriptions/${data.azurerm_client_config.current.subscription_id}" + } +} + +resource "azurerm_resource_group" "named_test_resource" { + name = var.resource_name + location = "East US" +} + +resource "azurerm_virtual_network" "named_test_resource" { + name = var.resource_name + address_space = ["10.0.0.0/16"] + location = azurerm_resource_group.named_test_resource.location + resource_group_name = azurerm_resource_group.named_test_resource.name +} + +resource "azurerm_subnet" "named_test_resource" { + name = var.resource_name + resource_group_name = azurerm_resource_group.named_test_resource.name + virtual_network_name = azurerm_virtual_network.named_test_resource.name + address_prefix = "10.0.2.0/24" +} + +resource "azurerm_public_ip" "named_test_resource" { + name = var.resource_name + location = azurerm_resource_group.named_test_resource.location + resource_group_name = azurerm_resource_group.named_test_resource.name + allocation_method = "Static" + domain_name_label = azurerm_resource_group.named_test_resource.name + + tags = { + Name = var.resource_name + } +} + +resource "azurerm_lb" "named_test_resource" { + name = var.resource_name + location = azurerm_resource_group.named_test_resource.location + resource_group_name = azurerm_resource_group.named_test_resource.name + + frontend_ip_configuration { + name = "PublicIPAddress" + public_ip_address_id = azurerm_public_ip.named_test_resource.id + } +} + +resource "azurerm_lb_backend_address_pool" "named_test_resource" { + resource_group_name = azurerm_resource_group.named_test_resource.name + loadbalancer_id = azurerm_lb.named_test_resource.id + name = var.resource_name +} + +resource "azurerm_lb_nat_pool" "named_test_resource" { + resource_group_name = azurerm_resource_group.named_test_resource.name + name = "ssh" + loadbalancer_id = azurerm_lb.named_test_resource.id + protocol = "Tcp" + frontend_port_start = 50000 + frontend_port_end = 50119 + backend_port = 22 + frontend_ip_configuration_name = "PublicIPAddress" +} + +resource "azurerm_virtual_machine_scale_set" "named_test_resource" { + name = var.resource_name + location = azurerm_resource_group.named_test_resource.location + resource_group_name = azurerm_resource_group.named_test_resource.name + + upgrade_policy_mode = "Manual" + + sku { + name = "Standard_F2" + tier = "Standard" + capacity = 2 + } + + storage_profile_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "16.04-LTS" + version = "latest" + } + + storage_profile_os_disk { + name = "" + caching = "ReadWrite" + create_option = "FromImage" + managed_disk_type = "Standard_LRS" + } + + storage_profile_data_disk { + lun = 0 + caching = "ReadWrite" + create_option = "Empty" + disk_size_gb = 10 + } + + os_profile { + computer_name_prefix = "testvm" + admin_username = "myadmin" + admin_password = "AdminPassword@123" + } + + os_profile_linux_config { + disable_password_authentication = false + } + + network_profile { + name = "terraformnetworkprofile" + primary = true + + ip_configuration { + name = "TestIPConfiguration" + primary = true + subnet_id = azurerm_subnet.named_test_resource.id + load_balancer_backend_address_pool_ids = [azurerm_lb_backend_address_pool.named_test_resource.id] + load_balancer_inbound_nat_rules_ids = [azurerm_lb_nat_pool.named_test_resource.id] + } + } + + tags = { + Name = var.resource_name + } +} + +output "resource_aka" { + value = "azure://${azurerm_virtual_machine_scale_set.named_test_resource.id}" +} + +output "resource_aka_lower" { + value = "azure://${lower(azurerm_virtual_machine_scale_set.named_test_resource.id)}" +} + +output "resource_name" { + value = var.resource_name +} + +output "resource_id" { + value = azurerm_virtual_machine_scale_set.named_test_resource.id +} \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/variables.json b/azure-test/tests/azure_virtual_machine_scale_set/variables.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/azure-test/tests/azure_virtual_machine_scale_set/variables.json @@ -0,0 +1 @@ +{} diff --git a/azure/plugin.go b/azure/plugin.go index 57bd3cd9..82599d58 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -103,6 +103,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_subnet": tableAzureSubnet(ctx), "azure_subscription": tableAzureSubscription(ctx), "azure_tenant": tableAzureTenant(ctx), + "azure_virtual_machine_scale_set": tableAzureVirtualMachineScaleSet(ctx), "azure_virtual_network": tableAzureVirtualNetwork(ctx), "azure_virtual_network_gateway": tableAzureVirtualNetworkGateway(ctx), // "azure_storage_table": tableAzureStorageTable(ctx), diff --git a/azure/table_azure_virtual_machine_scale_set.go b/azure/table_azure_virtual_machine_scale_set.go new file mode 100644 index 00000000..03e881a0 --- /dev/null +++ b/azure/table_azure_virtual_machine_scale_set.go @@ -0,0 +1,267 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableAzureVirtualMachineScaleSet(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_virtual_machine_scale_set", + Description: "Azure Virtual Machine Scale Set", + Get: &plugin.GetConfig{ + KeyColumns: plugin.AllColumns([]string{"name", "resource_group"}), + Hydrate: getAzureVirtualMachineScaleSet, + ShouldIgnoreError: isNotFoundError([]string{"ResourceGroupNotFound", "ResourceNotFound", "404"}), + }, + List: &plugin.ListConfig{ + Hydrate: listAzureVirtualMachineScaleSets, + }, + Columns: []*plugin.Column{ + { + Name: "name", + Description: "Name of the scale set.", + Type: proto.ColumnType_STRING, + }, + { + Name: "id", + Description: "The unique id identifying the resource in subscription.", + Type: proto.ColumnType_STRING, + Transform: transform.FromGo(), + }, + { + Name: "type", + Description: "The type of the resource in Azure.", + Type: proto.ColumnType_STRING, + }, + { + Name: "location", + Description: "The location of the resource.", + Type: proto.ColumnType_STRING, + }, + { + Name: "single_placement_group", + Description: "When true this limits the scale set to a single placement group, of max size 100 virtual machines.", + Type: proto.ColumnType_BOOL, + Transform: transform.FromField("VirtualMachineScaleSetProperties.SinglePlacementGroup"), + }, + { + Name: "provisioning_state", + Description: "The provisioning state.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("VirtualMachineScaleSetProperties.ProvisioningState"), + }, + { + Name: "overprovision", + Description: "Specifies whether the Virtual Machine Scale Set should be overprovisioned.", + Type: proto.ColumnType_BOOL, + Transform: transform.FromField("VirtualMachineScaleSetProperties.Overprovision"), + }, + { + Name: "do_not_run_extensions_on_overprovisioned_vms", + Description: "When Overprovision is enabled, extensions are launched only on the requested number of VMs which are finally kept.", + Type: proto.ColumnType_BOOL, + Transform: transform.FromField("VirtualMachineScaleSetProperties.DoNotRunExtensionsOnOverprovisionedVMs"), + }, + { + Name: "unique_id", + Description: "Specifies the ID which uniquely identifies a Virtual Machine Scale Set.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("VirtualMachineScaleSetProperties.UniqueID"), + }, + { + Name: "platform_fault_domain_count", + Description: "Fault Domain count for each placement group.", + Type: proto.ColumnType_INT, + Transform: transform.FromField("VirtualMachineScaleSetProperties.PlatformFaultDomainCount"), + }, + { + Name: "sku_name", + Description: "The sku name.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Sku.Name"), + }, + { + Name: "sku_tier", + Description: "Specifies the tier of virtual machines in a scale set.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Sku.Tier"), + }, + { + Name: "sku_capacity", + Description: "Specifies the tier of virtual machines in a scale set.", + Type: proto.ColumnType_INT, + Transform: transform.FromField("Sku.Capacity"), + }, + { + Name: "plan", + Description: "Specifies information about the marketplace image used to create the virtual machine.", + Type: proto.ColumnType_JSON, + }, + { + Name: "zones", + Description: "The Logical zone list for scale set.", + Type: proto.ColumnType_JSON, + }, + { + Name: "identity", + Description: "The identity of the virtual machine scale set, if configured.", + Type: proto.ColumnType_JSON, + }, + { + Name: "virtual_machine_os_profile", + Description: "Specifies the operating system settings for the virtual machines in the scale set.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.OsProfile"), + }, + { + Name: "virtual_machine_storage_profile", + Description: "Specifies the storage settings for the virtual machine disks.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.StorageProfile"), + }, + { + Name: "virtual_machine_network_profile", + Description: "Specifies properties of the network interfaces of the virtual machines in the scale set.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.NetworkProfile"), + }, + { + Name: "virtual_machine_security_profile", + Description: "Specifies the Security related profile settings for the virtual machines in the scale set.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.SecurityProfile"), + }, + { + Name: "virtual_machine_diagnostics_profile", + Description: "Specifies the boot diagnostic settings state.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.DiagnosticsProfile"), + }, + { + Name: "virtual_machine_extension_profile", + Description: "Specifies a collection of settings for extensions installed on virtual machines in the scale set.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.ExtensionProfile"), + }, + { + Name: "upgrade_policy", + Description: "The upgrade policy for the scale set.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineScaleSetProperties.UpgradePolicy"), + }, + { + Name: "scale_in_policy", + Description: "Specifies the scale-in policy that decides which virtual machines are chosen for removal when a Virtual Machine Scale Set is scaled-in.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineScaleSetProperties.ScaleInPolicy"), + }, + { + Name: "tags_src", + Description: "Resource tags.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("Tags"), + }, + + // Standard columns + { + Name: "title", + Description: ColumnDescriptionTitle, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Name"), + }, + { + Name: "tags", + Description: ColumnDescriptionTags, + Type: proto.ColumnType_JSON, + }, + { + Name: "akas", + Description: ColumnDescriptionAkas, + Type: proto.ColumnType_JSON, + Transform: transform.FromField("ID").Transform(idToAkas), + }, + { + Name: "region", + Description: ColumnDescriptionRegion, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Location").Transform(toLower), + }, + { + Name: "resource_group", + Description: ColumnDescriptionResourceGroup, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ID").Transform(extractResourceGroupFromID), + }, + { + Name: "subscription_id", + Description: ColumnDescriptionSubscription, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ID").Transform(idToSubscriptionID), + }, + }, + } +} + +//// LIST FUNCTION + +func listAzureVirtualMachineScaleSets(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("listAzureVirtualMachineScaleSet") + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + + subscriptionID := session.SubscriptionID + client := compute.NewVirtualMachineScaleSetsClient(subscriptionID) + client.Authorizer = session.Authorizer + pagesLeft := true + + for pagesLeft { + result, err := client.ListAll(context.Background()) + if err != nil { + return nil, err + } + + for _, scaleSet := range result.Values() { + d.StreamListItem(ctx, scaleSet) + } + result.NextWithContext(context.Background()) + pagesLeft = result.NotDone() + } + return nil, nil +} + +//// HYDRATE FUNCTION + +func getAzureVirtualMachineScaleSet(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("getAzureVirtualMachineScaleSet") + + name := d.KeyColumnQuals["name"].GetStringValue() + resourceGroup := d.KeyColumnQuals["resource_group"].GetStringValue() + + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + subscriptionID := session.SubscriptionID + client := compute.NewVirtualMachineScaleSetsClient(subscriptionID) + client.Authorizer = session.Authorizer + + op, err := client.Get(context.Background(), resourceGroup, name) + if err != nil { + return nil, err + } + + if op.ID != nil { + return op, nil + } + + return nil, nil +} diff --git a/docs/tables/azure_virtual_machine_scale_set.md b/docs/tables/azure_virtual_machine_scale_set.md new file mode 100644 index 00000000..d813feda --- /dev/null +++ b/docs/tables/azure_virtual_machine_scale_set.md @@ -0,0 +1,32 @@ +# Table: azure_virtual_machine_scale_set + +A virtual network gateway is used to establish secure, cross-premises connectivity. + +## Examples + +### Basic info + +```sql +select + name, + id, + identity, + region, + resource_group +from + azure_virtual_machine_scale_set; +``` + +### List Standard tier virtual machine scale set + +```sql +select + name, + id, + sku_name, + sku_tier +from + azure_virtual_machine_scale_set +where + sku_tier = 'Standard'; +``` From 225a3b071574a76b6738e046f9556f3788c7247e Mon Sep 17 00:00:00 2001 From: ParthaI Date: Wed, 11 Aug 2021 15:48:10 +0530 Subject: [PATCH 2/7] Added extension details to table --- .../table_azure_virtual_machine_scale_set.go | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/azure/table_azure_virtual_machine_scale_set.go b/azure/table_azure_virtual_machine_scale_set.go index 03e881a0..90e91f3d 100644 --- a/azure/table_azure_virtual_machine_scale_set.go +++ b/azure/table_azure_virtual_machine_scale_set.go @@ -2,6 +2,7 @@ package azure import ( "context" + "strings" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" @@ -99,6 +100,13 @@ func tableAzureVirtualMachineScaleSet(_ context.Context) *plugin.Table { Type: proto.ColumnType_INT, Transform: transform.FromField("Sku.Capacity"), }, + { + Name: "extensions", + Description: "Specifies the details of VM Scale Set Extensions.", + Type: proto.ColumnType_JSON, + Hydrate: getAzureComputeVirtualMachineScalesetExtensions, + Transform: transform.FromValue(), + }, { Name: "plan", Description: "Specifies information about the marketplace image used to create the virtual machine.", @@ -265,3 +273,46 @@ func getAzureVirtualMachineScaleSet(ctx context.Context, d *plugin.QueryData, h return nil, nil } + +func getAzureComputeVirtualMachineScalesetExtensions(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("getAzureComputeVirtualMachineScalesetExtensions") + + virtualMachineScaleSet := h.Item.(compute.VirtualMachineScaleSet) + resourceGroupName := strings.Split(string(*virtualMachineScaleSet.ID), "/")[4] + + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + subscriptionID := session.SubscriptionID + client := compute.NewVirtualMachineScaleSetExtensionsClient(subscriptionID) + client.Authorizer = session.Authorizer + + op, err := client.List(context.Background(), resourceGroupName, *virtualMachineScaleSet.Name) + if err != nil { + return nil, err + } + + // If we return the API response directly, the output only gives the contents of VirtualMachineScaleSetExtensionsListResult + var extensions []map[string]interface{} + + for _, extension := range op.Values() { + extensionMap := make(map[string]interface{}) + extensionMap["Id"] = extension.ID + extensionMap["Name"] = extension.Name + extensionMap["Type"] = extension.Type + extensionMap["ProvisionAfterExtensions"] = extension.ProvisionAfterExtensions + extensionMap["Publisher"] = extension.VirtualMachineScaleSetExtensionProperties.Publisher + extensionMap["ExtensionType"] = extension.VirtualMachineScaleSetExtensionProperties.Type + extensionMap["TypeHandlerVersion"] = extension.VirtualMachineScaleSetExtensionProperties.TypeHandlerVersion + extensionMap["AutoUpgradeMinorVersion"] = extension.VirtualMachineScaleSetExtensionProperties.AutoUpgradeMinorVersion + extensionMap["EnableAutomaticUpgrade"] = extension.VirtualMachineScaleSetExtensionProperties.EnableAutomaticUpgrade + extensionMap["ForceUpdateTag"] = extension.VirtualMachineScaleSetExtensionProperties.ForceUpdateTag + extensionMap["Settings"] = extension.VirtualMachineScaleSetExtensionProperties.Settings + extensionMap["ProtectedSettings"] = extension.VirtualMachineScaleSetExtensionProperties.ProtectedSettings + extensionMap["ProvisioningState"] = extension.VirtualMachineScaleSetExtensionProperties.ProvisioningState + plugin.Logger(ctx).Trace("Extensions ==>", extensionMap) + extensions = append(extensions, extensionMap) + } + return extensions, nil +} From 525286fe68dba2f2250686ac173ee17b622146e8 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Wed, 11 Aug 2021 17:10:59 +0530 Subject: [PATCH 3/7] Updated the document --- .../table_azure_virtual_machine_scale_set.go | 20 +++++++++++++------ .../tables/azure_virtual_machine_scale_set.md | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/azure/table_azure_virtual_machine_scale_set.go b/azure/table_azure_virtual_machine_scale_set.go index 90e91f3d..4f6d2933 100644 --- a/azure/table_azure_virtual_machine_scale_set.go +++ b/azure/table_azure_virtual_machine_scale_set.go @@ -229,19 +229,23 @@ func listAzureVirtualMachineScaleSets(ctx context.Context, d *plugin.QueryData, subscriptionID := session.SubscriptionID client := compute.NewVirtualMachineScaleSetsClient(subscriptionID) client.Authorizer = session.Authorizer - pagesLeft := true - for pagesLeft { - result, err := client.ListAll(context.Background()) + result, err := client.ListAll(context.Background()) + if err != nil { + return nil, err + } + + for _, scaleSet := range result.Values() { + d.StreamListItem(ctx, scaleSet) + } + for result.NotDone() { + err = result.NextWithContext(ctx) if err != nil { return nil, err } - for _, scaleSet := range result.Values() { d.StreamListItem(ctx, scaleSet) } - result.NextWithContext(context.Background()) - pagesLeft = result.NotDone() } return nil, nil } @@ -254,6 +258,10 @@ func getAzureVirtualMachineScaleSet(ctx context.Context, d *plugin.QueryData, h name := d.KeyColumnQuals["name"].GetStringValue() resourceGroup := d.KeyColumnQuals["resource_group"].GetStringValue() + if name == "" || resourceGroup == "" { + return nil, nil + } + session, err := GetNewSession(ctx, d, "MANAGEMENT") if err != nil { return nil, err diff --git a/docs/tables/azure_virtual_machine_scale_set.md b/docs/tables/azure_virtual_machine_scale_set.md index d813feda..b4089fef 100644 --- a/docs/tables/azure_virtual_machine_scale_set.md +++ b/docs/tables/azure_virtual_machine_scale_set.md @@ -1,6 +1,6 @@ # Table: azure_virtual_machine_scale_set -A virtual network gateway is used to establish secure, cross-premises connectivity. +Azure virtual machine scale sets let you create and manage a group of load balanced VMs. The number of VM instances can automatically increase or decrease in response to demand or a defined schedule. Scale sets provide high availability to your applications, and allow you to centrally manage, configure, and update a large number of VMs. ## Examples From d9acbb12471f604c3d1341c041f5c6b5989403fd Mon Sep 17 00:00:00 2001 From: ParthaI Date: Wed, 11 Aug 2021 18:17:02 +0530 Subject: [PATCH 4/7] Updated the table name from azure_virtual_machine_scale_set to azure_compute_virtual_machine_scale_set --- .../test-get-expected.json | 0 .../test-get-query.sql | 2 +- .../test-hydrate-expected.json | 0 .../test-hydrate-query.sql | 2 +- .../test-list-expected.json | 0 .../test-list-query.sql | 2 +- .../test-not-found-expected.json | 0 .../test-not-found-query.sql | 2 +- .../test-turbot-expected.json | 0 .../test-turbot-query.sql | 2 +- .../varable.tf | 0 .../variables.json | 0 azure/plugin.go | 2 +- ...azure_compute_virtual_machine_scale_set.go} | 18 +++++++++--------- ...azure_compute_virtual_machine_scale_set.md} | 6 +++--- 15 files changed, 18 insertions(+), 18 deletions(-) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/test-get-expected.json (100%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/test-get-query.sql (69%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/test-hydrate-expected.json (100%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/test-hydrate-query.sql (64%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/test-list-expected.json (100%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/test-list-query.sql (54%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/test-not-found-expected.json (100%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/test-not-found-query.sql (65%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/test-turbot-expected.json (100%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/test-turbot-query.sql (66%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/varable.tf (100%) rename azure-test/tests/{azure_virtual_machine_scale_set => azure_compute_virtual_machine_scale_set}/variables.json (100%) rename azure/{table_azure_virtual_machine_scale_set.go => table_azure_compute_virtual_machine_scale_set.go} (94%) rename docs/tables/{azure_virtual_machine_scale_set.md => azure_compute_virtual_machine_scale_set.md} (81%) diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-get-expected.json b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-get-expected.json similarity index 100% rename from azure-test/tests/azure_virtual_machine_scale_set/test-get-expected.json rename to azure-test/tests/azure_compute_virtual_machine_scale_set/test-get-expected.json diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-get-query.sql b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-get-query.sql similarity index 69% rename from azure-test/tests/azure_virtual_machine_scale_set/test-get-query.sql rename to azure-test/tests/azure_compute_virtual_machine_scale_set/test-get-query.sql index ea4cf43d..56a976a1 100644 --- a/azure-test/tests/azure_virtual_machine_scale_set/test-get-query.sql +++ b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-get-query.sql @@ -1,3 +1,3 @@ select name, id, sku_tier, sku_name, tags -from azure.azure_virtual_machine_scale_set +from azure.azure_compute_virtual_machine_scale_set where name = '{{resourceName}}' and resource_group = '{{resourceName}}'; \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-expected.json b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-hydrate-expected.json similarity index 100% rename from azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-expected.json rename to azure-test/tests/azure_compute_virtual_machine_scale_set/test-hydrate-expected.json diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-query.sql b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-hydrate-query.sql similarity index 64% rename from azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-query.sql rename to azure-test/tests/azure_compute_virtual_machine_scale_set/test-hydrate-query.sql index 9bbac21b..286647cc 100644 --- a/azure-test/tests/azure_virtual_machine_scale_set/test-hydrate-query.sql +++ b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-hydrate-query.sql @@ -1,3 +1,3 @@ select name, id, type -from azure.azure_virtual_machine_scale_set +from azure.azure_compute_virtual_machine_scale_set where name = '{{resourceName}}' and resource_group = '{{resourceName}}'; \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-list-expected.json b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-list-expected.json similarity index 100% rename from azure-test/tests/azure_virtual_machine_scale_set/test-list-expected.json rename to azure-test/tests/azure_compute_virtual_machine_scale_set/test-list-expected.json diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-list-query.sql b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-list-query.sql similarity index 54% rename from azure-test/tests/azure_virtual_machine_scale_set/test-list-query.sql rename to azure-test/tests/azure_compute_virtual_machine_scale_set/test-list-query.sql index d3d3a107..7ce5892e 100644 --- a/azure-test/tests/azure_virtual_machine_scale_set/test-list-query.sql +++ b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-list-query.sql @@ -1,3 +1,3 @@ select name, id -from azure.azure_virtual_machine_scale_set +from azure.azure_compute_virtual_machine_scale_set where id = '{{ output.resource_id.value }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-not-found-expected.json b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-not-found-expected.json similarity index 100% rename from azure-test/tests/azure_virtual_machine_scale_set/test-not-found-expected.json rename to azure-test/tests/azure_compute_virtual_machine_scale_set/test-not-found-expected.json diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-not-found-query.sql b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-not-found-query.sql similarity index 65% rename from azure-test/tests/azure_virtual_machine_scale_set/test-not-found-query.sql rename to azure-test/tests/azure_compute_virtual_machine_scale_set/test-not-found-query.sql index 012bb404..9a3a6bd3 100644 --- a/azure-test/tests/azure_virtual_machine_scale_set/test-not-found-query.sql +++ b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-not-found-query.sql @@ -1,3 +1,3 @@ select name, id -from azure.azure_virtual_machine_scale_set +from azure.azure_compute_virtual_machine_scale_set where name = 'dummy{{ resourceName }}' and resource_group = '{{ resourceName }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-turbot-expected.json b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-turbot-expected.json similarity index 100% rename from azure-test/tests/azure_virtual_machine_scale_set/test-turbot-expected.json rename to azure-test/tests/azure_compute_virtual_machine_scale_set/test-turbot-expected.json diff --git a/azure-test/tests/azure_virtual_machine_scale_set/test-turbot-query.sql b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-turbot-query.sql similarity index 66% rename from azure-test/tests/azure_virtual_machine_scale_set/test-turbot-query.sql rename to azure-test/tests/azure_compute_virtual_machine_scale_set/test-turbot-query.sql index f2bdb636..19d56244 100644 --- a/azure-test/tests/azure_virtual_machine_scale_set/test-turbot-query.sql +++ b/azure-test/tests/azure_compute_virtual_machine_scale_set/test-turbot-query.sql @@ -1,3 +1,3 @@ select title, akas, tags -from azure.azure_virtual_machine_scale_set +from azure.azure_compute_virtual_machine_scale_set where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_virtual_machine_scale_set/varable.tf b/azure-test/tests/azure_compute_virtual_machine_scale_set/varable.tf similarity index 100% rename from azure-test/tests/azure_virtual_machine_scale_set/varable.tf rename to azure-test/tests/azure_compute_virtual_machine_scale_set/varable.tf diff --git a/azure-test/tests/azure_virtual_machine_scale_set/variables.json b/azure-test/tests/azure_compute_virtual_machine_scale_set/variables.json similarity index 100% rename from azure-test/tests/azure_virtual_machine_scale_set/variables.json rename to azure-test/tests/azure_compute_virtual_machine_scale_set/variables.json diff --git a/azure/plugin.go b/azure/plugin.go index 8022eab2..268f5ce1 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -48,6 +48,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_compute_virtual_machine_metric_cpu_utilization": tableAzureComputeVirtualMachineMetricCpuUtilization(ctx), "azure_compute_virtual_machine_metric_cpu_utilization_daily": tableAzureComputeVirtualMachineMetricCpuUtilizationDaily(ctx), "azure_compute_virtual_machine_metric_cpu_utilization_hourly": tableAzureComputeVirtualMachineMetricCpuUtilizationHourly(ctx), + "azure_compute_virtual_machine_scale_set": tableAzureComputeVirtualMachineScaleSet(ctx), "azure_container_registry": tableAzureContainerRegistry(ctx), "azure_cosmosdb_account": tableAzureCosmosDBAccount(ctx), "azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx), @@ -107,7 +108,6 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_subnet": tableAzureSubnet(ctx), "azure_subscription": tableAzureSubscription(ctx), "azure_tenant": tableAzureTenant(ctx), - "azure_virtual_machine_scale_set": tableAzureVirtualMachineScaleSet(ctx), "azure_virtual_network": tableAzureVirtualNetwork(ctx), "azure_virtual_network_gateway": tableAzureVirtualNetworkGateway(ctx), // "azure_storage_table": tableAzureStorageTable(ctx), diff --git a/azure/table_azure_virtual_machine_scale_set.go b/azure/table_azure_compute_virtual_machine_scale_set.go similarity index 94% rename from azure/table_azure_virtual_machine_scale_set.go rename to azure/table_azure_compute_virtual_machine_scale_set.go index 4f6d2933..ffa77ad2 100644 --- a/azure/table_azure_virtual_machine_scale_set.go +++ b/azure/table_azure_compute_virtual_machine_scale_set.go @@ -12,17 +12,17 @@ import ( //// TABLE DEFINITION -func tableAzureVirtualMachineScaleSet(_ context.Context) *plugin.Table { +func tableAzureComputeVirtualMachineScaleSet(_ context.Context) *plugin.Table { return &plugin.Table{ - Name: "azure_virtual_machine_scale_set", - Description: "Azure Virtual Machine Scale Set", + Name: "azure_compute_virtual_machine_scale_set", + Description: "Azure Compute Virtual Machine Scale Set", Get: &plugin.GetConfig{ KeyColumns: plugin.AllColumns([]string{"name", "resource_group"}), - Hydrate: getAzureVirtualMachineScaleSet, + Hydrate: getAzureComputeVirtualMachineScaleSet, ShouldIgnoreError: isNotFoundError([]string{"ResourceGroupNotFound", "ResourceNotFound", "404"}), }, List: &plugin.ListConfig{ - Hydrate: listAzureVirtualMachineScaleSets, + Hydrate: listAzureComputeVirtualMachineScaleSets, }, Columns: []*plugin.Column{ { @@ -219,8 +219,8 @@ func tableAzureVirtualMachineScaleSet(_ context.Context) *plugin.Table { //// LIST FUNCTION -func listAzureVirtualMachineScaleSets(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("listAzureVirtualMachineScaleSet") +func listAzureComputeVirtualMachineScaleSets(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("listAzureComputeVirtualMachineScaleSet") session, err := GetNewSession(ctx, d, "MANAGEMENT") if err != nil { return nil, err @@ -252,8 +252,8 @@ func listAzureVirtualMachineScaleSets(ctx context.Context, d *plugin.QueryData, //// HYDRATE FUNCTION -func getAzureVirtualMachineScaleSet(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("getAzureVirtualMachineScaleSet") +func getAzureComputeVirtualMachineScaleSet(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("getAzureComputeVirtualMachineScaleSet") name := d.KeyColumnQuals["name"].GetStringValue() resourceGroup := d.KeyColumnQuals["resource_group"].GetStringValue() diff --git a/docs/tables/azure_virtual_machine_scale_set.md b/docs/tables/azure_compute_virtual_machine_scale_set.md similarity index 81% rename from docs/tables/azure_virtual_machine_scale_set.md rename to docs/tables/azure_compute_virtual_machine_scale_set.md index b4089fef..303fe324 100644 --- a/docs/tables/azure_virtual_machine_scale_set.md +++ b/docs/tables/azure_compute_virtual_machine_scale_set.md @@ -1,4 +1,4 @@ -# Table: azure_virtual_machine_scale_set +# Table: azure_compute_virtual_machine_scale_set Azure virtual machine scale sets let you create and manage a group of load balanced VMs. The number of VM instances can automatically increase or decrease in response to demand or a defined schedule. Scale sets provide high availability to your applications, and allow you to centrally manage, configure, and update a large number of VMs. @@ -14,7 +14,7 @@ select region, resource_group from - azure_virtual_machine_scale_set; + azure_compute_virtual_machine_scale_set; ``` ### List Standard tier virtual machine scale set @@ -26,7 +26,7 @@ select sku_name, sku_tier from - azure_virtual_machine_scale_set + azure_compute_virtual_machine_scale_set where sku_tier = 'Standard'; ``` From e2af09ac462f4e83c1679cf7158f8ee40c356226 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Wed, 11 Aug 2021 18:52:20 +0530 Subject: [PATCH 5/7] Updated the column ordering --- ...azure_compute_virtual_machine_scale_set.go | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/azure/table_azure_compute_virtual_machine_scale_set.go b/azure/table_azure_compute_virtual_machine_scale_set.go index ffa77ad2..0d1a5a21 100644 --- a/azure/table_azure_compute_virtual_machine_scale_set.go +++ b/azure/table_azure_compute_virtual_machine_scale_set.go @@ -36,6 +36,12 @@ func tableAzureComputeVirtualMachineScaleSet(_ context.Context) *plugin.Table { Type: proto.ColumnType_STRING, Transform: transform.FromGo(), }, + { + Name: "provisioning_state", + Description: "The provisioning state.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("VirtualMachineScaleSetProperties.ProvisioningState"), + }, { Name: "type", Description: "The type of the resource in Azure.", @@ -47,16 +53,10 @@ func tableAzureComputeVirtualMachineScaleSet(_ context.Context) *plugin.Table { Type: proto.ColumnType_STRING, }, { - Name: "single_placement_group", - Description: "When true this limits the scale set to a single placement group, of max size 100 virtual machines.", + Name: "do_not_run_extensions_on_overprovisioned_vms", + Description: "When Overprovision is enabled, extensions are launched only on the requested number of VMs which are finally kept.", Type: proto.ColumnType_BOOL, - Transform: transform.FromField("VirtualMachineScaleSetProperties.SinglePlacementGroup"), - }, - { - Name: "provisioning_state", - Description: "The provisioning state.", - Type: proto.ColumnType_STRING, - Transform: transform.FromField("VirtualMachineScaleSetProperties.ProvisioningState"), + Transform: transform.FromField("VirtualMachineScaleSetProperties.DoNotRunExtensionsOnOverprovisionedVMs"), }, { Name: "overprovision", @@ -64,30 +64,30 @@ func tableAzureComputeVirtualMachineScaleSet(_ context.Context) *plugin.Table { Type: proto.ColumnType_BOOL, Transform: transform.FromField("VirtualMachineScaleSetProperties.Overprovision"), }, - { - Name: "do_not_run_extensions_on_overprovisioned_vms", - Description: "When Overprovision is enabled, extensions are launched only on the requested number of VMs which are finally kept.", - Type: proto.ColumnType_BOOL, - Transform: transform.FromField("VirtualMachineScaleSetProperties.DoNotRunExtensionsOnOverprovisionedVMs"), - }, - { - Name: "unique_id", - Description: "Specifies the ID which uniquely identifies a Virtual Machine Scale Set.", - Type: proto.ColumnType_STRING, - Transform: transform.FromField("VirtualMachineScaleSetProperties.UniqueID"), - }, { Name: "platform_fault_domain_count", Description: "Fault Domain count for each placement group.", Type: proto.ColumnType_INT, Transform: transform.FromField("VirtualMachineScaleSetProperties.PlatformFaultDomainCount"), }, + { + Name: "single_placement_group", + Description: "When true this limits the scale set to a single placement group, of max size 100 virtual machines.", + Type: proto.ColumnType_BOOL, + Transform: transform.FromField("VirtualMachineScaleSetProperties.SinglePlacementGroup"), + }, { Name: "sku_name", Description: "The sku name.", Type: proto.ColumnType_STRING, Transform: transform.FromField("Sku.Name"), }, + { + Name: "sku_capacity", + Description: "Specifies the tier of virtual machines in a scale set.", + Type: proto.ColumnType_INT, + Transform: transform.FromField("Sku.Capacity"), + }, { Name: "sku_tier", Description: "Specifies the tier of virtual machines in a scale set.", @@ -95,10 +95,10 @@ func tableAzureComputeVirtualMachineScaleSet(_ context.Context) *plugin.Table { Transform: transform.FromField("Sku.Tier"), }, { - Name: "sku_capacity", - Description: "Specifies the tier of virtual machines in a scale set.", - Type: proto.ColumnType_INT, - Transform: transform.FromField("Sku.Capacity"), + Name: "unique_id", + Description: "Specifies the ID which uniquely identifies a Virtual Machine Scale Set.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("VirtualMachineScaleSetProperties.UniqueID"), }, { Name: "extensions", @@ -107,44 +107,33 @@ func tableAzureComputeVirtualMachineScaleSet(_ context.Context) *plugin.Table { Hydrate: getAzureComputeVirtualMachineScalesetExtensions, Transform: transform.FromValue(), }, - { - Name: "plan", - Description: "Specifies information about the marketplace image used to create the virtual machine.", - Type: proto.ColumnType_JSON, - }, - { - Name: "zones", - Description: "The Logical zone list for scale set.", - Type: proto.ColumnType_JSON, - }, { Name: "identity", Description: "The identity of the virtual machine scale set, if configured.", Type: proto.ColumnType_JSON, }, { - Name: "virtual_machine_os_profile", - Description: "Specifies the operating system settings for the virtual machines in the scale set.", + Name: "plan", + Description: "Specifies information about the marketplace image used to create the virtual machine.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.OsProfile"), }, { - Name: "virtual_machine_storage_profile", - Description: "Specifies the storage settings for the virtual machine disks.", + Name: "scale_in_policy", + Description: "Specifies the scale-in policy that decides which virtual machines are chosen for removal when a Virtual Machine Scale Set is scaled-in.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.StorageProfile"), + Transform: transform.FromField("VirtualMachineScaleSetProperties.ScaleInPolicy"), }, { - Name: "virtual_machine_network_profile", - Description: "Specifies properties of the network interfaces of the virtual machines in the scale set.", + Name: "tags_src", + Description: "Resource tags.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.NetworkProfile"), + Transform: transform.FromField("Tags"), }, { - Name: "virtual_machine_security_profile", - Description: "Specifies the Security related profile settings for the virtual machines in the scale set.", + Name: "upgrade_policy", + Description: "The upgrade policy for the scale set.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.SecurityProfile"), + Transform: transform.FromField("VirtualMachineScaleSetProperties.UpgradePolicy"), }, { Name: "virtual_machine_diagnostics_profile", @@ -159,22 +148,33 @@ func tableAzureComputeVirtualMachineScaleSet(_ context.Context) *plugin.Table { Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.ExtensionProfile"), }, { - Name: "upgrade_policy", - Description: "The upgrade policy for the scale set.", + Name: "virtual_machine_network_profile", + Description: "Specifies properties of the network interfaces of the virtual machines in the scale set.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("VirtualMachineScaleSetProperties.UpgradePolicy"), + Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.NetworkProfile"), }, { - Name: "scale_in_policy", - Description: "Specifies the scale-in policy that decides which virtual machines are chosen for removal when a Virtual Machine Scale Set is scaled-in.", + Name: "virtual_machine_os_profile", + Description: "Specifies the operating system settings for the virtual machines in the scale set.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("VirtualMachineScaleSetProperties.ScaleInPolicy"), + Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.OsProfile"), }, { - Name: "tags_src", - Description: "Resource tags.", + Name: "virtual_machine_storage_profile", + Description: "Specifies the storage settings for the virtual machine disks.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.StorageProfile"), + }, + { + Name: "virtual_machine_security_profile", + Description: "Specifies the Security related profile settings for the virtual machines in the scale set.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineScaleSetProperties.VirtualMachineProfile.SecurityProfile"), + }, + { + Name: "zones", + Description: "The Logical zone list for scale set.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("Tags"), }, // Standard columns From 5a634503776029edaf445bf64eaf3a9a887bf15e Mon Sep 17 00:00:00 2001 From: Khushboo <46913995+khushboo9024@users.noreply.github.com> Date: Wed, 11 Aug 2021 19:05:17 +0530 Subject: [PATCH 6/7] Update table_azure_compute_virtual_machine_scale_set.go added description for column --- azure/table_azure_compute_virtual_machine_scale_set.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure/table_azure_compute_virtual_machine_scale_set.go b/azure/table_azure_compute_virtual_machine_scale_set.go index 0d1a5a21..69a23c4d 100644 --- a/azure/table_azure_compute_virtual_machine_scale_set.go +++ b/azure/table_azure_compute_virtual_machine_scale_set.go @@ -195,6 +195,8 @@ func tableAzureComputeVirtualMachineScaleSet(_ context.Context) *plugin.Table { Type: proto.ColumnType_JSON, Transform: transform.FromField("ID").Transform(idToAkas), }, + + // Azure standard columns { Name: "region", Description: ColumnDescriptionRegion, From 88aad6c765295f7db9f305cd0bd3a1f281651bd5 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Wed, 11 Aug 2021 19:08:37 +0530 Subject: [PATCH 7/7] Update --- azure/table_azure_compute_virtual_machine_scale_set.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_compute_virtual_machine_scale_set.go b/azure/table_azure_compute_virtual_machine_scale_set.go index 0d1a5a21..630968c9 100644 --- a/azure/table_azure_compute_virtual_machine_scale_set.go +++ b/azure/table_azure_compute_virtual_machine_scale_set.go @@ -177,7 +177,7 @@ func tableAzureComputeVirtualMachineScaleSet(_ context.Context) *plugin.Table { Type: proto.ColumnType_JSON, }, - // Standard columns + // Azure standard columns { Name: "title", Description: ColumnDescriptionTitle,