Ejemplo n.º 1
0
    def create_vdi(self, vdi_struct, transient = False, create_file = True):
        """ Creates a fake VDI image for a traditional image string.

        The image uri is stored in the attribute 'uri'
        """
        if not vdi_struct.get('uuid') or vdi_struct.get('uuid') == '':
            vdi_struct['uuid'] = uuid.gen_regularUuid()
        vdi_struct['SR'] = self.uuid
        location = vdi_struct['location']
        vdi_struct['location'] = self.replace_backend_driver_with_default_type(location)
        if create_file:         
            self.create_img_file(vdi_struct)
#            self.create_logical_volume(vdi_struct)    
        new_image = XendLocalOcfs2VDI(vdi_struct)
        self.images[new_image.uuid] = new_image
        self.save_state(transient)
        return new_image.uuid
Ejemplo n.º 2
0
    def copy_vdi(self, vdi_struct, p_vdi_uuid, transient = False, copy_file = False):
        """ Creates a fake VDI image for a traditional image string.

        The image uri is stored in the attribute 'uri'
        """
        log.debug('==========copy_vdi=============')
        if not vdi_struct.get('uuid') or vdi_struct.get('uuid') == '':
            vdi_struct['uuid'] = uuid.gen_regularUuid()    
             
        vdi_struct['SR'] = self.uuid
        vdi_struct['parent'] = p_vdi_uuid  
        vdi_struct['children'] = []
        new_image = XendLocalOcfs2VDI(vdi_struct)
        if copy_file:            
            self.copy_img_file(vdi_struct, p_vdi_uuid)
#            self.create_logical_volume(vdi_struct)    
        self.images[new_image.uuid] = new_image  
#        self.add_vdi_children(p_vdi_uuid, vdi_struct['uuid']) 
        
        self.save_state(transient)
        return new_image.uuid