diff --git a/CHANGELOG.md b/CHANGELOG.md index d1bee7124..b8ce64a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ FEATURES: * resources/opennebula_virtual_network: allow to modify the user owning the resource (#529) * resources/opennebula_virtual_machine: add nil checks before type casting (#530) +* resources/opennebula_virtual_router_nic: add floating_only nic argument (#547) ENHANCEMENTS: diff --git a/opennebula/resource_opennebula_virtual_router_nic.go b/opennebula/resource_opennebula_virtual_router_nic.go index 0cfcaf13d..c00941715 100644 --- a/opennebula/resource_opennebula_virtual_router_nic.go +++ b/opennebula/resource_opennebula_virtual_router_nic.go @@ -81,6 +81,12 @@ func resourceOpennebulaVirtualRouterNIC() *schema.Resource { Default: false, ForceNew: true, }, + "floating_only": { + Type: schema.TypeBool, + Optional: true, + Default: false, + ForceNew: true, + }, }, } } @@ -125,6 +131,11 @@ func resourceOpennebulaVirtualRouterNICCreate(ctx context.Context, d *schema.Res nicTpl.Add("FLOATING_IP", "YES") } } + if v, ok := d.GetOk("floating_only"); ok { + if v.(bool) { + nicTpl.Add("FLOATING_ONLY", "YES") + } + } // wait before checking NIC nicID, err := vrNICAttach(ctx, d.Timeout(schema.TimeoutCreate), controller, vRouterID, nicTpl) @@ -197,6 +208,7 @@ func resourceOpennebulaVirtualRouterNICRead(ctx context.Context, d *schema.Resou } floatingIP, _ := nic.GetStr("FLOATING_IP") + floatingOnly, _ := nic.GetStr("FLOATING_ONLY") d.Set("network_id", networkID) d.Set("virtual_router_id", vr.ID) @@ -206,6 +218,7 @@ func resourceOpennebulaVirtualRouterNICRead(ctx context.Context, d *schema.Resou d.Set("virtio_queues", virtioQueues) d.Set("security_groups", sg) d.Set("floating_ip", strings.ToUpper(floatingIP) == "YES") + d.Set("floating_only", strings.ToUpper(floatingOnly) == "YES") return nil } diff --git a/opennebula/resource_opennebula_virtual_router_test.go b/opennebula/resource_opennebula_virtual_router_test.go index b5ec164d4..e758fc583 100644 --- a/opennebula/resource_opennebula_virtual_router_test.go +++ b/opennebula/resource_opennebula_virtual_router_test.go @@ -104,7 +104,9 @@ func TestAccVirtualRouter(t *testing.T) { resource.TestCheckResourceAttrSet("opennebula_virtual_router_nic.nic1", "network_id"), resource.TestCheckResourceAttrSet("opennebula_virtual_router_nic.nic2", "network_id"), resource.TestCheckResourceAttr("opennebula_virtual_router_nic.nic1", "floating_ip", "true"), + resource.TestCheckResourceAttr("opennebula_virtual_router_nic.nic1", "floating_only", "true"), resource.TestCheckResourceAttr("opennebula_virtual_router_nic.nic2", "floating_ip", "false"), + resource.TestCheckResourceAttr("opennebula_virtual_router_nic.nic2", "floating_only", "false"), testAccCheckVirtualRouterPermissions(&shared.Permissions{ OwnerU: 1, OwnerM: 1, @@ -127,7 +129,9 @@ func TestAccVirtualRouter(t *testing.T) { resource.TestCheckResourceAttrSet("opennebula_virtual_router_nic.nic1", "network_id"), resource.TestCheckResourceAttrSet("opennebula_virtual_router_nic.nic2", "network_id"), resource.TestCheckResourceAttr("opennebula_virtual_router_nic.nic1", "floating_ip", "false"), + resource.TestCheckResourceAttr("opennebula_virtual_router_nic.nic1", "floating_only", "false"), resource.TestCheckResourceAttr("opennebula_virtual_router_nic.nic2", "floating_ip", "false"), + resource.TestCheckResourceAttr("opennebula_virtual_router_nic.nic2", "floating_only", "false"), testAccCheckVirtualRouterPermissions(&shared.Permissions{ OwnerU: 1, OwnerM: 1, @@ -409,6 +413,7 @@ resource "opennebula_virtual_router_nic" "nic2" { resource "opennebula_virtual_router_nic" "nic1" { floating_ip = true + floating_only = true virtual_router_id = opennebula_virtual_router.test.id network_id = opennebula_virtual_network.network1.id } diff --git a/website/docs/r/virtual_router_nic.markdown b/website/docs/r/virtual_router_nic.markdown index a74c4e86d..08df17cd6 100644 --- a/website/docs/r/virtual_router_nic.markdown +++ b/website/docs/r/virtual_router_nic.markdown @@ -91,6 +91,7 @@ resource "opennebula_virtual_network" "example" { resource "opennebula_virtual_router_nic" "example1" { floating_ip = true + floating_only = true virtual_router_id = opennebula_virtual_router.example.id network_id = opennebula_virtual_network.example.id } @@ -112,6 +113,7 @@ The following arguments are supported: * `physical_device` - (Optional) Physical device hosting the virtual network. * `security_groups` - (Optional) List of security group IDs to use on the virtual network. * `floating_ip` - (Optional) Allocate floating IP for the NIC. Defaults to `false`. +* `floating_only` - (Optional) Do not allocate IP for the NIC. Defaults to `false`. ## Attribute Reference @@ -123,6 +125,7 @@ The following attribute are exported: * `physical_device` - Physical device hosting the virtual network. * `security_groups` - List of security group IDs to use on the virtual network. * `floating_ip` - Allocate floating IP for the NIC. Defaults to `false`. +* `floating_only` - (Optional) Do not allocate IP for the NIC. Defaults to `false`. ## Import