Examples of BaremetalPxeVO


Examples of com.cloud.baremetal.database.BaremetalPxeVO

    public boolean prepare(VirtualMachineProfile<UserVmVO> profile, NicProfile nic, DeployDestination dest, ReservationContext context) {
        NetworkVO nwVO = _nwDao.findById(nic.getNetworkId());
        SearchCriteriaService<BaremetalPxeVO, BaremetalPxeVO> sc = SearchCriteria2.create(BaremetalPxeVO.class);
        sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.toString());
        sc.addAnd(sc.getEntity().getPhysicalNetworkId(), Op.EQ, nwVO.getPhysicalNetworkId());
        BaremetalPxeVO pxeVo = sc.find();
        if (pxeVo == null) {
            throw new CloudRuntimeException("No kickstart PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM");
        }
        VMTemplateVO template = _tmpDao.findById(profile.getTemplateId());

        try {
            String tpl = profile.getTemplate().getUrl();
            assert tpl != null : "How can a null template get here!!!";
            String[] tpls = tpl.split(";");
            CloudRuntimeException err = new CloudRuntimeException(String.format("template url[%s] is not correctly encoded. it must be in format of ks=http_link_to_kickstartfile;kernel=nfs_path_to_pxe_kernel;initrd=nfs_path_to_pxe_initrd", tpl));
            if (tpls.length != 3) {
                throw err;
            }
           
            String ks = null;
            String kernel = null;
            String initrd = null;
           
            for (String t : tpls) {
                String[] kv = t.split("=");
                if (kv.length != 2) {
                    throw err;
                }
                if (kv[0].equals("ks")) {
                    ks = kv[1];
                } else if (kv[0].equals("kernel")) {
                    kernel = kv[1];
                } else if (kv[0].equals("initrd")) {
                    initrd = kv[1];
                } else {
                    throw err;
                }
            }

            PrepareKickstartPxeServerCommand cmd = new PrepareKickstartPxeServerCommand();
            cmd.setKsFile(ks);
            cmd.setInitrd(initrd);
            cmd.setKernel(kernel);
            cmd.setMac(nic.getMacAddress());
            cmd.setTemplateUuid(template.getUuid());
            Answer aws = _agentMgr.send(pxeVo.getHostId(), cmd);
            if (!aws.getResult()) {
                s_logger.warn("Unable to set host: " + dest.getHost().getId() + " to PXE boot because " + aws.getDetails());
                return aws.getResult();
            }
View Full Code Here

Examples of com.cloud.baremetal.database.BaremetalPxeVO

        Host pxeServer = _resourceMgr.addHost(zoneId, resource, Host.Type.BaremetalPxe, params);
        if (pxeServer == null) {
            throw new CloudRuntimeException("Cannot add PXE server as a host");
        }

        BaremetalPxeVO vo = new BaremetalPxeVO();
        Transaction txn = Transaction.currentTxn();
        vo.setHostId(pxeServer.getId());
        vo.setNetworkServiceProviderId(ntwkSvcProvider.getId());
        vo.setPhysicalNetworkId(kcmd.getPhysicalNetworkId());
        vo.setDeviceType(BaremetalPxeType.KICK_START.toString());
        txn.start();
        _pxeDao.persist(vo);
        txn.commit();
        return vo;
    }
View Full Code Here

Examples of com.cloud.baremetal.database.BaremetalPxeVO

    @Override
    public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd) {
        List<BaremetalPxeResponse> responses = new ArrayList<BaremetalPxeResponse>();
        if (cmd.getId() != null) {
            BaremetalPxeVO vo = _pxeDao.findById(cmd.getId());
            responses.add(getApiResponse(vo));
            return responses;
        }

        List<BaremetalPxeVO> vos = _pxeDao.listAll();
View Full Code Here

Examples of com.cloud.baremetal.database.BaremetalPxeVO

  @Override
  public boolean prepare(VirtualMachineProfile<UserVmVO> profile, NicProfile pxeNic, DeployDestination dest, ReservationContext context) {
      SearchCriteriaService<BaremetalPxeVO, BaremetalPxeVO> sc = SearchCriteria2.create(BaremetalPxeVO.class);
        sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, BaremetalPxeType.PING.toString());
        sc.addAnd(sc.getEntity().getPodId(), Op.EQ, dest.getPod().getId());
        BaremetalPxeVO pxeVo = sc.find();
        if (pxeVo == null) {
            throw new CloudRuntimeException("No PING PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM");
        }
        long pxeServerId = pxeVo.getHostId();
       
      String mac = pxeNic.getMacAddress();
      String ip = pxeNic.getIp4Address();
      String gateway = pxeNic.getGateway();
      String mask = pxeNic.getNetmask();
      String dns = pxeNic.getDns1();
      if (dns == null) {
        dns = pxeNic.getDns2();
      }

    try {
      String tpl = profile.getTemplate().getUrl();
      assert tpl != null : "How can a null template get here!!!";
      PreparePxeServerCommand cmd = new PreparePxeServerCommand(ip, mac, mask, gateway, dns, tpl,
          profile.getVirtualMachine().getInstanceName(), dest.getHost().getName());
      PreparePxeServerAnswer ans = (PreparePxeServerAnswer) _agentMgr.send(pxeServerId, cmd);
      if (!ans.getResult()) {
        s_logger.warn("Unable tot program PXE server: " + pxeVo.getId() + " because " + ans.getDetails());
        return false;
      }
     
      IpmISetBootDevCommand bootCmd = new IpmISetBootDevCommand(BootDev.pxe);
      Answer anw = _agentMgr.send(dest.getHost().getId(), bootCmd);
View Full Code Here

Examples of com.cloud.baremetal.database.BaremetalPxeVO

        Host pxeServer = _resourceMgr.addHost(zoneId, resource, Host.Type.BaremetalPxe, params);
        if (pxeServer == null) {
            throw new CloudRuntimeException("Cannot add PXE server as a host");
        }
       
        BaremetalPxeVO vo = new BaremetalPxeVO();
        Transaction txn = Transaction.currentTxn();
        vo.setHostId(pxeServer.getId());
        vo.setNetworkServiceProviderId(ntwkSvcProvider.getId());
        vo.setPodId(pod.getId());
        vo.setPhysicalNetworkId(pcmd.getPhysicalNetworkId());
        vo.setDeviceType(BaremetalPxeType.PING.toString());
        txn.start();
        _pxeDao.persist(vo);
        txn.commit();
        return vo;
    }
View Full Code Here

Examples of com.cloud.baremetal.database.BaremetalPxeVO

    @Override
    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
            ResourceAllocationException, NetworkRuleConflictException {
        try {
            BaremetalPxeVO vo = pxeMgr.addPxeServer(this);
            BaremetalPxeResponse rsp = pxeMgr.getApiResponse(vo);
            rsp.setResponseName(getCommandName());
            this.setResponseObject(rsp);
        } catch (Exception e) {
            s_logger.warn("Unable to add external pxe server with url: " + getUrl(), e);
View Full Code Here

Examples of com.cloud.baremetal.database.BaremetalPxeVO

       
        SearchCriteriaService<BaremetalPxeVO, BaremetalPxeVO> sc = SearchCriteria2.create(BaremetalPxeVO.class);
        //TODO: handle both kickstart and PING
        //sc.addAnd(sc.getEntity().getPodId(), Op.EQ, vm.getPodIdToDeployIn());
        sc.addAnd(sc.getEntity().getPhysicalNetworkId(), Op.EQ, phy.getId());
        BaremetalPxeVO pxeVo = sc.find();
        if (pxeVo == null) {
            throw new CloudRuntimeException("No PXE server found in pod: " + vm.getPodIdToDeployIn() + ", you need to add it before starting VM");
        }
       
        try {
            Answer ans = _agentMgr.send(pxeVo.getHostId(), cmd);
            if (!ans.getResult()) {
                s_logger.debug(String.format("Add userdata to vm:%s failed because %s", vm.getInstanceName(), ans.getDetails()));
                return false;
            } else {
                return true;
View Full Code Here

Examples of com.cloud.baremetal.database.BaremetalPxeVO

    public boolean prepare(VirtualMachineProfile profile, NicProfile nic, DeployDestination dest, ReservationContext context) {
        NetworkVO nwVO = _nwDao.findById(nic.getNetworkId());
        QueryBuilder<BaremetalPxeVO> sc = QueryBuilder.create(BaremetalPxeVO.class);
        sc.and(sc.entity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.toString());
        sc.and(sc.entity().getPhysicalNetworkId(), Op.EQ, nwVO.getPhysicalNetworkId());
        BaremetalPxeVO pxeVo = sc.find();
        if (pxeVo == null) {
            throw new CloudRuntimeException("No kickstart PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM");
        }
        VMTemplateVO template = _tmpDao.findById(profile.getTemplateId());

        try {
            String tpl = profile.getTemplate().getUrl();
            assert tpl != null : "How can a null template get here!!!";
            String[] tpls = tpl.split(";");
            CloudRuntimeException err =
                new CloudRuntimeException(
                    String.format(
                        "template url[%s] is not correctly encoded. it must be in format of ks=http_link_to_kickstartfile;kernel=nfs_path_to_pxe_kernel;initrd=nfs_path_to_pxe_initrd",
                        tpl));
            if (tpls.length != 3) {
                throw err;
            }

            String ks = null;
            String kernel = null;
            String initrd = null;

            for (String t : tpls) {
                String[] kv = t.split("=");
                if (kv.length != 2) {
                    throw err;
                }
                if (kv[0].equals("ks")) {
                    ks = kv[1];
                } else if (kv[0].equals("kernel")) {
                    kernel = kv[1];
                } else if (kv[0].equals("initrd")) {
                    initrd = kv[1];
                } else {
                    throw err;
                }
            }

            PrepareKickstartPxeServerCommand cmd = new PrepareKickstartPxeServerCommand();
            cmd.setKsFile(ks);
            cmd.setInitrd(initrd);
            cmd.setKernel(kernel);
            cmd.setMac(nic.getMacAddress());
            cmd.setTemplateUuid(template.getUuid());
            Answer aws = _agentMgr.send(pxeVo.getHostId(), cmd);
            if (!aws.getResult()) {
                s_logger.warn("Unable to set host: " + dest.getHost().getId() + " to PXE boot because " + aws.getDetails());
                return aws.getResult();
            }
View Full Code Here

Examples of com.cloud.baremetal.database.BaremetalPxeVO

        Host pxeServer = _resourceMgr.addHost(zoneId, resource, Host.Type.BaremetalPxe, params);
        if (pxeServer == null) {
            throw new CloudRuntimeException("Cannot add PXE server as a host");
        }

        BaremetalPxeVO vo = new BaremetalPxeVO();
        vo.setHostId(pxeServer.getId());
        vo.setNetworkServiceProviderId(ntwkSvcProvider.getId());
        vo.setPhysicalNetworkId(kcmd.getPhysicalNetworkId());
        vo.setDeviceType(BaremetalPxeType.KICK_START.toString());
        _pxeDao.persist(vo);
        return vo;
    }
View Full Code Here

Examples of com.cloud.baremetal.database.BaremetalPxeVO

    @Override
    public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd) {
        List<BaremetalPxeResponse> responses = new ArrayList<BaremetalPxeResponse>();
        if (cmd.getId() != null) {
            BaremetalPxeVO vo = _pxeDao.findById(cmd.getId());
            responses.add(getApiResponse(vo));
            return responses;
        }

        List<BaremetalPxeVO> vos = _pxeDao.listAll();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.