conn: Connection = create_connection()
nics = [{'net-id': '`net_id`', 'subnet-id': '`subnet_id`'}]
params = {
'name': 'Instance_app_2',
'networks': [{'uuid': 'net_id'}],
'nics': nics,
'security_groups': [{'name': 'GroupName'}],
'user_data': create_user_data(), # encoded user_data
'flavor_id': '`flavor_id`'
'image_id': '`image_id`',
'ipv6_address_mode': None,
'ipv6_ra_mode': None,
}
server = conn.compute.create_server(**params)
I run the code and create a server have both IPv4 and IPv6. How can I create a new server with only IPv4 ? please
Firstly, ipv6_address_mode
and ipv6_ra_mode
are used by network.create_subnet
rather than compute.create_server
method, and their Valid values are: 'dhcpv6-stateful', 'dhcpv6-stateless', or 'slaac'
.
Secondly, the networks
parameter Mutually exclusive with the nics parameter
in create_server
method.
Lastly, in your case create a server have both IPv4 and IPv6
, I guess that you had already defined the ipv6_address_scope
in net_id or ipv6_*_mode
in subnet_id, so it would auto create ipv6 address.
Try to create a port_id which port only with ipv4 address, and just use 'nics': port_id,
to create_server
.
see also: https://docs.openstack.org/openstacksdk/latest/user/connection.html