How to assign an ip-address to a server on creation
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
according to this <https://docs.openstack.org/api-ref/compute/#create-server>, 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.
Hello Harmon, Based on this line the ips should be just list of floating IP addresses: https://github.com/openstack/openstacksdk/blob/30d5753bcf08b262a7879bd0831ea... 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 <https://docs.openstack.org/api-ref/compute/#create-server>, 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.
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<https://aka.ms/LearnAboutSenderIdentification> Hello Harmon, Based on this line the ips should be just list of floating IP addresses: https://github.com/openstack/openstacksdk/blob/30d5753bcf08b262a7879bd0831ea... 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<mailto:thuvh87@gmail.com>> wrote: according to this<https://docs.openstack.org/api-ref/compute/#create-server>, you can use fixed_ip On Fri, May 3, 2024 at 10:22 AM Nine, Harmon S <harmon.s.nine@vanderbilt.edu<mailto: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.
Hi. I was just looking at the code from the link you sent. Lines 926 and 927 are: if type(ips) is list: ips = [ips] Shouldn't it be: if type(ips) is not list: ips = [ips] -- Harmon ________________________________ From: Nine, Harmon S <harmon.s.nine@Vanderbilt.Edu> Sent: Friday, May 3, 2024 9:27 AM To: Jan Jasek <jjasek@redhat.com>; Hoai-Thu Vuong <thuvh87@gmail.com> Cc: 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 harmon.s.nine@vanderbilt.edu. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification> 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<https://aka.ms/LearnAboutSenderIdentification> Hello Harmon, Based on this line the ips should be just list of floating IP addresses: https://github.com/openstack/openstacksdk/blob/30d5753bcf08b262a7879bd0831ea... 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<mailto:thuvh87@gmail.com>> wrote: according to this<https://docs.openstack.org/api-ref/compute/#create-server>, you can use fixed_ip On Fri, May 3, 2024 at 10:22 AM Nine, Harmon S <harmon.s.nine@vanderbilt.edu<mailto: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.
To resolve this issue (for now), I've found that: The options for controlling the ip-address(es) of a new instance when created using the connection api do not work. Instead, I've had to use the NOVA api in conjunction with the connection api to control the ip addresses of a newly created instance: redeployed_server = conn.compute.find_server(self.hostname) project_id = redeployed_server.location.project.id nova_client = client.Client( version='2.1', username=self.username, password=self.password, project_id=project_id, auth_url=self.auth_url, user_domain_name=self.user_domain_name, project_domain_name=self.project_domain_name ) server_nova_client = nova_client.servers.get(redeployed_server.id) -- Harmon ________________________________ From: Nine, Harmon S <harmon.s.nine@Vanderbilt.Edu> Sent: Friday, May 3, 2024 11:26 AM To: Jan Jasek <jjasek@redhat.com>; Hoai-Thu Vuong <thuvh87@gmail.com> Cc: 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 harmon.s.nine@vanderbilt.edu. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification> Hi. I was just looking at the code from the link you sent. Lines 926 and 927 are: if type(ips) is list: ips = [ips] Shouldn't it be: if type(ips) is not list: ips = [ips] -- Harmon ________________________________ From: Nine, Harmon S <harmon.s.nine@Vanderbilt.Edu> Sent: Friday, May 3, 2024 9:27 AM To: Jan Jasek <jjasek@redhat.com>; Hoai-Thu Vuong <thuvh87@gmail.com> Cc: 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 harmon.s.nine@vanderbilt.edu. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification> 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<https://aka.ms/LearnAboutSenderIdentification> Hello Harmon, Based on this line the ips should be just list of floating IP addresses: https://github.com/openstack/openstacksdk/blob/30d5753bcf08b262a7879bd0831ea... 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<mailto:thuvh87@gmail.com>> wrote: according to this<https://docs.openstack.org/api-ref/compute/#create-server>, you can use fixed_ip On Fri, May 3, 2024 at 10:22 AM Nine, Harmon S <harmon.s.nine@vanderbilt.edu<mailto: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.
participants (3)
-
Hoai-Thu Vuong
-
Jan Jasek
-
Nine, Harmon S