Search in sources :

Example 1 with NuageVspException

use of net.nuage.vsp.acs.client.exception.NuageVspException in project cloudstack by apache.

the class NuageVspCommandWrapper method execute.

@Override
public final Answer execute(final T command, final NuageVspResource nuageVspResource) {
    try {
        boolean success = executeNuageVspCommand(command, nuageVspResource);
        String detail = fillDetail(new StringBuilder(), command).append(" on ").append(nuageVspResource.getName()).toString();
        return new Answer(command, success, detail);
    } catch (NuageVspException | ConfigurationException e) {
        s_logger.error("Failure during " + command + " on " + nuageVspResource.getName(), e);
        return new Answer(command, e);
    }
}
Also used : Answer(com.cloud.agent.api.Answer) ConfigurationException(javax.naming.ConfigurationException) NuageVspException(net.nuage.vsp.acs.client.exception.NuageVspException)

Example 2 with NuageVspException

use of net.nuage.vsp.acs.client.exception.NuageVspException in project cloudstack by apache.

the class NuageVspSyncCmsIdCommandWrapper method execute.

@Override
public SyncNuageVspCmsIdAnswer execute(SyncNuageVspCmsIdCommand cmd, NuageVspResource nuageVspResource) {
    NuageVspManagerClient client = null;
    try {
        client = nuageVspResource.getNuageVspManagerClient();
        Pair<Boolean, String> answer;
        switch(cmd.getSyncType()) {
            case REGISTER:
                String registeredNuageVspCmsId = client.registerNuageVspCmsId();
                answer = Pair.of(StringUtils.isNotBlank(registeredNuageVspCmsId), registeredNuageVspCmsId);
                break;
            case UNREGISTER:
                boolean success = client.unregisterNuageVspCmsId(cmd.getNuageVspCmsId());
                answer = Pair.of(success, cmd.getNuageVspCmsId());
                break;
            default:
                answer = client.auditNuageVspCmsId(cmd.getNuageVspCmsId(), cmd.getSyncType() == SyncNuageVspCmsIdCommand.SyncType.AUDIT_ONLY);
                break;
        }
        return new SyncNuageVspCmsIdAnswer(answer.getLeft(), answer.getRight(), cmd.getSyncType());
    } catch (ConfigurationException | NuageVspException e) {
        return new SyncNuageVspCmsIdAnswer(cmd, e, cmd.getSyncType());
    }
}
Also used : NuageVspManagerClient(net.nuage.vsp.acs.client.api.NuageVspManagerClient) ConfigurationException(javax.naming.ConfigurationException) SyncNuageVspCmsIdAnswer(com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer) NuageVspException(net.nuage.vsp.acs.client.exception.NuageVspException)

Aggregations

ConfigurationException (javax.naming.ConfigurationException)2 NuageVspException (net.nuage.vsp.acs.client.exception.NuageVspException)2 Answer (com.cloud.agent.api.Answer)1 SyncNuageVspCmsIdAnswer (com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer)1 NuageVspManagerClient (net.nuage.vsp.acs.client.api.NuageVspManagerClient)1