Examples of MockVolumeVO


Examples of com.cloud.simulator.MockVolumeVO

                txn.close();
      }

      // preinstall default templates into secondary storage
      long defaultTemplateSize = 2 * 1024 * 1024 * 1024L;
      MockVolumeVO template = new MockVolumeVO();
      template.setName("simulator-domR");
      template.setPath(storage.getMountPoint() + "template/tmpl/1/9/" + UUID.randomUUID().toString());
      template.setPoolId(storage.getId());
      template.setSize(defaultTemplateSize);
      template.setType(MockVolumeType.TEMPLATE);
      template.setStatus(Status.DOWNLOADED);
      txn = Transaction.open(Transaction.SIMULATOR_DB);
      try {
        txn.start();
        template = _mockVolumeDao.persist(template);
        txn.commit();
      } catch (Exception ex) {
        txn.rollback();
        throw new CloudRuntimeException("Error when saving template " + template, ex);
      } finally {
        txn.close();
                txn = Transaction.open(Transaction.CLOUD_DB);
                txn.close();
      }

      template = new MockVolumeVO();
      template.setName("simulator-Centos");
      template.setPath(storage.getMountPoint() + "template/tmpl/1/10/" + UUID.randomUUID().toString());
      template.setPoolId(storage.getId());
      template.setSize(defaultTemplateSize);
      template.setType(MockVolumeType.TEMPLATE);
      template.setStatus(Status.DOWNLOADED);
      txn = Transaction.open(Transaction.SIMULATOR_DB);
      try {
        txn.start();
        template = _mockVolumeDao.persist(template);
        txn.commit();
View Full Code Here

Examples of com.cloud.simulator.MockVolumeVO

  }

  @Override
  public CreatePrivateTemplateAnswer CreatePrivateTemplateFromSnapshot(CreatePrivateTemplateFromSnapshotCommand cmd) {
    Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
    MockVolumeVO snapshot = null;
    MockSecStorageVO sec = null;
    try {
      txn.start();
      String snapshotUUId = cmd.getSnapshotUuid();
      snapshot = _mockVolumeDao.findByName(snapshotUUId);
      if (snapshot == null) {
        snapshotUUId = cmd.getSnapshotName();
        snapshot = _mockVolumeDao.findByName(snapshotUUId);
        if (snapshot == null) {
          return new CreatePrivateTemplateAnswer(cmd, false, "can't find snapshot:" + snapshotUUId);
        }
      }

      sec = _mockSecStorageDao.findByUrl(cmd.getSecondaryStorageUrl());
      if (sec == null) {
        return new CreatePrivateTemplateAnswer(cmd, false, "can't find secondary storage");
      }
      txn.commit();
    } finally {
      txn.close();
            txn = Transaction.open(Transaction.CLOUD_DB);
            txn.close();
    }

    MockVolumeVO template = new MockVolumeVO();
    String uuid = UUID.randomUUID().toString();
    template.setName(uuid);
    template.setPath(sec.getMountPoint() + uuid);
    template.setPoolId(sec.getId());
    template.setSize(snapshot.getSize());
    template.setStatus(Status.DOWNLOADED);
    template.setType(MockVolumeType.TEMPLATE);
    txn = Transaction.open(Transaction.SIMULATOR_DB);
    try {
      txn.start();
      template = _mockVolumeDao.persist(template);
      txn.commit();
    } catch (Exception ex) {
      txn.rollback();
      throw new CloudRuntimeException("Error when saving template " + template, ex);
    } finally {
      txn.close();
            txn = Transaction.open(Transaction.CLOUD_DB);
            txn.close();
    }

    return new CreatePrivateTemplateAnswer(cmd, true, "", template.getName(), template.getSize(),
        template.getSize(), template.getName(), ImageFormat.QCOW2);
  }
View Full Code Here

Examples of com.cloud.simulator.MockVolumeVO

  @Override
  public Answer ComputeChecksum(ComputeChecksumCommand cmd) {
    Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
    try {
      txn.start();
      MockVolumeVO volume = _mockVolumeDao.findByName(cmd.getTemplatePath());
      if (volume == null) {
        return new Answer(cmd, false, "cant' find volume:" + cmd.getTemplatePath());
      }
      String md5 = null;
      try {
View Full Code Here

Examples of com.cloud.simulator.MockVolumeVO

  }

  @Override
  public CreatePrivateTemplateAnswer CreatePrivateTemplateFromVolume(CreatePrivateTemplateFromVolumeCommand cmd) {
    Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
    MockVolumeVO volume = null;
    MockSecStorageVO sec = null;
    try {
      txn.start();
      volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolumePath());
      if (volume == null) {
        return new CreatePrivateTemplateAnswer(cmd, false, "cant' find volume" + cmd.getVolumePath());
      }

      sec = _mockSecStorageDao.findByUrl(cmd.getSecondaryStorageUrl());
      if (sec == null) {
        return new CreatePrivateTemplateAnswer(cmd, false, "can't find secondary storage");
      }
      txn.commit();
    } catch (Exception ex) {
      txn.rollback();
      throw new CloudRuntimeException("Error when creating private template from volume");
    } finally {
      txn.close();
            txn = Transaction.open(Transaction.CLOUD_DB);
            txn.close();
    }

    MockVolumeVO template = new MockVolumeVO();
    String uuid = UUID.randomUUID().toString();
    template.setName(uuid);
    template.setPath(sec.getMountPoint() + uuid);
    template.setPoolId(sec.getId());
    template.setSize(volume.getSize());
    template.setStatus(Status.DOWNLOADED);
    template.setType(MockVolumeType.TEMPLATE);
    txn = Transaction.open(Transaction.SIMULATOR_DB);
    try {
      txn.start();
      template = _mockVolumeDao.persist(template);
      txn.commit();
    } catch (Exception ex) {
      txn.rollback();
      throw new CloudRuntimeException("Encountered " + ex.getMessage() + " when persisting template "
          + template.getName(), ex);
    } finally {
      txn.close();
            txn = Transaction.open(Transaction.CLOUD_DB);
            txn.close();
    }

    return new CreatePrivateTemplateAnswer(cmd, true, "", template.getName(), template.getSize(),
        template.getSize(), template.getName(), ImageFormat.QCOW2);
  }
View Full Code Here

Examples of com.cloud.simulator.MockVolumeVO

      txn.close();
            txn = Transaction.open(Transaction.CLOUD_DB);
            txn.close();
    }

    MockVolumeVO volume = null;
    txn = Transaction.open(Transaction.SIMULATOR_DB);
    try {
      txn.start();
      volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolumePath());
      if (volume == null) {
        return new CopyVolumeAnswer(cmd, false, "cant' find volume" + cmd.getVolumePath(), null, null);
      }
      txn.commit();
    } catch (Exception ex) {
      txn.rollback();
      throw new CloudRuntimeException("Encountered " + ex.getMessage() + " when accessing volume at "
          + cmd.getVolumePath(), ex);
    } finally {
      txn.close();
            txn = Transaction.open(Transaction.CLOUD_DB);
            txn.close();
    }

    String name = UUID.randomUUID().toString();
    if (toSecondaryStorage) {
      MockVolumeVO vol = new MockVolumeVO();
      vol.setName(name);
      vol.setPath(sec.getMountPoint() + name);
      vol.setPoolId(sec.getId());
      vol.setSize(volume.getSize());
      vol.setStatus(Status.DOWNLOADED);
      vol.setType(MockVolumeType.VOLUME);
      txn = Transaction.open(Transaction.SIMULATOR_DB);
      try {
        txn.start();
        vol = _mockVolumeDao.persist(vol);
        txn.commit();
      } catch (Exception ex) {
        txn.rollback();
        throw new CloudRuntimeException("Encountered " + ex.getMessage() + " when persisting volume "
            + vol.getName(), ex);
      } finally {
        txn.close();
                txn = Transaction.open(Transaction.CLOUD_DB);
                txn.close();
      }
      return new CopyVolumeAnswer(cmd, true, null, sec.getMountPoint(), vol.getPath());
    } else {
      MockVolumeVO vol = new MockVolumeVO();
      vol.setName(name);
      vol.setPath(primaryStorage.getMountPoint() + name);
      vol.setPoolId(primaryStorage.getId());
      vol.setSize(volume.getSize());
      vol.setStatus(Status.DOWNLOADED);
      vol.setType(MockVolumeType.VOLUME);
      txn = Transaction.open(Transaction.SIMULATOR_DB);
      try {
        txn.start();
        vol = _mockVolumeDao.persist(vol);
        txn.commit();
      } catch (Exception ex) {
        txn.rollback();
        throw new CloudRuntimeException("Encountered " + ex.getMessage() + " when persisting volume "
            + vol.getName(), ex);
      } finally {
        txn.close();
                txn = Transaction.open(Transaction.CLOUD_DB);
                txn.close();
      }
      return new CopyVolumeAnswer(cmd, true, null, primaryStorage.getMountPoint(), vol.getPath());
    }
  }
View Full Code Here

Examples of com.cloud.simulator.MockVolumeVO

    }

    @Override
    public CreatePrivateTemplateAnswer CreatePrivateTemplateFromSnapshot(CreatePrivateTemplateFromSnapshotCommand cmd) {
        TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
        MockVolumeVO snapshot = null;
        MockSecStorageVO sec = null;
        try {
            txn.start();
            String snapshotUUId = cmd.getSnapshotUuid();
            snapshot = _mockVolumeDao.findByName(snapshotUUId);
            if (snapshot == null) {
                snapshotUUId = cmd.getSnapshotName();
                snapshot = _mockVolumeDao.findByName(snapshotUUId);
                if (snapshot == null) {
                    return new CreatePrivateTemplateAnswer(cmd, false, "can't find snapshot:" + snapshotUUId);
                }
            }

            sec = _mockSecStorageDao.findByUrl(cmd.getSecondaryStorageUrl());
            if (sec == null) {
                return new CreatePrivateTemplateAnswer(cmd, false, "can't find secondary storage");
            }
            txn.commit();
        } finally {
            txn.close();
            txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
            txn.close();
        }

        MockVolumeVO template = new MockVolumeVO();
        String uuid = UUID.randomUUID().toString();
        template.setName(uuid);
        template.setPath(sec.getMountPoint() + uuid);
        template.setPoolId(sec.getId());
        template.setSize(snapshot.getSize());
        template.setStatus(Status.DOWNLOADED);
        template.setType(MockVolumeType.TEMPLATE);
        txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
        try {
            txn.start();
            template = _mockVolumeDao.persist(template);
            txn.commit();
        } catch (Exception ex) {
            txn.rollback();
            throw new CloudRuntimeException("Error when saving template " + template, ex);
        } finally {
            txn.close();
            txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
            txn.close();
        }

        return new CreatePrivateTemplateAnswer(cmd, true, "", template.getName(), template.getSize(), template.getSize(), template.getName(), ImageFormat.QCOW2);
    }
View Full Code Here

Examples of com.cloud.simulator.MockVolumeVO

    @Override
    public Answer ComputeChecksum(ComputeChecksumCommand cmd) {
        TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
        try {
            txn.start();
            MockVolumeVO volume = _mockVolumeDao.findByName(cmd.getTemplatePath());
            if (volume == null) {
                return new Answer(cmd, false, "cant' find volume:" + cmd.getTemplatePath());
            }
            String md5 = null;
            try {
View Full Code Here

Examples of com.cloud.simulator.MockVolumeVO

    }

    @Override
    public CreatePrivateTemplateAnswer CreatePrivateTemplateFromVolume(CreatePrivateTemplateFromVolumeCommand cmd) {
        TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
        MockVolumeVO volume = null;
        MockSecStorageVO sec = null;
        try {
            txn.start();
            volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolumePath());
            if (volume == null) {
                return new CreatePrivateTemplateAnswer(cmd, false, "cant' find volume" + cmd.getVolumePath());
            }

            sec = _mockSecStorageDao.findByUrl(cmd.getSecondaryStorageUrl());
            if (sec == null) {
                return new CreatePrivateTemplateAnswer(cmd, false, "can't find secondary storage");
            }
            txn.commit();
        } catch (Exception ex) {
            txn.rollback();
            throw new CloudRuntimeException("Error when creating private template from volume");
        } finally {
            txn.close();
            txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
            txn.close();
        }

        MockVolumeVO template = new MockVolumeVO();
        String uuid = UUID.randomUUID().toString();
        template.setName(uuid);
        template.setPath(sec.getMountPoint() + uuid);
        template.setPoolId(sec.getId());
        template.setSize(volume.getSize());
        template.setStatus(Status.DOWNLOADED);
        template.setType(MockVolumeType.TEMPLATE);
        txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
        try {
            txn.start();
            template = _mockVolumeDao.persist(template);
            txn.commit();
        } catch (Exception ex) {
            txn.rollback();
            throw new CloudRuntimeException("Encountered " + ex.getMessage() + " when persisting template " + template.getName(), ex);
        } finally {
            txn.close();
            txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
            txn.close();
        }

        return new CreatePrivateTemplateAnswer(cmd, true, "", template.getName(), template.getSize(), template.getSize(), template.getName(), ImageFormat.QCOW2);
    }
View Full Code Here

Examples of com.cloud.simulator.MockVolumeVO

            txn.close();
            txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
            txn.close();
        }

        MockVolumeVO volume = null;
        txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
        try {
            txn.start();
            volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolumePath());
            if (volume == null) {
                return new CopyVolumeAnswer(cmd, false, "cant' find volume" + cmd.getVolumePath(), null, null);
            }
            txn.commit();
        } catch (Exception ex) {
            txn.rollback();
            throw new CloudRuntimeException("Encountered " + ex.getMessage() + " when accessing volume at " + cmd.getVolumePath(), ex);
        } finally {
            txn.close();
            txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
            txn.close();
        }

        String name = UUID.randomUUID().toString();
        if (toSecondaryStorage) {
            MockVolumeVO vol = new MockVolumeVO();
            vol.setName(name);
            vol.setPath(sec.getMountPoint() + name);
            vol.setPoolId(sec.getId());
            vol.setSize(volume.getSize());
            vol.setStatus(Status.DOWNLOADED);
            vol.setType(MockVolumeType.VOLUME);
            txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
            try {
                txn.start();
                vol = _mockVolumeDao.persist(vol);
                txn.commit();
            } catch (Exception ex) {
                txn.rollback();
                throw new CloudRuntimeException("Encountered " + ex.getMessage() + " when persisting volume " + vol.getName(), ex);
            } finally {
                txn.close();
                txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
                txn.close();
            }
            return new CopyVolumeAnswer(cmd, true, null, sec.getMountPoint(), vol.getPath());
        } else {
            MockVolumeVO vol = new MockVolumeVO();
            vol.setName(name);
            vol.setPath(primaryStorage.getMountPoint() + name);
            vol.setPoolId(primaryStorage.getId());
            vol.setSize(volume.getSize());
            vol.setStatus(Status.DOWNLOADED);
            vol.setType(MockVolumeType.VOLUME);
            txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
            try {
                txn.start();
                vol = _mockVolumeDao.persist(vol);
                txn.commit();
            } catch (Exception ex) {
                txn.rollback();
                throw new CloudRuntimeException("Encountered " + ex.getMessage() + " when persisting volume " + vol.getName(), ex);
            } finally {
                txn.close();
                txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
                txn.close();
            }
            return new CopyVolumeAnswer(cmd, true, null, primaryStorage.getMountPoint(), vol.getPath());
        }
    }
View Full Code Here

Examples of com.cloud.simulator.MockVolumeVO

            if (secStorage == null) {
                return null;
            }
            volumePath = secStorage.getMountPoint() + volumePath;
            volumePath = volumePath.replaceAll("//", "/");
            MockVolumeVO volume = _mockVolumeDao.findByStoragePathAndType(volumePath);
            txn.commit();
            if (volume == null) {
                return null;
            }
            return volume;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.