You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/03/31 09:14:01 UTC
[48/52] [partial] Moving jclouds dependencies to accurate parent
directories
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java
new file mode 100644
index 0000000..b85dfd4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java
@@ -0,0 +1,649 @@
+/*
+ * 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.nova.v2_0.compute.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Strings.emptyToNull;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.openstack.nova.v2_0.domain.Network;
+import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
+import org.jclouds.scriptbuilder.domain.Statement;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Contains options supported in the {@code ComputeService#runNode} operation on the
+ * "openstack-nova" provider. <h2>Usage</h2> The recommended way to instantiate a
+ * NovaTemplateOptions object is to statically import NovaTemplateOptions.* and invoke a static
+ * creation method followed by an instance mutator (if needed):
+ * <p/>
+ * <code>
+ * import static org.jclouds.aws.ec2.compute.options.NovaTemplateOptions.Builder.*;
+ * <p/>
+ * ComputeService api = // get connection
+ * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
+ * Set<? extends NodeMetadata> set = api.createNodesInGroup(tag, 2, templateBuilder.build());
+ * <code>
+ *
+ * @author Adam Lowe
+ */
+public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
+ @Override
+ public NovaTemplateOptions clone() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ copyTo(options);
+ return options;
+ }
+
+ @Override
+ public void copyTo(TemplateOptions to) {
+ super.copyTo(to);
+ if (to instanceof NovaTemplateOptions) {
+ NovaTemplateOptions eTo = NovaTemplateOptions.class.cast(to);
+ eTo.autoAssignFloatingIp(shouldAutoAssignFloatingIp());
+ if (getSecurityGroupNames().isPresent())
+ eTo.securityGroupNames(getSecurityGroupNames().get());
+ eTo.generateKeyPair(shouldGenerateKeyPair());
+ eTo.keyPairName(getKeyPairName());
+ eTo.availabilityZone(getAvailabilityZone());
+ if (getUserData() != null) {
+ eTo.userData(getUserData());
+ }
+ if (getDiskConfig() != null) {
+ eTo.diskConfig(getDiskConfig());
+ }
+
+ eTo.configDrive(getConfigDrive());
+ eTo.novaNetworks(getNovaNetworks());
+ }
+ }
+
+ protected boolean autoAssignFloatingIp = false;
+ protected Optional<Set<String>> securityGroupNames = Optional.absent();
+ protected boolean generateKeyPair = false;
+ protected String keyPairName;
+ protected byte[] userData;
+ protected String diskConfig;
+ protected boolean configDrive;
+ protected String availabilityZone;
+ protected Set<Network> novaNetworks;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ NovaTemplateOptions that = NovaTemplateOptions.class.cast(o);
+ return super.equals(that) && equal(this.autoAssignFloatingIp, that.autoAssignFloatingIp)
+ && equal(this.securityGroupNames, that.securityGroupNames)
+ && equal(this.generateKeyPair, that.generateKeyPair)
+ && equal(this.keyPairName, that.keyPairName)
+ && Arrays.equals(this.userData, that.userData)
+ && equal(this.diskConfig, that.diskConfig)
+ && equal(this.configDrive, that.configDrive)
+ && equal(this.availabilityZone, that.availabilityZone)
+ && equal(this.novaNetworks, that.novaNetworks);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), autoAssignFloatingIp, securityGroupNames, generateKeyPair, keyPairName, userData, diskConfig, configDrive,availabilityZone, novaNetworks);
+ }
+
+ @Override
+ public ToStringHelper string() {
+ ToStringHelper toString = super.string();
+ if (!autoAssignFloatingIp)
+ toString.add("autoAssignFloatingIp", autoAssignFloatingIp);
+ if (securityGroupNames.isPresent())
+ toString.add("securityGroupNames", securityGroupNames.get());
+ if (generateKeyPair)
+ toString.add("generateKeyPair", generateKeyPair);
+ toString.add("keyPairName", keyPairName);
+ toString.add("userData", userData);
+ toString.add("diskConfig", diskConfig);
+ toString.add("configDrive", configDrive);
+ toString.add("availabilityZone", availabilityZone);
+ toString.add("novaNetworks", novaNetworks);
+ return toString;
+ }
+
+ public static final NovaTemplateOptions NONE = new NovaTemplateOptions();
+
+ /**
+ * @see #shouldAutoAssignFloatingIp()
+ */
+ public NovaTemplateOptions autoAssignFloatingIp(boolean enable) {
+ this.autoAssignFloatingIp = enable;
+ return this;
+ }
+
+ /**
+ * @see #shouldGenerateKeyPair()
+ */
+ public NovaTemplateOptions generateKeyPair(boolean enable) {
+ this.generateKeyPair = enable;
+ return this;
+ }
+
+ /**
+ * @see #shouldGenerateKeyPair()
+ */
+ public NovaTemplateOptions keyPairName(String keyPairName) {
+ this.keyPairName = keyPairName;
+ return this;
+ }
+
+ /**
+ * set availability zone
+ */
+ public NovaTemplateOptions availabilityZone(String zone) {
+ this.availabilityZone = zone;
+ return this;
+ }
+
+
+ /**
+ *
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
+ */
+ public NovaTemplateOptions securityGroupNames(String... securityGroupNames) {
+ return securityGroupNames(ImmutableSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames")));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
+ */
+ public NovaTemplateOptions securityGroupNames(Iterable<String> securityGroupNames) {
+ for (String groupName : checkNotNull(securityGroupNames, "securityGroupNames"))
+ checkNotNull(emptyToNull(groupName), "all security groups must be non-empty");
+ this.securityGroupNames = Optional.<Set<String>> of(ImmutableSet.copyOf(securityGroupNames));
+ return this;
+ }
+
+ /**
+ * <h3>Note</h3>
+ *
+ * This requires that {@link NovaApi#getExtensionForZone(String)} to return
+ * {@link Optional#isPresent present}
+ *
+ * @return true if auto assignment of a floating ip to each vm is enabled
+ */
+ public boolean shouldAutoAssignFloatingIp() {
+ return autoAssignFloatingIp;
+ }
+
+ /**
+ * Specifies the keypair used to run instances with
+ * @return the keypair to be used
+ */
+ public String getKeyPairName() {
+ return keyPairName;
+ }
+
+ /**
+ * Specifies the availability zone used to run instances with
+ * @return the availability zone to be used
+ */
+ public String getAvailabilityZone() {
+ return availabilityZone;
+ }
+
+
+ /**
+ * <h3>Note</h3>
+ *
+ * This requires that {@link NovaApi#getKeyPairExtensionForZone(String)} to return
+ * {@link Optional#isPresent present}
+ *
+ * @return true if auto generation of keypairs is enabled
+ */
+ public boolean shouldGenerateKeyPair() {
+ return generateKeyPair;
+ }
+
+ /**
+ * if unset, generate a default group prefixed with {@link jclouds#} according
+ * to {@link #getInboundPorts()}
+ *
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
+ */
+ public Optional<Set<String>> getSecurityGroupNames() {
+ return securityGroupNames;
+ }
+
+ public byte[] getUserData() {
+ return userData;
+ }
+
+ /**
+ * @see CreateServerOptions#getDiskConfig()
+ */
+ public String getDiskConfig() {
+ return diskConfig;
+ }
+
+ /**
+ * @see CreateServerOptions#getConfigDrive()
+ */
+ public boolean getConfigDrive() {
+ return configDrive;
+ }
+
+ /**
+ * @see CreateServerOptions#getNetworks()
+ */
+ public Set<Network> getNovaNetworks() {
+ return novaNetworks;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see NovaTemplateOptions#shouldAutoAssignFloatingIp()
+ */
+ public static NovaTemplateOptions autoAssignFloatingIp(boolean enable) {
+ return new NovaTemplateOptions().autoAssignFloatingIp(enable);
+ }
+
+ /**
+ * @see NovaTemplateOptions#shouldGenerateKeyPair()
+ */
+ public static NovaTemplateOptions generateKeyPair(boolean enable) {
+ return new NovaTemplateOptions().generateKeyPair(enable);
+ }
+
+ /**
+ * @see NovaTemplateOptions#getKeyPairName()
+ */
+ public static NovaTemplateOptions keyPairName(String keyPairName) {
+ return new NovaTemplateOptions().keyPairName(keyPairName);
+ }
+
+ /**
+ * @see NovaTemplateOptions#getAvailabilityZone()
+ */
+ public static NovaTemplateOptions availabilityZone(String zone) {
+ return new NovaTemplateOptions().availabilityZone(zone);
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
+ */
+ public static NovaTemplateOptions securityGroupNames(String... groupNames) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.securityGroupNames(groupNames));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
+ */
+ public static NovaTemplateOptions securityGroupNames(Iterable<String> groupNames) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.securityGroupNames(groupNames));
+ }
+
+ // methods that only facilitate returning the correct object type
+
+ /**
+ * @see TemplateOptions#inboundPorts
+ */
+ public static NovaTemplateOptions inboundPorts(int... ports) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.inboundPorts(ports));
+ }
+
+ /**
+ * @see TemplateOptions#port
+ */
+ public static NovaTemplateOptions blockOnPort(int port, int seconds) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.blockOnPort(port, seconds));
+ }
+
+ /**
+ * @see TemplateOptions#installPrivateKey
+ */
+ public static NovaTemplateOptions installPrivateKey(String rsaKey) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.installPrivateKey(rsaKey));
+ }
+
+ /**
+ * @see TemplateOptions#authorizePublicKey
+ */
+ public static NovaTemplateOptions authorizePublicKey(String rsaKey) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.authorizePublicKey(rsaKey));
+ }
+
+ /**
+ * @see TemplateOptions#userMetadata
+ */
+ public static NovaTemplateOptions userMetadata(Map<String, String> userMetadata) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.userMetadata(userMetadata));
+ }
+
+ /**
+ * @see TemplateOptions#nodeNames(Iterable)
+ */
+ public static NovaTemplateOptions nodeNames(Iterable<String> nodeNames) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.nodeNames(nodeNames));
+ }
+
+ /**
+ * @see TemplateOptions#networks(Iterable)
+ */
+ public static NovaTemplateOptions networks(Iterable<String> networks) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.networks(networks));
+ }
+
+ /**
+ * @see TemplateOptions#overrideLoginUser
+ */
+ public static NovaTemplateOptions overrideLoginUser(String user) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.overrideLoginUser(user);
+ }
+
+ /**
+ * @see TemplateOptions#overrideLoginPassword
+ */
+ public static NovaTemplateOptions overrideLoginPassword(String password) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.overrideLoginPassword(password);
+ }
+
+ /**
+ * @see TemplateOptions#overrideLoginPrivateKey
+ */
+ public static NovaTemplateOptions overrideLoginPrivateKey(String privateKey) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.overrideLoginPrivateKey(privateKey);
+ }
+
+ /**
+ * @see TemplateOptions#overrideAuthenticateSudo
+ */
+ public static NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.overrideAuthenticateSudo(authenticateSudo);
+ }
+
+ /**
+ * @see TemplateOptions#overrideLoginCredentials
+ */
+ public static NovaTemplateOptions overrideLoginCredentials(LoginCredentials credentials) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.overrideLoginCredentials(credentials);
+ }
+
+ /**
+ * @see TemplateOptions#blockUntilRunning
+ */
+ public static NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.blockUntilRunning(blockUntilRunning);
+ }
+
+ /**
+ * @see NovaTemplateOptions#userData
+ */
+ public static NovaTemplateOptions userData(byte[] userData) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.userData(userData));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getDiskConfig()
+ */
+ public static NovaTemplateOptions diskConfig(String diskConfig) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.diskConfig(diskConfig));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getConfigDrive()
+ */
+ public static NovaTemplateOptions configDrive(boolean configDrive) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.configDrive(configDrive));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getNetworks()
+ */
+ public static NovaTemplateOptions novaNetworks(Set<Network> novaNetworks) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.novaNetworks(novaNetworks));
+ }
+ }
+
+ // methods that only facilitate returning the correct object type
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions blockOnPort(int port, int seconds) {
+ return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions inboundPorts(int... ports) {
+ return NovaTemplateOptions.class.cast(super.inboundPorts(ports));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions authorizePublicKey(String publicKey) {
+ return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions installPrivateKey(String privateKey) {
+ return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning) {
+ return NovaTemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions dontAuthorizePublicKey() {
+ return NovaTemplateOptions.class.cast(super.dontAuthorizePublicKey());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions nameTask(String name) {
+ return NovaTemplateOptions.class.cast(super.nameTask(name));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions runAsRoot(boolean runAsRoot) {
+ return NovaTemplateOptions.class.cast(super.runAsRoot(runAsRoot));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions runScript(Statement script) {
+ return NovaTemplateOptions.class.cast(super.runScript(script));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) {
+ return NovaTemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions overrideLoginPassword(String password) {
+ return NovaTemplateOptions.class.cast(super.overrideLoginPassword(password));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions overrideLoginPrivateKey(String privateKey) {
+ return NovaTemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions overrideLoginUser(String loginUser) {
+ return NovaTemplateOptions.class.cast(super.overrideLoginUser(loginUser));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
+ return NovaTemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions userMetadata(Map<String, String> userMetadata) {
+ return NovaTemplateOptions.class.cast(super.userMetadata(userMetadata));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions userMetadata(String key, String value) {
+ return NovaTemplateOptions.class.cast(super.userMetadata(key, value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions nodeNames(Iterable<String> nodeNames) {
+ return NovaTemplateOptions.class.cast(super.nodeNames(nodeNames));
+ }
+
+ /**
+ * <br>Ensures NovaTemplateOptions can work with networks specified as Strings.
+ * Also provides for compatibility with the abstraction layer.
+ */
+ @Override
+ public NovaTemplateOptions networks(Iterable<String> networks) {
+ return NovaTemplateOptions.class.cast(super.networks(networks));
+ }
+
+ /**
+ * <br>Ensures NovaTemplateOptions can work with networks specified as Strings.
+ * Also provides for compatibility with the abstraction layer.
+ */
+ @Override
+ public NovaTemplateOptions networks(String... networks) {
+ return NovaTemplateOptions.class.cast(super.networks(networks));
+ }
+
+ /**
+ * User data as bytes (not base64-encoded)
+ */
+ public NovaTemplateOptions userData(byte[] userData) {
+ // This limit may not be needed for nova
+ checkArgument(checkNotNull(userData, "userData").length <= 16 * 1024,
+ "userData cannot be larger than 16kb");
+ this.userData = userData;
+ return this;
+ }
+
+ /**
+ * @see CreateServerOptions#getDiskConfig()
+ */
+ public NovaTemplateOptions diskConfig(String diskConfig) {
+ this.diskConfig = diskConfig;
+ return this;
+ }
+
+ /**
+ * OpenStack can be configured to write metadata to a special configuration drive that will be
+ * attached to the instance when it boots. The instance can retrieve any information that would
+ * normally be available through the metadata service by mounting this disk and reading files from it.
+ * To enable the config drive, set this parameter to "true".
+ * This has to be enabled for user data cases.
+ * @see CreateServerOptions#getConfigDrive()
+ */
+ public NovaTemplateOptions configDrive(boolean configDrive) {
+ this.configDrive = configDrive;
+ return this;
+ }
+
+ /**
+ * @param novaNetworks The list of network declarations.
+ * Nova-specific network declarations allow for specifying network UUIDs, port UUIDs, and fixed IPs.
+ * Unline {@link #networks(Iterable)} this supports setting additional network parameters and not just network UUIDs.
+ * @see CreateServerOptions#getNetworks()
+ */
+ public NovaTemplateOptions novaNetworks(Set<Network> novaNetworks) {
+ this.novaNetworks = novaNetworks;
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java
new file mode 100644
index 0000000..680a82c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java
@@ -0,0 +1,56 @@
+/*
+ * 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.nova.v2_0.compute.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Predicates.and;
+import static com.google.common.collect.Iterables.all;
+import static org.jclouds.compute.predicates.NodePredicates.TERMINATED;
+import static org.jclouds.compute.predicates.NodePredicates.inGroup;
+import static org.jclouds.compute.predicates.NodePredicates.locationId;
+import static org.jclouds.compute.predicates.NodePredicates.parentLocationId;
+
+import javax.inject.Inject;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
+/**
+ * @author Adrian Cole
+ */
+public class AllNodesInGroupTerminated implements Predicate<ZoneAndName> {
+ private final ComputeService computeService;
+
+
+ //TODO: TESTME
+ @Inject
+ public AllNodesInGroupTerminated(ComputeService computeService) {
+ this.computeService = checkNotNull(computeService, "computeService");
+ }
+
+ @Override
+ public boolean apply(ZoneAndName input) {
+ // new nodes can have the zone as their location, existing nodes, the parent is the
+ // location
+ return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getZone()),
+ parentLocationId(input.getZone()))), and(inGroup(input.getName()), TERMINATED));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java
new file mode 100644
index 0000000..e3ea4cc
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.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.nova.v2_0.compute.strategy;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.ssh.SshKeys.fingerprintPrivateKey;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.compute.config.CustomizationResponse;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
+import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap;
+import org.jclouds.compute.strategy.ListNodesStrategy;
+import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.compute.functions.AllocateAndAddFloatingIpToNode;
+import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
+
+import com.google.common.base.Throwables;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.Multimap;
+import com.google.common.primitives.Ints;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet extends
+ CreateNodesWithGroupEncodedIntoNameThenAddToSet {
+
+ private final AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode;
+ private final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache;
+ private final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
+ private final NovaApi novaApi;
+
+ @Inject
+ protected ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet(
+ CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy,
+ ListNodesStrategy listNodesStrategy,
+ GroupNamingConvention.Factory namingConvention,
+ CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
+ @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
+ AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode,
+ LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache,
+ LoadingCache<ZoneAndName, KeyPair> keyPairCache, NovaApi novaApi) {
+ super(addNodeWithTagStrategy, listNodesStrategy, namingConvention, userExecutor,
+ customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
+ this.securityGroupCache = checkNotNull(securityGroupCache, "securityGroupCache");
+ this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
+ this.createAndAddFloatingIpToNode = checkNotNull(createAndAddFloatingIpToNode,
+ "createAndAddFloatingIpToNode");
+ this.novaApi = checkNotNull(novaApi, "novaApi");
+ }
+
+ @Override
+ public Map<?, ListenableFuture<Void>> execute(String group, int count, Template template, Set<NodeMetadata> goodNodes,
+ Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
+
+ Template mutableTemplate = template.clone();
+
+ NovaTemplateOptions templateOptions = NovaTemplateOptions.class.cast(mutableTemplate.getOptions());
+
+ assert template.getOptions().equals(templateOptions) : "options didn't clone properly";
+
+ String zone = mutableTemplate.getLocation().getId();
+
+ if (templateOptions.shouldAutoAssignFloatingIp()) {
+ checkArgument(novaApi.getFloatingIPExtensionForZone(zone).isPresent(),
+ "Floating IPs are required by options, but the extension is not available! options: %s",
+ templateOptions);
+ }
+
+ boolean keyPairExtensionPresent = novaApi.getKeyPairExtensionForZone(zone).isPresent();
+ if (templateOptions.shouldGenerateKeyPair()) {
+ checkArgument(keyPairExtensionPresent,
+ "Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
+ KeyPair keyPair = keyPairCache.getUnchecked(ZoneAndName.fromZoneAndName(zone, namingConvention.create()
+ .sharedNameForGroup(group)));
+ keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
+ templateOptions.keyPairName(keyPair.getName());
+ } else if (templateOptions.getKeyPairName() != null) {
+ checkArgument(keyPairExtensionPresent,
+ "Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
+ if (templateOptions.getLoginPrivateKey() != null) {
+ String pem = templateOptions.getLoginPrivateKey();
+ KeyPair keyPair = KeyPair.builder().name(templateOptions.getKeyPairName())
+ .fingerprint(fingerprintPrivateKey(pem)).privateKey(pem).build();
+ keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
+ }
+ }
+
+ boolean securityGroupExtensionPresent = novaApi.getSecurityGroupExtensionForZone(zone).isPresent();
+ List<Integer> inboundPorts = Ints.asList(templateOptions.getInboundPorts());
+ if (templateOptions.getSecurityGroupNames().isPresent()
+ && templateOptions.getSecurityGroupNames().get().size() > 0) {
+ checkArgument(securityGroupExtensionPresent,
+ "Security groups are required by options, but the extension is not available! options: %s",
+ templateOptions);
+ } else if (securityGroupExtensionPresent) {
+ if (!templateOptions.getSecurityGroupNames().isPresent() && inboundPorts.size() > 0) {
+ String securityGroupName = namingConvention.create().sharedNameForGroup(group);
+ try {
+ securityGroupCache.get(new ZoneSecurityGroupNameAndPorts(zone, securityGroupName, inboundPorts));
+ } catch (ExecutionException e) {
+ throw Throwables.propagate(e.getCause());
+ }
+ templateOptions.securityGroupNames(securityGroupName);
+ }
+ }
+ templateOptions.userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, group);
+
+ return super.execute(group, count, mutableTemplate, goodNodes, badNodes, customizationResponses);
+ }
+
+ @Override
+ protected ListenableFuture<AtomicReference<NodeMetadata>> createNodeInGroupWithNameAndTemplate(String group,
+ final String name, Template template) {
+
+ ListenableFuture<AtomicReference<NodeMetadata>> future = super.createNodeInGroupWithNameAndTemplate(group, name, template);
+ NovaTemplateOptions templateOptions = NovaTemplateOptions.class.cast(template.getOptions());
+
+ if (templateOptions.shouldAutoAssignFloatingIp()) {
+ return Futures.transform(future, createAndAddFloatingIpToNode, userExecutor);
+ } else {
+ return future;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java
new file mode 100644
index 0000000..7f31c27
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java
@@ -0,0 +1,159 @@
+/*
+ * 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.nova.v2_0.config;
+
+import java.beans.ConstructorProperties;
+import java.lang.reflect.Type;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Singleton;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.json.config.GsonModule.DateAdapter;
+import org.jclouds.openstack.nova.v2_0.domain.Address;
+import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedAttributes;
+import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedStatus;
+import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+
+/**
+ * @author Adrian Cole
+ * @author Adam Lowe
+ */
+public class NovaParserModule extends AbstractModule {
+
+ @Provides
+ @Singleton
+ public Map<Type, Object> provideCustomAdapterBindings() {
+ return ImmutableMap.<Type, Object>of(
+ HostResourceUsage.class, new HostResourceUsageAdapter(),
+ ServerWithSecurityGroups.class, new ServerWithSecurityGroupsAdapter(),
+ Server.class, new ServerAdapter()
+ );
+ }
+
+ @Override
+ protected void configure() {
+ bind(DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class);
+ }
+
+ @Singleton
+ public static class HostResourceUsageAdapter implements JsonSerializer<HostResourceUsage>, JsonDeserializer<HostResourceUsage> {
+ public HostResourceUsage apply(HostResourceUsageView in) {
+ return in.resource.toBuilder().build();
+ }
+
+ @Override
+ public HostResourceUsage deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
+ return apply((HostResourceUsageView) context.deserialize(jsonElement, HostResourceUsageView.class));
+ }
+
+ @Override
+ public JsonElement serialize(HostResourceUsage hostResourceUsage, Type type, JsonSerializationContext context) {
+ return context.serialize(hostResourceUsage);
+ }
+
+ private static class HostResourceUsageView {
+ protected HostResourceUsageInternal resource;
+ }
+
+ private static class HostResourceUsageInternal extends HostResourceUsage {
+
+ @ConstructorProperties({
+ "host", "project", "memory_mb", "cpu", "disk_gb"
+ })
+ protected HostResourceUsageInternal(String host, @Nullable String project, int memoryMb, int cpu, int diskGb) {
+ super(host, project, memoryMb, cpu, diskGb);
+ }
+ }
+ }
+
+ @Singleton
+ public static class ServerWithSecurityGroupsAdapter implements JsonDeserializer<ServerWithSecurityGroups> {
+ @Override
+ public ServerWithSecurityGroups deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context)
+ throws JsonParseException {
+ Server server = context.deserialize(jsonElement, Server.class);
+ ServerWithSecurityGroups.Builder<?> result = ServerWithSecurityGroups.builder().fromServer(server);
+ Set<String> names = Sets.newLinkedHashSet();
+ if (jsonElement.getAsJsonObject().get("security_groups") != null) {
+ JsonArray x = jsonElement.getAsJsonObject().get("security_groups").getAsJsonArray();
+ for (JsonElement y : x) {
+ names.add(y.getAsJsonObject().get("name").getAsString());
+ }
+ result.securityGroupNames(names);
+ }
+ return result.build();
+ }
+ }
+
+ @Singleton
+ public static class ServerAdapter implements JsonDeserializer<Server> {
+ @Override
+ public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context)
+ throws JsonParseException {
+ Server serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class));
+ Server.Builder<?> result = Server.builder().fromServer(serverBase);
+ ServerExtendedStatus extendedStatus = context.deserialize(jsonElement, ServerExtendedStatus.class);
+ if (!Objects.equal(extendedStatus, ServerExtendedStatus.builder().build())) {
+ result.extendedStatus(extendedStatus);
+ }
+ ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class);
+ if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) {
+ result.extendedAttributes(extraAttributes);
+ }
+ return result.build();
+ }
+
+ public Server apply(ServerInternal in) {
+ return in.toBuilder().build();
+ }
+
+ private static class ServerInternal extends Server {
+ @ConstructorProperties({
+ "id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig"
+ })
+ protected ServerInternal(String id, @Nullable String name, java.util.Set<Link> links, @Nullable String uuid, String tenantId,
+ String userId, Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4,
+ @Nullable String accessIPv6, Server.Status status, Resource image, Resource flavor, @Nullable String keyName,
+ @Nullable String configDrive, Multimap<String, Address> addresses, Map<String, String> metadata,
+ @Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes, @Nullable String diskConfig) {
+ super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java
new file mode 100644
index 0000000..9b55439
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java
@@ -0,0 +1,43 @@
+/*
+ * 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.nova.v2_0.config;
+
+/**
+ * Configuration properties and constants used in openstack Nova connections.
+ *
+ * @author Adam Lowe
+ */
+public class NovaProperties {
+
+ /**
+ * Eventual consistency delay for retrieving a security group after it is created (in ms)
+ */
+ public static final String TIMEOUT_SECURITYGROUP_PRESENT = "jclouds.openstack-nova.timeout.securitygroup-present";
+
+ /**
+ * Whenever a node is created, automatically create and assign a floating ip address, also
+ * delete when the node is destroyed.
+ */
+ public static final String AUTO_ALLOCATE_FLOATING_IPS = "jclouds.openstack-nova.auto-create-floating-ips";
+
+ /**
+ * Whenever a node is created, automatically generate keypairs for groups, as needed, also
+ * delete the keypair(s) when the last node in the group is destroyed.
+ */
+ public static final String AUTO_GENERATE_KEYPAIRS = "jclouds.openstack-nova.auto-generate-keypairs";
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java
new file mode 100644
index 0000000..556ec60
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java
@@ -0,0 +1,191 @@
+/*
+ * 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.nova.v2_0.config;
+import static org.jclouds.reflect.Reflection2.typeToken;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+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.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAPI;
+import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces;
+import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsApi;
+import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
+import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
+import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeAsyncApi;
+import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
+import org.jclouds.openstack.nova.v2_0.features.FlavorAsyncApi;
+import org.jclouds.openstack.nova.v2_0.features.ImageApi;
+import org.jclouds.openstack.nova.v2_0.features.ImageAsyncApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerAsyncApi;
+import org.jclouds.openstack.nova.v2_0.handlers.NovaErrorHandler;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.features.ExtensionApi;
+import org.jclouds.openstack.v2_0.features.ExtensionAsyncApi;
+import org.jclouds.openstack.v2_0.functions.PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet;
+import org.jclouds.rest.ConfiguresRestClient;
+import org.jclouds.rest.config.RestClientModule;
+import org.jclouds.rest.functions.ImplicitOptionalConverter;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.reflect.TypeToken;
+import com.google.inject.Provides;
+
+/**
+ * Configures the Nova connection.
+ *
+ * @author Adrian Cole
+ */
+@ConfiguresRestClient
+public class NovaRestClientModule<S extends NovaApi, A extends NovaAsyncApi> extends RestClientModule<S, A> {
+
+ public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
+ .put(ServerApi.class, ServerAsyncApi.class)
+ .put(FlavorApi.class, FlavorAsyncApi.class)
+ .put(ImageApi.class, ImageAsyncApi.class)
+ .put(ExtensionApi.class, ExtensionAsyncApi.class)
+ .put(FloatingIPApi.class, FloatingIPAsyncApi.class)
+ .put(AvailabilityZoneAPI.class, AvailabilityZoneAsyncApi.class)
+ .put(SecurityGroupApi.class, SecurityGroupAsyncApi.class)
+ .put(KeyPairApi.class, KeyPairAsyncApi.class)
+ .put(HostAdministrationApi.class, HostAdministrationAsyncApi.class)
+ .put(SimpleTenantUsageApi.class, SimpleTenantUsageAsyncApi.class)
+ .put(VirtualInterfaceApi.class, VirtualInterfaceAsyncApi.class)
+ .put(ServerWithSecurityGroupsApi.class, ServerWithSecurityGroupsAsyncApi.class)
+ .put(ServerAdminApi.class, ServerAdminAsyncApi.class)
+ .put(HostAggregateApi.class, HostAggregateAsyncApi.class)
+ .put(FlavorExtraSpecsApi.class, FlavorExtraSpecsAsyncApi.class)
+ .put(QuotaApi.class, QuotaAsyncApi.class)
+ .put(QuotaClassApi.class, QuotaClassAsyncApi.class)
+ .put(VolumeApi.class, VolumeAsyncApi.class)
+ .put(VolumeAttachmentApi.class, VolumeAttachmentAsyncApi.class)
+ .put(VolumeTypeApi.class, VolumeTypeAsyncApi.class)
+ .build();
+
+ @SuppressWarnings("unchecked")
+ public NovaRestClientModule() {
+ super(TypeToken.class.cast(typeToken(NovaApi.class)), TypeToken.class.cast(typeToken(NovaAsyncApi.class)), DELEGATE_MAP);
+ }
+
+ protected NovaRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
+ Map<Class<?>, Class<?>> sync2Async) {
+ super(syncClientType, asyncClientType, sync2Async);
+ }
+
+ @Override
+ protected void configure() {
+ bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class);
+ super.configure();
+ }
+
+ @Provides
+ @Singleton
+ public Multimap<URI, URI> aliases() {
+ return ImmutableMultimap.<URI, URI>builder()
+ .put(URI.create(ExtensionNamespaces.SECURITY_GROUPS),
+ URI.create("http://docs.openstack.org/compute/ext/securitygroups/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.FLOATING_IPS),
+ URI.create("http://docs.openstack.org/compute/ext/floating_ips/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.KEYPAIRS),
+ URI.create("http://docs.openstack.org/compute/ext/keypairs/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.SIMPLE_TENANT_USAGE),
+ URI.create("http://docs.openstack.org/compute/ext/os-simple-tenant-usage/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.HOSTS),
+ URI.create("http://docs.openstack.org/compute/ext/hosts/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.VOLUMES),
+ URI.create("http://docs.openstack.org/compute/ext/volumes/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.VIRTUAL_INTERFACES),
+ URI.create("http://docs.openstack.org/compute/ext/virtual_interfaces/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.CREATESERVEREXT),
+ URI.create("http://docs.openstack.org/compute/ext/createserverext/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.ADMIN_ACTIONS),
+ URI.create("http://docs.openstack.org/compute/ext/admin-actions/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.AGGREGATES),
+ URI.create("http://docs.openstack.org/compute/ext/aggregates/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.FLAVOR_EXTRA_SPECS),
+ URI.create("http://docs.openstack.org/compute/ext/flavor_extra_specs/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.QUOTAS),
+ URI.create("http://docs.openstack.org/compute/ext/quotas-sets/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.QUOTA_CLASSES),
+ URI.create("http://docs.openstack.org/compute/ext/quota-classes-sets/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.VOLUME_TYPES),
+ URI.create("http://docs.openstack.org/compute/ext/volume_types/api/v1.1"))
+ .build();
+ }
+
+ @Provides
+ @Singleton
+ public LoadingCache<String, Set<? extends Extension>> provideExtensionsByZone(final Provider<NovaApi> novaApi) {
+ 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 novaApi.get().getExtensionApiForZone(key).list();
+ }
+ });
+ }
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(NovaErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(NovaErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(NovaErrorHandler.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java
new file mode 100644
index 0000000..38c744d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.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.nova.v2_0.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * IP address
+ *
+ * @author AdrianCole
+*/
+public class Address {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromAddress(this);
+ }
+
+ public static Address createV4(String addr) {
+ return builder().version(4).addr(addr).build();
+ }
+
+ public static Address createV6(String addr) {
+ return builder().version(6).addr(addr).build();
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String addr;
+ protected int version;
+
+ /**
+ * @see Address#getAddr()
+ */
+ public T addr(String addr) {
+ this.addr = addr;
+ return self();
+ }
+
+ /**
+ * @see Address#getVersion()
+ */
+ public T version(int version) {
+ this.version = version;
+ return self();
+ }
+
+ public Address build() {
+ return new Address(addr, version);
+ }
+
+ public T fromAddress(Address in) {
+ return this
+ .addr(in.getAddr())
+ .version(in.getVersion());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String addr;
+ private final int version;
+
+ @ConstructorProperties({
+ "addr", "version"
+ })
+ protected Address(String addr, int version) {
+ this.addr = checkNotNull(addr, "addr");
+ this.version = version;
+ }
+
+ /**
+ * @return the ip address
+ */
+ public String getAddr() {
+ return this.addr;
+ }
+
+ /**
+ * @return the IP version, ex. 4
+ */
+ public int getVersion() {
+ return this.version;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(addr, version);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Address that = Address.class.cast(obj);
+ return Objects.equal(this.addr, that.addr)
+ && Objects.equal(this.version, that.version);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("addr", addr).add("version", version);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java
new file mode 100644
index 0000000..97460d8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nova.v2_0.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.CaseFormat;
+
+/**
+ * @author Adam Lowe
+ */
+public enum BackupType {
+ DAILY, WEEKLY;
+
+ public String value() {
+ return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static BackupType fromValue(String backupType) {
+ return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(backupType, "backupType")));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java
new file mode 100644
index 0000000..c353ab0
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java
@@ -0,0 +1,211 @@
+/*
+ * 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.nova.v2_0.domain;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+
+/**
+ * A flavor is an available hardware configuration for a server. Each flavor has
+ * a unique combination of disk space and memory capacity.
+ *
+ * @author Jeremy Daggett, Ilja Bobkevic
+ * @see <a href=
+ "http://docs.openstack.org/api/openstack-compute/2/content/List_Flavors-d1e4188.html"
+ />
+*/
+public class Flavor extends Resource {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromFlavor(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends Resource.Builder<T> {
+ protected int ram;
+ protected int disk;
+ protected int vcpus;
+ protected String swap;
+ protected Double rxtxFactor;
+ protected Integer ephemeral;
+
+ /**
+ * @see Flavor#getRam()
+ */
+ public T ram(int ram) {
+ this.ram = ram;
+ return self();
+ }
+
+ /**
+ * @see Flavor#getDisk()
+ */
+ public T disk(int disk) {
+ this.disk = disk;
+ return self();
+ }
+
+ /**
+ * @see Flavor#getVcpus()
+ */
+ public T vcpus(int vcpus) {
+ this.vcpus = vcpus;
+ return self();
+ }
+
+ /**
+ * @see Flavor#getSwap()
+ */
+ public T swap(String swap) {
+ this.swap = swap;
+ return self();
+ }
+
+ /**
+ * @see Flavor#getRxtxFactor()
+ */
+ public T rxtxFactor(Double rxtxFactor) {
+ this.rxtxFactor = rxtxFactor;
+ return self();
+ }
+
+ /**
+ * @see Flavor#getEphemeral()
+ */
+ public T ephemeral(Integer ephemeral) {
+ this.ephemeral = ephemeral;
+ return self();
+ }
+
+ public Flavor build() {
+ return new Flavor(id, name, links, ram, disk, vcpus, swap, rxtxFactor, ephemeral);
+ }
+
+ public T fromFlavor(Flavor in) {
+ return super.fromResource(in)
+ .ram(in.getRam())
+ .disk(in.getDisk())
+ .vcpus(in.getVcpus())
+ .swap(in.getSwap().orNull())
+ .rxtxFactor(in.getRxtxFactor().orNull())
+ .ephemeral(in.getEphemeral().orNull());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final int ram;
+ private final int disk;
+ private final int vcpus;
+ private final Optional<String> swap;
+ @Named("rxtx_factor")
+ private final Optional<Double> rxtxFactor;
+ @Named("OS-FLV-EXT-DATA:ephemeral")
+ private final Optional<Integer> ephemeral;
+
+ @ConstructorProperties({
+ "id", "name", "links", "ram", "disk", "vcpus", "swap", "rxtx_factor", "OS-FLV-EXT-DATA:ephemeral"
+ })
+ protected Flavor(String id, String name, java.util.Set<Link> links, int ram, int disk, int vcpus,
+ @Nullable String swap, @Nullable Double rxtxFactor, @Nullable Integer ephemeral) {
+ super(id, checkNotNull(name, "name"), links);
+ checkArgument(ram > 0, "Value of ram has to greater than 0");
+ checkArgument(vcpus > 0, "Value of vcpus has to greater than 0");
+ this.ram = ram;
+ this.disk = disk;
+ this.vcpus = vcpus;
+ this.swap = Optional.fromNullable(swap);
+ this.rxtxFactor = Optional.fromNullable(rxtxFactor);
+ this.ephemeral = Optional.fromNullable(ephemeral);
+ }
+
+ public int getRam() {
+ return this.ram;
+ }
+
+ public int getDisk() {
+ return this.disk;
+ }
+
+ public int getVcpus() {
+ return this.vcpus;
+ }
+
+ public Optional<String> getSwap() {
+ return this.swap;
+ }
+
+ public Optional<Double> getRxtxFactor() {
+ return this.rxtxFactor;
+ }
+
+ /**
+ * Retrieves ephemeral disk space in GB
+ * <p/>
+ * NOTE: This field is only present if the Flavor Extra Data extension is installed (alias "OS-FLV-EXT-DATA").
+ *
+ * @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
+ * @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#FLAVOR_EXTRA_DATA
+ */
+ public Optional<Integer> getEphemeral() {
+ return this.ephemeral;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(ram, disk, vcpus, swap, rxtxFactor, ephemeral);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Flavor that = Flavor.class.cast(obj);
+ return super.equals(that) && Objects.equal(this.ram, that.ram)
+ && Objects.equal(this.disk, that.disk)
+ && Objects.equal(this.vcpus, that.vcpus)
+ && Objects.equal(this.swap, that.swap)
+ && Objects.equal(this.rxtxFactor, that.rxtxFactor)
+ && Objects.equal(this.ephemeral, that.ephemeral);
+ }
+
+ protected ToStringHelper string() {
+ return super.string()
+ .add("ram", ram).add("disk", disk).add("vcpus", vcpus).add("swap", swap).add("rxtxFactor", rxtxFactor).add("ephemeral", ephemeral);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java
new file mode 100644
index 0000000..203b2da
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java
@@ -0,0 +1,173 @@
+/*
+ * 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.nova.v2_0.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.base.Objects.ToStringHelper;
+
+/**
+ * A Floating IP is an IP address that can be created and associated with a
+ * Server instance. Floating IPs can also be disassociated and deleted from a
+ * Server instance.
+ *
+ * @author Jeremy Daggett
+ * @author chamerling
+*/
+public class FloatingIP implements Comparable<FloatingIP> {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromFloatingIP(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected String ip;
+ protected String fixedIp;
+ protected String instanceId;
+
+ /**
+ * @see FloatingIP#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see FloatingIP#getIp()
+ */
+ public T ip(String ip) {
+ this.ip = ip;
+ return self();
+ }
+
+ /**
+ * @see FloatingIP#getFixedIp()
+ */
+ public T fixedIp(String fixedIp) {
+ this.fixedIp = fixedIp;
+ return self();
+ }
+
+ /**
+ * @see FloatingIP#getInstanceId()
+ */
+ public T instanceId(String instanceId) {
+ this.instanceId = instanceId;
+ return self();
+ }
+
+ public FloatingIP build() {
+ return new FloatingIP(id, ip, fixedIp, instanceId);
+ }
+
+ public T fromFloatingIP(FloatingIP in) {
+ return this
+ .id(in.getId())
+ .ip(in.getIp())
+ .fixedIp(in.getFixedIp())
+ .instanceId(in.getInstanceId());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ private final String ip;
+ @Named("fixed_ip")
+ private final String fixedIp;
+ @Named("instance_id")
+ private final String instanceId;
+
+ @ConstructorProperties({
+ "id", "ip", "fixed_ip", "instance_id"
+ })
+ protected FloatingIP(String id, String ip, @Nullable String fixedIp, @Nullable String instanceId) {
+ this.id = checkNotNull(id, "id");
+ this.ip = checkNotNull(ip, "ip");
+ this.fixedIp = fixedIp;
+ this.instanceId = instanceId;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public String getIp() {
+ return this.ip;
+ }
+
+ @Nullable
+ public String getFixedIp() {
+ return this.fixedIp;
+ }
+
+ @Nullable
+ public String getInstanceId() {
+ return this.instanceId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, ip, fixedIp, instanceId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ FloatingIP that = FloatingIP.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.ip, that.ip)
+ && Objects.equal(this.fixedIp, that.fixedIp)
+ && Objects.equal(this.instanceId, that.instanceId);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("ip", ip).add("fixedIp", fixedIp).add("instanceId", instanceId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ @Override
+ public int compareTo(FloatingIP o) {
+ return this.id.compareTo(o.getId());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java
new file mode 100644
index 0000000..72df77d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java
@@ -0,0 +1,127 @@
+/*
+ * 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.nova.v2_0.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;
+
+/**
+ * Class Host
+*/
+public class Host {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromHost(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String name;
+ protected String service;
+
+ /**
+ * @see Host#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see Host#getService()
+ */
+ public T service(String service) {
+ this.service = service;
+ return self();
+ }
+
+ public Host build() {
+ return new Host(name, service);
+ }
+
+ public T fromHost(Host in) {
+ return this
+ .name(in.getName())
+ .service(in.getService());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ @Named("host_name")
+ private final String name;
+ private final String service;
+
+ @ConstructorProperties({
+ "host_name", "service"
+ })
+ protected Host(@Nullable String name, @Nullable String service) {
+ this.name = name;
+ this.service = service;
+ }
+
+ @Nullable
+ public String getName() {
+ return this.name;
+ }
+
+ @Nullable
+ public String getService() {
+ return this.service;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, service);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Host that = Host.class.cast(obj);
+ return Objects.equal(this.name, that.name)
+ && Objects.equal(this.service, that.service);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("name", name).add("service", service);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}