Esempio 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;
  }
Esempio n. 2
0
  /**
   * Rack Factory construction
   *
   * @throws PersistenceException
   */
  private RackHB createRack(DatacenterHB dc) throws PersistenceException {
    factorytest = HibernateDAOFactory.instance();
    RackDAO daoRack = factorytest.getRackDAO();

    factorytest.beginConnection();

    RackHB rack = new RackHB();
    rack.setDatacenter(dc);
    rack.setName("test");
    rack.setShortDescription("test");
    rack.setLargeDescription("test");
    daoRack.makePersistent(rack);

    factorytest.endConnection();

    return rack;
  }