- def prepare_vdu_on_boot(self, account, server_id, floating_ip):
- cmd = PREPARE_VM_CMD.format(auth_url = account.openstack.auth_url,
- username = account.openstack.key,
- password = account.openstack.secret,
- tenant_name = account.openstack.tenant,
- mgmt_network = account.openstack.mgmt_network,
- server_id = server_id)
-
- if floating_ip is not None:
- cmd += (" --floating_ip "+ floating_ip.ip)
+ def prepare_vdu_on_boot(self, account, server_id, floating_ip, pool_name, volumes=None):
+ cmd = PREPARE_VM_CMD.format(auth_url = account.openstack.auth_url,
+ username = account.openstack.key,
+ password = account.openstack.secret,
+ tenant_name = account.openstack.tenant,
+ region = account.openstack.region,
+ user_domain = account.openstack.user_domain,
+ project_domain = account.openstack.project_domain,
+ mgmt_network = account.openstack.mgmt_network,
+ server_id = server_id)
+ if floating_ip:
+ cmd += " --floating_ip"
+ if pool_name:
+ cmd += (" --pool_name " + pool_name)
+
+ vol_metadata = False
+ if volumes is not None:
+ for volume in volumes:
+ if volume.has_field('custom_meta_data'):
+ vol_metadata = True
+ break
+
+ if vol_metadata is True:
+ tmp_file = None
+ with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file:
+ vol_list = list()
+ for volume in volumes:
+ vol_dict = volume.as_dict()
+ vol_list.append(vol_dict)
+
+ yaml.dump(vol_list, tmp_file)
+ cmd += (" --vol_metadata {}").format(tmp_file.name)