Hi, Jan.

1.  The server is getting created, but it's not getting assigned the specified ip-address in the call.  Instead, it's getting assigned a random ip on the 10.0.0.0/24 network.

The OpenStack cluster is being used to simulate a scenario where a malicious user compromises this machine.  What we're trying to do is to re-image the machine programmatically
so that it will be set back to a pristine state.

The python program gathers information about the machine, including its ip-address, destroys it, and then creates an identical machine (same name, same ip, etc.) in its place.
We wait for the machine to be destroyed before creating its replacement.

2.  There are actually several networks for which the machine could be assigned on ip-address.  The 10.0.0.0/24 network is a "control" network which includes all of the machines in the project cluster.
This network is used for a backbone for controlling what commands are executed on the machines.

The other networks contain subsets of the cluster machines, connected together by routers.  This is the actual intranet that is being simulated.


The server we are working with is just a test machine at this point to make sure we can destroy it and bring up an identical, but pristine, machine in its place, complete with an identical ip-address
on the 10.0.0.0/24 network.

Everything is working except the assignment of the identical ip-address.


Thanks for your help 🙂
-- Harmon

From: Jan Jasek <jjasek@redhat.com>
Sent: Friday, May 3, 2024 3:06 AM
To: Hoai-Thu Vuong <thuvh87@gmail.com>
Cc: Nine, Harmon S <harmon.s.nine@vanderbilt.edu>; openstack-discuss@lists.openstack.org <openstack-discuss@lists.openstack.org>
Subject: Re: How to assign an ip-address to a server on creation
 
You don't often get email from jjasek@redhat.com. Learn why this is important

Hello Harmon,

Based on this line the ips should be just list of floating IP addresses:

https://github.com/openstack/openstacksdk/blob/30d5753bcf08b262a7879bd0831ea8c510743d9d/openstack/cloud/_floating_ip.py#L911


  1. You are saying that the server is getting created but not assigning the ip-address to the server that is specified in the call - does it mean that the server is created with a different ip-address or there is no specified ip-address at all or the server creation fails?

  2. Are you sure that it is physically possible for the instance to assign with the specified ip-address (network)? Specifically - are both on the same network or are the networks connected using a router?


On Fri, May 3, 2024 at 6:58 AM Hoai-Thu Vuong <thuvh87@gmail.com> wrote:
according to this, you can use fixed_ip 

On Fri, May 3, 2024 at 10:22 AM Nine, Harmon S <harmon.s.nine@vanderbilt.edu> wrote:
Hello.

I'm using the openstack connection api in python to create a server.

The server is getting created, but the "create_server" call is not assigning the ip-address to the server that is specified in the call.


flavor_id = 'ed88b5d6-150d-4715-8de0-8a2df0a1746a'
image_id = '399ae60e-7f73-476e-aad7-13aebcad84a1'
networks = [{'uuid': '978ebb40-8ee4-4c0b-932e-83dce7e182dd'}]
ip_addresses =[{'subnet_id': '978ebb40-8ee4-4c0b-932e-83dce7e182dd', 'ip_address': '10.0.0.153'}]

# also tried ip_addresses = ['10.0.0.153']

instance = conn.compute.create_server(
    name='testmachine',
    flavor_id=flavor_id,
    image_id=image_id,
    ips=ip_addresses,
    networks=network_uuid_list,
    key_name='key_name'
)


What is the format of the "ips" argument?  Are there other arguments that need to be specified?


Thanks for any help you can provide 🙂

-- Harmon


--
Thu.