instance_name="functest-vm",
confdrive=True,
userdata=None,
- av_zone=''):
+ av_zone='',
+ fixed_ip=None,
+ files=None):
nova_client = get_nova_client()
try:
flavor = nova_client.flavors.find(name=flavor_name)
except:
print("Error: Flavor '%s' not found. Available flavors are:" %
flavor_name)
- print(nova_client.flavor.list())
+ print(nova_client.flavors.list())
return -1
+ if fixed_ip is not None:
+ nics = {"net-id": network_id, "v4-fixed-ip": fixed_ip}
+ else:
+ nics = {"net-id": network_id}
if userdata is None:
instance = nova_client.servers.create(
name=instance_name,
flavor=flavor,
image=image_id,
- nics=[{"net-id": network_id}],
- availability_zone=av_zone
+ nics=[nics],
+ availability_zone=av_zone,
+ files=files
)
else:
instance = nova_client.servers.create(
name=instance_name,
flavor=flavor,
image=image_id,
- nics=[{"net-id": network_id}],
+ nics=[nics],
config_drive=confdrive,
userdata=userdata,
- availability_zone=av_zone
+ availability_zone=av_zone,
+ files=files
)
return instance
instance_name="",
config_drive=False,
userdata="",
- av_zone=''):
+ av_zone='',
+ fixed_ip=None,
+ files=None):
SLEEP = 3
VM_BOOT_TIMEOUT = 180
nova_client = get_nova_client()
instance_name,
config_drive,
userdata,
- av_zone)
-
+ av_zone=av_zone,
+ fixed_ip=fixed_ip,
+ files=files)
count = VM_BOOT_TIMEOUT / SLEEP
for n in range(count, -1, -1):
status = get_instance_status(nova_client, instance)
def delete_bgpvpn(neutron_client, bgpvpn_id):
return neutron_client.delete_bgpvpn(bgpvpn_id)
-
# *********************************************
# SEC GROUPS
# *********************************************