def show_vm_boot_process(self, output_id): output_file = image_boot_output_map.get_output_file_path(output_id) if output_file != None: return html_utils.file_watch_page(output_file) else: return html_utils.message( 'Could not get output of image boot process.')
def boot_vm(self, image_name=None, image_location=None, arch=None, cloud=None, ram=None, network=None, cpus=None, blank_space_MB=None): try: t = ImageBooter(image_name, image_location, arch, cloud, ram, network, cpus, cherrypy.request.wsgi_environ['X509_USER_PROXY'], blank_space_MB) boot_process_id = t.get_boot_process_id() t.start() cherrypy.log('Image booter thread started.') #return html_utils.message('Boot process started.') return html_utils.message('Image boot process initiated.<br><a href="/webui/show_vm_boot_process?output_id=%s">Watch boot progress</a>' % (boot_process_id)) except Exception, e: return html_utils.exception_page(e)
def create_image(self, image_name=None, image_description=None, image_file=None, image_source=None, source_image=None, unauthenticated_access=False): args = {} args['name'] = image_name args['description'] = image_description args['unauthenticated_access'] = unauthenticated_access try: # Check if image already exist. try: previous_image = self.get_repoman_client().describe_image('%s/%s' % (self.get_repoman_username(), image_name)) return html_utils.message('An image with name <i>%s</i> already exist.<br>Please select another name.' % (image_name)) except InvalidUserProxy, e: return html_utils.exception_page(e) except Exception, e: pass
def boot_vm(self, image_name=None, image_location=None, arch=None, cloud=None, ram=None, network=None, cpus=None, blank_space_MB=None): try: t = ImageBooter(image_name, image_location, arch, cloud, ram, network, cpus, cherrypy.request.wsgi_environ['X509_USER_PROXY'], blank_space_MB) boot_process_id = t.get_boot_process_id() t.start() cherrypy.log('Image booter thread started.') #return html_utils.message('Boot process started.') return html_utils.message( 'Image boot process initiated.<br><a href="/webui/show_vm_boot_process?output_id=%s">Watch boot progress</a>' % (boot_process_id)) except Exception, e: return html_utils.exception_page(e)
def create_image(self, image_name=None, image_description=None, image_file=None, image_source=None, source_image=None, unauthenticated_access=False): args = {} args['name'] = image_name args['description'] = image_description args['unauthenticated_access'] = unauthenticated_access try: # Check if image already exist. try: previous_image = self.get_repoman_client().describe_image( '%s/%s' % (self.get_repoman_username(), image_name)) return html_utils.message( 'An image with name <i>%s</i> already exist.<br>Please select another name.' % (image_name)) except InvalidUserProxy, e: return html_utils.exception_page(e) except Exception, e: pass
def delete_cached_user_proxy(self): user_proxy = cherrypy.request.wsgi_environ['X509_USER_PROXY'] user_info_file = user_proxy.replace('-delegation','-user') os.remove(user_proxy) os.remove(user_info_file) return html_utils.message('Cached user proxy deleted.')
def show_vm_boot_process(self, output_id): output_file = image_boot_output_map.get_output_file_path(output_id) if output_file != None: return html_utils.file_watch_page(output_file) else: return html_utils.message('Could not get output of image boot process.')
args['name'] = image_name args['description'] = image_description args['unauthenticated_access'] = unauthenticated_access try: # Check if image already exist. try: previous_image = self.get_repoman_client().describe_image('%s/%s' % (self.get_repoman_username(), image_name)) return html_utils.message('An image with name <i>%s</i> already exist.<br>Please select another name.' % (image_name)) except InvalidUserProxy, e: return html_utils.exception_page(e) except Exception, e: pass if image_name == None or len(image_name) == 0: return html_utils.message('You need to enter a image name for the new image.<br>Please try again.') if image_source == 'from_existing_image': # Feature not implemented yet. return html_utils.message('Creating an image by cloning an existing image as not been been implemented.<br>Please select another image source.') if image_source == 'from_uploaded_file' and (image_file == None or image_file.file == None): return html_utils.message('Please select an image file to upload.') # Proceed and create the new image metadata. self.get_repoman_client().create_image_metadata(**args) cherrypy.log('New image metadata created.') if image_source == 'from_uploaded_file' and image_file != None and image_file.file != None: url = 'https://vmrepo.cloud.nrc.ca/api/images/raw/%s/%s' % (self.get_repoman_username(), image_name)
def delete_cached_user_proxy(self): user_proxy = cherrypy.request.wsgi_environ['X509_USER_PROXY'] user_info_file = user_proxy.replace('-delegation', '-user') os.remove(user_proxy) os.remove(user_info_file) return html_utils.message('Cached user proxy deleted.')
try: # Check if image already exist. try: previous_image = self.get_repoman_client().describe_image( '%s/%s' % (self.get_repoman_username(), image_name)) return html_utils.message( 'An image with name <i>%s</i> already exist.<br>Please select another name.' % (image_name)) except InvalidUserProxy, e: return html_utils.exception_page(e) except Exception, e: pass if image_name == None or len(image_name) == 0: return html_utils.message( 'You need to enter a image name for the new image.<br>Please try again.' ) if image_source == 'from_existing_image': # Feature not implemented yet. return html_utils.message( 'Creating an image by cloning an existing image as not been been implemented.<br>Please select another image source.' ) if image_source == 'from_uploaded_file' and ( image_file == None or image_file.file == None): return html_utils.message( 'Please select an image file to upload.') # Proceed and create the new image metadata. self.get_repoman_client().create_image_metadata(**args)