You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/10/05 19:28:10 UTC
[7/9] git commit: Remove nodepool,
which hasn't been published in over a year.
Remove nodepool, which hasn't been published in over a year.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/065071ca
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/065071ca
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/065071ca
Branch: refs/heads/master
Commit: 065071ca8a92fe996d63708715ab13c43ba9fcf9
Parents: 1795ff7
Author: Adrian Cole <ad...@gmail.com>
Authored: Sun Oct 5 09:20:13 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Sun Oct 5 10:22:45 2014 -0700
----------------------------------------------------------------------
nodepool/pom.xml | 146 --------
.../main/java/org/jclouds/nodepool/Backend.java | 38 ---
.../jclouds/nodepool/NodePoolApiMetadata.java | 100 ------
.../nodepool/NodePoolComputeServiceAdapter.java | 44 ---
.../nodepool/NodePoolComputeServiceContext.java | 73 ----
.../org/jclouds/nodepool/NodePoolStats.java | 73 ----
.../config/BindBackendComputeService.java | 338 -------------------
.../BindInputStreamToFilesystemBlobStore.java | 83 -----
.../nodepool/config/BindJcloudsModules.java | 62 ----
.../NodePoolComputeServiceContextModule.java | 71 ----
.../nodepool/config/NodePoolProperties.java | 74 ----
.../BaseNodePoolComputeServiceAdapter.java | 164 ---------
.../EagerNodePoolComputeServiceAdapter.java | 183 ----------
.../internal/JsonNodeMetadataStore.java | 144 --------
.../nodepool/internal/NodeMetadataStore.java | 75 ----
.../internal/NodeMetadataStoreCache.java | 86 -----
.../services/org.jclouds.apis.ApiMetadata | 1 -
.../jclouds/nodepool/BYONBackendLiveTest.java | 108 ------
.../jclouds/nodepool/NodeMetadataStoreTest.java | 138 --------
.../NodePoolComputeServiceContextTest.java | 63 ----
.../NodePoolComputeServiceLiveTest.java | 251 --------------
.../config/BindBackendComputeServiceTest.java | 82 -----
...indInputStreamToFilesystemBlobStoreTest.java | 62 ----
nodepool/src/test/resources/logback.xml | 71 ----
24 files changed, 2530 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/pom.xml
----------------------------------------------------------------------
diff --git a/nodepool/pom.xml b/nodepool/pom.xml
deleted file mode 100644
index 771893d..0000000
--- a/nodepool/pom.xml
+++ /dev/null
@@ -1,146 +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.labs</groupId>
- <artifactId>jclouds-labs</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <!-- TODO: when out of labs, switch to org.jclouds.api? -->
- <groupId>org.apache.jclouds.labs</groupId>
- <artifactId>nodepool</artifactId>
- <name>jclouds nodepool api</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jclouds.nodepool.backend-provider>byon</jclouds.nodepool.backend-provider>
- <jclouds.nodepool.backend-modules>org.jclouds.logging.slf4j.config.SLF4JLoggingModule,org.jclouds.sshj.config.SshjSshClientModule</jclouds.nodepool.backend-modules>
- <test.nodepool.endpoint>FIXME_ENDPOINT</test.nodepool.endpoint>
- <test.nodepool.api-version />
- <test.nodepool.build-version />
- <test.nodepool.identity>FIXME_IDENTITY</test.nodepool.identity>
- <test.nodepool.credential>FIXME_CREDENTIALS</test.nodepool.credential>
- <jclouds.osgi.export>org.jclouds.nodepool*;version="${project.version}"</jclouds.osgi.export>
- <jclouds.osgi.import>
- org.jclouds.rest.internal;version="${project.version}",
- org.jclouds*;version="${project.version}",
- *
- </jclouds.osgi.import>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-compute</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-blobstore</artifactId>
- <version>${project.version}</version>
- </dependency>
- <!-- Add all compute so that we can run tests with any provider -->
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-allcompute</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.api</groupId>
- <artifactId>filesystem</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-compute</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.api</groupId>
- <artifactId>byon</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-core</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-slf4j</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-sshj</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </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.nodepool.endpoint>${test.nodepool.endpoint}</test.nodepool.endpoint>
- <test.nodepool.api-version>${test.nodepool.api-version}</test.nodepool.api-version>
- <test.nodepool.build-version>${test.nodepool.build-version}</test.nodepool.build-version>
- <test.nodepool.identity>${test.nodepool.identity}</test.nodepool.identity>
- <test.nodepool.credential>${test.nodepool.credential}</test.nodepool.credential>
- <jclouds.nodepool.backend-provider>${jclouds.nodepool.backend-provider}</jclouds.nodepool.backend-provider>
- <jclouds.nodepool.backend-modules>${jclouds.nodepool.backend-modules}</jclouds.nodepool.backend-modules>
- </systemPropertyVariables>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/Backend.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/Backend.java b/nodepool/src/main/java/org/jclouds/nodepool/Backend.java
deleted file mode 100644
index c13fa7a..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/Backend.java
+++ /dev/null
@@ -1,38 +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.nodepool;
-
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * Designates that this Resource qualifies an object to the back-end of the pool
- */
-@Target( { ANNOTATION_TYPE, FIELD, METHOD, PARAMETER })
-@Retention(RUNTIME)
-@Qualifier
-public @interface Backend {
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/NodePoolApiMetadata.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/NodePoolApiMetadata.java b/nodepool/src/main/java/org/jclouds/nodepool/NodePoolApiMetadata.java
deleted file mode 100644
index 468da40..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/NodePoolApiMetadata.java
+++ /dev/null
@@ -1,100 +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.nodepool;
-
-import static org.jclouds.nodepool.config.NodePoolProperties.BACKEND_GROUP;
-import static org.jclouds.nodepool.config.NodePoolProperties.BACKEND_MODULES;
-import static org.jclouds.nodepool.config.NodePoolProperties.MAX_SIZE;
-import static org.jclouds.nodepool.config.NodePoolProperties.METADATA_CONTAINER;
-import static org.jclouds.nodepool.config.NodePoolProperties.MIN_SIZE;
-import static org.jclouds.nodepool.config.NodePoolProperties.POOL_ADMIN_ACCESS;
-import static org.jclouds.nodepool.config.NodePoolProperties.REMOVE_DESTROYED;
-
-import java.io.File;
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.apis.internal.BaseApiMetadata;
-import org.jclouds.nodepool.config.BindBackendComputeService;
-import org.jclouds.nodepool.config.BindInputStreamToFilesystemBlobStore;
-import org.jclouds.nodepool.config.NodePoolComputeServiceContextModule;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-
-public class NodePoolApiMetadata extends BaseApiMetadata {
-
- @Override
- public Builder toBuilder() {
- return new Builder().fromApiMetadata(this);
- }
-
- public NodePoolApiMetadata() {
- super(new Builder());
- }
-
- protected NodePoolApiMetadata(Builder builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- Properties properties = BaseRestApiMetadata.defaultProperties();
- properties.setProperty(BACKEND_GROUP, "nodepool");
- properties.setProperty(METADATA_CONTAINER, "nodes");
- properties.setProperty(BACKEND_MODULES,
- "org.jclouds.logging.slf4j.config.SLF4JLoggingModule,org.jclouds.sshj.config.SshjSshClientModule");
- properties.setProperty(MAX_SIZE, 10 + "");
- properties.setProperty(MIN_SIZE, 5 + "");
- properties.setProperty(REMOVE_DESTROYED, "true");
- // by default use the current user's user and private key if one exists, if not the properties
- // will need to be set (no default passwords)
- if (new File(System.getProperty("user.home") + "/.ssh/id_rsa").exists()) {
- properties.setProperty(POOL_ADMIN_ACCESS, "adminUsername=" + System.getProperty("user.name")
- + ",adminPrivateKeyFile=" + System.getProperty("user.home") + "/.ssh/id_rsa");
- }
- return properties;
- }
-
- public static class Builder extends BaseApiMetadata.Builder<Builder> {
- protected Builder() {
- id("nodepool")
- .name("node pool provider wrapper")
- .identityName("backend identity")
- .endpointName("backend endpoint")
- .defaultEndpoint("fixme")
- .documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute"))
- .view(NodePoolComputeServiceContext.class)
- .defaultModules(
- ImmutableSet.<Class<? extends Module>> builder()
- .add(NodePoolComputeServiceContextModule.class)
- .add(BindInputStreamToFilesystemBlobStore.class)
- .add(BindBackendComputeService.class).build())
- .defaultProperties(NodePoolApiMetadata.defaultProperties());
- }
-
- @Override
- public NodePoolApiMetadata build() {
- return new NodePoolApiMetadata(this);
- }
-
- @Override
- protected Builder self() {
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceAdapter.java b/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceAdapter.java
deleted file mode 100644
index aac0c60..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceAdapter.java
+++ /dev/null
@@ -1,44 +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.nodepool;
-
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.JCloudsNativeComputeServiceAdapter;
-import org.jclouds.nodepool.internal.EagerNodePoolComputeServiceAdapter;
-
-import com.google.inject.ImplementedBy;
-
-@ImplementedBy(EagerNodePoolComputeServiceAdapter.class)
-public interface NodePoolComputeServiceAdapter extends JCloudsNativeComputeServiceAdapter {
-
- int idleNodes();
-
- int maxNodes();
-
- int minNodes();
-
- int usedNodes();
-
- int currentSize();
-
- void destroyPool();
-
- ComputeServiceContext getBackendComputeServiceContext();
-
- String getPoolGroupName();
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceContext.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceContext.java b/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceContext.java
deleted file mode 100644
index da498cf..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceContext.java
+++ /dev/null
@@ -1,73 +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.nodepool;
-
-import javax.inject.Singleton;
-
-import org.jclouds.Context;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.Utils;
-import org.jclouds.compute.internal.ComputeServiceContextImpl;
-import org.jclouds.location.Provider;
-
-import com.google.common.reflect.TypeToken;
-import com.google.inject.Inject;
-
-@Singleton
-public class NodePoolComputeServiceContext extends ComputeServiceContextImpl {
-
- private final NodePoolComputeServiceAdapter adapter;
-
- @Inject
- public NodePoolComputeServiceContext(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
- ComputeService computeService, Utils utils, NodePoolComputeServiceAdapter adapter) {
- super(backend, backendType, computeService, utils);
- this.adapter = adapter;
- }
-
- /**
- * Returns the statistics on the pool.
- *
- * @return
- */
- public NodePoolStats getPoolStats() {
- return new NodePoolStats(adapter.currentSize(), adapter.idleNodes(), adapter.usedNodes(), adapter.maxNodes(),
- adapter.minNodes());
- }
-
- /**
- * Destroys all (backing nodes) in the pool and deletes all state.
- */
- public void destroyPool() {
- this.adapter.destroyPool();
- }
-
- /**
- * Returns the backend context.
- *
- * @return
- */
- public ComputeServiceContext getBackendContext() {
- return this.adapter.getBackendComputeServiceContext();
- }
-
- public String getPoolGroupName() {
- return this.adapter.getPoolGroupName();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/NodePoolStats.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/NodePoolStats.java b/nodepool/src/main/java/org/jclouds/nodepool/NodePoolStats.java
deleted file mode 100644
index 07a9dc2..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/NodePoolStats.java
+++ /dev/null
@@ -1,73 +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.nodepool;
-
-/**
- * NodePool statistics and status.
- */
-public class NodePoolStats {
-
- private final int currentSize;
- private final int idleNodes;
- private final int usedNodes;
- private final int maxNodes;
- private final int minNodes;
-
- NodePoolStats(int currentSize, int idleNodes, int usedNodes, int maxNodes, int minNodes) {
- this.currentSize = currentSize;
- this.idleNodes = idleNodes;
- this.usedNodes = usedNodes;
- this.maxNodes = maxNodes;
- this.minNodes = minNodes;
- }
-
- /**
- * The number of nodes currently allocated in the backend provider and in the pool.
- */
- public int currentSize() {
- return currentSize;
- }
-
- /**
- * The number of nodes in the pool not being used.
- */
- public int idleNodes() {
- return idleNodes;
- }
-
- /**
- * The number of nodes in the pool that are currently being used.
- */
- public int usedNodes() {
- return usedNodes;
- }
-
- /**
- * The maximum size the pool will reach.
- */
- public int maxNodes() {
- return maxNodes;
- }
-
- /**
- * The minimum size of the pool.
- */
- public int minNodes() {
- return minNodes;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/config/BindBackendComputeService.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/config/BindBackendComputeService.java b/nodepool/src/main/java/org/jclouds/nodepool/config/BindBackendComputeService.java
deleted file mode 100644
index d581e54..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/config/BindBackendComputeService.java
+++ /dev/null
@@ -1,338 +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.nodepool.config;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static org.jclouds.nodepool.config.NodePoolProperties.BACKEND_GROUP;
-
-import java.net.URI;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.ContextBuilder;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.Image.Status;
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.domain.TemplateBuilder;
-import org.jclouds.compute.domain.TemplateBuilderSpec;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.compute.predicates.NodePredicates;
-import org.jclouds.domain.Credentials;
-import org.jclouds.domain.Location;
-import org.jclouds.internal.FilterStringsBoundToInjectorByName;
-import org.jclouds.lifecycle.Closer;
-import org.jclouds.location.Provider;
-import org.jclouds.nodepool.Backend;
-import org.jclouds.rest.annotations.ApiVersion;
-import org.jclouds.rest.annotations.BuildVersion;
-import org.jclouds.util.Predicates2;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-import com.google.inject.Exposed;
-import com.google.inject.Module;
-import com.google.inject.Provides;
-
-public class BindBackendComputeService extends BindJcloudsModules {
-
- @Provides
- @Singleton
- @Backend
- protected String provideBackendProvider(@Named(NodePoolProperties.BACKEND_PROVIDER) String provider) {
- return provider;
- }
-
- // things wrapped in suppliers are intentional. They can cause network i/o
- // and shouldn't be invoked until after the injector is created.
-
- @Provides
- @Singleton
- @Backend
- @Exposed
- protected Supplier<ComputeService> makeBackendComputeService(@Backend final String provider,
- @Backend final Set<Module> modules, @Provider final Supplier<Credentials> creds,
- @Backend final Supplier<Properties> overrides, final Closer closer) {
- return Suppliers.memoize(new Supplier<ComputeService>() {
-
- @Override
- public ComputeService get() {
- Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null");
- ComputeServiceContext ctx = ContextBuilder.newBuilder(provider)
- .credentials(currentCreds.identity, currentCreds.credential).overrides(overrides.get())
- .modules(modules).buildView(ComputeServiceContext.class);
- closer.addToClose(ctx);
- return ctx.getComputeService();
- }
-
- });
- }
-
- private static final Predicate<String> keys = Predicates.<String>and(
- Predicates.not(Predicates2.startsWith("jclouds.nodepool")),
- Predicates.not(Predicates2.startsWith("nodepool")));
-
- @Provides
- @Singleton
- @Backend
- protected Supplier<Properties> propertiesFor(final FilterStringsBoundToInjectorByName filterStringsBoundByName,
- @Backend final String provider, @Provider final Supplier<URI> endpoint,
- @ApiVersion final String apiVersion, @BuildVersion final String buildVersion) {
- return Suppliers.memoize(new Supplier<Properties>() {
-
- @Override
- public Properties get() {
- Properties props = new Properties();
- props.putAll(filterStringsBoundByName.apply(keys));
- props.put(provider + ".endpoint", endpoint.get().toASCIIString());
- props.put(provider + ".api-version", apiVersion);
- props.put(provider + ".build-version", buildVersion);
- return props;
- }
-
- });
- }
-
- @Provides
- @Exposed
- @Singleton
- protected TemplateBuilder templateBuilder(@Backend final Supplier<ComputeService> compute,
- @Backend final Supplier<Template> template) {
- try {
- // if the backend cannot provide a decent template we'll have problems with looking for
- // images, just provide a custom templatebuilder that returns our custom template.
- compute.get().templateBuilder().build();
- return compute.get().templateBuilder();
- } catch (Exception e) {
- return new TemplateBuilder() {
-
- @Override
- public TemplateBuilder smallest() {
- return this;
- }
-
- @Override
- public TemplateBuilder osVersionMatches(String osVersionRegex) {
- return this;
- }
-
- @Override
- public TemplateBuilder osNameMatches(String osNameRegex) {
- return this;
- }
-
- @Override
- public TemplateBuilder osFamily(OsFamily os) {
- return this;
- }
-
- @Override
- public TemplateBuilder osDescriptionMatches(String osDescriptionRegex) {
- return this;
- }
-
- @Override
- public TemplateBuilder osArchMatches(String architecture) {
- return this;
- }
-
- @Override
- public TemplateBuilder os64Bit(boolean is64bit) {
- return this;
- }
-
- @Override
- public TemplateBuilder options(TemplateOptions options) {
- return this;
- }
-
- @Override
- public TemplateBuilder minRam(int megabytes) {
- return this;
- }
-
- @Override
- public TemplateBuilder minDisk(double gigabytes) {
- return this;
- }
-
- @Override
- public TemplateBuilder minCores(double minCores) {
- return this;
- }
-
- @Override
- public TemplateBuilder locationId(String locationId) {
- return this;
- }
-
- @Override
- public TemplateBuilder imageVersionMatches(String imageVersionRegex) {
- return this;
- }
-
- @Override
- public TemplateBuilder imageNameMatches(String imageNameRegex) {
- return this;
- }
-
- @Override
- public TemplateBuilder imageMatches(Predicate<Image> condition) {
- return this;
- }
-
- @Override
- public TemplateBuilder imageId(String imageId) {
- return this;
- }
-
- @Override
- public TemplateBuilder imageDescriptionMatches(String imageDescriptionRegex) {
- return this;
- }
-
- @Override
- public TemplateBuilder hypervisorMatches(String hypervisorRegex) {
- return this;
- }
-
- @Override
- public TemplateBuilder hardwareId(String hardwareId) {
- return this;
- }
-
- @Override
- public TemplateBuilder fromTemplate(Template image) {
- return this;
- }
-
- @Override
- public TemplateBuilder fromImage(Image image) {
- return this;
- }
-
- @Override
- public TemplateBuilder fromHardware(Hardware hardware) {
- return this;
- }
-
- @Override
- @Beta
- public TemplateBuilder from(String spec) {
- return this;
- }
-
- @Override
- @Beta
- public TemplateBuilder from(TemplateBuilderSpec spec) {
- return this;
- }
-
- @Override
- public TemplateBuilder fastest() {
- return this;
- }
-
- @Override
- public Template build() {
- return template.get();
- }
-
- @Override
- public TemplateBuilder biggest() {
- return this;
- }
-
- @Override
- public TemplateBuilder any() {
- return this;
- }
- };
- }
- }
-
- @Provides
- @Singleton
- @Backend
- @Exposed
- protected Supplier<Template> makeBackendTemplate(@Backend Supplier<ComputeService> compute,
- @Named(BACKEND_GROUP) final String poolGroupPrefix) {
- return Suppliers.memoize(Suppliers.compose(new Function<ComputeService, Template>() {
- @Override
- public Template apply(ComputeService input) {
- try {
- return input.templateBuilder().build();
- } catch (IllegalStateException e) {
- // if there's no template we must be on byon and there must be at least one node in
- // our group
- Set<? extends NodeMetadata> nodes = Sets.filter(input.listNodesDetailsMatching(NodePredicates.all()),
- NodePredicates.inGroup(poolGroupPrefix));
- checkState(!nodes.isEmpty(), "service provided no template and no node was in this nodepool's group.");
- final NodeMetadata node = Iterables.get(nodes, 0);
- final Image image = new ImageBuilder().id(node.getId()).location(node.getLocation())
- .operatingSystem(node.getOperatingSystem()).status(Status.AVAILABLE)
- .description("physical node").build();
- final Hardware hardware = new HardwareBuilder().id(node.getId()).build();
- return new Template() {
-
- @Override
- public Image getImage() {
- return image;
- }
-
- @Override
- public Hardware getHardware() {
- return hardware;
- }
-
- @Override
- public Location getLocation() {
- return node.getLocation();
- }
-
- @Override
- public TemplateOptions getOptions() {
- return new TemplateOptions();
- }
-
- @Override
- public Template clone() {
- return this;
- }
- };
- }
- }
-
- }, compute));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/config/BindInputStreamToFilesystemBlobStore.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/config/BindInputStreamToFilesystemBlobStore.java b/nodepool/src/main/java/org/jclouds/nodepool/config/BindInputStreamToFilesystemBlobStore.java
deleted file mode 100644
index 67c3bad..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/config/BindInputStreamToFilesystemBlobStore.java
+++ /dev/null
@@ -1,83 +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.nodepool.config;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.ContextBuilder;
-import org.jclouds.blobstore.BlobStoreContext;
-import org.jclouds.filesystem.reference.FilesystemConstants;
-import org.jclouds.lifecycle.Closer;
-import org.jclouds.nodepool.Backend;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.inject.Exposed;
-import com.google.inject.Module;
-import com.google.inject.Provides;
-
-public class BindInputStreamToFilesystemBlobStore extends BindJcloudsModules {
-
- @Override
- protected void configure() {
- }
-
- @Provides
- @Singleton
- @Exposed
- @Named("METADATA")
- protected Supplier<Map<String, InputStream>> provideInputStreamMapFromBlobStore(Supplier<BlobStoreContext> in,
- @Named(NodePoolProperties.METADATA_CONTAINER) final String container) {
- return Suppliers.ofInstance(new Function<BlobStoreContext, Map<String, InputStream>>() {
- @Override
- public Map<String, InputStream> apply(BlobStoreContext input) {
- input.getBlobStore().createContainerInLocation(null, container);
- return input.createInputStreamMap(container);
- }
-
- }.apply(in.get()));
- }
-
- @Provides
- @Singleton
- protected Supplier<BlobStoreContext> makeBlobStoreContext(@Named(NodePoolProperties.BASEDIR) final String basedir,
- @Backend final Set<Module> modules, final Closer closer) {
- final Properties overrides = new Properties();
- overrides.setProperty(FilesystemConstants.PROPERTY_BASEDIR, basedir);
- return Suppliers.memoize(new Supplier<BlobStoreContext>() {
-
- @Override
- public BlobStoreContext get() {
- // GAE alert!
- new File(basedir).mkdirs();
- BlobStoreContext returnVal = ContextBuilder.newBuilder("filesystem").overrides(overrides).modules(modules)
- .buildView(BlobStoreContext.class);
- closer.addToClose(returnVal);
- return returnVal;
- }
-
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/config/BindJcloudsModules.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/config/BindJcloudsModules.java b/nodepool/src/main/java/org/jclouds/nodepool/config/BindJcloudsModules.java
deleted file mode 100644
index 8225e94..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/config/BindJcloudsModules.java
+++ /dev/null
@@ -1,62 +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.nodepool.config;
-
-import java.util.Set;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.nodepool.Backend;
-
-import com.google.common.base.Function;
-import com.google.common.base.Splitter;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.inject.Module;
-import com.google.inject.PrivateModule;
-import com.google.inject.Provides;
-
-public class BindJcloudsModules extends PrivateModule {
-
- @Override
- protected void configure() {
- }
-
- @Provides
- @Singleton
- @Backend
- protected Set<Module> provideBackendModules(@Named(NodePoolProperties.BACKEND_MODULES) String moduleString) {
- return ImmutableSet.copyOf(Iterables.transform(Splitter.on(',').split(moduleString),
- new Function<String, Module>() {
-
- @Override
- public Module apply(String input) {
- try {
- return Module.class.cast(Class.forName(input).newInstance());
- } catch (InstantiationException e) {
- throw Throwables.propagate(e);
- } catch (IllegalAccessException e) {
- throw Throwables.propagate(e);
- } catch (ClassNotFoundException e) {
- throw Throwables.propagate(e);
- }
- }
- }));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/config/NodePoolComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/config/NodePoolComputeServiceContextModule.java b/nodepool/src/main/java/org/jclouds/nodepool/config/NodePoolComputeServiceContextModule.java
deleted file mode 100644
index e047371..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/config/NodePoolComputeServiceContextModule.java
+++ /dev/null
@@ -1,71 +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.nodepool.config;
-
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.nodepool.NodePoolApiMetadata;
-import org.jclouds.nodepool.NodePoolComputeServiceAdapter;
-import org.jclouds.nodepool.NodePoolComputeServiceContext;
-import org.jclouds.nodepool.internal.JsonNodeMetadataStore;
-import org.jclouds.nodepool.internal.NodeMetadataStore;
-
-import com.google.common.base.Function;
-import com.google.inject.TypeLiteral;
-
-public class NodePoolComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule {
-
- private static class NullCredentialsOverrider implements Function<Template, LoginCredentials> {
-
- @Override
- @Nullable
- public LoginCredentials apply(@Nullable Template input) {
- return null;
- }
-
- }
-
- public NodePoolComputeServiceContextModule() {
- super(NodePoolComputeServiceAdapter.class);
- }
-
- @Override
- protected void configure() {
- super.configure();
- bind(NodeMetadataStore.class).to(JsonNodeMetadataStore.class);
- bind(ApiMetadata.class).to(NodePoolApiMetadata.class);
- bind(ComputeServiceContext.class).to(NodePoolComputeServiceContext.class);
- install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {
- });
-
- }
-
- @Override
- protected void bindCredentialsOverriderFunction() {
- bind(new TypeLiteral<Function<Template, LoginCredentials>>() {
- }).to(NullCredentialsOverrider.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/config/NodePoolProperties.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/config/NodePoolProperties.java b/nodepool/src/main/java/org/jclouds/nodepool/config/NodePoolProperties.java
deleted file mode 100644
index fb3e7d4..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/config/NodePoolProperties.java
+++ /dev/null
@@ -1,74 +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.nodepool.config;
-
-/**
- * Constants for the {@link org.jclouds.nodepool.NodePoolComputeService}.
- */
-public interface NodePoolProperties {
-
- /**
- * Property to set the name of the backend group used for pooled nodes.
- */
- public static final String BACKEND_GROUP = "jclouds.nodepool.backend-group";
-
- /**
- * Property to set the {@link AdminAccess} that will be installed in the nodes pre-frontend
- * allocation.
- *
- * @see AdminAccessBuilderSpec for details on the format
- */
- public static final String POOL_ADMIN_ACCESS = "jclouds.nodepool.admin-access";
-
- /**
- * Property to set the provider or api of backend the pool
- */
- public static final String BACKEND_PROVIDER = "jclouds.nodepool.backend-provider";
-
- /**
- * Property to set the modules the backend will use for ssh and logging, comma delimited
- */
- public static final String BACKEND_MODULES = "jclouds.nodepool.backend-modules";
-
- /**
- * Property to set the basedir where metadata will be stored
- */
- public static final String BASEDIR = "jclouds.nodepool.basedir";
-
- /**
- * Property to set the container where metadata will be stored
- */
- public static final String METADATA_CONTAINER = "jclouds.nodepool.metadata-container";
-
- /**
- * Property to set the maximum size of the pool. Set this to {@literal -1} to have an unlimited
- * pool size.
- */
- public static final String MAX_SIZE = "jclouds.nodepool.max-size";
-
- /**
- * Property to set the minimum (initial) size of the pool.
- */
- public static final String MIN_SIZE = "jclouds.nodepool.min-size";
-
- /**
- * Property to set the pool behaviour to remove destroyed nodes rather than returning them to the
- * pool for re-use.
- */
- public static final String REMOVE_DESTROYED = "jclouds.nodepool.remove-destroyed";
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/internal/BaseNodePoolComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/internal/BaseNodePoolComputeServiceAdapter.java b/nodepool/src/main/java/org/jclouds/nodepool/internal/BaseNodePoolComputeServiceAdapter.java
deleted file mode 100644
index 336d90e..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/internal/BaseNodePoolComputeServiceAdapter.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.nodepool.internal;
-
-import static org.jclouds.nodepool.config.NodePoolProperties.BACKEND_GROUP;
-import static org.jclouds.nodepool.config.NodePoolProperties.POOL_ADMIN_ACCESS;
-
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import javax.inject.Named;
-
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.RunNodesException;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.predicates.NodePredicates;
-import org.jclouds.domain.Location;
-import org.jclouds.nodepool.Backend;
-import org.jclouds.nodepool.NodePoolComputeServiceAdapter;
-import org.jclouds.scriptbuilder.statements.login.AdminAccess;
-import org.jclouds.scriptbuilder.statements.login.AdminAccessBuilderSpec;
-
-import com.google.common.base.Supplier;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-/**
- * A base class for {@link NodePoolComputeService}, takes care of keeping (not changing assignments)
- * and of everything that does not change the pool.
- */
-public abstract class BaseNodePoolComputeServiceAdapter implements NodePoolComputeServiceAdapter {
-
- protected final Supplier<ComputeService> backendComputeService;
- protected final Supplier<Template> backendTemplate;
- protected final String poolGroupName;
- protected final NodeMetadataStore metadataStore;
- protected final AdminAccess.Builder initialCredentialsBuilder;
-
- public BaseNodePoolComputeServiceAdapter(@Backend Supplier<ComputeService> backendComputeService,
-
- @Backend Supplier<Template> backendTemplate, @Named(BACKEND_GROUP) String poolGroupName,
-
- NodeMetadataStore metadataStore, @Named(POOL_ADMIN_ACCESS) String poolNodeAdminAccess,
- AdminAccess.Configuration configuration) {
- this.backendComputeService = backendComputeService;
- this.poolGroupName = poolGroupName;
- this.backendTemplate = backendTemplate;
- this.metadataStore = metadataStore;
- this.initialCredentialsBuilder = AdminAccessBuilderSpec.parse(poolNodeAdminAccess).copyTo(
- new AdminAccess.Builder());
- }
-
- @Override
- public NodeMetadata getNode(String id) {
- NodeMetadata backendMetadata = backendComputeService.get().getNodeMetadata(id);
- if (backendMetadata == null) {
- return null;
- }
- return metadataStore.load(backendMetadata);
- }
-
- @Override
- public Iterable<NodeMetadata> listNodes() {
- return metadataStore.loadAll(getBackendNodes());
- }
-
- @Override
- public Iterable<Hardware> listHardwareProfiles() {
- return ImmutableSet.of(backendTemplate.get().getHardware());
- }
-
- @Override
- public Iterable<Image> listImages() {
- return ImmutableSet.of(backendTemplate.get().getImage());
-
- }
-
- @Override
- public Iterable<Location> listLocations() {
- return ImmutableSet.of(backendTemplate.get().getLocation());
- }
-
- @Override
- public Image getImage(String id) {
- Image backendImage = backendTemplate.get().getImage();
- return backendImage.getId().equals(id) ? backendImage : null;
- }
-
- @Override
- public void suspendNode(String id) {
- if (getNode(id) != null) {
- backendComputeService.get().suspendNode(id);
- }
- throw new NoSuchElementException(id);
- }
-
- @Override
- public void resumeNode(String id) {
- if (getNode(id) != null) {
- backendComputeService.get().resumeNode(id);
- }
- throw new NoSuchElementException(id);
- }
-
- @Override
- public void rebootNode(String id) {
- if (getNode(id) != null) {
- backendComputeService.get().rebootNode(id);
- }
- throw new NoSuchElementException(id);
- }
-
- protected Set<NodeMetadata> getBackendNodes() {
- return ImmutableSet.copyOf(Iterables.filter(
- backendComputeService.get().listNodesDetailsMatching(NodePredicates.all()),
- NodePredicates.inGroup(poolGroupName)));
- }
-
- @Override
- public void destroyPool() {
- metadataStore.deleteAllMappings();
- backendComputeService.get().destroyNodesMatching(NodePredicates.inGroup(poolGroupName));
- }
-
- @Override
- public ComputeServiceContext getBackendComputeServiceContext() {
- return backendComputeService.get().getContext();
- }
-
- protected Set<? extends NodeMetadata> addToPool(int number) {
- try {
- Template template = backendTemplate.get().clone();
- template.getOptions().runScript(initialCredentialsBuilder.build());
- return backendComputeService.get().createNodesInGroup(poolGroupName, number, template);
- } catch (RunNodesException e) {
- throw Throwables.propagate(e);
- }
- }
-
- @Override
- public String getPoolGroupName() {
- return this.poolGroupName;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/internal/EagerNodePoolComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/internal/EagerNodePoolComputeServiceAdapter.java b/nodepool/src/main/java/org/jclouds/nodepool/internal/EagerNodePoolComputeServiceAdapter.java
deleted file mode 100644
index 90780ca..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/internal/EagerNodePoolComputeServiceAdapter.java
+++ /dev/null
@@ -1,183 +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.nodepool.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static org.jclouds.nodepool.config.NodePoolProperties.BACKEND_GROUP;
-import static org.jclouds.nodepool.config.NodePoolProperties.MAX_SIZE;
-import static org.jclouds.nodepool.config.NodePoolProperties.MIN_SIZE;
-import static org.jclouds.nodepool.config.NodePoolProperties.POOL_ADMIN_ACCESS;
-import static org.jclouds.nodepool.config.NodePoolProperties.REMOVE_DESTROYED;
-
-import java.util.Set;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.logging.Logger;
-import org.jclouds.nodepool.Backend;
-import org.jclouds.scriptbuilder.statements.login.AdminAccess;
-
-import com.google.common.base.Supplier;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-import com.google.common.collect.Sets.SetView;
-
-/**
- * An eager {@link NodePoolComputeService}. Eagerly builds and maintains a pool of nodes. It's only
- * "started" after min nodes are allocated and available.
- */
-@Singleton
-public class EagerNodePoolComputeServiceAdapter extends BaseNodePoolComputeServiceAdapter {
-
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- protected Logger logger = Logger.NULL;
-
- private final int maxSize;
- private final int minSize;
- private final boolean removeDestroyed;
-
- @Inject
- public EagerNodePoolComputeServiceAdapter(@Backend Supplier<ComputeService> backendComputeService,
- @Backend Supplier<Template> backendTemplate, @Named(BACKEND_GROUP) String poolGroupPrefix,
- @Named(MAX_SIZE) int maxSize, @Named(MIN_SIZE) int minSize,
- @Named(REMOVE_DESTROYED) boolean removeDestroyed, NodeMetadataStore storage,
- @Named(POOL_ADMIN_ACCESS) String poolNodeAdminAccess, AdminAccess.Configuration configuration) {
- super(backendComputeService, backendTemplate, poolGroupPrefix, storage, poolNodeAdminAccess, configuration);
- this.maxSize = maxSize;
- this.minSize = minSize;
- this.removeDestroyed = removeDestroyed;
- }
-
- @PostConstruct
- public void startEagerPool() {
- Set<? extends NodeMetadata> backendNodes = getBackendNodes();
- int currentNodes = backendNodes.size();
- int newNodes = backendNodes.size() < minSize ? minSize - backendNodes.size() : 0;
- logger.info(
- ">> initializing nodepool [backend provider: %s]. [existing nodes: %s, min nodes: %s, allocating: %s ]",
- backendComputeService.get().getClass().getSimpleName(), currentNodes, minSize, newNodes);
- if (backendNodes.size() < minSize) {
- addToPool(minSize - backendNodes.size());
- }
- logger.info("<< pool initialized.");
- }
-
- @Override
- public NodeWithInitialCredentials createNodeWithGroupEncodedIntoName(String group, String name, Template template) {
- int count = 1;
- synchronized (this) {
- TemplateOptions options = template.getOptions().clone();
-
- // if no user is provided we set the pool's user
- if (options.getLoginUser() == null) {
- options.overrideLoginCredentials(LoginCredentials.fromCredentials(checkNotNull(initialCredentialsBuilder
- .build().getAdminCredentials())));
- }
-
- logger.info(">> assigning pool node to frontend group %s", group);
- Set<NodeMetadata> backendNodes = getBackendNodes();
- checkState(!backendNodes.isEmpty());
- Set<NodeMetadata> frontendNodes = metadataStore.loadAll(backendNodes);
- checkState(frontendNodes.size() + count <= maxSize,
- "cannot add more nodes to pool [requested: %s, current: %s, max: %s]", count, frontendNodes.size(),
- maxSize);
-
- SetView<NodeMetadata> availableNodes = Sets.difference(backendNodes, frontendNodes);
-
- if (availableNodes.size() < 1) {
- if (backendNodes.size() < maxSize && backendNodes.size() + count <= maxSize) {
- logger.info(
- ">> all pool nodes are assigned, requiring additional nodes [requested: %s, current: %s, next: %s, max: %s]",
- count, frontendNodes.size(), frontendNodes.size() + 1, maxSize);
- addToPool(count);
- // update backend and available sets, no need to update frontend
- backendNodes = getBackendNodes();
- availableNodes = Sets.difference(backendNodes, frontendNodes);
- logger.info("<< additional nodes added to the pool and ready");
- } else {
- logger.error("maximum pool size reached (%s)", maxSize);
- throw new IllegalStateException(String.format("maximum pool size reached (%s)", maxSize));
- }
- }
- NodeMetadata userNode = Iterables.get(availableNodes, 0);
- NodeMetadata node = metadataStore.store(userNode, options, group);
- logger.info("pool node assigned");
- return new NodeWithInitialCredentials(node);
- }
- }
-
- @Override
- public synchronized void destroyNode(String id) {
- checkState(getNode(id) != null);
- logger.info(">> destroying node %s", id);
- metadataStore.deleteMapping(id);
- if (removeDestroyed) {
- backendComputeService.get().destroyNode(id);
- if (currentSize() < minSize) {
- logger.info(">> policy is remove destroyed node and pool "
- + "would fall below minsize, replacing node with id %s", id);
- Set<? extends NodeMetadata> replacement = addToPool(1);
- logger.info("<< node %s replaced with %s", id, Iterables.getOnlyElement(replacement));
- }
- }
- // TODO we should allow the user to hook a way to "clean" the node
- else {
-
- }
- logger.info("<< node destroyed %s", id);
- }
-
- @Override
- public int currentSize() {
- return getBackendNodes().size();
- }
-
- @Override
- public int idleNodes() {
- Set<NodeMetadata> backendNodes = getBackendNodes();
- Set<NodeMetadata> frontendNodes = metadataStore.loadAll(backendNodes);
- return backendNodes.size() - frontendNodes.size();
- }
-
- @Override
- public int maxNodes() {
- return maxSize;
- }
-
- @Override
- public int minNodes() {
- return minSize;
- }
-
- @Override
- public int usedNodes() {
- return metadataStore.loadAll(getBackendNodes()).size();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/internal/JsonNodeMetadataStore.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/internal/JsonNodeMetadataStore.java b/nodepool/src/main/java/org/jclouds/nodepool/internal/JsonNodeMetadataStore.java
deleted file mode 100644
index 9150fe1..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/internal/JsonNodeMetadataStore.java
+++ /dev/null
@@ -1,144 +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.nodepool.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Named;
-
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.json.Json;
-import org.jclouds.util.Strings2;
-
-import com.google.common.base.Supplier;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-/**
- * An implementation of {@link NodeMetadataStore} that stores all that is needed by building a json
- * string.
- */
-@Singleton
-public class JsonNodeMetadataStore implements NodeMetadataStore {
-
- private Supplier<Map<String, InputStream>> storage;
- private final Json json;
-
- private static class JsonUserNodeMetadata {
- private String group;
- private Set<String> tags;
- private Map<String, String> userMetadata;
- private String user;
- private String password;
- private String privateKey;
- private boolean authenticateSudo;
- }
-
- @Inject
- public JsonNodeMetadataStore(@Named("METADATA") Supplier<Map<String, InputStream>> storage, Json json) {
- this.storage = storage;
- this.json = json;
- }
-
- @Override
- public NodeMetadata store(NodeMetadata backendNodeMetadata, TemplateOptions userOptions, String userGroup) {
- checkNotNull(backendNodeMetadata);
- checkNotNull(userGroup);
- checkNotNull(userOptions);
- checkNotNull(userOptions.getLoginUser());
- checkState(userOptions.getLoginPassword() != null || userOptions.getLoginPrivateKey() != null);
- JsonUserNodeMetadata jsonMetadata = new JsonUserNodeMetadata();
- jsonMetadata.user = userOptions.getLoginUser();
- jsonMetadata.password = userOptions.getLoginPassword();
- jsonMetadata.privateKey = userOptions.getLoginPrivateKey();
- jsonMetadata.authenticateSudo = userOptions.shouldAuthenticateSudo() != null ? userOptions
- .shouldAuthenticateSudo().booleanValue() : false;
- jsonMetadata.userMetadata = userOptions.getUserMetadata();
- jsonMetadata.tags = userOptions.getTags();
- jsonMetadata.group = userGroup;
- storage.get().put(backendNodeMetadata.getId(), Strings2.toInputStream(json.toJson(jsonMetadata)));
- return buildFromJsonAndBackendMetadata(backendNodeMetadata, jsonMetadata);
- }
-
- @Override
- public NodeMetadata load(NodeMetadata backendNodeMetadata) {
- try {
- InputStream storedMetadata = storage.get().get(checkNotNull(backendNodeMetadata).getId());
- if (storedMetadata == null) {
- return null;
- }
- String jsonMetadataAsString = Strings2.toStringAndClose(storedMetadata);
- JsonUserNodeMetadata jsonMetadata = json.fromJson(jsonMetadataAsString, JsonUserNodeMetadata.class);
- return buildFromJsonAndBackendMetadata(backendNodeMetadata, jsonMetadata);
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-
- @Override
- public Set<NodeMetadata> loadAll(Set<NodeMetadata> backendNodes) {
- if (backendNodes == null || backendNodes.isEmpty()) {
- return ImmutableSet.of();
- }
- final Set<NodeMetadata> loadedSet = Sets.newLinkedHashSet();
- for (NodeMetadata input : backendNodes) {
- NodeMetadata loaded = load(input);
- if (loaded != null) {
- loadedSet.add(loaded);
- }
-
- }
- return loadedSet;
- }
-
- private NodeMetadata buildFromJsonAndBackendMetadata(NodeMetadata backendNodeMetadata,
- JsonUserNodeMetadata jsonMetadata) {
- return NodeMetadataBuilder
- .fromNodeMetadata(backendNodeMetadata)
- .tags(jsonMetadata.tags)
- .group(jsonMetadata.group)
- .userMetadata(jsonMetadata.userMetadata)
- .credentials(LoginCredentials.builder()
- .user(jsonMetadata.user)
- .privateKey(jsonMetadata.privateKey)
- .password(jsonMetadata.password)
- .authenticateSudo(jsonMetadata.authenticateSudo).build()).build();
- }
-
- @Override
- public void deleteAllMappings() {
- storage.get().clear();
- }
-
- @Override
- public void deleteMapping(String backendNodeId) {
- storage.get().remove(backendNodeId);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/internal/NodeMetadataStore.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/internal/NodeMetadataStore.java b/nodepool/src/main/java/org/jclouds/nodepool/internal/NodeMetadataStore.java
deleted file mode 100644
index 04d3766..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/internal/NodeMetadataStore.java
+++ /dev/null
@@ -1,75 +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.nodepool.internal;
-
-import java.util.Set;
-
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.options.TemplateOptions;
-
-/**
- * Stores/Loads frontend {@link NodeMetadata} mappings.
- */
-public interface NodeMetadataStore {
-
- /**
- * Associates the provided user options and group with the provided backend {@link NodeMetadata},
- * then build a frontend version of node metadata that has some fields from the backend node such
- * as id, name or location, and some fields from the provided userOptions, such as userMetadata
- * or tags.
- *
- * @param backendNode
- * the backend node's {@link NodeMetadata}
- * @param userOptions
- * the user provided options
- * @param userGroup
- * the user selected group
- * @return a version of NodeMetadata that includes information from the backend node and form the
- * user provided options and group.
- */
- public NodeMetadata store(NodeMetadata backendNode, TemplateOptions userOptions, String userGroup);
-
- /**
- * Removes the mapping from storage.
- *
- * @param backendNodeId
- */
- public void deleteMapping(String backendNodeId);
-
- /**
- * Clears all mappings.
- */
- public void deleteAllMappings();
-
- /**
- * Loads the previously stored user {@link NodeMetadata} corresponding to the provided backend
- * {@link NodeMetadata}.
- *
- * @param backendNode
- *
- * @return the frontend {@link NodeMetadata} or null of this backend node has no mapping
- */
- public NodeMetadata load(NodeMetadata backendNode);
-
- /**
- * Loads frontend {@link NodeMetadata} for all provided backend nodes.
- *
- * @param backendNodes
- * @return
- */
- public Set<NodeMetadata> loadAll(Set<NodeMetadata> backendNodes);
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/java/org/jclouds/nodepool/internal/NodeMetadataStoreCache.java
----------------------------------------------------------------------
diff --git a/nodepool/src/main/java/org/jclouds/nodepool/internal/NodeMetadataStoreCache.java b/nodepool/src/main/java/org/jclouds/nodepool/internal/NodeMetadataStoreCache.java
deleted file mode 100644
index 34e3fc9..0000000
--- a/nodepool/src/main/java/org/jclouds/nodepool/internal/NodeMetadataStoreCache.java
+++ /dev/null
@@ -1,86 +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.nodepool.internal;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.options.TemplateOptions;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-
-@Singleton
-public class NodeMetadataStoreCache implements NodeMetadataStore {
-
- private Map<String, NodeMetadata> frontendMetadataCache = Maps.newHashMap();
- private NodeMetadataStore backend;
-
- @Inject
- public NodeMetadataStoreCache(NodeMetadataStore backend) {
- this.backend = backend;
- }
-
- @Override
- public synchronized NodeMetadata store(NodeMetadata backendNode, TemplateOptions userOptions, String userGroup) {
- NodeMetadata frontEndNode = backend.store(backendNode, userOptions, userGroup);
- frontendMetadataCache.put(backendNode.getId(), frontEndNode);
- return frontEndNode;
- }
-
- @Override
- public synchronized void deleteMapping(String backendNodeId) {
- frontendMetadataCache.remove(backendNodeId);
- backend.deleteMapping(backendNodeId);
-
- }
-
- @Override
- public synchronized void deleteAllMappings() {
- frontendMetadataCache.clear();
- backend.deleteAllMappings();
- }
-
- @Override
- public synchronized NodeMetadata load(NodeMetadata backendNode) {
- NodeMetadata frontendNode = frontendMetadataCache.get(backendNode.getId());
- if (frontendNode == null) {
- frontendNode = backend.load(backendNode);
- if (frontendNode != null) {
- frontendMetadataCache.put(backendNode.getId(), frontendNode);
- }
- }
- return frontendNode;
- }
-
- @Override
- public synchronized Set<NodeMetadata> loadAll(Set<NodeMetadata> backendNodes) {
- return ImmutableSet.copyOf(Iterables.transform(backendNodes, new Function<NodeMetadata, NodeMetadata>() {
- @Override
- public NodeMetadata apply(NodeMetadata input) {
- return load(input);
- }
- }));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
----------------------------------------------------------------------
diff --git a/nodepool/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/nodepool/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
deleted file mode 100644
index 64dfe90..0000000
--- a/nodepool/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
+++ /dev/null
@@ -1 +0,0 @@
-org.jclouds.nodepool.NodePoolApiMetadata
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/test/java/org/jclouds/nodepool/BYONBackendLiveTest.java
----------------------------------------------------------------------
diff --git a/nodepool/src/test/java/org/jclouds/nodepool/BYONBackendLiveTest.java b/nodepool/src/test/java/org/jclouds/nodepool/BYONBackendLiveTest.java
deleted file mode 100644
index 674917e..0000000
--- a/nodepool/src/test/java/org/jclouds/nodepool/BYONBackendLiveTest.java
+++ /dev/null
@@ -1,108 +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.nodepool;
-
-import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
-import static org.jclouds.nodepool.config.NodePoolProperties.BACKEND_PROVIDER;
-import static org.jclouds.nodepool.config.NodePoolProperties.BASEDIR;
-import static org.jclouds.nodepool.config.NodePoolProperties.MAX_SIZE;
-import static org.jclouds.nodepool.config.NodePoolProperties.MIN_SIZE;
-import static org.jclouds.nodepool.config.NodePoolProperties.REMOVE_DESTROYED;
-import static org.jclouds.scriptbuilder.domain.Statements.exec;
-
-import java.io.File;
-import java.util.Properties;
-import java.util.Set;
-
-import org.jclouds.compute.domain.ExecResponse;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
-import org.jclouds.scriptbuilder.domain.OsFamily;
-import org.jclouds.sshj.config.SshjSshClientModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-import com.google.inject.Module;
-
-@Test(groups = "live", testName = "BYONBackendLiveTest")
-public class BYONBackendLiveTest extends BaseComputeServiceContextLiveTest {
-
- final String basedir = "target/" + this.getClass().getSimpleName();
-
- public BYONBackendLiveTest() {
- provider = "nodepool";
- }
-
- @Override
- protected Properties setupProperties() {
-
- Properties contextProperties = super.setupProperties();
-
- contextProperties.setProperty(BACKEND_PROVIDER, "byon");
- contextProperties.setProperty(BASEDIR, basedir);
- contextProperties.setProperty(MAX_SIZE, 1 + "");
- contextProperties.setProperty(MIN_SIZE, 1 + "");
- contextProperties.setProperty(REMOVE_DESTROYED, false + "");
- contextProperties.setProperty("nodepool.identity", System.getProperty("user.name"));
-
- StringBuilder nodes = new StringBuilder();
- nodes.append("nodes:\n");
- nodes.append(" - id: mymachine\n");
- nodes.append(" location_id: localhost\n");
- nodes.append(" name: my local machine\n");
- nodes.append(" hostname: localhost\n");
- nodes.append(" os_arch: ").append(System.getProperty("os.arch")).append("\n");
- nodes.append(" os_family: ").append(OsFamily.UNIX).append("\n");
- nodes.append(" os_description: ").append(System.getProperty("os.name")).append("\n");
- nodes.append(" os_version: ").append(System.getProperty("os.version")).append("\n");
- nodes.append(" group: ").append("nodepool").append("\n");
- nodes.append(" tags:\n");
- nodes.append(" - local\n");
- nodes.append(" username: ").append(System.getProperty("user.name")).append("\n");
- nodes.append(" credential_url: file://").append(System.getProperty("user.home")).append("/.ssh/id_rsa")
- .append("\n");
-
- contextProperties.setProperty("byon.nodes", nodes.toString());
- contextProperties.setProperty("byon.template", "locationId=localhost");
- return contextProperties;
- }
-
- @Override
- protected Module getSshModule() {
- return new SshjSshClientModule();
- }
-
- @Test(groups = "live")
- public void testCanRunCommandAsCurrentUser() throws Exception {
- Set<? extends NodeMetadata> nodes = view.getComputeService().createNodesInGroup("goo", 1);
- NodeMetadata node = Iterables.get(nodes, 0);
-
- try {
- ExecResponse response = view.getComputeService().runScriptOnNode(node.getId(), exec("id"),
- wrapInInitScript(false).runAsRoot(false));
- assert response.getOutput().trim().contains(System.getProperty("user.name")) : node + ": " + response;
- } finally {
- view.getComputeService().destroyNode(node.getId());
- }
- }
-
- @Override
- protected void tearDownContext() {
- super.tearDownContext();
- new File(basedir).delete();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/065071ca/nodepool/src/test/java/org/jclouds/nodepool/NodeMetadataStoreTest.java
----------------------------------------------------------------------
diff --git a/nodepool/src/test/java/org/jclouds/nodepool/NodeMetadataStoreTest.java b/nodepool/src/test/java/org/jclouds/nodepool/NodeMetadataStoreTest.java
deleted file mode 100644
index a1b5238..0000000
--- a/nodepool/src/test/java/org/jclouds/nodepool/NodeMetadataStoreTest.java
+++ /dev/null
@@ -1,138 +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.nodepool;
-
-import static org.jclouds.nodepool.config.NodePoolProperties.POOL_ADMIN_ACCESS;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import org.jclouds.Context;
-import org.jclouds.ContextBuilder;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
-import org.jclouds.nodepool.config.NodePoolProperties;
-import org.jclouds.nodepool.internal.NodeMetadataStore;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.io.Files;
-import com.google.inject.Injector;
-
-@Test(groups = "unit", testName = "NodeMetadataStoreTest")
-public class NodeMetadataStoreTest {
-
- @Inject
- NodeMetadataStore store;
-
- private String baseDir;
- private NodeMetadata nodeMeta1;
- private NodeMetadata nodeMeta2;
- private TemplateOptions templateOptions;
-
- @BeforeMethod
- public void setUp() {
- Injector injector = createInjector();
- injector.injectMembers(this);
- this.nodeMeta1 = new NodeMetadataBuilder().id("testmeta1").status(Status.ERROR).build();
- this.nodeMeta2 = new NodeMetadataBuilder().id("testmeta2").status(Status.ERROR).build();
- this.templateOptions = new TemplateOptions().overrideLoginUser("testuser").overrideLoginPassword("testpass")
- .overrideAuthenticateSudo(true).userMetadata("testmetakey", "testmetavalue")
- .overrideLoginPrivateKey("pk").userMetadata("testmetakey2", "testmetavalue2")
- .tags(ImmutableList.of("tag1", "tag2"));
- }
-
- protected Injector createInjector() {
- this.baseDir = "target/nodemetadatastoretest";
- Properties overrides = new Properties();
- overrides.setProperty(NodePoolProperties.BACKEND_PROVIDER, "stub");
- overrides.setProperty(NodePoolProperties.MIN_SIZE, "0");
- overrides.setProperty(NodePoolProperties.BASEDIR, baseDir);
- overrides.setProperty(POOL_ADMIN_ACCESS, "adminUsername=pooluser,adminPassword=poolpass");
- // note no ssh module since we are stub and not trying ssh, yet
- overrides.setProperty(NodePoolProperties.BACKEND_MODULES, SLF4JLoggingModule.class.getName());
- Context nodePoolCtx = ContextBuilder.newBuilder("nodepool").credentials("foo", "bar").overrides(overrides)
- .build();
- return nodePoolCtx.utils().getInjector();
- }
-
- @Test(groups = "unit")
- public void testStore() throws FileNotFoundException, IOException {
- store.store(nodeMeta1, templateOptions, "testgroup");
- store.store(nodeMeta2, templateOptions, "testgroup");
- String readJSon = Files.toString(new File(baseDir + File.separator + "nodes"
- + File.separator + nodeMeta1.getId()), Charsets.UTF_8);
- assertEquals(readJSon, "{\"group\":\"testgroup\",\"tags\":[\"tag1\",\"tag2\"],"
- + "\"userMetadata\":{\"testmetakey\":\"testmetavalue\",\"testmetakey2\":\"testmetavalue2\"},"
- + "\"user\":\"testuser\",\"password\":\"testpass\",\"privateKey\":\"pk\",\"authenticateSudo\":true}");
- }
-
- @Test(groups = "unit", dependsOnMethods = "testStore")
- public void testLoad() {
- NodeMetadata loaded = store.load(nodeMeta1);
- assertEquals(loaded.getId(), nodeMeta1.getId());
- assertTrue(loaded.getTags().contains("tag1"));
- assertTrue(loaded.getTags().contains("tag2"));
- assertTrue(loaded.getUserMetadata().containsKey("testmetakey")
- && loaded.getUserMetadata().get("testmetakey").equals("testmetavalue"));
- assertTrue(loaded.getUserMetadata().containsKey("testmetakey2")
- && loaded.getUserMetadata().get("testmetakey2").equals("testmetavalue2"));
- assertEquals(loaded.getCredentials().getUser(), "testuser");
- assertEquals(loaded.getCredentials().getPassword(), "testpass");
- assertEquals(loaded.getCredentials().getPrivateKey(), "pk");
- assertEquals(loaded.getCredentials().shouldAuthenticateSudo(), true);
- assertEquals(loaded.getGroup(), "testgroup");
- }
-
- @Test(groups = "unit", dependsOnMethods = "testLoad")
- public void testLoadAll() {
- Set<NodeMetadata> loaded = store.loadAll(ImmutableSet.of(nodeMeta1, nodeMeta2));
- assertSame(loaded.size(), 2);
- }
-
- @Test(groups = "unit", dependsOnMethods = "testLoadAll")
- public void testDeleteMapping() {
- store.deleteMapping(nodeMeta1.getId());
- // make sure the other node is still there and this one isn't
- assertNull(store.load(nodeMeta1));
- assertEquals(nodeMeta2.getId(), store.load(nodeMeta2).getId());
- }
-
- @Test(groups = "unit", dependsOnMethods = "testDeleteMapping")
- public void testDeleteAllMappings() {
- store.deleteAllMappings();
- assertNull(store.load(nodeMeta1));
- assertNull(store.load(nodeMeta2));
- assertSame(new File(baseDir + File.separator + "nodes").listFiles().length, 0);
- }
-
-}