Skip to content
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

triton_network: Add data source for triton_networks #13

Closed
wants to merge 3 commits into from

Conversation

jwreagor
Copy link
Contributor

@jwreagor jwreagor commented Jul 26, 2017

This adds a new data source for pulling up network UUIDs by their name/label. Here's two examples of looking up Joyent-SDC-Public and Joyent-SDC-Private. Any caps sensitive string part of the network name will match. The first match is used.

data "triton_network" "private" {
  name = "SDC-Private"
}

data "triton_network" "public" {
  name = "SDC-Public"
}

resource "triton_machine" "tf-base" {
  name = "tf-base-${count.index}"
  package = "g4-highcpu-512M"
  image = "${data.triton_image.base.id}"

  nic {
    network = "${data.triton_network.public.id}"
  }

  tags {
    version = "1.0.0"
    role = "test"
  }
}

/cc @jen20 @sean-

Copy link
Contributor

@sean- sean- 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.

  1. Docs?
  2. How does this handle network pools?


var network *network.Network
for _, found := range networks {
if strings.Contains(found.Name, netName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

strings.Contains() vs a strict == comparison?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was providing a feature to search but, in hindsight, probably should be a direct one-to-one comparison. I'll change this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would use a direct comparison here and require the full name. It might also be worth adding a switch for whether the network is a fabric?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jen20 It's sort of bunk that the ListNetworks endpoint of CloudAPI doesn't provide any filter or search capabilities. Neither do many other List endpoints for that matter (can I haz cloudapi-go). But I can certainly add this (or any other returned field) since the implementation pulls all networks.

@jwreagor
Copy link
Contributor Author

How does this handle network pools?

This should be the existing behavior as the data source simply maps the network name to it's UUID.

@jen20
Copy link
Contributor

jen20 commented Jul 27, 2017

I think with respect to network pools we'll need to make upstream API changes, since it's effectively impossible to converge on a given network if there are multiple pools involved.

@jwreagor
Copy link
Contributor Author

I've updated according to what we last spoke about. Curious what filters everyone might want, I can certainly add more.

Copy link
Contributor

@jen20 jen20 left a comment

Choose a reason for hiding this comment

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

Couple of minor nits here - I think to make this substantially more useful we should also expose the address space.

# triton\_network

The `triton_network` data source queries the Triton Network API for a network ID
based on it's name.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/it's name/the name of the network/ ?


* `name` - (string)
The name of the network

Copy link
Contributor

Choose a reason for hiding this comment

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

This probably wants an "Attribute Reference" section too. We probably want to expose the address space as well as the network, in order that it can be used as input into the various IP functions.

@jen20
Copy link
Contributor

jen20 commented Jul 28, 2017

I rebased and fixed this up, merged it as ea8ad1f. Thanks @cheapRoc!

@jen20 jen20 closed this Jul 28, 2017
@jen20
Copy link
Contributor

jen20 commented Jul 28, 2017

We can add other attributes at a future point.

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

Successfully merging this pull request may close these issues.

3 participants