コード例 #1
0
  /**
   * Creates nodes that correspond to the Virtualapp for the this object
   *
   * @throws PersistenceException
   */
  public void createNodes() throws PersistenceException {

    VirtualMachine virtualMachine = new VirtualMachine();
    factorytest = HibernateDAOFactory.instance();
    HyperVisorDAO dao = factorytest.getHyperVisorDAO();

    factorytest.beginConnection();

    virtualMachine.setAssignedTo(dao.findById(hypervisor.getIdHyper()).toPojo());
    virtualMachine.setHd(1);
    virtualMachine.setHighDisponibility(true);
    virtualMachine.setDescription("test-virtual machine");
    virtualMachine.setCpu(2);
    virtualMachine.setRam(256);
    virtualMachine.setUUID("apophis");
    State state = new State(StateEnum.NOT_DEPLOYED);
    virtualMachine.setState(state);
    virtualMachine.setVdrpIP("vdrpIP");
    virtualMachine.setVdrpPort(5050);

    VirtualimageHB virtualImageHB = createVirtualImage("image", 4, 256, 2);
    virtualMachine.setVirtualImage(virtualImageHB.toPojo());

    createVirtualImageNode(virtualImageHB, virtualMachine);

    factorytest.endConnection();
  }
コード例 #2
0
ファイル: VirtualmachineHB.java プロジェクト: grkvlt/abiquo
  @Override
  public VirtualMachine toPojo() {
    VirtualMachine virtualMachine = new VirtualMachine();

    virtualMachine.setId(idVm);
    virtualMachine.setName(name);

    if (hypervisor == null) {
      virtualMachine.setAssignedTo(null);
    } else {
      virtualMachine.setAssignedTo(hypervisor.toPojo());
    }

    if (conversion == null) {
      virtualMachine.setConversion(null);
    } else {
      virtualMachine.setConversion(conversion.toPojo());
    }

    virtualMachine.setVirtualImage(image == null ? null : image.toPojo());
    virtualMachine.setUUID(uuid);
    virtualMachine.setDescription(description);
    virtualMachine.setRam(ram);
    virtualMachine.setCpu(cpu);
    virtualMachine.setHd(hd);
    virtualMachine.setVdrpIP(vdrpIp);
    virtualMachine.setVdrpPort(vdrpPort);
    virtualMachine.setState(new State(state));
    virtualMachine.setSubState(new State(subState == null ? StateEnum.UNKNOWN : subState));
    virtualMachine.setHighDisponibility(highDisponibility == 1 ? true : false);
    virtualMachine.setUser(userHB == null ? null : userHB.toPojo());
    virtualMachine.setEnterprise(enterpriseHB == null ? null : enterpriseHB.toPojo());
    virtualMachine.setIdType(idType);
    virtualMachine.setDatastore(datastore == null ? null : datastore.toPojo());
    virtualMachine.setPassword(password);

    return virtualMachine;
  }
コード例 #3
0
  /**
   * VirtualImage Factory construction XXX is not stored on DB. (not an HB because it's not useful
   * the ''category''/''repository''...)
   *
   * @throws PersistenceException
   * @param name
   * @param cpu
   * @param ram
   * @param hd
   * @return a reference to the newly created VirtualimageHB persistent object
   * @throws PersistenceException
   */
  public VirtualimageHB createVirtualImage(String name, int cpu, int ram, long hd)
      throws PersistenceException {
    factorytest = HibernateDAOFactory.instance();
    VirtualImageDAO daoVI = factorytest.getVirtualImageDAO();

    factorytest.beginConnection();

    VirtualimageHB vImage = new VirtualimageHB();

    vImage.setName(name);
    vImage.setDescription("test");

    vImage.setCpuRequired(cpu);
    vImage.setHdRequired(hd);
    vImage.setRamRequired(ram);

    vImage.setPathName("test");

    vImage.setIcon(icon);
    vImage.setCategory(category);
    vImage.setType(imageType);
    vImage.setRepository(repository);

    daoVI.makePersistent(vImage);

    vImagesCreated.add(vImage);

    factorytest.endConnection();

    return vImage;
  }