public ControlClusterStatus getControlClusterStatus() throws NiciraNvpApiException { final String uri = NiciraConstants.CONTROL_CLUSTER_STATUS_URL; try { return restConnector.executeRetrieveObject(ControlClusterStatus.class, uri, new HashMap<String, String>()); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } }
/** * PUT item given a UUID as key and an item object with the new data * * @param item * @param uuid * @throws NiciraNvpApiException */ private <T> void updateWithUri(final T item, final String uri) throws NiciraNvpApiException { try { restConnector.executeUpdateObject(item, uri, Collections.<String, String> emptyMap()); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } }
/** * POST * * @param entity * @return * @throws NiciraNvpApiException */ private <T> T createWithUri(final T entity, final String uri) throws NiciraNvpApiException { T createdEntity; try { createdEntity = restConnector.executeCreateObject(entity, uri, Collections.<String, String> emptyMap()); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } return createdEntity; }
/** * DELETE Security Profile given a UUID as key * * @param securityProfileUuid * @throws NiciraNvpApiException */ private void deleteWithUri(final String uri) throws NiciraNvpApiException { try { restConnector.executeDeleteObject(uri); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } }
/** * GET list of items * * @param uuid * * @return * @throws NiciraNvpApiException */ private <T> List<T> find(final Optional<String> uuid, final Class<T> clazz) throws NiciraNvpApiException { final String uri = prefixMap.get(clazz); Map<String, String> params = defaultListParams; if (uuid.isPresent()) { params = new HashMap<String, String>(defaultListParams); params.put(UUID_QUERY_PARAMETER, uuid.get()); } NiciraNvpList<T> entities; try { entities = restConnector.executeRetrieveObject(listTypeMap.get(clazz), uri, params); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } if (entities == null) { throw new NiciraNvpApiException("Unexpected response from API"); } return entities.getResults(); }
public List<LogicalRouterPort> findLogicalRouterPortByGatewayServiceAndVlanId(final String logicalRouterUuid, final String gatewayServiceUuid, final long vlanId) throws NiciraNvpApiException { final String uri = buildLogicalRouterElementUri(logicalRouterUuid, LPORT_PATH_SEGMENT); final Map<String, String> params = buildBasicParametersMap(WILDCARD_QUERY_PARAMETER); params.put(ATTACHMENT_GWSVC_UUID_QUERY_PARAMETER, gatewayServiceUuid); params.put(NiciraConstants.ATTACHMENT_VLAN_PARAMETER, Long.toString(vlanId)); try { final Type niciraListType = new TypeToken<NiciraNvpList<LogicalRouterPort>>() { }.getType(); return restConnector.<NiciraNvpList<LogicalRouterPort>> executeRetrieveObject(niciraListType, uri, params).getResults(); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } }
public List<L2GatewayServiceConfig> findL2GatewayServiceByUuidAndType(final String gatewayServiceUuid, final String serviceConfigType) throws NiciraNvpApiException{ final String uri = buildGatewayServiceUri(); final Map<String, String> params = buildBasicParametersMap(WILDCARD_QUERY_PARAMETER); params.put(UUID_QUERY_PARAMETER, gatewayServiceUuid); params.put(TYPES_QUERY_PARAMETER, serviceConfigType); try { final Type niciraListType = new TypeToken<NiciraNvpList<L2GatewayServiceConfig>>() { }.getType(); return restConnector.<NiciraNvpList<L2GatewayServiceConfig>> executeRetrieveObject(niciraListType, uri, params).getResults(); } catch (final CloudstackRESTException e){ throw new NiciraNvpApiException(e, e.getErrorCode()); } }
public List<LogicalRouterPort> findLogicalRouterPortsByUuid(final String logicalRouterUuid, final String logicalRouterPortUuid) throws NiciraNvpApiException { final String uri = buildLogicalRouterElementUri(logicalRouterUuid, LPORT_PATH_SEGMENT); final Map<String, String> params = buildBasicParametersMap(UUID_QUERY_PARAMETER); params.put(UUID_QUERY_PARAMETER, logicalRouterPortUuid); try { final Type niciraListType = new TypeToken<NiciraNvpList<LogicalRouterPort>>() { }.getType(); return restConnector.<NiciraNvpList<LogicalRouterPort>> executeRetrieveObject(niciraListType, uri, params).getResults(); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } }
public List<LogicalRouterPort> findLogicalRouterPortByAttachmentLSwitchUuid(final String logicalRouterUuid, final String attachmentLSwitchUuid) throws NiciraNvpApiException{ final String uri = buildLogicalRouterElementUri(logicalRouterUuid, LPORT_PATH_SEGMENT); final Map<String, String> params = buildBasicParametersMap(WILDCARD_QUERY_PARAMETER); params.put(NiciraConstants.ATTACHMENT_LSWITCH_UUID, attachmentLSwitchUuid); try{ final Type niciraListType = new TypeToken<NiciraNvpList<LogicalRouterPort>>() { }.getType(); return restConnector.<NiciraNvpList<LogicalRouterPort>> executeRetrieveObject(niciraListType, uri, params).getResults(); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } }
public List<LogicalSwitchPort> findLogicalSwitchPortsByUuid(final String logicalSwitchUuid, final String logicalSwitchPortUuid) throws NiciraNvpApiException { final String uri = buildLogicalSwitchElementUri(logicalSwitchUuid, LPORT_PATH_SEGMENT); final Map<String, String> params = buildBasicParametersMap(UUID_QUERY_PARAMETER); params.put(UUID_QUERY_PARAMETER, logicalSwitchPortUuid); try { final Type niciraListType = new TypeToken<NiciraNvpList<LogicalSwitchPort>>() { }.getType(); return restConnector.<NiciraNvpList<LogicalSwitchPort>> executeRetrieveObject(niciraListType, uri, params).getResults(); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } }
public List<LogicalRouterPort> findLogicalRouterPortByGatewayServiceUuid(final String logicalRouterUuid, final String l3GatewayServiceUuid) throws NiciraNvpApiException { final String uri = buildLogicalRouterElementUri(logicalRouterUuid, LPORT_PATH_SEGMENT); final Map<String, String> params = buildBasicParametersMap(WILDCARD_QUERY_PARAMETER); params.put(ATTACHMENT_GWSVC_UUID_QUERY_PARAMETER, l3GatewayServiceUuid); try { final Type niciraListType = new TypeToken<NiciraNvpList<LogicalRouterPort>>() { }.getType(); return restConnector.<NiciraNvpList<LogicalRouterPort>> executeRetrieveObject(niciraListType, uri, params).getResults(); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } }
public String findLogicalSwitchPortUuidByVifAttachmentUuid(final String logicalSwitchUuid, final String vifAttachmentUuid) throws NiciraNvpApiException { final String uri = buildLogicalSwitchElementUri(logicalSwitchUuid, LPORT_PATH_SEGMENT); final Map<String, String> params = buildBasicParametersMap(UUID_QUERY_PARAMETER); params.put(NiciraConstants.ATTACHMENT_VIF_UUID_QUERY_PARAMETER_NAME, vifAttachmentUuid); NiciraNvpList<LogicalSwitchPort> niciraList; try { final Type niciraListType = new TypeToken<NiciraNvpList<LogicalSwitchPort>>() { }.getType(); niciraList = restConnector.executeRetrieveObject(niciraListType, uri, params); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } final List<LogicalSwitchPort> lspl = niciraList.getResults(); final int listSize = lspl.size(); if (listSize != 1) { throw new NiciraNvpApiException("Expected 1 LogicalSwitchPort, but got " + listSize); } final LogicalSwitchPort lsp = lspl.get(0); return lsp.getUuid(); }
public List<NatRule> findNatRulesByLogicalRouterUuid(final String logicalRouterUuid) throws NiciraNvpApiException { final String uri = buildLogicalRouterElementUri(logicalRouterUuid, NAT_PATH_SEGMENT); final Map<String, String> params = buildBasicParametersMap(WILDCARD_QUERY_PARAMETER); try { final Type niciraListType = new TypeToken<NiciraNvpList<NatRule>>() { }.getType(); return restConnector.<NiciraNvpList<NatRule>> executeRetrieveObject(niciraListType, uri, params).getResults(); } catch (final CloudstackRESTException e) { throw new NiciraNvpApiException(e, e.getErrorCode()); } }