Skip to content

Commit

Permalink
Merge pull request #28 from mohith10/vmNat-feature
Browse files Browse the repository at this point in the history
Added NAT feature to support both Ip and Vm nat
  • Loading branch information
hughwphamill authored Oct 20, 2023
2 parents bbce129 + 7792d19 commit a376b66
Show file tree
Hide file tree
Showing 17 changed files with 791 additions and 6 deletions.
37 changes: 37 additions & 0 deletions docs/data-sources/ip_nat_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "dcloud_ip_nat_rules Data Source - terraform-provider-dcloud"
subcategory: ""
description: |-
All the IP Nat rules currently in a given topology
---

# dcloud_ip_nat_rules (Data Source)

All the IP Nat rules currently in a given topology


<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `topology_uid` (String)

### Read-Only

- `id` (String) The ID of this resource.
- `ip_nat_rules` (List of Object) (see [below for nested schema](#nestedatt--ip_nat_rules))

<a id="nestedatt--ip_nat_rules"></a>
### Nested Schema for `ip_nat_rules`

Read-Only:

- `target_ip_address` (String)
- `target_name` (String)
- `east_west` (Bool)
- `topology_uid` (String)
- `uid` (String)


39 changes: 39 additions & 0 deletions docs/data-sources/vm_nat_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "dcloud_vm_nat_rules Data Source - terraform-provider-dcloud"
subcategory: ""
description: |-
All the VM Nat rules currently in a given topology
---

# dcloud_vm_nat_rules (Data Source)

All the VM Nat rules currently in a given topology



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `topology_uid` (String)

### Read-Only

- `id` (String) The ID of this resource.
- `vm_nat_rules` (List of Object) (see [below for nested schema](#nestedatt--vm_nat_rules))

<a id="nestedatt--vm_nat_rules"></a>
### Nested Schema for `vm_nat_rules`

Read-Only:

- `target_ip_address` (String)
- `target_name` (String)
- `nic_uid` (String)
- `east_west` (Bool)
- `topology_uid` (String)
- `uid` (String)


29 changes: 29 additions & 0 deletions docs/resources/ip_nat_rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "dcloud_ip_nat_rule Resource - terraform-provider-dcloud"
subcategory: ""
description: |-
---

# dcloud_ip_nat_rule (Resource)


<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `target_ip_address` (String)
- `target_name` (String)
- `east_west` (Bool)
- `topology_uid` (String)


### Read-Only

- `id` (String) The ID of this resource.
- `uid` (String)



31 changes: 31 additions & 0 deletions docs/resources/vm_nat_rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "dcloud_vm_nat_rule Resource - terraform-provider-dcloud"
subcategory: ""
description: |-
---

# dcloud_vm_nat_rule (Resource)


<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `target_ip_address` (String)
- `target_name` (String)
- `nic_uid` (String)
- `east_west` (Bool)
- `topology_uid` (String)



### Read-Only

- `id` (String) The ID of this resource.
- `uid` (String)



34 changes: 34 additions & 0 deletions examples/data-sources/ip_nat_rule_data_source/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
terraform {
required_providers {
dcloud = {
version = "0.1"
source = "cisco-open/dcloud"
}
}
}

provider "dcloud" {
tb_url = "https://tbv3-production.ciscodcloud.com/api"
}

resource "dcloud_topology" "test_topology" {
name = "Test Topology For Testing IP NAT Rule"
description = "Will be used to create IP NAT rules "
notes = ""
datacenter = "LON"
}

resource "dcloud_ip_nat_rule" "ip_nat"{
topology_uid = dcloud_topology.test_topology.id
target_ip_address = "192.168.1.1"
target_name = "Sample Device"
east_west = true
}

data "dcloud_ip_nat_rules" "test_topology_ip_nat_rules"{
topology_uid = dcloud_topology.test_topology.id
}

output "ip_nat_rules" {
value = data.dcloud_ip_nat_rules.test_topology_ip_nat_rules
}
99 changes: 99 additions & 0 deletions examples/data-sources/vm_nat_rule_data_source/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
terraform {
required_providers {
dcloud = {
version = "0.1"
source = "cisco-open/dcloud"
}
}
}

provider "dcloud" {
tb_url = "https://tbv3-production.ciscodcloud.com/api"
}

resource "dcloud_topology" "test_topology" {
name = "Test Topology For Testing VM NAT Rule"
description = "Will be used to create VM NAT rules "
notes = ""
datacenter = "LON"
}

resource "dcloud_network" "routed_network" {
name = "A routed network"
description = "Demonstrating a network routed through VPOD Gateway"
inventory_network_id = "L3-VLAN-2"
topology_uid = dcloud_topology.test_topology.id
}

resource "dcloud_network" "unrouted_network" {
name = "An unrouted network"
description = "Demonstrating a network not routed through VPOD Gateway"
inventory_network_id = "L2-VLAN-16"
topology_uid = dcloud_topology.test_topology.id
}

resource "dcloud_vm" "vm1" {
inventory_vm_id = "7668085"
topology_uid = dcloud_topology.test_topology.id
name = "Ubuntu Desktop 1"
description = "A standard Ubuntu Desktop VM"
cpu_qty = 8
memory_mb = 8192
nested_hypervisor = false
os_family = "LINUX"

advanced_settings {
all_disks_non_persistent = false
bios_uuid = "42 3a 5f 9d f1 a8 7c 0e-7d c2 44 27 2e d6 67 aa"
name_in_hypervisor = "ubuntu"
not_started = false
}

network_interfaces {
network_uid = dcloud_network.routed_network.id
name = "Network adapter 0"
mac_address = "00:50:56:00:01:AA"
type = "VIRTUAL_E1000"
}

network_interfaces{
network_uid = dcloud_network.unrouted_network.id
name = "Network adapter 1"
mac_address = "00:50:56:00:01:AB"
type = "VIRTUAL_E1000"
ip_address = "127.0.0.2"
ssh_enabled = true
rdp_enabled = true
rdp_auto_login = true
}

remote_access {
username = "user"
password = "password"
vm_console_enabled = true

display_credentials {
username = "displayuser"
password = "displaypassword"
}
}

guest_automation {
command = "RUN PROGRAM"
delay_seconds = 10
}
}

resource "dcloud_vm_nat_rule" "vm_nat"{
topology_uid = dcloud_topology.test_topology.id
nic_uid = dcloud_vm.vm1.network_interfaces[1].uid
east_west = true
}

data "dcloud_vm_nat_rules" "test_topology_vm_nat_rules"{
topology_uid = dcloud_topology.test_topology.id
}

output "vm_nat_rules" {
value = data.dcloud_vm_nat_rules.test_topology_vm_nat_rules
}
16 changes: 14 additions & 2 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ resource "dcloud_vm" "vm1" {
type = "VIRTUAL_E1000"
}

network_interfaces {
network_interfaces{
network_uid = dcloud_network.unrouted_network.id
name = "Network adapter 1"
mac_address = "00:50:56:00:01:AB"
Expand Down Expand Up @@ -136,7 +136,6 @@ resource "dcloud_hw" "hw2" {
name = "UCS Hardware Pod"
}


resource "dcloud_license" "mc_license" {
quantity = 3
inventory_license_id = "340"
Expand Down Expand Up @@ -223,3 +222,16 @@ resource "dcloud_telephony" "telephony" {
topology_uid = dcloud_topology.test_topology.id
inventory_telephony_id = "1"
}

resource "dcloud_ip_nat_rule" "ip_nat_rule"{
topology_uid = dcloud_topology.test_topology.id
target_ip_address = "192.168.1.1"
target_name = "Sample Device"
east_west = false
}

resource "dcloud_vm_nat_rule" "vm_nat_rule"{
topology_uid = dcloud_topology.test_topology.id
nic_uid = dcloud_vm.vm1.network_interfaces[1].uid
east_west = false
}
26 changes: 26 additions & 0 deletions examples/resources/ip_nat_rule_resource/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
terraform {
required_providers {
dcloud = {
version = "0.1"
source = "cisco-open/dcloud"
}
}
}

provider "dcloud" {
tb_url = "https://tbv3-production.ciscodcloud.com/api"
}

resource "dcloud_topology" "test_topology" {
name = "IP NAT Rule Resource Test"
description = "Testing IP NAT Rule Resource Management"
notes = "Created via Terraform Test"
datacenter = "LON"
}

resource "dcloud_ip_nat_rule" "test_ip_nat"{
topology_uid = dcloud_topology.test_topology.id
target_ip_address = "192.168.1.1"
target_name = "Sample Device"
east_west = true
}
Loading

0 comments on commit a376b66

Please sign in to comment.