You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2014/12/23 05:26:35 UTC
[11/51] [partial] stratos git commit: dropping jclouds 1.8.0 clone
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/pom.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/pom.xml b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/pom.xml
deleted file mode 100644
index b6964b9..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/pom.xml
+++ /dev/null
@@ -1,157 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-project</artifactId>
- <version>1.8.0</version>
- </parent>
- <groupId>org.apache.stratos</groupId>
- <artifactId>openstack-nova</artifactId>
- <version>1.8.0-stratos</version>
- <name>jclouds openstack-nova api</name>
- <description>jclouds components to access an implementation of OpenStack Nova</description>
- <packaging>bundle</packaging>
-
- <properties>
- <jclouds.version>1.8.0</jclouds.version>
- <!-- keystone endpoint -->
- <test.openstack-nova.endpoint>http://localhost:5000/v2.0/</test.openstack-nova.endpoint>
- <!-- keystone version -->
- <test.openstack-nova.api-version>1.1</test.openstack-nova.api-version>
- <test.openstack-nova.build-version />
- <test.openstack-nova.identity>FIXME_IDENTITY</test.openstack-nova.identity>
- <test.openstack-nova.credential>FIXME_CREDENTIALS</test.openstack-nova.credential>
- <test.openstack-nova.template />
- <test.jclouds.openstack-nova.auto-allocate-floating-ips>false</test.jclouds.openstack-nova.auto-allocate-floating-ips>
- <test.jclouds.keystone.credential-type>passwordCredentials</test.jclouds.keystone.credential-type>
-
- <jclouds.osgi.export>org.jclouds.openstack.nova.v2_0*;version="${project.version}"</jclouds.osgi.export>
- <jclouds.osgi.import>
- org.jclouds.compute.internal;version="${jclouds.version}",
- org.jclouds.rest.internal;version="${jclouds.version}",
- org.jclouds*;version="${jclouds.version}",
- *
- </jclouds.osgi.import>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.jclouds.api</groupId>
- <artifactId>openstack-keystone</artifactId>
- <version>${jclouds.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-compute</artifactId>
- <version>${jclouds.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-core</artifactId>
- <version>${jclouds.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.api</groupId>
- <artifactId>openstack-keystone</artifactId>
- <version>${jclouds.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-compute</artifactId>
- <version>${jclouds.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-sshj</artifactId>
- <version>${jclouds.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-slf4j</artifactId>
- <version>${jclouds.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.squareup.okhttp</groupId>
- <artifactId>mockwebserver</artifactId>
- <scope>test</scope>
- <exclusions>
- <!-- provided by the jclouds-bouncycastle driver -->
- <exclusion>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-jdk15on</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>live</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>integration</id>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <systemPropertyVariables>
- <test.openstack-nova.endpoint>${test.openstack-nova.endpoint}</test.openstack-nova.endpoint>
- <test.openstack-nova.api-version>${test.openstack-nova.api-version}</test.openstack-nova.api-version>
- <test.openstack-nova.build-version>${test.openstack-nova.build-version}</test.openstack-nova.build-version>
- <test.openstack-nova.identity>${test.openstack-nova.identity}</test.openstack-nova.identity>
- <test.openstack-nova.credential>${test.openstack-nova.credential}</test.openstack-nova.credential>
- <test.openstack-nova.template>${test.openstack-nova.template}</test.openstack-nova.template>
- <test.jclouds.openstack-nova.auto-allocate-floating-ips>${test.jclouds.openstack-nova.auto-allocate-floating-ips}</test.jclouds.openstack-nova.auto-allocate-floating-ips>
- <test.jclouds.keystone.credential-type>${test.jclouds.keystone.credential-type}</test.jclouds.keystone.credential-type>
- </systemPropertyVariables>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
- <scm>
- <tag>4.0.0-rc4</tag>
- </scm>
-</project>
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java
deleted file mode 100644
index 9f8d302..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.nova.v2_0;
-
-import java.io.Closeable;
-import java.util.Set;
-
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.location.Zone;
-import org.jclouds.location.functions.ZoneToEndpoint;
-import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneApi;
-import org.jclouds.openstack.nova.v2_0.extensions.ConsolesApi;
-import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsApi;
-import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
-import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationApi;
-import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi;
-import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
-import org.jclouds.openstack.nova.v2_0.extensions.QuotaApi;
-import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
-import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminApi;
-import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi;
-import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageApi;
-import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceApi;
-import org.jclouds.openstack.nova.v2_0.extensions.VolumeApi;
-import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentApi;
-import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeApi;
-import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
-import org.jclouds.openstack.nova.v2_0.features.ImageApi;
-import org.jclouds.openstack.nova.v2_0.features.ServerApi;
-import org.jclouds.openstack.v2_0.features.ExtensionApi;
-import org.jclouds.rest.annotations.Delegate;
-import org.jclouds.rest.annotations.EndpointParam;
-
-import com.google.common.base.Optional;
-import com.google.inject.Provides;
-
-/**
- * Provides access to the OpenStack Compute (Nova) API.
- * <p/>
- *
- */
-public interface NovaApi extends Closeable {
- /**
- *
- * @return the Zone codes configured
- */
- @Provides
- @Zone
- Set<String> getConfiguredZones();
-
- /**
- * Provides access to Server features.
- */
- @Delegate
- ServerApi getServerApiForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Flavor features.
- */
- @Delegate
- FlavorApi getFlavorApiForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Extension features.
- */
- @Delegate
- ExtensionApi getExtensionApiForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Image features.
- */
- @Delegate
- ImageApi getImageApiForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to availability zone features
- */
- @Delegate
- Optional<? extends AvailabilityZoneApi> getAvailabilityZoneApi(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Floating IP features.
- */
- @Delegate
- Optional<? extends FloatingIPApi> getFloatingIPExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Security Group features.
- */
- @Delegate
- Optional<? extends SecurityGroupApi> getSecurityGroupExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Key Pair features.
- */
- @Delegate
- Optional<? extends KeyPairApi> getKeyPairExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Host Administration features.
- */
- @Delegate
- Optional<? extends HostAdministrationApi> getHostAdministrationExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Simple Tenant Usage features.
- */
- @Delegate
- Optional<? extends SimpleTenantUsageApi> getSimpleTenantUsageExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Virtual Interface features.
- */
- @Delegate
- Optional<? extends VirtualInterfaceApi> getVirtualInterfaceExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Server Extra Data features.
- */
- @Delegate
- Optional<? extends ServerWithSecurityGroupsApi> getServerWithSecurityGroupsExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Server Admin Actions features.
- */
- @Delegate
- Optional<? extends ServerAdminApi> getServerAdminExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Aggregate features.
- */
- @Delegate
- Optional<? extends HostAggregateApi> getHostAggregateExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Flavor extra specs features.
- */
- @Delegate
- Optional<? extends FlavorExtraSpecsApi> getFlavorExtraSpecsExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Quota features.
- */
- @Delegate
- Optional<? extends QuotaApi> getQuotaExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Volume features.
- */
- @Delegate
- Optional<? extends VolumeApi> getVolumeExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Volume Attachment features.
- */
- @Delegate
- Optional<? extends VolumeAttachmentApi> getVolumeAttachmentExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides access to Volume Type features.
- */
- @Delegate
- Optional<? extends VolumeTypeApi> getVolumeTypeExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-
- /**
- * Provides synchronous access to Console features.
- */
- @Delegate
- Optional<? extends ConsolesApi> getConsolesExtensionForZone(
- @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java
deleted file mode 100644
index 4dfd401..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.nova.v2_0;
-
-import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
-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 static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS;
-import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_GENERATE_KEYPAIRS;
-import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.TIMEOUT_SECURITYGROUP_PRESENT;
-import static org.jclouds.reflect.Reflection2.typeToken;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.compute.ComputeServiceContext;
-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.ZoneModule;
-import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
-import org.jclouds.openstack.nova.v2_0.config.NovaHttpApiModule;
-import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
-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 Nova 2.0 API
- */
-public class NovaApiMetadata extends BaseHttpApiMetadata<NovaApi> {
-
- @Override
- public Builder toBuilder() {
- return new Builder().fromApiMetadata(this);
- }
-
- public NovaApiMetadata() {
- this(new Builder());
- }
-
- protected NovaApiMetadata(Builder builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- Properties properties = BaseHttpApiMetadata.defaultProperties();
- // auth fail can happen while cloud-init applies keypair updates
- properties.setProperty("jclouds.ssh.max-retries", "7");
- properties.setProperty("jclouds.ssh.retry-auth", "true");
- properties.setProperty(SERVICE_TYPE, ServiceType.COMPUTE);
- properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);
- properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "false");
- properties.setProperty(AUTO_GENERATE_KEYPAIRS, "false");
- properties.setProperty(TIMEOUT_SECURITYGROUP_PRESENT, "500");
- // Keystone 1.1 expires tokens after 24 hours and allows renewal 1 hour
- // before expiry by default. We choose a value less than the latter
- // since the former persists between jclouds invocations.
- properties.setProperty(PROPERTY_SESSION_INTERVAL, 30 * 60 + "");
- return properties;
- }
-
- public static class Builder extends BaseHttpApiMetadata.Builder<NovaApi, Builder> {
-
- protected Builder() {
- id("openstack-nova")
- .name("OpenStack Nova Diablo+ API")
- .identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant")
- .credentialName("${password}")
- .endpointName("Keystone base url ending in /v2.0/")
- .documentation(URI.create("http://api.openstack.org/"))
- .version("2")
- .defaultEndpoint("http://localhost:5000/v2.0/")
- .defaultProperties(NovaApiMetadata.defaultProperties())
- .view(typeToken(ComputeServiceContext.class))
- .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
- .add(AuthenticationApiModule.class)
- .add(KeystoneAuthenticationModule.class)
- .add(ZoneModule.class)
- .add(NovaParserModule.class)
- .add(NovaHttpApiModule.class)
- .add(NovaComputeServiceContextModule.class).build());
- }
-
- @Override
- public NovaApiMetadata build() {
- return new NovaApiMetadata(this);
- }
-
- @Override
- protected Builder self() {
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindConsoleToJsonPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindConsoleToJsonPayload.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindConsoleToJsonPayload.java
deleted file mode 100644
index 82f69f3..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindConsoleToJsonPayload.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.nova.v2_0.binders;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.openstack.nova.v2_0.domain.Console;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSortedMap;
-
-@Singleton
-public class BindConsoleToJsonPayload extends BindToJsonPayload {
-
- @Inject
- public BindConsoleToJsonPayload(Json jsonBinder) {
- super(jsonBinder);
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- String action;
-
- Console.Type type = (Console.Type) postParams.get("type");
-
- switch (type) {
- case NOVNC:
- case XVPVNC:
- action = "os-getVNCConsole";
- break;
- case SPICE_HTML5:
- action = "os-getSPICEConsole";
- break;
- case RDP_HTML5:
- action = "os-getRDPConsole";
- break;
- default:
- throw new IllegalArgumentException("Invalid type: " + type);
- }
-
- return bindToRequest(request, ImmutableMap.of(action, ImmutableSortedMap.copyOf(postParams)));
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java
deleted file mode 100644
index 509de12..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.nova.v2_0.binders;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSortedMap;
-
-@Singleton
-public class BindKeyPairToJsonPayload extends BindToJsonPayload {
-
- @Inject
- public BindKeyPairToJsonPayload(Json jsonBinder) {
- super(jsonBinder);
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- return bindToRequest(request, (Object) ImmutableMap.of("keypair", ImmutableSortedMap.copyOf(postParams)));
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java
deleted file mode 100644
index c0fa3bb..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.nova.v2_0.binders;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-
-@Singleton
-public class BindMetadataToJsonPayload extends BindToJsonPayload {
-
- @Inject
- public BindMetadataToJsonPayload(Json jsonBinder) {
- super(jsonBinder);
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- return bindToRequest(request,
- (Object) ImmutableMap.of("metadata", ImmutableMap.of(postParams.get("key"), postParams.get("value"))));
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java
deleted file mode 100644
index 022ce6c..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.nova.v2_0.binders;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Predicates.instanceOf;
-import static com.google.common.collect.Iterables.find;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.openstack.nova.v2_0.domain.Ingress;
-import org.jclouds.rest.MapBinder;
-import org.jclouds.rest.binders.BindToJsonPayload;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-
-@Singleton
-public class BindSecurityGroupRuleToJsonPayload extends BindToJsonPayload implements MapBinder {
- @Inject
- public BindSecurityGroupRuleToJsonPayload(Json jsonBinder) {
- super(jsonBinder);
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
- throw new IllegalStateException("BindCredentialsToJsonPayload needs parameters");
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- Builder<String, Object> payload = ImmutableMap.builder();
- payload.putAll(postParams);
- checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
- "this binder is only valid for GeneratedHttpRequests!");
- GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
-
- Ingress ingress = Ingress.class.cast(find(gRequest.getInvocation().getArgs(), instanceOf(Ingress.class)));
- payload.put("ip_protocol", ingress.getIpProtocol().toString());
- payload.put("from_port", ingress.getFromPort() + "");
- payload.put("to_port", ingress.getToPort() + "");
-
- return super.bindToRequest(request, ImmutableMap.of("security_group_rule", payload.build()));
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java
deleted file mode 100644
index 163bbe4..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.nova.v2_0.compute;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
-import static org.jclouds.openstack.nova.v2_0.predicates.KeyPairPredicates.nameMatches;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Provider;
-import javax.inject.Singleton;
-
-import org.jclouds.Constants;
-import org.jclouds.collect.Memoized;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.callables.RunScriptOnNode;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.TemplateBuilder;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.compute.extensions.SecurityGroupExtension;
-import org.jclouds.compute.functions.GroupNamingConvention;
-import org.jclouds.compute.internal.BaseComputeService;
-import org.jclouds.compute.internal.PersistNodeCredentials;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
-import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
-import org.jclouds.compute.strategy.DestroyNodeStrategy;
-import org.jclouds.compute.strategy.GetImageStrategy;
-import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
-import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap;
-import org.jclouds.compute.strategy.ListNodesStrategy;
-import org.jclouds.compute.strategy.RebootNodeStrategy;
-import org.jclouds.compute.strategy.ResumeNodeStrategy;
-import org.jclouds.compute.strategy.SuspendNodeStrategy;
-import org.jclouds.domain.Credentials;
-import org.jclouds.domain.Location;
-import org.jclouds.openstack.nova.v2_0.NovaApi;
-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.SecurityGroup;
-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.extensions.KeyPairApi;
-import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
-import org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates;
-import org.jclouds.scriptbuilder.functions.InitAdminAccess;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Multimap;
-import com.google.common.util.concurrent.ListeningExecutorService;
-
-@Singleton
-public class NovaComputeService extends BaseComputeService {
- protected final NovaApi novaApi;
- protected final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap;
- protected final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
- protected final Function<Set<? extends NodeMetadata>, Multimap<String, String>> orphanedGroupsByZoneId;
- protected final GroupNamingConvention.Factory namingConvention;
-
- @Inject
- protected NovaComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
- @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
- @Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
- GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
- CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
- DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
- SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
- @Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
- @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
- @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
- @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
- InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
- RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
- PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
- @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, NovaApi novaApi,
- LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap,
- LoadingCache<ZoneAndName, KeyPair> keyPairCache,
- Function<Set<? extends NodeMetadata>, Multimap<String, String>> orphanedGroupsByZoneId,
- GroupNamingConvention.Factory namingConvention, Optional<ImageExtension> imageExtension,
- Optional<SecurityGroupExtension> securityGroupExtension) {
- super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
- getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
- startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
- nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
- persistNodeCredentials, timeouts, userExecutor, imageExtension, securityGroupExtension);
- this.novaApi = checkNotNull(novaApi, "novaApi");
- this.securityGroupMap = checkNotNull(securityGroupMap, "securityGroupMap");
- this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
- this.orphanedGroupsByZoneId = checkNotNull(orphanedGroupsByZoneId, "orphanedGroupsByZoneId");
- this.namingConvention = checkNotNull(namingConvention, "namingConvention");
- }
-
- @Override
- protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) {
- Multimap<String, String> zoneToZoneAndGroupNames = orphanedGroupsByZoneId.apply(deadNodes);
- for (Map.Entry<String, Collection<String>> entry : zoneToZoneAndGroupNames.asMap().entrySet()) {
- cleanOrphanedGroupsInZone(ImmutableSet.copyOf(entry.getValue()), entry.getKey());
- }
- }
-
- protected void cleanOrphanedGroupsInZone(Set<String> groups, String zoneId) {
- cleanupOrphanedSecurityGroupsInZone(groups, zoneId);
- cleanupOrphanedKeyPairsInZone(groups, zoneId);
- }
-
- private void cleanupOrphanedSecurityGroupsInZone(Set<String> groups, String zoneId) {
- Optional<? extends SecurityGroupApi> securityGroupApi = novaApi.getSecurityGroupExtensionForZone(zoneId);
- if (securityGroupApi.isPresent()) {
- for (String group : groups) {
- for (SecurityGroup securityGroup : Iterables.filter(securityGroupApi.get().list(),
- SecurityGroupPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
- ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, securityGroup.getName());
- logger.debug(">> deleting securityGroup(%s)", zoneAndName);
- securityGroupApi.get().delete(securityGroup.getId());
- // TODO: test this clear happens
- securityGroupMap.invalidate(zoneAndName);
- logger.debug("<< deleted securityGroup(%s)", zoneAndName);
- }
- }
- }
- }
-
- private void cleanupOrphanedKeyPairsInZone(Set<String> groups, String zoneId) {
- Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
- if (keyPairApi.isPresent()) {
- for (String group : groups) {
- for (KeyPair pair : keyPairApi.get().list().filter(nameMatches(namingConvention.create().containsGroup(group)))) {
- ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
- logger.debug(">> deleting keypair(%s)", zoneAndName);
- keyPairApi.get().delete(pair.getName());
- // TODO: test this clear happens
- keyPairCache.invalidate(zoneAndName);
- logger.debug("<< deleted keypair(%s)", zoneAndName);
- }
- keyPairCache.invalidate(ZoneAndName.fromZoneAndName(zoneId,
- namingConvention.create().sharedNameForGroup(group)));
- }
- }
- }
-
- /**
- * returns template options, except of type {@link NovaTemplateOptions}.
- */
- @Override
- public NovaTemplateOptions templateOptions() {
- return NovaTemplateOptions.class.cast(super.templateOptions());
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java
deleted file mode 100644
index 7a7cb7d..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.nova.v2_0.compute;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.Iterables.contains;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.transform;
-import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue;
-
-import java.util.Set;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.jclouds.compute.ComputeServiceAdapter;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.location.Zone;
-import org.jclouds.logging.Logger;
-import org.jclouds.openstack.nova.v2_0.NovaApi;
-import org.jclouds.openstack.nova.v2_0.compute.functions.RemoveFloatingIpFromNodeAndDeallocate;
-import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
-import org.jclouds.openstack.nova.v2_0.domain.Flavor;
-import org.jclouds.openstack.nova.v2_0.domain.Image;
-import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
-import org.jclouds.openstack.nova.v2_0.domain.RebootType;
-import org.jclouds.openstack.nova.v2_0.domain.Server;
-import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.FlavorInZone;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
-import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
-import org.jclouds.openstack.nova.v2_0.predicates.ImagePredicates;
-
-import com.google.common.base.Function;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-
-/**
- * The adapter used by the NovaComputeServiceContextModule to interface the nova-specific domain
- * model to the computeService generic domain model.
- */
-public class NovaComputeServiceAdapter implements
- ComputeServiceAdapter<ServerInZone, FlavorInZone, ImageInZone, Location> {
-
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- protected Logger logger = Logger.NULL;
-
- protected final NovaApi novaApi;
- protected final Supplier<Set<String>> zoneIds;
- protected final RemoveFloatingIpFromNodeAndDeallocate removeFloatingIpFromNodeAndDeallocate;
- protected final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
-
- @Inject
- public NovaComputeServiceAdapter(NovaApi novaApi, @Zone Supplier<Set<String>> zoneIds,
- RemoveFloatingIpFromNodeAndDeallocate removeFloatingIpFromNodeAndDeallocate,
- LoadingCache<ZoneAndName, KeyPair> keyPairCache) {
- this.novaApi = checkNotNull(novaApi, "novaApi");
- this.zoneIds = checkNotNull(zoneIds, "zoneIds");
- this.removeFloatingIpFromNodeAndDeallocate = checkNotNull(removeFloatingIpFromNodeAndDeallocate,
- "removeFloatingIpFromNodeAndDeallocate");
- this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
- }
-
- /**
- * Note that we do not validate extensions here, on basis that
- * {@link ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet} has already
- * done so.
- */
- @Override
- public NodeAndInitialCredentials<ServerInZone> createNodeWithGroupEncodedIntoName(String group, String name,
- Template template) {
-
- LoginCredentials.Builder credentialsBuilder = LoginCredentials.builder();
- NovaTemplateOptions templateOptions = template.getOptions().as(NovaTemplateOptions.class);
-
- CreateServerOptions options = new CreateServerOptions();
- options.metadata(metadataAndTagsAsCommaDelimitedValue(template.getOptions()));
- if (templateOptions.getSecurityGroupNames().isPresent())
- options.securityGroupNames(templateOptions.getSecurityGroupNames().get());
- options.userData(templateOptions.getUserData());
- options.diskConfig(templateOptions.getDiskConfig());
- options.configDrive(templateOptions.getConfigDrive());
- options.availabilityZone(templateOptions.getAvailabilityZone());
- if (templateOptions.getNovaNetworks() != null) {
- options.novaNetworks(templateOptions.getNovaNetworks());
- }
- if (templateOptions.getNetworks() != null) {
- options.networks(templateOptions.getNetworks());
- }
-
- Optional<String> privateKey = Optional.absent();
- if (templateOptions.getKeyPairName() != null) {
- options.keyPairName(templateOptions.getKeyPairName());
- KeyPair keyPair = keyPairCache.getIfPresent(ZoneAndName.fromZoneAndName(template.getLocation().getId(), templateOptions.getKeyPairName()));
- if (keyPair != null && keyPair.getPrivateKey() != null) {
- privateKey = Optional.of(keyPair.getPrivateKey());
- credentialsBuilder.privateKey(privateKey.get());
- }
- }
-
- String zoneId = template.getLocation().getId();
- String imageId = template.getImage().getProviderId();
- String flavorId = template.getHardware().getProviderId();
-
- logger.debug(">> creating new server zone(%s) name(%s) image(%s) flavor(%s) options(%s)", zoneId, name, imageId, flavorId, options);
- ServerCreated lightweightServer = novaApi.getServerApiForZone(zoneId).create(name, imageId, flavorId, options);
- Server server = novaApi.getServerApiForZone(zoneId).get(lightweightServer.getId());
-
- logger.trace("<< server(%s)", server.getId());
-
- ServerInZone serverInZone = new ServerInZone(server, zoneId);
- if (!privateKey.isPresent() && lightweightServer.getAdminPass().isPresent())
- credentialsBuilder.password(lightweightServer.getAdminPass().get());
- return new NodeAndInitialCredentials<ServerInZone>(serverInZone, serverInZone.slashEncode(), credentialsBuilder
- .build());
- }
-
- @Override
- public Iterable<FlavorInZone> listHardwareProfiles() {
- Builder<FlavorInZone> builder = ImmutableSet.builder();
- for (final String zoneId : zoneIds.get()) {
- builder.addAll(transform(novaApi.getFlavorApiForZone(zoneId).listInDetail().concat(),
- new Function<Flavor, FlavorInZone>() {
-
- @Override
- public FlavorInZone apply(Flavor arg0) {
- return new FlavorInZone(arg0, zoneId);
- }
-
- }));
- }
- return builder.build();
- }
-
- @Override
- public Iterable<ImageInZone> listImages() {
- Builder<ImageInZone> builder = ImmutableSet.builder();
- Set<String> zones = zoneIds.get();
- checkState(zones.size() > 0, "no zones found in supplier %s", zoneIds);
- for (final String zoneId : zones) {
- Set<? extends Image> images = novaApi.getImageApiForZone(zoneId).listInDetail().concat().toSet();
- if (images.size() == 0) {
- logger.debug("no images found in zone %s", zoneId);
- continue;
- }
- Iterable<? extends Image> active = filter(images, ImagePredicates.statusEquals(Image.Status.ACTIVE));
- if (images.size() == 0) {
- logger.debug("no images with status active in zone %s; non-active: %s", zoneId,
- transform(active, new Function<Image, String>() {
-
- @Override
- public String apply(Image input) {
- return Objects.toStringHelper("").add("id", input.getId()).add("status", input.getStatus())
- .toString();
- }
-
- }));
- continue;
- }
- builder.addAll(transform(active, new Function<Image, ImageInZone>() {
-
- @Override
- public ImageInZone apply(Image arg0) {
- return new ImageInZone(arg0, zoneId);
- }
-
- }));
- }
- return builder.build();
- }
-
- @Override
- public Iterable<ServerInZone> listNodes() {
- Builder<ServerInZone> builder = ImmutableSet.builder();
- for (final String zoneId : zoneIds.get()) {
- builder.addAll(novaApi.getServerApiForZone(zoneId).listInDetail().concat()
- .transform(new Function<Server, ServerInZone>() {
-
- @Override
- public ServerInZone apply(Server arg0) {
- return new ServerInZone(arg0, zoneId);
- }
-
- }));
- }
- return builder.build();
- }
-
- @Override
- public Iterable<ServerInZone> listNodesByIds(final Iterable<String> ids) {
- return filter(listNodes(), new Predicate<ServerInZone>() {
-
- @Override
- public boolean apply(ServerInZone server) {
- return contains(ids, server.slashEncode());
- }
- });
- }
-
- @Override
- public Iterable<Location> listLocations() {
- // locations provided by keystone
- return ImmutableSet.of();
- }
-
- @Override
- public ServerInZone getNode(String id) {
- ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
- Server server = novaApi.getServerApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
- return server == null ? null : new ServerInZone(server, zoneAndId.getZone());
- }
-
- @Override
- public ImageInZone getImage(String id) {
- ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
- Image image = novaApi.getImageApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
- return image == null ? null : new ImageInZone(image, zoneAndId.getZone());
- }
-
- @Override
- public void destroyNode(String id) {
- ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
- if (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
- try {
- removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
- } catch (RuntimeException e) {
- logger.warn(e, "<< error removing and deallocating ip from node(%s): %s", id, e.getMessage());
- }
- }
- novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
- }
-
- @Override
- public void rebootNode(String id) {
- ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
- novaApi.getServerApiForZone(zoneAndId.getZone()).reboot(zoneAndId.getId(), RebootType.HARD);
- }
-
- @Override
- public void resumeNode(String id) {
- ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
- if (novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).isPresent()) {
- novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).get().resume(zoneAndId.getId());
- } else {
- throw new UnsupportedOperationException("resume requires installation of the Admin Actions extension");
- }
- }
-
- @Override
- public void suspendNode(String id) {
- ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
- if (novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).isPresent()) {
- novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).get().suspend(zoneAndId.getId());
- } else {
- throw new UnsupportedOperationException("suspend requires installation of the Admin Actions extension");
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java
deleted file mode 100644
index e070bdb..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.nova.v2_0.compute.config;
-
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS;
-import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_GENERATE_KEYPAIRS;
-import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.TIMEOUT_SECURITYGROUP_PRESENT;
-import static org.jclouds.util.Predicates2.retry;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.collect.Memoized;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.ComputeServiceAdapter;
-import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.compute.domain.SecurityGroup;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.compute.extensions.SecurityGroupExtension;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.functions.IdentityFunction;
-import org.jclouds.net.domain.IpPermission;
-import org.jclouds.openstack.nova.v2_0.compute.NovaComputeService;
-import org.jclouds.openstack.nova.v2_0.compute.NovaComputeServiceAdapter;
-import org.jclouds.openstack.nova.v2_0.compute.extensions.NovaImageExtension;
-import org.jclouds.openstack.nova.v2_0.compute.extensions.NovaSecurityGroupExtension;
-import org.jclouds.openstack.nova.v2_0.compute.functions.CreateSecurityGroupIfNeeded;
-import org.jclouds.openstack.nova.v2_0.compute.functions.FlavorInZoneToHardware;
-import org.jclouds.openstack.nova.v2_0.compute.functions.ImageInZoneToImage;
-import org.jclouds.openstack.nova.v2_0.compute.functions.ImageToOperatingSystem;
-import org.jclouds.openstack.nova.v2_0.compute.functions.NovaSecurityGroupInZoneToSecurityGroup;
-import org.jclouds.openstack.nova.v2_0.compute.functions.NovaSecurityGroupToSecurityGroup;
-import org.jclouds.openstack.nova.v2_0.compute.functions.OrphanedGroupsByZoneId;
-import org.jclouds.openstack.nova.v2_0.compute.functions.SecurityGroupRuleToIpPermission;
-import org.jclouds.openstack.nova.v2_0.compute.functions.ServerInZoneToNodeMetadata;
-import org.jclouds.openstack.nova.v2_0.compute.loaders.CreateUniqueKeyPair;
-import org.jclouds.openstack.nova.v2_0.compute.loaders.FindSecurityGroupOrCreate;
-import org.jclouds.openstack.nova.v2_0.compute.loaders.LoadFloatingIpsForInstance;
-import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
-import org.jclouds.openstack.nova.v2_0.compute.strategy.ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet;
-import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
-import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
-import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
-import org.jclouds.openstack.nova.v2_0.domain.Server;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.FlavorInZone;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
-import org.jclouds.openstack.nova.v2_0.predicates.FindSecurityGroupWithNameAndReturnTrue;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-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.Maps;
-import com.google.common.collect.Multimap;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.Provides;
-import com.google.inject.TypeLiteral;
-import com.google.inject.name.Names;
-
-/**
- * Module for building a compute service context for Nova
- */
-public class NovaComputeServiceContextModule extends
- ComputeServiceAdapterContextModule<ServerInZone, FlavorInZone, ImageInZone, Location> {
-
- @SuppressWarnings("unchecked")
- @Override
- protected void configure() {
- super.configure();
- bind(new TypeLiteral<ComputeServiceAdapter<ServerInZone, FlavorInZone, ImageInZone, Location>>() {
- }).to(NovaComputeServiceAdapter.class);
-
- bind(ComputeService.class).to(NovaComputeService.class);
-
- bind(new TypeLiteral<Function<ServerInZone, NodeMetadata>>() {
- }).to(ServerInZoneToNodeMetadata.class);
-
- bind(new TypeLiteral<Function<SecurityGroupRule, IpPermission>>() {
- }).to(SecurityGroupRuleToIpPermission.class);
-
- bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroup>>() {
- }).to(NovaSecurityGroupToSecurityGroup.class);
-
- bind(new TypeLiteral<Function<SecurityGroupInZone, SecurityGroup>>() {
- }).to(NovaSecurityGroupInZoneToSecurityGroup.class);
-
- bind(new TypeLiteral<Function<Set<? extends NodeMetadata>, Multimap<String, String>>>() {
- }).to(OrphanedGroupsByZoneId.class);
-
- bind(new TypeLiteral<Function<ImageInZone, Image>>() {
- }).to(ImageInZoneToImage.class);
- bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v2_0.domain.Image, OperatingSystem>>() {
- }).to(ImageToOperatingSystem.class);
-
- bind(new TypeLiteral<Function<FlavorInZone, Hardware>>() {
- }).to(FlavorInZoneToHardware.class);
-
- // we aren't converting location from a provider-specific type
- bind(new TypeLiteral<Function<Location, Location>>() {
- }).to(Class.class.cast(IdentityFunction.class));
-
- bind(TemplateOptions.class).to(NovaTemplateOptions.class);
-
- bind(new TypeLiteral<CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>>>() {
- }).annotatedWith(Names.named("FLOATINGIP")).to(LoadFloatingIpsForInstance.class);
-
- bind(new TypeLiteral<Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>>() {
- }).to(CreateSecurityGroupIfNeeded.class);
-
- bind(new TypeLiteral<CacheLoader<ZoneAndName, SecurityGroupInZone>>() {
- }).to(FindSecurityGroupOrCreate.class);
-
- bind(CreateNodesWithGroupEncodedIntoNameThenAddToSet.class).to(
- ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.class);
-
- bind(new TypeLiteral<CacheLoader<ZoneAndName, KeyPair>>() {
- }).to(CreateUniqueKeyPair.class);
-
- bind(new TypeLiteral<ImageExtension>() {
- }).to(NovaImageExtension.class);
-
- bind(new TypeLiteral<SecurityGroupExtension>() {
- }).to(NovaSecurityGroupExtension.class);
- }
-
- @Override
- protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) {
- return options.as(NovaTemplateOptions.class)
- .autoAssignFloatingIp(injector.getInstance(
- Key.get(boolean.class, Names.named(AUTO_ALLOCATE_FLOATING_IPS))))
- .generateKeyPair(injector.getInstance(
- Key.get(boolean.class, Names.named(AUTO_GENERATE_KEYPAIRS))));
- }
-
- @Provides
- @Singleton
- @Named("FLOATINGIP")
- protected LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> instanceToFloatingIps(
- @Named("FLOATINGIP") CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>> in) {
- return CacheBuilder.newBuilder().build(in);
- }
-
- @Provides
- @Singleton
- protected LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap(
- CacheLoader<ZoneAndName, SecurityGroupInZone> in) {
- return CacheBuilder.newBuilder().build(in);
- }
-
- @Override
- protected Map<OsFamily, LoginCredentials> osFamilyToCredentials(Injector injector) {
- return ImmutableMap.of(OsFamily.WINDOWS, LoginCredentials.builder().user("Administrator").build(),
- OsFamily.UBUNTU, LoginCredentials.builder().user("ubuntu").build());
- }
-
- @Provides
- @Singleton
- @Named("SECURITYGROUP_PRESENT")
- protected Predicate<AtomicReference<ZoneAndName>> securityGroupEventualConsistencyDelay(
- FindSecurityGroupWithNameAndReturnTrue in,
- @Named(TIMEOUT_SECURITYGROUP_PRESENT) long msDelay) {
- return retry(in, msDelay, 100l, MILLISECONDS);
- }
-
- @Provides
- @Singleton
- protected LoadingCache<ZoneAndName, KeyPair> keyPairMap(
- CacheLoader<ZoneAndName, KeyPair> in) {
- return CacheBuilder.newBuilder().build(in);
- }
-
- @Provides
- @Singleton
- protected Supplier<Map<String, Location>> createLocationIndexedById(
- @Memoized Supplier<Set<? extends Location>> locations) {
- return Suppliers.compose(new Function<Set<? extends Location>, Map<String, Location>>() {
-
- @SuppressWarnings("unchecked")
- @Override
- public Map<String, Location> apply(Set<? extends Location> arg0) {
- // TODO: find a nice way to get rid of this cast.
- Iterable<Location> locations = (Iterable<Location>) arg0;
- return Maps.uniqueIndex(locations, new Function<Location, String>() {
-
- @Override
- public String apply(Location arg0) {
- return arg0.getId();
- }
-
- });
- }
- }, locations);
-
- }
-
- @VisibleForTesting
- public static final Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus = ImmutableMap
- .<Server.Status, NodeMetadata.Status> builder()
- .put(Server.Status.ACTIVE, NodeMetadata.Status.RUNNING)
- .put(Server.Status.BUILD, NodeMetadata.Status.PENDING)
- .put(Server.Status.DELETED, NodeMetadata.Status.TERMINATED)
- .put(Server.Status.ERROR, NodeMetadata.Status.ERROR)
- .put(Server.Status.HARD_REBOOT, NodeMetadata.Status.PENDING)
- .put(Server.Status.MIGRATING, NodeMetadata.Status.PENDING)
- .put(Server.Status.PASSWORD, NodeMetadata.Status.PENDING)
- .put(Server.Status.PAUSED, NodeMetadata.Status.SUSPENDED)
- .put(Server.Status.REBOOT, NodeMetadata.Status.PENDING)
- .put(Server.Status.REBUILD, NodeMetadata.Status.PENDING)
- .put(Server.Status.RESCUE, NodeMetadata.Status.PENDING)
- .put(Server.Status.RESIZE, NodeMetadata.Status.PENDING)
- .put(Server.Status.REVERT_RESIZE, NodeMetadata.Status.PENDING)
- .put(Server.Status.SHELVED, NodeMetadata.Status.SUSPENDED)
- .put(Server.Status.SHELVED_OFFLOADED, NodeMetadata.Status.SUSPENDED)
- .put(Server.Status.SHUTOFF, NodeMetadata.Status.SUSPENDED)
- .put(Server.Status.SOFT_DELETED, NodeMetadata.Status.TERMINATED)
- .put(Server.Status.STOPPED, NodeMetadata.Status.SUSPENDED)
- .put(Server.Status.SUSPENDED, NodeMetadata.Status.SUSPENDED)
- .put(Server.Status.UNKNOWN, NodeMetadata.Status.UNRECOGNIZED)
- .put(Server.Status.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED)
- .put(Server.Status.VERIFY_RESIZE, NodeMetadata.Status.PENDING)
- .build();
-
- @Singleton
- @Provides
- protected Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus() {
- return toPortableNodeStatus;
- }
-
- @VisibleForTesting
- public static final Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus = ImmutableMap
- .<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> builder()
- .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.ACTIVE, Image.Status.AVAILABLE)
- .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.SAVING, Image.Status.PENDING)
- .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.DELETED, Image.Status.DELETED)
- .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.ERROR, Image.Status.ERROR)
- .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.UNKNOWN, Image.Status.UNRECOGNIZED)
- .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.UNRECOGNIZED, Image.Status.UNRECOGNIZED).build();
-
- @Singleton
- @Provides
- protected Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus() {
- return toPortableImageStatus;
- }
-
- @Override
- protected Optional<ImageExtension> provideImageExtension(Injector i) {
- return Optional.of(i.getInstance(ImageExtension.class));
- }
-
- @Override
- protected Optional<SecurityGroupExtension> provideSecurityGroupExtension(Injector i) {
- return Optional.of(i.getInstance(SecurityGroupExtension.class));
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java
deleted file mode 100644
index dfee4d1..0000000
--- a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openstack.nova.v2_0.compute.extensions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.Iterables.find;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE;
-import static org.jclouds.location.predicates.LocationPredicates.idEquals;
-
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.Constants;
-import org.jclouds.collect.Memoized;
-import org.jclouds.compute.domain.CloneImageTemplate;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.compute.domain.ImageTemplate;
-import org.jclouds.compute.domain.ImageTemplateBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.domain.Location;
-import org.jclouds.logging.Logger;
-import org.jclouds.openstack.nova.v2_0.NovaApi;
-import org.jclouds.openstack.nova.v2_0.domain.Server;
-import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.util.concurrent.Atomics;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.UncheckedTimeoutException;
-
-/**
- * Nova implementation of {@link ImageExtension}
- */
-@Singleton
-public class NovaImageExtension implements ImageExtension {
-
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- protected Logger logger = Logger.NULL;
-
- private final NovaApi novaApi;
- private final ListeningExecutorService userExecutor;
- private final Supplier<Set<? extends Location>> locations;
- private final Predicate<AtomicReference<Image>> imageAvailablePredicate;
-
- @Inject
- public NovaImageExtension(NovaApi novaApi, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
- @Memoized Supplier<Set<? extends Location>> locations,
- @Named(TIMEOUT_IMAGE_AVAILABLE) Predicate<AtomicReference<Image>> imageAvailablePredicate) {
- this.novaApi = checkNotNull(novaApi, "novaApi");
- this.userExecutor = checkNotNull(userExecutor, "userExecutor");
- this.locations = checkNotNull(locations, "locations");
- this.imageAvailablePredicate = checkNotNull(imageAvailablePredicate, "imageAvailablePredicate");
- }
-
- @Override
- public ImageTemplate buildImageTemplateFromNode(String name, final String id) {
- ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
- Server server = novaApi.getServerApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
- if (server == null)
- throw new NoSuchElementException("Cannot find server with id: " + zoneAndId);
- CloneImageTemplate template = new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name).build();
- return template;
- }
-
- @Override
- public ListenableFuture<Image> createImage(ImageTemplate template) {
- checkState(template instanceof CloneImageTemplate,
- " openstack-nova only supports creating images through cloning.");
- CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
- ZoneAndId sourceImageZoneAndId = ZoneAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId());
-
- String newImageId = novaApi.getServerApiForZone(sourceImageZoneAndId.getZone()).createImageFromServer(
- cloneTemplate.getName(), sourceImageZoneAndId.getId());
-
- final ZoneAndId targetImageZoneAndId = ZoneAndId.fromZoneAndId(sourceImageZoneAndId.getZone(), newImageId);
-
- logger.info(">> Registered new Image %s, waiting for it to become available.", newImageId);
-
- final AtomicReference<Image> image = Atomics.newReference(new ImageBuilder()
- .location(find(locations.get(), idEquals(targetImageZoneAndId.getZone())))
- .id(targetImageZoneAndId.slashEncode())
- .providerId(targetImageZoneAndId.getId())
- .description(cloneTemplate.getName())
- .operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build())
- .status(Image.Status.PENDING).build());
-
- return userExecutor.submit(new Callable<Image>() {
- @Override
- public Image call() throws Exception {
- if (imageAvailablePredicate.apply(image))
- return image.get();
- // TODO: get rid of the expectation that the image will be available, as it is very brittle
- throw new UncheckedTimeoutException("Image was not created within the time limit: " + image.get());
- }
- });
- }
-
- @Override
- public boolean deleteImage(String id) {
- ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
- try {
- this.novaApi.getImageApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
- } catch (Exception e) {
- return false;
- }
- return true;
- }
-
-}