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

Define 'ip_address = "" ' parameter in "fixed_ip" for openstack_networking_port_v2 ,but the ip will be assigned a value. #429

Closed
xudehua opened this issue Sep 21, 2018 · 11 comments
Labels

Comments

@xudehua
Copy link

xudehua commented Sep 21, 2018

Hi there,

Terraform v0.11.7

  • provider.openstack v1.9.0

Affected Resource(s)

Please list the resources as a list, for example:

  • openstack_compute_instance_v2
  • openstack_networking_port_v2

According the terraform docs https://www.terraform.io/docs/providers/openstack/r/networking_port_v2.html

The fixed_ip block supports:
subnet_id - (Required) Subnet in which to allocate IP address for this port.
ip_address - (Optional) IP address desired in the subnet for this port. If you don't specify ip_address, an available IP address from the specified subnet will be allocated to this port. This field will not be populated if it is left blank. To retrieve the assigned IP address, use the all_fixed_ips attribute.

I create port and instance

resource "openstack_networking_port_v2" "port_net-03_v4" {
name = "test"
network_id = "${var.uuid}"
admin_state_up = "true"
security_group_ids = [ "${var.security_group_id}" ]
fixed_ip {
"subnet_id" = "${var.sub_uuid}"
"ip_address" = ""
}
}

Output
I just want to create a port in the instance ,no IP required. But after creating instance , the instance's port had been assigned IP value( may be by DHCP).

Thanks

@ozerovandrei
Copy link
Member

@xudehua Hello.

This is expected behaviour according to OpenStack Neutron Documentation:

If you specify only a subnet ID, OpenStack Networking allocates an available IP from that subnet to the port.

And we have the following note in the Terraform Provider Documentation:

If you don't specify ip_address, an available IP address from the specified subnet will be allocated to this port.

Setting this value to blank is the same as skipping this flag.
Let me know if you have any questions.

@xudehua
Copy link
Author

xudehua commented Sep 25, 2018

@ozerovandrei Hi,

Thank you for you answer.
By terraform *.tf file,I created a port from the specified subnet and attached to one VM on openstack platformthe .I hope the port's IP address is blank when the VM was deployed.
Maybe I misunderstood the note “This field will not be populated if it is left blank.”. I thought that the port's IP address would not be assigned when the "ip_address" was set blank in the fixed_ip.

Thanks again

Edward

@jtopjian
Copy link
Contributor

I thought that the port's IP address would not be assigned when the "ip_address" was set blank in the fixed_ip.

That's a good point. We will update our documentation to clarify "if it is left blank or omitted".

As far as creating a port with no IP address, you might have to disable DHCP on the subnet itself.

@xudehua
Copy link
Author

xudehua commented Sep 25, 2018

@jtopjian

Can you describe it in more detail. I disable DHCP,but the VM was still assigned IP address.

Another, Did the Terraform support the paramete "--no-fixed-ip" in the command " openstack port create --no-fixed-ip"?

Edward

@xudehua
Copy link
Author

xudehua commented Sep 25, 2018

openstack port create --help

--no-fixed-ip No IP or subnet for this port.

@jtopjian
Copy link
Contributor

I don't think it currently supports it, but we might be able to get this to work. Here's the API request when using --no-fixed-ip:

{"port": {"network_id": "foo", "fixed_ips": [], "name": "jttest", "admin_state_up": true}

The upstream Gophercloud library might allow us to pass in [] for the value of fixed_ips. I'll test this out when I have a moment.

@ozerovandrei
Copy link
Member

@jtopjian I guess that [] actually might work: db_base_plugin_v2.py#L1322

@jtopjian
Copy link
Contributor

@ozerovandrei Right. I'm just wondering if Gophercloud's current use of interface{} and omitempty will allow it.

@jtopjian
Copy link
Contributor

Looks like this is very possible to do 😄

I've submitted #433 which adds a new argument of no_fixed_ip.

@ozerovandrei
Copy link
Member

Implemented in #433

@xudehua this feature will be available in 1.10.0 release.

@xudehua
Copy link
Author

xudehua commented Sep 28, 2018

@ozerovandrei
OK,thanks

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

No branches or pull requests

3 participants