Esempio n. 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();
  }
Esempio n. 2
0
  @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;
  }