-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new resource azurerm_stack_hci_logical_network
#26473
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @teowa, Thanks for this PR - I've taken a look through and left some comments inline. If we can fix those up, this should be good to go 👍
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validation.StringIsNotEmpty, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does name
have max length and special characters limitation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validation added.
ForceNew: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"name": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why name
is not required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to requred
t.Skipf("skip the test as one or more of below environment variables are not specified: %q", customLocationIdEnv) | ||
} | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use basic
-> complete
-> update
-> basic
to also test add/remove tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test updated
|
||
* `custom_location_id` - (Required) The ID of Custom Location where the Azure Stack HCI Logical Network should exist. Changing this forces a new resource to be created. | ||
|
||
* `vm_switch_name` - (Required) The name of the network switch used to associate with the Azure Stack HCI Logical Network. Possible switch name can be retrieved following the [Azure documents](https://learn.microsoft.com/azure-stack/hci/manage/create-logical-networks?tabs=azurecli#prerequisites). Changing this forces a new resource to be created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the description, it seems should be named as network_switch_name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to virtual_switch_name
and the description to Name of the external virtual switch
|
||
A `subnet` block supports the following: | ||
|
||
* `ip_allocation_method` - (Required) IP address allocation method for the subnet. Possible value is `Dynamic` or `Static`. Changing this forces a new resource to be created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `ip_allocation_method` - (Required) IP address allocation method for the subnet. Possible value is `Dynamic` or `Static`. Changing this forces a new resource to be created. | |
* `ip_allocation_method` - (Required) IP address allocation method for the subnet. Possible values are `Dynamic` and `Static`. Changing this forces a new resource to be created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
* `address_prefix` - (Optional) The address prefix in CIDR notation. Changing this forces a new resource to be created. | ||
|
||
* `ip_pool` - (Optional) One or more `ip_pool` block as defined above. Changing this forces a new resource to be created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not define the description of ip_pool
and route
after subnet
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the blocks are ranked in alphabetical order
…hange vm_switch_name to virtual_switch_name; update doc
Hi @ms-zhenhua , thanks for reviewing this, I have changed the code, please kindly take another look.
|
Hi @teowa, thank you for your updates. LGTM~ |
|
future, err := client.CreateOrUpdate(ctx, id, payload) | ||
if err != nil { | ||
return fmt.Errorf("performing create %s: %+v", id, err) | ||
} | ||
|
||
metadata.SetID(id) | ||
|
||
if err := future.Poller.PollUntilDone(ctx); err != nil { | ||
return fmt.Errorf("polling after create %s: %+v", id, err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't we using the combined CreateOrUpdateThenPoll
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
|
||
parameters := resp.Model | ||
if parameters == nil { | ||
return fmt.Errorf("retrieving %s: model was nil", *id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We put the object or property name between back ticks in the error message
return fmt.Errorf("retrieving %s: model was nil", *id) | |
return fmt.Errorf("retrieving %s: `model` was nil", *id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
r := StackHCILogicalNetworkResource{} | ||
|
||
if os.Getenv(customLocationIdEnv) == "" { | ||
t.Skipf("skip the test as one or more of below environment variables are not specified: %q", customLocationIdEnv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only see one required environment variable for the test:
t.Skipf("skip the test as one or more of below environment variables are not specified: %q", customLocationIdEnv) | |
t.Skipf("skipping since %q has not been specified", customLocationIdEnv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
r := StackHCILogicalNetworkResource{} | ||
|
||
if os.Getenv(customLocationIdEnv) == "" { | ||
t.Skipf("skip the test as one or more of below environment variables are not specified: %q", customLocationIdEnv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.Skipf("skip the test as one or more of below environment variables are not specified: %q", customLocationIdEnv) | |
t.Skipf("skipping since %q has not been specified", customLocationIdEnv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
return nil, fmt.Errorf("retrieving %s: %+v", *id, err) | ||
} | ||
|
||
return utils.Bool(resp.Model != nil), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return utils.Bool(resp.Model != nil), nil | |
return pointer.To(resp.Model != nil), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
if response.WasNotFound(resp.HttpResponse) { | ||
return utils.Bool(false), nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a typical pattern in the Exists
check for tests? If we get any error kind of error from getting the resource here we should just return it
if response.WasNotFound(resp.HttpResponse) { | |
return utils.Bool(false), nil | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
|
||
* `custom_location_id` - (Required) The ID of Custom Location where the Azure Stack HCI Logical Network should exist. Changing this forces a new resource to be created. | ||
|
||
* `virtual_switch_name` - (Required) The name of the virtual switch on the cluster used to associate with the Azure Stack HCI Logical Network. Possible switch name can be retrieved following the [Azure documents](https://learn.microsoft.com/azure-stack/hci/manage/create-logical-networks?tabs=azurecli#prerequisites). Changing this forces a new resource to be created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `virtual_switch_name` - (Required) The name of the virtual switch on the cluster used to associate with the Azure Stack HCI Logical Network. Possible switch name can be retrieved following the [Azure documents](https://learn.microsoft.com/azure-stack/hci/manage/create-logical-networks?tabs=azurecli#prerequisites). Changing this forces a new resource to be created. | |
* `virtual_switch_name` - (Required) The name of the virtual switch on the cluster used to associate with the Azure Stack HCI Logical Network. Possible switch names can be retrieved by following this [Azure guide](https://learn.microsoft.com/azure-stack/hci/manage/create-logical-networks?tabs=azurecli#prerequisites). Changing this forces a new resource to be created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
|
||
* `route` - (Optional) One or more `route` block as defined above. Changing this forces a new resource to be created. | ||
|
||
* `vlan_id` - (Optional) VLAN ID for the Logical Network. Changing this forces a new resource to be created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `vlan_id` - (Optional) VLAN ID for the Logical Network. Changing this forces a new resource to be created. | |
* `vlan_id` - (Optional) The VLAN ID for the Logical Network. Changing this forces a new resource to be created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @teowa LGTM 👍
* new resource stack_hci_logical_network * validate name property; update test; change route name to required; change vm_switch_name to virtual_switch_name; update doc * fix update test * use createThenPoll; fix error message; fix doc * update doc
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Community Note
Description
swagger: https://github.com/Azure/azure-rest-api-specs/blob/1c63635d66ae38cff18045ab416a6572d3e15f6e/specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/logicalNetworks.json
Azure doc: https://learn.microsoft.com/en-us/azure-stack/hci/manage/create-logical-networks?tabs=azurecli#prerequisites
The acctest is based on existing custom location, the custom location is generated during HCI deployment which can take more than 3 hours. How to test HCI deployment from scratch is included in PR #25646
PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_stack_hci_logical_network
[GH-00000]This is a (please select all that apply):
Related Issue(s)
Fixes #0000
Note
If this PR changes meaningfully during the course of review please update the title and description as required.