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());
}
}
Aggregations