Skip to content
Permalink
Browse files
ComputeService implementation for ProfitBricks Rest
  • Loading branch information
alibazlamit authored and nacx committed Oct 6, 2016
1 parent 4e39720 commit 5742745e029cf765137b03f246415739a5feb4e3
Show file tree
Hide file tree
Showing 63 changed files with 4,797 additions and 462 deletions.
@@ -50,6 +50,11 @@
<artifactId>jclouds-core</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
@@ -61,9 +66,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-okhttp</artifactId>
<version>${jclouds.version}</version>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-okhttp</artifactId>
<version>${jclouds.version}</version>
</dependency>
<!-- Test dependencies -->
<dependency>
@@ -73,6 +78,13 @@
<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>
@@ -108,6 +120,13 @@
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-log4j</artifactId>
<version>${jclouds.version}</version>
<scope>test</scope>
<type>jar</type>
</dependency>
</dependencies>

<profiles>
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.jclouds.profitbricks.rest;

import com.google.common.annotations.Beta;
import java.io.Closeable;
import org.apache.jclouds.profitbricks.rest.features.DataCenterApi;
import org.apache.jclouds.profitbricks.rest.features.FirewallApi;
import org.apache.jclouds.profitbricks.rest.features.ImageApi;
import org.apache.jclouds.profitbricks.rest.features.IpBlockApi;
import org.apache.jclouds.profitbricks.rest.features.LanApi;
import org.apache.jclouds.profitbricks.rest.features.NicApi;
import org.apache.jclouds.profitbricks.rest.features.ServerApi;
@@ -31,29 +31,32 @@

@Beta
public interface ProfitBricksApi extends Closeable {

@Delegate
DataCenterApi dataCenterApi();


@Delegate
LanApi lanApi();

@Delegate
FirewallApi firewallApi();

@Delegate
ServerApi serverApi();

@Delegate
VolumeApi volumeApi();

@Delegate
ImageApi imageApi();

@Delegate
SnapshotApi snapshotApi();

@Delegate
NicApi nicApi();

@Delegate
LanApi lanApi();


@Delegate
FirewallApi firewallApi();
IpBlockApi ipBlockApi();

}
@@ -20,8 +20,9 @@
import com.google.inject.Module;
import java.net.URI;
import java.util.Properties;
import org.apache.jclouds.profitbricks.rest.util.ApiPredicatesModule;
import org.apache.jclouds.profitbricks.rest.compute.config.ProfitBricksComputeServiceContextModule;
import org.apache.jclouds.profitbricks.rest.config.ProfitBricksHttpApiModule;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule;
import org.jclouds.rest.internal.BaseHttpApiMetadata;

@@ -49,17 +50,18 @@ public static class Builder extends BaseHttpApiMetadata.Builder<ProfitBricksApi,

protected Builder() {
id("profitbricks-rest")
.name("ProfitBricks REST API")
.identityName("API Username")
.credentialName("API Password")
.documentation(URI.create("https://devops.profitbricks.com/api/rest/"))
.defaultEndpoint("https://api.profitbricks.com/rest/v2/")
.defaultProperties(ProfitBricksApiMetadata.defaultProperties())
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(OkHttpCommandExecutorServiceModule.class)
.add(ProfitBricksHttpApiModule.class)
.add(ApiPredicatesModule.class)
.build());
.name("ProfitBricks REST API")
.identityName("API Username")
.credentialName("API Password")
.documentation(URI.create("https://devops.profitbricks.com/api/rest/"))
.defaultEndpoint("https://api.profitbricks.com/rest/v2/")
.view(ComputeServiceContext.class)
.defaultProperties(ProfitBricksApiMetadata.defaultProperties())
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(OkHttpCommandExecutorServiceModule.class)
.add(ProfitBricksHttpApiModule.class)
.add(ProfitBricksComputeServiceContextModule.class)
.build());
}

@Override
@@ -55,41 +55,44 @@ public ProfitBricksProviderMetadata(Builder builder) {

public static Properties defaultProperties() {
Properties properties = ProfitBricksApiMetadata.defaultProperties();

properties.setProperty(PROPERTY_ISO3166_CODES, "US-NV,DE-HE,DE-BW");

properties.setProperty(PROPERTY_REGIONS, "DE,US");
properties.setProperty(PROPERTY_REGION + ".DE.zones", "FKB,FRA");
properties.setProperty(PROPERTY_REGION + ".US.zones", "LAS,LASDEV");

properties.setProperty(PROPERTY_ZONES, "FKB,FRA,LAS,LASDEV");
properties.setProperty(PROPERTY_ZONE + ".FKB." + ISO3166_CODES, "DE-BW");
properties.setProperty(PROPERTY_ZONE + ".FRA." + ISO3166_CODES, "DE-HE");
properties.setProperty(PROPERTY_ZONE + ".LAS." + ISO3166_CODES, "US-NV");
properties.setProperty(PROPERTY_ZONE + ".LASDEV." + ISO3166_CODES, "US-NV");


properties.setProperty(PROPERTY_REGIONS, "de,us");
properties.setProperty(PROPERTY_REGION + ".de.zones", "de/fkb,de/fra");
properties.setProperty(PROPERTY_REGION + ".us.zones", "us/las,us/lasdev");
properties.setProperty(PROPERTY_ZONES, "de/fkb,de/fra,us/las,us/lasdev");
properties.setProperty(PROPERTY_ISO3166_CODES, "DE-BW,DE-HE,US_NV");
properties.setProperty(PROPERTY_REGION + ".de." + ISO3166_CODES, "DE-BW,DE-HE");
properties.setProperty(PROPERTY_REGION + ".us." + ISO3166_CODES, "US-NV");
properties.setProperty(PROPERTY_ZONE + ".de/fkb." + ISO3166_CODES, "DE-BW");
properties.setProperty(PROPERTY_ZONE + ".de/fra." + ISO3166_CODES, "DE-HE");
properties.setProperty(PROPERTY_ZONE + ".us/las." + ISO3166_CODES, "US-NV");
properties.setProperty(PROPERTY_ZONE + ".us/lasdev." + ISO3166_CODES, "US-NV");

properties.put("jclouds.ssh.max-retries", "7");
properties.put("jclouds.ssh.retry-auth", "true");

long defaultTimeout = 60l * 60l; // 1 hour
properties.put(POLL_TIMEOUT, defaultTimeout);
properties.put(POLL_PERIOD, 2l);
properties.put(POLL_MAX_PERIOD, 2l * 10l);

properties.put(PROPERTY_SO_TIMEOUT, 60000 * 5);
properties.put(PROPERTY_CONNECTION_TIMEOUT, 60000 * 5);

return properties;
}

public static class Builder extends BaseProviderMetadata.Builder {

protected Builder() {
id("profitbricks-rest")
.name("ProfitBricks REST Compute")
.apiMetadata(new ProfitBricksApiMetadata())
.homepage(URI.create("https://www.profitbricks.com/"))
.console(URI.create("https://my.profitbricks.com/dashboard/dcdr2"))
.iso3166Codes("DE-FKB", "DE-FRA", "US-LAS", "US-LASDEV")
.endpoint("https://api.profitbricks.com/rest/v2/")
.defaultProperties(ProfitBricksProviderMetadata.defaultProperties());
.name("ProfitBricks REST Compute")
.apiMetadata(new ProfitBricksApiMetadata())
.homepage(URI.create("https://www.profitbricks.com/"))
.console(URI.create("https://my.profitbricks.com/dashboard/dcdr2"))
.iso3166Codes("DE-BW", "DE-HE", "US-NV")
.endpoint("https://api.profitbricks.com/rest/v2/")
.defaultProperties(ProfitBricksProviderMetadata.defaultProperties());
}

@Override

0 comments on commit 5742745

Please sign in to comment.