http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadata.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadata.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadata.java new file mode 100644 index 0000000..043bed8 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadata.java @@ -0,0 +1,100 @@ +/* + * 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 static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule; +import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.neutron.v2.config.NeutronHttpApiModule; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.rest.internal.BaseHttpApiMetadata; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + +/** + * Implementation of {@link org.jclouds.apis.ApiMetadata} for Neutron 2.0 API + * + */ +public class NeutronApiMetadata extends BaseHttpApiMetadata<NeutronApi> { + + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); + } + + public NeutronApiMetadata() { + this(new Builder()); + } + + protected NeutronApiMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = BaseHttpApiMetadata.defaultProperties(); + properties.setProperty(SERVICE_TYPE, ServiceType.NETWORK); + properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); + return properties; + } + + public static class Builder extends BaseHttpApiMetadata.Builder<NeutronApi, Builder> { + + protected Builder() { + super(NeutronApi.class); + id("openstack-neutron") + .name("OpenStack Neutron API") + .identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant") + .credentialName("${password}") + .endpointName("Neutron base url ending in /v2.0/") + .documentation(URI.create("http://docs.openstack.org/api/openstack-network/2.0/content/")) + .version("v2.0") + .defaultEndpoint("http://localhost:5000/v2.0/") + .defaultProperties(NeutronApiMetadata.defaultProperties()) + .defaultModules(ImmutableSet.<Class<? extends Module>>builder() + .add(AuthenticationApiModule.class) + .add(KeystoneAuthenticationModule.class) + .add(RegionModule.class) + .add(NeutronHttpApiModule.class).build()); + } + + @Override + public NeutronApiMetadata build() { + return new NeutronApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(ApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + + @Override + protected Builder self() { + return this; + } + } + +}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java new file mode 100644 index 0000000..90c59f2 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java @@ -0,0 +1,91 @@ +/* + * 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.config; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.Multimap; +import com.google.inject.Provides; +import org.jclouds.http.HttpErrorHandler; +import org.jclouds.http.annotation.ClientError; +import org.jclouds.http.annotation.Redirection; +import org.jclouds.http.annotation.ServerError; +import org.jclouds.json.config.GsonModule.DateAdapter; +import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.handlers.NeutronErrorHandler; +import org.jclouds.openstack.v2_0.domain.Extension; +import org.jclouds.openstack.v2_0.functions.PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet; +import org.jclouds.openstack.neutron.v2.extensions.ExtensionNamespaces; +import org.jclouds.rest.ConfiguresHttpApi; +import org.jclouds.rest.config.HttpApiModule; +import org.jclouds.rest.functions.ImplicitOptionalConverter; + +import javax.inject.Provider; +import javax.inject.Singleton; +import java.net.URI; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * Configures the Neutron connection. + * + */ +@ConfiguresHttpApi +public class NeutronHttpApiModule extends HttpApiModule<NeutronApi> { + + @Override + protected void configure() { + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class); + super.configure(); + } + + @Provides + @Singleton + public Multimap<URI, URI> aliases() { + return ImmutableMultimap.<URI, URI>builder() + .put(URI.create(ExtensionNamespaces.L3_ROUTER), + URI.create("http://docs.openstack.org/ext/neutron/router/api/v1.0")) + .put(URI.create(ExtensionNamespaces.SECURITY_GROUPS), + URI.create("http://docs.openstack.org/ext/securitygroups/api/v2.0")) + .put(URI.create(ExtensionNamespaces.LBAAS), + URI.create("http://docs.openstack.org/networking/ext/lbaas/api/v1.0")) + .build(); + } + + @Provides + @Singleton + public LoadingCache<String, Set<? extends Extension>> provideExtensionsByRegion(final Provider<NeutronApi> neutronApi) { + return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS) + .build(new CacheLoader<String, Set<? extends Extension>>() { + @Override + public Set<? extends Extension> load(String key) throws Exception { + return neutronApi.get().getExtensionApi(key).list(); + } + }); + } + + @Override + protected void bindErrorHandlers() { + bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(NeutronErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(NeutronErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(NeutronErrorHandler.class); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AddressPair.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AddressPair.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AddressPair.java new file mode 100644 index 0000000..e2d888c --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AddressPair.java @@ -0,0 +1,176 @@ +/* + * 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.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; + +/** + * Contains a mapping between a MAC address and an IP address. + */ +public class AddressPair { + + @Named("mac_address") + private String macAddress; + @Named("ip_address") + private String ipAddress; + + @ConstructorProperties({"mac_address", "ip_address"}) + protected AddressPair(String macAddress, String ipAddress) { + checkNotNull(macAddress, "mac address should not be null"); + checkNotNull(ipAddress, "ip should not be null"); + this.macAddress = macAddress; + this.ipAddress = ipAddress; + } + + /** + * Copy constructor + * @param addressPair + */ + private AddressPair(AddressPair addressPair) { + this(addressPair.getMacAddress(), addressPair.getIpAddress()); + } + + /** + * Default constructor + */ + private AddressPair() {} + + /** + * @return the macAddress of the AddressPair + */ + @Nullable + public String getMacAddress() { + return macAddress; + } + + /** + * @return the ipAddress of the AddressPair + */ + @Nullable + public String getIpAddress() { + return ipAddress; + } + + @Override + public int hashCode() { + return Objects.hashCode(macAddress, ipAddress); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + AddressPair that = AddressPair.class.cast(obj); + return Objects.equal(this.macAddress, that.macAddress) && Objects.equal(this.ipAddress, that.ipAddress); + } + + protected Objects.ToStringHelper string() { + return Objects.toStringHelper(this).add("macAddress", macAddress).add("ipAddress", ipAddress); + } + + @Override + public String toString() { + return string().toString(); + } + + /** + * Returns a builder, but requires the user to specify any parameters required when creating a resource. + * In this case, both parameters are required. + * @return the Builder for AddressPair + */ + public static Builder builder(String macAddress, String ipAddress) { + return new Builder(macAddress, ipAddress); + } + + /** + * Gets a Builder configured as this object. + */ + public Builder toBuilder() { + return new Builder().fromAddressPair(this); + } + + public static class Builder { + // Keep track of the builder's state. + private AddressPair addressPair; + + /** + * No-parameters constructor used when updating. + * */ + private Builder() { + addressPair = new AddressPair(); + } + + /** + * Required parameters constructor used when creating. + * @param macAddress + * @param ipAddress + */ + private Builder(String macAddress, String ipAddress) { + addressPair = new AddressPair(); + addressPair.macAddress = macAddress; + addressPair.ipAddress = ipAddress; + } + + /** + * Provide the macAddress to the AddressPair's Builder. + * + * @return the Builder. + * @see AddressPair#getMacAddress() + */ + public Builder macAddress(String macAddress) { + addressPair.macAddress = macAddress; + return this; + } + + /** + * Provide the ipAddress to the AddressPair's Builder. + * + * @return the Builder. + * @see AddressPair#getIpAddress() + */ + public Builder ipAddress(String ipAddress) { + addressPair.ipAddress = ipAddress; + return this; + } + + /** + * @return a AddressPair constructed with this Builder. + */ + public AddressPair build() { + // Use the copy constructor to copy the builder's state (config) object and pass back to the user. + // Immutability is preserved, and fields are defined only once. + return new AddressPair(addressPair); + } + + /** + * @return a Builder from another AddressPair. + */ + public Builder fromAddressPair(AddressPair in) { + return this.macAddress(in.getMacAddress()).ipAddress(in.getIpAddress()); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AllocationPool.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AllocationPool.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AllocationPool.java new file mode 100644 index 0000000..6d20999 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AllocationPool.java @@ -0,0 +1,138 @@ +/* + * 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.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; + +/** + * A Neutron Subnet Allocation Pool + * Contains a start and an end IP address describing the pool. + * + * @see <a + * href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api + * doc</a> + */ +public class AllocationPool { + + protected final String start; + protected final String end; + + @ConstructorProperties({"start", "end"}) + protected AllocationPool(String start, String end) { + this.start = start; + this.end = end; + } + + /** + * @return the start of the AllocationPool + */ + @Nullable + public String getStart() { + return start; + } + + /** + * @return the end of the AllocationPool + */ + @Nullable + public String getEnd() { + return end; + } + + @Override + public int hashCode() { + return Objects.hashCode(start, end); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + AllocationPool that = AllocationPool.class.cast(obj); + return Objects.equal(this.start, that.start) && Objects.equal(this.end, that.end); + } + + protected Objects.ToStringHelper string() { + return Objects.toStringHelper(this).add("start", start).add("end", end); + } + + @Override + public String toString() { + return string().toString(); + } + + /** + * @return the Builder for AllocationPool + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Gets a Builder configured as this object. + */ + public Builder toBuilder() { + return new Builder().fromAllocationPool(this); + } + + public static class Builder { + protected String start; + protected String end; + + /** + * Provide the start to the AllocationPool's Builder. + * + * @return the Builder. + * @see AllocationPool#getStart() + */ + public Builder start(String start) { + this.start = start; + return this; + } + + /** + * Provide the end to the AllocationPool's Builder. + * + * @return the Builder. + * @see AllocationPool#getEnd() + */ + public Builder end(String end) { + this.end = end; + return this; + } + + /** + * @return a AllocationPool constructed with this Builder. + */ + public AllocationPool build() { + return new AllocationPool(start, end); + } + + /** + * @return a Builder from another AllocationPool. + */ + public Builder fromAllocationPool(AllocationPool in) { + return this.start(in.getStart()).end(in.getEnd()); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExternalGatewayInfo.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExternalGatewayInfo.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExternalGatewayInfo.java new file mode 100644 index 0000000..4dd6505 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExternalGatewayInfo.java @@ -0,0 +1,137 @@ +/* + * 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.domain; + +import com.google.common.base.Objects; +import org.jclouds.javax.annotation.Nullable; + +import javax.inject.Named; +import java.beans.ConstructorProperties; + +/** + * Information on the external gateway for the router + */ +public class ExternalGatewayInfo { + + @Named("network_id") + protected final String networkId; + @Named("enable_snat") + protected final Boolean enableSnat; + + @ConstructorProperties({"network_id", "enable_snat"}) + protected ExternalGatewayInfo(String networkId, Boolean enableSnat) { + this.networkId = networkId; + this.enableSnat = enableSnat; + } + + /** + * @return the networkId of the ExternalGatewayInfo + */ + @Nullable + public String getNetworkId() { + return networkId; + } + + /** + * @return the enableSnat status of the ExternalGatewayInfo + */ + @Nullable + public Boolean getEnableSnat() { + return enableSnat; + } + + @Override + public int hashCode() { + return Objects.hashCode(networkId, enableSnat); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + ExternalGatewayInfo that = (ExternalGatewayInfo) o; + + return Objects.equal(this.networkId, that.networkId) && + Objects.equal(this.enableSnat, that.enableSnat); + } + + /** + * @return the Builder for ExternalGatewayInfo + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Gets a Builder configured as this object. + */ + public Builder toBuilder() { + return new Builder().fromExternalGatewayInfo(this); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("networkId", networkId) + .add("enableSnat", enableSnat) + .toString(); + } + + public static class Builder { + protected String networkId; + protected Boolean enableSnat; + + /** + * Provide the networkId to the ExternalGatewayInfo's Builder. + * + * @return the Builder. + * @see ExternalGatewayInfo#getNetworkId() + */ + public Builder networkId(String networkId) { + this.networkId = networkId; + return this; + } + + /** + * Provide the enableSnat status to the ExternalGatewayInfo's Builder. + * + * @return the Builder. + * @see ExternalGatewayInfo#getEnableSnat() + */ + public Builder enableSnat(Boolean enableSnat) { + this.enableSnat = enableSnat; + return this; + } + + /** + * @return a ExternalGatewayInfo constructed with this Builder. + */ + public ExternalGatewayInfo build() { + return new ExternalGatewayInfo(networkId, enableSnat); + } + + /** + * @return a Builder from another ExternalGatewayInfo. + */ + public Builder fromExternalGatewayInfo(ExternalGatewayInfo in) { + return this.networkId(in.getNetworkId()).enableSnat(in.getEnableSnat()); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExtraDhcpOption.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExtraDhcpOption.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExtraDhcpOption.java new file mode 100644 index 0000000..89060f7 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExtraDhcpOption.java @@ -0,0 +1,165 @@ +/* + * 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.domain; + +import com.google.common.base.Objects; +import org.jclouds.javax.annotation.Nullable; + +import javax.inject.Named; +import java.beans.ConstructorProperties; + +/** + * This is used to provide additional DHCP-related options to Subnet. This is + * based on a neutron extension. + * For example PXE boot options to DHCP clients can be specified (e.g. tftp-server, + * server-ip-address, bootfile-name) + * + * @see <a + * href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api + * doc</a> + */ +public class ExtraDhcpOption { + + protected final String id; + @Named("opt_name") + protected final String optionName; + @Named("opt_value") + protected final String optionValue; + + @ConstructorProperties({"id", "opt_name", "opt_value"}) + protected ExtraDhcpOption(String id, String optionName, String optionValue) { + this.id = id; + this.optionName = optionName; + this.optionValue = optionValue; + } + + /** + * @return the id of the ExtraDhcpOption + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return the optionName of the ExtraDhcpOption + */ + @Nullable + public String getOptionName() { + return optionName; + } + + /** + * @return the optionValue of the ExtraDhcpOption + */ + @Nullable + public String getOptionValue() { + return optionValue; + } + + @Override + public int hashCode() { + return Objects.hashCode(id, optionName, optionValue); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + ExtraDhcpOption that = ExtraDhcpOption.class.cast(obj); + return Objects.equal(this.id, that.id) && Objects.equal(this.optionName, that.optionName) + && Objects.equal(this.optionValue, that.optionValue); + } + + protected Objects.ToStringHelper string() { + return Objects.toStringHelper(this).add("id", id).add("optionName", optionName).add("optionValue", optionValue); + } + + @Override + public String toString() { + return string().toString(); + } + + /** + * @return the Builder for ExtraDhcpOption + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Gets a Builder configured as this object. + */ + public Builder toBuilder() { + return new Builder().fromExtraDhcpOption(this); + } + + public static class Builder { + protected String id; + protected String optionName; + protected String optionValue; + + /** + * Provide the id to the ExtraDhcpOption's Builder. + * + * @return the Builder. + * @see ExtraDhcpOption#getId() + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Provide the optionName to the ExtraDhcpOption's Builder. + * + * @return the Builder. + * @see ExtraDhcpOption#getOptionName() + */ + public Builder optionName(String optionName) { + this.optionName = optionName; + return this; + } + + /** + * Provide the optionValue to the ExtraDhcpOption's Builder. + * + * @return the Builder. + * @see ExtraDhcpOption#getOptionValue() + */ + public Builder optionValue(String optionValue) { + this.optionValue = optionValue; + return this; + } + + /** + * @return a ExtraDhcpOption constructed with this Builder. + */ + public ExtraDhcpOption build() { + return new ExtraDhcpOption(id, optionName, optionValue); + } + + /** + * @return a Builder from another ExtraDhcpOption. + */ + public Builder fromExtraDhcpOption(ExtraDhcpOption in) { + return this.id(in.getId()).optionName(in.getOptionName()).optionValue(in.getOptionValue()); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIP.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIP.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIP.java new file mode 100644 index 0000000..fa5a8b5 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIP.java @@ -0,0 +1,315 @@ +/* + * 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.domain; + +import java.beans.ConstructorProperties; +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; +import com.google.common.base.Objects; + +/** + * A Neutron Floating IP + * + */ +public class FloatingIP { + + private String id; + @Named("router_id") + private String routerId; + @Named("tenant_id") + private String tenantId; + // Only mandatory attribute when creating + @Named("floating_network_id") + private String floatingNetworkId; + @Named("fixed_ip_address") + private String fixedIpAddress; + @Named("floating_ip_address") + private String floatingIpAddress; + @Named("port_id") + private String portId; + + /** + * Deserialization constructor + */ + @ConstructorProperties({"id", "router_id", "tenant_id", "floating_network_id", "fixed_ip_address", + "floating_ip_address", "port_id"}) + private FloatingIP(String id, String routerId, String tenantId, String floatingNetworkId, String fixedIpAddress, + String floatingIpAddress, String portId) { + this.id = id; + this.routerId = routerId; + this.tenantId = tenantId; + this.floatingNetworkId = floatingNetworkId; + this.fixedIpAddress = fixedIpAddress; + this.floatingIpAddress = floatingIpAddress; + this.portId = portId; + } + + private FloatingIP() {} + + /** + * @param floatingIP The floating IP to copy from + */ + private FloatingIP(FloatingIP floatingIP) { + this(floatingIP.id, floatingIP.routerId, floatingIP.tenantId, floatingIP.floatingNetworkId, + floatingIP.fixedIpAddress, floatingIP.floatingIpAddress, floatingIP.portId); + } + + /** + * @return the id of the floating IP + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return the router id of this floating IP + */ + @Nullable + public String getRouterId() { + return routerId; + } + + /** + * @return the tenant id of the Floating IP + */ + @Nullable + public String getTenantId() { + return tenantId; + } + + /** + * @return the floating network id for this floating IP + */ + @Nullable + public String getFloatingNetworkId() { + return floatingNetworkId; + } + + /** + * @return the fixed IP address for this floating IP + */ + @Nullable + public String getFixedIpAddress() { + return fixedIpAddress; + } + + /** + * @return the floating IP address for this floating IP + */ + @Nullable + public String getFloatingIpAddress() { + return floatingIpAddress; + } + + /** + * @return the port id for this floating IP + */ + @Nullable + public String getPortId() { + return portId; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + FloatingIP that = (FloatingIP) o; + + return Objects.equal(this.id, that.id) && + Objects.equal(this.routerId, that.routerId) && + Objects.equal(this.tenantId, that.tenantId) && + Objects.equal(this.floatingNetworkId, that.floatingNetworkId) && + Objects.equal(this.fixedIpAddress, that.fixedIpAddress) && + Objects.equal(this.floatingIpAddress, that.floatingIpAddress) && + Objects.equal(this.portId, that.portId); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, routerId, tenantId, floatingNetworkId, fixedIpAddress, floatingIpAddress, + portId); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("id", id) + .add("routerId", routerId) + .add("tenantId", tenantId) + .add("floatingNetworkId", floatingNetworkId) + .add("fixedIpAddress", fixedIpAddress) + .add("floatingIpAddress", floatingIpAddress) + .add("portId", portId) + .toString(); + } + + /** + * @return the Builder for creating a new floating IP + */ + public static CreateBuilder createBuilder(String floatingNetworkId) { + return new CreateBuilder(floatingNetworkId); + } + + /** + * @return the Builder for updating a floating IP + */ + public static UpdateBuilder updateBuilder() { + return new UpdateBuilder(); + } + + private abstract static class Builder<ParameterizedBuilderType> { + protected FloatingIP floatingIP; + + /** + * No-parameters constructor. + * */ + private Builder() { + floatingIP = new FloatingIP(); + } + + protected abstract ParameterizedBuilderType self(); + + /** + * Provide the tenantId for this Floating IP. Admin-only. + * When keystone is enabled, it is not mandatory to specify tenant_id for resources in create requests, as the + * tenant identifier will be derived from the Authentication token. Please note that the default authorization + * settings only allow administrative users to create resources on behalf of a different tenant. + * + * @return the Builder. + * @see FloatingIP#getTenantId() + */ + public ParameterizedBuilderType tenantId(String tenantId) { + floatingIP.tenantId = tenantId; + return self(); + } + + /** + * Provides the floating network id for this Floating IP. + * Mandatory when creating a floating IP. + * Floating IPs can only be created on external networks. If the network specified by floating_network_id is not + * external (for example, router:external=false), a 400 error is returned. + * + * @return the Builder. + * @see FloatingIP#getFloatingNetworkId() () + */ + public ParameterizedBuilderType floatingNetworkId(String floatingNetworkId) { + floatingIP.floatingNetworkId = floatingNetworkId; + return self(); + } + + /** + * Provides the fixed ip address for this Floating IP. + * As an OpenStack Networking port might be associated with multiple IP addresses, the particular IP address to + * associate with the floating IP can be specified using the fixed_ip_address request body parameter. The default + * logic of this operation is to associate the floating IP with a single IP address configured on a port; hence, + * if a port has multiple IP addresses, it is mandatory to specify the fixed_ip_address attribute. If an invalid + * IP address is specified in fixed_ip_address a 400 error will be returned. + * + * @return the Builder. + * @see FloatingIP#getFixedIpAddress() + */ + public ParameterizedBuilderType fixedIpAddress(String fixedIpAddress) { + floatingIP.fixedIpAddress = fixedIpAddress; + return self(); + } + + /** + * Provides the port id for this Floating IP. + * Users can associate the floating IP with an internal port using the port_id attribute in the request body. + * If an invalid port identifier is specified, a 404 error will be returned. The internal OpenStack Networking + * port associated with the Floating IP must have at least an IP address configured, otherwise a 400 error will + * be returned. + * + * @return the Builder. + * @see FloatingIP#getPortId() + */ + public ParameterizedBuilderType portId(String portId) { + floatingIP.portId = portId; + return self(); + } + } + + public static class CreateBuilder extends Builder<CreateBuilder> { + /** + * Supply required properties for creating a Builder + */ + private CreateBuilder(String floatingNetworkId) { + floatingIP.floatingNetworkId = floatingNetworkId; + } + + /** + * @return a CreateFloatingIP constructed with this Builder. + */ + public CreateFloatingIP build() { + return new CreateFloatingIP(floatingIP); + } + + protected CreateBuilder self() { + return this; + } + } + + public static class UpdateBuilder extends Builder<UpdateBuilder> { + /** + * Supply required properties for updating a Builder + */ + private UpdateBuilder() { + } + + /** + * Provide the floating ip address for this Floating IP. + * An address for the floating ip will be automatically allocated, unless the floating_ip_address attribute is + * specified in the request body. If the requested floating IP address does not fall in the external network's + * subnet range, a 400 error will be returned. If the requested floating IP address is already in use, a 409 + * error code will be returned. + * + * @return the Builder. + * @see FloatingIP#getFloatingIpAddress() + */ + public UpdateBuilder floatingIpAddress(String floatingIpAddress) { + floatingIP.floatingIpAddress = floatingIpAddress; + return this; + } + + /** + * @return a UpdateFloatingIP constructed with this Builder. + */ + public UpdateFloatingIP build() { + return new UpdateFloatingIP(floatingIP); + } + + protected UpdateBuilder self() { + return this; + } + } + + public static class CreateFloatingIP extends FloatingIP { + private CreateFloatingIP(FloatingIP floatingIP) { + super(floatingIP); + } + } + public static class UpdateFloatingIP extends FloatingIP { + private UpdateFloatingIP(FloatingIP floatingIP) { + super(floatingIP); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIPs.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIPs.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIPs.java new file mode 100644 index 0000000..8befa3e --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIPs.java @@ -0,0 +1,36 @@ +/* + * 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.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of Floating IPs + */ +public class FloatingIPs extends PaginatedCollection<FloatingIP> { + public static final FloatingIPs EMPTY = new FloatingIPs(ImmutableSet.<FloatingIP> of(), ImmutableSet.<Link> of()); + + @ConstructorProperties({"floatingips", "floatingips_links"}) + protected FloatingIPs(Iterable<FloatingIP> floatingIPs, Iterable<Link> floatingIPsLinks) { + super(floatingIPs, floatingIPsLinks); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/HostRoute.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/HostRoute.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/HostRoute.java new file mode 100644 index 0000000..6ff0ddc --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/HostRoute.java @@ -0,0 +1,123 @@ +/* + * 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.domain; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; + +/** + * A Neutron Subnet Host Route + * + * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api doc</a> + */ +public class HostRoute { + + @Named("destination") + private final String destinationCidr; + @Named("nexthop") + private final String nextHop; + + @ConstructorProperties({"destination", "nexthop"}) + protected HostRoute(String destinationCidr, String nextHop) { + this.destinationCidr = destinationCidr; + this.nextHop = nextHop; + } + + /** + * @return the destination CIDR for this route. + */ + @Nullable + public String getDestinationCidr() { + return destinationCidr; + } + + /** + * @return the IP of the next hop to forward traffic to. + */ + @Nullable + public String getNextHop() { + return nextHop; + } + + @Override + public int hashCode() { + return Objects.hashCode(destinationCidr, nextHop); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + HostRoute that = HostRoute.class.cast(obj); + return Objects.equal(this.destinationCidr, that.destinationCidr) && Objects.equal(this.nextHop, that.nextHop); + } + + protected ToStringHelper string() { + return Objects.toStringHelper(this) + .add("destinationCidr", destinationCidr).add("nextHop", nextHop); + } + + @Override + public String toString() { + return string().toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromHostRoute(this); + } + + public static class Builder { + protected String destinationCidr; + protected String nextHop; + + /** + * This should be a valid CIDR. + * @see HostRoute#getDestinationCidr() + */ + public Builder destinationCidr(String destinationCidr) { + this.destinationCidr = destinationCidr; + return this; + } + + /** + * This should be a valid IP address. + * @see HostRoute#getNextHop() + */ + public Builder nextHop(String nextHop) { + this.nextHop = nextHop; + return this; + } + + public HostRoute build() { + return new HostRoute(destinationCidr, nextHop); + } + + public Builder fromHostRoute(HostRoute in) { + return this.destinationCidr(in.getDestinationCidr()).nextHop(in.getNextHop()); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IP.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IP.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IP.java new file mode 100644 index 0000000..9c64604 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IP.java @@ -0,0 +1,135 @@ +/* + * 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.domain; + +import com.google.common.base.Objects; +import org.jclouds.javax.annotation.Nullable; + +import javax.inject.Named; +import java.beans.ConstructorProperties; + +/** + * Describes an IP address + */ +public class IP { + + @Named("ip_address") + protected final String ipAddress; + @Named("subnet_id") + protected final String subnetId; + + @ConstructorProperties({"ip_address", "subnet_id"}) + protected IP(String ipAddress, String subnetId) { + this.ipAddress = ipAddress; + this.subnetId = subnetId; + } + + /** + * @return the ipAddress of the IP + */ + @Nullable + public String getIpAddress() { + return ipAddress; + } + + /** + * @return the subnetId of the IP + */ + @Nullable + public String getSubnetId() { + return subnetId; + } + + @Override + public int hashCode() { + return Objects.hashCode(ipAddress, subnetId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + IP that = IP.class.cast(obj); + return Objects.equal(this.ipAddress, that.ipAddress) && Objects.equal(this.subnetId, that.subnetId); + } + + protected Objects.ToStringHelper string() { + return Objects.toStringHelper(this).add("ipAddress", ipAddress).add("subnetId", subnetId); + } + + @Override + public String toString() { + return string().toString(); + } + + /** + * @return the Builder for IP + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Gets a Builder configured as this object. + */ + public Builder toBuilder() { + return new Builder().fromIP(this); + } + + public static class Builder { + protected String ipAddress; + protected String subnetId; + + /** + * Provide the ipAddress to the IP's Builder. + * + * @return the Builder. + * @see IP#getIpAddress() + */ + public Builder ipAddress(String ipAddress) { + this.ipAddress = ipAddress; + return this; + } + + /** + * Provide the subnetId to the IP's Builder. + * + * @return the Builder. + * @see IP#getSubnetId() + */ + public Builder subnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + /** + * @return a IP constructed with this Builder. + */ + public IP build() { + return new IP(ipAddress, subnetId); + } + + /** + * @return a Builder from another IP. + */ + public Builder fromIP(IP in) { + return this.ipAddress(in.getIpAddress()).subnetId(in.getSubnetId()); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IPv6DHCPMode.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IPv6DHCPMode.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IPv6DHCPMode.java new file mode 100644 index 0000000..654e053 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IPv6DHCPMode.java @@ -0,0 +1,57 @@ +/* + * 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.domain; + +/** + * Enumerates DHCP modes for UPv6 + */ +public enum IPv6DHCPMode { + OFF("off"), + SLAAC("slaac"), + DHCPV6_STATEFUL("dhcpv6-stateful"), + DHCPV6_STATELESS("dhcpv6-stateless"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private String name; + + private IPv6DHCPMode(String name) { + this.name = name; + } + + public String toString() { + return name; + } + + /* + * This provides GSON enum support in jclouds. + * */ + public static IPv6DHCPMode fromValue(String name){ + if (name != null) { + for (IPv6DHCPMode value : IPv6DHCPMode.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Network.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Network.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Network.java new file mode 100644 index 0000000..ac40019 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Network.java @@ -0,0 +1,646 @@ +/* + * 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.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * A Neutron network + * + * @see <a + * href="http://docs.openstack.org/api/openstack-network/2.0/content/Networks.html">api + * doc</a> + */ +public class Network { + + private String id; + private NetworkStatus status; + private ImmutableSet<String> subnets; + + private String name; + @Named("admin_state_up") + private Boolean adminStateUp; + private Boolean shared; + @Named("tenant_id") + private String tenantId; + + // providernet.py: Provider Networks Extension + @Named("provider:network_type") + private NetworkType networkType; + @Named("provider:physical_network") + private String physicalNetworkName; + @Named("provider:segmentation_id") + private Integer segmentationId; + + // external_net.py: Configurable external gateway modes extension + @Named("router:external") + private Boolean external; + + // portsecurity.py: VMWare port security + @Named("port_security_enabled") + private Boolean portSecurity; + + // n1kv.py: Cisco plugin extension; admin rights might be needed + @Named("n1kv:profile_id") + // UUID + private String profileId; + @Named("n1kv:multicast_ip") + private String multicastIp; + @Named("n1kv:segment_add") + private String segmentAdd; + @Named("n1kv:segment_del") + private String segmentDel; + @Named("n1kv:member_segments") + private String memberSegments; + + // multiprovidernet.py: Multiprovider net extension; Segments and provider + // values cannot both be set. + private ImmutableSet<NetworkSegment> segments; + + // flavor.py: Flavor support for network and router + @Named("flavor:network") + private String networkFlavor; + + @ConstructorProperties({"id", "status", "subnets", "name", "admin_state_up", "shared", "tenant_id", + "provider:network_type", "provider:physical_network", "provider:segmentation_id", "router:external", + "port_security_enabled", "n1kv:profile_id", "n1kv:multicast_ip", "n1kv:segment_add", "n1kv:segment_del", + "n1kv:member_segments", "segments", "flavor:network"}) + private Network(String id, NetworkStatus status, ImmutableSet<String> subnets, String name, Boolean adminStateUp, + Boolean shared, String tenantId, NetworkType networkType, String physicalNetworkName, Integer segmentationId, + Boolean external, Boolean portSecurity, String profileId, String multicastIp, String segmentAdd, + String segmentDel, String memberSegments, ImmutableSet<NetworkSegment> segments, String networkFlavor) { + // No checkNotNulls. With Neutron, any of these properties can be left null when used in an update. + this.id = id; + this.status = status; + this.subnets = subnets; + this.name = name; + this.adminStateUp = adminStateUp; + this.shared = shared; + this.tenantId = tenantId; + this.networkType = networkType; + this.physicalNetworkName = physicalNetworkName; + this.segmentationId = segmentationId; + this.external = external; + this.portSecurity = portSecurity; + this.profileId = profileId; + this.multicastIp = multicastIp; + this.segmentAdd = segmentAdd; + this.segmentDel = segmentDel; + this.memberSegments = memberSegments; + this.segments = segments; + this.networkFlavor = networkFlavor; + } + + /** + * Default constructor. + */ + private Network() {} + + /** + * Copy constructor + * @param network + */ + private Network(Network network) { + this(network.id, + network.status, + network.subnets, + network.name, + network.adminStateUp, + network.shared, + network.tenantId, + network.networkType, + network.physicalNetworkName, + network.segmentationId, + network.external, + network.portSecurity, + network.profileId, + network.multicastIp, + network.segmentAdd, + network.segmentDel, + network.memberSegments, + network.segments, + network.networkFlavor); + } + + /** + * @return the id of the Network + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return the status of the Network + */ + @Nullable + public NetworkStatus getStatus() { + return status; + } + + /** + * @return the subnets of the Network + */ + @Nullable + public ImmutableSet<String> getSubnets() { + return subnets; + } + + /** + * @return the name of the Network + */ + @Nullable + public String getName() { + return name; + } + + /** + * @return the adminStateUp of the Network + */ + @Nullable + public Boolean getAdminStateUp() { + return adminStateUp; + } + + /** + * The shared attribute can be used to create a public network, i.e.: a network which is shared with all other tenants. + * Control of the shared attribute could be reserved to particular users only, such as administrators. + * In this case, regular users trying to create a shared network will receive a 403 - Forbidden error. + * @return true if the network resource can be accessed by any tenant or not, false if not + */ + @Nullable + public Boolean getShared() { + return shared; + } + + /** + * @return the tenantId of the Network + */ + @Nullable + public String getTenantId() { + return tenantId; + } + + /** + * @return the networkType of the Network + */ + @Nullable + public NetworkType getNetworkType() { + return networkType; + } + + /** + * @return the physicalNetworkName of the Network + */ + @Nullable + public String getPhysicalNetworkName() { + return physicalNetworkName; + } + + /** + * @return the segmentationId of the Network + */ + @Nullable + public Integer getSegmentationId() { + return segmentationId; + } + + /** + * Adds external network attribute to network resource. + * @return the external of the Network + */ + @Nullable + public Boolean getExternal() { + return external; + } + + /** + * @return the portSecurity of the Network + */ + @Nullable + public Boolean getPortSecurity() { + return portSecurity; + } + + /** + * @return the profileId of the Network + */ + @Nullable + public String getProfileId() { + return profileId; + } + + /** + * @return the multicastIp of the Network + */ + @Nullable + public String getMulticastIp() { + return multicastIp; + } + + /** + * @return the segmentAdd of the Network + */ + @Nullable + public String getSegmentAdd() { + return segmentAdd; + } + + /** + * @return the segmentDel of the Network + */ + @Nullable + public String getSegmentDel() { + return segmentDel; + } + + /** + * @return the memberSegments of the Network + */ + @Nullable + public String getMemberSegments() { + return memberSegments; + } + + /** + * @return the segments of the Network + */ + @Nullable + public ImmutableSet<NetworkSegment> getSegments() { + return segments; + } + + /** + * @return the networkFlavor of the Network + */ + @Nullable + public String getNetworkFlavor() { + return networkFlavor; + } + + @Override + public int hashCode() { + return Objects.hashCode(id, status, subnets, name, adminStateUp, shared, tenantId, networkType, + physicalNetworkName, segmentationId, external, portSecurity, profileId, multicastIp, segmentAdd, segmentDel, + memberSegments, segments, networkFlavor); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + Network that = Network.class.cast(obj); + return Objects.equal(this.id, that.id) + && Objects.equal(this.status, that.status) + && Objects.equal(this.subnets, that.subnets) + && Objects.equal(this.name, that.name) + && Objects.equal(this.adminStateUp, that.adminStateUp) + && Objects.equal(this.shared, that.shared) + && Objects.equal(this.tenantId, that.tenantId) + && Objects.equal(this.networkType, that.networkType) + && Objects.equal(this.physicalNetworkName, that.physicalNetworkName) + && Objects.equal(this.segmentationId, that.segmentationId) + && Objects.equal(this.external, that.external) + && Objects.equal(this.portSecurity, that.portSecurity) + && Objects.equal(this.profileId, that.profileId) + && Objects.equal(this.multicastIp, that.multicastIp) + && Objects.equal(this.segmentAdd, that.segmentAdd) + && Objects.equal(this.segmentDel, that.segmentDel) + && Objects.equal(this.memberSegments, that.memberSegments) + && Objects.equal(this.segments, that.segments) + && Objects.equal(this.networkFlavor, that.networkFlavor); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("id", id) + .add("status", status) + .add("subnets", subnets) + .add("name", name) + .add("adminStateUp", adminStateUp) + .add("shared", shared) + .add("tenantId", tenantId) + .add("networkType", networkType) + .add("physicalNetworkName", physicalNetworkName) + .add("segmentationId", segmentationId) + .add("external", external) + .add("portSecurity", portSecurity) + .add("profileId", profileId) + .add("multicastIp", multicastIp) + .add("segmentAdd", segmentAdd) + .add("segmentDel", segmentDel) + .add("memberSegments", memberSegments) + .add("segments", segments) + .add("networkFlavor", networkFlavor) + .toString(); + } + + /* + * Methods to get the Create and Update builders follow + */ + + /** + * @return the Builder for creating a new Router + */ + public static CreateBuilder createBuilder(String name) { + return new CreateBuilder(name); + } + + /** + * @return the Builder for updating a Router + */ + public static UpdateBuilder updateBuilder() { + return new UpdateBuilder(); + } + + private abstract static class Builder<ParameterizedBuilderType> { + protected Network network; + + /** + * No-parameters constructor used when updating. + * */ + private Builder() { + network = new Network(); + } + + protected abstract ParameterizedBuilderType self(); + + /** + * Provide the name to the Network's Builder. + * + * @return the Builder. + * @see Network#getName() + */ + public ParameterizedBuilderType name(String name) { + network.name = name; + return self(); + } + + /** + * Provide the adminStateUp to the Network's Builder. + * + * @return the Builder. + * @see Network#isAdminStateUp() + */ + public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) { + network.adminStateUp = adminStateUp; + return self(); + } + + /** + * Provide the shared to the Network's Builder. + * + * @return the Builder. + * @see Network#isShared() + */ + public ParameterizedBuilderType shared(Boolean shared) { + network.shared = shared; + return self(); + } + + /** + * Provide the tenantId to the Network's Builder. + * + * @return the Builder. + * @see Network#getTenantId() + */ + public ParameterizedBuilderType tenantId(String tenantId) { + network.tenantId = tenantId; + return self(); + } + + /** + * Provide the networkType to the Network's Builder. + * + * @return the Builder. + * @see Network#getNetworkType() + */ + public ParameterizedBuilderType networkType(NetworkType networkType) { + network.networkType = networkType; + return self(); + } + + /** + * Provide the physicalNetworkName to the Network's Builder. + * + * @return the Builder. + * @see Network#getPhysicalNetworkName() + */ + public ParameterizedBuilderType physicalNetworkName(String physicalNetworkName) { + network.physicalNetworkName = physicalNetworkName; + return self(); + } + + /** + * Provide the segmentationId to the Network's Builder. + * + * @return the Builder. + * @see Network#getSegmentationId() + */ + public ParameterizedBuilderType segmentationId(Integer segmentationId) { + network.segmentationId = segmentationId; + return self(); + } + + /** + * Adds external network attribute to network resource. + * + * @return the Builder. + * @see Network#isExternal() + */ + public ParameterizedBuilderType external(Boolean external) { + network.external = external; + return self(); + } + + /** + * Provide the portSecurity to the Network's Builder. + * + * @return the Builder. + * @see Network#isPortSecurity() + */ + public ParameterizedBuilderType portSecurity(Boolean portSecurity) { + network.portSecurity = portSecurity; + return self(); + } + + /** + * Provide the profileId to the Network's Builder. + * + * @return the Builder. + * @see Network#getProfileId() + */ + public ParameterizedBuilderType profileId(String profileId) { + network.profileId = profileId; + return self(); + } + + /** + * Provide the multicastIp to the Network's Builder. + * + * @return the Builder. + * @see Network#getMulticastIp() + */ + public ParameterizedBuilderType multicastIp(String multicastIp) { + network.multicastIp = multicastIp; + return self(); + } + + /** + * Provide the segmentAdd to the Network's Builder. + * Cisco plugin extension; admin right might be needed to use this. + * + * @return the Builder. + * @see Network#getSegmentAdd() + */ + public ParameterizedBuilderType segmentAdd(String segmentAdd) { + network.segmentAdd = segmentAdd; + return self(); + } + + /** + * Provide the segmentDel to the Network's Builder. + * Cisco plugin extension; admin right might be needed to use this. + * + * @return the Builder. + * @see Network#getSegmentDel() + */ + public ParameterizedBuilderType segmentDel(String segmentDel) { + network.segmentDel = segmentDel; + return self(); + } + + /** + * Provide the memberSegments to the Network's Builder. + * Cisco plugin extension; admin right might be needed to use this. + * + * @return the Builder. + * @see Network#getMemberSegments() + */ + public ParameterizedBuilderType memberSegments(String memberSegments) { + network.memberSegments = memberSegments; + return self(); + } + + /** + * Provide the segments to the Network's Builder. + * Multiprovider extension. + * + * @return the Builder. + * @see Network#getSegments() + */ + public ParameterizedBuilderType segments(ImmutableSet<NetworkSegment> segments) { + network.segments = segments; + return self(); + } + + /** + * Provide the networkFlavor to the Network's Builder. + * + * @return the Builder. + * @see Network#getNetworkFlavor() + */ + public ParameterizedBuilderType networkFlavor(String networkFlavor) { + network.networkFlavor = networkFlavor; + return self(); + } + } + + /** + * Create and Update builders (inheriting from Builder) + */ + public static class CreateBuilder extends Builder<CreateBuilder> { + /** + * Supply required properties for creating a Builder + */ + private CreateBuilder(String name) { + network.name = name; + } + + /** + * @return a CreateNetwork constructed with this Builder. + */ + public CreateNetwork build() { + return new CreateNetwork(network); + } + + protected CreateBuilder self() { + return this; + } + } + + /** + * Create and Update builders (inheriting from Builder) + */ + public static class UpdateBuilder extends Builder<UpdateBuilder> { + /** + * Supply required properties for updating a Builder + */ + private UpdateBuilder() { + } + + /** + * @return a UpdateNetwork constructed with this Builder. + */ + public UpdateNetwork build() { + return new UpdateNetwork(network); + } + + protected UpdateBuilder self() { + return this; + } + } + + /** + * Create and Update options - extend the domain class, passed to API update and create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class CreateNetwork extends Network { + /** + * Copy constructor + */ + private CreateNetwork(Network network) { + super(network); + checkNotNull(network.name, "name should not be null"); + } + } + + /** + * Create and Update options - extend the domain class, passed to API update and create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class UpdateNetwork extends Network { + /** + * Copy constructor + */ + private UpdateNetwork(Network network) { + super(network); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkSegment.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkSegment.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkSegment.java new file mode 100644 index 0000000..aacd5c1 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkSegment.java @@ -0,0 +1,167 @@ +/* + * 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.domain; + +import com.google.common.base.Objects; +import org.jclouds.javax.annotation.Nullable; + +import javax.inject.Named; +import java.beans.ConstructorProperties; + +/** + * A Neutron Network Segment + * Segments and provider values cannot both be set. + * + * @see <a + * href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api + * doc</a> + */ +public class NetworkSegment { + + @Named("provider:network_type") + protected final NetworkType networkType; + @Named("provider:physical_network") + protected final String physicalNetwork; + @Named("provider:segmentation_id") + protected final Integer segmentationId; + + @ConstructorProperties({"provider:network_type", "provider:physical_network", "provider:segmentation_id"}) + protected NetworkSegment(NetworkType networkType, String physicalNetwork, Integer segmentationId) { + this.networkType = networkType; + this.physicalNetwork = physicalNetwork; + this.segmentationId = segmentationId; + } + + /** + * @return the networkType of the NetworkSegment + */ + @Nullable + public NetworkType getNetworkType() { + return networkType; + } + + /** + * @return the physicalNetwork of the NetworkSegment + */ + @Nullable + public String getPhysicalNetwork() { + return physicalNetwork; + } + + /** + * @return the segmentationId of the NetworkSegment + */ + @Nullable + public Integer getSegmentationId() { + return segmentationId; + } + + @Override + public int hashCode() { + return Objects.hashCode(networkType, physicalNetwork, segmentationId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + NetworkSegment that = NetworkSegment.class.cast(obj); + return Objects.equal(this.networkType, that.networkType) + && Objects.equal(this.physicalNetwork, that.physicalNetwork) + && Objects.equal(this.segmentationId, that.segmentationId); + } + + protected Objects.ToStringHelper string() { + return Objects.toStringHelper(this).add("networkType", networkType).add("physicalNetwork", physicalNetwork) + .add("segmentationId", segmentationId); + } + + @Override + public String toString() { + return string().toString(); + } + + /** + * @return the Builder for NetworkSegment + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Gets a Builder configured as this object. + */ + public Builder toBuilder() { + return new Builder().fromNetworkSegment(this); + } + + public static class Builder { + protected NetworkType networkType; + protected String physicalNetwork; + protected Integer segmentationId; + + /** + * Provide the networkType to the NetworkSegment's Builder. + * + * @return the Builder. + * @see NetworkSegment#getNetworkType() + */ + public Builder networkType(NetworkType networkType) { + this.networkType = networkType; + return this; + } + + /** + * Provide the physicalNetwork to the NetworkSegment's Builder. + * + * @return the Builder. + * @see NetworkSegment#getPhysicalNetwork() + */ + public Builder physicalNetwork(String physicalNetwork) { + this.physicalNetwork = physicalNetwork; + return this; + } + + /** + * Provide the segmentationId to the NetworkSegment's Builder. + * + * @return the Builder. + * @see NetworkSegment#getSegmentationId() + */ + public Builder segmentationId(int segmentationId) { + this.segmentationId = segmentationId; + return this; + } + + /** + * @return a NetworkSegment constructed with this Builder. + */ + public NetworkSegment build() { + return new NetworkSegment(networkType, physicalNetwork, segmentationId); + } + + /** + * @return a Builder from another NetworkSegment. + */ + public Builder fromNetworkSegment(NetworkSegment in) { + return this.networkType(in.getNetworkType()).physicalNetwork(in.getPhysicalNetwork()) + .segmentationId(in.getSegmentationId()); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkStatus.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkStatus.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkStatus.java new file mode 100644 index 0000000..04334d0 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkStatus.java @@ -0,0 +1,60 @@ +/* + * 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.domain; + +/** + * Enumerates Network Status. + */ +public enum NetworkStatus { + ACTIVE("active"), + DOWN("down"), + BUILD("build"), + ERROR("error"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private final String name; + + private NetworkStatus(String name) { + this.name = name; + } + + @Override + public String toString() { + return name(); + } + + /* + * This provides GSON enum support in jclouds. + * @param name The string representation of this enum value. + * @return The corresponding enum value. + */ + public static NetworkStatus fromValue(String name) { + if (name != null) { + for (NetworkStatus value : NetworkStatus.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkType.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkType.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkType.java new file mode 100644 index 0000000..89c3e9a --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkType.java @@ -0,0 +1,81 @@ +/* + * 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.domain; + +/** + * Enumerates supported Network types. + */ +public enum NetworkType { + /** + * Used to describe a local network. + */ + LOCAL("local"), + /** + * Used to describe a flat network. + */ + FLAT("flat"), + /** + * Used to describe a VLAN network. NetworkSegment might have to be set. + */ + VLAN("vlan"), + /** + * Used to describe a Virtual Extensible LAN (VXLAN) network. + * It uses a VLAN-like encapsulation technique to encapsulate MAC-based + * OSI layer 2 Ethernet frames within layer 4 UDP packets. + */ + VXLAN("vxlan"), + /** + * Used to describe a GRE tunnel network. A virtual network realized as + * packets encapsulated using Generic Routing Encapsulation. GRE tunnel + * packets are routed by the compute node hosts, so GRE tunnels are not + * associated by the openvswitch plugin with specific physical networks. + */ + GRE("gre"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private String name; + + private NetworkType(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + + /* + * This provides GSON enum support in jclouds. + * @param name The string representation of this enum value. + * @return The corresponding enum value. + */ + public static NetworkType fromValue(String name) { + if (name != null) { + for (NetworkType value : NetworkType.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Networks.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Networks.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Networks.java new file mode 100644 index 0000000..9b3bf10 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Networks.java @@ -0,0 +1,36 @@ +/* + * 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.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of Networks + */ +public class Networks extends PaginatedCollection<Network> { + public static final Networks EMPTY = new Networks(ImmutableSet.<Network> of(), ImmutableSet.<Link> of()); + + @ConstructorProperties({"networks", "networks_links"}) + protected Networks(Iterable<Network> networks, Iterable<Link> networksLinks) { + super(networks, networksLinks); + } +}
