Exemplo n.º 1
0
  /**
   * Persist on database the input PhysicalMachine (also its DataCenter, Rack and So).
   *
   * @throws PersistenceException
   */
  protected PhysicalmachineHB createPhysicalMachine(
      PhysicalmachineHB machine, RackHB rack, HypervisorType htype) throws PersistenceException {
    factorytest = HibernateDAOFactory.instance();
    PhysicalMachineDAO pmDAO = factorytest.getPhysicalMachineDAO();
    HyperVisorDAO hyperDAO = factorytest.getHyperVisorDAO();

    factorytest.beginConnection();

    HypervisorHB hyper = createHypervisor(htype);

    machine.setRack(rack);
    machine.setDataCenter(rack.getDatacenter());

    machine.setHypervisor(hyper);

    pmDAO.makePersistent(machine);

    log.debug("Added machine [{}]", machine.getName());

    hyper.setPhysicalMachine(machine);
    hyperDAO.makePersistent(hyper);

    factorytest.endConnection();

    return machine;
  }
Exemplo n.º 2
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();
  }
Exemplo n.º 3
0
  /**
   * HyperVisor Factory construction
   *
   * @throws PersistenceException
   */
  private HypervisorHB createHypervisor(HypervisorType hType) throws PersistenceException {
    // Crudable<HypervisorHB, Integer> daoHyper =
    // new GenericHibernateDAO<HypervisorHB, Integer>(HypervisorHB.class);

    HypervisorHB hyp = new HypervisorHB();

    hyp.setType(hType);

    hyp.setIp("test");
    hyp.setIpService("test");
    hyp.setPort(0);

    // XXX hyp.setPhysicalMachine(physicalMachine);

    // daoHyper.makePersistent(hyp);

    return hyp;
  }
Exemplo n.º 4
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;
  }