-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixes #38742 - Add fixed IP address support for OpenStack #10704
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
Conversation
|
Hello, |
Thanks for sharing! I’ll take a look and work on fixing it. |
|
Hi @Loumy, could you give it another round of testing? |
|
Thanks @nofaralfasi but still not working. But on the json sent to Openstack, I have only the network ID : |
|
I tried to reproduce with FOG and it works with this class OpenStackVMManager
def initialize(auth_params)
@compute = Fog::Compute.new(auth_params.merge(provider: 'OpenStack'))
@network = Fog::Network.new(auth_params.merge(provider: 'OpenStack'))
end
def create_vm_with_ip(name, image_id, flavor_id, network_id, ip_address)
begin
# check if already used IP
existing_ports = @network.ports.all(fixed_ips: "ip_address=#{ip_address}")
if existing_ports.any?
raise "IP #{ip_address} already used"
end
# createport
port = @network.ports.create(
name: "#{name}-port",
network_id: network_id,
fixed_ips: [{ ip_address: ip_address }]
)
# Créer la VM
server = @compute.servers.create(
name: name,
image_ref: image_id,
flavor_ref: flavor_id,
nics: [{ port_id: port.id }]
)
[...]I hope it help, I'm not so skilled in ruby to propose a path, I may try with an AI |
|
I made it work finally @nofaralfasi , from [1] the param is supposed
|
|
Hi @Loumy, thanks for your review and comments. I was on PTO but will go through your feedback and update the PR ASAP. |
4827e2d to
4fc5eec
Compare
|
Hi @Loumy, Two things:
Thanks! |
|
@nofaralfasi I tested it on version 3.16.0 and it works like a charm great jobs.
Many thanks ! |
|
Thanks a lot @clopnis! 😊 |
| args[:nics].map! { |nic| nic.is_a?(String) ? { 'net_id' => nic } : nic } | ||
|
|
||
| # Process interface attributes to add fixed IP addresses | ||
| process_fixed_ips(args) if args[:interfaces_attributes].present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| process_fixed_ips(args) if args[:interfaces_attributes].present? | |
| process_fixed_ips(args) |
There is another return unless interfaces_attrs&.any? check in the method itself
| next unless interface_attrs.is_a?(Hash) | ||
|
|
||
| ip = interface_attrs[:ip] || interface_attrs['ip'] | ||
| if ip.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about IPv6?
|
|
||
| # Update nics with fixed IPs based on position | ||
| args[:nics].each_with_index do |nic, index| | ||
| next unless nic.is_a?(Hash) && nic['net_id'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be filtered out at the begining of the method so we can skip the ordering and everything:
nics = args[:nics].reject_if ....
return if nics.empty?| return unless interfaces_attrs&.any? | ||
|
|
||
| # Sort interface attributes by index to match nics order | ||
| sorted_interfaces = interfaces_attrs.sort_by { |index, _| index.to_i }.map(&:last) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you skip the sorting and just call interfaces_attrs[index.to_s] later on?
|
tested and works on 3.16 with Openstack Epoxy |
|
Thanks @nofaralfasi @clopnis |
No description provided.