Package com.cloud.ucs.database

Examples of com.cloud.ucs.database.UcsBladeVO


    @Override
    public UcsBladeResponse associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd) {
        SearchCriteriaService<UcsBladeVO, UcsBladeVO> q = SearchCriteria2.create(UcsBladeVO.class);
        q.addAnd(q.getEntity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId());
        q.addAnd(q.getEntity().getId(), Op.EQ, cmd.getBladeId());
        UcsBladeVO bvo = q.find();
        if (bvo == null) {
            throw new IllegalArgumentException(String.format("cannot find UCS blade[id:%s, ucs manager id:%s]", cmd.getBladeId(), cmd.getUcsManagerId()));
        }

        if (bvo.getHostId() != null) {
            throw new CloudRuntimeException(String.format("blade[id:%s,  dn:%s] has been associated with host[id:%s]", bvo.getId(), bvo.getDn(), bvo.getHostId()));
        }

        UcsManagerVO mgrvo = ucsDao.findById(cmd.getUcsManagerId());
        String cookie = getCookie(cmd.getUcsManagerId());
        String pdn = cloneProfile(mgrvo.getId(), cmd.getProfileDn(), "profile-for-blade-" + bvo.getId());
        String ucscmd = UcsCommands.associateProfileToBlade(cookie, pdn, bvo.getDn());
        UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
        String res = client.call(ucscmd);
        int count = 0;
        int timeout = 3600;
        while (count < timeout) {
            if (isBladeAssociated(mgrvo.getId(), bvo.getDn())) {
                break;
            }

            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                throw new CloudRuntimeException(e);
            }

            count += 2;
        }

        if (count >= timeout) {
            throw new CloudRuntimeException(String.format("associating profile[%s] to balde[%s] timeout after 600 seconds", pdn, bvo.getDn()));
        }

        bvo.setProfileDn(pdn);
        bladeDao.update(bvo.getId(), bvo);

        UcsBladeResponse rsp = bladeVOToResponse(bvo);

        s_logger.debug(String.format("successfully associated profile[%s] to blade[%s]", pdn, bvo.getDn()));
        return rsp;
    }
View Full Code Here


        }

        SearchCriteriaService<UcsBladeVO, UcsBladeVO> q = SearchCriteria2.create(UcsBladeVO.class);
        q.addAnd(q.getEntity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId());
        q.addAnd(q.getEntity().getId(), Op.EQ, cmd.getBladeId());
        UcsBladeVO bvo = q.find();
        if (bvo == null) {
            throw new IllegalArgumentException(String.format("cannot find UCS blade[id:%s, ucs manager id:%s]", cmd.getBladeId(), cmd.getUcsManagerId()));
        }

        if (bvo.getHostId() != null) {
            throw new CloudRuntimeException(String.format("blade[id:%s,  dn:%s] has been associated with host[id:%s]", bvo.getId(), bvo.getDn(), bvo.getHostId()));
        }

        UcsManagerVO mgrvo = ucsDao.findById(cmd.getUcsManagerId());
        String cookie = getCookie(cmd.getUcsManagerId());
        String instantiateTemplateCmd = UcsCommands.instantiateTemplate(cookie, cmd.getTemplateDn(), profileName);
        UcsHttpClient http = new UcsHttpClient(mgrvo.getUrl());
        String res = http.call(instantiateTemplateCmd);
        XmlObject xo = XmlObjectParser.parseFromString(res);
        String profileDn = xo.get("outConfig.lsServer.dn");
        String ucscmd = UcsCommands.associateProfileToBlade(cookie, profileDn, bvo.getDn());
        res = http.call(ucscmd);
        int count = 0;
        int timeout = 3600;
        while (count < timeout) {
            if (isBladeAssociated(mgrvo.getId(), bvo.getDn())) {
                break;
            }

            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                throw new CloudRuntimeException(e);
            }

            count += 2;
        }

        if (count >= timeout) {
            throw new CloudRuntimeException(String.format("associating profile[%s] to balde[%s] timeout after 600 seconds", profileDn, bvo.getDn()));
        }

        bvo.setProfileDn(profileDn);
        bladeDao.update(bvo.getId(), bvo);

        UcsBladeResponse rsp = bladeVOToResponse(bvo);

        s_logger.debug(String.format("successfully associated profile[%s] to blade[%s]", profileDn, bvo.getDn()));
        return rsp;
    }
View Full Code Here

        UcsManagerVO mgrvo = ucsDao.findById(mgrId);
        List<ComputeBlade> blades = listBlades(mgrvo.getId());
        for (ComputeBlade b : blades) {
            SearchCriteria2<UcsBladeVO, UcsBladeVO> q = SearchCriteria2.create(UcsBladeVO.class, UcsBladeVO.class);
            q.addAnd(q.getEntity().getDn(), Op.EQ, b.getDn());
            UcsBladeVO vo = q.find();
            if (vo == null) {
                vo = new UcsBladeVO();
                vo.setProfileDn("".equals(b.getAssignedToDn()) ? null : b.getAssignedToDn());
                vo.setDn(b.getDn());
                vo.setUuid(UUID.randomUUID().toString());
                vo.setUcsManagerId(mgrId);
                bladeDao.persist(vo);
            } else {
                vo.setProfileDn("".equals(b.getAssignedToDn()) ? null : b.getAssignedToDn());
                bladeDao.update(vo.getId(), vo);
            }
        }

        return listUcsBlades(mgrId);
    }
View Full Code Here

        return listUcsBlades(mgrId);
    }

    @Override
    public UcsBladeResponse disassociateProfile(DisassociateUcsProfileCmd cmd) {
        UcsBladeVO blade = bladeDao.findById(cmd.getBladeId());
        UcsManagerVO mgrvo = ucsDao.findById(blade.getUcsManagerId());
        UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
        String cookie = getCookie(mgrvo.getId());
        String call = UcsCommands.disassociateProfileFromBlade(cookie, blade.getProfileDn());
        client.call(call);
        if (cmd.isDeleteProfile()) {
            call = UcsCommands.deleteProfile(cookie, blade.getProfileDn());
            client = new UcsHttpClient(mgrvo.getUrl());
            client.call(call);
        }
        blade.setProfileDn(null);
        bladeDao.update(blade.getId(), blade);
        UcsBladeResponse rsp = bladeVOToResponse(blade);
        return rsp;
    }
View Full Code Here

    }

    private void discoverBlades(UcsManagerVO ucsMgrVo) {
        List<ComputeBlade> blades = listBlades(ucsMgrVo.getId());
        for (ComputeBlade b : blades) {
            UcsBladeVO vo = new UcsBladeVO();
            vo.setDn(b.getDn());
            vo.setUcsManagerId(ucsMgrVo.getId());
            vo.setUuid(UUID.randomUUID().toString());
            bladeDao.persist(vo);
        }
    }
View Full Code Here

    }

    private void discoverBlades(UcsManagerVO ucsMgrVo) {
        List<ComputeBlade> blades = listBlades(ucsMgrVo.getId());
        for (ComputeBlade b : blades) {
            UcsBladeVO vo = new UcsBladeVO();
            vo.setDn(b.getDn());
            vo.setUcsManagerId(ucsMgrVo.getId());
            vo.setUuid(UUID.randomUUID().toString());
            if (!"".equals(b.getAssignedToDn())) {
                vo.setProfileDn(b.getAssignedToDn());
            }
            bladeDao.persist(vo);
        }
    }
View Full Code Here

    @Override
    public UcsBladeResponse associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd) {
        SearchCriteria<UcsBladeVO> sc = bladeDao.createSearchCriteria();
        sc.addAnd("ucsManagerId", Op.EQ, cmd.getUcsManagerId());
        sc.addAnd("id", Op.EQ, cmd.getBladeId());
        UcsBladeVO bvo = bladeDao.findOneBy(sc);
        if (bvo == null) {
            throw new IllegalArgumentException(String.format("cannot find UCS blade[id:%s, ucs manager id:%s]", cmd.getBladeId(), cmd.getUcsManagerId()));
        }

        if (bvo.getHostId() != null) {
            throw new CloudRuntimeException(String.format("blade[id:%s,  dn:%s] has been associated with host[id:%s]", bvo.getId(), bvo.getDn(), bvo.getHostId()));
        }

        UcsManagerVO mgrvo = ucsDao.findById(cmd.getUcsManagerId());
        String cookie = getCookie(cmd.getUcsManagerId());
        String pdn = cloneProfile(mgrvo.getId(), cmd.getProfileDn(), "profile-for-blade-" + bvo.getId());
        String ucscmd = UcsCommands.associateProfileToBlade(cookie, pdn, bvo.getDn());
        UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
        String res = client.call(ucscmd);
        int count = 0;
        int timeout = 3600;
        while (count < timeout) {
            if (isBladeAssociated(mgrvo.getId(), bvo.getDn())) {
                break;
            }

            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                throw new CloudRuntimeException(e);
            }

            count += 2;
        }

        if (count >= timeout) {
            throw new CloudRuntimeException(String.format("associating profile[%s] to balde[%s] timeout after 600 seconds", pdn, bvo.getDn()));
        }

        bvo.setProfileDn(pdn);
        bladeDao.update(bvo.getId(), bvo);

        UcsBladeResponse rsp = bladeVOToResponse(bvo);

        s_logger.debug(String.format("successfully associated profile[%s] to blade[%s]", pdn, bvo.getDn()));
        return rsp;
    }
View Full Code Here

        }

        SearchCriteria<UcsBladeVO> sc = bladeDao.createSearchCriteria();
        sc.addAnd("ucsManagerId", Op.EQ, cmd.getUcsManagerId());
        sc.addAnd("id", Op.EQ, cmd.getBladeId());
        UcsBladeVO bvo = bladeDao.findOneBy(sc);
        if (bvo == null) {
            throw new IllegalArgumentException(String.format("cannot find UCS blade[id:%s, ucs manager id:%s]", cmd.getBladeId(), cmd.getUcsManagerId()));
        }

        if (bvo.getHostId() != null) {
            throw new CloudRuntimeException(String.format("blade[id:%s,  dn:%s] has been associated with host[id:%s]", bvo.getId(), bvo.getDn(), bvo.getHostId()));
        }

        UcsManagerVO mgrvo = ucsDao.findById(cmd.getUcsManagerId());
        String cookie = getCookie(cmd.getUcsManagerId());
        String instantiateTemplateCmd = UcsCommands.instantiateTemplate(cookie, cmd.getTemplateDn(), profileName);
        UcsHttpClient http = new UcsHttpClient(mgrvo.getUrl());
        String res = http.call(instantiateTemplateCmd);
        XmlObject xo = XmlObjectParser.parseFromString(res);
        String profileDn = xo.get("outConfig.lsServer.dn");
        String ucscmd = UcsCommands.associateProfileToBlade(cookie, profileDn, bvo.getDn());
        res = http.call(ucscmd);
        int count = 0;
        int timeout = 3600;
        while (count < timeout) {
            if (isBladeAssociated(mgrvo.getId(), bvo.getDn())) {
                break;
            }

            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                throw new CloudRuntimeException(e);
            }

            count += 2;
        }

        if (count >= timeout) {
            throw new CloudRuntimeException(String.format("associating profile[%s] to balde[%s] timeout after 600 seconds", profileDn, bvo.getDn()));
        }

        bvo.setProfileDn(profileDn);
        bladeDao.update(bvo.getId(), bvo);

        UcsBladeResponse rsp = bladeVOToResponse(bvo);

        s_logger.debug(String.format("successfully associated profile[%s] to blade[%s]", profileDn, bvo.getDn()));
        return rsp;
    }
View Full Code Here

        UcsManagerVO mgrvo = ucsDao.findById(mgrId);
        List<ComputeBlade> blades = listBlades(mgrvo.getId());
        for (ComputeBlade b : blades) {
            SearchCriteria<UcsBladeVO> sc = bladeDao.createSearchCriteria();
            sc.addAnd("dn", Op.EQ, b.getDn());
            UcsBladeVO vo = bladeDao.findOneBy(sc);
            if (vo == null) {
                vo = new UcsBladeVO();
                vo.setProfileDn("".equals(b.getAssignedToDn()) ? null : b.getAssignedToDn());
                vo.setDn(b.getDn());
                vo.setUuid(UUID.randomUUID().toString());
                vo.setUcsManagerId(mgrId);
                bladeDao.persist(vo);
            } else {
                vo.setProfileDn("".equals(b.getAssignedToDn()) ? null : b.getAssignedToDn());
                bladeDao.update(vo.getId(), vo);
            }
        }

        return listUcsBlades(mgrId);
    }
View Full Code Here

        return listUcsBlades(mgrId);
    }

    @Override
    public UcsBladeResponse disassociateProfile(DisassociateUcsProfileCmd cmd) {
        UcsBladeVO blade = bladeDao.findById(cmd.getBladeId());
        UcsManagerVO mgrvo = ucsDao.findById(blade.getUcsManagerId());
        UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
        String cookie = getCookie(mgrvo.getId());
        String call = UcsCommands.disassociateProfileFromBlade(cookie, blade.getProfileDn());
        client.call(call);
        if (cmd.isDeleteProfile()) {
            call = UcsCommands.deleteProfile(cookie, blade.getProfileDn());
            client = new UcsHttpClient(mgrvo.getUrl());
            client.call(call);
        }
        blade.setProfileDn(null);
        bladeDao.update(blade.getId(), blade);
        UcsBladeResponse rsp = bladeVOToResponse(blade);
        return rsp;
    }
View Full Code Here

TOP

Related Classes of com.cloud.ucs.database.UcsBladeVO

Copyright © 2018 www.massapicom. 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.