示例#1
0
    def test_crt_lu_linked_clone(self, mock_run_job):
        clust1 = clust.Cluster.wrap(tju.load_file(CLUSTER, self.adpt))
        self.adpt.read.return_value = tju.load_file(LU_LINKED_CLONE_JOB,
                                                    self.adpt)

        def verify_run_job(uuid, job_parms):
            self.assertEqual(clust1.uuid, uuid)
            self.assertEqual(
                '<web:JobParameter xmlns:web="http://www.ibm.com/xmlns/systems'
                '/power/firmware/web/mc/2012_10/" schemaVersion="V1_0"><web:Pa'
                'rameterName>SourceUDID</web:ParameterName><web:ParameterValue'
                '>xxabc1231</web:ParameterValue></web:JobParameter>'.encode(
                    'utf-8'), job_parms[0].toxmlstring())
            self.assertEqual(
                '<web:JobParameter xmlns:web="http://www.ibm.com/xmlns/systems'
                '/power/firmware/web/mc/2012_10/" schemaVersion="V1_0"><web:Pa'
                'rameterName>DestinationUDID</web:ParameterName><web:Parameter'
                'Value>udid_linked_lu</web:ParameterValue></web:JobParameter>'.
                encode('utf-8'), job_parms[1].toxmlstring())

        mock_run_job.side_effect = verify_run_job
        ts.crt_lu_linked_clone(self.ssp, clust1, self.ssp.logical_units[0],
                               'linked_lu')
示例#2
0
    def test_crt_lu_linked_clone(self, mock_run_job):
        clust1 = clust.Cluster.wrap(tju.load_file(CLUSTER, self.adpt))
        self.adpt.read.return_value = tju.load_file(LU_LINKED_CLONE_JOB,
                                                    self.adpt)

        def verify_run_job(uuid, job_parms):
            self.assertEqual(clust1.uuid, uuid)
            self.assertEqual(
                '<web:JobParameter xmlns:web="http://www.ibm.com/xmlns/systems'
                '/power/firmware/web/mc/2012_10/" schemaVersion="V1_0"><web:Pa'
                'rameterName>SourceUDID</web:ParameterName><web:ParameterValue'
                '>xxabc1231</web:ParameterValue></web:JobParameter>'.
                encode('utf-8'),
                job_parms[0].toxmlstring())
            self.assertEqual(
                '<web:JobParameter xmlns:web="http://www.ibm.com/xmlns/systems'
                '/power/firmware/web/mc/2012_10/" schemaVersion="V1_0"><web:Pa'
                'rameterName>DestinationUDID</web:ParameterName><web:Parameter'
                'Value>udid_linked_lu</web:ParameterValue></web:JobParameter>'.
                encode('utf-8'),
                job_parms[1].toxmlstring())
        mock_run_job.side_effect = verify_run_job
        ts.crt_lu_linked_clone(self.ssp, clust1, self.ssp.logical_units[0],
                               'linked_lu')
示例#3
0
    def create_disk_from_image(self,
                               context,
                               instance,
                               img_meta,
                               disk_size_gb,
                               image_type=disk_drv.DiskType.BOOT):
        """Creates a boot disk and links the specified image to it.

        If the specified image has not already been uploaded, an Image LU is
        created for it.  A Disk LU is then created for the instance and linked
        to the Image LU.

        :param context: nova context used to retrieve image from glance
        :param instance: instance to create the disk for.
        :param img_meta: image metadata dict:
                      { 'id': reference used to locate the image in glance,
                        'size': size in bytes of the image. }
        :param disk_size_gb: The size of the disk to create in GB.  If smaller
                             than the image, it will be ignored (as the disk
                             must be at least as big as the image).  Must be an
                             int.
        :param image_type: The image type. See disk_drv.DiskType.
        :return: The backing pypowervm LU storage object that was created.
        """
        LOG.info(
            _LI('SSP: Create %(image_type)s disk from image %(image_id)s '
                'for instance %(instance_uuid)s.'),
            dict(image_type=image_type,
                 image_id=img_meta['id'],
                 instance_uuid=instance.uuid))

        # TODO(IBM): There's an optimization to be had here if we can create
        # both the image LU and the boot LU in the same ssp.update() call.
        # This will require some nontrivial refactoring, though, as the LUs are
        # created down inside of upload_new_lu and crt_lu_linked_clone.

        image_lu = self._get_or_upload_image_lu(context, img_meta)

        boot_lu_name = self._get_disk_name(image_type, instance)
        LOG.info(_LI('SSP: Disk name is %s'), boot_lu_name)

        ssp, boot_lu = tsk_stg.crt_lu_linked_clone(self._ssp, self._cluster,
                                                   image_lu, boot_lu_name,
                                                   disk_size_gb)

        return boot_lu
示例#4
0
    def create_disk_from_image(self, context, instance, img_meta, disk_size_gb,
                               image_type=disk_drv.DiskType.BOOT):
        """Creates a boot disk and links the specified image to it.

        If the specified image has not already been uploaded, an Image LU is
        created for it.  A Disk LU is then created for the instance and linked
        to the Image LU.

        :param context: nova context used to retrieve image from glance
        :param instance: instance to create the disk for.
        :param img_meta: image metadata dict:
                      { 'id': reference used to locate the image in glance,
                        'size': size in bytes of the image. }
        :param disk_size_gb: The size of the disk to create in GB.  If smaller
                             than the image, it will be ignored (as the disk
                             must be at least as big as the image).  Must be an
                             int.
        :param image_type: The image type. See disk_drv.DiskType.
        :return: The backing pypowervm LU storage object that was created.
        """
        LOG.info(_LI('SSP: Create %(image_type)s disk from image %(image_id)s '
                     'for instance %(instance_uuid)s.'),
                 dict(image_type=image_type, image_id=img_meta['id'],
                      instance_uuid=instance.uuid))

        # TODO(IBM): There's an optimization to be had here if we can create
        # both the image LU and the boot LU in the same ssp.update() call.
        # This will require some nontrivial refactoring, though, as the LUs are
        # created down inside of upload_new_lu and crt_lu_linked_clone.

        image_lu = self._get_or_upload_image_lu(context, img_meta)

        boot_lu_name = self._get_disk_name(image_type, instance)
        LOG.info(_LI('SSP: Disk name is %s'), boot_lu_name)

        ssp, boot_lu = tsk_stg.crt_lu_linked_clone(
            self._ssp, self._cluster, image_lu, boot_lu_name, disk_size_gb)

        return boot_lu