mirror of https://github.com/apache/jclouds.git
JCLOUDS-702: JClouds ProfitBricks provider - ComputeServiceAdapter
This commit is contained in:
parent
cd91e009ed
commit
ed247e7dea
|
@ -0,0 +1,63 @@
|
||||||
|
# jclouds ProfitBricks
|
||||||
|
|
||||||
|
## Terms
|
||||||
|
Like any cloud provider, ProfitBricks has its own set of terms in cloud computing. To abstract this into jclouds' Compute interface, these terms were associated:
|
||||||
|
|
||||||
|
- Node - composite instance of `Server` and `Storage`
|
||||||
|
- Image - both *user-uploaded* and *provided* `Images`; and `Snapshots`
|
||||||
|
- Location - `DataCenters` and `Region` (Las Vegas, Frankfurt, etc.)
|
||||||
|
- Hardware - number of cores, RAM size and storage size
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
Assuming that there's **atleast one** datacenter existing in your account, the provider needs only an *identity* (your ProfitBricks email), and *credentials* (password) to provision a `Node`, by using a ProfitBricks-provided ubuntu-12.04 image as a template.
|
||||||
|
|
||||||
|
```java
|
||||||
|
ComputeService compute = ContextBuilder.newBuilder( "profitbricks" )
|
||||||
|
.credentials( "profitbricks email", "password" )
|
||||||
|
.buildView( ComputeServiceContext.class )
|
||||||
|
.getComputeService();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
This works well; however, we won't be able to use jclouds' ability to execute *scripts* on a remote node. This is because, ProfitBricks' default images require users to change passwords upon first log in.
|
||||||
|
|
||||||
|
To enable jclouds to execute script, we need to use a custom image. The easiest way to do this is via ProfitBricks snapshot:
|
||||||
|
|
||||||
|
- Go to your [DCD](https://my.profitbricks.com/dashboard/).
|
||||||
|
- Provision a server + storage, and connect it to the internet. Upon success, you will receive an email containing the credentials needed to login to your server.
|
||||||
|
- Login to your server, and change the password, as requested.
|
||||||
|
|
||||||
|
```
|
||||||
|
~ ssh root@<remote-ip>
|
||||||
|
...
|
||||||
|
Changing password for root.
|
||||||
|
(current) UNIX password:
|
||||||
|
Enter new UNIX password:
|
||||||
|
Retype new UNIX password:
|
||||||
|
~ root@ubuntu:~# exit
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
- Go back to the DCD, and *make a snapshot* of the storage. Put a descriptive name.
|
||||||
|
- Configure jclouds to use this *snapshot*.
|
||||||
|
|
||||||
|
```java
|
||||||
|
Template template = compute.templateBuilder()
|
||||||
|
.imageNameMatches( "<ideally-unique-snapshot-name>" )
|
||||||
|
.options( compute.templateOptions()
|
||||||
|
.overrideLoginUser( "root" ) // unless you changed the user
|
||||||
|
.overrideLoginPassword( "<changed-password>" ))
|
||||||
|
// more options, as you need
|
||||||
|
.build();
|
||||||
|
|
||||||
|
compute.createNodesInGroup( "cluster1", 1, template );
|
||||||
|
```
|
||||||
|
> If no `locationId` is specified in the template, jclouds will look for a `DataCenter` that is of same scope as the `Image`.
|
||||||
|
|
||||||
|
|
||||||
|
## Limitations
|
||||||
|
|
||||||
|
- There's no direct way of specifying arbitrary number of cores, RAM size, and storage size via the compute interface, at least until after [JCLOUDS-482](https://issues.apache.org/jira/browse/JCLOUDS-482) is resolved. The adapter uses a predefined list hardware profiles instead.
|
||||||
|
|
||||||
|
> Take note that these features are still accessible by *unwraping* the ProfitBricks API, but this'll reduce portability of your code. See [Concepts](https://jclouds.apache.org/start/concepts/).
|
|
@ -36,7 +36,6 @@
|
||||||
<test.profitbricks.identity>FIXME</test.profitbricks.identity>
|
<test.profitbricks.identity>FIXME</test.profitbricks.identity>
|
||||||
<test.profitbricks.credential>FIXME</test.profitbricks.credential>
|
<test.profitbricks.credential>FIXME</test.profitbricks.credential>
|
||||||
<test.profitbricks.api-version>1.3</test.profitbricks.api-version>
|
<test.profitbricks.api-version>1.3</test.profitbricks.api-version>
|
||||||
<test.profitbricks.template />
|
|
||||||
<jclouds.osgi.export>org.jclouds.profitbricks*;version="${project.version}"</jclouds.osgi.export>
|
<jclouds.osgi.export>org.jclouds.profitbricks*;version="${project.version}"</jclouds.osgi.export>
|
||||||
<jclouds.osgi.import>
|
<jclouds.osgi.import>
|
||||||
org.jclouds.labs*;version="${project.version}",
|
org.jclouds.labs*;version="${project.version}",
|
||||||
|
|
|
@ -19,8 +19,10 @@ package org.jclouds.profitbricks;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.profitbricks.compute.config.ProfitBricksComputeServiceContextModule;
|
||||||
import org.jclouds.profitbricks.config.ProfitBricksHttpApiModule;
|
import org.jclouds.profitbricks.config.ProfitBricksHttpApiModule;
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.profitbricks.config.ProfitBricksHttpApiModule.ProfitBricksHttpCommandExecutorServiceModule;
|
import org.jclouds.profitbricks.config.ProfitBricksHttpApiModule.ProfitBricksHttpCommandExecutorServiceModule;
|
||||||
import org.jclouds.rest.internal.BaseHttpApiMetadata;
|
import org.jclouds.rest.internal.BaseHttpApiMetadata;
|
||||||
|
|
||||||
|
@ -60,11 +62,12 @@ public class ProfitBricksApiMetadata extends BaseHttpApiMetadata<ProfitBricksApi
|
||||||
.documentation(URI.create("https://www.profitbricks.com/sites/default/files/profitbricks_api_1_3.pdf"))
|
.documentation(URI.create("https://www.profitbricks.com/sites/default/files/profitbricks_api_1_3.pdf"))
|
||||||
.defaultEndpoint("https://api.profitbricks.com/1.3")
|
.defaultEndpoint("https://api.profitbricks.com/1.3")
|
||||||
.version("1.3")
|
.version("1.3")
|
||||||
// .view(ComputeServiceContext.class)
|
.view(ComputeServiceContext.class)
|
||||||
.defaultProperties(ProfitBricksApiMetadata.defaultProperties())
|
.defaultProperties(ProfitBricksApiMetadata.defaultProperties())
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(
|
||||||
ProfitBricksHttpApiModule.class,
|
ProfitBricksHttpApiModule.class,
|
||||||
ProfitBricksHttpCommandExecutorServiceModule.class
|
ProfitBricksHttpCommandExecutorServiceModule.class,
|
||||||
|
ProfitBricksComputeServiceContextModule.class
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,17 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks;
|
package org.jclouds.profitbricks;
|
||||||
|
|
||||||
|
import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT;
|
||||||
|
import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
|
||||||
|
import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_PERIOD;
|
||||||
|
import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_MAX_PERIOD;
|
||||||
|
import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_TIMEOUT;
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.providers.ProviderMetadata;
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.providers.internal.BaseProviderMetadata;
|
import org.jclouds.providers.internal.BaseProviderMetadata;
|
||||||
|
|
||||||
|
@ -41,6 +50,19 @@ public class ProfitBricksProviderMetadata extends BaseProviderMetadata {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Properties defaultProperties() {
|
||||||
|
Properties properties = ProfitBricksApiMetadata.defaultProperties();
|
||||||
|
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 {
|
public static class Builder extends BaseProviderMetadata.Builder {
|
||||||
|
|
||||||
protected Builder() {
|
protected Builder() {
|
||||||
|
@ -49,7 +71,8 @@ public class ProfitBricksProviderMetadata extends BaseProviderMetadata {
|
||||||
.homepage(URI.create("http://www.profitbricks.com"))
|
.homepage(URI.create("http://www.profitbricks.com"))
|
||||||
.console(URI.create("https://my.profitbricks.com/dashboard/dcdr2/"))
|
.console(URI.create("https://my.profitbricks.com/dashboard/dcdr2/"))
|
||||||
.linkedServices("profitbricks")
|
.linkedServices("profitbricks")
|
||||||
.apiMetadata(new ProfitBricksApiMetadata());
|
.apiMetadata(new ProfitBricksApiMetadata())
|
||||||
|
.defaultProperties(ProfitBricksProviderMetadata.defaultProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class CreateDataCenterRequestBinder extends BaseProfitBricksRequestBinder
|
||||||
requestBuilder.append("<ws:createDataCenter>")
|
requestBuilder.append("<ws:createDataCenter>")
|
||||||
.append("<request>")
|
.append("<request>")
|
||||||
.append(format("<dataCenterName>%s</dataCenterName>", payload.name()))
|
.append(format("<dataCenterName>%s</dataCenterName>", payload.name()))
|
||||||
.append(format("<location>%s</location>", payload.location().value()))
|
.append(format("<location>%s</location>", payload.location().getId()))
|
||||||
.append("</request>")
|
.append("</request>")
|
||||||
.append("</ws:createDataCenter>");
|
.append("</ws:createDataCenter>");
|
||||||
return requestBuilder.toString();
|
return requestBuilder.toString();
|
||||||
|
|
|
@ -39,9 +39,8 @@ public class CreateLoadBalancerRequestBinder extends BaseProfitBricksRequestBind
|
||||||
.append(format("<loadBalancerAlgorithm>%s</loadBalancerAlgorithm>", payload.loadBalancerAlgorithm()))
|
.append(format("<loadBalancerAlgorithm>%s</loadBalancerAlgorithm>", payload.loadBalancerAlgorithm()))
|
||||||
.append(format("<ip>%s</ip>", payload.ip()))
|
.append(format("<ip>%s</ip>", payload.ip()))
|
||||||
.append(format("<lanId>%s</lanId>", payload.lanId()));
|
.append(format("<lanId>%s</lanId>", payload.lanId()));
|
||||||
for (String serverId : payload.serverIds()) {
|
for (String serverId : payload.serverIds())
|
||||||
requestBuilder.append(format("<serverIds>%s</serverIds>", serverId));
|
requestBuilder.append(format("<serverIds>%s</serverIds>", serverId));
|
||||||
}
|
|
||||||
requestBuilder
|
requestBuilder
|
||||||
.append("</request>")
|
.append("</request>")
|
||||||
.append("</ws:createLoadBalancer>");
|
.append("</ws:createLoadBalancer>");
|
||||||
|
|
|
@ -33,9 +33,8 @@ public class DeregisterLoadBalancerRequestBinder extends BaseProfitBricksRequest
|
||||||
protected String createPayload(LoadBalancer.Request.DeregisterPayload payload) {
|
protected String createPayload(LoadBalancer.Request.DeregisterPayload payload) {
|
||||||
requestBuilder.append("<ws:deregisterServersOnLoadBalancer>")
|
requestBuilder.append("<ws:deregisterServersOnLoadBalancer>")
|
||||||
.append("<request>");
|
.append("<request>");
|
||||||
for (String s : payload.serverIds()) {
|
for (String s : payload.serverIds())
|
||||||
requestBuilder.append(format("<serverIds>%s</serverIds>", s));
|
requestBuilder.append(format("<serverIds>%s</serverIds>", s));
|
||||||
}
|
|
||||||
requestBuilder.append(format("<loadBalancerId>%s</loadBalancerId>", payload.id()))
|
requestBuilder.append(format("<loadBalancerId>%s</loadBalancerId>", payload.id()))
|
||||||
.append("</request>")
|
.append("</request>")
|
||||||
.append("</ws:deregisterServersOnLoadBalancer>");
|
.append("</ws:deregisterServersOnLoadBalancer>");
|
||||||
|
|
|
@ -35,9 +35,8 @@ public class RegisterLoadBalancerRequestBinder extends BaseProfitBricksRequestBi
|
||||||
.append("<ws:registerServersOnLoadBalancer>").append("<request>")
|
.append("<ws:registerServersOnLoadBalancer>").append("<request>")
|
||||||
.append(format("<loadBalancerId>%s</loadBalancerId>", payload.id()));
|
.append(format("<loadBalancerId>%s</loadBalancerId>", payload.id()));
|
||||||
|
|
||||||
for (String s : payload.serverIds()) {
|
for (String s : payload.serverIds())
|
||||||
requestBuilder.append(format("<serverIds>%s</serverIds>", s));
|
requestBuilder.append(format("<serverIds>%s</serverIds>", s));
|
||||||
}
|
|
||||||
requestBuilder
|
requestBuilder
|
||||||
.append("</request>")
|
.append("</request>")
|
||||||
.append("</ws:registerServersOnLoadBalancer>");
|
.append("</ws:registerServersOnLoadBalancer>");
|
||||||
|
|
|
@ -33,12 +33,12 @@ public class CreateSnapshotRequestBinder extends BaseProfitBricksRequestBinder<S
|
||||||
@Override
|
@Override
|
||||||
protected String createPayload(Snapshot.Request.CreatePayload payload) {
|
protected String createPayload(Snapshot.Request.CreatePayload payload) {
|
||||||
requestBuilder.append("<ws:createSnapshot>")
|
requestBuilder.append("<ws:createSnapshot>")
|
||||||
.append("<request>")
|
.append("<request>")
|
||||||
.append(format("<storageId>%s</storageId>", payload.storageId()))
|
.append(format("<storageId>%s</storageId>", payload.storageId()))
|
||||||
.append(formatIfNotEmpty("<description>%s</description>", payload.description()))
|
.append(formatIfNotEmpty("<description>%s</description>", payload.description()))
|
||||||
.append(formatIfNotEmpty("<snapshotName>%s</snapshotName>", payload.name()))
|
.append(formatIfNotEmpty("<snapshotName>%s</snapshotName>", payload.name()))
|
||||||
.append("</request>")
|
.append("</request>")
|
||||||
.append("</ws:createSnapshot>");
|
.append("</ws:createSnapshot>");
|
||||||
return requestBuilder.toString();
|
return requestBuilder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,21 +23,21 @@ import static java.lang.String.format;
|
||||||
|
|
||||||
public class RollbackSnapshotRequestBinder extends BaseProfitBricksRequestBinder<Snapshot.Request.RollbackPayload> {
|
public class RollbackSnapshotRequestBinder extends BaseProfitBricksRequestBinder<Snapshot.Request.RollbackPayload> {
|
||||||
|
|
||||||
protected final StringBuilder requestBuilder;
|
protected final StringBuilder requestBuilder;
|
||||||
|
|
||||||
protected RollbackSnapshotRequestBinder() {
|
protected RollbackSnapshotRequestBinder() {
|
||||||
super("snapshot");
|
super("snapshot");
|
||||||
this.requestBuilder = new StringBuilder(128);
|
this.requestBuilder = new StringBuilder(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String createPayload(Snapshot.Request.RollbackPayload payload) {
|
protected String createPayload(Snapshot.Request.RollbackPayload payload) {
|
||||||
requestBuilder.append("<ws:rollbackSnapshot>")
|
requestBuilder.append("<ws:rollbackSnapshot>")
|
||||||
.append("<request>")
|
.append("<request>")
|
||||||
.append(format("<snapshotId>%s</snapshotId>", payload.snapshotId()))
|
.append(format("<snapshotId>%s</snapshotId>", payload.snapshotId()))
|
||||||
.append(format("<storageId>%s</storageId>", payload.storageId()))
|
.append(format("<storageId>%s</storageId>", payload.storageId()))
|
||||||
.append("</request>")
|
.append("</request>")
|
||||||
.append("</ws:rollbackSnapshot>");
|
.append("</ws:rollbackSnapshot>");
|
||||||
return requestBuilder.toString();
|
return requestBuilder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,22 +32,22 @@ public class UpdateSnapshotRequestBinder extends BaseProfitBricksRequestBinder<S
|
||||||
@Override
|
@Override
|
||||||
protected String createPayload(Snapshot.Request.UpdatePayload payload) {
|
protected String createPayload(Snapshot.Request.UpdatePayload payload) {
|
||||||
requestBuilder.append("<ws:updateSnapshot>")
|
requestBuilder.append("<ws:updateSnapshot>")
|
||||||
.append("<request>")
|
.append("<request>")
|
||||||
.append(format("<snapshotId>%s</snapshotId>", payload.snapshotId()))
|
.append(format("<snapshotId>%s</snapshotId>", payload.snapshotId()))
|
||||||
.append(format("<description>%s</description>", payload.description()))
|
.append(format("<description>%s</description>", payload.description()))
|
||||||
.append(format("<snapshotName>%s</snapshotName>", payload.name()))
|
.append(format("<snapshotName>%s</snapshotName>", payload.name()))
|
||||||
.append(formatIfNotEmpty("<bootable>%s</bootable>", payload.bootable()))
|
.append(formatIfNotEmpty("<bootable>%s</bootable>", payload.bootable()))
|
||||||
.append(formatIfNotEmpty("<osType>%s</osType>", payload.osType()))
|
.append(formatIfNotEmpty("<osType>%s</osType>", payload.osType()))
|
||||||
.append(formatIfNotEmpty("<cpuHotPlug>%s</cpuHotPlug>", payload.cpuHotplug()))
|
.append(formatIfNotEmpty("<cpuHotPlug>%s</cpuHotPlug>", payload.isCpuHotPlug()))
|
||||||
.append(formatIfNotEmpty("<cpuHotUnPlug>%s</cpuHotUnPlug>", payload.cpuHotunplug()))
|
.append(formatIfNotEmpty("<cpuHotUnPlug>%s</cpuHotUnPlug>", payload.isCpuHotUnPlug()))
|
||||||
.append(formatIfNotEmpty("<ramHotPlug>%s</ramHotPlug>", payload.ramHotplug()))
|
.append(formatIfNotEmpty("<ramHotPlug>%s</ramHotPlug>", payload.isRamHotPlug()))
|
||||||
.append(formatIfNotEmpty("<ramHotUnPlug>%s</ramHotUnPlug>", payload.ramHotunplug()))
|
.append(formatIfNotEmpty("<ramHotUnPlug>%s</ramHotUnPlug>", payload.isRamHotUnPlug()))
|
||||||
.append(formatIfNotEmpty("<nicHotPlug>%s</nicHotPlug>", payload.nicHotplug()))
|
.append(formatIfNotEmpty("<nicHotPlug>%s</nicHotPlug>", payload.isNicHotPlug()))
|
||||||
.append(formatIfNotEmpty("<nicHotUnPlug>%s</nicHotUnPlug>", payload.nicHotunplug()))
|
.append(formatIfNotEmpty("<nicHotUnPlug>%s</nicHotUnPlug>", payload.isNicHotUnPlug()))
|
||||||
.append(formatIfNotEmpty("<discVirtioHotPlug>%s</discVirtioHotPlug>", payload.discVirtioHotplug()))
|
.append(formatIfNotEmpty("<discVirtioHotPlug>%s</discVirtioHotPlug>", payload.isDiscVirtioHotPlug()))
|
||||||
.append(formatIfNotEmpty("<discVirtioHotUnPlug>%s</discVirtioHotUnPlug>", payload.discVirtioHotunplug()))
|
.append(formatIfNotEmpty("<discVirtioHotUnPlug>%s</discVirtioHotUnPlug>", payload.isDiscVirtioHotUnPlug()))
|
||||||
.append("</request>")
|
.append("</request>")
|
||||||
.append("</ws:updateSnapshot>");
|
.append("</ws:updateSnapshot>");
|
||||||
return requestBuilder.toString();
|
return requestBuilder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,488 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute;
|
||||||
|
|
||||||
|
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
import static com.google.common.util.concurrent.Futures.allAsList;
|
||||||
|
import static com.google.common.util.concurrent.Futures.getUnchecked;
|
||||||
|
import static java.lang.String.format;
|
||||||
|
import static org.jclouds.Constants.PROPERTY_USER_THREADS;
|
||||||
|
import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
|
import org.jclouds.compute.domain.Processor;
|
||||||
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.compute.domain.internal.VolumeImpl;
|
||||||
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.compute.util.ComputeServiceUtils;
|
||||||
|
import org.jclouds.domain.LoginCredentials;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.profitbricks.ProfitBricksApi;
|
||||||
|
import org.jclouds.profitbricks.domain.AvailabilityZone;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
|
import org.jclouds.profitbricks.domain.Image;
|
||||||
|
import org.jclouds.profitbricks.domain.Server;
|
||||||
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
|
import org.jclouds.profitbricks.features.DataCenterApi;
|
||||||
|
import org.jclouds.profitbricks.features.ServerApi;
|
||||||
|
import org.jclouds.profitbricks.compute.concurrent.ProvisioningJob;
|
||||||
|
import org.jclouds.profitbricks.compute.concurrent.ProvisioningManager;
|
||||||
|
import org.jclouds.profitbricks.domain.Snapshot;
|
||||||
|
import org.jclouds.profitbricks.domain.internal.Provisionable;
|
||||||
|
import org.jclouds.profitbricks.util.Passwords;
|
||||||
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class ProfitBricksComputeServiceAdapter implements ComputeServiceAdapter<Server, Hardware, Provisionable, DataCenter> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final ProfitBricksApi api;
|
||||||
|
private final Predicate<String> waitDcUntilAvailable;
|
||||||
|
private final ListeningExecutorService executorService;
|
||||||
|
private final ProvisioningJob.Factory jobFactory;
|
||||||
|
private final ProvisioningManager provisioningManager;
|
||||||
|
|
||||||
|
private static final Integer DEFAULT_LAN_ID = 1;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ProfitBricksComputeServiceAdapter(ProfitBricksApi api,
|
||||||
|
@Named(POLL_PREDICATE_DATACENTER) Predicate<String> waitDcUntilAvailable,
|
||||||
|
@Named(PROPERTY_USER_THREADS) ListeningExecutorService executorService,
|
||||||
|
ProvisioningJob.Factory jobFactory,
|
||||||
|
ProvisioningManager provisioningManager) {
|
||||||
|
this.api = api;
|
||||||
|
this.waitDcUntilAvailable = waitDcUntilAvailable;
|
||||||
|
this.executorService = executorService;
|
||||||
|
this.jobFactory = jobFactory;
|
||||||
|
this.provisioningManager = provisioningManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NodeAndInitialCredentials<Server> createNodeWithGroupEncodedIntoName(String group, String name, Template template) {
|
||||||
|
final String dataCenterId = template.getLocation().getId();
|
||||||
|
Hardware hardware = template.getHardware();
|
||||||
|
|
||||||
|
TemplateOptions options = template.getOptions();
|
||||||
|
final String loginUser = isNullOrEmpty(options.getLoginUser()) ? "root" : options.getLoginUser();
|
||||||
|
final String password = options.hasLoginPassword() ? options.getLoginPassword() : Passwords.generate();
|
||||||
|
|
||||||
|
final org.jclouds.compute.domain.Image image = template.getImage();
|
||||||
|
|
||||||
|
// provision all storages based on hardware
|
||||||
|
List<? extends Volume> volumes = hardware.getVolumes();
|
||||||
|
List<String> storageIds = Lists.newArrayListWithExpectedSize(volumes.size());
|
||||||
|
|
||||||
|
int i = 1;
|
||||||
|
for (final Volume volume : volumes)
|
||||||
|
try {
|
||||||
|
logger.trace("<< provisioning storage '%s'", volume);
|
||||||
|
final Storage.Request.CreatePayload request = Storage.Request.creatingBuilder()
|
||||||
|
.dataCenterId(dataCenterId)
|
||||||
|
// put image to first storage
|
||||||
|
.mountImageId(i == 1 ? image.getId() : "")
|
||||||
|
.imagePassword(password)
|
||||||
|
.name(format("%s-disk-%d", name, i++))
|
||||||
|
.size(volume.getSize())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
String storageId = (String) provisioningManager.provision(jobFactory.create(dataCenterId, new Supplier<Object>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
return api.storageApi().createStorage(request);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
storageIds.add(storageId);
|
||||||
|
logger.trace(">> provisioning complete for storage. returned id='%s'", storageId);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (i - 1 == 1) // if first storage (one with image) provisioning fails; stop method
|
||||||
|
throw Throwables.propagate(ex);
|
||||||
|
logger.warn(ex, ">> failed to provision storage. skipping..");
|
||||||
|
}
|
||||||
|
|
||||||
|
int lanId = DEFAULT_LAN_ID;
|
||||||
|
if (options.getNetworks() != null)
|
||||||
|
try {
|
||||||
|
String networkId = Iterables.get(options.getNetworks(), 0);
|
||||||
|
lanId = Integer.valueOf(networkId);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.warn("no valid network id found from options. using default id='%d'", DEFAULT_LAN_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
Double cores = ComputeServiceUtils.getCores(hardware);
|
||||||
|
|
||||||
|
// provision server and connect boot storage (first provisioned)
|
||||||
|
String serverId = null;
|
||||||
|
try {
|
||||||
|
String storageBootDeviceId = Iterables.get(storageIds, 0); // must have atleast 1
|
||||||
|
final Server.Request.CreatePayload serverRequest = Server.Request.creatingBuilder()
|
||||||
|
.dataCenterId(dataCenterId)
|
||||||
|
.name(name)
|
||||||
|
.bootFromStorageId(storageBootDeviceId)
|
||||||
|
.cores(cores.intValue())
|
||||||
|
.ram(hardware.getRam())
|
||||||
|
.availabilityZone(AvailabilityZone.AUTO)
|
||||||
|
.hasInternetAccess(true)
|
||||||
|
.lanId(lanId)
|
||||||
|
.build();
|
||||||
|
logger.trace("<< provisioning server '%s'", serverRequest);
|
||||||
|
|
||||||
|
serverId = (String) provisioningManager.provision(jobFactory.create(dataCenterId, new Supplier<Object>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
return api.serverApi().createServer(serverRequest);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
logger.trace(">> provisioning complete for server. returned id='%s'", serverId);
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error(ex, ">> failed to provision server. rollbacking..");
|
||||||
|
destroyStorages(storageIds, dataCenterId);
|
||||||
|
throw Throwables.propagate(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// connect the rest of storages to server; delete if fails
|
||||||
|
final int storageCount = storageIds.size();
|
||||||
|
for (int j = 1; j < storageCount; j++) { // skip first; already connected
|
||||||
|
String storageId = storageIds.get(j);
|
||||||
|
try {
|
||||||
|
logger.trace("<< connecting storage '%s' to server '%s'", storageId, serverId);
|
||||||
|
final Storage.Request.ConnectPayload request = Storage.Request.connectingBuilder()
|
||||||
|
.storageId(storageId)
|
||||||
|
.serverId(serverId)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
provisioningManager.provision(jobFactory.create(group, new Supplier<Object>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
return api.storageApi().connectStorageToServer(request);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
logger.trace(">> storage connected.");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// delete unconnected storage
|
||||||
|
logger.warn(ex, ">> failed to connect storage '%s'. deleting..", storageId);
|
||||||
|
destroyStorage(storageId, dataCenterId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last paranoid check
|
||||||
|
waitDcUntilAvailable.apply(dataCenterId);
|
||||||
|
|
||||||
|
LoginCredentials serverCredentials = LoginCredentials.builder()
|
||||||
|
.user(loginUser)
|
||||||
|
.password(password)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Server server = getNode(serverId);
|
||||||
|
|
||||||
|
return new NodeAndInitialCredentials<Server>(server, serverId, serverCredentials);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<Hardware> listHardwareProfiles() {
|
||||||
|
// Max [cores=48] [disk size per storage=2048GB] [ram=200704 MB]
|
||||||
|
List<Hardware> hardwares = Lists.newArrayList();
|
||||||
|
for (int core = 1; core <= 48; core++)
|
||||||
|
for (int ram : new int[]{1024, 2 * 1024, 4 * 1024, 8 * 1024,
|
||||||
|
10 * 1024, 16 * 1024, 24 * 1024, 28 * 1024, 32 * 1024})
|
||||||
|
for (float size : new float[]{10, 20, 30, 50, 80, 100, 150, 200, 250, 500}) {
|
||||||
|
String id = String.format("cpu=%d,ram=%s,disk=%f", core, ram, size);
|
||||||
|
hardwares.add(new HardwareBuilder()
|
||||||
|
.ids(id)
|
||||||
|
.ram(ram)
|
||||||
|
.hypervisor("kvm")
|
||||||
|
.name(id)
|
||||||
|
.processor(new Processor(core, 1d))
|
||||||
|
.volume(new VolumeImpl(size, true, true))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
return hardwares;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<Provisionable> listImages() {
|
||||||
|
// fetch images..
|
||||||
|
ListenableFuture<List<Image>> images = executorService.submit(new Callable<List<Image>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Image> call() throws Exception {
|
||||||
|
logger.trace("<< fetching images..");
|
||||||
|
// Filter HDD types only, since JClouds doesn't have a concept of "CD-ROM" anyway
|
||||||
|
Iterable<Image> filteredImages = Iterables.filter(api.imageApi().getAllImages(), new Predicate<Image>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Image image) {
|
||||||
|
return image.type() == Image.Type.HDD;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
logger.trace(">> images fetched.");
|
||||||
|
|
||||||
|
return ImmutableList.copyOf(filteredImages);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
// and snapshots at the same time
|
||||||
|
ListenableFuture<List<Snapshot>> snapshots = executorService.submit(new Callable<List<Snapshot>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Snapshot> call() throws Exception {
|
||||||
|
logger.trace("<< fetching snapshots");
|
||||||
|
List<Snapshot> remoteSnapshots = api.snapshotApi().getAllSnapshots();
|
||||||
|
logger.trace(">> snapshots feched.");
|
||||||
|
|
||||||
|
return remoteSnapshots;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return Iterables.concat(getUnchecked(images), getUnchecked(snapshots));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Provisionable getImage(String id) {
|
||||||
|
// try search images
|
||||||
|
logger.trace("<< searching for image with id=%s", id);
|
||||||
|
Image image = api.imageApi().getImage(id);
|
||||||
|
if (image != null) {
|
||||||
|
logger.trace(">> found image [%s].", image.name());
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
// try search snapshots
|
||||||
|
logger.trace("<< not found from images. searching for snapshot with id=%s", id);
|
||||||
|
Snapshot snapshot = api.snapshotApi().getSnapshot(id);
|
||||||
|
if (snapshot != null) {
|
||||||
|
logger.trace(">> found snapshot [%s]", snapshot.name());
|
||||||
|
return snapshot;
|
||||||
|
}
|
||||||
|
throw new ResourceNotFoundException("No image/snapshot with id '" + id + "' was found");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<DataCenter> listLocations() {
|
||||||
|
logger.trace("<< fetching datacenters..");
|
||||||
|
final DataCenterApi dcApi = api.dataCenterApi();
|
||||||
|
|
||||||
|
// Fetch all datacenters
|
||||||
|
ListenableFuture<List<DataCenter>> futures = allAsList(transform(dcApi.getAllDataCenters(),
|
||||||
|
new Function<DataCenter, ListenableFuture<DataCenter>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenableFuture<DataCenter> apply(final DataCenter input) {
|
||||||
|
// Fetch more details in parallel
|
||||||
|
return executorService.submit(new Callable<DataCenter>() {
|
||||||
|
@Override
|
||||||
|
public DataCenter call() throws Exception {
|
||||||
|
logger.trace("<< fetching datacenter with id [%s]", input.id());
|
||||||
|
return dcApi.getDataCenter(input.id());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
return getUnchecked(futures);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Server getNode(String id) {
|
||||||
|
logger.trace("<< searching for server with id=%s", id);
|
||||||
|
|
||||||
|
Server server = api.serverApi().getServer(id);
|
||||||
|
if (server != null)
|
||||||
|
logger.trace(">> found server [%s]", server.name());
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroyNode(String nodeId) {
|
||||||
|
ServerApi serverApi = api.serverApi();
|
||||||
|
Server server = serverApi.getServer(nodeId);
|
||||||
|
if (server != null) {
|
||||||
|
String dataCenterId = server.dataCenter().id();
|
||||||
|
for (Storage storage : server.storages())
|
||||||
|
destroyStorage(storage.id(), dataCenterId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
destroyServer(nodeId, dataCenterId);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.warn(ex, ">> failed to delete server with id=%s", nodeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rebootNode(final String id) {
|
||||||
|
// Fail pre-emptively if not found
|
||||||
|
final Server node = getRequiredNode(id);
|
||||||
|
final DataCenter dataCenter = node.dataCenter();
|
||||||
|
provisioningManager.provision(jobFactory.create(dataCenter.id(), new Supplier<Object>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
api.serverApi().resetServer(id);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resumeNode(final String id) {
|
||||||
|
final Server node = getRequiredNode(id);
|
||||||
|
if (node.status() == Server.Status.RUNNING)
|
||||||
|
return;
|
||||||
|
|
||||||
|
final DataCenter dataCenter = node.dataCenter();
|
||||||
|
provisioningManager.provision(jobFactory.create(dataCenter.id(), new Supplier<Object>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
api.serverApi().startServer(id);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void suspendNode(final String id) {
|
||||||
|
final Server node = getRequiredNode(id);
|
||||||
|
// Intentionally didn't include SHUTDOWN (only achieved via UI; soft-shutdown).
|
||||||
|
// A SHUTOFF server is no longer billed, so we execute method for all other status
|
||||||
|
if (node.status() == Server.Status.SHUTOFF)
|
||||||
|
return;
|
||||||
|
|
||||||
|
final DataCenter dataCenter = node.dataCenter();
|
||||||
|
provisioningManager.provision(jobFactory.create(dataCenter.id(), new Supplier<Object>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
api.serverApi().stopServer(id);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<Server> listNodes() {
|
||||||
|
logger.trace(">> fetching all servers..");
|
||||||
|
List<Server> servers = api.serverApi().getAllServers();
|
||||||
|
logger.trace(">> servers fetched.");
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<Server> listNodesByIds(final Iterable<String> ids) {
|
||||||
|
// Only fetch the requested nodes. Do it in parallel.
|
||||||
|
ListenableFuture<List<Server>> futures = allAsList(transform(ids,
|
||||||
|
new Function<String, ListenableFuture<Server>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenableFuture<Server> apply(final String input) {
|
||||||
|
return executorService.submit(new Callable<Server>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Server call() throws Exception {
|
||||||
|
return getNode(input);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
return getUnchecked(futures);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void destroyServer(final String serverId, final String dataCenterId) {
|
||||||
|
try {
|
||||||
|
logger.trace("<< deleting server with id=%s", serverId);
|
||||||
|
provisioningManager.provision(jobFactory.create(dataCenterId, new Supplier<Object>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
api.serverApi().deleteServer(serverId);
|
||||||
|
|
||||||
|
return serverId;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
logger.trace(">> server '%s' deleted.", serverId);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.warn(ex, ">> failed to delete server with id=%s", serverId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void destroyStorages(List<String> storageIds, String dataCenterId) {
|
||||||
|
for (String storageId : storageIds)
|
||||||
|
destroyStorage(storageId, dataCenterId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void destroyStorage(final String storageId, final String dataCenterId) {
|
||||||
|
try {
|
||||||
|
logger.trace("<< deleting storage with id=%s", storageId);
|
||||||
|
provisioningManager.provision(jobFactory.create(dataCenterId, new Supplier<Object>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
api.storageApi().deleteStorage(storageId);
|
||||||
|
|
||||||
|
return storageId;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
logger.trace(">> storage '%s' deleted.", storageId);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.warn(ex, ">> failed to delete storage with id=%s", storageId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Server getRequiredNode(String nodeId) {
|
||||||
|
Server node = getNode(nodeId);
|
||||||
|
if (node == null)
|
||||||
|
throw new ResourceNotFoundException("Node with id'" + nodeId + "' was not found.");
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.concurrent;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER;
|
||||||
|
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
|
||||||
|
public class ProvisioningJob implements Callable {
|
||||||
|
|
||||||
|
public interface Factory {
|
||||||
|
|
||||||
|
ProvisioningJob create(String group, Supplier<Object> operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Predicate<String> waitDataCenterUntilReady;
|
||||||
|
private final String group;
|
||||||
|
private final Supplier<Object> operation;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ProvisioningJob(@Named(POLL_PREDICATE_DATACENTER) Predicate<String> waitDataCenterUntilReady,
|
||||||
|
@Assisted String group, @Assisted Supplier<Object> operation) {
|
||||||
|
this.waitDataCenterUntilReady = waitDataCenterUntilReady;
|
||||||
|
this.group = checkNotNull(group, "group cannot be null");
|
||||||
|
this.operation = checkNotNull(operation, "operation cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object call() throws Exception {
|
||||||
|
waitDataCenterUntilReady.apply(group);
|
||||||
|
Object obj = operation.get();
|
||||||
|
waitDataCenterUntilReady.apply(group);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.concurrent;
|
||||||
|
|
||||||
|
import static com.google.common.util.concurrent.Futures.getUnchecked;
|
||||||
|
import static com.google.common.util.concurrent.MoreExecutors.listeningDecorator;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.jclouds.concurrent.config.WithSubmissionTrace;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delegates {@link Job} to single-threaded executor services based on it's group.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class ProvisioningManager implements Closeable {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final Map<String, ListeningExecutorService> workers
|
||||||
|
= new ConcurrentHashMap<String, ListeningExecutorService>(1);
|
||||||
|
|
||||||
|
private final AtomicBoolean terminated = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
public Object provision(ProvisioningJob job) {
|
||||||
|
if (terminated.get()) {
|
||||||
|
logger.warn("Job(%s) submitted but the provisioning manager is already closed", job);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup());
|
||||||
|
ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup());
|
||||||
|
return getUnchecked(workerGroup.submit(job));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ListeningExecutorService newExecutorService() {
|
||||||
|
return WithSubmissionTrace.wrap(listeningDecorator(Executors.newSingleThreadExecutor()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void newWorkerGroupIfAbsent(String name) {
|
||||||
|
if (!workers.containsKey(name))
|
||||||
|
workers.put(name, newExecutorService());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ListeningExecutorService getWorkerGroup(String name) {
|
||||||
|
newWorkerGroupIfAbsent(name);
|
||||||
|
return workers.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
terminated.set(true); // Do not allow to enqueue more jobs
|
||||||
|
Collection<ListeningExecutorService> executors = workers.values();
|
||||||
|
for (ListeningExecutorService executor : executors) {
|
||||||
|
List<Runnable> runnables = executor.shutdownNow();
|
||||||
|
if (!runnables.isEmpty())
|
||||||
|
logger.warn("when shutting down executor %s, runnables outstanding: %s", executor, runnables);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,147 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.config;
|
||||||
|
|
||||||
|
import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_PERIOD;
|
||||||
|
import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_MAX_PERIOD;
|
||||||
|
import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER;
|
||||||
|
import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_TIMEOUT;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.functions.IdentityFunction;
|
||||||
|
import org.jclouds.lifecycle.Closer;
|
||||||
|
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
|
||||||
|
import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
|
||||||
|
import org.jclouds.profitbricks.ProfitBricksApi;
|
||||||
|
import org.jclouds.profitbricks.compute.ProfitBricksComputeServiceAdapter;
|
||||||
|
import org.jclouds.profitbricks.compute.concurrent.ProvisioningJob;
|
||||||
|
import org.jclouds.profitbricks.compute.concurrent.ProvisioningManager;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
|
import org.jclouds.profitbricks.domain.Server;
|
||||||
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
|
import org.jclouds.profitbricks.compute.function.DataCenterToLocation;
|
||||||
|
import org.jclouds.profitbricks.compute.function.LocationToLocation;
|
||||||
|
import org.jclouds.profitbricks.compute.function.ProvisionableToImage;
|
||||||
|
import org.jclouds.profitbricks.compute.function.ServerToNodeMetadata;
|
||||||
|
import org.jclouds.profitbricks.compute.function.StorageToVolume;
|
||||||
|
import org.jclouds.profitbricks.compute.internal.ProvisioningStatusAware;
|
||||||
|
import org.jclouds.profitbricks.compute.internal.ProvisioningStatusPollingPredicate;
|
||||||
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
|
import org.jclouds.profitbricks.domain.internal.Provisionable;
|
||||||
|
import org.jclouds.util.Predicates2;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||||
|
|
||||||
|
public class ProfitBricksComputeServiceContextModule extends
|
||||||
|
ComputeServiceAdapterContextModule<Server, Hardware, Provisionable, DataCenter> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
super.configure();
|
||||||
|
|
||||||
|
install(new LocationsFromComputeServiceAdapterModule<Server, Hardware, Provisionable, DataCenter>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
install(new FactoryModuleBuilder().build(ProvisioningJob.Factory.class));
|
||||||
|
|
||||||
|
bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Singleton.class);
|
||||||
|
|
||||||
|
bind(new TypeLiteral<ComputeServiceAdapter<Server, Hardware, Provisionable, DataCenter>>() {
|
||||||
|
}).to(ProfitBricksComputeServiceAdapter.class);
|
||||||
|
|
||||||
|
bind(new TypeLiteral<Function<org.jclouds.profitbricks.domain.Location, Location>>() {
|
||||||
|
}).to(LocationToLocation.class);
|
||||||
|
|
||||||
|
bind(new TypeLiteral<Function<DataCenter, Location>>() {
|
||||||
|
}).to(DataCenterToLocation.class);
|
||||||
|
|
||||||
|
bind(new TypeLiteral<Function<Server, NodeMetadata>>() {
|
||||||
|
}).to(ServerToNodeMetadata.class);
|
||||||
|
|
||||||
|
bind(new TypeLiteral<Function<Provisionable, Image>>() {
|
||||||
|
}).to(ProvisionableToImage.class);
|
||||||
|
|
||||||
|
bind(new TypeLiteral<Function<Storage, Volume>>() {
|
||||||
|
}).to(StorageToVolume.class);
|
||||||
|
|
||||||
|
bind(new TypeLiteral<Function<Hardware, Hardware>>() {
|
||||||
|
}).to(Class.class.cast(IdentityFunction.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@Named(POLL_PREDICATE_DATACENTER)
|
||||||
|
Predicate<String> provideWaitDataCenterUntilAvailablePredicate(
|
||||||
|
final ProfitBricksApi api, ComputeConstants constants) {
|
||||||
|
return Predicates2.retry(new ProvisioningStatusPollingPredicate(
|
||||||
|
api, ProvisioningStatusAware.DATACENTER, ProvisioningState.AVAILABLE),
|
||||||
|
constants.pollTimeout(), constants.pollPeriod(), constants.pollMaxPeriod(), TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
ProvisioningManager provideProvisioningManager(Closer closer) {
|
||||||
|
ProvisioningManager provisioningManager = new ProvisioningManager();
|
||||||
|
closer.addToClose(provisioningManager);
|
||||||
|
|
||||||
|
return provisioningManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public static class ComputeConstants {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named(POLL_TIMEOUT)
|
||||||
|
private String pollTimeout;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named(POLL_PERIOD)
|
||||||
|
private String pollPeriod;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named(POLL_MAX_PERIOD)
|
||||||
|
private String pollMaxPeriod;
|
||||||
|
|
||||||
|
public long pollTimeout() {
|
||||||
|
return Long.parseLong(pollTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long pollPeriod() {
|
||||||
|
return Long.parseLong(pollPeriod);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long pollMaxPeriod() {
|
||||||
|
return Long.parseLong(pollMaxPeriod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.function;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
public class DataCenterToLocation implements Function<DataCenter, Location> {
|
||||||
|
|
||||||
|
private final Function<org.jclouds.profitbricks.domain.Location, Location> fnRegion;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
DataCenterToLocation(Function<org.jclouds.profitbricks.domain.Location, Location> fnRegion) {
|
||||||
|
this.fnRegion = fnRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location apply(DataCenter dataCenter) {
|
||||||
|
checkNotNull(dataCenter, "Null dataCenter");
|
||||||
|
|
||||||
|
LocationBuilder builder = new LocationBuilder()
|
||||||
|
.id(dataCenter.id())
|
||||||
|
.description(dataCenter.name())
|
||||||
|
.scope(LocationScope.ZONE)
|
||||||
|
.metadata(ImmutableMap.<String, Object>of(
|
||||||
|
"version", dataCenter.version(),
|
||||||
|
"state", dataCenter.state()));
|
||||||
|
if (dataCenter.location() != null)
|
||||||
|
builder.parent(fnRegion.apply(dataCenter.location()));
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.function;
|
||||||
|
|
||||||
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.location.suppliers.all.JustProvider;
|
||||||
|
import org.jclouds.profitbricks.domain.Location;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
public class LocationToLocation implements Function<Location, org.jclouds.domain.Location> {
|
||||||
|
|
||||||
|
private final JustProvider justProvider;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
LocationToLocation(JustProvider justProvider) {
|
||||||
|
this.justProvider = justProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.jclouds.domain.Location apply(Location in) {
|
||||||
|
return new LocationBuilder()
|
||||||
|
.id(in.getId())
|
||||||
|
.description(in.getDescription())
|
||||||
|
.scope(LocationScope.REGION)
|
||||||
|
.parent(Iterables.getOnlyElement(justProvider.get()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,215 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.function;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.ImageBuilder;
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
|
import org.jclouds.profitbricks.domain.Snapshot;
|
||||||
|
import org.jclouds.profitbricks.domain.internal.Provisionable;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
public class ProvisionableToImage implements Function<Provisionable, Image> {
|
||||||
|
|
||||||
|
private final ImageToImage fnImageToImage;
|
||||||
|
private final SnapshotToImage fnSnapshotToImage;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ProvisionableToImage(Function<org.jclouds.profitbricks.domain.Location, Location> fnRegion) {
|
||||||
|
this.fnImageToImage = new ImageToImage(fnRegion);
|
||||||
|
this.fnSnapshotToImage = new SnapshotToImage(fnRegion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image apply(Provisionable input) {
|
||||||
|
checkNotNull(input, "Cannot convert null input");
|
||||||
|
|
||||||
|
if (input instanceof org.jclouds.profitbricks.domain.Image)
|
||||||
|
return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input);
|
||||||
|
|
||||||
|
else if (input instanceof Snapshot)
|
||||||
|
return fnSnapshotToImage.apply((Snapshot) input);
|
||||||
|
|
||||||
|
else
|
||||||
|
throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '"
|
||||||
|
+ input.getClass().getCanonicalName() + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OsFamily mapOsFamily(OsType osType) {
|
||||||
|
if (osType == null)
|
||||||
|
return OsFamily.UNRECOGNIZED;
|
||||||
|
switch (osType) {
|
||||||
|
case WINDOWS:
|
||||||
|
return OsFamily.WINDOWS;
|
||||||
|
case LINUX:
|
||||||
|
return OsFamily.LINUX;
|
||||||
|
case UNRECOGNIZED:
|
||||||
|
case OTHER:
|
||||||
|
default:
|
||||||
|
return OsFamily.UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ImageToImage implements Function<org.jclouds.profitbricks.domain.Image, Image> {
|
||||||
|
|
||||||
|
private static final Pattern HAS_NUMBERS = Pattern.compile(".*\\d+.*");
|
||||||
|
|
||||||
|
private final Function<org.jclouds.profitbricks.domain.Location, Location> fnRegion;
|
||||||
|
|
||||||
|
ImageToImage(Function<org.jclouds.profitbricks.domain.Location, Location> fnRegion) {
|
||||||
|
this.fnRegion = fnRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image apply(org.jclouds.profitbricks.domain.Image from) {
|
||||||
|
String desc = from.name();
|
||||||
|
OsFamily osFamily = parseOsFamily(desc, from.osType());
|
||||||
|
|
||||||
|
OperatingSystem os = OperatingSystem.builder()
|
||||||
|
.description(osFamily.value())
|
||||||
|
.family(osFamily)
|
||||||
|
.version(parseVersion(desc))
|
||||||
|
.is64Bit(is64Bit(desc, from.type()))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return new ImageBuilder()
|
||||||
|
.ids(from.id())
|
||||||
|
.name(desc)
|
||||||
|
.location(fnRegion.apply(from.location()))
|
||||||
|
.status(Image.Status.AVAILABLE)
|
||||||
|
.operatingSystem(os)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private OsFamily parseOsFamily(String from, OsType fallbackValue) {
|
||||||
|
if (from != null)
|
||||||
|
try {
|
||||||
|
// ProfitBricks images names are usually in format:
|
||||||
|
// [osType]-[version]-[subversion]-..-[date-created]
|
||||||
|
String desc = from.toUpperCase().split("-")[0];
|
||||||
|
OsFamily osFamily = OsFamily.fromValue(desc);
|
||||||
|
checkArgument(osFamily != OsFamily.UNRECOGNIZED);
|
||||||
|
|
||||||
|
return osFamily;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
return mapOsFamily(fallbackValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String parseVersion(String from) {
|
||||||
|
if (from != null) {
|
||||||
|
String[] split = from.toLowerCase().split("-");
|
||||||
|
if (split.length >= 2) {
|
||||||
|
int i = 1; // usually on second token
|
||||||
|
String version = split[i];
|
||||||
|
while (!HAS_NUMBERS.matcher(version).matches())
|
||||||
|
version = split[++i];
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean is64Bit(String from, org.jclouds.profitbricks.domain.Image.Type type) {
|
||||||
|
switch (type) {
|
||||||
|
case CDROM:
|
||||||
|
if (!Strings.isNullOrEmpty(from))
|
||||||
|
return from.matches("x86_64|amd64");
|
||||||
|
case HDD: // HDD provided by ProfitBricks are always 64-bit
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SnapshotToImage implements Function<Snapshot, Image> {
|
||||||
|
|
||||||
|
private final Function<org.jclouds.profitbricks.domain.Location, Location> fnRegion;
|
||||||
|
|
||||||
|
SnapshotToImage(Function<org.jclouds.profitbricks.domain.Location, Location> fnRegion) {
|
||||||
|
this.fnRegion = fnRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image apply(Snapshot from) {
|
||||||
|
String textToParse = from.name() + from.description();
|
||||||
|
OsFamily osFamily = parseOsFamily(textToParse, from.osType());
|
||||||
|
|
||||||
|
OperatingSystem os = OperatingSystem.builder()
|
||||||
|
.description(osFamily.value())
|
||||||
|
.family(osFamily)
|
||||||
|
.is64Bit(true)
|
||||||
|
.version("00.00")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return new ImageBuilder()
|
||||||
|
.ids(from.id())
|
||||||
|
.name(from.name())
|
||||||
|
.description(from.description())
|
||||||
|
.location(fnRegion.apply(from.location()))
|
||||||
|
.status(mapStatus(from.state()))
|
||||||
|
.operatingSystem(os)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private OsFamily parseOsFamily(String text, OsType fallbackValue) {
|
||||||
|
if (text != null)
|
||||||
|
try {
|
||||||
|
// Attempt parsing OsFamily by scanning name and description
|
||||||
|
// @see ProfitBricksComputeServiceAdapter#L190
|
||||||
|
OsFamily[] families = OsFamily.values();
|
||||||
|
for (OsFamily family : families)
|
||||||
|
if (text.contains(family.value()))
|
||||||
|
return family;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
return mapOsFamily(fallbackValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Image.Status mapStatus(ProvisioningState state) {
|
||||||
|
if (state == null)
|
||||||
|
return Image.Status.UNRECOGNIZED;
|
||||||
|
switch (state) {
|
||||||
|
case AVAILABLE:
|
||||||
|
return Image.Status.AVAILABLE;
|
||||||
|
case DELETED:
|
||||||
|
return Image.Status.DELETED;
|
||||||
|
case ERROR:
|
||||||
|
return Image.Status.ERROR;
|
||||||
|
case INACTIVE:
|
||||||
|
case INPROCESS:
|
||||||
|
return Image.Status.PENDING;
|
||||||
|
default:
|
||||||
|
return Image.Status.UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,180 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.function;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Predicates.not;
|
||||||
|
import static org.jclouds.profitbricks.domain.OsType.LINUX;
|
||||||
|
import static org.jclouds.profitbricks.domain.OsType.WINDOWS;
|
||||||
|
import static org.jclouds.profitbricks.domain.Server.Status.BLOCKED;
|
||||||
|
import static org.jclouds.profitbricks.domain.Server.Status.CRASHED;
|
||||||
|
import static org.jclouds.profitbricks.domain.Server.Status.PAUSED;
|
||||||
|
import static org.jclouds.profitbricks.domain.Server.Status.RUNNING;
|
||||||
|
import static org.jclouds.profitbricks.domain.Server.Status.SHUTDOWN;
|
||||||
|
import static org.jclouds.profitbricks.domain.Server.Status.SHUTOFF;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.Processor;
|
||||||
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.profitbricks.domain.Nic;
|
||||||
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
|
import org.jclouds.profitbricks.domain.Server;
|
||||||
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
|
import org.jclouds.util.InetAddresses2.IsPrivateIPAddress;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.collect.Memoized;
|
||||||
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
|
|
||||||
|
public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
|
|
||||||
|
private final Function<Storage, Volume> fnVolume;
|
||||||
|
private final Supplier<Set<? extends Location>> locationSupply;
|
||||||
|
private final Function<List<Nic>, List<String>> fnCollectIps;
|
||||||
|
|
||||||
|
private final GroupNamingConvention groupNamingConvention;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ServerToNodeMetadata(Function<Storage, Volume> fnVolume,
|
||||||
|
@Memoized Supplier<Set<? extends Location>> locationsSupply,
|
||||||
|
GroupNamingConvention.Factory groupNamingConvention) {
|
||||||
|
this.fnVolume = fnVolume;
|
||||||
|
this.locationSupply = locationsSupply;
|
||||||
|
this.groupNamingConvention = groupNamingConvention.createWithoutPrefix();
|
||||||
|
this.fnCollectIps = new Function<List<Nic>, List<String>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> apply(List<Nic> in) {
|
||||||
|
List<String> ips = Lists.newArrayListWithExpectedSize(in.size());
|
||||||
|
for (Nic nic : in)
|
||||||
|
ips.addAll(nic.ips());
|
||||||
|
return ips;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NodeMetadata apply(final Server server) {
|
||||||
|
checkNotNull(server, "Null server");
|
||||||
|
|
||||||
|
// Map fetched dataCenterId with actual populated object
|
||||||
|
Location location = null;
|
||||||
|
if (server.dataCenter() != null)
|
||||||
|
location = Iterables.find(locationSupply.get(), new Predicate<Location>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Location t) {
|
||||||
|
return t.getId().equals(server.dataCenter().id());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
float size = 0f;
|
||||||
|
List<Volume> volumes = Lists.newArrayList();
|
||||||
|
List<Storage> storages = server.storages();
|
||||||
|
if (storages != null)
|
||||||
|
for (Storage storage : storages) {
|
||||||
|
size += storage.size();
|
||||||
|
volumes.add(fnVolume.apply(storage));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build hardware
|
||||||
|
String id = String.format("cpu=%d,ram=%d,disk=%.0f", server.cores(), server.ram(), size);
|
||||||
|
Hardware hardware = new HardwareBuilder()
|
||||||
|
.ids(id)
|
||||||
|
.name(id)
|
||||||
|
.ram(server.ram())
|
||||||
|
.processor(new Processor(server.cores(), 1d))
|
||||||
|
.hypervisor("kvm")
|
||||||
|
.volumes(volumes)
|
||||||
|
.location(location)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Collect ips
|
||||||
|
List<String> addresses = fnCollectIps.apply(server.nics());
|
||||||
|
|
||||||
|
// Build node
|
||||||
|
NodeMetadataBuilder nodeBuilder = new NodeMetadataBuilder();
|
||||||
|
nodeBuilder.ids(server.id())
|
||||||
|
.group(groupNamingConvention.extractGroup(server.name()))
|
||||||
|
.hostname(server.hostname())
|
||||||
|
.name(server.name())
|
||||||
|
.backendStatus(server.state().toString())
|
||||||
|
.status(mapStatus(server.status()))
|
||||||
|
.hardware(hardware)
|
||||||
|
.operatingSystem(mapOsType(server.osType()))
|
||||||
|
.location(location)
|
||||||
|
.privateAddresses(Iterables.filter(addresses, IsPrivateIPAddress.INSTANCE))
|
||||||
|
.publicAddresses(Iterables.filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
|
||||||
|
|
||||||
|
return nodeBuilder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
static NodeMetadata.Status mapStatus(Server.Status status) {
|
||||||
|
if (status == null)
|
||||||
|
return NodeMetadata.Status.UNRECOGNIZED;
|
||||||
|
switch (status) {
|
||||||
|
case SHUTDOWN:
|
||||||
|
case SHUTOFF:
|
||||||
|
case PAUSED:
|
||||||
|
return NodeMetadata.Status.SUSPENDED;
|
||||||
|
case RUNNING:
|
||||||
|
return NodeMetadata.Status.RUNNING;
|
||||||
|
case BLOCKED:
|
||||||
|
return NodeMetadata.Status.PENDING;
|
||||||
|
case CRASHED:
|
||||||
|
return NodeMetadata.Status.ERROR;
|
||||||
|
default:
|
||||||
|
return NodeMetadata.Status.UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static OperatingSystem mapOsType(OsType osType) {
|
||||||
|
if (osType != null)
|
||||||
|
switch (osType) {
|
||||||
|
case WINDOWS:
|
||||||
|
return OperatingSystem.builder()
|
||||||
|
.description(OsFamily.WINDOWS.value())
|
||||||
|
.family(OsFamily.WINDOWS)
|
||||||
|
.build();
|
||||||
|
case LINUX:
|
||||||
|
return OperatingSystem.builder()
|
||||||
|
.description(OsFamily.LINUX.value())
|
||||||
|
.family(OsFamily.LINUX)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
return OperatingSystem.builder()
|
||||||
|
.description(OsFamily.UNRECOGNIZED.value())
|
||||||
|
.family(OsFamily.UNRECOGNIZED)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.function;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.compute.domain.VolumeBuilder;
|
||||||
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
public class StorageToVolume implements Function<Storage, Volume> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Volume apply(Storage storage) {
|
||||||
|
checkNotNull(storage, "Null storage");
|
||||||
|
|
||||||
|
String device = "";
|
||||||
|
if (storage.deviceNumber() != null)
|
||||||
|
device = storage.deviceNumber().toString();
|
||||||
|
|
||||||
|
return new VolumeBuilder()
|
||||||
|
.id(storage.id())
|
||||||
|
.size(storage.size())
|
||||||
|
.bootDevice(storage.bootDevice())
|
||||||
|
.device(device)
|
||||||
|
.durable(true)
|
||||||
|
.type(Volume.Type.LOCAL)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ import org.jclouds.profitbricks.ProfitBricksApi;
|
||||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A custom predicate for waiting until a virtual resource satisfies the given expected status
|
* A custom predicate for waiting until a virtual resource satisfies the given expected status
|
||||||
|
@ -45,19 +46,24 @@ public class ProvisioningStatusPollingPredicate implements Predicate<String> {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(String input) {
|
public boolean apply(String input) {
|
||||||
checkNotNull(input, "Virtual item id can't be null.");
|
checkNotNull(input, "Virtual item id can't be null.");
|
||||||
switch (domain) {
|
try {
|
||||||
case DATACENTER:
|
switch (domain) {
|
||||||
return expect == api.dataCenterApi().getDataCenterState(input);
|
case DATACENTER:
|
||||||
case SERVER:
|
return expect == api.dataCenterApi().getDataCenterState(input);
|
||||||
return expect == api.serverApi().getServer(input).state();
|
case SERVER:
|
||||||
case STORAGE:
|
return expect == api.serverApi().getServer(input).state();
|
||||||
return expect == api.storageApi().getStorage(input).state();
|
case STORAGE:
|
||||||
case NIC:
|
return expect == api.storageApi().getStorage(input).state();
|
||||||
return expect == api.nicApi().getNic(input).state();
|
case NIC:
|
||||||
case SNAPSHOT:
|
return expect == api.nicApi().getNic(input).state();
|
||||||
return expect == api.snapshotApi().getSnapshot(input).state();
|
case SNAPSHOT:
|
||||||
default:
|
return expect == api.snapshotApi().getSnapshot(input).state();
|
||||||
throw new IllegalArgumentException("Unknown domain '" + domain + "'");
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown domain '" + domain + "'");
|
||||||
|
}
|
||||||
|
} catch (ResourceNotFoundException ex) {
|
||||||
|
// After provisioning, a node might still not be "fetchable" via API
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.config;
|
||||||
|
|
||||||
|
public class ProfitBricksComputeProperties {
|
||||||
|
|
||||||
|
public static final String POLL_PREDICATE_DATACENTER = "jclouds.profitbricks.predicate.datacenter";
|
||||||
|
|
||||||
|
public static final String POLL_TIMEOUT = "jclouds.profitbricks.poll.timeout";
|
||||||
|
public static final String POLL_PERIOD = "jclouds.profitbricks.operation.poll.initial-period";
|
||||||
|
public static final String POLL_MAX_PERIOD = "jclouds.profitbricks.operation.poll.max-period";
|
||||||
|
|
||||||
|
private ProfitBricksComputeProperties() {
|
||||||
|
throw new AssertionError("Intentionally unimplemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,20 +17,18 @@
|
||||||
package org.jclouds.profitbricks.domain;
|
package org.jclouds.profitbricks.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.net.InetAddresses.isInetAddress;
|
||||||
import static org.jclouds.profitbricks.util.MacAddresses.isMacAddress;
|
import static org.jclouds.profitbricks.util.MacAddresses.isMacAddress;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.profitbricks.domain.internal.FirewallRuleCommonProperties;
|
import org.jclouds.profitbricks.domain.internal.FirewallRuleCommonProperties;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import static com.google.common.net.InetAddresses.isInetAddress;
|
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public abstract class Firewall {
|
public abstract class Firewall {
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.domain;
|
package org.jclouds.profitbricks.domain;
|
||||||
|
|
||||||
|
import org.jclouds.profitbricks.domain.internal.Provisionable;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public abstract class Image {
|
public abstract class Image implements Provisionable {
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
|
|
||||||
|
@ -34,46 +36,21 @@ public abstract class Image {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String id();
|
|
||||||
|
|
||||||
public abstract String name();
|
|
||||||
|
|
||||||
public abstract float size(); // MB
|
|
||||||
|
|
||||||
public abstract Type type();
|
public abstract Type type();
|
||||||
|
|
||||||
public abstract Location location();
|
|
||||||
|
|
||||||
public abstract OsType osType();
|
|
||||||
|
|
||||||
public abstract boolean isPublic();
|
public abstract boolean isPublic();
|
||||||
|
|
||||||
public abstract boolean isWriteable();
|
public abstract boolean isWriteable();
|
||||||
|
|
||||||
public abstract boolean isBootable();
|
public abstract boolean isBootable();
|
||||||
|
|
||||||
public abstract boolean isCpuHotPlug();
|
|
||||||
|
|
||||||
public abstract boolean isCpuHotUnPlug();
|
|
||||||
|
|
||||||
public abstract boolean isRamHotPlug();
|
|
||||||
|
|
||||||
public abstract boolean isRamHotUnPlug();
|
|
||||||
|
|
||||||
public abstract boolean isNicHotPlug();
|
|
||||||
|
|
||||||
public abstract boolean isNicHotUnPlug();
|
|
||||||
|
|
||||||
public abstract boolean isDiscVirtioHotPlug();
|
|
||||||
|
|
||||||
public abstract boolean isDiscVirtioHotUnPlug();
|
|
||||||
|
|
||||||
public static Image create(String id, String name, float size, Type type, Location location, OsType osType,
|
public static Image create(String id, String name, float size, Type type, Location location, OsType osType,
|
||||||
boolean isPublic, boolean isWriteable, boolean isBootable, boolean cpuHotPlug, boolean cpuHotUnPlug,
|
boolean isPublic, Boolean isWriteable, Boolean isBootable, Boolean cpuHotPlug, Boolean cpuHotUnPlug,
|
||||||
boolean ramHotPlug, boolean ramHotUnPlug, boolean nicHotPlug, boolean nicHotUnPlug,
|
Boolean ramHotPlug, Boolean ramHotUnPlug, Boolean nicHotPlug, Boolean nicHotUnPlug,
|
||||||
boolean discVirtioHotPlug, boolean discVirtioHotUnPlug) {
|
Boolean discVirtioHotPlug, Boolean discVirtioHotUnPlug) {
|
||||||
return new AutoValue_Image(id, name, size, type, location, osType, isPublic, isWriteable,
|
return new AutoValue_Image(cpuHotPlug, cpuHotUnPlug, ramHotPlug, ramHotUnPlug, nicHotPlug, nicHotUnPlug,
|
||||||
isBootable, cpuHotPlug, cpuHotUnPlug, ramHotPlug, ramHotUnPlug, nicHotPlug, nicHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug);
|
discVirtioHotPlug, discVirtioHotUnPlug, id, name, size, location, osType, type, isPublic, isWriteable,
|
||||||
|
isBootable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -84,56 +61,18 @@ public abstract class Image {
|
||||||
return builder().fromImage(this);
|
return builder().fromImage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder extends Provisionable.Builder<Builder, Image> {
|
||||||
|
|
||||||
private String id;
|
|
||||||
private String name;
|
|
||||||
private float size;
|
|
||||||
private Type type;
|
private Type type;
|
||||||
private Location location;
|
|
||||||
private OsType osType;
|
|
||||||
private boolean isPublic;
|
private boolean isPublic;
|
||||||
private boolean isWriteable;
|
private boolean isWriteable;
|
||||||
private boolean isBootable;
|
private boolean isBootable;
|
||||||
private boolean cpuHotPlug;
|
|
||||||
private boolean cpuHotUnPlug;
|
|
||||||
private boolean ramHotPlug;
|
|
||||||
private boolean ramHotUnPlug;
|
|
||||||
private boolean nicHotPlug;
|
|
||||||
private boolean nicHotUnPlug;
|
|
||||||
private boolean discVirtioHotPlug;
|
|
||||||
private boolean discVirtioHotUnPlug;
|
|
||||||
|
|
||||||
public Builder id(String id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder size(float size) {
|
|
||||||
this.size = size;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder type(Type type) {
|
public Builder type(Type type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder osType(OsType osType) {
|
|
||||||
this.osType = osType;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder location(Location location) {
|
|
||||||
this.location = location;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder isPublic(boolean isPublic) {
|
public Builder isPublic(boolean isPublic) {
|
||||||
this.isPublic = isPublic;
|
this.isPublic = isPublic;
|
||||||
return this;
|
return this;
|
||||||
|
@ -149,46 +88,7 @@ public abstract class Image {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder isCpuHotPlug(boolean cpuHotPlug) {
|
@Override
|
||||||
this.cpuHotPlug = cpuHotPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder isCpuHotUnPlug(boolean cpuHotUnPlug) {
|
|
||||||
this.cpuHotUnPlug = cpuHotUnPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder isRamHotPlug(boolean ramHotPlug) {
|
|
||||||
this.ramHotPlug = ramHotPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder isRamHotUnPlug(boolean ramHotUnPlug) {
|
|
||||||
this.ramHotUnPlug = ramHotUnPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder isNicHotPlug(boolean nicHotPlug) {
|
|
||||||
this.nicHotPlug = nicHotPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder isNicHotUnPlug(boolean nicHotUnPlug) {
|
|
||||||
this.nicHotUnPlug = nicHotUnPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder isDiscVirtioHotPlug(boolean discVirtioHotPlug) {
|
|
||||||
this.discVirtioHotPlug = discVirtioHotPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder isDiscVirtioHotUnPlug(boolean discVirtioHotUnPlug) {
|
|
||||||
this.discVirtioHotUnPlug = discVirtioHotUnPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image build() {
|
public Image build() {
|
||||||
return Image.create(id, name, size, type, location, osType, isPublic, isWriteable, isBootable, cpuHotPlug, cpuHotUnPlug,
|
return Image.create(id, name, size, type, location, osType, isPublic, isWriteable, isBootable, cpuHotPlug, cpuHotUnPlug,
|
||||||
ramHotPlug, ramHotUnPlug, nicHotPlug, nicHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug);
|
ramHotPlug, ramHotUnPlug, nicHotPlug, nicHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug);
|
||||||
|
@ -199,7 +99,12 @@ public abstract class Image {
|
||||||
.isDiscVirtioHotPlug(in.isDiscVirtioHotPlug()).isDiscVirtioHotUnPlug(in.isDiscVirtioHotUnPlug())
|
.isDiscVirtioHotPlug(in.isDiscVirtioHotPlug()).isDiscVirtioHotUnPlug(in.isDiscVirtioHotUnPlug())
|
||||||
.isNicHotPlug(in.isNicHotPlug()).isNicHotUnPlug(in.isNicHotUnPlug()).isPublic(in.isPublic())
|
.isNicHotPlug(in.isNicHotPlug()).isNicHotUnPlug(in.isNicHotUnPlug()).isPublic(in.isPublic())
|
||||||
.isRamHotPlug(in.isRamHotPlug()).isRamHotUnPlug(in.isRamHotUnPlug()).isWriteable(in.isWriteable())
|
.isRamHotPlug(in.isRamHotPlug()).isRamHotUnPlug(in.isRamHotUnPlug()).isWriteable(in.isWriteable())
|
||||||
.location(in.location()).name(in.name()).osType(in.osType()).size(in.size());
|
.location(in.location()).name(in.name()).osType(in.osType()).size(in.size()).type(in.type());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder self() {
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,13 +47,10 @@ public abstract class LoadBalancer {
|
||||||
public abstract String name();
|
public abstract String name();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract Algorithm loadBalancerAlgorithm();
|
public abstract Algorithm algorithm();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract String dataCenterId();
|
public abstract DataCenter dataCenter();
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public abstract String dataCenterVersion();
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract Boolean internetAccess();
|
public abstract Boolean internetAccess();
|
||||||
|
@ -79,10 +76,11 @@ public abstract class LoadBalancer {
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract List<Firewall> firewalls();
|
public abstract List<Firewall> firewalls();
|
||||||
|
|
||||||
public static LoadBalancer create(String id, String name, Algorithm loadBalancerAlgorithm,
|
public static LoadBalancer create(String id, String name, Algorithm algorithm, DataCenter dataCenter,
|
||||||
String dataCenterId, String dataCenterVersion, boolean internetAccess,
|
boolean internetAccess, String ip, String lanId, ProvisioningState state, Date creationTime,
|
||||||
String ip, String lanId, ProvisioningState state, Date creationTime, Date lastModificationTime, List<Server> balancedServers, List<Firewall> firewalls) {
|
Date lastModificationTime, List<Server> balancedServers, List<Firewall> firewalls) {
|
||||||
return new AutoValue_LoadBalancer(id, name, loadBalancerAlgorithm, dataCenterId, dataCenterVersion, internetAccess, ip, lanId, state, creationTime, lastModificationTime,
|
return new AutoValue_LoadBalancer(id, name, algorithm, dataCenter,
|
||||||
|
internetAccess, ip, lanId, state, creationTime, lastModificationTime,
|
||||||
balancedServers != null ? ImmutableList.copyOf(balancedServers) : ImmutableList.<Server>of(),
|
balancedServers != null ? ImmutableList.copyOf(balancedServers) : ImmutableList.<Server>of(),
|
||||||
firewalls != null ? ImmutableList.copyOf(firewalls) : ImmutableList.<Firewall>of());
|
firewalls != null ? ImmutableList.copyOf(firewalls) : ImmutableList.<Firewall>of());
|
||||||
}
|
}
|
||||||
|
@ -102,11 +100,9 @@ public abstract class LoadBalancer {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private Algorithm loadBalancerAlgorithm;
|
private Algorithm algorithm;
|
||||||
|
|
||||||
private String dataCenterId;
|
private DataCenter dataCenter;
|
||||||
|
|
||||||
private String dataCenterVersion;
|
|
||||||
|
|
||||||
private boolean internetAccess;
|
private boolean internetAccess;
|
||||||
|
|
||||||
|
@ -134,18 +130,13 @@ public abstract class LoadBalancer {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder loadBalancerAlgorithm(Algorithm loadBalancerAlgorithm) {
|
public Builder algorithm(Algorithm algorithm) {
|
||||||
this.loadBalancerAlgorithm = loadBalancerAlgorithm;
|
this.algorithm = algorithm;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder dataCenterId(String dataCenterId) {
|
public Builder dataCenter(DataCenter dataCenter) {
|
||||||
this.dataCenterId = dataCenterId;
|
this.dataCenter = dataCenter;
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder dataCenterVersion(String dataCenterVersion) {
|
|
||||||
this.dataCenterVersion = dataCenterVersion;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,13 +182,16 @@ public abstract class LoadBalancer {
|
||||||
|
|
||||||
public LoadBalancer build() {
|
public LoadBalancer build() {
|
||||||
checkIp(ip);
|
checkIp(ip);
|
||||||
return LoadBalancer.create(id, name, loadBalancerAlgorithm, dataCenterId, dataCenterVersion, internetAccess, ip, lanId, state, creationTime, lastModificationTime, balancedServers, firewalls);
|
return LoadBalancer.create(id, name, algorithm, dataCenter, internetAccess,
|
||||||
|
ip, lanId, state, creationTime, lastModificationTime, balancedServers, firewalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromLoadBalancer(LoadBalancer in) {
|
public Builder fromLoadBalancer(LoadBalancer in) {
|
||||||
return this.id(in.id()).name(in.name()).loadBalancerAlgorithm(in.loadBalancerAlgorithm())
|
return this.id(in.id()).name(in.name()).algorithm(in.algorithm())
|
||||||
.dataCenterId(in.dataCenterId()).dataCenterVersion(in.dataCenterVersion()).internetAccess(in.internetAccess())
|
.dataCenter(in.dataCenter()).internetAccess(in.internetAccess())
|
||||||
.ip(in.ip()).lanId(in.lanId()).state(in.state()).creationTime(in.creationTime()).lastModificationTime(in.lastModificationTime()).balancedServers(in.balancedServers()).firewalls(in.firewalls());
|
.ip(in.ip()).lanId(in.lanId()).state(in.state()).creationTime(in.creationTime())
|
||||||
|
.lastModificationTime(in.lastModificationTime()).balancedServers(in.balancedServers())
|
||||||
|
.firewalls(in.firewalls());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,22 +18,28 @@ package org.jclouds.profitbricks.domain;
|
||||||
|
|
||||||
public enum Location {
|
public enum Location {
|
||||||
|
|
||||||
DE_FKB("de/fkb"),
|
DE_FKB("de/fkb", "Germany, Karlsruhe"),
|
||||||
DE_FRA("de/fra"),
|
DE_FRA("de/fra", "Germany, Frankfurt (M)"),
|
||||||
US_LAS("us/las"),
|
US_LAS("us/las", "USA, Las Vegas"),
|
||||||
US_LAS_DEV("us/lasdev"),
|
US_LASDEV("us/lasdev", "USA Developer cluster"),
|
||||||
UNRECOGNIZED("unknown");
|
UNRECOGNIZED("unrecognized", "Unrecognized location");
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
Location(String id) {
|
Location(String id, String description) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String value() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
public static Location fromValue(String v) {
|
public static Location fromValue(String v) {
|
||||||
try {
|
try {
|
||||||
return valueOf(v);
|
return valueOf(v);
|
||||||
|
|
|
@ -17,17 +17,15 @@
|
||||||
package org.jclouds.profitbricks.domain;
|
package org.jclouds.profitbricks.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.net.InetAddresses.isInetAddress;
|
||||||
import com.google.auto.value.AutoValue;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import static com.google.common.net.InetAddresses.isInetAddress;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public abstract class Nic {
|
public abstract class Nic {
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.profitbricks.domain.internal.HotPluggable;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -51,6 +52,9 @@ public abstract class Server implements ServerCommonProperties {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract DataCenter dataCenter();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract String id();
|
public abstract String id();
|
||||||
|
|
||||||
|
@ -89,17 +93,23 @@ public abstract class Server implements ServerCommonProperties {
|
||||||
public abstract String balancedNicId();
|
public abstract String balancedNicId();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract Boolean activate();
|
public abstract Boolean loadBalanced();
|
||||||
|
|
||||||
public static Server create(String id, String name, int cores, int ram, Boolean hasInternetAccess, ProvisioningState state,
|
@Nullable
|
||||||
Status status, OsType osType, AvailabilityZone availabilityZone, Date creationTime, Date lastModificationTime,
|
public abstract String hostname(); // Non-profitbricks property; Added to hold hostname parsed from image temporarily
|
||||||
List<Storage> storages, List<Nic> nics, Boolean isCpuHotPlug, Boolean isRamHotPlug, Boolean isNicHotPlug,
|
|
||||||
Boolean isNicHotUnPlug, Boolean isDiscVirtioHotPlug, Boolean isDiscVirtioHotUnPlug, String balancedNicId, boolean activate) {
|
public static Server create(DataCenter dataCenter, String id, String name, int cores, int ram,
|
||||||
return new AutoValue_Server(isCpuHotPlug, isRamHotPlug, isNicHotPlug, isNicHotUnPlug, isDiscVirtioHotPlug, isDiscVirtioHotUnPlug,
|
Boolean hasInternetAccess, ProvisioningState state, Status status, OsType osType,
|
||||||
cores, ram, id, name, hasInternetAccess, state, status, osType, availabilityZone, creationTime, lastModificationTime,
|
AvailabilityZone availabilityZone, Date creationTime, Date lastModificationTime, List<Storage> storages,
|
||||||
|
List<Nic> nics, Boolean isCpuHotPlug, Boolean isRamHotPlug, Boolean isNicHotPlug, Boolean isNicHotUnPlug,
|
||||||
|
Boolean isDiscVirtioHotPlug, Boolean isDiscVirtioHotUnPlug, String balancedNicId, Boolean loadBalanced,
|
||||||
|
String hostname) {
|
||||||
|
return new AutoValue_Server(isCpuHotPlug, null, isRamHotPlug, null, isNicHotPlug, isNicHotUnPlug, isDiscVirtioHotPlug,
|
||||||
|
isDiscVirtioHotUnPlug, cores, ram, dataCenter, id, name, hasInternetAccess, state, status, osType,
|
||||||
|
availabilityZone, creationTime, lastModificationTime,
|
||||||
storages != null ? ImmutableList.copyOf(storages) : Lists.<Storage>newArrayList(),
|
storages != null ? ImmutableList.copyOf(storages) : Lists.<Storage>newArrayList(),
|
||||||
nics != null ? ImmutableList.copyOf(nics) : Lists.<Nic>newArrayList(), balancedNicId, activate);
|
nics != null ? ImmutableList.copyOf(nics) : Lists.<Nic>newArrayList(),
|
||||||
|
balancedNicId, loadBalanced, hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DescribingBuilder builder() {
|
public static DescribingBuilder builder() {
|
||||||
|
@ -110,17 +120,11 @@ public abstract class Server implements ServerCommonProperties {
|
||||||
return builder().fromServer(this);
|
return builder().fromServer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class Builder<B extends Builder, D extends ServerCommonProperties> {
|
public abstract static class Builder<B extends Builder, D extends ServerCommonProperties> extends HotPluggable.Builder<B, D> {
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
protected int cores;
|
protected int cores;
|
||||||
protected int ram;
|
protected int ram;
|
||||||
protected Boolean cpuHotPlug;
|
|
||||||
protected Boolean ramHotPlug;
|
|
||||||
protected Boolean nicHotPlug;
|
|
||||||
protected Boolean nicHotUnPlug;
|
|
||||||
protected Boolean discVirtioHotPlug;
|
|
||||||
protected Boolean discVirtioHotUnPlug;
|
|
||||||
|
|
||||||
public B name(String name) {
|
public B name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -136,45 +140,11 @@ public abstract class Server implements ServerCommonProperties {
|
||||||
this.ram = ram;
|
this.ram = ram;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public B isCpuHotPlug(Boolean cpuHotPlug) {
|
|
||||||
this.cpuHotPlug = cpuHotPlug;
|
|
||||||
return self();
|
|
||||||
}
|
|
||||||
|
|
||||||
public B isRamHotPlug(Boolean ramHotPlug) {
|
|
||||||
this.ramHotPlug = ramHotPlug;
|
|
||||||
return self();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public B isNicHotPlug(Boolean nicHotPlug) {
|
|
||||||
this.nicHotPlug = nicHotPlug;
|
|
||||||
return self();
|
|
||||||
}
|
|
||||||
|
|
||||||
public B isNicHotUnPlug(Boolean nicHotUnPlug) {
|
|
||||||
this.nicHotUnPlug = nicHotUnPlug;
|
|
||||||
return self();
|
|
||||||
}
|
|
||||||
|
|
||||||
public B isDiscVirtioHotPlug(Boolean discVirtioHotPlug) {
|
|
||||||
this.discVirtioHotPlug = discVirtioHotPlug;
|
|
||||||
return self();
|
|
||||||
}
|
|
||||||
|
|
||||||
public B isDiscVirtioHotUnPlug(Boolean discVirtioHotUnPlug) {
|
|
||||||
this.discVirtioHotUnPlug = discVirtioHotUnPlug;
|
|
||||||
return self();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract B self();
|
|
||||||
|
|
||||||
public abstract D build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DescribingBuilder extends Builder<DescribingBuilder, Server> {
|
public static class DescribingBuilder extends Builder<DescribingBuilder, Server> {
|
||||||
|
|
||||||
|
private DataCenter dataCenter;
|
||||||
private String id;
|
private String id;
|
||||||
private ProvisioningState state;
|
private ProvisioningState state;
|
||||||
private Status status;
|
private Status status;
|
||||||
|
@ -185,8 +155,14 @@ public abstract class Server implements ServerCommonProperties {
|
||||||
private Boolean hasInternetAccess;
|
private Boolean hasInternetAccess;
|
||||||
private List<Storage> storages;
|
private List<Storage> storages;
|
||||||
private List<Nic> nics;
|
private List<Nic> nics;
|
||||||
private boolean activate;
|
private Boolean loadBalanced;
|
||||||
private String balancedNicId;
|
private String balancedNicId;
|
||||||
|
private String hostname;
|
||||||
|
|
||||||
|
public DescribingBuilder dataCenter(DataCenter dataCenter) {
|
||||||
|
this.dataCenter = dataCenter;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DescribingBuilder id(String id) {
|
public DescribingBuilder id(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -243,16 +219,21 @@ public abstract class Server implements ServerCommonProperties {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescribingBuilder activate(boolean activate) {
|
public DescribingBuilder loadBalanced(Boolean loadBalanced) {
|
||||||
this.activate = activate;
|
this.loadBalanced = loadBalanced;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescribingBuilder hostname(String hostname) {
|
||||||
|
this.hostname = hostname;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Server build() {
|
public Server build() {
|
||||||
return Server.create(id, name, cores, ram, hasInternetAccess, state, status, osType, zone, creationTime,
|
return Server.create(dataCenter, id, name, cores, ram, hasInternetAccess, state, status, osType, zone, creationTime,
|
||||||
lastModificationTime, storages, nics, cpuHotPlug, ramHotPlug, nicHotPlug, nicHotUnPlug,
|
lastModificationTime, storages, nics, cpuHotPlug, ramHotPlug, nicHotPlug, nicHotUnPlug,
|
||||||
discVirtioHotPlug, discVirtioHotUnPlug, balancedNicId, activate);
|
discVirtioHotPlug, discVirtioHotUnPlug, balancedNicId, loadBalanced, hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DescribingBuilder fromServer(Server in) {
|
private DescribingBuilder fromServer(Server in) {
|
||||||
|
@ -261,7 +242,8 @@ public abstract class Server implements ServerCommonProperties {
|
||||||
.isDiscVirtioHotUnPlug(in.isDiscVirtioHotUnPlug()).isNicHotPlug(in.isNicHotPlug())
|
.isDiscVirtioHotUnPlug(in.isDiscVirtioHotUnPlug()).isNicHotPlug(in.isNicHotPlug())
|
||||||
.isNicHotUnPlug(in.isNicHotUnPlug()).isRamHotPlug(in.isRamHotPlug())
|
.isNicHotUnPlug(in.isNicHotUnPlug()).isRamHotPlug(in.isRamHotPlug())
|
||||||
.lastModificationTime(in.lastModificationTime()).name(in.name()).osType(in.osType()).ram(in.ram())
|
.lastModificationTime(in.lastModificationTime()).name(in.name()).osType(in.osType()).ram(in.ram())
|
||||||
.state(in.state()).status(in.status()).storages(in.storages()).nics(in.nics()).balancedNicId(in.balancedNicId()).activate(in.activate());
|
.state(in.state()).status(in.status()).storages(in.storages()).nics(in.nics()).dataCenter(in.dataCenter())
|
||||||
|
.balancedNicId(balancedNicId).loadBalanced(loadBalanced).hostname(hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -308,14 +290,15 @@ public abstract class Server implements ServerCommonProperties {
|
||||||
return create(dataCenterId, name, core, ram, "", "", null, false, null, null, null, null, null, null, null, null);
|
return create(dataCenterId, name, core, ram, "", "", null, false, null, null, null, null, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CreatePayload create(String dataCenterId, String name, int cores, int ram, String bootFromStorageId, String bootFromImageId,
|
public static CreatePayload create(String dataCenterId, String name, int cores, int ram, String bootFromStorageId,
|
||||||
Integer lanId, Boolean hasInternetAccess, AvailabilityZone availabilityZone, OsType osType, Boolean isCpuHotPlug, Boolean isRamHotPlug,
|
String bootFromImageId, Integer lanId, Boolean hasInternetAccess, AvailabilityZone availabilityZone,
|
||||||
Boolean isNicHotPlug, Boolean isNicHotUnPlug, Boolean isDiscVirtioHotPlug, Boolean isDiscVirtioHotUnPlug) {
|
OsType osType, Boolean isCpuHotPlug, Boolean isRamHotPlug, Boolean isNicHotPlug, Boolean isNicHotUnPlug,
|
||||||
|
Boolean isDiscVirtioHotPlug, Boolean isDiscVirtioHotUnPlug) {
|
||||||
validateCores(cores);
|
validateCores(cores);
|
||||||
validateRam(ram, isRamHotPlug);
|
validateRam(ram, isRamHotPlug);
|
||||||
return new AutoValue_Server_Request_CreatePayload(isCpuHotPlug, isRamHotPlug, isNicHotPlug, isNicHotUnPlug, isDiscVirtioHotPlug,
|
return new AutoValue_Server_Request_CreatePayload(isCpuHotPlug, null, isRamHotPlug, null, isNicHotPlug,
|
||||||
isDiscVirtioHotUnPlug, name, cores, ram, dataCenterId, bootFromStorageId, bootFromImageId, lanId, hasInternetAccess,
|
isNicHotUnPlug, isDiscVirtioHotPlug, isDiscVirtioHotUnPlug, name, cores, ram, dataCenterId,
|
||||||
availabilityZone, osType);
|
bootFromStorageId, bootFromImageId, lanId, hasInternetAccess, availabilityZone, osType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends Server.Builder<Builder, CreatePayload> {
|
public static class Builder extends Server.Builder<Builder, CreatePayload> {
|
||||||
|
@ -406,8 +389,9 @@ public abstract class Server implements ServerCommonProperties {
|
||||||
public static UpdatePayload create(String id, String name, int cores, int ram, String bootFromStorageId, String bootFromImageId,
|
public static UpdatePayload create(String id, String name, int cores, int ram, String bootFromStorageId, String bootFromImageId,
|
||||||
AvailabilityZone availabilityZone, OsType osType, Boolean isCpuHotPlug, Boolean isRamHotPlug, Boolean isNicHotPlug,
|
AvailabilityZone availabilityZone, OsType osType, Boolean isCpuHotPlug, Boolean isRamHotPlug, Boolean isNicHotPlug,
|
||||||
Boolean isNicHotUnPlug, Boolean isDiscVirtioHotPlug, Boolean isDiscVirtioHotUnPlug) {
|
Boolean isNicHotUnPlug, Boolean isDiscVirtioHotPlug, Boolean isDiscVirtioHotUnPlug) {
|
||||||
return new AutoValue_Server_Request_UpdatePayload(isCpuHotPlug, isRamHotPlug, isNicHotPlug, isNicHotUnPlug, isDiscVirtioHotPlug,
|
return new AutoValue_Server_Request_UpdatePayload(isCpuHotPlug, null, isRamHotPlug, null, isNicHotPlug,
|
||||||
isDiscVirtioHotUnPlug, cores, ram, name, id, bootFromStorageId, bootFromImageId, availabilityZone, osType);
|
isNicHotUnPlug, isDiscVirtioHotPlug, isDiscVirtioHotUnPlug, cores, ram, name, id, bootFromStorageId,
|
||||||
|
bootFromImageId, availabilityZone, osType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends Server.Builder<Builder, UpdatePayload> {
|
public static class Builder extends Server.Builder<Builder, UpdatePayload> {
|
||||||
|
|
|
@ -17,45 +17,34 @@
|
||||||
package org.jclouds.profitbricks.domain;
|
package org.jclouds.profitbricks.domain;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jclouds.profitbricks.domain.internal.HotPluggable;
|
||||||
|
import org.jclouds.profitbricks.domain.internal.Provisionable;
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public abstract class Snapshot {
|
public abstract class Snapshot implements Provisionable {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@Override
|
||||||
public abstract String id();
|
public abstract String id();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@Override
|
||||||
public abstract String name();
|
public abstract String name();
|
||||||
|
|
||||||
public abstract float size();
|
|
||||||
|
|
||||||
public abstract boolean bootable();
|
public abstract boolean bootable();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract String description();
|
public abstract String description();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@Override
|
||||||
public abstract OsType osType();
|
public abstract OsType osType();
|
||||||
|
|
||||||
public abstract boolean cpuHotPlug();
|
|
||||||
|
|
||||||
public abstract boolean cpuHotUnPlug();
|
|
||||||
|
|
||||||
public abstract boolean discVirtioHotPlug();
|
|
||||||
|
|
||||||
public abstract boolean discVirtioHotUnPlug();
|
|
||||||
|
|
||||||
public abstract boolean ramHotPlug();
|
|
||||||
|
|
||||||
public abstract boolean ramHotUnPlug();
|
|
||||||
|
|
||||||
public abstract boolean nicHotPlug();
|
|
||||||
|
|
||||||
public abstract boolean nicHotUnPlug();
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract Date creationTime();
|
public abstract Date creationTime();
|
||||||
|
|
||||||
|
@ -66,367 +55,237 @@ public abstract class Snapshot {
|
||||||
public abstract ProvisioningState state();
|
public abstract ProvisioningState state();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@Override
|
||||||
public abstract Location location();
|
public abstract Location location();
|
||||||
|
|
||||||
public static Snapshot create(String id, String name, float size, boolean bootable, String description, OsType osType, boolean cpuHotPlug, boolean cpuHotUnPlug,
|
public static Snapshot create(String id, String name, float size, boolean bootable, String description, OsType osType,
|
||||||
boolean discVirtioHotPlug, boolean discVirtioHotUnPlug, boolean ramHotPlug, boolean ramHotUnPlug,
|
Boolean cpuHotPlug, Boolean cpuHotUnPlug, Boolean discVirtioHotPlug, Boolean discVirtioHotUnPlug,
|
||||||
boolean nicHotPlug, boolean nicHotUnPlug, Date creationTime, Date lastModificationTime, ProvisioningState state, Location location) {
|
Boolean ramHotPlug, Boolean ramHotUnPlug, Boolean nicHotPlug, Boolean nicHotUnPlug, Date creationTime,
|
||||||
return new AutoValue_Snapshot(id, name, size, bootable, description, osType, cpuHotPlug, cpuHotUnPlug,
|
Date lastModificationTime, ProvisioningState state, Location location) {
|
||||||
discVirtioHotPlug, discVirtioHotUnPlug, ramHotPlug, ramHotUnPlug,
|
return new AutoValue_Snapshot(cpuHotPlug, cpuHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug, ramHotPlug,
|
||||||
nicHotPlug, nicHotUnPlug, creationTime, lastModificationTime, state, location);
|
ramHotUnPlug, nicHotPlug, nicHotUnPlug, size, id, name, bootable, description, osType, creationTime,
|
||||||
|
lastModificationTime, state, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder extends Provisionable.Builder<Builder, Snapshot> {
|
||||||
|
|
||||||
private String id;
|
|
||||||
@Nullable
|
|
||||||
private String name;
|
|
||||||
private float size;
|
|
||||||
private Date creationTime;
|
private Date creationTime;
|
||||||
private Date lastModificationTime;
|
private Date lastModificationTime;
|
||||||
private ProvisioningState state;
|
private ProvisioningState state;
|
||||||
private boolean bootable;
|
private boolean bootable;
|
||||||
@Nullable
|
|
||||||
private String description;
|
private String description;
|
||||||
private OsType osType;
|
|
||||||
private boolean cpuHotPlug;
|
|
||||||
private boolean cpuHotUnPlug;
|
|
||||||
private boolean discVirtioHotPlug;
|
|
||||||
private boolean discVirtioHotUnPlug;
|
|
||||||
private boolean ramHotPlug;
|
|
||||||
private boolean ramHotUnPlug;
|
|
||||||
private boolean nicHotPlug;
|
|
||||||
private boolean nicHotUnPlug;
|
|
||||||
private Location location;
|
|
||||||
|
|
||||||
public Builder id(String id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder size(float size) {
|
|
||||||
this.size = size;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder creationTime(Date creationTime) {
|
public Builder creationTime(Date creationTime) {
|
||||||
this.creationTime = creationTime;
|
this.creationTime = creationTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder lastModificationTime(Date lastModificationTime) {
|
public Builder lastModificationTime(Date lastModificationTime) {
|
||||||
this.lastModificationTime = lastModificationTime;
|
this.lastModificationTime = lastModificationTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder state(ProvisioningState state) {
|
public Builder state(ProvisioningState state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder description(String description) {
|
public Builder description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder bootable(Boolean bootable) {
|
public Builder isBootable(boolean bootable) {
|
||||||
this.bootable = bootable;
|
this.bootable = bootable;
|
||||||
return this;
|
return this;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder osType(OsType osType) {
|
|
||||||
this.osType = osType;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder cpuHotPlug(boolean cpuHotPlug) {
|
|
||||||
this.cpuHotPlug = cpuHotPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder cpuHotUnPlug(boolean cpuHotUnPlug) {
|
|
||||||
this.cpuHotUnPlug = cpuHotUnPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder discVirtioHotPlug(boolean discVirtioHotPlug) {
|
|
||||||
this.discVirtioHotPlug = discVirtioHotPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder discVirtioHotUnPlug(boolean discVirtioHotUnPlug) {
|
|
||||||
this.discVirtioHotUnPlug = discVirtioHotUnPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder ramHotPlug(boolean ramHotPlug) {
|
|
||||||
this.ramHotPlug = ramHotPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder ramHotUnPlug(boolean ramHotUnPlug) {
|
|
||||||
this.ramHotUnPlug = ramHotUnPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder nicHotPlug(boolean nicHotPlug) {
|
|
||||||
this.nicHotPlug = nicHotPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder nicHotUnPlug(boolean nicHotUnPlug) {
|
|
||||||
this.nicHotUnPlug = nicHotUnPlug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder location(Location location) {
|
|
||||||
this.location = location;
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder fromSnapshot(Snapshot in) {
|
private Builder fromSnapshot(Snapshot in) {
|
||||||
return this.id(in.id()).name(in.name()).size(in.size()).creationTime(in.creationTime())
|
return this.id(in.id()).name(in.name()).size(in.size()).creationTime(in.creationTime())
|
||||||
.lastModificationTime(in.lastModificationTime()).state(in.state()).bootable(in.bootable()).description(in.description())
|
.lastModificationTime(in.lastModificationTime()).state(in.state()).isBootable(in.bootable())
|
||||||
.cpuHotPlug(in.cpuHotPlug()).cpuHotUnPlug(in.cpuHotUnPlug()).discVirtioHotPlug(in.discVirtioHotPlug())
|
.description(in.description()).isCpuHotPlug(in.isCpuHotPlug()).isCpuHotUnPlug(in.isCpuHotUnPlug())
|
||||||
.discVirtioHotUnPlug(in.discVirtioHotUnPlug()).ramHotPlug(in.ramHotPlug()).ramHotUnPlug(in.ramHotUnPlug())
|
.isDiscVirtioHotPlug(in.isDiscVirtioHotPlug()).isDiscVirtioHotUnPlug(in.isDiscVirtioHotUnPlug())
|
||||||
.nicHotPlug(in.nicHotPlug()).nicHotUnPlug(in.nicHotUnPlug());
|
.isRamHotPlug(in.isRamHotPlug()).isRamHotUnPlug(in.isRamHotUnPlug())
|
||||||
|
.isNicHotPlug(in.isNicHotPlug()).isNicHotUnPlug(in.isNicHotUnPlug());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Snapshot build() {
|
public Snapshot build() {
|
||||||
return Snapshot.create(id, name, size, bootable, description, osType, cpuHotPlug, cpuHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug, ramHotPlug, ramHotUnPlug, nicHotPlug, nicHotUnPlug, creationTime, lastModificationTime, state, location);
|
return Snapshot.create(id, name, size, bootable, description, osType, cpuHotPlug, cpuHotUnPlug,
|
||||||
|
discVirtioHotPlug, discVirtioHotUnPlug, ramHotPlug, ramHotUnPlug, nicHotPlug, nicHotUnPlug,
|
||||||
|
creationTime, lastModificationTime, state, location);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder self() {
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Request {
|
public static final class Request {
|
||||||
|
|
||||||
public static CreatePayload.Builder creatingBuilder() {
|
public static CreatePayload.Builder creatingBuilder() {
|
||||||
return new CreatePayload.Builder();
|
return new CreatePayload.Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UpdatePayload.Builder updatingBuilder() {
|
public static UpdatePayload.Builder updatingBuilder() {
|
||||||
return new UpdatePayload.Builder();
|
return new UpdatePayload.Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RollbackPayload.Builder rollbackBuilder() {
|
public static RollbackPayload.Builder rollbackBuilder() {
|
||||||
return new RollbackPayload.Builder();
|
return new RollbackPayload.Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public abstract static class CreatePayload {
|
public abstract static class CreatePayload {
|
||||||
|
|
||||||
public abstract String storageId();
|
public abstract String storageId();
|
||||||
|
|
||||||
public abstract String description();
|
public abstract String description();
|
||||||
|
|
||||||
public abstract String name();
|
public abstract String name();
|
||||||
|
|
||||||
public static CreatePayload create(String storageId, String description, String name) {
|
public static CreatePayload create(String storageId, String description, String name) {
|
||||||
return new AutoValue_Snapshot_Request_CreatePayload(storageId, description, name);
|
return new AutoValue_Snapshot_Request_CreatePayload(storageId, description, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private String storageId;
|
private String storageId;
|
||||||
private String description;
|
private String description;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public Builder storageId(String storageId) {
|
public Builder storageId(String storageId) {
|
||||||
this.storageId = storageId;
|
this.storageId = storageId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder description(String description) {
|
public Builder description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder name(String name) {
|
public Builder name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreatePayload build() {
|
public CreatePayload build() {
|
||||||
return CreatePayload.create(storageId, description, name);
|
return CreatePayload.create(storageId, description, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public abstract static class UpdatePayload {
|
public abstract static class UpdatePayload implements HotPluggable {
|
||||||
|
|
||||||
public abstract String snapshotId();
|
public abstract String snapshotId();
|
||||||
|
|
||||||
public abstract String description();
|
public abstract String description();
|
||||||
|
|
||||||
public abstract String name();
|
public abstract String name();
|
||||||
|
|
||||||
public abstract boolean bootable();
|
public abstract boolean bootable();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract OsType osType();
|
public abstract OsType osType();
|
||||||
|
|
||||||
public abstract boolean cpuHotplug();
|
public static UpdatePayload create(String snapshotId, String description, String name, boolean bootable,
|
||||||
|
OsType osType, Boolean cpuHotplug, Boolean cpuHotunplug, Boolean ramHotplug, Boolean ramHotunplug,
|
||||||
|
Boolean nicHotplug, Boolean nicHotunplug, Boolean discVirtioHotplug, Boolean discVirtioHotunplug) {
|
||||||
|
return new AutoValue_Snapshot_Request_UpdatePayload(
|
||||||
|
cpuHotplug, cpuHotunplug, ramHotplug, ramHotunplug, nicHotplug, nicHotunplug, discVirtioHotplug,
|
||||||
|
discVirtioHotunplug, snapshotId, description, name, bootable, osType);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean cpuHotunplug();
|
public static class Builder extends HotPluggable.Builder<Builder, UpdatePayload> {
|
||||||
|
|
||||||
public abstract boolean ramHotplug();
|
private String snapshotId;
|
||||||
|
|
||||||
public abstract boolean ramHotunplug();
|
@Nullable
|
||||||
|
private String description;
|
||||||
|
|
||||||
public abstract boolean nicHotplug();
|
@Nullable
|
||||||
|
private String name;
|
||||||
|
|
||||||
public abstract boolean nicHotunplug();
|
private boolean bootable;
|
||||||
|
|
||||||
public abstract boolean discVirtioHotplug();
|
private OsType osType;
|
||||||
|
|
||||||
public abstract boolean discVirtioHotunplug();
|
public Builder snapshotId(String snapshotId) {
|
||||||
|
this.snapshotId = snapshotId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public static UpdatePayload create(String snapshotId, String description, String name, boolean bootable, OsType osType, boolean cpuHotplug, boolean cpuHotunplug, boolean ramHotplug, boolean ramHotunplug, boolean nicHotplug, boolean nicHotunplug, boolean discVirtioHotplug, boolean discVirtioHotunplug) {
|
public Builder description(String description) {
|
||||||
return new AutoValue_Snapshot_Request_UpdatePayload(snapshotId, description, name, bootable, osType, cpuHotplug, cpuHotunplug, ramHotplug, ramHotunplug, nicHotplug, nicHotunplug, discVirtioHotplug, discVirtioHotunplug);
|
this.description = description;
|
||||||
}
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
private String snapshotId;
|
public Builder bootable(boolean bootable) {
|
||||||
|
this.bootable = bootable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
public Builder osType(OsType osType) {
|
||||||
private String description;
|
this.osType = osType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Override
|
||||||
private String name;
|
public UpdatePayload build() {
|
||||||
|
return UpdatePayload.create(snapshotId, description, name, bootable, osType, cpuHotPlug, cpuHotUnPlug,
|
||||||
|
ramHotPlug, ramHotUnPlug, nicHotUnPlug, nicHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean bootable;
|
@Override
|
||||||
|
public Builder self() {
|
||||||
private OsType osType;
|
return this;
|
||||||
|
}
|
||||||
private boolean cpuHotplug;
|
}
|
||||||
|
|
||||||
private boolean cpuHotunplug;
|
|
||||||
|
|
||||||
private boolean ramHotplug;
|
|
||||||
|
|
||||||
private boolean ramHotunplug;
|
|
||||||
|
|
||||||
private boolean nicHotplug;
|
|
||||||
|
|
||||||
private boolean nicHotunplug;
|
|
||||||
|
|
||||||
private boolean discVirtioHotplug;
|
|
||||||
|
|
||||||
private boolean discVirtioHotunplug;
|
|
||||||
|
|
||||||
public Builder snapshotId(String snapshotId) {
|
|
||||||
this.snapshotId = snapshotId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder description(String description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder bootable(boolean bootable) {
|
|
||||||
this.bootable = bootable;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder osType(OsType osType) {
|
|
||||||
this.osType = osType;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder cpuHotplug(boolean cpuHotplug) {
|
|
||||||
this.cpuHotplug = cpuHotplug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder cpuHotunplug(boolean cpuHotunplug) {
|
|
||||||
this.cpuHotunplug = cpuHotunplug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder ramHotplug(boolean ramHotplug) {
|
|
||||||
this.ramHotplug = ramHotplug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder ramHotunplug(boolean ramHotunplug) {
|
|
||||||
this.ramHotunplug = ramHotunplug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder nicHotplug(boolean nicHotplug) {
|
|
||||||
this.nicHotplug = nicHotplug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder nicHotunplug(boolean nicHotunplug) {
|
|
||||||
this.nicHotunplug = nicHotunplug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder discVirtioHotplug(boolean discVirtioHotplug) {
|
|
||||||
this.discVirtioHotplug = discVirtioHotplug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder discVirtioHotunplug(boolean discVirtioHotunplug) {
|
|
||||||
this.discVirtioHotunplug = discVirtioHotunplug;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UpdatePayload build() {
|
|
||||||
return UpdatePayload.create(snapshotId, description, name, bootable, osType, cpuHotplug, cpuHotunplug, ramHotplug, ramHotunplug, nicHotplug, nicHotunplug, discVirtioHotplug, discVirtioHotunplug);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public abstract static class RollbackPayload {
|
public abstract static class RollbackPayload {
|
||||||
|
|
||||||
public abstract String snapshotId();
|
public abstract String snapshotId();
|
||||||
|
|
||||||
public abstract String storageId();
|
public abstract String storageId();
|
||||||
|
|
||||||
public static RollbackPayload create(String snapshotId, String storageId) {
|
public static RollbackPayload create(String snapshotId, String storageId) {
|
||||||
return new AutoValue_Snapshot_Request_RollbackPayload(snapshotId, storageId);
|
return new AutoValue_Snapshot_Request_RollbackPayload(snapshotId, storageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private String snapshotId;
|
private String snapshotId;
|
||||||
|
|
||||||
private String storageId;
|
private String storageId;
|
||||||
|
|
||||||
public Builder snapshotId(String snapshotId) {
|
public Builder snapshotId(String snapshotId) {
|
||||||
this.snapshotId = snapshotId;
|
this.snapshotId = snapshotId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder storageId(String storageId) {
|
public Builder storageId(String storageId) {
|
||||||
this.storageId = storageId;
|
this.storageId = storageId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RollbackPayload build() {
|
public RollbackPayload build() {
|
||||||
return RollbackPayload.create(snapshotId, storageId);
|
return RollbackPayload.create(snapshotId, storageId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import static org.jclouds.profitbricks.util.Passwords.isValidPassword;
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public abstract class Storage {
|
public abstract class Storage {
|
||||||
|
@ -194,7 +195,8 @@ public abstract class Storage {
|
||||||
public abstract String profitBricksImagePassword();
|
public abstract String profitBricksImagePassword();
|
||||||
|
|
||||||
public static CreatePayload create(String dataCenterId, float size, String name, String mountImageId, String imagePassword) {
|
public static CreatePayload create(String dataCenterId, float size, String name, String mountImageId, String imagePassword) {
|
||||||
validateSize(size);
|
checkSize(size);
|
||||||
|
checkPassword(imagePassword);
|
||||||
return new AutoValue_Storage_Request_CreatePayload(dataCenterId, size, name, mountImageId, imagePassword);
|
return new AutoValue_Storage_Request_CreatePayload(dataCenterId, size, name, mountImageId, imagePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +260,7 @@ public abstract class Storage {
|
||||||
public abstract String mountImageId();
|
public abstract String mountImageId();
|
||||||
|
|
||||||
public static UpdatePayload create(String id, Float size, String name, String mountImageId) {
|
public static UpdatePayload create(String id, Float size, String name, String mountImageId) {
|
||||||
validateSize(size);
|
checkSize(size);
|
||||||
return new AutoValue_Storage_Request_UpdatePayload(id, size, name, mountImageId);
|
return new AutoValue_Storage_Request_UpdatePayload(id, size, name, mountImageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,10 +348,15 @@ public abstract class Storage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void validateSize(Float size) {
|
private static void checkSize(Float size) {
|
||||||
if (size != null)
|
if (size != null)
|
||||||
checkArgument(size > 1, "Storage size must be > 1GB");
|
checkArgument(size > 1, "Storage size must be > 1GB");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkPassword(String password) {
|
||||||
|
if (password != null)
|
||||||
|
checkArgument(isValidPassword(password), "Password must be between 8 and 50 characters, "
|
||||||
|
+ "only a-z, A-Z, 0-9 without characters i, I, l, o, O, w, W, y, Y, z, Z and 1, 0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.domain.internal;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public interface HotPluggable {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Boolean isCpuHotPlug();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Boolean isCpuHotUnPlug();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Boolean isRamHotPlug();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Boolean isRamHotUnPlug();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Boolean isNicHotPlug();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Boolean isNicHotUnPlug();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Boolean isDiscVirtioHotPlug();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Boolean isDiscVirtioHotUnPlug();
|
||||||
|
|
||||||
|
public abstract static class Builder<B extends Builder, D extends HotPluggable> {
|
||||||
|
|
||||||
|
protected Boolean cpuHotPlug;
|
||||||
|
protected Boolean cpuHotUnPlug;
|
||||||
|
protected Boolean ramHotPlug;
|
||||||
|
protected Boolean ramHotUnPlug;
|
||||||
|
protected Boolean nicHotPlug;
|
||||||
|
protected Boolean nicHotUnPlug;
|
||||||
|
protected Boolean discVirtioHotPlug;
|
||||||
|
protected Boolean discVirtioHotUnPlug;
|
||||||
|
|
||||||
|
public B isCpuHotPlug(Boolean cpuHotPlug) {
|
||||||
|
this.cpuHotPlug = cpuHotPlug;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B isCpuHotUnPlug(Boolean cpuHotUnplug) {
|
||||||
|
this.cpuHotUnPlug = cpuHotUnplug;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B isRamHotPlug(Boolean ramHotPlug) {
|
||||||
|
this.ramHotPlug = ramHotPlug;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B isRamHotUnPlug(Boolean ramHotUnplug) {
|
||||||
|
this.ramHotUnPlug = ramHotUnplug;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B isNicHotPlug(Boolean nicHotPlug) {
|
||||||
|
this.nicHotPlug = nicHotPlug;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B isNicHotUnPlug(Boolean nicHotUnPlug) {
|
||||||
|
this.nicHotUnPlug = nicHotUnPlug;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B isDiscVirtioHotPlug(Boolean discVirtioHotPlug) {
|
||||||
|
this.discVirtioHotPlug = discVirtioHotPlug;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B isDiscVirtioHotUnPlug(Boolean discVirtioHotUnPlug) {
|
||||||
|
this.discVirtioHotUnPlug = discVirtioHotUnPlug;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract B self();
|
||||||
|
|
||||||
|
public abstract D build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.domain.internal;
|
||||||
|
|
||||||
|
import org.jclouds.profitbricks.domain.Location;
|
||||||
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
|
|
||||||
|
public interface Provisionable extends HotPluggable {
|
||||||
|
|
||||||
|
String id();
|
||||||
|
|
||||||
|
String name();
|
||||||
|
|
||||||
|
float size(); // MB
|
||||||
|
|
||||||
|
Location location();
|
||||||
|
|
||||||
|
OsType osType();
|
||||||
|
|
||||||
|
public abstract static class Builder<B extends Builder, D extends Provisionable> extends HotPluggable.Builder<B, D> {
|
||||||
|
|
||||||
|
protected String id;
|
||||||
|
protected String name;
|
||||||
|
protected float size;
|
||||||
|
protected Location location;
|
||||||
|
protected OsType osType;
|
||||||
|
|
||||||
|
public B id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B size(float size) {
|
||||||
|
this.size = size;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B location(Location location) {
|
||||||
|
this.location = location;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public B osType(OsType osType) {
|
||||||
|
this.osType = osType;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,30 +16,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.domain.internal;
|
package org.jclouds.profitbricks.domain.internal;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface used as common data type for {@link org.jclouds.profitbricks.domain.Server.Builder}
|
* An interface used as common data type for {@link org.jclouds.profitbricks.domain.Server.Builder}
|
||||||
*/
|
*/
|
||||||
public interface ServerCommonProperties {
|
public interface ServerCommonProperties extends HotPluggable {
|
||||||
|
|
||||||
@Nullable
|
|
||||||
Boolean isCpuHotPlug();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
Boolean isRamHotPlug();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
Boolean isNicHotPlug();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
Boolean isNicHotUnPlug();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
Boolean isDiscVirtioHotPlug();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
Boolean isDiscVirtioHotUnPlug();
|
|
||||||
|
|
||||||
String name();
|
String name();
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ public interface LoadBalancerApi {
|
||||||
@POST
|
@POST
|
||||||
@Named("loadbalancer:delete")
|
@Named("loadbalancer:delete")
|
||||||
@Payload("<ws:deleteLoadBalancer><loadBalancerId>{id}</loadBalancerId></ws:deleteLoadBalancer>")
|
@Payload("<ws:deleteLoadBalancer><loadBalancerId>{id}</loadBalancerId></ws:deleteLoadBalancer>")
|
||||||
boolean deleteLoadbalancer(@PayloadParam("id") String id);
|
boolean deleteLoadBalancer(@PayloadParam("id") String id);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Named("loadbalancer:update")
|
@Named("loadbalancer:update")
|
||||||
|
|
|
@ -16,15 +16,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.http.parser.firewall;
|
package org.jclouds.profitbricks.http.parser.firewall;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.profitbricks.domain.Firewall;
|
import org.jclouds.profitbricks.domain.Firewall;
|
||||||
import org.jclouds.profitbricks.http.parser.firewall.rule.FirewallRuleListResponseHandler;
|
import org.jclouds.profitbricks.http.parser.firewall.rule.FirewallRuleListResponseHandler;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public class FirewallListResponseHandler extends BaseFirewallResponseHandler<List<Firewall>> {
|
public class FirewallListResponseHandler extends BaseFirewallResponseHandler<List<Firewall>> {
|
||||||
|
|
||||||
private List<Firewall> firewalls;
|
private List<Firewall> firewalls;
|
||||||
|
|
|
@ -16,15 +16,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.http.parser.ipblock;
|
package org.jclouds.profitbricks.http.parser.ipblock;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.profitbricks.domain.IpBlock;
|
import org.jclouds.profitbricks.domain.IpBlock;
|
||||||
import org.jclouds.profitbricks.http.parser.publicip.PublicIpListResponseHandler;
|
import org.jclouds.profitbricks.http.parser.publicip.PublicIpListResponseHandler;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public class IpBlockListResponseHandler extends BaseIpBlockResponseHandler<List<IpBlock>> {
|
public class IpBlockListResponseHandler extends BaseIpBlockResponseHandler<List<IpBlock>> {
|
||||||
|
|
||||||
private final List<IpBlock> ipBlocks;
|
private final List<IpBlock> ipBlocks;
|
||||||
|
|
|
@ -16,9 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.http.parser.loadbalancer;
|
package org.jclouds.profitbricks.http.parser.loadbalancer;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import org.jclouds.date.DateCodec;
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
import org.jclouds.profitbricks.domain.LoadBalancer;
|
import org.jclouds.profitbricks.domain.LoadBalancer;
|
||||||
import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm;
|
import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm;
|
||||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
|
@ -34,23 +37,23 @@ public abstract class BaseLoadBalancerResponseHandler<T> extends BaseProfitBrick
|
||||||
protected final FirewallListResponseHandler firewallListResponseHandler;
|
protected final FirewallListResponseHandler firewallListResponseHandler;
|
||||||
|
|
||||||
protected LoadBalancer.Builder builder;
|
protected LoadBalancer.Builder builder;
|
||||||
protected final DateCodec dateCodec;
|
protected DataCenter.Builder dataCenterBuilder;
|
||||||
|
|
||||||
|
protected final DateService dateService;
|
||||||
|
|
||||||
protected boolean useBalancedServerParser = false;
|
protected boolean useBalancedServerParser = false;
|
||||||
protected boolean useFirewallParser = false;
|
protected boolean useFirewallParser = false;
|
||||||
|
|
||||||
protected BaseLoadBalancerResponseHandler(DateCodecFactory dateCodec,
|
protected BaseLoadBalancerResponseHandler(DateService dateService,
|
||||||
ServerListResponseHandler balancedServerResponseHandler, FirewallListResponseHandler firewallResponseHandler) {
|
ServerListResponseHandler balancedServerResponseHandler, FirewallListResponseHandler firewallResponseHandler) {
|
||||||
|
|
||||||
if (dateCodec == null)
|
checkNotNull(dateService, "DateService cannot be null");
|
||||||
throw new NullPointerException("DateCodecFactory cannot be null");
|
checkNotNull(balancedServerResponseHandler, "BalancedServerResponseHandler cannot be null");
|
||||||
if (balancedServerResponseHandler == null)
|
checkNotNull(firewallResponseHandler, "FirewallListResponseHandler cannot be null");
|
||||||
throw new NullPointerException("BalancedServerResponseHandler cannot be null");
|
|
||||||
if (firewallResponseHandler == null)
|
|
||||||
throw new NullPointerException("FirewallListResponseHandler cannot be null");
|
|
||||||
|
|
||||||
this.dateCodec = dateCodec.iso8601();
|
this.dateService = dateService;
|
||||||
this.builder = LoadBalancer.builder();
|
this.builder = LoadBalancer.builder();
|
||||||
|
this.dataCenterBuilder = DataCenter.builder();
|
||||||
|
|
||||||
this.balancedServerResponseHandler = balancedServerResponseHandler;
|
this.balancedServerResponseHandler = balancedServerResponseHandler;
|
||||||
this.firewallListResponseHandler = firewallResponseHandler;
|
this.firewallListResponseHandler = firewallResponseHandler;
|
||||||
|
@ -80,7 +83,7 @@ public abstract class BaseLoadBalancerResponseHandler<T> extends BaseProfitBrick
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Date textToIso8601Date() {
|
protected final Date textToIso8601Date() {
|
||||||
return dateCodec.toDate(textToStringValue());
|
return dateService.iso8601DateOrSecondsDateParse(textToStringValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,11 +93,11 @@ public abstract class BaseLoadBalancerResponseHandler<T> extends BaseProfitBrick
|
||||||
else if ("loadBalancerName".equals(qName))
|
else if ("loadBalancerName".equals(qName))
|
||||||
builder.name(textToStringValue());
|
builder.name(textToStringValue());
|
||||||
else if ("loadBalancerAlgorithm".equals(qName))
|
else if ("loadBalancerAlgorithm".equals(qName))
|
||||||
builder.loadBalancerAlgorithm(Algorithm.fromValue(textToStringValue()));
|
builder.algorithm(Algorithm.fromValue(textToStringValue()));
|
||||||
else if ("dataCenterId".equals(qName))
|
else if ("dataCenterId".equals(qName))
|
||||||
builder.dataCenterId(textToStringValue());
|
dataCenterBuilder.id(textToStringValue());
|
||||||
else if ("dataCenterVersion".equals(qName))
|
else if ("dataCenterVersion".equals(qName))
|
||||||
builder.dataCenterVersion(textToStringValue());
|
dataCenterBuilder.version(textToIntValue());
|
||||||
else if ("internetAccess".equals(qName))
|
else if ("internetAccess".equals(qName))
|
||||||
builder.internetAccess(textToBooleanValue());
|
builder.internetAccess(textToBooleanValue());
|
||||||
else if ("ip".equals(qName))
|
else if ("ip".equals(qName))
|
||||||
|
|
|
@ -21,7 +21,8 @@ import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
import org.jclouds.profitbricks.domain.LoadBalancer;
|
import org.jclouds.profitbricks.domain.LoadBalancer;
|
||||||
import org.jclouds.profitbricks.http.parser.firewall.FirewallListResponseHandler;
|
import org.jclouds.profitbricks.http.parser.firewall.FirewallListResponseHandler;
|
||||||
import org.jclouds.profitbricks.http.parser.server.ServerListResponseHandler;
|
import org.jclouds.profitbricks.http.parser.server.ServerListResponseHandler;
|
||||||
|
@ -32,39 +33,45 @@ public class LoadBalancerListResponseHandler extends BaseLoadBalancerResponseHan
|
||||||
private final List<LoadBalancer> loadBalancers;
|
private final List<LoadBalancer> loadBalancers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
LoadBalancerListResponseHandler(DateCodecFactory dateCodec, ServerListResponseHandler balancedServerResponseHandler, FirewallListResponseHandler firewallListResponseHandler) {
|
LoadBalancerListResponseHandler(DateService dateService, ServerListResponseHandler balancedServerResponseHandler, FirewallListResponseHandler firewallListResponseHandler) {
|
||||||
super(dateCodec, balancedServerResponseHandler, firewallListResponseHandler);
|
super(dateService, balancedServerResponseHandler, firewallListResponseHandler);
|
||||||
this.loadBalancers = Lists.newArrayList();
|
this.loadBalancers = Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||||
if (useBalancedServerParser) {
|
if (useBalancedServerParser)
|
||||||
balancedServerResponseHandler.endElement(uri, localName, qName);
|
balancedServerResponseHandler.endElement(uri, localName, qName);
|
||||||
} else if (useFirewallParser) {
|
else if (useFirewallParser)
|
||||||
firewallListResponseHandler.endElement(uri, localName, qName);
|
firewallListResponseHandler.endElement(uri, localName, qName);
|
||||||
} else {
|
else {
|
||||||
setPropertyOnEndTag(qName);
|
setPropertyOnEndTag(qName);
|
||||||
if ("return".equals(qName)) {
|
if ("return".equals(qName)) {
|
||||||
loadBalancers.add(builder
|
loadBalancers.add(builder
|
||||||
|
.dataCenter(dataCenterBuilder.build())
|
||||||
.firewalls(firewallListResponseHandler.getResult())
|
.firewalls(firewallListResponseHandler.getResult())
|
||||||
.balancedServers(balancedServerResponseHandler.getResult())
|
.balancedServers(balancedServerResponseHandler.getResult())
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
balancedServerResponseHandler.reset();
|
balancedServerResponseHandler.reset();
|
||||||
firewallListResponseHandler.reset();
|
firewallListResponseHandler.reset();
|
||||||
|
|
||||||
builder = LoadBalancer.builder();
|
builder = LoadBalancer.builder();
|
||||||
}
|
}
|
||||||
clearTextBuffer();
|
clearTextBuffer();
|
||||||
}
|
}
|
||||||
if ("firewall".equals(qName)) {
|
if ("firewall".equals(qName))
|
||||||
useFirewallParser = false;
|
useFirewallParser = false;
|
||||||
} else if ("balancedServers".equals(qName)) {
|
else if ("balancedServers".equals(qName))
|
||||||
useBalancedServerParser = false;
|
useBalancedServerParser = false;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
this.dataCenterBuilder = DataCenter.builder();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LoadBalancer> getResult() {
|
public List<LoadBalancer> getResult() {
|
||||||
return loadBalancers;
|
return loadBalancers;
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
package org.jclouds.profitbricks.http.parser.loadbalancer;
|
package org.jclouds.profitbricks.http.parser.loadbalancer;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.profitbricks.domain.LoadBalancer;
|
import org.jclouds.profitbricks.domain.LoadBalancer;
|
||||||
import org.jclouds.profitbricks.http.parser.firewall.FirewallListResponseHandler;
|
import org.jclouds.profitbricks.http.parser.firewall.FirewallListResponseHandler;
|
||||||
import org.jclouds.profitbricks.http.parser.server.ServerListResponseHandler;
|
import org.jclouds.profitbricks.http.parser.server.ServerListResponseHandler;
|
||||||
|
@ -28,8 +29,9 @@ public class LoadBalancerResponseHandler extends BaseLoadBalancerResponseHandler
|
||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
LoadBalancerResponseHandler(DateCodecFactory dateCodec, ServerListResponseHandler serverListResponseHandler, FirewallListResponseHandler firewallListResponseHandler) {
|
LoadBalancerResponseHandler(DateService dateService, ServerListResponseHandler serverListResponseHandler,
|
||||||
super(dateCodec, serverListResponseHandler, firewallListResponseHandler);
|
FirewallListResponseHandler firewallListResponseHandler) {
|
||||||
|
super(dateService, serverListResponseHandler, firewallListResponseHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,8 +47,9 @@ public class LoadBalancerResponseHandler extends BaseLoadBalancerResponseHandler
|
||||||
setPropertyOnEndTag(qName);
|
setPropertyOnEndTag(qName);
|
||||||
if ("return".equals(qName)) {
|
if ("return".equals(qName)) {
|
||||||
done = true;
|
done = true;
|
||||||
builder.balancedServers(balancedServerResponseHandler.getResult());
|
builder.dataCenter(dataCenterBuilder.build())
|
||||||
builder.firewalls(firewallListResponseHandler.getResult());
|
.balancedServers(balancedServerResponseHandler.getResult())
|
||||||
|
.firewalls(firewallListResponseHandler.getResult());
|
||||||
}
|
}
|
||||||
clearTextBuffer();
|
clearTextBuffer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.http.parser.server;
|
package org.jclouds.profitbricks.http.parser.server;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import org.jclouds.date.DateCodec;
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.profitbricks.domain.AvailabilityZone;
|
import org.jclouds.profitbricks.domain.AvailabilityZone;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
import org.jclouds.profitbricks.domain.OsType;
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
import org.jclouds.profitbricks.domain.Server;
|
import org.jclouds.profitbricks.domain.Server;
|
||||||
|
@ -31,29 +34,28 @@ import org.xml.sax.SAXException;
|
||||||
|
|
||||||
public abstract class BaseServerResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
|
public abstract class BaseServerResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
|
||||||
|
|
||||||
protected StorageListResponseHandler storageListResponseHandler;
|
protected final StorageListResponseHandler storageListResponseHandler;
|
||||||
protected NicListResponseHandler nicListResponseHandler;
|
protected final NicListResponseHandler nicListResponseHandler;
|
||||||
|
|
||||||
|
protected DataCenter.Builder dataCenterBuilder;
|
||||||
protected Server.DescribingBuilder builder;
|
protected Server.DescribingBuilder builder;
|
||||||
|
|
||||||
protected final DateCodec dateCodec;
|
protected final DateService dateService;
|
||||||
|
|
||||||
protected boolean useStorageParser = false;
|
protected boolean useStorageParser = false;
|
||||||
protected boolean useNicParser = false;
|
protected boolean useNicParser = false;
|
||||||
|
|
||||||
BaseServerResponseHandler(DateCodecFactory dateCodec, StorageListResponseHandler storageListResponseHandler,
|
BaseServerResponseHandler(DateService dateService, StorageListResponseHandler storageListResponseHandler,
|
||||||
NicListResponseHandler nicListResponseHandler) {
|
NicListResponseHandler nicListResponseHandler) {
|
||||||
if (dateCodec == null)
|
checkNotNull(dateService, "DateService cannot be null");
|
||||||
throw new NullPointerException("DateCodecFactory cannot be null");
|
checkNotNull(storageListResponseHandler, "StorageListResponseHandler cannot be null");
|
||||||
if (storageListResponseHandler == null)
|
checkNotNull(nicListResponseHandler, "NicListResponseHandler cannot be null");
|
||||||
throw new NullPointerException("StorageListResponseHandler cannot be null");
|
|
||||||
if (nicListResponseHandler == null)
|
|
||||||
throw new NullPointerException("NicListResponseHandler cannot be null");
|
|
||||||
|
|
||||||
this.dateCodec = dateCodec.iso8601();
|
this.dateService = dateService;
|
||||||
this.storageListResponseHandler = storageListResponseHandler;
|
this.storageListResponseHandler = storageListResponseHandler;
|
||||||
this.nicListResponseHandler = nicListResponseHandler;
|
this.nicListResponseHandler = nicListResponseHandler;
|
||||||
this.builder = Server.builder();
|
this.builder = Server.builder();
|
||||||
|
this.dataCenterBuilder = DataCenter.builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,12 +84,16 @@ public abstract class BaseServerResponseHandler<T> extends BaseProfitBricksRespo
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Date textToIso8601Date() {
|
protected final Date textToIso8601Date() {
|
||||||
return dateCodec.toDate(textToStringValue());
|
return dateService.iso8601DateOrSecondsDateParse(textToStringValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setPropertyOnEndTag(String qName) {
|
protected void setPropertyOnEndTag(String qName) {
|
||||||
if ("serverId".equals(qName))
|
if ("dataCenterId".equals(qName))
|
||||||
|
dataCenterBuilder.id(textToStringValue());
|
||||||
|
else if ("dataCenterVersion".equals(qName))
|
||||||
|
dataCenterBuilder.version(textToIntValue());
|
||||||
|
else if ("serverId".equals(qName))
|
||||||
builder.id(textToStringValue());
|
builder.id(textToStringValue());
|
||||||
else if ("serverName".equals(qName))
|
else if ("serverName".equals(qName))
|
||||||
builder.name(textToStringValue());
|
builder.name(textToStringValue());
|
||||||
|
@ -122,7 +128,7 @@ public abstract class BaseServerResponseHandler<T> extends BaseProfitBricksRespo
|
||||||
else if ("discVirtioHotUnPlug".equals(qName))
|
else if ("discVirtioHotUnPlug".equals(qName))
|
||||||
builder.isDiscVirtioHotUnPlug(textToBooleanValue());
|
builder.isDiscVirtioHotUnPlug(textToBooleanValue());
|
||||||
else if ("activate".equals(qName))
|
else if ("activate".equals(qName))
|
||||||
builder.activate(textToBooleanValue());
|
builder.loadBalanced(textToBooleanValue());
|
||||||
else if ("balancedNicId".equals(qName))
|
else if ("balancedNicId".equals(qName))
|
||||||
builder.balancedNicId(textToStringValue());
|
builder.balancedNicId(textToStringValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.jclouds.profitbricks.http.parser.server;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.profitbricks.domain.Server;
|
import org.jclouds.profitbricks.domain.Server;
|
||||||
import org.jclouds.profitbricks.http.parser.nic.NicListResponseHandler;
|
import org.jclouds.profitbricks.http.parser.nic.NicListResponseHandler;
|
||||||
import org.jclouds.profitbricks.http.parser.storage.StorageListResponseHandler;
|
import org.jclouds.profitbricks.http.parser.storage.StorageListResponseHandler;
|
||||||
|
@ -29,9 +29,9 @@ public class ServerInfoResponseHandler extends BaseServerResponseHandler<Server>
|
||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ServerInfoResponseHandler(DateCodecFactory dateCodec, StorageListResponseHandler storageListResponseHandler,
|
ServerInfoResponseHandler(DateService dateService, StorageListResponseHandler storageListResponseHandler,
|
||||||
NicListResponseHandler nicListResponseHandler) {
|
NicListResponseHandler nicListResponseHandler) {
|
||||||
super(dateCodec, storageListResponseHandler, nicListResponseHandler);
|
super(dateService, storageListResponseHandler, nicListResponseHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,6 +48,7 @@ public class ServerInfoResponseHandler extends BaseServerResponseHandler<Server>
|
||||||
if ("return".equals(qName)) {
|
if ("return".equals(qName)) {
|
||||||
done = true;
|
done = true;
|
||||||
builder
|
builder
|
||||||
|
.dataCenter(dataCenterBuilder.build())
|
||||||
.storages(storageListResponseHandler.getResult())
|
.storages(storageListResponseHandler.getResult())
|
||||||
.nics(nicListResponseHandler.getResult());
|
.nics(nicListResponseHandler.getResult());
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@ import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
import org.jclouds.profitbricks.domain.Server;
|
import org.jclouds.profitbricks.domain.Server;
|
||||||
import org.jclouds.profitbricks.http.parser.nic.NicListResponseHandler;
|
import org.jclouds.profitbricks.http.parser.nic.NicListResponseHandler;
|
||||||
import org.jclouds.profitbricks.http.parser.storage.StorageListResponseHandler;
|
import org.jclouds.profitbricks.http.parser.storage.StorageListResponseHandler;
|
||||||
|
@ -32,9 +33,9 @@ public class ServerListResponseHandler extends BaseServerResponseHandler<List<Se
|
||||||
private List<Server> servers;
|
private List<Server> servers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ServerListResponseHandler(DateCodecFactory dateCodec, StorageListResponseHandler storageListResponseHandler,
|
ServerListResponseHandler(DateService dateService, StorageListResponseHandler storageListResponseHandler,
|
||||||
NicListResponseHandler nicListResponseHandler) {
|
NicListResponseHandler nicListResponseHandler) {
|
||||||
super(dateCodec, storageListResponseHandler, nicListResponseHandler);
|
super(dateService, storageListResponseHandler, nicListResponseHandler);
|
||||||
this.servers = Lists.newArrayList();
|
this.servers = Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,10 +49,18 @@ public class ServerListResponseHandler extends BaseServerResponseHandler<List<Se
|
||||||
else {
|
else {
|
||||||
setPropertyOnEndTag(qName);
|
setPropertyOnEndTag(qName);
|
||||||
if ("return".equals(qName) || "servers".equals(qName) || "balancedServers".equals(qName)) {
|
if ("return".equals(qName) || "servers".equals(qName) || "balancedServers".equals(qName)) {
|
||||||
servers.add(builder
|
Server.DescribingBuilder sdb = null;
|
||||||
.storages(storageListResponseHandler.getResult())
|
try {
|
||||||
.nics(nicListResponseHandler.getResult())
|
sdb = builder
|
||||||
.build());
|
.storages(storageListResponseHandler.getResult())
|
||||||
|
.nics(nicListResponseHandler.getResult());
|
||||||
|
servers.add(sdb
|
||||||
|
// For LoadBalancer's case, there's no DataCenter (may throw NPE on #build()).
|
||||||
|
.dataCenter(dataCenterBuilder.build())
|
||||||
|
.build());
|
||||||
|
} catch (NullPointerException ex) {
|
||||||
|
servers.add(sdb.build());
|
||||||
|
}
|
||||||
storageListResponseHandler.reset();
|
storageListResponseHandler.reset();
|
||||||
nicListResponseHandler.reset();
|
nicListResponseHandler.reset();
|
||||||
|
|
||||||
|
@ -69,6 +78,7 @@ public class ServerListResponseHandler extends BaseServerResponseHandler<List<Se
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
this.servers = Lists.newArrayList();
|
this.servers = Lists.newArrayList();
|
||||||
|
this.dataCenterBuilder = DataCenter.builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
package org.jclouds.profitbricks.http.parser.snapshot;
|
package org.jclouds.profitbricks.http.parser.snapshot;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import org.jclouds.date.DateCodec;
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.profitbricks.domain.Location;
|
import org.jclouds.profitbricks.domain.Location;
|
||||||
import org.jclouds.profitbricks.domain.OsType;
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
|
@ -29,55 +29,55 @@ public abstract class BaseSnapshotResponseHandler<T> extends BaseProfitBricksRes
|
||||||
|
|
||||||
protected Snapshot.Builder builder;
|
protected Snapshot.Builder builder;
|
||||||
|
|
||||||
protected final DateCodec dateCodec;
|
protected final DateService dateService;
|
||||||
|
|
||||||
BaseSnapshotResponseHandler(DateCodecFactory dateCodec) {
|
BaseSnapshotResponseHandler(DateService dateService) {
|
||||||
this.dateCodec = dateCodec.iso8601();
|
this.dateService = dateService;
|
||||||
this.builder = Snapshot.builder();
|
this.builder = Snapshot.builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Date textToIso8601Date() {
|
protected final Date textToIso8601Date() {
|
||||||
return dateCodec.toDate(textToStringValue());
|
return dateService.iso8601DateOrSecondsDateParse(textToStringValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setPropertyOnEndTag(String qName) {
|
protected void setPropertyOnEndTag(String qName) {
|
||||||
if ("snapshotId".equals(qName))
|
if ("snapshotId".equals(qName))
|
||||||
builder.id(textToStringValue());
|
builder.id(textToStringValue());
|
||||||
else if ("snapshotName".equals(qName))
|
else if ("snapshotName".equals(qName))
|
||||||
builder.name(textToStringValue());
|
builder.name(textToStringValue());
|
||||||
else if ("snapshotSize".equals(qName))
|
else if ("snapshotSize".equals(qName))
|
||||||
builder.size(textToFloatValue());
|
builder.size(textToFloatValue());
|
||||||
else if ("osType".equals(qName))
|
else if ("osType".equals(qName))
|
||||||
builder.osType(OsType.fromValue(textToStringValue()));
|
builder.osType(OsType.fromValue(textToStringValue()));
|
||||||
else if ("location".equals(qName))
|
else if ("location".equals(qName))
|
||||||
builder.location(Location.fromId(textToStringValue()));
|
builder.location(Location.fromId(textToStringValue()));
|
||||||
else if ("description".equals(qName))
|
else if ("description".equals(qName))
|
||||||
builder.description(qName);
|
builder.description(qName);
|
||||||
else if ("bootable".equals(qName))
|
else if ("bootable".equals(qName))
|
||||||
builder.bootable(textToBooleanValue());
|
builder.isBootable(textToBooleanValue());
|
||||||
else if ("cpuHotPlug".equals(qName))
|
else if ("cpuHotPlug".equals(qName))
|
||||||
builder.cpuHotPlug(textToBooleanValue());
|
builder.isCpuHotPlug(textToBooleanValue());
|
||||||
else if ("cpuHotUnPlug".equals(qName))
|
else if ("cpuHotUnPlug".equals(qName))
|
||||||
builder.cpuHotUnPlug(textToBooleanValue());
|
builder.isCpuHotUnPlug(textToBooleanValue());
|
||||||
else if ("ramHotPlug".equals(qName))
|
else if ("ramHotPlug".equals(qName))
|
||||||
builder.ramHotPlug(textToBooleanValue());
|
builder.isRamHotPlug(textToBooleanValue());
|
||||||
else if ("ramHotUnPlug".equals(qName))
|
else if ("ramHotUnPlug".equals(qName))
|
||||||
builder.ramHotUnPlug(textToBooleanValue());
|
builder.isRamHotUnPlug(textToBooleanValue());
|
||||||
else if ("nicHotPlug".equals(qName))
|
else if ("nicHotPlug".equals(qName))
|
||||||
builder.nicHotPlug(textToBooleanValue());
|
builder.isNicHotPlug(textToBooleanValue());
|
||||||
else if ("nicHotUnPlug".equals(qName))
|
else if ("nicHotUnPlug".equals(qName))
|
||||||
builder.nicHotUnPlug(textToBooleanValue());
|
builder.isNicHotUnPlug(textToBooleanValue());
|
||||||
else if ("discVirtioHotPlug".equals(qName))
|
else if ("discVirtioHotPlug".equals(qName))
|
||||||
builder.discVirtioHotPlug(textToBooleanValue());
|
builder.isDiscVirtioHotPlug(textToBooleanValue());
|
||||||
else if ("discVirtioHotUnPlug".equals(qName))
|
else if ("discVirtioHotUnPlug".equals(qName))
|
||||||
builder.discVirtioHotUnPlug(textToBooleanValue());
|
builder.isDiscVirtioHotUnPlug(textToBooleanValue());
|
||||||
else if ("provisioningState".equals(qName))
|
else if ("provisioningState".equals(qName))
|
||||||
builder.state(ProvisioningState.fromValue(textToStringValue()));
|
builder.state(ProvisioningState.fromValue(textToStringValue()));
|
||||||
else if ("creationTimestamp".equals(qName))
|
else if ("creationTimestamp".equals(qName))
|
||||||
builder.creationTime(textToIso8601Date());
|
builder.creationTime(textToIso8601Date());
|
||||||
else if ("modificationTimestamp".equals(qName))
|
else if ("modificationTimestamp".equals(qName))
|
||||||
builder.lastModificationTime(textToIso8601Date());
|
builder.lastModificationTime(textToIso8601Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,19 +18,21 @@ package org.jclouds.profitbricks.http.parser.snapshot;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.profitbricks.domain.Snapshot;
|
import org.jclouds.profitbricks.domain.Snapshot;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
|
||||||
public class SnapshotListResponseHandler extends BaseSnapshotResponseHandler<List<Snapshot>> {
|
public class SnapshotListResponseHandler extends BaseSnapshotResponseHandler<List<Snapshot>> {
|
||||||
|
|
||||||
private final List<Snapshot> snapshots;
|
private final List<Snapshot> snapshots;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SnapshotListResponseHandler(DateCodecFactory dateCodec) {
|
SnapshotListResponseHandler(DateService dateService) {
|
||||||
super(dateCodec);
|
super(dateService);
|
||||||
this.snapshots = Lists.newArrayList();
|
this.snapshots = Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +40,8 @@ public class SnapshotListResponseHandler extends BaseSnapshotResponseHandler<Lis
|
||||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||||
setPropertyOnEndTag(qName);
|
setPropertyOnEndTag(qName);
|
||||||
if ("return".equals(qName)) {
|
if ("return".equals(qName)) {
|
||||||
snapshots.add(builder.build());
|
snapshots.add(builder.build());
|
||||||
builder = Snapshot.builder();
|
builder = Snapshot.builder();
|
||||||
}
|
}
|
||||||
clearTextBuffer();
|
clearTextBuffer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
package org.jclouds.profitbricks.http.parser.snapshot;
|
package org.jclouds.profitbricks.http.parser.snapshot;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.profitbricks.domain.Snapshot;
|
import org.jclouds.profitbricks.domain.Snapshot;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
@ -26,17 +27,17 @@ public class SnapshotResponseHandler extends BaseSnapshotResponseHandler<Snapsho
|
||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SnapshotResponseHandler(DateCodecFactory dateCodec) {
|
SnapshotResponseHandler(DateService dateService) {
|
||||||
super(dateCodec);
|
super(dateService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||||
if (done)
|
if (done)
|
||||||
return;
|
return;
|
||||||
setPropertyOnEndTag(qName);
|
setPropertyOnEndTag(qName);
|
||||||
if ("return".equals(qName))
|
if ("return".equals(qName))
|
||||||
done = true;
|
done = true;
|
||||||
clearTextBuffer();
|
clearTextBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,9 @@ package org.jclouds.profitbricks.http.parser.storage;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodec;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
import org.jclouds.profitbricks.domain.Storage;
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
import org.jclouds.profitbricks.domain.Storage.BusType;
|
import org.jclouds.profitbricks.domain.Storage.BusType;
|
||||||
|
@ -33,20 +31,20 @@ import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public abstract class BaseStorageResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
|
public abstract class BaseStorageResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
|
||||||
|
|
||||||
protected final DateCodec dateCodec;
|
protected final DateService dateService;
|
||||||
|
|
||||||
protected Storage.Builder builder;
|
protected Storage.Builder builder;
|
||||||
protected List<String> serverIds;
|
protected List<String> serverIds;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BaseStorageResponseHandler(DateCodecFactory dateCodec) {
|
BaseStorageResponseHandler(DateService dateService) {
|
||||||
this.dateCodec = dateCodec.iso8601();
|
this.dateService = dateService;
|
||||||
this.builder = Storage.builder();
|
this.builder = Storage.builder();
|
||||||
this.serverIds = Lists.newArrayList();
|
this.serverIds = Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Date textToIso8601Date() {
|
protected final Date textToIso8601Date() {
|
||||||
return dateCodec.toDate(textToStringValue());
|
return dateService.iso8601DateOrSecondsDateParse(textToStringValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
package org.jclouds.profitbricks.http.parser.storage;
|
package org.jclouds.profitbricks.http.parser.storage;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.profitbricks.domain.Storage;
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
@ -26,8 +27,8 @@ public class StorageInfoResponseHandler extends BaseStorageResponseHandler<Stora
|
||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
StorageInfoResponseHandler(DateCodecFactory dateCodec) {
|
StorageInfoResponseHandler(DateService dateService) {
|
||||||
super(dateCodec);
|
super(dateService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,22 +16,22 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.http.parser.storage;
|
package org.jclouds.profitbricks.http.parser.storage;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.profitbricks.domain.Storage;
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public class StorageListResponseHandler extends BaseStorageResponseHandler<List<Storage>> {
|
public class StorageListResponseHandler extends BaseStorageResponseHandler<List<Storage>> {
|
||||||
|
|
||||||
private List<Storage> storages;
|
private List<Storage> storages;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
StorageListResponseHandler(DateCodecFactory dateCodec) {
|
StorageListResponseHandler(DateService dateService) {
|
||||||
super(dateCodec);
|
super(dateService);
|
||||||
this.storages = Lists.newArrayList();
|
this.storages = Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.util;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
public class Passwords {
|
||||||
|
|
||||||
|
private static final Random random = new Random();
|
||||||
|
|
||||||
|
private static final int MIN_CHAR = 8;
|
||||||
|
private static final int MAX_CHAR = 50;
|
||||||
|
private static final String PASSWORD_FORMAT = String.format(
|
||||||
|
"[a-zA-Z0-9][^iIloOwWyYzZ10]{%d,%d}", MIN_CHAR - 1, MAX_CHAR);
|
||||||
|
private static final Pattern PASSWORD_PATTERN = Pattern.compile(PASSWORD_FORMAT);
|
||||||
|
|
||||||
|
private static final ImmutableSet<Character> INVALID_CHARS = ImmutableSet.<Character>of(
|
||||||
|
'i', 'I', 'l', 'o', 'O', 'w', 'W', 'y', 'Y', 'z', 'Z', '1', '0');
|
||||||
|
|
||||||
|
public static boolean isValidPassword(String password) {
|
||||||
|
return PASSWORD_PATTERN.matcher(password).matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String generate() {
|
||||||
|
int count = random.nextInt(MAX_CHAR - MIN_CHAR) + MIN_CHAR;
|
||||||
|
|
||||||
|
final char[] buffer = new char[count];
|
||||||
|
|
||||||
|
final int start = 'A';
|
||||||
|
final int end = 'z';
|
||||||
|
final int gap = end - start + 1;
|
||||||
|
|
||||||
|
while (count-- != 0) {
|
||||||
|
char ch = (char) (random.nextInt(gap) + start);
|
||||||
|
if ((isBetween(ch, start, 'Z') || isBetween(ch, 'a', end))
|
||||||
|
&& !INVALID_CHARS.contains(ch))
|
||||||
|
buffer[count] = ch;
|
||||||
|
else
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return new String(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isBetween(char ch, int start, int end) {
|
||||||
|
return ch >= start && ch <= end;
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,11 +37,11 @@ public class CreateSnapshotRequestBinderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String expectedPayload
|
private final String expectedPayload
|
||||||
= (" <ws:createSnapshot>\n"
|
= (" <ws:createSnapshot>\n"
|
||||||
+ "<request>\n"
|
+ "<request>\n"
|
||||||
+ "<storageId>123-1233-1324</storageId>\n"
|
+ "<storageId>123-1233-1324</storageId>\n"
|
||||||
+ "<description>describing the snapshot</description>\n"
|
+ "<description>describing the snapshot</description>\n"
|
||||||
+ "<snapshotName>snapshot name</snapshotName>\n"
|
+ "<snapshotName>snapshot name</snapshotName>\n"
|
||||||
+ "</request>\n"
|
+ "</request>\n"
|
||||||
+ "</ws:createSnapshot>").replaceAll("\\s+", "");
|
+ "</ws:createSnapshot>").replaceAll("\\s+", "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,9 @@ public class RollbackSnapshotRequestBinderTest {
|
||||||
RollbackSnapshotRequestBinder binder = new RollbackSnapshotRequestBinder();
|
RollbackSnapshotRequestBinder binder = new RollbackSnapshotRequestBinder();
|
||||||
|
|
||||||
Snapshot.Request.RollbackPayload payload = Snapshot.Request.rollbackBuilder()
|
Snapshot.Request.RollbackPayload payload = Snapshot.Request.rollbackBuilder()
|
||||||
.snapshotId("snapshot-id")
|
.snapshotId("snapshot-id")
|
||||||
.storageId("storage-id")
|
.storageId("storage-id")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String actual = binder.createPayload(payload);
|
String actual = binder.createPayload(payload);
|
||||||
assertNotNull(actual, "Binder returned null payload");
|
assertNotNull(actual, "Binder returned null payload");
|
||||||
|
@ -39,9 +39,9 @@ public class RollbackSnapshotRequestBinderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String expectedPayload = "<ws:rollbackSnapshot>"
|
private final String expectedPayload = "<ws:rollbackSnapshot>"
|
||||||
+ "<request>"
|
+ "<request>"
|
||||||
+ "<snapshotId>snapshot-id</snapshotId>"
|
+ "<snapshotId>snapshot-id</snapshotId>"
|
||||||
+ "<storageId>storage-id</storageId>"
|
+ "<storageId>storage-id</storageId>"
|
||||||
+ "</request>"
|
+ "</request>"
|
||||||
+ "</ws:rollbackSnapshot>".replaceAll("\\s", "");
|
+ "</ws:rollbackSnapshot>".replaceAll("\\s", "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
|
||||||
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
|
import org.jclouds.logging.config.LoggingModule;
|
||||||
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
|
|
||||||
|
@Test(groups = "live", singleThreaded = true, testName = "ProfitBricksComputeServiceAdapterLiveTest")
|
||||||
|
public class ProfitBricksComputeServiceAdapterLiveTest extends BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
|
public ProfitBricksComputeServiceAdapterLiveTest() {
|
||||||
|
provider = "profitbricks";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Module getSshModule() {
|
||||||
|
return new SshjSshClientModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LoggingModule getLoggingModule() {
|
||||||
|
return new SLF4JLoggingModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testOptionToNotBlock() throws Exception {
|
||||||
|
// ProfitBricks implementation intentionally blocks until the node is 'AVAILABLE'
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void checkTagsInNodeEquals(NodeMetadata node, ImmutableSet<String> tags) {
|
||||||
|
// ProfitBricks doesn't support tags
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||||
|
// ProfitBricks doesn't support user metadata
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) {
|
||||||
|
// ProfitBricks doesn't support hostname
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void checkOsMatchesTemplate(NodeMetadata node) {
|
||||||
|
// Not enough description from API to match template
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@Test(groups = "live", testName = "ProfitBricksTemplateBuilderLiveTest")
|
||||||
|
public class ProfitBricksTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
|
|
||||||
|
public ProfitBricksTemplateBuilderLiveTest() {
|
||||||
|
this.provider = "profitbricks";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<String> getIso3166Codes() {
|
||||||
|
return ImmutableSet.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.concurrent;
|
||||||
|
|
||||||
|
import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
|
||||||
|
import static java.util.logging.Logger.getAnonymousLogger;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
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.base.Throwables;
|
||||||
|
|
||||||
|
@Test(groups = "unit", testName = "ProvisioningManagerTest")
|
||||||
|
public class ProvisioningManagerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProvision() throws IOException {
|
||||||
|
ProvisioningManager manager = new ProvisioningManager();
|
||||||
|
AtomicInteger completedJobs = new AtomicInteger(0);
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
manager.provision(new MockJob(200, "slow", completedJobs));
|
||||||
|
manager.provision(new MockJob(0, "fast", completedJobs));
|
||||||
|
manager.provision(new MockJob(100, "normal", completedJobs));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
manager.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(completedJobs.get(), 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProvisionInterrupted() {
|
||||||
|
ProvisioningManager manager = new ProvisioningManager();
|
||||||
|
AtomicInteger completedJobs = new AtomicInteger(0);
|
||||||
|
|
||||||
|
manager.provision(new ShutdownExecutorJob(manager, completedJobs));
|
||||||
|
manager.provision(new MockJob(0, "rejected", completedJobs));
|
||||||
|
|
||||||
|
assertEquals(completedJobs.get(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class MockJob extends ProvisioningJob {
|
||||||
|
|
||||||
|
private final long delay;
|
||||||
|
private final AtomicInteger completedJobs;
|
||||||
|
|
||||||
|
public MockJob(long delay, String group, AtomicInteger completedJobs) {
|
||||||
|
super(sleepPredicate(delay), group, Suppliers.ofInstance((Object) 0));
|
||||||
|
this.delay = delay;
|
||||||
|
this.completedJobs = completedJobs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer call() throws Exception {
|
||||||
|
getAnonymousLogger().info("ProvisioningManagerTest: Starting " + this);
|
||||||
|
super.call();
|
||||||
|
getAnonymousLogger().info("ProvisioningManagerTest: Completed " + this);
|
||||||
|
return completedJobs.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MockJob [id=" + hashCode() + ", group=" + getGroup() + ", delay=" + delay + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ShutdownExecutorJob extends ProvisioningJob {
|
||||||
|
|
||||||
|
public ShutdownExecutorJob(final ProvisioningManager manager, final AtomicInteger completedJobs) {
|
||||||
|
super(Predicates.<String>alwaysTrue(), "shutdown", new Supplier<Object>() {
|
||||||
|
@Override
|
||||||
|
public Integer get() {
|
||||||
|
try {
|
||||||
|
manager.close();
|
||||||
|
return completedJobs.incrementAndGet();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw Throwables.propagate(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Predicate<String> sleepPredicate(final long delay) {
|
||||||
|
return new Predicate<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(String input) {
|
||||||
|
sleepUninterruptibly(delay, TimeUnit.MILLISECONDS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.function;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.location.suppliers.all.JustProvider;
|
||||||
|
import org.jclouds.profitbricks.ProfitBricksProviderMetadata;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
@Test(groups = "unit", testName = "DataCenterToLocationTest")
|
||||||
|
public class DataCenterToLocationTest {
|
||||||
|
|
||||||
|
private DataCenterToLocation fnLocation;
|
||||||
|
private LocationToLocation fnRegion;
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
public void setup() {
|
||||||
|
ProfitBricksProviderMetadata metadata = new ProfitBricksProviderMetadata();
|
||||||
|
JustProvider justProvider = new JustProvider(metadata.getId(), Suppliers.<URI>ofInstance(
|
||||||
|
URI.create(metadata.getEndpoint())), ImmutableSet.<String>of());
|
||||||
|
this.fnRegion = new LocationToLocation(justProvider);
|
||||||
|
this.fnLocation = new DataCenterToLocation(fnRegion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDataCenterToLocation() {
|
||||||
|
DataCenter dataCenter = DataCenter.builder()
|
||||||
|
.id("12345678-abcd-efgh-ijkl-987654321000")
|
||||||
|
.version(10)
|
||||||
|
.name("JClouds-DC")
|
||||||
|
.state(ProvisioningState.AVAILABLE)
|
||||||
|
.location(org.jclouds.profitbricks.domain.Location.DE_FRA)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Location actual = fnLocation.apply(dataCenter);
|
||||||
|
|
||||||
|
Location expected = new LocationBuilder()
|
||||||
|
.id(dataCenter.id())
|
||||||
|
.description(dataCenter.name())
|
||||||
|
.scope(LocationScope.ZONE)
|
||||||
|
.metadata(ImmutableMap.<String, Object>of(
|
||||||
|
"version", dataCenter.version(),
|
||||||
|
"state", dataCenter.state()))
|
||||||
|
.parent(fnRegion.apply(org.jclouds.profitbricks.domain.Location.DE_FRA))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(actual, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.function;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.location.suppliers.all.JustProvider;
|
||||||
|
import org.jclouds.profitbricks.ProfitBricksProviderMetadata;
|
||||||
|
import org.jclouds.profitbricks.domain.Location;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
@Test(groups = "unit", testName = "LocationToLocationTest")
|
||||||
|
public class LocationToLocationTest {
|
||||||
|
|
||||||
|
private LocationToLocation fnRegion;
|
||||||
|
private JustProvider justProvider;
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
public void setup() {
|
||||||
|
ProfitBricksProviderMetadata metadata = new ProfitBricksProviderMetadata();
|
||||||
|
this.justProvider = new JustProvider(metadata.getId(), Suppliers.<URI>ofInstance(
|
||||||
|
URI.create(metadata.getEndpoint())), ImmutableSet.<String>of());
|
||||||
|
this.fnRegion = new LocationToLocation(justProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLocationToLocation() {
|
||||||
|
Location[] locations = Location.values();
|
||||||
|
for (Location loc : locations) {
|
||||||
|
org.jclouds.domain.Location actual = fnRegion.apply(loc);
|
||||||
|
org.jclouds.domain.Location expected = new LocationBuilder()
|
||||||
|
.id(loc.getId()).description(loc.getDescription()).scope(LocationScope.REGION)
|
||||||
|
.parent(Iterables.getOnlyElement(justProvider.get())).build();
|
||||||
|
|
||||||
|
assertEquals(actual, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,260 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.function;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.ImageBuilder;
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.location.suppliers.all.JustProvider;
|
||||||
|
import org.jclouds.profitbricks.ProfitBricksProviderMetadata;
|
||||||
|
import org.jclouds.profitbricks.domain.Location;
|
||||||
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
|
import org.jclouds.profitbricks.domain.Snapshot;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
@Test(groups = "unit", testName = "ProvisionableToImageTest")
|
||||||
|
public class ProvisionableToImageTest {
|
||||||
|
|
||||||
|
private ProvisionableToImage fnImage;
|
||||||
|
private LocationToLocation fnRegion;
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
public void setup() {
|
||||||
|
ProfitBricksProviderMetadata metadata = new ProfitBricksProviderMetadata();
|
||||||
|
JustProvider justProvider = new JustProvider(metadata.getId(), Suppliers.<URI>ofInstance(
|
||||||
|
URI.create(metadata.getEndpoint())), ImmutableSet.<String>of());
|
||||||
|
this.fnRegion = new LocationToLocation(justProvider);
|
||||||
|
this.fnImage = new ProvisionableToImage(fnRegion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testImageToImage() {
|
||||||
|
org.jclouds.profitbricks.domain.Image image
|
||||||
|
= org.jclouds.profitbricks.domain.Image.builder()
|
||||||
|
.isBootable(true)
|
||||||
|
.isCpuHotPlug(true)
|
||||||
|
.isCpuHotUnPlug(false)
|
||||||
|
.isDiscVirtioHotPlug(true)
|
||||||
|
.isDiscVirtioHotUnPlug(true)
|
||||||
|
.id("5ad99c9e-9166-11e4-9d74-52540066fee9")
|
||||||
|
.name("Ubuntu-14.04-LTS-server-2015-01-01")
|
||||||
|
.size(2048f)
|
||||||
|
.type(org.jclouds.profitbricks.domain.Image.Type.HDD)
|
||||||
|
.location(Location.US_LAS)
|
||||||
|
.isNicHotPlug(true)
|
||||||
|
.isNicHotUnPlug(true)
|
||||||
|
.osType(OsType.LINUX)
|
||||||
|
.isPublic(true)
|
||||||
|
.isRamHotPlug(true)
|
||||||
|
.isRamHotUnPlug(false)
|
||||||
|
.isWriteable(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Image actual = fnImage.apply(image);
|
||||||
|
|
||||||
|
Image expected = new ImageBuilder()
|
||||||
|
.ids(image.id())
|
||||||
|
.name(image.name())
|
||||||
|
.location(fnRegion.apply(Location.US_LAS))
|
||||||
|
.status(Image.Status.AVAILABLE)
|
||||||
|
.operatingSystem(OperatingSystem.builder()
|
||||||
|
.description("UBUNTU")
|
||||||
|
.family(OsFamily.UBUNTU)
|
||||||
|
.version("14.04")
|
||||||
|
.is64Bit(false)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(actual, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testImageDescriptionParsing() {
|
||||||
|
org.jclouds.profitbricks.domain.Image image1
|
||||||
|
= org.jclouds.profitbricks.domain.Image.builder()
|
||||||
|
.id("f4742db0-9160-11e4-9d74-52540066fee9")
|
||||||
|
.name("Fedora-19-server-2015-01-01")
|
||||||
|
.size(2048f)
|
||||||
|
.type(org.jclouds.profitbricks.domain.Image.Type.HDD)
|
||||||
|
.location(Location.DE_FRA)
|
||||||
|
.osType(OsType.LINUX)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Image actual1 = fnImage.apply(image1);
|
||||||
|
|
||||||
|
Image expected1 = new ImageBuilder()
|
||||||
|
.ids(image1.id())
|
||||||
|
.name(image1.name())
|
||||||
|
.location(fnRegion.apply(image1.location()))
|
||||||
|
.status(Image.Status.AVAILABLE)
|
||||||
|
.operatingSystem(OperatingSystem.builder()
|
||||||
|
.description("FEDORA")
|
||||||
|
.family(OsFamily.FEDORA)
|
||||||
|
.version("7")
|
||||||
|
.is64Bit(true)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(actual1, expected1);
|
||||||
|
|
||||||
|
org.jclouds.profitbricks.domain.Image image2
|
||||||
|
= org.jclouds.profitbricks.domain.Image.builder()
|
||||||
|
.id("457bf707-d5d1-11e3-8b4f-52540066fee9")
|
||||||
|
.name("clearos-community-6.5.0-x86_64.iso")
|
||||||
|
.size(2048f)
|
||||||
|
.type(org.jclouds.profitbricks.domain.Image.Type.CDROM)
|
||||||
|
.location(Location.DE_FKB)
|
||||||
|
.osType(OsType.LINUX)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Image actual2 = fnImage.apply(image2);
|
||||||
|
|
||||||
|
Image expected2 = new ImageBuilder()
|
||||||
|
.ids(image2.id())
|
||||||
|
.name(image2.name())
|
||||||
|
.location(fnRegion.apply(image2.location()))
|
||||||
|
.status(Image.Status.AVAILABLE)
|
||||||
|
.operatingSystem(OperatingSystem.builder()
|
||||||
|
.description("UNRECOGNIZED")
|
||||||
|
.family(OsFamily.UNRECOGNIZED)
|
||||||
|
.version("6.5.0")
|
||||||
|
.is64Bit(true)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(actual2, expected2);
|
||||||
|
|
||||||
|
org.jclouds.profitbricks.domain.Image image3
|
||||||
|
= org.jclouds.profitbricks.domain.Image.builder()
|
||||||
|
.id("e54af701-53b8-11e3-8f17-52540066fee9")
|
||||||
|
.name("windows-2008-r2-server-setup.iso")
|
||||||
|
.size(2048f)
|
||||||
|
.type(org.jclouds.profitbricks.domain.Image.Type.CDROM)
|
||||||
|
.location(Location.US_LASDEV)
|
||||||
|
.osType(OsType.WINDOWS)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Image actual3 = fnImage.apply(image3);
|
||||||
|
|
||||||
|
Image expected3 = new ImageBuilder()
|
||||||
|
.ids(image3.id())
|
||||||
|
.name(image3.name())
|
||||||
|
.location(fnRegion.apply(image3.location()))
|
||||||
|
.status(Image.Status.AVAILABLE)
|
||||||
|
.operatingSystem(OperatingSystem.builder()
|
||||||
|
.description("WINDOWS")
|
||||||
|
.family(OsFamily.WINDOWS)
|
||||||
|
.version("2008")
|
||||||
|
.is64Bit(false)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(actual3, expected3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSnapshotToImage() {
|
||||||
|
Snapshot snapshot1 = Snapshot.builder()
|
||||||
|
.isBootable(true)
|
||||||
|
.isCpuHotPlug(true)
|
||||||
|
.isCpuHotUnPlug(false)
|
||||||
|
.isDiscVirtioHotPlug(true)
|
||||||
|
.isDiscVirtioHotUnPlug(true)
|
||||||
|
.id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||||
|
.name("placeholder-snapshot-04/13/2015")
|
||||||
|
.description("Created from \"placeholder\" in Data Center \"sbx-computeservice\"")
|
||||||
|
.size(2048f)
|
||||||
|
.location(Location.US_LAS)
|
||||||
|
.isNicHotPlug(true)
|
||||||
|
.isNicHotUnPlug(true)
|
||||||
|
.osType(OsType.LINUX)
|
||||||
|
.isRamHotPlug(true)
|
||||||
|
.isRamHotUnPlug(false)
|
||||||
|
.creationTime(new Date(2015, 4, 13))
|
||||||
|
.lastModificationTime(new Date())
|
||||||
|
.state(ProvisioningState.AVAILABLE)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Image actual1 = fnImage.apply(snapshot1);
|
||||||
|
|
||||||
|
Image expected1 = new ImageBuilder()
|
||||||
|
.ids(snapshot1.id())
|
||||||
|
.name(snapshot1.name())
|
||||||
|
.location(fnRegion.apply(Location.US_LAS))
|
||||||
|
.status(Image.Status.AVAILABLE)
|
||||||
|
.operatingSystem(OperatingSystem.builder()
|
||||||
|
.description(snapshot1.description())
|
||||||
|
.family(OsFamily.LINUX)
|
||||||
|
.is64Bit(true)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(actual1, expected1);
|
||||||
|
|
||||||
|
Snapshot snapshot2 = Snapshot.builder()
|
||||||
|
.isBootable(true)
|
||||||
|
.isCpuHotPlug(true)
|
||||||
|
.isCpuHotUnPlug(false)
|
||||||
|
.isDiscVirtioHotPlug(true)
|
||||||
|
.isDiscVirtioHotUnPlug(true)
|
||||||
|
.id("d80bf9c0-ce6e-4283-9ea4-2906635f6137")
|
||||||
|
.name("jclouds-ubuntu14.10-template")
|
||||||
|
.description("Created from \"jclouds-ubuntu14.10 Storage\" in Data Center \"jclouds-computeservice\"")
|
||||||
|
.size(10240f)
|
||||||
|
.location(Location.DE_FKB)
|
||||||
|
.isNicHotPlug(true)
|
||||||
|
.isNicHotUnPlug(true)
|
||||||
|
.osType(OsType.LINUX)
|
||||||
|
.isRamHotPlug(true)
|
||||||
|
.isRamHotUnPlug(false)
|
||||||
|
.creationTime(new Date(2015, 4, 13))
|
||||||
|
.lastModificationTime(new Date())
|
||||||
|
.state(ProvisioningState.INPROCESS)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Image actual2 = fnImage.apply(snapshot2);
|
||||||
|
|
||||||
|
Image expected2 = new ImageBuilder()
|
||||||
|
.ids(snapshot2.id())
|
||||||
|
.name(snapshot2.name())
|
||||||
|
.location(fnRegion.apply(Location.DE_FKB))
|
||||||
|
.status(Image.Status.PENDING)
|
||||||
|
.operatingSystem(OperatingSystem.builder()
|
||||||
|
.description("ubuntu")
|
||||||
|
.family(OsFamily.UBUNTU)
|
||||||
|
.is64Bit(true)
|
||||||
|
.version("00.00")
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(actual2, expected2);
|
||||||
|
assertEquals(actual2.getOperatingSystem(), expected2.getOperatingSystem());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,184 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.function;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.Processor;
|
||||||
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.compute.domain.VolumeBuilder;
|
||||||
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.profitbricks.ProfitBricksApiMetadata;
|
||||||
|
import org.jclouds.profitbricks.domain.AvailabilityZone;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
|
import org.jclouds.profitbricks.domain.Nic;
|
||||||
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
|
import org.jclouds.profitbricks.domain.Server;
|
||||||
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
|
@Test(groups = "unit", testName = "ServerToNodeMetadataTest")
|
||||||
|
public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
|
private ServerToNodeMetadata fnNodeMetadata;
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
public void setup() {
|
||||||
|
Supplier<Set<? extends Location>> locationsSupply = new Supplier<Set<? extends Location>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<? extends Location> get() {
|
||||||
|
return ImmutableSet.of(
|
||||||
|
new LocationBuilder()
|
||||||
|
.id("12345678-abcd-efgh-ijkl-987654321000")
|
||||||
|
.description("JClouds-DC")
|
||||||
|
.scope(LocationScope.REGION)
|
||||||
|
.metadata(ImmutableMap.<String, Object>of(
|
||||||
|
"version", "10",
|
||||||
|
"state", "AVAILABLE"))
|
||||||
|
.parent(new LocationBuilder()
|
||||||
|
.id("de/fra")
|
||||||
|
.description("Germany, Frankfurt (M)")
|
||||||
|
.scope(LocationScope.PROVIDER)
|
||||||
|
.build())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GroupNamingConvention.Factory namingConvention = Guice.createInjector(new AbstractModule() {
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
Names.bindProperties(binder(), new ProfitBricksApiMetadata().getDefaultProperties());
|
||||||
|
}
|
||||||
|
}).getInstance(GroupNamingConvention.Factory.class);
|
||||||
|
|
||||||
|
this.fnNodeMetadata = new ServerToNodeMetadata(new StorageToVolume(), locationsSupply, namingConvention);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testServerToNodeMetadata() {
|
||||||
|
Server server = Server.builder()
|
||||||
|
.dataCenter(DataCenter.builder()
|
||||||
|
.id("12345678-abcd-efgh-ijkl-987654321000").version(10)
|
||||||
|
.build())
|
||||||
|
.id("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
|
||||||
|
.name("mock-facebook-node")
|
||||||
|
.cores(4)
|
||||||
|
.ram(4096)
|
||||||
|
.hasInternetAccess(true)
|
||||||
|
.state(ProvisioningState.AVAILABLE)
|
||||||
|
.status(Server.Status.RUNNING)
|
||||||
|
.osType(OsType.LINUX)
|
||||||
|
.availabilityZone(AvailabilityZone.AUTO)
|
||||||
|
.isCpuHotPlug(true)
|
||||||
|
.isRamHotPlug(true)
|
||||||
|
.isNicHotPlug(true)
|
||||||
|
.isNicHotUnPlug(true)
|
||||||
|
.isDiscVirtioHotPlug(true)
|
||||||
|
.isDiscVirtioHotUnPlug(true)
|
||||||
|
.storages(ImmutableList.<Storage>of(
|
||||||
|
Storage.builder()
|
||||||
|
.bootDevice(true)
|
||||||
|
.busType(Storage.BusType.VIRTIO)
|
||||||
|
.deviceNumber(1)
|
||||||
|
.size(40f)
|
||||||
|
.id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||||
|
.name("facebook-storage")
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.nics(ImmutableList.<Nic>of(
|
||||||
|
Nic.builder()
|
||||||
|
.id("qwqwqwqw-wewe-erer-rtrt-tytytytytyty")
|
||||||
|
.lanId(1)
|
||||||
|
.dataCenterId("12345678-abcd-efgh-ijkl-987654321000")
|
||||||
|
.internetAccess(true)
|
||||||
|
.serverId("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
|
||||||
|
.macAddress("02:01:09:cd:f0:b0")
|
||||||
|
.ip("173.252.120.6")
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
NodeMetadata expected = fnNodeMetadata.apply(server);
|
||||||
|
assertNotNull(expected);
|
||||||
|
|
||||||
|
NodeMetadata actual = new NodeMetadataBuilder()
|
||||||
|
.group("mock")
|
||||||
|
.ids(server.id())
|
||||||
|
.name(server.name())
|
||||||
|
.backendStatus("AVAILABLE")
|
||||||
|
.status(NodeMetadata.Status.RUNNING)
|
||||||
|
.hardware(new HardwareBuilder()
|
||||||
|
.ids("cpu=4,ram=4096,disk=40")
|
||||||
|
.name("cpu=4,ram=4096,disk=40")
|
||||||
|
.ram(server.ram())
|
||||||
|
.processor(new Processor(server.cores(), 1d))
|
||||||
|
.hypervisor("kvm")
|
||||||
|
.volume(new VolumeBuilder()
|
||||||
|
.bootDevice(true)
|
||||||
|
.size(40f)
|
||||||
|
.id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||||
|
.durable(true)
|
||||||
|
.type(Volume.Type.LOCAL)
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.operatingSystem(new OperatingSystem.Builder()
|
||||||
|
.description(OsFamily.LINUX.value())
|
||||||
|
.family(OsFamily.LINUX)
|
||||||
|
.build())
|
||||||
|
.location(new LocationBuilder()
|
||||||
|
.id("12345678-abcd-efgh-ijkl-987654321000")
|
||||||
|
.description("JClouds-DC")
|
||||||
|
.scope(LocationScope.REGION)
|
||||||
|
.metadata(ImmutableMap.<String, Object>of(
|
||||||
|
"version", "10",
|
||||||
|
"state", "AVAILABLE"))
|
||||||
|
.parent(new LocationBuilder()
|
||||||
|
.id("de/fra")
|
||||||
|
.description("Germany, Frankfurt (M)")
|
||||||
|
.scope(LocationScope.PROVIDER)
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.publicAddresses(ImmutableList.<String>of("173.252.120.6"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(actual, expected);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.compute.function;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.compute.domain.VolumeBuilder;
|
||||||
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@Test(groups = "unit", testName = "StorageToVolumeTest")
|
||||||
|
public class StorageToVolumeTest {
|
||||||
|
|
||||||
|
private StorageToVolume fnVolume;
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
public void setup() {
|
||||||
|
this.fnVolume = new StorageToVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStorageToVolume() {
|
||||||
|
Storage storage = Storage.builder()
|
||||||
|
.id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||||
|
.size(40)
|
||||||
|
.name("hdd-1")
|
||||||
|
.busType(Storage.BusType.VIRTIO)
|
||||||
|
.bootDevice(true)
|
||||||
|
.deviceNumber(1)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Volume actual = fnVolume.apply(storage);
|
||||||
|
|
||||||
|
Volume expected = new VolumeBuilder()
|
||||||
|
.id(storage.id())
|
||||||
|
.size(40f)
|
||||||
|
.bootDevice(true)
|
||||||
|
.device("1")
|
||||||
|
.type(Volume.Type.LOCAL)
|
||||||
|
.durable(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(actual, expected);
|
||||||
|
}
|
||||||
|
}
|
|
@ -138,8 +138,8 @@ public class ProvisioningStatusPollingPredicateTest extends BaseProfitBricksMock
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSnapshotPredicate() throws Exception{
|
public void testSnapshotPredicate() throws Exception {
|
||||||
MockWebServer server = mockWebServer();
|
MockWebServer server = mockWebServer();
|
||||||
|
|
||||||
byte[] payloadInProcess = payloadFromResource("/snapshot/snapshot-state-inprocess.xml");
|
byte[] payloadInProcess = payloadFromResource("/snapshot/snapshot-state-inprocess.xml");
|
||||||
byte[] payloadAvailable = payloadFromResource("/snapshot/snapshot.xml");
|
byte[] payloadAvailable = payloadFromResource("/snapshot/snapshot.xml");
|
||||||
|
|
|
@ -16,16 +16,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.features;
|
package org.jclouds.profitbricks.features;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertFalse;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.profitbricks.BaseProfitBricksLiveTest;
|
import org.jclouds.profitbricks.BaseProfitBricksLiveTest;
|
||||||
import org.jclouds.profitbricks.domain.Drive;
|
import org.jclouds.profitbricks.domain.Drive;
|
||||||
import org.jclouds.profitbricks.domain.Image;
|
import org.jclouds.profitbricks.domain.Image;
|
||||||
import org.jclouds.profitbricks.domain.Server;
|
import org.jclouds.profitbricks.domain.Server;
|
||||||
|
|
||||||
import static org.testng.Assert.assertFalse;
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -67,7 +66,7 @@ public class DrivesApiLiveTest extends BaseProfitBricksLiveTest {
|
||||||
assertNotNull(requestId);
|
assertNotNull(requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test (dependsOnMethods = "addRomDriveToServerTest")
|
@Test(dependsOnMethods = "addRomDriveToServerTest")
|
||||||
public void removeRomDriveFromServerTest() {
|
public void removeRomDriveFromServerTest() {
|
||||||
String requestId = api.drivesApi().removeRomDriveFromServer(imageId, serverId);
|
String requestId = api.drivesApi().removeRomDriveFromServer(imageId, serverId);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.features;
|
package org.jclouds.profitbricks.features;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -41,6 +40,7 @@ import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
@Test(groups = "live", testName = "FirewallApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "FirewallApiLiveTest", singleThreaded = true)
|
||||||
public class FirewallApiLiveTest extends BaseProfitBricksLiveTest {
|
public class FirewallApiLiveTest extends BaseProfitBricksLiveTest {
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class IpBlockApiLiveTest extends BaseProfitBricksLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReservePublicIpBlock() {
|
public void testReservePublicIpBlock() {
|
||||||
newIpBlock = api.ipBlockApi().reservePublicIpBlock("2", Location.US_LAS.value());
|
newIpBlock = api.ipBlockApi().reservePublicIpBlock("2", Location.US_LAS.getId());
|
||||||
|
|
||||||
assertNotNull(newIpBlock);
|
assertNotNull(newIpBlock);
|
||||||
assertNotNull(newIpBlock.ips());
|
assertNotNull(newIpBlock.ips());
|
||||||
|
|
|
@ -122,9 +122,9 @@ public class IpBlockApiMockTest extends BaseProfitBricksMockTest {
|
||||||
String blockSize = "2";
|
String blockSize = "2";
|
||||||
Location location = Location.US_LAS;
|
Location location = Location.US_LAS;
|
||||||
|
|
||||||
String content = "<ws:reservePublicIpBlock><request><blockSize>" + blockSize + "</blockSize><location>" + location.value() + "</location></request></ws:reservePublicIpBlock>";
|
String content = "<ws:reservePublicIpBlock><request><blockSize>" + blockSize + "</blockSize><location>" + location.getId() + "</location></request></ws:reservePublicIpBlock>";
|
||||||
try {
|
try {
|
||||||
IpBlock ipBlock = api.reservePublicIpBlock(blockSize, location.value());
|
IpBlock ipBlock = api.reservePublicIpBlock(blockSize, location.getId());
|
||||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||||
assertNotNull(ipBlock);
|
assertNotNull(ipBlock);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class LoadbalancerApiLiveTest extends BaseProfitBricksLiveTest {
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
public void testDeleteLoadBalancer() {
|
public void testDeleteLoadBalancer() {
|
||||||
boolean result = api.loadBalancerApi().deleteLoadbalancer(loadBalancerID);
|
boolean result = api.loadBalancerApi().deleteLoadBalancer(loadBalancerID);
|
||||||
|
|
||||||
Assert.assertTrue(result);
|
Assert.assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,7 +273,7 @@ public class LoadbalancerApiMockTest extends BaseProfitBricksMockTest {
|
||||||
String content = "<ws:deleteLoadBalancer><loadBalancerId>" + loadBalancerId + "</loadBalancerId></ws:deleteLoadBalancer>";
|
String content = "<ws:deleteLoadBalancer><loadBalancerId>" + loadBalancerId + "</loadBalancerId></ws:deleteLoadBalancer>";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean done = api.deleteLoadbalancer(loadBalancerId);
|
boolean done = api.deleteLoadBalancer(loadBalancerId);
|
||||||
|
|
||||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||||
assertTrue(done);
|
assertTrue(done);
|
||||||
|
|
|
@ -89,20 +89,20 @@ public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest {
|
||||||
String newName = "new name";
|
String newName = "new name";
|
||||||
|
|
||||||
api.snapshotApi().updateSnapshot(Snapshot.Request.updatingBuilder()
|
api.snapshotApi().updateSnapshot(Snapshot.Request.updatingBuilder()
|
||||||
.snapshotId(snapshotId)
|
.snapshotId(snapshotId)
|
||||||
.description("new description")
|
.description("new description")
|
||||||
.name(newName)
|
.name(newName)
|
||||||
.bootable(true)
|
.bootable(true)
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
.cpuHotplug(true)
|
.isCpuHotPlug(true)
|
||||||
.cpuHotunplug(true)
|
.isCpuHotUnPlug(true)
|
||||||
.discVirtioHotplug(true)
|
.isDiscVirtioHotPlug(true)
|
||||||
.discVirtioHotunplug(true)
|
.isDiscVirtioHotUnPlug(true)
|
||||||
.nicHotplug(true)
|
.isNicHotPlug(true)
|
||||||
.nicHotunplug(true)
|
.isNicHotUnPlug(true)
|
||||||
.ramHotplug(true)
|
.isRamHotPlug(true)
|
||||||
.ramHotunplug(true)
|
.isRamHotUnPlug(true)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
Snapshot snapshot = api.snapshotApi().getSnapshot(snapshotId);
|
Snapshot snapshot = api.snapshotApi().getSnapshot(snapshotId);
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest {
|
||||||
|
|
||||||
private void initializeWaitPredicate() {
|
private void initializeWaitPredicate() {
|
||||||
this.snapshotWaitingPredicate = Predicates2.retry(
|
this.snapshotWaitingPredicate = Predicates2.retry(
|
||||||
new ProvisioningStatusPollingPredicate(api, ProvisioningStatusAware.SNAPSHOT, ProvisioningState.AVAILABLE),
|
new ProvisioningStatusPollingPredicate(api, ProvisioningStatusAware.SNAPSHOT, ProvisioningState.AVAILABLE),
|
||||||
2l * 60l, 2l, TimeUnit.SECONDS);
|
2l * 60l, 2l, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,13 +47,13 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
||||||
SnapshotApi api = pbApi.snapshotApi();
|
SnapshotApi api = pbApi.snapshotApi();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<Snapshot> snapshots = api.getAllSnapshots();
|
List<Snapshot> snapshots = api.getAllSnapshots();
|
||||||
assertRequestHasCommonProperties(server.takeRequest(), "<ws:getAllSnapshots/>");
|
assertRequestHasCommonProperties(server.takeRequest(), "<ws:getAllSnapshots/>");
|
||||||
assertNotNull(snapshots);
|
assertNotNull(snapshots);
|
||||||
assertEquals(snapshots.size(), 2);
|
assertEquals(snapshots.size(), 2);
|
||||||
} finally {
|
} finally {
|
||||||
pbApi.close();
|
pbApi.close();
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,12 +66,12 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
||||||
SnapshotApi api = pbApi.snapshotApi();
|
SnapshotApi api = pbApi.snapshotApi();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<Snapshot> snapshots = api.getAllSnapshots();
|
List<Snapshot> snapshots = api.getAllSnapshots();
|
||||||
assertRequestHasCommonProperties(server.takeRequest());
|
assertRequestHasCommonProperties(server.takeRequest());
|
||||||
assertTrue(snapshots.isEmpty());
|
assertTrue(snapshots.isEmpty());
|
||||||
} finally {
|
} finally {
|
||||||
pbApi.close();
|
pbApi.close();
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,13 +88,13 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
||||||
String content = "<ws:getSnapshot><snapshotId>" + id + "</snapshotId></ws:getSnapshot>";
|
String content = "<ws:getSnapshot><snapshotId>" + id + "</snapshotId></ws:getSnapshot>";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Snapshot snapshot = api.getSnapshot(id);
|
Snapshot snapshot = api.getSnapshot(id);
|
||||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||||
assertNotNull(snapshot);
|
assertNotNull(snapshot);
|
||||||
assertEquals(snapshot.id(), id);
|
assertEquals(snapshot.id(), id);
|
||||||
} finally {
|
} finally {
|
||||||
pbApi.close();
|
pbApi.close();
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,12 +108,12 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
||||||
|
|
||||||
String id = "random-non-existing-id";
|
String id = "random-non-existing-id";
|
||||||
try {
|
try {
|
||||||
Snapshot snapshot = api.getSnapshot(id);
|
Snapshot snapshot = api.getSnapshot(id);
|
||||||
assertRequestHasCommonProperties(server.takeRequest());
|
assertRequestHasCommonProperties(server.takeRequest());
|
||||||
assertNull(snapshot);
|
assertNull(snapshot);
|
||||||
} finally {
|
} finally {
|
||||||
pbApi.close();
|
pbApi.close();
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,27 +128,27 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
||||||
String storageId = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
|
String storageId = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
|
||||||
|
|
||||||
String content = "<ws:createSnapshot>"
|
String content = "<ws:createSnapshot>"
|
||||||
+ "<request>"
|
+ "<request>"
|
||||||
+ "<storageId>" + storageId + "</storageId>"
|
+ "<storageId>" + storageId + "</storageId>"
|
||||||
+ "<description>description</description>"
|
+ "<description>description</description>"
|
||||||
+ "<snapshotName>snapshot-name</snapshotName>"
|
+ "<snapshotName>snapshot-name</snapshotName>"
|
||||||
+ "</request>"
|
+ "</request>"
|
||||||
+ "</ws:createSnapshot>";
|
+ "</ws:createSnapshot>";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Snapshot snapshot = api.createSnapshot(
|
Snapshot snapshot = api.createSnapshot(
|
||||||
Snapshot.Request.creatingBuilder()
|
Snapshot.Request.creatingBuilder()
|
||||||
.storageId(storageId)
|
.storageId(storageId)
|
||||||
.description("description")
|
.description("description")
|
||||||
.name("snapshot-name")
|
.name("snapshot-name")
|
||||||
.build());
|
.build());
|
||||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||||
assertNotNull(snapshot.id());
|
assertNotNull(snapshot.id());
|
||||||
assertEquals(snapshot.id(), "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
|
assertEquals(snapshot.id(), "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
pbApi.close();
|
pbApi.close();
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,35 +163,43 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
||||||
String snapshotId = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
|
String snapshotId = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
|
||||||
|
|
||||||
String content = "<ws:updateSnapshot>"
|
String content = "<ws:updateSnapshot>"
|
||||||
+ "<request>"
|
+ "<request>"
|
||||||
+ "<snapshotId>" + snapshotId + "</snapshotId>"
|
+ "<snapshotId>" + snapshotId + "</snapshotId>"
|
||||||
+ "<description>description</description>"
|
+ "<description>description</description>"
|
||||||
+ "<snapshotName>snapshot-name</snapshotName>"
|
+ "<snapshotName>snapshot-name</snapshotName>"
|
||||||
+ "<bootable>false</bootable>"
|
+ "<bootable>false</bootable>"
|
||||||
+ "<osType>LINUX</osType>"
|
+ "<osType>LINUX</osType>"
|
||||||
+ "<cpuHotPlug>false</cpuHotPlug>"
|
+ "<cpuHotPlug>false</cpuHotPlug>"
|
||||||
+ "<cpuHotUnPlug>false</cpuHotUnPlug>"
|
+ "<cpuHotUnPlug>false</cpuHotUnPlug>"
|
||||||
+ "<ramHotPlug>false</ramHotPlug>"
|
+ "<ramHotPlug>false</ramHotPlug>"
|
||||||
+ "<ramHotUnPlug>false</ramHotUnPlug>"
|
+ "<ramHotUnPlug>false</ramHotUnPlug>"
|
||||||
+ "<nicHotPlug>false</nicHotPlug>"
|
+ "<nicHotPlug>false</nicHotPlug>"
|
||||||
+ "<nicHotUnPlug>false</nicHotUnPlug>"
|
+ "<nicHotUnPlug>false</nicHotUnPlug>"
|
||||||
+ "<discVirtioHotPlug>false</discVirtioHotPlug>"
|
+ "<discVirtioHotPlug>false</discVirtioHotPlug>"
|
||||||
+ "<discVirtioHotUnPlug>false</discVirtioHotUnPlug>"
|
+ "<discVirtioHotUnPlug>false</discVirtioHotUnPlug>"
|
||||||
+ "</request>"
|
+ "</request>"
|
||||||
+ "</ws:updateSnapshot>";
|
+ "</ws:updateSnapshot>";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String requestId = api.updateSnapshot(Snapshot.Request.updatingBuilder()
|
String requestId = api.updateSnapshot(Snapshot.Request.updatingBuilder()
|
||||||
.snapshotId(snapshotId)
|
.snapshotId(snapshotId)
|
||||||
.name("snapshot-name")
|
.name("snapshot-name")
|
||||||
.description("description")
|
.description("description")
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
.build());
|
.isCpuHotPlug(false)
|
||||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
.isCpuHotUnPlug(false)
|
||||||
assertNotNull(requestId);
|
.isDiscVirtioHotPlug(false)
|
||||||
|
.isDiscVirtioHotUnPlug(false)
|
||||||
|
.isNicHotPlug(false)
|
||||||
|
.isNicHotUnPlug(false)
|
||||||
|
.isRamHotPlug(false)
|
||||||
|
.isRamHotUnPlug(false)
|
||||||
|
.build());
|
||||||
|
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||||
|
assertNotNull(requestId);
|
||||||
} finally {
|
} finally {
|
||||||
pbApi.close();
|
pbApi.close();
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,12 +215,12 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
||||||
String content = "<ws:deleteSnapshot><snapshotId>" + snapshotId + "</snapshotId></ws:deleteSnapshot>";
|
String content = "<ws:deleteSnapshot><snapshotId>" + snapshotId + "</snapshotId></ws:deleteSnapshot>";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean result = api.deleteSnapshot(snapshotId);
|
boolean result = api.deleteSnapshot(snapshotId);
|
||||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||||
assertTrue(result);
|
assertTrue(result);
|
||||||
} finally {
|
} finally {
|
||||||
pbApi.close();
|
pbApi.close();
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,12 +234,12 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
||||||
|
|
||||||
String id = "random-non-existing-id";
|
String id = "random-non-existing-id";
|
||||||
try {
|
try {
|
||||||
boolean result = api.deleteSnapshot(id);
|
boolean result = api.deleteSnapshot(id);
|
||||||
assertRequestHasCommonProperties(server.takeRequest());
|
assertRequestHasCommonProperties(server.takeRequest());
|
||||||
Assert.assertFalse(result);
|
Assert.assertFalse(result);
|
||||||
} finally {
|
} finally {
|
||||||
pbApi.close();
|
pbApi.close();
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,15 +256,15 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
||||||
|
|
||||||
String content = "<ws:rollbackSnapshot><request><snapshotId>" + snapshotId + "</snapshotId><storageId>" + storageId + "</storageId></request></ws:rollbackSnapshot>";
|
String content = "<ws:rollbackSnapshot><request><snapshotId>" + snapshotId + "</snapshotId><storageId>" + storageId + "</storageId></request></ws:rollbackSnapshot>";
|
||||||
try {
|
try {
|
||||||
String result = api.rollbackSnapshot(Snapshot.Request.rollbackBuilder()
|
String result = api.rollbackSnapshot(Snapshot.Request.rollbackBuilder()
|
||||||
.snapshotId(snapshotId)
|
.snapshotId(snapshotId)
|
||||||
.storageId(storageId)
|
.storageId(storageId)
|
||||||
.build());
|
.build());
|
||||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
} finally {
|
} finally {
|
||||||
pbApi.close();
|
pbApi.close();
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,7 @@ package org.jclouds.profitbricks.http.parser.datacenter;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodec;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.profitbricks.domain.AvailabilityZone;
|
import org.jclouds.profitbricks.domain.AvailabilityZone;
|
||||||
import org.jclouds.profitbricks.domain.DataCenter;
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
|
@ -44,8 +43,8 @@ public class DataCenterInfoResponseHandlerTest extends BaseResponseHandlerTest<D
|
||||||
return factory.create(injector.getInstance(DataCenterInfoResponseHandler.class));
|
return factory.create(injector.getInstance(DataCenterInfoResponseHandler.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DateCodecFactory createDateParser() {
|
protected DateService createDateParser() {
|
||||||
return injector.getInstance(DateCodecFactory.class);
|
return injector.getInstance(DateService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -55,7 +54,7 @@ public class DataCenterInfoResponseHandlerTest extends BaseResponseHandlerTest<D
|
||||||
DataCenter actual = parser.parse(payloadFromResource("/datacenter/datacenter.xml"));
|
DataCenter actual = parser.parse(payloadFromResource("/datacenter/datacenter.xml"));
|
||||||
assertNotNull(actual, "Parsed content returned null");
|
assertNotNull(actual, "Parsed content returned null");
|
||||||
|
|
||||||
DateCodec dateParser = createDateParser().iso8601();
|
DateService dateParser = createDateParser();
|
||||||
|
|
||||||
DataCenter expected = DataCenter.builder()
|
DataCenter expected = DataCenter.builder()
|
||||||
.id("12345678-abcd-efgh-ijkl-987654321000")
|
.id("12345678-abcd-efgh-ijkl-987654321000")
|
||||||
|
@ -65,6 +64,11 @@ public class DataCenterInfoResponseHandlerTest extends BaseResponseHandlerTest<D
|
||||||
.location(Location.US_LAS)
|
.location(Location.US_LAS)
|
||||||
.servers(ImmutableList.<Server>of(
|
.servers(ImmutableList.<Server>of(
|
||||||
Server.builder()
|
Server.builder()
|
||||||
|
.dataCenter(DataCenter.builder()
|
||||||
|
.id("12345678-abcd-efgh-ijkl-987654321000")
|
||||||
|
.version(10)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
.id("qqqqqqqq-wwww-eeee-rrrr-tttttttttttt")
|
.id("qqqqqqqq-wwww-eeee-rrrr-tttttttttttt")
|
||||||
.name("jnode1")
|
.name("jnode1")
|
||||||
.cores(4)
|
.cores(4)
|
||||||
|
@ -72,8 +76,8 @@ public class DataCenterInfoResponseHandlerTest extends BaseResponseHandlerTest<D
|
||||||
.hasInternetAccess(true)
|
.hasInternetAccess(true)
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.status(Server.Status.RUNNING)
|
.status(Server.Status.RUNNING)
|
||||||
.creationTime(dateParser.toDate("2014-12-04T07:09:23.138Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2014-12-12T03:08:35.629Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z"))
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
.availabilityZone(AvailabilityZone.AUTO)
|
.availabilityZone(AvailabilityZone.AUTO)
|
||||||
.isCpuHotPlug(true)
|
.isCpuHotPlug(true)
|
||||||
|
@ -125,8 +129,8 @@ public class DataCenterInfoResponseHandlerTest extends BaseResponseHandlerTest<D
|
||||||
.size(40)
|
.size(40)
|
||||||
.name("jnode1-disk1")
|
.name("jnode1-disk1")
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.creationTime(dateParser.toDate("2014-12-04T07:09:23.138Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2014-12-12T03:14:48.316Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:14:48.316Z"))
|
||||||
.serverIds(ImmutableList.of(
|
.serverIds(ImmutableList.of(
|
||||||
"qqqqqqqq-wwww-eeee-rrrr-tttttttttttt"
|
"qqqqqqqq-wwww-eeee-rrrr-tttttttttttt"
|
||||||
))
|
))
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class ImageListResponseHandlerTest extends BaseResponseHandlerTest<List<I
|
||||||
.name("Debian-jessie-prerelease-server-2015-01-01")
|
.name("Debian-jessie-prerelease-server-2015-01-01")
|
||||||
.size(2048f)
|
.size(2048f)
|
||||||
.type(Image.Type.HDD)
|
.type(Image.Type.HDD)
|
||||||
.location(Location.US_LAS_DEV)
|
.location(Location.US_LASDEV)
|
||||||
.isNicHotPlug(true)
|
.isNicHotPlug(true)
|
||||||
.isNicHotUnPlug(true)
|
.isNicHotUnPlug(true)
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
|
@ -110,7 +110,7 @@ public class ImageListResponseHandlerTest extends BaseResponseHandlerTest<List<I
|
||||||
.name("Fedora-19-server-2015-01-01")
|
.name("Fedora-19-server-2015-01-01")
|
||||||
.size(2048f)
|
.size(2048f)
|
||||||
.type(Image.Type.HDD)
|
.type(Image.Type.HDD)
|
||||||
.location(Location.US_LAS_DEV)
|
.location(Location.US_LASDEV)
|
||||||
.isNicHotPlug(true)
|
.isNicHotPlug(true)
|
||||||
.isNicHotUnPlug(true)
|
.isNicHotUnPlug(true)
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
|
@ -129,7 +129,7 @@ public class ImageListResponseHandlerTest extends BaseResponseHandlerTest<List<I
|
||||||
.name("Ubuntu-12.04-LTS-server-2015-01-01")
|
.name("Ubuntu-12.04-LTS-server-2015-01-01")
|
||||||
.size(2048f)
|
.size(2048f)
|
||||||
.type(Image.Type.HDD)
|
.type(Image.Type.HDD)
|
||||||
.location(Location.US_LAS_DEV)
|
.location(Location.US_LASDEV)
|
||||||
.isNicHotPlug(true)
|
.isNicHotPlug(true)
|
||||||
.isNicHotUnPlug(true)
|
.isNicHotUnPlug(true)
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
package org.jclouds.profitbricks.http.parser.loadbalancer;
|
package org.jclouds.profitbricks.http.parser.loadbalancer;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jclouds.date.DateCodec;
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.profitbricks.domain.Firewall;
|
import org.jclouds.profitbricks.domain.Firewall;
|
||||||
import org.jclouds.profitbricks.domain.LoadBalancer;
|
import org.jclouds.profitbricks.domain.LoadBalancer;
|
||||||
|
@ -27,8 +27,12 @@ import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm;
|
||||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
import org.jclouds.profitbricks.domain.Server;
|
import org.jclouds.profitbricks.domain.Server;
|
||||||
import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
|
import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@Test(groups = "unit", testName = "LoadBalancerListResponseHandlerTest")
|
@Test(groups = "unit", testName = "LoadBalancerListResponseHandlerTest")
|
||||||
|
@ -39,8 +43,8 @@ public class LoadBalancerListResponseHandlerTest extends BaseResponseHandlerTest
|
||||||
return factory.create(injector.getInstance(LoadBalancerListResponseHandler.class));
|
return factory.create(injector.getInstance(LoadBalancerListResponseHandler.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DateCodecFactory createDateParser() {
|
protected DateService createDateParser() {
|
||||||
return injector.getInstance(DateCodecFactory.class);
|
return injector.getInstance(DateService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -50,23 +54,68 @@ public class LoadBalancerListResponseHandlerTest extends BaseResponseHandlerTest
|
||||||
List<LoadBalancer> actual = parser.parse(payloadFromResource("/loadbalancer/loadbalancers.xml"));
|
List<LoadBalancer> actual = parser.parse(payloadFromResource("/loadbalancer/loadbalancers.xml"));
|
||||||
assertNotNull(actual, "Parsed content returned null");
|
assertNotNull(actual, "Parsed content returned null");
|
||||||
|
|
||||||
DateCodec dateParser = createDateParser().iso8601();
|
DateService dateParser = createDateParser();
|
||||||
|
|
||||||
List<LoadBalancer> expected = ImmutableList.<LoadBalancer>of(LoadBalancer.builder().id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee").loadBalancerAlgorithm(Algorithm.ROUND_ROBIN).name("load-1234567890-name")
|
List<LoadBalancer> expected = ImmutableList.<LoadBalancer>of(
|
||||||
.dataCenterId("datacenter-id").dataCenterVersion("datacenter-version").internetAccess(true).ip("192.168.0.1").lanId("lan-id").state(ProvisioningState.AVAILABLE).creationTime(dateParser.toDate("2014-12-04T07:09:23.138Z")).lastModificationTime(dateParser.toDate("2014-12-04T07:09:23.138Z"))
|
LoadBalancer.builder()
|
||||||
|
.id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
||||||
|
.algorithm(Algorithm.ROUND_ROBIN)
|
||||||
|
.name("load-1234567890-name")
|
||||||
|
.dataCenter(DataCenter.builder()
|
||||||
|
.id("datacenter-id")
|
||||||
|
.version(4)
|
||||||
|
.build())
|
||||||
|
.internetAccess(true)
|
||||||
|
.ip("192.168.0.1")
|
||||||
|
.lanId("lan-id")
|
||||||
|
.state(ProvisioningState.AVAILABLE)
|
||||||
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||||
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||||
.firewalls(ImmutableList.<Firewall>of(
|
.firewalls(ImmutableList.<Firewall>of(
|
||||||
Firewall.builder().id("firewall-id").nicId("nic-id").active(false).state(ProvisioningState.AVAILABLE).build()
|
Firewall.builder()
|
||||||
|
.id("firewall-id")
|
||||||
|
.nicId("nic-id")
|
||||||
|
.active(false)
|
||||||
|
.state(ProvisioningState.AVAILABLE)
|
||||||
|
.build()
|
||||||
))
|
))
|
||||||
.balancedServers(ImmutableList.<Server>of(
|
.balancedServers(ImmutableList.<Server>of(
|
||||||
Server.builder().activate(true).balancedNicId("balanced-nic-id").id("server-id").name("server-name").build()
|
Server.builder()
|
||||||
|
.loadBalanced(true)
|
||||||
|
.balancedNicId("balanced-nic-id")
|
||||||
|
.id("server-id")
|
||||||
|
.name("server-name")
|
||||||
|
.build()
|
||||||
)).build(),
|
)).build(),
|
||||||
LoadBalancer.builder().id("qqqqqqqq-wwww-rrrr-tttt-yyyyyyyyyyyy").loadBalancerAlgorithm(Algorithm.ROUND_ROBIN).name("load-balancer-name")
|
LoadBalancer.builder()
|
||||||
.dataCenterId("datacenter-id").dataCenterVersion("datacenter-version").internetAccess(false).ip("192.168.0.1").lanId("lan-id").state(ProvisioningState.AVAILABLE).creationTime(dateParser.toDate("2014-12-04T07:09:23.138Z")).lastModificationTime(dateParser.toDate("2014-12-04T07:09:23.138Z"))
|
.id("qqqqqqqq-wwww-rrrr-tttt-yyyyyyyyyyyy")
|
||||||
|
.algorithm(Algorithm.ROUND_ROBIN)
|
||||||
|
.name("load-balancer-name")
|
||||||
|
.dataCenter(DataCenter.builder()
|
||||||
|
.id("datacenter-id")
|
||||||
|
.version(4)
|
||||||
|
.build())
|
||||||
|
.internetAccess(false)
|
||||||
|
.ip("192.168.0.1")
|
||||||
|
.lanId("lan-id")
|
||||||
|
.state(ProvisioningState.AVAILABLE)
|
||||||
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||||
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||||
.firewalls(ImmutableList.<Firewall>of(
|
.firewalls(ImmutableList.<Firewall>of(
|
||||||
Firewall.builder().id("firewall-id").nicId("nic-id").active(false).state(ProvisioningState.AVAILABLE).build()
|
Firewall.builder()
|
||||||
|
.id("firewall-id")
|
||||||
|
.nicId("nic-id")
|
||||||
|
.active(false)
|
||||||
|
.state(ProvisioningState.AVAILABLE)
|
||||||
|
.build()
|
||||||
))
|
))
|
||||||
.balancedServers(ImmutableList.<Server>of(
|
.balancedServers(ImmutableList.<Server>of(
|
||||||
Server.builder().activate(false).balancedNicId("balanced-nic-id").id("server-id").name("server-name").build()
|
Server.builder()
|
||||||
|
.loadBalanced(false)
|
||||||
|
.balancedNicId("balanced-nic-id")
|
||||||
|
.id("server-id")
|
||||||
|
.name("server-name")
|
||||||
|
.build()
|
||||||
))
|
))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
package org.jclouds.profitbricks.http.parser.loadbalancer;
|
package org.jclouds.profitbricks.http.parser.loadbalancer;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jclouds.date.DateCodec;
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.profitbricks.domain.Firewall;
|
import org.jclouds.profitbricks.domain.Firewall;
|
||||||
import org.jclouds.profitbricks.domain.LoadBalancer;
|
import org.jclouds.profitbricks.domain.LoadBalancer;
|
||||||
|
@ -28,8 +28,12 @@ import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
import org.jclouds.profitbricks.domain.Server;
|
import org.jclouds.profitbricks.domain.Server;
|
||||||
import org.jclouds.profitbricks.domain.Storage;
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
|
import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@Test(groups = "unit", testName = "LoadBalancerResponseHandlerTest")
|
@Test(groups = "unit", testName = "LoadBalancerResponseHandlerTest")
|
||||||
|
@ -40,8 +44,8 @@ public class LoadBalancerResponseHandlerTest extends BaseResponseHandlerTest<Loa
|
||||||
return factory.create(injector.getInstance(LoadBalancerResponseHandler.class));
|
return factory.create(injector.getInstance(LoadBalancerResponseHandler.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DateCodecFactory createDateParser() {
|
protected DateService createDateParser() {
|
||||||
return injector.getInstance(DateCodecFactory.class);
|
return injector.getInstance(DateService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -51,13 +55,13 @@ public class LoadBalancerResponseHandlerTest extends BaseResponseHandlerTest<Loa
|
||||||
LoadBalancer actual = parser.parse(payloadFromResource("/loadbalancer/loadbalancer.xml"));
|
LoadBalancer actual = parser.parse(payloadFromResource("/loadbalancer/loadbalancer.xml"));
|
||||||
assertNotNull(actual, "Parsed content returned null");
|
assertNotNull(actual, "Parsed content returned null");
|
||||||
|
|
||||||
DateCodec dateParser = createDateParser().iso8601();
|
DateService dateParser = createDateParser();
|
||||||
|
|
||||||
List<Storage> emptyStorages = Lists.newArrayList();
|
List<Storage> emptyStorages = Lists.newArrayList();
|
||||||
|
|
||||||
List<Server> balancedServers = Lists.newArrayList();
|
List<Server> balancedServers = Lists.newArrayList();
|
||||||
balancedServers.add(Server.builder()
|
balancedServers.add(Server.builder()
|
||||||
.activate(true)
|
.loadBalanced(true)
|
||||||
.balancedNicId("balanced-nic-id")
|
.balancedNicId("balanced-nic-id")
|
||||||
.id("server-id")
|
.id("server-id")
|
||||||
.name("server-name")
|
.name("server-name")
|
||||||
|
@ -73,16 +77,18 @@ public class LoadBalancerResponseHandlerTest extends BaseResponseHandlerTest<Loa
|
||||||
|
|
||||||
LoadBalancer expected = LoadBalancer.builder()
|
LoadBalancer expected = LoadBalancer.builder()
|
||||||
.id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
.id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
||||||
.loadBalancerAlgorithm(Algorithm.ROUND_ROBIN)
|
.algorithm(Algorithm.ROUND_ROBIN)
|
||||||
.name("load-balancer-name")
|
.name("load-balancer-name")
|
||||||
.dataCenterId("datacenter-id")
|
.dataCenter(DataCenter.builder()
|
||||||
.dataCenterVersion("datacenter-version")
|
.id("datacenter-id")
|
||||||
|
.version(4)
|
||||||
|
.build())
|
||||||
.internetAccess(true)
|
.internetAccess(true)
|
||||||
.ip("192.168.0.1")
|
.ip("192.168.0.1")
|
||||||
.lanId("lan-id")
|
.lanId("lan-id")
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.creationTime(dateParser.toDate("2014-12-12T03:08:35.629Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2014-12-12T03:08:35.629Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z"))
|
||||||
.firewalls(firewalls)
|
.firewalls(firewalls)
|
||||||
.balancedServers(balancedServers)
|
.balancedServers(balancedServers)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -19,10 +19,10 @@ package org.jclouds.profitbricks.http.parser.server;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodec;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.profitbricks.domain.AvailabilityZone;
|
import org.jclouds.profitbricks.domain.AvailabilityZone;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
import org.jclouds.profitbricks.domain.Firewall;
|
import org.jclouds.profitbricks.domain.Firewall;
|
||||||
import org.jclouds.profitbricks.domain.Nic;
|
import org.jclouds.profitbricks.domain.Nic;
|
||||||
import org.jclouds.profitbricks.domain.OsType;
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
|
@ -43,8 +43,8 @@ public class ServerInfoResponseHandlerTest extends BaseResponseHandlerTest<Serve
|
||||||
return factory.create(injector.getInstance(ServerInfoResponseHandler.class));
|
return factory.create(injector.getInstance(ServerInfoResponseHandler.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DateCodecFactory createDateParser() {
|
protected DateService createDateParser() {
|
||||||
return injector.getInstance(DateCodecFactory.class);
|
return injector.getInstance(DateService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -54,18 +54,22 @@ public class ServerInfoResponseHandlerTest extends BaseResponseHandlerTest<Serve
|
||||||
Server actual = parser.parse(payloadFromResource("/server/server.xml"));
|
Server actual = parser.parse(payloadFromResource("/server/server.xml"));
|
||||||
assertNotNull(actual, "Parsed content returned null");
|
assertNotNull(actual, "Parsed content returned null");
|
||||||
|
|
||||||
DateCodec dateParser = createDateParser().iso8601();
|
DateService dateParser = createDateParser();
|
||||||
|
|
||||||
Server expected = Server.builder()
|
Server expected = Server.builder()
|
||||||
.id("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
|
.id("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
|
||||||
|
.dataCenter(DataCenter.builder()
|
||||||
|
.id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
||||||
|
.version(10)
|
||||||
|
.build())
|
||||||
.name("facebook-node")
|
.name("facebook-node")
|
||||||
.cores(4)
|
.cores(4)
|
||||||
.ram(4096)
|
.ram(4096)
|
||||||
.hasInternetAccess(true)
|
.hasInternetAccess(true)
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.status(Server.Status.RUNNING)
|
.status(Server.Status.RUNNING)
|
||||||
.creationTime(dateParser.toDate("2014-12-04T07:09:23.138Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2014-12-12T03:08:35.629Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z"))
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
.availabilityZone(AvailabilityZone.AUTO)
|
.availabilityZone(AvailabilityZone.AUTO)
|
||||||
.isCpuHotPlug(true)
|
.isCpuHotPlug(true)
|
||||||
|
@ -74,7 +78,7 @@ public class ServerInfoResponseHandlerTest extends BaseResponseHandlerTest<Serve
|
||||||
.isNicHotUnPlug(true)
|
.isNicHotUnPlug(true)
|
||||||
.isDiscVirtioHotPlug(true)
|
.isDiscVirtioHotPlug(true)
|
||||||
.isDiscVirtioHotUnPlug(true)
|
.isDiscVirtioHotUnPlug(true)
|
||||||
.activate(true)
|
.loadBalanced(true)
|
||||||
.balancedNicId("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
.balancedNicId("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||||
.storages(ImmutableList.<Storage>of(
|
.storages(ImmutableList.<Storage>of(
|
||||||
Storage.builder()
|
Storage.builder()
|
||||||
|
|
|
@ -20,8 +20,6 @@ import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodec;
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.profitbricks.domain.AvailabilityZone;
|
import org.jclouds.profitbricks.domain.AvailabilityZone;
|
||||||
import org.jclouds.profitbricks.domain.OsType;
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
|
@ -32,6 +30,8 @@ import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.profitbricks.domain.DataCenter;
|
||||||
import org.jclouds.profitbricks.domain.Firewall;
|
import org.jclouds.profitbricks.domain.Firewall;
|
||||||
import org.jclouds.profitbricks.domain.Nic;
|
import org.jclouds.profitbricks.domain.Nic;
|
||||||
import org.jclouds.profitbricks.domain.Storage;
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
|
@ -45,8 +45,8 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
|
||||||
return factory.create(injector.getInstance(ServerListResponseHandler.class));
|
return factory.create(injector.getInstance(ServerListResponseHandler.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DateCodecFactory createDateParser() {
|
protected DateService createDateParser() {
|
||||||
return injector.getInstance(DateCodecFactory.class);
|
return injector.getInstance(DateService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -56,10 +56,15 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
|
||||||
List<Server> actual = parser.parse(payloadFromResource("/server/servers.xml"));
|
List<Server> actual = parser.parse(payloadFromResource("/server/servers.xml"));
|
||||||
assertNotNull(actual, "Parsed content returned null");
|
assertNotNull(actual, "Parsed content returned null");
|
||||||
|
|
||||||
DateCodec dateParser = createDateParser().iso8601();
|
DateService dateParser = createDateParser();
|
||||||
|
|
||||||
List<Server> expected = ImmutableList.<Server>of(
|
List<Server> expected = ImmutableList.<Server>of(
|
||||||
Server.builder()
|
Server.builder()
|
||||||
|
.dataCenter(DataCenter.builder()
|
||||||
|
.id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
||||||
|
.version(10)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
.id("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
|
.id("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
|
||||||
.name("facebook-node")
|
.name("facebook-node")
|
||||||
.cores(4)
|
.cores(4)
|
||||||
|
@ -67,8 +72,8 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
|
||||||
.hasInternetAccess(true)
|
.hasInternetAccess(true)
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.status(Server.Status.RUNNING)
|
.status(Server.Status.RUNNING)
|
||||||
.creationTime(dateParser.toDate("2014-12-04T07:09:23.138Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2014-12-12T03:08:35.629Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z"))
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
.availabilityZone(AvailabilityZone.AUTO)
|
.availabilityZone(AvailabilityZone.AUTO)
|
||||||
.isCpuHotPlug(true)
|
.isCpuHotPlug(true)
|
||||||
|
@ -77,7 +82,7 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
|
||||||
.isNicHotUnPlug(true)
|
.isNicHotUnPlug(true)
|
||||||
.isDiscVirtioHotPlug(true)
|
.isDiscVirtioHotPlug(true)
|
||||||
.isDiscVirtioHotUnPlug(true)
|
.isDiscVirtioHotUnPlug(true)
|
||||||
.activate(true)
|
.loadBalanced(true)
|
||||||
.balancedNicId("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
.balancedNicId("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||||
.storages(ImmutableList.<Storage>of(
|
.storages(ImmutableList.<Storage>of(
|
||||||
Storage.builder()
|
Storage.builder()
|
||||||
|
@ -113,6 +118,11 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
|
||||||
)
|
)
|
||||||
.build(),
|
.build(),
|
||||||
Server.builder()
|
Server.builder()
|
||||||
|
.dataCenter(DataCenter.builder()
|
||||||
|
.id("qqqqqqqq-wwww-rrrr-tttt-yyyyyyyyyyyy")
|
||||||
|
.version(238)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
.id("asdfghjk-asdf-asdf-asdf-asdfghjklkjl")
|
.id("asdfghjk-asdf-asdf-asdf-asdfghjklkjl")
|
||||||
.name("google-node")
|
.name("google-node")
|
||||||
.cores(1)
|
.cores(1)
|
||||||
|
@ -120,8 +130,8 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
|
||||||
.hasInternetAccess(false)
|
.hasInternetAccess(false)
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.status(Server.Status.RUNNING)
|
.status(Server.Status.RUNNING)
|
||||||
.creationTime(dateParser.toDate("2014-11-12T07:01:00.441Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-11-12T07:01:00.441Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2014-11-12T07:01:00.441Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-11-12T07:01:00.441Z"))
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
.availabilityZone(AvailabilityZone.AUTO)
|
.availabilityZone(AvailabilityZone.AUTO)
|
||||||
.isCpuHotPlug(true)
|
.isCpuHotPlug(true)
|
||||||
|
@ -130,7 +140,7 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
|
||||||
.isNicHotUnPlug(true)
|
.isNicHotUnPlug(true)
|
||||||
.isDiscVirtioHotPlug(true)
|
.isDiscVirtioHotPlug(true)
|
||||||
.isDiscVirtioHotUnPlug(true)
|
.isDiscVirtioHotUnPlug(true)
|
||||||
.activate(true)
|
.loadBalanced(true)
|
||||||
.balancedNicId("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
.balancedNicId("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||||
.storages(ImmutableList.<Storage>of(
|
.storages(ImmutableList.<Storage>of(
|
||||||
Storage.builder()
|
Storage.builder()
|
||||||
|
|
|
@ -17,17 +17,20 @@
|
||||||
package org.jclouds.profitbricks.http.parser.snapshot;
|
package org.jclouds.profitbricks.http.parser.snapshot;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jclouds.date.DateCodec;
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.profitbricks.domain.Location;
|
import org.jclouds.profitbricks.domain.Location;
|
||||||
import org.jclouds.profitbricks.domain.OsType;
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
import org.jclouds.profitbricks.domain.Snapshot;
|
import org.jclouds.profitbricks.domain.Snapshot;
|
||||||
import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
|
import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@Test(groups = "unit", testName = "SnapshotListResponseHandlerTest")
|
@Test(groups = "unit", testName = "SnapshotListResponseHandlerTest")
|
||||||
|
@ -38,8 +41,8 @@ public class SnapshotListResponseHandlerTest extends BaseResponseHandlerTest<Lis
|
||||||
return factory.create(injector.getInstance(SnapshotListResponseHandler.class));
|
return factory.create(injector.getInstance(SnapshotListResponseHandler.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DateCodecFactory createDateParser() {
|
protected DateService createDateParser() {
|
||||||
return injector.getInstance(DateCodecFactory.class);
|
return injector.getInstance(DateService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -49,51 +52,51 @@ public class SnapshotListResponseHandlerTest extends BaseResponseHandlerTest<Lis
|
||||||
List<Snapshot> actual = parser.parse(payloadFromResource("/snapshot/snapshots.xml"));
|
List<Snapshot> actual = parser.parse(payloadFromResource("/snapshot/snapshots.xml"));
|
||||||
assertNotNull(actual);
|
assertNotNull(actual);
|
||||||
|
|
||||||
DateCodec dateParser = createDateParser().iso8601();
|
DateService dateParser = createDateParser();
|
||||||
|
|
||||||
List<Snapshot> expected = Lists.newArrayList();
|
List<Snapshot> expected = Lists.newArrayList();
|
||||||
|
|
||||||
expected.add(Snapshot.builder()
|
expected.add(Snapshot.builder()
|
||||||
.id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
.id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
||||||
.description("description")
|
.description("description")
|
||||||
.size(1024)
|
.size(1024)
|
||||||
.name("snapshot01")
|
.name("snapshot01")
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.bootable(true)
|
.isBootable(true)
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
.cpuHotPlug(true)
|
.isCpuHotPlug(true)
|
||||||
.cpuHotUnPlug(true)
|
.isCpuHotUnPlug(true)
|
||||||
.discVirtioHotPlug(true)
|
.isDiscVirtioHotPlug(true)
|
||||||
.discVirtioHotUnPlug(true)
|
.isDiscVirtioHotUnPlug(true)
|
||||||
.ramHotPlug(true)
|
.isRamHotPlug(true)
|
||||||
.ramHotUnPlug(true)
|
.isRamHotUnPlug(true)
|
||||||
.nicHotPlug(true)
|
.isNicHotPlug(true)
|
||||||
.nicHotUnPlug(true)
|
.isNicHotUnPlug(true)
|
||||||
.location(Location.US_LAS)
|
.location(Location.US_LAS)
|
||||||
.creationTime(dateParser.toDate("2015-01-26T07:09:23.138Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2015-01-26T07:09:23.138Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2015-01-26T07:09:23.138Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2015-01-26T07:09:23.138Z"))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
expected.add(Snapshot.builder()
|
expected.add(Snapshot.builder()
|
||||||
.id("qqqqqqqq-wwww-rrrr-tttt-yyyyyyyyyyyy")
|
.id("qqqqqqqq-wwww-rrrr-tttt-yyyyyyyyyyyy")
|
||||||
.description("description")
|
.description("description")
|
||||||
.size(1024)
|
.size(1024)
|
||||||
.name("snapshot02")
|
.name("snapshot02")
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.bootable(true)
|
.isBootable(true)
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
.cpuHotPlug(true)
|
.isCpuHotPlug(true)
|
||||||
.cpuHotUnPlug(true)
|
.isCpuHotUnPlug(true)
|
||||||
.discVirtioHotPlug(true)
|
.isDiscVirtioHotPlug(true)
|
||||||
.discVirtioHotUnPlug(true)
|
.isDiscVirtioHotUnPlug(true)
|
||||||
.ramHotPlug(true)
|
.isRamHotPlug(true)
|
||||||
.ramHotUnPlug(true)
|
.isRamHotUnPlug(true)
|
||||||
.nicHotPlug(true)
|
.isNicHotPlug(true)
|
||||||
.nicHotUnPlug(true)
|
.isNicHotUnPlug(true)
|
||||||
.location(Location.US_LAS)
|
.location(Location.US_LAS)
|
||||||
.creationTime(dateParser.toDate("2015-01-26T07:09:23.138Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2015-01-26T07:09:23.138Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2015-01-26T07:09:23.138Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2015-01-26T07:09:23.138Z"))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,17 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.http.parser.snapshot;
|
package org.jclouds.profitbricks.http.parser.snapshot;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodec;
|
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.profitbricks.domain.Location;
|
import org.jclouds.profitbricks.domain.Location;
|
||||||
import org.jclouds.profitbricks.domain.OsType;
|
import org.jclouds.profitbricks.domain.OsType;
|
||||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
import org.jclouds.profitbricks.domain.Snapshot;
|
import org.jclouds.profitbricks.domain.Snapshot;
|
||||||
import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
|
import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@Test(groups = "unit", testName = "ServerResponseHandlerTest")
|
@Test(groups = "unit", testName = "ServerResponseHandlerTest")
|
||||||
|
@ -36,8 +37,8 @@ public class SnapshotResponseHandlerTest extends BaseResponseHandlerTest<Snapsho
|
||||||
return factory.create(injector.getInstance(SnapshotResponseHandler.class));
|
return factory.create(injector.getInstance(SnapshotResponseHandler.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DateCodecFactory createDateParser() {
|
protected DateService createDateParser() {
|
||||||
return injector.getInstance(DateCodecFactory.class);
|
return injector.getInstance(DateService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -47,28 +48,28 @@ public class SnapshotResponseHandlerTest extends BaseResponseHandlerTest<Snapsho
|
||||||
Snapshot actual = parser.parse(payloadFromResource("/snapshot/snapshot.xml"));
|
Snapshot actual = parser.parse(payloadFromResource("/snapshot/snapshot.xml"));
|
||||||
assertNotNull(actual, "Parsed content returned null");
|
assertNotNull(actual, "Parsed content returned null");
|
||||||
|
|
||||||
DateCodec dateParser = createDateParser().iso8601();
|
DateService dateParser = createDateParser();
|
||||||
|
|
||||||
Snapshot expected = Snapshot.builder()
|
Snapshot expected = Snapshot.builder()
|
||||||
.id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
.id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||||
.description("description")
|
.description("description")
|
||||||
.size(1024)
|
.size(1024)
|
||||||
.name("snapshot01")
|
.name("snapshot01")
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.bootable(true)
|
.isBootable(true)
|
||||||
.osType(OsType.LINUX)
|
.osType(OsType.LINUX)
|
||||||
.cpuHotPlug(true)
|
.isCpuHotPlug(true)
|
||||||
.cpuHotUnPlug(true)
|
.isCpuHotUnPlug(true)
|
||||||
.discVirtioHotPlug(true)
|
.isDiscVirtioHotPlug(true)
|
||||||
.discVirtioHotUnPlug(true)
|
.isDiscVirtioHotUnPlug(true)
|
||||||
.ramHotPlug(true)
|
.isRamHotPlug(true)
|
||||||
.ramHotUnPlug(true)
|
.isRamHotUnPlug(true)
|
||||||
.nicHotPlug(true)
|
.isNicHotPlug(true)
|
||||||
.nicHotUnPlug(true)
|
.isNicHotUnPlug(true)
|
||||||
.location(Location.US_LAS)
|
.location(Location.US_LAS)
|
||||||
.creationTime(dateParser.toDate("2015-01-26T07:09:23.138Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2015-01-26T07:09:23.138Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2015-01-26T07:09:23.138Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2015-01-26T07:09:23.138Z"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,7 @@ package org.jclouds.profitbricks.http.parser.storage;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodec;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
import org.jclouds.profitbricks.domain.Storage;
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
|
@ -37,8 +36,8 @@ public class StorageInfoResponseHandlerTest extends BaseResponseHandlerTest<Stor
|
||||||
return factory.create(injector.getInstance(StorageInfoResponseHandler.class));
|
return factory.create(injector.getInstance(StorageInfoResponseHandler.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DateCodecFactory createDateParser() {
|
protected DateService createDateParser() {
|
||||||
return injector.getInstance(DateCodecFactory.class);
|
return injector.getInstance(DateService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -48,7 +47,7 @@ public class StorageInfoResponseHandlerTest extends BaseResponseHandlerTest<Stor
|
||||||
Storage actual = parser.parse(payloadFromResource("/storage/storage.xml"));
|
Storage actual = parser.parse(payloadFromResource("/storage/storage.xml"));
|
||||||
assertNotNull(actual, "Parsed content returned null");
|
assertNotNull(actual, "Parsed content returned null");
|
||||||
|
|
||||||
DateCodec dateParser = createDateParser().iso8601();
|
DateService dateParser = createDateParser();
|
||||||
|
|
||||||
Storage expected = Storage.builder()
|
Storage expected = Storage.builder()
|
||||||
.id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
.id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||||
|
@ -56,8 +55,8 @@ public class StorageInfoResponseHandlerTest extends BaseResponseHandlerTest<Stor
|
||||||
.name("hdd-1")
|
.name("hdd-1")
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.serverIds(ImmutableList.<String>of("qwertyui-qwer-qwer-qwer-qwertyyuiiop"))
|
.serverIds(ImmutableList.<String>of("qwertyui-qwer-qwer-qwer-qwertyyuiiop"))
|
||||||
.creationTime(dateParser.toDate("2014-12-04T07:09:23.138Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2014-12-12T03:14:48.316Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:14:48.316Z"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
|
|
|
@ -23,8 +23,7 @@ import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.date.DateCodec;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.date.DateCodecFactory;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||||
import org.jclouds.profitbricks.domain.Storage;
|
import org.jclouds.profitbricks.domain.Storage;
|
||||||
|
@ -40,8 +39,8 @@ public class StorageListResponseHandlerTest extends BaseResponseHandlerTest<List
|
||||||
return factory.create(injector.getInstance(StorageListResponseHandler.class));
|
return factory.create(injector.getInstance(StorageListResponseHandler.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DateCodecFactory createDateParser() {
|
protected DateService createDateParser() {
|
||||||
return injector.getInstance(DateCodecFactory.class);
|
return injector.getInstance(DateService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -51,7 +50,7 @@ public class StorageListResponseHandlerTest extends BaseResponseHandlerTest<List
|
||||||
List<Storage> actual = parser.parse(payloadFromResource("/storage/storages.xml"));
|
List<Storage> actual = parser.parse(payloadFromResource("/storage/storages.xml"));
|
||||||
assertNotNull(actual, "Parsed content returned null");
|
assertNotNull(actual, "Parsed content returned null");
|
||||||
|
|
||||||
DateCodec dateParser = createDateParser().iso8601();
|
DateService dateParser = createDateParser();
|
||||||
|
|
||||||
List<Storage> expected = ImmutableList.<Storage>of(
|
List<Storage> expected = ImmutableList.<Storage>of(
|
||||||
Storage.builder()
|
Storage.builder()
|
||||||
|
@ -60,8 +59,8 @@ public class StorageListResponseHandlerTest extends BaseResponseHandlerTest<List
|
||||||
.name("hdd-1")
|
.name("hdd-1")
|
||||||
.state(ProvisioningState.AVAILABLE)
|
.state(ProvisioningState.AVAILABLE)
|
||||||
.serverIds(ImmutableList.<String>of("qwertyui-qwer-qwer-qwer-qwertyyuiiop"))
|
.serverIds(ImmutableList.<String>of("qwertyui-qwer-qwer-qwer-qwertyyuiiop"))
|
||||||
.creationTime(dateParser.toDate("2014-12-04T07:09:23.138Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2014-12-12T03:14:48.316Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:14:48.316Z"))
|
||||||
.build(),
|
.build(),
|
||||||
Storage.builder()
|
Storage.builder()
|
||||||
.id("asfasfle-f23n-cu89-klfr-njkdsvwllkfa")
|
.id("asfasfle-f23n-cu89-klfr-njkdsvwllkfa")
|
||||||
|
@ -69,8 +68,8 @@ public class StorageListResponseHandlerTest extends BaseResponseHandlerTest<List
|
||||||
.name("hdd-2")
|
.name("hdd-2")
|
||||||
.state(ProvisioningState.INPROCESS)
|
.state(ProvisioningState.INPROCESS)
|
||||||
.serverIds(ImmutableList.<String>of("asdfghjk-asdf-asdf-asdf-asdfghjklkjl"))
|
.serverIds(ImmutableList.<String>of("asdfghjk-asdf-asdf-asdf-asdfghjklkjl"))
|
||||||
.creationTime(dateParser.toDate("2014-11-04T07:09:23.138Z"))
|
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-11-04T07:09:23.138Z"))
|
||||||
.lastModificationTime(dateParser.toDate("2014-11-12T03:14:48.316Z"))
|
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-11-12T03:14:48.316Z"))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* 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.profitbricks.util;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import java.util.List;
|
||||||
|
import static org.jclouds.profitbricks.util.Passwords.isValidPassword;
|
||||||
|
import static org.testng.Assert.assertFalse;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@Test(groups = "unit", testName = "PasswordsTest")
|
||||||
|
public class PasswordsTest {
|
||||||
|
|
||||||
|
private final List<String> validPasswords = ImmutableList.of(
|
||||||
|
"fKVasTnNm", "84625894", "QQQQQQQQ", "qqqqqqqq", "asdfghjk"
|
||||||
|
);
|
||||||
|
private final List<String> invalidPasswords = ImmutableList.of(
|
||||||
|
"", "apachejclouds", "s0merand0mpassw0rd"
|
||||||
|
);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPasswordValidation() {
|
||||||
|
for (String pwd : validPasswords)
|
||||||
|
assertTrue(isValidPassword(pwd), "Should've been valid: " + pwd);
|
||||||
|
|
||||||
|
for (String pwd : invalidPasswords)
|
||||||
|
assertFalse(isValidPassword(pwd), "Should've been invalid: " + pwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGeneratorGeneratesValidPassword() {
|
||||||
|
final int times = 50;
|
||||||
|
for (int i = 0; i < times; i++) {
|
||||||
|
String pwd = Passwords.generate();
|
||||||
|
assertTrue(isValidPassword(pwd), "Failed with: " + pwd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:deleteDataCenterResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:deleteDataCenterResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>11411363</requestId>
|
<requestId>11411363</requestId>
|
||||||
</return>
|
</return>
|
||||||
</ns2:deleteDataCenterResponse>
|
</ns2:deleteDataCenterResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,17 +1,17 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
|
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
|
||||||
<faultcode>S:Server</faultcode>
|
<faultcode>S:Server</faultcode>
|
||||||
<faultstring>The requested resource could not be found. Please refer to Request Id : 11122416. [VDC-6-404] The requested data center does not exist or already deleted by the users. ResourceId random-non-existing-id</faultstring>
|
<faultstring>The requested resource could not be found. Please refer to Request Id : 11122416. [VDC-6-404] The requested data center does not exist or already deleted by the users. ResourceId random-non-existing-id</faultstring>
|
||||||
<detail>
|
<detail>
|
||||||
<ns2:ProfitbricksServiceFault xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:ProfitbricksServiceFault xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<faultCode>RESOURCE_NOT_FOUND</faultCode>
|
<faultCode>RESOURCE_NOT_FOUND</faultCode>
|
||||||
<httpCode>404</httpCode>
|
<httpCode>404</httpCode>
|
||||||
<message>The requested resource could not be found. Please refer to Request Id : 11122416. [VDC-6-404] The requested data center does not exist or already deleted by the users. ResourceId random-non-existing-id</message>
|
<message>The requested resource could not be found. Please refer to Request Id : 11122416. [VDC-6-404] The requested data center does not exist or already deleted by the users. ResourceId random-non-existing-id</message>
|
||||||
<requestId>11122416</requestId>
|
<requestId>11122416</requestId>
|
||||||
</ns2:ProfitbricksServiceFault>
|
</ns2:ProfitbricksServiceFault>
|
||||||
</detail>
|
</detail>
|
||||||
</S:Fault>
|
</S:Fault>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:getDataCenterStateResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:getDataCenterStateResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>INPROCESS</return>
|
<return>INPROCESS</return>
|
||||||
</ns2:getDataCenterStateResponse>
|
</ns2:getDataCenterStateResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:getDataCenterStateResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:getDataCenterStateResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>AVAILABLE</return>
|
<return>AVAILABLE</return>
|
||||||
</ns2:getDataCenterStateResponse>
|
</ns2:getDataCenterStateResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:addRomDriveToServerResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:addRomDriveToServerResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id</requestId>
|
<requestId>request-id</requestId>
|
||||||
<dataCenterId>datacenter-id</dataCenterId>
|
<dataCenterId>datacenter-id</dataCenterId>
|
||||||
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
||||||
</return>
|
</return>
|
||||||
</ns2:addRomDriveToServerResponse>
|
</ns2:addRomDriveToServerResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:removeRomDriveFromServerResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:removeRomDriveFromServerResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id</requestId>
|
<requestId>request-id</requestId>
|
||||||
<dataCenterId>datacenter-id</dataCenterId>
|
<dataCenterId>datacenter-id</dataCenterId>
|
||||||
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
||||||
</return>
|
</return>
|
||||||
</ns2:removeRomDriveFromServerResponse>
|
</ns2:removeRomDriveFromServerResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:activateFirewallsResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:activateFirewallsResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id</requestId>
|
<requestId>request-id</requestId>
|
||||||
<dataCenterId>datacenter-id</dataCenterId>
|
<dataCenterId>datacenter-id</dataCenterId>
|
||||||
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
||||||
</return>
|
</return>
|
||||||
</ns2:activateFirewallsResponse>
|
</ns2:activateFirewallsResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,23 +1,23 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:addFirewallRulesToNicResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:addFirewallRulesToNicResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<active>active</active>
|
<active>active</active>
|
||||||
<firewallId>firewall-id</firewallId>
|
<firewallId>firewall-id</firewallId>
|
||||||
<firewallRules>
|
<firewallRules>
|
||||||
<firewallRuleId>firewall-rule-id</firewallRuleId>
|
<firewallRuleId>firewall-rule-id</firewallRuleId>
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
<portRangeEnd>45678</portRangeEnd>
|
<portRangeEnd>45678</portRangeEnd>
|
||||||
<portRangeStart>12345</portRangeStart>
|
<portRangeStart>12345</portRangeStart>
|
||||||
<protocol>TCP</protocol>
|
<protocol>TCP</protocol>
|
||||||
<sourceIp>192.168.0.1</sourceIp>
|
<sourceIp>192.168.0.1</sourceIp>
|
||||||
<sourceMac>aa:bb:cc:dd:ee:ff</sourceMac>
|
<sourceMac>aa:bb:cc:dd:ee:ff</sourceMac>
|
||||||
<targetIp>192.168.0.2</targetIp>
|
<targetIp>192.168.0.2</targetIp>
|
||||||
</firewallRules>
|
</firewallRules>
|
||||||
<nicId>nic-id</nicId>
|
<nicId>nic-id</nicId>
|
||||||
<provisioningState>AVAILABLE</provisioningState>
|
<provisioningState>AVAILABLE</provisioningState>
|
||||||
</return>
|
</return>
|
||||||
</ns2:addFirewallRulesToNicResponse>
|
</ns2:addFirewallRulesToNicResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:deactivateFirewallsResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:deactivateFirewallsResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id1111</requestId>
|
<requestId>request-id1111</requestId>
|
||||||
<dataCenterId>datacenter-id</dataCenterId>
|
<dataCenterId>datacenter-id</dataCenterId>
|
||||||
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
||||||
</return>
|
</return>
|
||||||
</ns2:deactivateFirewallsResponse>
|
</ns2:deactivateFirewallsResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:deleteFirewallsResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:deleteFirewallsResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id</requestId>
|
<requestId>request-id</requestId>
|
||||||
<dataCenterId>datacenter-id</dataCenterId>
|
<dataCenterId>datacenter-id</dataCenterId>
|
||||||
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
||||||
</return>
|
</return>
|
||||||
</ns2:deleteFirewallsResponse>
|
</ns2:deleteFirewallsResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:removeFirewallRulesResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:removeFirewallRulesResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id</requestId>
|
<requestId>request-id</requestId>
|
||||||
<dataCenterId>datacenter-id</dataCenterId>
|
<dataCenterId>datacenter-id</dataCenterId>
|
||||||
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
||||||
</return>
|
</return>
|
||||||
</ns2:removeFirewallRulesResponse>
|
</ns2:removeFirewallRulesResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,23 +1,23 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:getFirewallResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:getFirewallResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<active>true</active>
|
<active>true</active>
|
||||||
<firewallId>firewall-id</firewallId>
|
<firewallId>firewall-id</firewallId>
|
||||||
<firewallRules>
|
<firewallRules>
|
||||||
<firewallRuleId>firewall-rule-id</firewallRuleId>
|
<firewallRuleId>firewall-rule-id</firewallRuleId>
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
<portRangeEnd>45678</portRangeEnd>
|
<portRangeEnd>45678</portRangeEnd>
|
||||||
<portRangeStart>12345</portRangeStart>
|
<portRangeStart>12345</portRangeStart>
|
||||||
<protocol>TCP</protocol>
|
<protocol>TCP</protocol>
|
||||||
<sourceIp>192.168.0.1</sourceIp>
|
<sourceIp>192.168.0.1</sourceIp>
|
||||||
<sourceMac>aa:bb:cc:dd:ee:ff</sourceMac>
|
<sourceMac>aa:bb:cc:dd:ee:ff</sourceMac>
|
||||||
<targetIp>192.168.0.2</targetIp>
|
<targetIp>192.168.0.2</targetIp>
|
||||||
</firewallRules>
|
</firewallRules>
|
||||||
<nicId>nic-id</nicId>
|
<nicId>nic-id</nicId>
|
||||||
<provisioningState>AVAILABLE</provisioningState>
|
<provisioningState>AVAILABLE</provisioningState>
|
||||||
</return>
|
</return>
|
||||||
</ns2:getFirewallResponse>
|
</ns2:getFirewallResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:addPublicIpToNicResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:addPublicIpToNicResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id</requestId>
|
<requestId>request-id</requestId>
|
||||||
<dataCenterId>datacenter-id</dataCenterId>
|
<dataCenterId>datacenter-id</dataCenterId>
|
||||||
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
||||||
</return>
|
</return>
|
||||||
</ns2:addPublicIpToNicResponse>
|
</ns2:addPublicIpToNicResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:releasePublicIpBlockResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:releasePublicIpBlockResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id</requestId>
|
<requestId>request-id</requestId>
|
||||||
</return>
|
</return>
|
||||||
</ns2:releasePublicIpBlockResponse>
|
</ns2:releasePublicIpBlockResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:addPublicIpToNicResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:addPublicIpToNicResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id</requestId>
|
<requestId>request-id</requestId>
|
||||||
<dataCenterId>datacenter-id</dataCenterId>
|
<dataCenterId>datacenter-id</dataCenterId>
|
||||||
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
||||||
</return>
|
</return>
|
||||||
</ns2:addPublicIpToNicResponse>
|
</ns2:addPublicIpToNicResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,13 +1,13 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:reservePublicIpBlockResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:reservePublicIpBlockResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id</requestId>
|
<requestId>request-id</requestId>
|
||||||
<blockId>block-id</blockId>
|
<blockId>block-id</blockId>
|
||||||
<location>us/las</location>
|
<location>us/las</location>
|
||||||
<ips>ip</ips>
|
<ips>ip</ips>
|
||||||
</return>
|
</return>
|
||||||
</ns2:reservePublicIpBlockResponse>
|
</ns2:reservePublicIpBlockResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,18 +1,18 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:getAllPublicIpBlocksResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:getAllPublicIpBlocksResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<blockId>qwertyui-qwer-qwer-qwer-qwertyyuiiop</blockId>
|
<blockId>qwertyui-qwer-qwer-qwer-qwertyyuiiop</blockId>
|
||||||
<location>us/las</location>
|
<location>us/las</location>
|
||||||
<publicIps>
|
<publicIps>
|
||||||
<ip>ip</ip>
|
<ip>ip</ip>
|
||||||
<nicId>nic-id</nicId>
|
<nicId>nic-id</nicId>
|
||||||
</publicIps>
|
</publicIps>
|
||||||
<publicIps>
|
<publicIps>
|
||||||
<ip>ip</ip>
|
<ip>ip</ip>
|
||||||
</publicIps>
|
</publicIps>
|
||||||
</return>
|
</return>
|
||||||
</ns2:getAllPublicIpBlocksResponse>
|
</ns2:getAllPublicIpBlocksResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,6 +1,6 @@
|
||||||
<soapenv:Envelope
|
<soapenv:Envelope
|
||||||
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
|
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
|
||||||
xmlns:ws='http://ws.api.profitbricks.com/'>
|
xmlns:ws='http://ws.api.profitbricks.com/'>
|
||||||
<soapenv:Header />
|
<soapenv:Header />
|
||||||
<soapenv:Body>
|
<soapenv:Body>
|
||||||
<ws:createLoadBalancer>
|
<ws:createLoadBalancer>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<S:Body>
|
<S:Body>
|
||||||
<ns2:deleteLoadBalancerResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
<ns2:deleteLoadBalancerResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||||
<return>
|
<return>
|
||||||
<requestId>request-id</requestId>
|
<requestId>request-id</requestId>
|
||||||
<dataCenterId>datacenter-id</dataCenterId>
|
<dataCenterId>datacenter-id</dataCenterId>
|
||||||
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
||||||
</return>
|
</return>
|
||||||
</ns2:deleteLoadBalancerResponse>
|
</ns2:deleteLoadBalancerResponse>
|
||||||
</S:Body>
|
</S:Body>
|
||||||
</S:Envelope>
|
</S:Envelope>
|
|
@ -1,14 +1,14 @@
|
||||||
<soapenv:Envelope
|
<soapenv:Envelope
|
||||||
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
|
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
|
||||||
xmlns:ws='http://ws.api.profitbricks.com/'>
|
xmlns:ws='http://ws.api.profitbricks.com/'>
|
||||||
<soapenv:Header />
|
<soapenv:Header />
|
||||||
<soapenv:Body>
|
<soapenv:Body>
|
||||||
<ws:deregisterServersOnLoadBalancer>
|
<ws:deregisterServersOnLoadBalancer>
|
||||||
<request>
|
<request>
|
||||||
<serverIds>1</serverIds>
|
<serverIds>1</serverIds>
|
||||||
<serverIds>2</serverIds>
|
<serverIds>2</serverIds>
|
||||||
<loadBalancerId>load-balancer-id</loadBalancerId>
|
<loadBalancerId>load-balancer-id</loadBalancerId>
|
||||||
<request>
|
<request>
|
||||||
</ws:deregisterServersOnLoadBalancer>
|
</ws:deregisterServersOnLoadBalancer>
|
||||||
</soapenv:Body>
|
</soapenv:Body>
|
||||||
</soapenv:Envelope>
|
</soapenv:Envelope>
|
|
@ -1,13 +1,13 @@
|
||||||
<soapenv:Envelope
|
<soapenv:Envelope
|
||||||
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
|
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
|
||||||
xmlns:ws='http://ws.api.profitbricks.com/'>
|
xmlns:ws='http://ws.api.profitbricks.com/'>
|
||||||
<soapenv:Header/>
|
<soapenv:Header/>
|
||||||
<soapenv:Body>
|
<soapenv:Body>
|
||||||
<ws:registerServersOnLoadBalancer>
|
<ws:registerServersOnLoadBalancer>
|
||||||
<request>
|
<request>
|
||||||
<serverIds>1234</serverIds>
|
<serverIds>1234</serverIds>
|
||||||
<loadBalancerId>load-balancer-id</loadBalancerId>
|
<loadBalancerId>load-balancer-id</loadBalancerId>
|
||||||
</request>
|
</request>
|
||||||
</ws:registerServersOnLoadBalancer>
|
</ws:registerServersOnLoadBalancer>
|
||||||
</soapenv:Body>
|
</soapenv:Body>
|
||||||
</soapenv:Envelope>
|
</soapenv:Envelope>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue