Skip to content
Permalink
Browse files
Merge remote-tracking branch 'jclouds-labs-local/packet-moved' into p…
…romoted-packet
  • Loading branch information
nacx committed May 18, 2017
2 parents 2b49bf3 + 8c973e4 commit c757906fb511f4907b232c8bf1b35b9863cee614
Show file tree
Hide file tree
Showing 91 changed files with 9,083 additions and 0 deletions.
@@ -0,0 +1,10 @@
# Apache jclouds Packet (packet.net) provider


## Pre-requisites

If you are using Oracle JDK, you may get this exception
```
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
```
when calling Packet endpoints. To solve this, you want to install JCE following the [official documentation](http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html).
@@ -0,0 +1,145 @@
<?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/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>jclouds-labs</artifactId>
<version>2.1.0-SNAPSHOT</version>
</parent>

<!-- TODO: when out of labs, switch to org.jclouds.provider -->
<artifactId>packet</artifactId>
<name>jclouds Packet compute API</name>
<description>jclouds components to access an implementation of Packet's Compute Service</description>
<packaging>bundle</packaging>

<properties>
<test.packet.endpoint>https://api.packet.net/</test.packet.endpoint>
<test.packet.identity>projectId</test.packet.identity>
<test.packet.credential>api key</test.packet.credential>
<jclouds.osgi.export>org.jclouds.packet*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-sshj</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
<exclusions>
<!-- Already provided by jclouds-sshj -->
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<profiles>
<profile>
<id>live</id>

<build>
<defaultGoal>clean verify</defaultGoal>

<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.packet.endpoint>${test.packet.endpoint}</test.packet.endpoint>
<test.packet.identity>${test.packet.identity}</test.packet.identity>
<test.packet.credential>${test.packet.credential}</test.packet.credential>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
@@ -0,0 +1,86 @@
/*
* 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.packet;

import java.io.Closeable;

import javax.ws.rs.PathParam;

import org.jclouds.packet.features.DeviceApi;
import org.jclouds.packet.features.FacilityApi;
import org.jclouds.packet.features.OperatingSystemApi;
import org.jclouds.packet.features.PlanApi;
import org.jclouds.packet.features.ProjectApi;
import org.jclouds.packet.features.SshKeyApi;
import org.jclouds.rest.annotations.Delegate;

/**
* The Packet API is a REST API for managing your services and deployments.
* <p>
*
* @see <a href="https://www.packet.net/help/api/" >doc</a>
*/
public interface PacketApi extends Closeable {

/**
* The Packet API includes operations for managing project.
*
* @see <a href="https://www.packet.net/help/api/#page:projects,header:projects-projects">docs</a>
*/
@Delegate
ProjectApi projectApi();

/**
* This Packet API provides all of the devices
*
* @see <a href="https://www.packet.net/help/api/#page:devices">docs</a>
*/
@Delegate
DeviceApi deviceApi(@PathParam("projectId") String projectId);

/**
* This Packet API provides all of the facilities
*
* @see <a href="https://www.packet.net/help/api/#page:devices,header:devices-operating-systems">docs</a>
*/
@Delegate
FacilityApi facilityApi();

/**
* This Packet API provides all of the plans
*
* @see <a href="https://www.packet.net/help/api/#page:devices,header:devices-plans">docs</a>
*/
@Delegate
PlanApi planApi();

/**
* This Packet API provides all of the operating systems
*
* @see <a href="https://www.packet.net/help/api/#page:devices,header:devices-operating-systems">docs</a>
*/
@Delegate
OperatingSystemApi operatingSystemApi();

/**
* This Packet API provides all of the operating systems
*
* @see <a href="https://www.packet.net/help/api/#page:ssh-keys">docs</a>
*/
@Delegate
SshKeyApi sshKeyApi();
}
@@ -0,0 +1,92 @@
/*
* 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.packet;

import java.net.URI;
import java.util.Properties;

import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.packet.compute.config.PacketComputeServiceContextModule;
import org.jclouds.packet.config.PacketComputeParserModule;
import org.jclouds.packet.config.PacketHttpApiModule;
import org.jclouds.rest.internal.BaseHttpApiMetadata;

import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;

import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
import static org.jclouds.reflect.Reflection2.typeToken;

/**
* Implementation of {@link ApiMetadata} for Packet API
*/
public class PacketApiMetadata extends BaseHttpApiMetadata<PacketApi> {

@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
}

public PacketApiMetadata() {
this(new Builder());
}

protected PacketApiMetadata(Builder builder) {
super(builder);
}

public static Properties defaultProperties() {
Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.put(TEMPLATE, "osFamily=UBUNTU,os64Bit=true,osVersionMatches=16.*");
properties.put(TIMEOUT_NODE_RUNNING, 900000); // 15 mins
properties.put(TIMEOUT_NODE_SUSPENDED, 900000); // 15 mins
return properties;
}

public static class Builder extends BaseHttpApiMetadata.Builder<PacketApi, Builder> {

protected Builder() {
id("packet")
.name("Packet API")
.identityName("Packet Project Id")
.credentialName("Must be Packet Token")
.documentation(URI.create("https://www.packet.net/help/api/#"))
.defaultEndpoint("https://api.packet.net")
.defaultProperties(PacketApiMetadata.defaultProperties())
.version("1")
.view(typeToken(ComputeServiceContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(PacketHttpApiModule.class)
.add(PacketComputeParserModule.class)
.add(PacketComputeServiceContextModule.class)
.build());
}

@Override
public PacketApiMetadata build() {
return new PacketApiMetadata(this);
}

@Override
protected Builder self() {
return this;
}
}
}

0 comments on commit c757906

Please sign in to comment.