Search in sources :

Example 1 with NuageVspManagerClient

use of net.nuage.vsp.acs.client.api.NuageVspManagerClient 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

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