def fix_private_images_without_repr(private_images, prov, accounts): """ See if image has a machine request See if we can 'piece it together' """ for img in private_images: machine_requests = MachineRequest.objects.filter( new_machine_provider=prov, new_application_name=img.name) for mr in machine_requests: print "Machine Request found matching name %s of image %s" \ % (img.name, img.id) if mr.status != 'completed': print "Processing machine with image %s" % img.id process_machine_request(mr, img.id) pm = mr.new_machine if mr.new_application_visibility.lower() == 'public': make_public(accounts.image_manager, img, pm) continue # Private or selected access.. access_list = parse_list(mr.access_list, prov.id) # Fix on the image tenant_list = sync_image_access_list( accounts, img, names=access_list) # Fix on the database make_private(accounts.image_manager, img, pm, tenant_list)
def fix_private_images_without_repr(private_images, prov, accounts): """ See if image has a machine request See if we can 'piece it together' """ for img in private_images: machine_requests = MachineRequest.objects.filter( new_machine_provider=prov, new_application_name=img.name) for mr in machine_requests: print "Machine Request found matching name %s of image %s" \ % (img.name, img.id) if mr.status != 'completed': print "Processing machine with image %s" % img.id process_machine_request(mr, img.id) pm = mr.new_machine if mr.new_application_visibility.lower() == 'public': make_public(accounts.image_manager, img, pm) continue # Private or selected access.. access_list = parse_list(mr.access_list, prov.id) # Fix on the image tenant_list = sync_image_access_list(accounts, img, names=access_list) # Fix on the database make_private(accounts.image_manager, img, pm, tenant_list)
def process_request(new_image_id, machine_request_id): """ First, save the new image id so we can resume in case of failure. Then, Invalidate the machine cache to avoid a cache miss. Then, process the request by creating/updating all core objects related to this specific machine request. Finally, update the metadata on the provider. """ machine_request = MachineRequest.objects.get(id=machine_request_id) machine_request.status = 'processing - %s' % new_image_id machine_request.save() # TODO: Best if we could 'broadcast' this to all running # Apache WSGI procs && celery 'imaging' procs process_machine_request(machine_request, new_image_id) return new_image_id
def _process_new_update_request(self, machine, new_name, new_version, uuid_suffix, update_date=None): if not update_date: update_date = self.start_time instance = self._new_instance_of(machine, update_date) update_request_helper = CoreMachineRequestHelper( new_name, update_date, new_version, False, instance) core_request = update_request_helper.to_core_machine_request() process_machine_request(core_request, 'machine-%s' % uuid_suffix, update_cloud=False) new_machine = core_request.new_machine return new_machine
def _process_new_update_request( self, machine, new_name, new_version, uuid_suffix, update_date=None): if not update_date: update_date = self.start_time instance = self._new_instance_of(machine, update_date) update_request_helper = CoreMachineRequestHelper( new_name, update_date, new_version, False, instance) core_request = update_request_helper.to_core_machine_request() process_machine_request(core_request, 'machine-%s' % uuid_suffix, update_cloud=False) new_machine = core_request.new_machine return new_machine
def _process_new_fork_request(self, machine, new_name, new_version, uuid_suffix, fork_date=None): if not fork_date: fork_date = self.start_time instance = self._new_instance_of(machine, fork_date) # Create a MachineRequest for newly created Instance new_app_request_helper = CoreMachineRequestHelper( new_name, fork_date, new_version, True, instance) new_app_request = new_app_request_helper.to_core_machine_request() process_machine_request(new_app_request, 'machine-%s' % uuid_suffix, update_cloud=False) new_machine = new_app_request.new_machine return new_machine
def _process_new_fork_request( self, machine, new_name, new_version, uuid_suffix, fork_date=None): if not fork_date: fork_date = self.start_time instance = self._new_instance_of(machine, fork_date) # Create a MachineRequest for newly created Instance new_app_request_helper = CoreMachineRequestHelper( new_name, fork_date, new_version, True, instance) new_app_request = new_app_request_helper.to_core_machine_request() process_machine_request(new_app_request, 'machine-%s' % uuid_suffix, update_cloud=False) new_machine = new_app_request.new_machine return new_machine
def process_request(new_image_id, machine_request_id): """ First, save the new image id so we can resume in case of failure. Then, Invalidate the machine cache to avoid a cache miss. Then, process the request by creating/updating all core objects related to this specific machine request. Finally, update the metadata on the provider. """ machine_request = MachineRequest.objects.get(id=machine_request_id) new_status, _ = StatusType.objects.get_or_create(name="processing") machine_request.status = new_status machine_request.old_status = 'processing - %s' % new_image_id # HACK - TODO - replace with proper `default` in model # PATCHED (lenards, 2015-12-21) if machine_request.new_version_name is None: machine_request.new_version_name = "1.0" machine_request.save() # TODO: Best if we could 'broadcast' this to all running # Apache WSGI procs && celery 'imaging' procs process_machine_request(machine_request, new_image_id) return new_image_id