Search in sources :

Example 6 with UcsManagerVO

use of com.cloud.ucs.database.UcsManagerVO in project cloudstack by apache.

the class UcsManagerImpl method listBlades.

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);
}
Also used : UcsManagerVO(com.cloud.ucs.database.UcsManagerVO)

Example 7 with UcsManagerVO

use of com.cloud.ucs.database.UcsManagerVO in project cloudstack by apache.

the class UcsManagerImpl method associateProfileToBlade.

@Override
public UcsBladeResponse associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd) {
    QueryBuilder<UcsBladeVO> q = QueryBuilder.create(UcsBladeVO.class);
    q.and(q.entity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId());
    q.and(q.entity().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 = 600;
    while (count < timeout) {
        if (isProfileAssociated(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;
}
Also used : UcsBladeVO(com.cloud.ucs.database.UcsBladeVO) UcsManagerVO(com.cloud.ucs.database.UcsManagerVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UcsBladeResponse(org.apache.cloudstack.api.response.UcsBladeResponse)

Example 8 with UcsManagerVO

use of com.cloud.ucs.database.UcsManagerVO in project cloudstack by apache.

the class UcsManagerImpl method getUcsProfiles.

private List<UcsProfile> getUcsProfiles(Long ucsMgrId) {
    String cookie = getCookie(ucsMgrId);
    UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
    String cmd = UcsCommands.listProfiles(cookie);
    UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
    String res = client.call(cmd);
    List<UcsProfile> profiles = UcsProfile.fromXmlString(res);
    return profiles;
}
Also used : UcsManagerVO(com.cloud.ucs.database.UcsManagerVO) UcsProfile(com.cloud.ucs.structure.UcsProfile)

Aggregations

UcsManagerVO (com.cloud.ucs.database.UcsManagerVO)8 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 XmlObject (com.cloud.utils.xmlobject.XmlObject)3 UcsManagerResponse (org.apache.cloudstack.api.response.UcsManagerResponse)2 UcsBladeVO (com.cloud.ucs.database.UcsBladeVO)1 UcsCookie (com.cloud.ucs.structure.UcsCookie)1 UcsProfile (com.cloud.ucs.structure.UcsProfile)1 DB (com.cloud.utils.db.DB)1 ArrayList (java.util.ArrayList)1 ConfigurationException (javax.naming.ConfigurationException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 UcsBladeResponse (org.apache.cloudstack.api.response.UcsBladeResponse)1