diff options
author | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2021-09-07 11:28:35 -0400 |
---|---|---|
committer | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2021-09-13 12:50:16 -0400 |
commit | a819fc1df86721eda36eee89d0235c89b3159d6b (patch) | |
tree | bf4b7f7f15d7e7947f8d2ba81f79b4b48f75d2c4 /src/booking/quick_deployer.py | |
parent | d93346a716bde5237b7cfef5c10ea56e4922b59a (diff) |
Add user specified CI file entry
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Change-Id: Ia920130612da8fcde9d1a0d5dde7861904857162
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Diffstat (limited to 'src/booking/quick_deployer.py')
-rw-r--r-- | src/booking/quick_deployer.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/booking/quick_deployer.py b/src/booking/quick_deployer.py index 9e53da5..9bdebc2 100644 --- a/src/booking/quick_deployer.py +++ b/src/booking/quick_deployer.py @@ -26,6 +26,7 @@ from resource_inventory.models import ( NetworkConnection, InterfaceConfiguration, Network, + CloudInitFile, ) from resource_inventory.resource_manager import ResourceManager from resource_inventory.pdf_templater import PDFTemplater @@ -60,7 +61,7 @@ def parse_resource_field(resource_json): return lab, template -def update_template(old_template, image, hostname, user): +def update_template(old_template, image, hostname, user, global_cloud_config=None): """ Duplicate a template to the users account and update configured fields. @@ -112,9 +113,17 @@ def update_template(old_template, image, hostname, user): image=image_to_set, template=template, is_head_node=old_config.is_head_node, - name=hostname if len(old_template.getConfigs()) == 1 else old_config.name + name=hostname if len(old_template.getConfigs()) == 1 else old_config.name, + #cloud_init_files=old_config.cloud_init_files.set() ) + for file in old_config.cloud_init_files.all(): + config.cloud_init_files.add(file); + + if global_cloud_config: + config.cloud_init_files.add(global_cloud_config) + config.save() + for old_iface_config in old_config.interface_configs.all(): iface_config = InterfaceConfiguration.objects.create( profile=old_iface_config.profile, @@ -186,6 +195,13 @@ def check_invariants(request, **kwargs): if length < 1 or length > 21: raise BookingLengthException("Booking must be between 1 and 21 days long") +# global_cloud_config is Option<str> forming a valid yaml file if Some +def generate_cloud_configs(resource_bundle, global_cloud_config): + c_file = CloudInitFile.objects.new(priority=1) # apply after the internal + for host in resource_bundle.get_resources(): + #cfile = CloudInitFile::from_text( + pass + # TODO def create_from_form(form, request): """ @@ -200,6 +216,12 @@ def create_from_form(form, request): users_field = form.cleaned_data['users'] hostname = 'opnfv_host' if not form.cleaned_data['hostname'] else form.cleaned_data['hostname'] length = form.cleaned_data['length'] + global_cloud_config = None if not form.cleaned_data['global_cloud_config'] else form.cleaned_data['global_cloud_config'] + + if global_cloud_config: + print("about to create global cloud config") + global_cloud_config = CloudInitFile.create(text=global_cloud_config, priority=CloudInitFile.objects.count()) + print("made global cloud config") image = form.cleaned_data['image'] scenario = form.cleaned_data['scenario'] @@ -219,7 +241,7 @@ def create_from_form(form, request): ResourceManager.getInstance().templateIsReservable(resource_template) - resource_template = update_template(resource_template, image, hostname, request.user) + resource_template = update_template(resource_template, image, hostname, request.user, global_cloud_config=global_cloud_config) # if no installer provided, just create blank host opnfv_config = None @@ -231,6 +253,8 @@ def create_from_form(form, request): # generate resource bundle resource_bundle = generate_resource_bundle(resource_template) + #generate_cloud_configs(resource_bundle) + # generate booking booking = Booking.objects.create( purpose=purpose_field, |