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
  /**
   * 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;
  }
Esempio n. 3
0
  /**
   * Retrieves the default hypervisor and returns pojo encapsulating this information
   *
   * @return a {@link HypervisorHB} object representing the default Hypervisor stored in the DB
   * @throws PersistenceException
   */
  public HypervisorHB getDefaultHypervisor() throws PersistenceException {
    factorytest = HibernateDAOFactory.instance();
    HyperVisorDAO dao = factorytest.getHyperVisorDAO();

    factorytest.beginConnection();

    HypervisorHB hb = dao.findById(1);

    factorytest.endConnection();

    return hb;
  }