http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateNetworkOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateNetworkOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateNetworkOptions.java deleted file mode 100644 index e794acf..0000000 --- a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateNetworkOptions.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.openstack.neutron.v2_0.options; - -import com.google.common.collect.ImmutableMap; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Inject; -import java.util.Map; - -public class UpdateNetworkOptions implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromUpdateNetworkOptions(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected String name; - protected Boolean adminStateUp; - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdateNetworkOptions#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdateNetworkOptions#getAdminStateUp() - */ - public T adminStateUp(Boolean adminStateUp) { - this.adminStateUp = adminStateUp; - return self(); - } - - public UpdateNetworkOptions build() { - return new UpdateNetworkOptions(name, adminStateUp); - } - - public T fromUpdateNetworkOptions(UpdateNetworkOptions options) { - return this.name(options.getName()).adminStateUp(options.getAdminStateUp()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private static class UpdateNetworkRequest { - protected String name; - protected Boolean admin_state_up; - } - - private final String name; - private final Boolean adminStateUp; - - protected UpdateNetworkOptions() { - this.name = null; - this.adminStateUp = null; - } - - public UpdateNetworkOptions(String name, Boolean adminStateUp) { - this.name = name; - this.adminStateUp = adminStateUp; - } - - /** - * @return the new name for the network - */ - public String getName() { - return name; - } - - /** - * @return the new administrative state for the network. If false, the network does not forward packets. - */ - public boolean getAdminStateUp() { - return adminStateUp; - } - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { - UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); - - if (this.name != null) - updateNetworkRequest.name = this.name; - if (this.adminStateUp != null) - updateNetworkRequest.admin_state_up = this.adminStateUp; - - return bindToRequest(request, ImmutableMap.of("network", updateNetworkRequest)); - } - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } - -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdatePortOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdatePortOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdatePortOptions.java deleted file mode 100644 index dfbc820..0000000 --- a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdatePortOptions.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.openstack.neutron.v2_0.options; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; -import org.jclouds.http.HttpRequest; -import org.jclouds.openstack.neutron.v2_0.domain.IP; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Inject; -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -public class UpdatePortOptions implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromUpdatePortOptions(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected String name; - protected Boolean adminStateUp; - protected String deviceId; - protected String deviceOwner; - protected Set<IP> fixedIps; - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions#getAdminStateUp() - */ - public T adminStateUp(Boolean adminStateUp) { - this.adminStateUp = adminStateUp; - return self(); - } - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions#getDeviceId() - */ - public T deviceId(String deviceId) { - this.deviceId = deviceId; - return self(); - } - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions#getDeviceOwner() - */ - public T deviceOwner(String deviceOwner) { - this.deviceOwner = deviceOwner; - return self(); - } - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions#getFixedIps() - */ - public T fixedIps(Collection<IP> fixedIps) { - this.fixedIps = ImmutableSet.copyOf(fixedIps); - return self(); - } - - public UpdatePortOptions build() { - return new UpdatePortOptions(name, adminStateUp, deviceId, deviceOwner, fixedIps); - } - - public T fromUpdatePortOptions(UpdatePortOptions options) { - return this.name(options.getName()) - .adminStateUp(options.getAdminStateUp()) - .deviceId(options.getDeviceId()) - .deviceOwner(options.getDeviceOwner()) - .fixedIps(options.getFixedIps()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private static class UpdatePortRequest { - protected String name; - protected Boolean admin_state_up; - protected String device_id; - protected String device_owner; - protected Set<IP> fixed_ips; - - private static class IP { - protected String ip_address; - protected String subnet_id; - } - } - - private final String name; - private final Boolean adminStateUp; - private final String deviceId; - private final String deviceOwner; - private final Set<IP> fixedIps; - - protected UpdatePortOptions() { - this.name = null; - this.adminStateUp = null; - this.deviceId = null; - this.deviceOwner = null; - this.fixedIps = Sets.newHashSet(); - } - - public UpdatePortOptions(String name, Boolean adminStateUp, String deviceId, String deviceOwner, Set<IP> fixedIps) { - this.name = name; - this.adminStateUp = adminStateUp; - this.deviceId = deviceId; - this.deviceOwner = deviceOwner; - this.fixedIps = fixedIps != null ? ImmutableSet.copyOf(fixedIps) : Sets.<IP>newHashSet(); - } - - /** - * @return the new name for the port - */ - public String getName() { - return name; - } - - /** - * @return the new administrative state for the port. If false, port does not forward packets. - */ - public Boolean getAdminStateUp() { - return adminStateUp; - } - - /** - * @return the new device id for the port - */ - public String getDeviceId() { - return deviceId; - } - - /** - * @return the new device owner for the port - */ - public String getDeviceOwner() { - return deviceOwner; - } - - /** - * @return a new set of fixed ips this port will get assigned - */ - public Set<IP> getFixedIps() { - return fixedIps; - } - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { - UpdatePortRequest updatePortRequest = new UpdatePortRequest(); - - if (this.name != null) - updatePortRequest.name = this.name; - if (this.adminStateUp != null) - updatePortRequest.admin_state_up = this.adminStateUp; - if (this.deviceId != null) - updatePortRequest.device_id = this.deviceId; - if (this.deviceOwner != null) - updatePortRequest.device_owner = this.deviceOwner; - if (!this.fixedIps.isEmpty()) { - updatePortRequest.fixed_ips = Sets.newHashSet(); - for (IP fixedIp : this.fixedIps) { - UpdatePortRequest.IP requestIp = new UpdatePortRequest.IP(); - requestIp.ip_address = fixedIp.getIpAddress(); - requestIp.subnet_id = fixedIp.getSubnetId(); - updatePortRequest.fixed_ips.add(requestIp); - } - } - - return bindToRequest(request, ImmutableMap.of("port", updatePortRequest)); - } - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateRouterOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateRouterOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateRouterOptions.java deleted file mode 100644 index c614e91..0000000 --- a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateRouterOptions.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.openstack.neutron.v2_0.options; - -import com.google.common.collect.ImmutableMap; -import org.jclouds.http.HttpRequest; -import org.jclouds.openstack.neutron.v2_0.domain.ExternalGatewayInfo; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Inject; -import java.util.Map; - -public class UpdateRouterOptions implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromUpdateRouterOptions(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected String name; - protected Boolean adminStateUp; - protected ExternalGatewayInfo externalGatewayInfo; - - /** - * @see UpdateRouterOptions#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see UpdateRouterOptions#getAdminStateUp() - */ - public T adminStateUp(Boolean adminStateUp) { - this.adminStateUp = adminStateUp; - return self(); - } - - /** - * @see UpdateRouterOptions#getExternalGatewayInfo() - */ - public T externalGatewayInfo(ExternalGatewayInfo externalGatewayInfo) { - this.externalGatewayInfo = externalGatewayInfo; - return self(); - } - - public UpdateRouterOptions build() { - return new UpdateRouterOptions(name, adminStateUp, externalGatewayInfo); - } - - public T fromUpdateRouterOptions(UpdateRouterOptions options) { - return this.name(options.getName()) - .adminStateUp(options.getAdminStateUp()) - .externalGatewayInfo(options.getExternalGatewayInfo()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected static class UpdateRouterRequest { - protected String name; - protected Boolean admin_state_up; - protected ExternalGatewayInfo external_gateway_info; - - protected UpdateRouterRequest() { - } - - protected static final class ExternalGatewayInfo { - protected String network_id; - - protected ExternalGatewayInfo(String network_id) { - this.network_id = network_id; - } - } - } - - protected String name; - protected Boolean adminStateUp; - protected ExternalGatewayInfo externalGatewayInfo; - - protected UpdateRouterOptions() { - this.name = null; - this.adminStateUp = null; - this.externalGatewayInfo = null; - } - - public UpdateRouterOptions(String name, Boolean adminStateUp, ExternalGatewayInfo externalGatewayInfo) { - this.name = name; - this.adminStateUp = adminStateUp; - this.externalGatewayInfo = externalGatewayInfo; - } - - /** - * @return the new name for the router - */ - public String getName() { - return name; - } - - /** - * @return the new administrative state for the router - */ - public Boolean getAdminStateUp() { - return adminStateUp; - } - - /** - * @return the new information on external gateway for the router - */ - public ExternalGatewayInfo getExternalGatewayInfo() { - return externalGatewayInfo; - } - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { - UpdateRouterRequest updateRouterRequest = new UpdateRouterRequest(); - - if (this.name != null) - updateRouterRequest.name = this.name; - if (this.adminStateUp != null) - updateRouterRequest.admin_state_up = this.adminStateUp; - if (this.externalGatewayInfo != null) - updateRouterRequest.external_gateway_info = new UpdateRouterRequest.ExternalGatewayInfo(this.externalGatewayInfo.getNetworkId()); - - return bindToRequest(request, ImmutableMap.of("router", updateRouterRequest)); - } - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateSubnetOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateSubnetOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateSubnetOptions.java deleted file mode 100644 index 3f2ec26..0000000 --- a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateSubnetOptions.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.openstack.neutron.v2_0.options; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; -import org.jclouds.http.HttpRequest; -import org.jclouds.openstack.neutron.v2_0.domain.HostRoute; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Inject; -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -public class UpdateSubnetOptions implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromUpdateSubnetOptions(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected String name; - protected String gatewayIp; - protected Boolean enableDhcp; - protected Set<String> dnsNameServers; - protected Set<HostRoute> hostRoutes; - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions#getGatewayIp() - */ - public T gatewayIp(String gatewayIp) { - this.gatewayIp = gatewayIp; - return self(); - } - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions#getEnableDhcp() - */ - public T enableDhcp(Boolean enableDhcp) { - this.enableDhcp = enableDhcp; - return self(); - } - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions#getDnsNameServers() - */ - public T dnsNameServers(Collection<String> dnsNameServers) { - this.dnsNameServers = ImmutableSet.copyOf(dnsNameServers); - return self(); - } - - /** - * @see org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions#getHostRoutes() - */ - public T hostRoutes(Collection<HostRoute> hostRoutes) { - this.hostRoutes = ImmutableSet.copyOf(hostRoutes); - return self(); - } - - public UpdateSubnetOptions build() { - return new UpdateSubnetOptions(name, gatewayIp, enableDhcp, dnsNameServers, hostRoutes); - } - - public T fromUpdateSubnetOptions(UpdateSubnetOptions in) { - return this.name(in.getName()) - .gatewayIp(in.getGatewayIp()) - .enableDhcp(in.getEnableDhcp()) - .dnsNameServers(in.getDnsNameServers()) - .hostRoutes(in.getHostRoutes()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private static class UpdateSubnetRequest { - protected String name; - protected String gateway_ip; - protected Boolean enable_dhcp; - protected Set<String> dns_nameservers; - protected Set<HostRoute> host_routes; - - private static class HostRoute { - protected String destination; - protected String nexthop; - } - } - - private final String name; - private final String gatewayIp; - private final Boolean enableDhcp; - private final Set<String> dnsNameServers; - private final Set<HostRoute> hostRoutes; - - protected UpdateSubnetOptions() { - this.name = null; - this.gatewayIp = null; - this.enableDhcp = null; - this.dnsNameServers = Sets.newHashSet(); - this.hostRoutes = Sets.newHashSet(); - } - - public UpdateSubnetOptions(String name, String gatewayIp, Boolean enableDhcp, Set<String> dnsNameServers, Set<HostRoute> hostRoutes) { - this.name = name; - this.gatewayIp = gatewayIp; - this.enableDhcp = enableDhcp; - this.dnsNameServers = dnsNameServers != null ? ImmutableSet.copyOf(dnsNameServers) : Sets.<String>newHashSet(); - this.hostRoutes = hostRoutes != null ? ImmutableSet.copyOf(hostRoutes) : Sets.<HostRoute>newHashSet(); - } - - /** - * @return the new name for the subnet - */ - public String getName() { - return name; - } - - /** - * @return the new default gateway used by devices in this subnet - */ - public String getGatewayIp() { - return gatewayIp; - } - - /** - * @return true if DHCP is enabled for this subnet, false if not - */ - public Boolean getEnableDhcp() { - return enableDhcp; - } - - /** - * @return the new set of DNS name servers used by hosts in this subnet - */ - public Set<String> getDnsNameServers() { - return dnsNameServers; - } - - /** - * @return the new set of routes that should be used by devices with IPs from this subnet - */ - public Set<HostRoute> getHostRoutes() { - return hostRoutes; - } - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { - UpdateSubnetRequest updateSubnetRequest = new UpdateSubnetRequest(); - - if (this.name != null) - updateSubnetRequest.name = this.name; - if (this.gatewayIp != null) - updateSubnetRequest.gateway_ip = this.gatewayIp; - if (this.enableDhcp != null) - updateSubnetRequest.enable_dhcp = this.enableDhcp; - if (!this.dnsNameServers.isEmpty()) - updateSubnetRequest.dns_nameservers = this.dnsNameServers; - if (!this.hostRoutes.isEmpty()) { - updateSubnetRequest.host_routes = Sets.newHashSet(); - for (HostRoute hostRoute : this.hostRoutes) { - UpdateSubnetRequest.HostRoute requestHostRoute = new UpdateSubnetRequest.HostRoute(); - requestHostRoute.destination = hostRoute.getDestinationCidr(); - requestHostRoute.nexthop = hostRoute.getNextHop(); - updateSubnetRequest.host_routes.add(requestHostRoute); - } - } - - return bindToRequest(request, ImmutableMap.of("subnet", updateSubnetRequest)); - } - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index 2365644..0000000 --- a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -org.jclouds.openstack.neutron.v2_0.NeutronApiMetadata -org.jclouds.openstack.neutron.v2.NeutronApiMetadata http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadataTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadataTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadataTest.java deleted file mode 100644 index f38136a..0000000 --- a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadataTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.neutron.v2; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import org.jclouds.View; -import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.testng.annotations.Test; - -/** - * The Neutron metadata test. - */ -@Test(groups = "unit", testName = "NeutronApiMetadataTest") -public class NeutronApiMetadataTest extends BaseApiMetadataTest { - public NeutronApiMetadataTest() { - super(new NeutronApiMetadata(), ImmutableSet.<TypeToken<? extends View>>of()); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiLiveTest.java deleted file mode 100644 index a3d5f3d..0000000 --- a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiLiveTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.openstack.neutron.v2.extensions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.openstack.neutron.v2.domain.FloatingIP; -import org.jclouds.openstack.neutron.v2.domain.IP; -import org.jclouds.openstack.neutron.v2.domain.Network; -import org.jclouds.openstack.neutron.v2.domain.NetworkType; -import org.jclouds.openstack.neutron.v2.domain.Subnet; -import org.jclouds.openstack.neutron.v2.features.NetworkApi; -import org.jclouds.openstack.neutron.v2.features.SubnetApi; -import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests parsing and Guice wiring of RouterApi - */ -@Test(groups = "live", testName = "FloatingIPApiLiveTest") -public class FloatingIPApiLiveTest extends BaseNeutronApiLiveTest { - - public void testCreateUpdateAndDeleteFloatingIP() { - for (String region : api.getConfiguredRegions()) { - - SubnetApi subnetApi = api.getSubnetApi(region); - FloatingIPApi floatingIPApi = api.getFloatingIPApi(region).get(); - NetworkApi networkApi = api.getNetworkApi(region); - - FloatingIP floatingIPGet = null; - String ipv4SubnetId = null; - Network network = null; - - try { - network = networkApi.create( - Network.createBuilder("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build()); - assertNotNull(network); - - ipv4SubnetId = subnetApi.create(Subnet.createBuilder(network.getId(), "198.51.100.0/24").ipVersion(4) - .name("JClouds-Live-IPv4-Subnet").build()).getId(); - - floatingIPApi.create(FloatingIP.createBuilder(network.getId()).build()); - - /* List and Get test */ - Set<FloatingIP> floatingIPs = floatingIPApi.list().concat().toSet(); - FloatingIP floatingIPList = floatingIPs.iterator().next(); - floatingIPGet = floatingIPApi.get(floatingIPList.getId()); - - assertNotNull(floatingIPGet); - assertEquals(floatingIPGet, floatingIPList); - } - finally { - try { - assertTrue(floatingIPApi.delete(floatingIPGet.getId())); - } - finally { - try { - assertTrue(subnetApi.delete(ipv4SubnetId)); - } - finally { - assertTrue(networkApi.delete(network.getId())); - } - } - } - } - } - - public Set<IP> getFixedAddresses(String subnetId) { - return ImmutableSet.of(IP.builder().subnetId(subnetId).build()); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiMockTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiMockTest.java deleted file mode 100644 index c28b1c8..0000000 --- a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiMockTest.java +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.neutron.v2.extensions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.List; - -import org.jclouds.openstack.neutron.v2.NeutronApi; -import org.jclouds.openstack.neutron.v2.domain.FloatingIP; -import org.jclouds.openstack.neutron.v2.domain.FloatingIPs; -import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest; -import org.jclouds.openstack.v2_0.options.PaginationOptions; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; - -/** - * Tests Floating Api Guice wiring and parsing - * - */ -@Test -public class FloatingIPApiMockTest extends BaseNeutronApiMockTest { - - public void testCreateFloatingIP() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201).setBody(stringFromResource("/floatingip_create_response.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - FloatingIP.CreateFloatingIP createFip = FloatingIP.createBuilder("376da547-b977-4cfe-9cba-275c80debf57") - .portId("ce705c24-c1ef-408a-bda3-7bbd946164ab") - .build(); - - FloatingIP floatingIP = api.create(createFip); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "POST", "/v2.0/floatingips", "/floatingip_create_request.json"); - - /* - * Check response - */ - assertNotNull(floatingIP); - assertEquals(floatingIP.getRouterId(), "d23abc8d-2991-4a55-ba98-2aaea84cc72f"); - assertEquals(floatingIP.getTenantId(), "4969c491a3c74ee4af974e6d800c62de"); - assertEquals(floatingIP.getFloatingNetworkId(), "376da547-b977-4cfe-9cba-275c80debf57"); - assertEquals(floatingIP.getFixedIpAddress(), "10.0.0.3"); - assertEquals(floatingIP.getFloatingIpAddress(), "172.24.4.228"); - assertEquals(floatingIP.getPortId(), "ce705c24-c1ef-408a-bda3-7bbd946164ab"); - assertEquals(floatingIP.getId(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7"); - - } finally { - server.shutdown(); - } - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testCreateFloatingIPFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - FloatingIP.CreateFloatingIP createFip = FloatingIP.createBuilder("376da547-b977-4cfe-9cba-275c80debf57") - .portId("ce705c24-c1ef-408a-bda3-7bbd946164ab") - .build(); - - FloatingIP floatingIP = api.create(createFip); - } finally { - server.shutdown(); - } - } - - public void testListSpecificPageFloatingIP() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/floatingip_list_response_paged1.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - FloatingIPs floatingIPs = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg")); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips?limit=2&marker=abcdefg"); - - /* - * Check response - */ - assertNotNull(floatingIPs); - assertEquals(floatingIPs.size(), 2); - assertEquals(floatingIPs.first().get().getId(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7"); - assertEquals(floatingIPs.get(1).getId(), "61cea855-49cb-4846-997d-801b70c71bdd"); - } finally { - server.shutdown(); - } - } - - public void testListSpecificPageFloatingIPFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - FloatingIPs floatingIPs = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg")); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips?limit=2&marker=abcdefg"); - - /* - * Check response - */ - assertNotNull(floatingIPs); - assertTrue(floatingIPs.isEmpty()); - } finally { - server.shutdown(); - } - } - - public void testListPagedFloatingIP() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/floatingip_list_response_paged1.json")))); - server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/floatingip_list_response_paged2.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - // Note: Lazy! Have to actually look at the collection. - List<FloatingIP> floatingIPs = api.list().concat().toList(); - - /* - * Check request - */ - assertEquals(server.getRequestCount(), 3); - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips"); - assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718"); - - /* - * Check response - */ - assertNotNull(floatingIPs); - assertEquals(floatingIPs.size(), 4); - assertEquals(floatingIPs.get(0).getId(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7"); - assertEquals(floatingIPs.get(3).getId(), "61cea855-49cb-4846-997d-801b70c71bdd2"); - } finally { - server.shutdown(); - } - } - - public void testListPagedFloatingIPFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - // Note: Lazy! Have to actually look at the collection. - List<FloatingIP> floatingIPs = api.list().concat().toList(); - - /* - * Check request - */ - assertEquals(server.getRequestCount(), 2); - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips"); - - /* - * Check response - */ - assertNotNull(floatingIPs); - assertTrue(floatingIPs.isEmpty()); - } finally { - server.shutdown(); - } - } - - public void testGetFloatingIP() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201).setBody(stringFromResource("/floatingip_get_response.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - FloatingIP floatingIP = api.get("12345"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips/12345"); - - /* - * Check response - */ - assertNotNull(floatingIP); - assertEquals(floatingIP.getId(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7"); - assertEquals(floatingIP.getPortId(), "ce705c24-c1ef-408a-bda3-7bbd946164ab"); - assertEquals(floatingIP.getFloatingIpAddress(), "172.24.4.228"); - assertEquals(floatingIP.getFixedIpAddress(), "10.0.0.3"); - assertEquals(floatingIP.getFloatingNetworkId(), "376da547-b977-4cfe-9cba-275c80debf57"); - assertEquals(floatingIP.getRouterId(), "d23abc8d-2991-4a55-ba98-2aaea84cc72f"); - assertEquals(floatingIP.getTenantId(), "4969c491a3c74ee4af974e6d800c62de"); - - } finally { - server.shutdown(); - } - } - - public void testGetFloatingIPFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - FloatingIP floatingIP = api.get("12345"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips/12345"); - - /* - * Check response - */ - assertNull(floatingIP); - - } finally { - server.shutdown(); - } - } - - public void testUpdateFloatingIP() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201).setBody(stringFromResource("/floatingip_update_response.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - FloatingIP.UpdateFloatingIP updateFloatingIP = FloatingIP.updateBuilder() - .portId("fc861431-0e6c-4842-a0ed-e2363f9bc3a8") - .build(); - - FloatingIP floatingIP = api.update("12345", updateFloatingIP); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/floatingips/12345", "/floatingip_update_request.json"); - - /* - * Check response - */ - assertNotNull(floatingIP); - assertEquals(floatingIP.getPortId(), "fc861431-0e6c-4842-a0ed-e2363f9bc3a8"); - - } finally { - server.shutdown(); - } - } - - public void testUpdateFloatingIPDissociate() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201).setBody(stringFromResource("/floatingip_update_dissociate_response.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - FloatingIP.UpdateFloatingIP updateFloatingIP = FloatingIP.updateBuilder().build(); - - FloatingIP floatingIP = api.update("12345", updateFloatingIP); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/floatingips/12345", "/floatingip_update_dissociate_request.json"); - - /* - * Check response - */ - assertNotNull(floatingIP); - assertNull(floatingIP.getPortId()); - - } finally { - server.shutdown(); - } - } - - public void testUpdateFloatingIPFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - FloatingIP.UpdateFloatingIP updateFloatingIP = FloatingIP.updateBuilder() - .portId("fc861431-0e6c-4842-a0ed-e2363f9bc3a8") - .build(); - - FloatingIP floatingIP = api.update("12345", updateFloatingIP); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/floatingips/12345", "/floatingip_update_request.json"); - - /* - * Check response - */ - assertNull(floatingIP); - } finally { - server.shutdown(); - } - } - - public void testDeleteFloatingIP() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - boolean result = api.delete("12345"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "DELETE", "/v2.0/floatingips/12345"); - - /* - * Check response - */ - assertTrue(result); - } finally { - server.shutdown(); - } - } - - public void testDeleteFloatingIPFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); - - boolean result = api.delete("12345"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "DELETE", "/v2.0/floatingips/12345"); - - /* - * Check response - */ - assertFalse(result); - } finally { - server.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiLiveTest.java deleted file mode 100644 index 2a006e8..0000000 --- a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiLiveTest.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.openstack.neutron.v2.extensions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.openstack.neutron.v2.domain.ExternalGatewayInfo; -import org.jclouds.openstack.neutron.v2.domain.Network; -import org.jclouds.openstack.neutron.v2.domain.NetworkType; -import org.jclouds.openstack.neutron.v2.domain.Port; -import org.jclouds.openstack.neutron.v2.domain.Router; -import org.jclouds.openstack.neutron.v2.domain.RouterInterface; -import org.jclouds.openstack.neutron.v2.domain.Subnet; -import org.jclouds.openstack.neutron.v2.features.NetworkApi; -import org.jclouds.openstack.neutron.v2.features.PortApi; -import org.jclouds.openstack.neutron.v2.features.SubnetApi; -import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest; -import org.testng.annotations.Test; - -/** - * Tests parsing and Guice wiring of RouterApi - */ -@Test(groups = "live", testName = "RouterApiLiveTest") -public class RouterApiLiveTest extends BaseNeutronApiLiveTest { - - public void testCreateUpdateAndDeleteRouter() { - for (String region : api.getConfiguredRegions()) { - RouterApi routerApi = api.getRouterApi(region).get(); - NetworkApi networkApi = api.getNetworkApi(region); - SubnetApi subnetApi = api.getSubnetApi(region); - - Network network = networkApi.create( - Network.createBuilder("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build()); - assertNotNull(network); - - Subnet subnet = subnetApi.create(Subnet.createBuilder(network.getId(), "192.168.0.0/16").ipVersion(4).build()); - assertNotNull(subnet); - - Router router = routerApi.create(Router.createBuilder().name("jclouds-router-test") - .externalGatewayInfo(ExternalGatewayInfo.builder().networkId(network.getId()).build()).build()); - assertNotNull(router); - - /* List and Get test */ - Set<Router> routers = api.getRouterApi(region).get().list().concat().toSet(); - Router routerList = routers.iterator().next(); - Router routerGet = api.getRouterApi(region).get().get(routerList.getId()); - - assertNotNull(routerGet); - assertEquals(routerGet, routerList); - /***/ - - routerGet = routerApi.get(router.getId()); - - assertEquals(routerGet.getName(), router.getName()); - assertEquals(routerGet.getId(), router.getId()); - assertEquals(routerGet.getExternalGatewayInfo(), router.getExternalGatewayInfo()); - - Router routerUpdate = routerApi.update(router.getId(), Router.updateBuilder().name("jclouds-router-test-rename").build()); - assertNotNull(routerUpdate); - assertEquals(routerUpdate.getName(), "jclouds-router-test-rename"); - - routerGet = routerApi.get(router.getId()); - - assertEquals(routerGet.getId(), router.getId()); - assertEquals(routerGet.getName(), "jclouds-router-test-rename"); - - assertTrue(routerApi.delete(router.getId())); - assertTrue(subnetApi.delete(subnet.getId())); - assertTrue(networkApi.delete(network.getId())); - } - } - - public void testCreateAndDeleteRouterInterfaceForSubnet() { - for (String region : api.getConfiguredRegions()) { - RouterApi routerApi = api.getRouterApi(region).get(); - NetworkApi networkApi = api.getNetworkApi(region); - SubnetApi subnetApi = api.getSubnetApi(region); - - Network network = networkApi.create(Network.createBuilder("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build()); - assertNotNull(network); - - Subnet subnet = subnetApi.create(Subnet.createBuilder(network.getId(), "192.168.0.0/16").ipVersion(4).build()); - assertNotNull(subnet); - - Network network2 = networkApi.create(Network.createBuilder("jclouds-network-test2").external(true).networkType(NetworkType.LOCAL).build()); - assertNotNull(network2); - - Subnet subnet2 = subnetApi.create(Subnet.createBuilder(network2.getId(), "192.169.0.0/16").ipVersion(4).build()); - assertNotNull(subnet2); - - Router router = routerApi.create(Router.createBuilder().name("jclouds-router-test").build()); - assertNotNull(router); - - RouterInterface routerInterface = routerApi.addInterfaceForSubnet(router.getId(), subnet.getId()); - assertNotNull(routerInterface); - - RouterInterface routerInterface2 = routerApi.addInterfaceForSubnet(router.getId(), subnet2.getId()); - assertNotNull(routerInterface2); - - assertTrue(routerApi.removeInterfaceForSubnet(router.getId(), subnet.getId())); - assertTrue(routerApi.removeInterfaceForSubnet(router.getId(), subnet2.getId())); - assertTrue(routerApi.delete(router.getId())); - assertTrue(subnetApi.delete(subnet.getId())); - assertTrue(networkApi.delete(network.getId())); - assertTrue(subnetApi.delete(subnet2.getId())); - assertTrue(networkApi.delete(network2.getId())); - } - } - - public void testCreateAndDeleteRouterInterfaceForPort() { - for (String region : api.getConfiguredRegions()) { - RouterApi routerApi = api.getRouterApi(region).get(); - NetworkApi networkApi = api.getNetworkApi(region); - SubnetApi subnetApi = api.getSubnetApi(region); - PortApi portApi = api.getPortApi(region); - - Network network = networkApi.create(Network.createBuilder("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build()); - assertNotNull(network); - - Subnet subnet = subnetApi.create(Subnet.createBuilder(network.getId(), "192.168.0.0/16").ipVersion(4).build()); - assertNotNull(subnet); - - Network network2 = networkApi.create(Network.createBuilder("jclouds-network-test2").external(true).networkType(NetworkType.LOCAL).build()); - assertNotNull(network2); - - Subnet subnet2 = subnetApi.create(Subnet.createBuilder(network2.getId(), "192.169.0.0/16").ipVersion(4).build()); - assertNotNull(subnet2); - - Port port = portApi.create(Port.createBuilder(network.getId()).build()); - assertNotNull(port); - - Port port2 = portApi.create(Port.createBuilder(network2.getId()).build()); - assertNotNull(port2); - - Router router = routerApi.create(Router.createBuilder().name("jclouds-router-test").build()); - assertNotNull(router); - - RouterInterface routerInterface = routerApi.addInterfaceForPort(router.getId(), port.getId()); - assertNotNull(routerInterface); - - RouterInterface routerInterface2 = routerApi.addInterfaceForPort(router.getId(), port2.getId()); - assertNotNull(routerInterface2); - - assertTrue(routerApi.removeInterfaceForPort(router.getId(), port.getId())); - assertTrue(routerApi.removeInterfaceForPort(router.getId(), port2.getId())); - assertTrue(routerApi.delete(router.getId())); - assertTrue(subnetApi.delete(subnet.getId())); - assertTrue(networkApi.delete(network.getId())); - assertTrue(subnetApi.delete(subnet2.getId())); - assertTrue(networkApi.delete(network2.getId())); - } - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiMockTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiMockTest.java deleted file mode 100644 index 00232f8..0000000 --- a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiMockTest.java +++ /dev/null @@ -1,631 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.neutron.v2.extensions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.List; - -import org.jclouds.openstack.neutron.v2.NeutronApi; -import org.jclouds.openstack.neutron.v2.domain.ExternalGatewayInfo; -import org.jclouds.openstack.neutron.v2.domain.NetworkStatus; -import org.jclouds.openstack.neutron.v2.domain.Router; -import org.jclouds.openstack.neutron.v2.domain.RouterInterface; -import org.jclouds.openstack.neutron.v2.domain.Routers; -import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest; -import org.jclouds.openstack.v2_0.options.PaginationOptions; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; - -/** - * Tests NetworkApi Guice wiring and parsing - * - */ -@Test -public class RouterApiMockTest extends BaseNeutronApiMockTest { - - public void testCreateRouter() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201).setBody(stringFromResource("/router_create_response.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - Router.CreateRouter createRouter = Router.createBuilder().name("another_router").adminStateUp(Boolean.TRUE) - .externalGatewayInfo(ExternalGatewayInfo.builder().networkId("8ca37218-28ff-41cb-9b10-039601ea7e6b").build()) - .build(); - - Router router = api.create(createRouter); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "POST", "/v2.0/routers", "/router_create_request.json"); - - /* - * Check response - */ - assertNotNull(router); - assertEquals(router.getName(), "another_router"); - assertEquals(router.getExternalGatewayInfo().getNetworkId(), "8ca37218-28ff-41cb-9b10-039601ea7e6b"); - assertEquals(router.getStatus(), NetworkStatus.ACTIVE); - assertEquals(router.getAdminStateUp(), Boolean.TRUE); - assertEquals(router.getId(), "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e"); - assertEquals(router.getTenantId(), "6b96ff0cb17a4b859e1e575d221683d3"); - } finally { - server.shutdown(); - } - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testCreateRouterFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - Router.CreateRouter createRouter = Router.createBuilder().name("another_router").adminStateUp(Boolean.TRUE) - .externalGatewayInfo(ExternalGatewayInfo.builder().networkId("8ca37218-28ff-41cb-9b10-039601ea7e6b").build()) - .build(); - - api.create(createRouter); - fail("Should have failed with not found exception"); - - } finally { - server.shutdown(); - } - } - - public void testListSpecificPageRouter() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/router_list_response_paged1.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - Routers routers = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg")); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/routers?limit=2&marker=abcdefg"); - - /* - * Check response - */ - assertNotNull(routers); - assertEquals(routers.size(), 2); - assertEquals(routers.first().get().getId(), "a9254bdb-2613-4a13-ac4c-adc581fba50d"); - } finally { - server.shutdown(); - } - } - - public void testListSpecificPageRouterFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - Routers routers = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg")); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/routers?limit=2&marker=abcdefg"); - - /* - * Check response - */ - assertNotNull(routers); - assertTrue(routers.isEmpty()); - } finally { - server.shutdown(); - } - } - - public void testListPagedRouter() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/router_list_response_paged1.json")))); - server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/router_list_response_paged2.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - // Note: Lazy! Have to actually look at the collection. - List<Router> routers = api.list().concat().toList(); - - /* - * Check request - */ - assertEquals(server.getRequestCount(), 3); - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/routers"); - assertRequest(server.takeRequest(), "GET", "/v2.0/routers?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718"); - - /* - * Check response - */ - assertNotNull(routers); - assertEquals(routers.size(), 4); - assertEquals(routers.get(0).getId(), "a9254bdb-2613-4a13-ac4c-adc581fba50d"); - assertEquals(routers.get(3).getId(), "a9254bdb-2613-4a13-ac4c-adc581fba50d_4"); - } finally { - server.shutdown(); - } - } - - public void testListPagedRouterFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - // Note: Lazy! Have to actually look at the collection. - List<Router> routers = api.list().concat().toList(); - - /* - * Check request - */ - assertEquals(server.getRequestCount(), 2); - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/routers"); - - /* - * Check response - */ - assertNotNull(routers); - assertTrue(routers.isEmpty()); - } finally { - server.shutdown(); - } - } - - public void testGetRouter() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201).setBody(stringFromResource("/router_get_response.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - Router router = api.get("12345"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/routers/12345"); - - /* - * Check response - */ - assertNotNull(router); - assertEquals(router.getName(), "router1"); - assertEquals(router.getExternalGatewayInfo().getNetworkId(), "3c5bcddd-6af9-4e6b-9c3e-c153e521cab8"); - assertEquals(router.getStatus(), NetworkStatus.ACTIVE); - assertEquals(router.getAdminStateUp(), Boolean.TRUE); - assertEquals(router.getId(), "a9254bdb-2613-4a13-ac4c-adc581fba50d"); - assertEquals(router.getTenantId(), "33a40233088643acb66ff6eb0ebea679"); - } finally { - server.shutdown(); - } - } - - public void testGetRouterFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - Router router = api.get("12345"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "GET", "/v2.0/routers/12345"); - - /* - * Check response - */ - assertNull(router); - } finally { - server.shutdown(); - } - } - - public void testUpdateRouter() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201).setBody(stringFromResource("/router_update_response.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - Router.UpdateRouter updateRouter = Router.updateBuilder() - .externalGatewayInfo( - ExternalGatewayInfo.builder().networkId("8ca37218-28ff-41cb-9b10-039601ea7e6b").build()) - .build(); - - Router router = api.update("12345", updateRouter); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345", "/router_update_request.json"); - - /* - * Check response - */ - assertNotNull(router); - assertEquals(router.getName(), "another_router"); - assertEquals(router.getExternalGatewayInfo().getNetworkId(), "8ca37218-28ff-41cb-9b10-039601ea7e6b"); - assertEquals(router.getStatus(), NetworkStatus.ACTIVE); - assertEquals(router.getAdminStateUp(), Boolean.TRUE); - assertEquals(router.getId(), "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e"); - assertEquals(router.getTenantId(), "6b96ff0cb17a4b859e1e575d221683d3"); - } finally { - server.shutdown(); - } - } - - public void testUpdateRouterFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - Router.UpdateRouter updateRouter = Router.updateBuilder() - .externalGatewayInfo( - ExternalGatewayInfo.builder().networkId("8ca37218-28ff-41cb-9b10-039601ea7e6b").build()) - .build(); - - Router router = api.update("12345", updateRouter); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345", "/router_update_request.json"); - - /* - * Check response - */ - assertNull(router); - } finally { - server.shutdown(); - } - } - - public void testDeleteRouter() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - boolean result = api.delete("12345"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "DELETE", "/v2.0/routers/12345"); - - /* - * Check response - */ - assertTrue(result); - } finally { - server.shutdown(); - } - } - - public void testDeleteRouterFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - boolean result = api.delete("12345"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "DELETE", "/v2.0/routers/12345"); - - /* - * Check response - */ - assertFalse(result); - } finally { - server.shutdown(); - } - } - - public void testAddRouterInterfaceForSubnet() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201).setBody(stringFromResource("/router_add_interface_response.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - RouterInterface routerInterface = api.addInterfaceForSubnet("12345", "a2f1f29d-571b-4533-907f-5803ab96ead1"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/add_router_interface", "/router_add_interface_request.json"); - - /* - * Check response - */ - assertNotNull(routerInterface); - assertEquals(routerInterface.getSubnetId(), "a2f1f29d-571b-4533-907f-5803ab96ead1"); - assertEquals(routerInterface.getPortId(), "3a44f4e5-1694-493a-a1fb-393881c673a4"); - } finally { - server.shutdown(); - } - } - - public void testAddRouterInterfaceForSubnetFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - RouterInterface routerInterface = api.addInterfaceForSubnet("12345", "a2f1f29d-571b-4533-907f-5803ab96ead1"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/add_router_interface", "/router_add_interface_request.json"); - - /* - * Check response - */ - assertNull(routerInterface); - } finally { - server.shutdown(); - } - } - - public void testAddRouterInterfaceForPort() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201).setBody(stringFromResource("/router_add_interface_response.json")))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - RouterInterface routerInterface = api.addInterfaceForPort("12345", "portid"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/add_router_interface", "/router_add_interface_port_request.json"); - - /* - * Check response - */ - assertNotNull(routerInterface); - assertEquals(routerInterface.getSubnetId(), "a2f1f29d-571b-4533-907f-5803ab96ead1"); - assertEquals(routerInterface.getPortId(), "3a44f4e5-1694-493a-a1fb-393881c673a4"); - } finally { - server.shutdown(); - } - } - - public void testAddRouterInterfaceForPortFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - RouterInterface routerInterface = api.addInterfaceForPort("12345", "portid"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/add_router_interface", "/router_add_interface_port_request.json"); - - /* - * Check response - */ - assertNull(routerInterface); - } finally { - server.shutdown(); - } - } - - public void testRemoveRouterInterfaceForSubnet() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - boolean result = api.removeInterfaceForSubnet("12345", "a2f1f29d-571b-4533-907f-5803ab96ead1"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/remove_router_interface", "/router_remove_interface_subnet_request.json"); - - /* - * Check response - */ - assertTrue(result); - } finally { - server.shutdown(); - } - } - - public void testRemoveRouterInterfaceForSubnetFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - boolean result = api.removeInterfaceForSubnet("12345", "a2f1f29d-571b-4533-907f-5803ab96ead1"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/remove_router_interface", "/router_remove_interface_subnet_request.json"); - - /* - * Check response - */ - assertFalse(result); - } finally { - server.shutdown(); - } - } - - public void testRemoveRouterInterfaceForPort() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(201))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - boolean result = api.removeInterfaceForPort("12345", "portid"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/remove_router_interface", "/router_remove_interface_port_request.json"); - - /* - * Check response - */ - assertTrue(result); - } finally { - server.shutdown(); - } - } - - public void testRemoveRouterInterfaceForPortFail() throws IOException, InterruptedException, URISyntaxException { - MockWebServer server = mockOpenStackServer(); - server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); - server.enqueue(addCommonHeaders( - new MockResponse().setResponseCode(404))); - - try { - NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); - RouterApi api = neutronApi.getRouterApi("RegionOne").get(); - - boolean result = api.removeInterfaceForPort("12345", "portid"); - - /* - * Check request - */ - assertAuthentication(server); - assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/remove_router_interface", "/router_remove_interface_port_request.json"); - - /* - * Check response - */ - assertFalse(result); - } finally { - server.shutdown(); - } - } -}
