Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Pull network info from NETWORK_LIST json in resourceview #30

Merged
merged 4 commits into from
Sep 16, 2019

Conversation

cars
Copy link
Contributor

@cars cars commented Sep 6, 2019

This is a possible solution/workaround to #16 that utilizes the NETWORK_LIST data map as suggested by @hobovirtual. It works for both privileged (Tenant Admin) and non-privileged users, as well as supporting cases where there might be multiple interfaces/NICs. It doesn't use the ip_address field but fields more similar to the vRA custom properties one would use to specify the settings in a request. In the case of a blueprint with a component called 'VM' with two NICs the resource_configuration block would look something like:

 resource_configuration = {
    "VM.cpu" = 2
    "VM.ip_address" = ""
    "VM.name" = ""
    "VM.Network0.IPAddress" = ""
    "VM.Network0.MACAddress" = ""
    "VM.Network0.Name" = ""
    "VM.Network1.IPAddress" = ""
    "VM.Network1.MACAddress" = ""
    "VM.Network1.Name" = ""

  }

so using a count of 2 in the resource definition and the following output:

# Or, print the whole thing:
output "Machine_Info" {
  value = vra7_deployment.test.*.resource_configuration
}

would yield something like:

Machine_Info = [
  {
    "VM.Network0.IPAddress" = "10.0.3.131"
    "VM.Network0.MACAddress" = "00:50:56:84:e5:d3"
    "VM.Network0.Name" = "Public 3"
    "VM.Network1.IPAddress" = "10.0.4.102"
    "VM.Network1.MACAddress" = "00:50:56:84:8c:2e"
    "VM.Network1.Name" = "Public 4"
    "VM.cpu" = "2"
    "VM.ip_address" = ""
    "VM.name" = "K8S0305"
  },
  {
    "VM.Network0.IPAddress" = "10.0.3.130"
    "VM.Network0.MACAddress" = "00:50:56:84:d4:37"
    "VM.Network0.Name" = "Public 3"
    "VM.Network1.IPAddress" = "10.0.4.101"
    "VM.Network1.MACAddress" = "00:50:56:84:57:7e"
    "VM.Network1.Name" = "Public 4"
    "VM.cpu" = "2"
    "VM.ip_address" = ""
    "VM.name" = "K8S0306"
  },
]

@ghost ghost added the size/M label Sep 6, 2019
Copy link
Contributor

@markpeek markpeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this looks good. A couple of tweaks needed. Also, I'd like @Prativa20 to look at this change and approve. Thanks!

build.cmd Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@cars
Copy link
Contributor Author

cars commented Sep 6, 2019

@markpeek I think I made the changes correctly

Copy link
Contributor

@Prativa20 Prativa20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants