示例#1
0
    def clone(self, pool, name, new_pool=None, new_name=None):
        """Clone a storage volume.

        Arguments:
        pool -- The name of the original pool.
        name -- The name of the original volume.
        new_pool -- The name of the destination pool (optional). If omitted,
            the new volume will be created on the same pool as the
            original one.
        new_name -- The name of the new volume (optional). If omitted, a new
            value based on the original volume's name will be used.

        Return:
        A Task running the clone operation.
        """
        # the same pool will be used if no pool is specified
        if new_pool is None:
            new_pool = pool

        # a default name based on the original name will be used if no name
        # is specified
        if new_name is None:
            base, ext = os.path.splitext(name)
            new_name = get_next_clone_name(self.storagevolumes.get_list(pool),
                                           base, ext)

        params = {'pool': pool,
                  'name': name,
                  'new_pool': new_pool,
                  'new_name': new_name}
        taskid = add_task(u'/plugins/kimchi/storagepools/%s/storagevolumes/%s'
                          % (pool, new_name), self._clone_task, self.objstore,
                          params)
        return self.task.lookup(taskid)
示例#2
0
 def _mock_vm_clone(self, name):
     new_name = get_next_clone_name(self.vms_get_list(), name)
     snapshots = MockModel._mock_snapshots.get(name, [])
     MockModel._mock_snapshots[new_name] = snapshots
     return self._model_vm_clone(name)
示例#3
0
 def _mock_vm_clone(self, name):
     new_name = get_next_clone_name(self.vms_get_list(), name)
     snapshots = MockModel._mock_snapshots.get(name, [])
     MockModel._mock_snapshots[new_name] = snapshots
     return self._model_vm_clone(name)