Package com.cloud.ucs.database

Examples of com.cloud.ucs.database.UcsManagerVO


    @DB
    public ListResponse<UcsBladeResponse> refreshBlades(Long mgrId) {
        SyncBladesThread synct = new SyncBladesThread();
        synct.run();

        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) {
View Full Code Here


    }

    @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);
View Full Code Here

    @Override
    @DB
    public UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd) {
        SearchCriteria<UcsManagerVO> q = ucsDao.createSearchCriteria();
        q.addAnd("url", Op.EQ, cmd.getUrl());
        UcsManagerVO mgrvo = ucsDao.findOneBy(q);
        if (mgrvo != null) {
            throw new IllegalArgumentException(String.format("duplicate UCS manager. url[%s] is used by another UCS manager already", cmd.getUrl()));
        }

        try {
            UcsManagerVO vo = new UcsManagerVO();
            vo.setUuid(UUID.randomUUID().toString());
            vo.setPassword(cmd.getPassword());
            vo.setUrl(cmd.getUrl());
            vo.setUsername(cmd.getUsername());
            vo.setZoneId(cmd.getZoneId());
            vo.setName(cmd.getName());

            mgrvo = ucsDao.persist(vo);
            UcsManagerResponse rsp = new UcsManagerResponse();
            rsp.setId(String.valueOf(vo.getId()));
            rsp.setName(vo.getName());
            rsp.setUrl(vo.getUrl());
            rsp.setZoneId(String.valueOf(vo.getZoneId()));

            discoverBlades(vo);
            return rsp;
        } catch (CloudRuntimeException e) {
            if (mgrvo != null) {
View Full Code Here

    private String getCookie(Long ucsMgrId) {
        try {
            UcsCookie ucsCookie = cookies.get(ucsMgrId);
            long currentTime = System.currentTimeMillis();
            UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
            UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
            String cmd = null;
            if (ucsCookie == null) {
                cmd = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
            }
            else {
                String cookie = ucsCookie.getCookie();
                long cookieStartTime = ucsCookie.getStartTime();
                if(currentTime - cookieStartTime > COOKIE_TTL) {
                    cmd = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
                }
                else if(currentTime - cookieStartTime > COOKIE_REFRESH_TTL) {
                    cmd = UcsCommands.refreshCmd(mgrvo.getUsername(), mgrvo.getPassword(), cookie);
                }
            }
            if(cmd != null) {
                String ret = client.call(cmd);
                XmlObject xo = XmlObjectParser.parseFromString(ret);
View Full Code Here

        }
    }
   
    private List<ComputeBlade> listBlades(Long ucsMgrId) {
        String cookie = getCookie(ucsMgrId);
        UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
        UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
        String cmd = UcsCommands.listComputeBlades(cookie);
        String ret = client.call(cmd);
        return ComputeBlade.fromXmString(ret);
    }
View Full Code Here

        return ComputeBlade.fromXmString(ret);
    }

    private List<UcsTemplate> getUcsTemplates(Long ucsMgrId) {
        String cookie = getCookie(ucsMgrId);
        UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
        String cmd = UcsCommands.listTemplates(cookie);
        UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
        String res = client.call(cmd);
        List<UcsTemplate> tmps = UcsTemplate.fromXmlString(res);
        return tmps;
    }
View Full Code Here

        return tmps;
    }

    private List<UcsProfile> getUcsProfiles(Long ucsMgrId) {
        String cookie = getCookie(ucsMgrId);
        UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
        String cmd = UcsCommands.listTemplates(cookie);
        UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
        String res = client.call(cmd);
        List<UcsTemplate> tmps = UcsTemplate.fromXmlString(res);
        return null;
    }
View Full Code Here

        response.setResponses(rs);
        return response;
    }

    private String cloneProfile(Long ucsMgrId, String srcDn, String newProfileName) {
        UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
        UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
        String cookie = getCookie(ucsMgrId);
        String cmd = UcsCommands.cloneProfile(cookie, srcDn, newProfileName);
        String res = client.call(cmd);
        XmlObject xo = XmlObjectParser.parseFromString(res);
        return xo.get("outConfig.lsServer.dn");
View Full Code Here

        return xo.get("outConfig.lsServer.dn");
    }


    private boolean isProfileAssociated(Long ucsMgrId, String dn) {
        UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
        UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
        String cookie = getCookie(ucsMgrId);
        String cmd = UcsCommands.configResolveDn(cookie, dn);
        String res = client.call(cmd);
        XmlObject xo = XmlObjectParser.parseFromString(res);
View Full Code Here

        return xo.get("outConfig.lsServer.assocState").equals("associated");
    }

    private boolean isBladeAssociated(Long ucsMgrId, String dn) {
        UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
        UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
        String cookie = getCookie(ucsMgrId);
        String cmd = UcsCommands.configResolveDn(cookie, dn);
        String res = client.call(cmd);
        XmlObject xo = XmlObjectParser.parseFromString(res);
        s_logger.debug(String.format("association response is %s", res));
View Full Code Here

TOP

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

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.