diff --git a/labs/fgcp-au/pom.xml b/labs/fgcp-au/pom.xml new file mode 100644 index 0000000000..e32cc3d801 --- /dev/null +++ b/labs/fgcp-au/pom.xml @@ -0,0 +1,175 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.5.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.labs + fgcp-au + jclouds Fujitsu Global Cloud Platform AU provider + jclouds components to access Fujitsu Global Cloud Platform in Australia + http://globalcloud.fujitsu.com.au + + bundle + + + + Dies Koper + dkoper + diesk -at- fast -dot- au -dot- fujitsu -dot- com + Fujitsu + + Java Developer + + +10 + + + + + UTF-8 + https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint + 2011-01-31 + + fgcp-id + fgcp-cred + + + + org.jclouds.fujitsu.fgcp*;version="${project.version}" + + org.jclouds.providers*;version="${project.version}", + * + + + + + + + org.jclouds + jclouds-compute + ${project.version} + + + + + + + + org.bouncycastle + bcprov-jdk16 + 1.46 + true + + + org.jclouds.driver + jclouds-sshj + ${project.version} + test + + + org.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.testng + testng + 6.0.1 + test + + + org.easymock + easymockclassextension + 2.4 + test + + + org.jclouds.labs + fgcp + ${project.version} + jar + + + org.jclouds.labs + fgcp + ${project.version} + test-jar + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.fgcp-au.identity} + ${test.fgcp-au.credential} + ${test.fgcp-au.endpoint} + ${test.fgcp-au.apiversion} + ${test.fgcp-au.build-version} + ${test.fgcp-au.image-id} + ${test.fgcp-au.image.login-user} + ${test.fgcp-au.image.authenticate-sudo} + + + + + + + + + + + diff --git a/labs/fgcp-au/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderMetadata.java b/labs/fgcp-au/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderMetadata.java new file mode 100644 index 0000000000..b17d6caf96 --- /dev/null +++ b/labs/fgcp-au/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderMetadata.java @@ -0,0 +1,77 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp; + +import java.net.URI; + +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +/** + * Implementation of {@link org.jclouds.providers.ProviderMetadata} for FGCP. + * + * @author Dies Koper + */ +public class FGCPAUProviderMetadata extends FGCPProviderMetadata { + + public static Builder builder() { + return new Builder(); + } + + public FGCPAUProviderMetadata() { + super(builder()); + } + + public FGCPAUProviderMetadata(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public static class Builder extends BaseProviderMetadata.Builder { + + protected Builder() { + id("fgcp-au") + .name("Fujitsu Global Cloud Platform (FGCP) - AU") + .apiMetadata(new FGCPApiMetadata()) + .homepage( + URI.create("http://www.fujitsu.com/global/solutions/cloud/solutions/global-cloud-platform/index.html")) + .console(URI.create("http://globalcloud.fujitsu.com.au")) + .defaultProperties(FGCPApiMetadata.defaultProperties()) + .iso3166Codes("AU-NSW") + .endpoint( + "https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint") + .defaultProperties(FGCPProviderMetadata.defaultProperties()); + } + + @Override + public FGCPAUProviderMetadata build() { + return new FGCPAUProviderMetadata(this); + } + + @Override + public Builder fromProviderMetadata(ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } + } +} \ No newline at end of file diff --git a/labs/fgcp-au/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/fgcp-au/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..83cbc2086a --- /dev/null +++ b/labs/fgcp-au/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.fujitsu.fgcp.FGCPAUProviderMetadata diff --git a/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderTest.java b/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderTest.java new file mode 100644 index 0000000000..9a2ddbce86 --- /dev/null +++ b/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderTest.java @@ -0,0 +1,34 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp; + +import org.jclouds.providers.internal.BaseProviderMetadataTest; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "FGCPAUProviderTest") +public class FGCPAUProviderTest extends BaseProviderMetadataTest { + + public FGCPAUProviderTest() { + super(new FGCPAUProviderMetadata(), new FGCPApiMetadata()); + } + +} diff --git a/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPAUTemplateBuilderLiveTest.java b/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPAUTemplateBuilderLiveTest.java new file mode 100644 index 0000000000..30f12dea7e --- /dev/null +++ b/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPAUTemplateBuilderLiveTest.java @@ -0,0 +1,43 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute; + +import java.util.Set; + +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; + +/** + * @author Dies Koper + * + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "FGCPAUTemplateBuilderLiveTest") +public class FGCPAUTemplateBuilderLiveTest extends + FGCPBaseTemplateBuilderLiveTest { + + public FGCPAUTemplateBuilderLiveTest() { + provider = "fgcp-au"; + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("AU-NSW"); + } +} diff --git a/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPAUComputeServiceLiveTest.java b/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPAUComputeServiceLiveTest.java new file mode 100644 index 0000000000..49c23ffe47 --- /dev/null +++ b/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPAUComputeServiceLiveTest.java @@ -0,0 +1,37 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.config; + + +import org.testng.annotations.Test; + + +/** + * @author Dies Koper + * + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "FGCPAUComputeServiceLiveTest") +public class FGCPAUComputeServiceLiveTest extends FGCPBaseComputeServiceLiveTest { + + @Override + public void setServiceDefaults() { + provider = "fgcp-au"; + } + +} diff --git a/labs/fgcp-de/pom.xml b/labs/fgcp-de/pom.xml new file mode 100644 index 0000000000..6aa954ab0e --- /dev/null +++ b/labs/fgcp-de/pom.xml @@ -0,0 +1,175 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.5.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.labs + fgcp-de + jclouds Fujitsu Global Cloud Platform DE provider + jclouds components to access Fujitsu Global Cloud Platform in Germany + http://globalcloud.de.fujitsu.com + + bundle + + + + Dies Koper + dkoper + diesk -at- fast -dot- au -dot- fujitsu -dot- com + Fujitsu + + Java Developer + + +10 + + + + + UTF-8 + https://api.globalcloud.de.fujitsu.com/ovissapi/endpoint + 2011-01-31 + + fgcp-id + fgcp-cred + + + + org.jclouds.fujitsu.fgcp*;version="${project.version}" + + org.jclouds.providers*;version="${project.version}", + * + + + + + + + org.jclouds + jclouds-compute + ${project.version} + + + + + + + + org.bouncycastle + bcprov-jdk16 + 1.46 + true + + + org.jclouds.driver + jclouds-sshj + ${project.version} + test + + + org.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.testng + testng + 6.0.1 + test + + + org.easymock + easymockclassextension + 2.4 + test + + + org.jclouds.labs + fgcp + ${project.version} + jar + + + org.jclouds.labs + fgcp + ${project.version} + test-jar + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.fgcp-de.identity} + ${test.fgcp-de.credential} + ${test.fgcp-de.endpoint} + ${test.fgcp-de.apiversion} + ${test.fgcp-de.build-version} + ${test.fgcp-de.image-id} + ${test.fgcp-de.image.login-user} + ${test.fgcp-de.image.authenticate-sudo} + + + + + + + + + + + diff --git a/labs/fgcp-de/src/main/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderMetadata.java b/labs/fgcp-de/src/main/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderMetadata.java new file mode 100644 index 0000000000..db087a580f --- /dev/null +++ b/labs/fgcp-de/src/main/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderMetadata.java @@ -0,0 +1,79 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp; + +import java.net.URI; + +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +/** + * Implementation of {@link org.jclouds.providers.ProviderMetadata} for FGCP. + * + * @author Dies Koper + */ +public class FGCPDEProviderMetadata extends FGCPProviderMetadata { + + private static final long serialVersionUID = -8498457904032259345L; + + public static Builder builder() { + return new Builder(); + } + + public FGCPDEProviderMetadata() { + super(builder()); + } + + public FGCPDEProviderMetadata(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public static class Builder extends BaseProviderMetadata.Builder { + + protected Builder() { + id("fgcp-de") + .name("Fujitsu Global Cloud Platform (FGCP) - DE") + .apiMetadata(new FGCPApiMetadata()) + .homepage( + URI.create("http://www.fujitsu.com/global/solutions/cloud/solutions/global-cloud-platform/index.html")) + .console(URI.create("http://globalcloud.de.fujitsu.com")) + .defaultProperties(FGCPApiMetadata.defaultProperties()) + .iso3166Codes("DE-BY") + .endpoint( + "https://api.globalcloud.de.fujitsu.com/ovissapi/endpoint") + .defaultProperties(FGCPProviderMetadata.defaultProperties()); + } + + @Override + public FGCPDEProviderMetadata build() { + return new FGCPDEProviderMetadata(this); + } + + @Override + public Builder fromProviderMetadata(ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } + } +} \ No newline at end of file diff --git a/labs/fgcp-de/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/fgcp-de/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..9e952cb7ea --- /dev/null +++ b/labs/fgcp-de/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.fujitsu.fgcp.FGCPDEProviderMetadata diff --git a/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderTest.java b/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderTest.java new file mode 100644 index 0000000000..99b37d255b --- /dev/null +++ b/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderTest.java @@ -0,0 +1,34 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp; + +import org.jclouds.providers.internal.BaseProviderMetadataTest; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "FGCPDEProviderTest") +public class FGCPDEProviderTest extends BaseProviderMetadataTest { + + public FGCPDEProviderTest() { + super(new FGCPDEProviderMetadata(), new FGCPApiMetadata()); + } + +} diff --git a/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPDETemplateBuilderLiveTest.java b/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPDETemplateBuilderLiveTest.java new file mode 100644 index 0000000000..0894978822 --- /dev/null +++ b/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPDETemplateBuilderLiveTest.java @@ -0,0 +1,43 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute; + +import java.util.Set; + +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; + +/** + * @author Dies Koper + * + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "FGCPDETemplateBuilderLiveTest") +public class FGCPDETemplateBuilderLiveTest extends + FGCPBaseTemplateBuilderLiveTest { + + public FGCPDETemplateBuilderLiveTest() { + provider = "fgcp-de"; + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("DE-BY"); + } +} diff --git a/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPDEComputeServiceLiveTest.java b/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPDEComputeServiceLiveTest.java new file mode 100644 index 0000000000..f0de55992f --- /dev/null +++ b/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPDEComputeServiceLiveTest.java @@ -0,0 +1,37 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.config; + + +import org.testng.annotations.Test; + + +/** + * @author Dies Koper + * + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "FGCPDEComputeServiceLiveTest") +public class FGCPDEComputeServiceLiveTest extends FGCPBaseComputeServiceLiveTest { + + @Override + public void setServiceDefaults() { + provider = "fgcp-de"; + } + +} diff --git a/labs/fgcp/pom.xml b/labs/fgcp/pom.xml new file mode 100644 index 0000000000..cc1e81fe45 --- /dev/null +++ b/labs/fgcp/pom.xml @@ -0,0 +1,169 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.5.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.labs + fgcp + jclouds Fujitsu Global Cloud Platform + jclouds components to access Fujitsu Global Cloud Platform + + bundle + + + + Dies Koper + dkoper + diesk -at- fast -dot- au -dot- fujitsu -dot- com + Fujitsu + + Java Developer + + +10 + + + + + UTF-8 + https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint + 2011-01-31 + + fgcp-id + fgcp-cred + IMG_3c9820_71OW9NZC268 + + + org.jclouds.fujitsu.fgcp*;version="${project.version}" + + org.jclouds.compute.internal;version="${project.version}", + org.jclouds.rest.internal;version="${project.version}", + org.jclouds*;version="${project.version}", + * + + + + + + + org.jclouds + jclouds-compute + ${project.version} + + + + + + + + org.bouncycastle + bcprov-jdk16 + 1.46 + true + + + org.jclouds.driver + jclouds-sshj + ${project.version} + test + + + org.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.testng + testng + 6.0.1 + test + + + org.easymock + easymockclassextension + 2.4 + test + + + ch.qos.logback + logback-classic + 1.0.0 + + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.fgcp-au.identity} + ${test.fgcp-au.credential} + ${test.fgcp-au.endpoint} + ${test.fgcp-au.apiversion} + ${test.fgcp-au.build-version} + ${test.fgcp-au.image-id} + ${test.fgcp-au.image.login-user} + ${test.fgcp-au.image.authenticate-sudo} + + + + + + + + + + + diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApi.java new file mode 100644 index 0000000000..54561af058 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApi.java @@ -0,0 +1,69 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp; + +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.services.AdditionalDiskApi; +import org.jclouds.fujitsu.fgcp.services.DiskImageApi; +import org.jclouds.fujitsu.fgcp.services.FirewallApi; +import org.jclouds.fujitsu.fgcp.services.LoadBalancerApi; +import org.jclouds.fujitsu.fgcp.services.PublicIPAddressApi; +import org.jclouds.fujitsu.fgcp.services.SystemTemplateApi; +import org.jclouds.fujitsu.fgcp.services.VirtualDCApi; +import org.jclouds.fujitsu.fgcp.services.VirtualServerApi; +import org.jclouds.fujitsu.fgcp.services.VirtualSystemApi; +import org.jclouds.rest.annotations.Delegate; + +/** + * Provides synchronous access to FGCP services. + * + * @author Dies Koper + */ +@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) +public interface FGCPApi { + + @Delegate + VirtualDCApi getVirtualDCApi(); + + @Delegate + VirtualSystemApi getVirtualSystemApi(); + + @Delegate + VirtualServerApi getVirtualServerApi(); + + @Delegate + AdditionalDiskApi getAdditionalDiskApi(); + + @Delegate + SystemTemplateApi getSystemTemplateApi(); + + @Delegate + DiskImageApi getDiskImageApi(); + + @Delegate + FirewallApi getFirewallApi(); + + @Delegate + LoadBalancerApi getLoadBalancerApi(); + + @Delegate + PublicIPAddressApi getPublicIPAddressApi(); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApiMetadata.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApiMetadata.java new file mode 100644 index 0000000000..0f5e9fdb44 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApiMetadata.java @@ -0,0 +1,99 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.Constants; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.fujitsu.fgcp.compute.FGCPRestClientModule; +import org.jclouds.fujitsu.fgcp.compute.config.FGCPComputeServiceContextModule; +import org.jclouds.rest.internal.BaseRestApiMetadata; + +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; +import com.google.inject.Module; + +/** + * Implementation of {@link ApiMetadata} for Fujitsu's Global Cloud Platform + * (FGCP, FGCP/S5) provider in Australia. + * + * @author Dies Koper + */ +public class FGCPApiMetadata extends BaseRestApiMetadata { + + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); + } + + public FGCPApiMetadata() { + this(new Builder()); + } + + protected FGCPApiMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); + // enables peer verification using the CAs bundled with the JRE (or + // value of javax.net.ssl.trustStore if set) + properties.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "false"); + // properties.setProperty("jclouds.ssh.max-retries", "5"); + // properties.setProperty("jclouds.ssh.retry-auth", "true"); + return properties; + } + + public static class Builder extends BaseRestApiMetadata.Builder { + + protected Builder() { + super(FGCPApi.class, FGCPAsyncApi.class); + id("fgcp") + .name("Fujitsu Global Cloud Platform (FGCP)") + .identityName("User certificate (PEM file)") + .credentialName("User certificate password") + .documentation( + URI.create("https://globalcloud.fujitsu.com.au/portala/ctrl/aboutSopManual")) + .version(FGCPAsyncApi.VERSION) + .defaultEndpoint( + "https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint") + .defaultProperties(FGCPApiMetadata.defaultProperties()) + .view(TypeToken.of(ComputeServiceContext.class)) + .defaultModules( + ImmutableSet.> of( + FGCPComputeServiceContextModule.class, + FGCPRestClientModule.class)); + } + + @Override + public FGCPApiMetadata build() { + return new FGCPApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(ApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAsyncApi.java new file mode 100644 index 0000000000..9eda1dde95 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAsyncApi.java @@ -0,0 +1,66 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp; + +import org.jclouds.fujitsu.fgcp.services.AdditionalDiskAsyncApi; +import org.jclouds.fujitsu.fgcp.services.DiskImageAsyncApi; +import org.jclouds.fujitsu.fgcp.services.FirewallAsyncApi; +import org.jclouds.fujitsu.fgcp.services.LoadBalancerAsyncApi; +import org.jclouds.fujitsu.fgcp.services.PublicIPAddressAsyncApi; +import org.jclouds.fujitsu.fgcp.services.SystemTemplateAsyncApi; +import org.jclouds.fujitsu.fgcp.services.VirtualDCAsyncApi; +import org.jclouds.fujitsu.fgcp.services.VirtualServerAsyncApi; +import org.jclouds.fujitsu.fgcp.services.VirtualSystemAsyncApi; +import org.jclouds.rest.annotations.Delegate; + +/** + * Provides asynchronous access to FGCP services. + * + * @author Dies Koper + */ +public interface FGCPAsyncApi { + public final static String VERSION = "2012-02-18"; + + @Delegate + VirtualDCAsyncApi getVirtualDCApi(); + + @Delegate + VirtualSystemAsyncApi getVirtualSystemApi(); + + @Delegate + VirtualServerAsyncApi getVirtualServerApi(); + + @Delegate + AdditionalDiskAsyncApi getAdditionalDiskApi(); + + @Delegate + SystemTemplateAsyncApi getSystemTemplateApi(); + + @Delegate + DiskImageAsyncApi getDiskImageApi(); + + @Delegate + FirewallAsyncApi getFirewallApi(); + + @Delegate + LoadBalancerAsyncApi getLoadBalancerApi(); + + @Delegate + PublicIPAddressAsyncApi getPublicIPAddressApi(); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPProviderMetadata.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPProviderMetadata.java new file mode 100644 index 0000000000..a7718d4c2e --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPProviderMetadata.java @@ -0,0 +1,57 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp; + +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; + +import java.util.Properties; + +import org.jclouds.providers.internal.BaseProviderMetadata; + +/** + * Base implementation of {@link org.jclouds.providers.ProviderMetadata} for + * FGCP. + * + * @author Dies Koper + */ +public class FGCPProviderMetadata extends BaseProviderMetadata { + + private static final long serialVersionUID = 7527265705102650456L; + + public static Builder builder() { + return new Builder(); + } + + public FGCPProviderMetadata() { + super(builder()); + } + + public FGCPProviderMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = new Properties(); + + properties.setProperty(TEMPLATE, + "osFamily=CENTOS,osVersionMatches=6.2,os64Bit=true"); + + return properties; + } +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/binders/BindAlsoToSystemId.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/binders/BindAlsoToSystemId.java new file mode 100644 index 0000000000..0986997dbf --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/binders/BindAlsoToSystemId.java @@ -0,0 +1,70 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.binders; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.inject.Singleton; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpRequest.Builder; +import org.jclouds.rest.Binder; + +/** + * Adds system id to resource id and binds them to query parameters + * + * @author Dies Koper + */ +@Singleton +public class BindAlsoToSystemId implements Binder { + + /** + * + * @param request + * request where the query params will be set + * @param input + * array of String params + */ + @SuppressWarnings("unchecked") + @Override + public R bindToRequest(R request, Object input) { + + checkNotNull(input); + checkArgument( + input instanceof String, + "this binder only applies to String arguments: " + + input.getClass()); + + Pattern pattern = Pattern.compile("^(\\w+-\\w+)\\b.*"); + Matcher matcher = pattern.matcher((String) input); + + checkArgument(matcher.find(), + "no valid resource id found to construct vsys id from: " + + input.toString()); + + Builder builder = request.toBuilder(); + builder.replaceQueryParam("vsysId", matcher.group(1)); + + return (R) builder.build(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModule.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModule.java new file mode 100644 index 0000000000..c86abea2ea --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModule.java @@ -0,0 +1,375 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.security.KeyStore; +import java.security.PrivateKey; +import java.security.cert.Certificate; +import java.security.cert.CertificateFactory; +import java.security.spec.KeySpec; +import java.util.Calendar; +import java.util.Collection; +import java.util.Map; + +import javax.annotation.Resource; +import javax.inject.Singleton; +import javax.net.ssl.SSLContext; + +import org.jclouds.crypto.Crypto; +import org.jclouds.crypto.Pems; +import org.jclouds.date.TimeStamp; +import org.jclouds.fujitsu.fgcp.FGCPApi; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.handlers.FGCPRetryIfNotProxyAuthenticationFailureHandler; +import org.jclouds.fujitsu.fgcp.http.SSLContextWithKeysSupplier; +import org.jclouds.fujitsu.fgcp.location.SystemAndNetworkSegmentToLocationSupplier; +import org.jclouds.fujitsu.fgcp.services.AdditionalDiskApi; +import org.jclouds.fujitsu.fgcp.services.AdditionalDiskAsyncApi; +import org.jclouds.fujitsu.fgcp.services.BuiltinServerApi; +import org.jclouds.fujitsu.fgcp.services.BuiltinServerAsyncApi; +import org.jclouds.fujitsu.fgcp.services.DiskImageApi; +import org.jclouds.fujitsu.fgcp.services.DiskImageAsyncApi; +import org.jclouds.fujitsu.fgcp.services.FirewallApi; +import org.jclouds.fujitsu.fgcp.services.FirewallAsyncApi; +import org.jclouds.fujitsu.fgcp.services.LoadBalancerApi; +import org.jclouds.fujitsu.fgcp.services.LoadBalancerAsyncApi; +import org.jclouds.fujitsu.fgcp.services.PublicIPAddressApi; +import org.jclouds.fujitsu.fgcp.services.PublicIPAddressAsyncApi; +import org.jclouds.fujitsu.fgcp.services.SystemTemplateApi; +import org.jclouds.fujitsu.fgcp.services.SystemTemplateAsyncApi; +import org.jclouds.fujitsu.fgcp.services.VirtualDCApi; +import org.jclouds.fujitsu.fgcp.services.VirtualDCAsyncApi; +import org.jclouds.fujitsu.fgcp.services.VirtualServerApi; +import org.jclouds.fujitsu.fgcp.services.VirtualServerAsyncApi; +import org.jclouds.fujitsu.fgcp.services.VirtualSystemApi; +import org.jclouds.fujitsu.fgcp.services.VirtualSystemAsyncApi; +import org.jclouds.fujitsu.fgcp.xml.FGCPJAXBParser; +import org.jclouds.http.HttpRetryHandler; +import org.jclouds.http.annotation.ClientError; +import org.jclouds.io.InputSuppliers; +import org.jclouds.location.suppliers.ImplicitLocationSupplier; +import org.jclouds.location.suppliers.LocationsSupplier; +import org.jclouds.location.suppliers.implicit.FirstNetwork; +import org.jclouds.logging.Logger; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.annotations.Credential; +import org.jclouds.rest.annotations.Identity; +import org.jclouds.rest.config.RestClientModule; +import org.jclouds.xml.XMLParser; + +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableMap; +import com.google.inject.Provides; +import com.google.inject.Scopes; +import com.google.inject.TypeLiteral; + +/** + * Configures the FGCP connection. This module is added in FGCPContextBuilder. + * + * @author Dies Koper + */ +@ConfiguresRestClient +public class FGCPRestClientModule extends + RestClientModule { + + @Resource + Logger logger = Logger.NULL; + + public static final Map, Class> DELEGATE_MAP = ImmutableMap + ., Class> builder() + // + .put(VirtualDCApi.class, VirtualDCAsyncApi.class) + .put(VirtualSystemApi.class, VirtualSystemAsyncApi.class) + .put(VirtualServerApi.class, VirtualServerAsyncApi.class) + .put(AdditionalDiskApi.class, AdditionalDiskAsyncApi.class) + .put(SystemTemplateApi.class, SystemTemplateAsyncApi.class) + .put(DiskImageApi.class, DiskImageAsyncApi.class) + .put(BuiltinServerApi.class, BuiltinServerAsyncApi.class) + .put(FirewallApi.class, FirewallAsyncApi.class) + .put(LoadBalancerApi.class, LoadBalancerAsyncApi.class) + .put(PublicIPAddressApi.class, PublicIPAddressAsyncApi.class) + .build(); + + public FGCPRestClientModule() { + super(DELEGATE_MAP); + } + + @Override + protected void bindErrorHandlers() { + // bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseAWSErrorFromXmlContent.class); + // bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseAWSErrorFromXmlContent.class); + // bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseAWSErrorFromXmlContent.class); + } + + @Override + protected void installLocations() { + super.installLocations(); + bind(ImplicitLocationSupplier.class).to(FirstNetwork.class).in( + Scopes.SINGLETON); + bind(LocationsSupplier.class).to( + SystemAndNetworkSegmentToLocationSupplier.class).in( + Scopes.SINGLETON); + } + + @Override + protected void bindRetryHandlers() { + bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to( + FGCPRetryIfNotProxyAuthenticationFailureHandler.class); + } + + @Override + protected void configure() { + super.configure(); + bind(XMLParser.class).to(FGCPJAXBParser.class); + bind(new TypeLiteral>() { + }).to(new TypeLiteral() { + }); + } + + @Provides + @TimeStamp + protected Calendar provideCalendar() { + return Calendar.getInstance(); + } + + /* + * + * @Provides + * + * @Singleton protected KeyStore + * provideKeyStore(@Named(Constants.PROPERTY_IDENTITY) String + * keyStoreFilename, @Named(Constants.PROPERTY_CREDENTIAL) String + * keyStorePassword) throws KeyStoreException { KeyStore keyStore = + * KeyStore.getInstance("pkcs12"); + * + * try { FileInputStream is = new + * FileInputStream(checkNotNull(keyStoreFilename, + * Constants.PROPERTY_IDENTITY)); keyStore.load(is, + * checkNotNull(keyStorePassword, + * Constants.PROPERTY_CREDENTIAL).toCharArray()); } catch (Exception e) { // + * expecting IOException, NoSuchAlgorithmException, CertificateException + * logger.error(e, "Keystore could not be opened: %s", keyStoreFilename); } + * return keyStore; } + * + * @Provides + * + * @Singleton protected PrivateKey provideKey(Provider + * keyStoreProvider, @Named(Constants.PROPERTY_CREDENTIAL) String + * keyPassword) throws KeyStoreException, NoSuchAlgorithmException, + * UnrecoverableKeyException { KeyStore keyStore = keyStoreProvider.get(); + * if (keyStore == null) return null; + * + * // retrieving 1st alias in keystore as expecting only one String alias = + * checkNotNull(keyStore.aliases().nextElement(), + * "first alias in keystore"); return (PrivateKey) keyStore.getKey(alias, + * checkNotNull(keyPassword, Constants.PROPERTY_CREDENTIAL).toCharArray()); + * } + */ + /* + * maybe we can provide two authentication methods: + * + * 1. same as DeltaCloud: User passes a folder name as identity and cert + * password as credential Note: pass relative path (e.g. cert's path: + * c:\jclouds\certs\dkoper\UserCert.p12: user passes 'dkoper': provider + * impl. finds it under e.g. $USER_DIR or $CURRENT_DIR or pass absolute path + * 2. no file access for GAE: User passes cert in PEM format (converted from + * UserCert.p12 using openssl?) as identity and cert password as credential + */ + @Provides + @Singleton + protected KeyStore provideKeyStore(Crypto crypto, @Identity String cert, + @Credential String keyStorePassword) { + KeyStore keyStore = null; + try { + keyStore = KeyStore.getInstance("PKCS12"); + + // System.out.println("cert: " + cert); + // System.out.println("pwd : " + keyStorePassword); + File certFile = new File(checkNotNull(cert)); + if (certFile.isFile()) { // cert is path to pkcs12 file + + keyStore.load(new FileInputStream(certFile), + keyStorePassword.toCharArray()); + } else { // cert is PEM encoded, containing private key and certs + + // System.out.println("cert:\n" + cert); + // split in private key and certs + int privateKeyBeginIdx = cert.indexOf("-----BEGIN PRIVATE KEY"); + int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY"); + String pemPrivateKey = cert.substring(privateKeyBeginIdx, + privateKeyEndIdx + 26); + // System.out.println("***************"); + // System.out.println("pemPrivateKey:\n" + pemPrivateKey); + // System.out.println("***************"); + + String pemCerts = ""; + int certsBeginIdx = 0; + + do { + certsBeginIdx = cert.indexOf("-----BEGIN CERTIFICATE", + certsBeginIdx); + // System.out.println("begin:" + certsBeginIdx); + + if (certsBeginIdx >= 0) { + int certsEndIdx = cert.indexOf("-----END CERTIFICATE", + certsBeginIdx) + 26; + // System.out.println("end :" + certsEndIdx); + pemCerts += cert.substring(certsBeginIdx, certsEndIdx); + certsBeginIdx = certsEndIdx; + } + } while (certsBeginIdx != -1); + // System.out.println("***************"); + // System.out.println("pemCerts:\n" + pemCerts); + // System.out.println("***************"); + + /* + * String pemCerts = "-----BEGIN "; Splitter pemSplitter = + * Splitter.on("-----BEGIN "); + * + * for (String part : pemSplitter.split(cert)) { + * System.out.println("***************"); + * System.out.println("Part:\n" + part); + * System.out.println("***************"); + * + * if (part.startsWith("PRIVATE KEY") + */ + /* || part.startsWith("RSA PRIVATE KEY)" *//* + * ) { + * + * int certEndIdx = + * part.lastIndexOf + * ("-----END"); + * pemPrivateKey += + * part.substring(0, + * certEndIdx + 26); + * // take up to next + * "-----" (i.e. + * "-----END") // + * Splitter + * keySplitter = + * Splitter + * .on("-----"). + * omitEmptyStrings + * ().trimResults(); + * // + * Iterator + * iter = + * keySplitter. + * split(part + * ).iterator(); // + * String keyName = + * iter.next() + + * "-----\n"; // + * pemPrivateKey += + * keyName; //// + * System.out + * .println + * ("Skipping: '" + + * iter.next() + + * "'"); // + * pemPrivateKey += + * iter.next(); // + * pemPrivateKey += + * "\n-----END " + + * keyName; + * System.out.println + * ( + * "/////////////////" + * ); + * System.out.println + * ( + * "pemPrivateKey:\n" + * + pemPrivateKey); + * System + * .out.println( + * "/////////////////" + * ); } else if + * (part.startsWith + * ("CERTIFICATE")) { + * + * // take up to next + * "-----" (i.e. + * "-----END") // or + * take up to last + * END CERTIFICATE? + * int certEndIdx = + * part.lastIndexOf ( + * "----- END CERTIFICATE" + * ); // pemCerts += + * part. // Splitter + * keySplitter = + * Splitter + * .on("-----"). + * omitEmptyStrings + * (); // pemCerts += + * keySplitter + * .split(part) + * .iterator + * ().next(); // + * pemCerts += + * "-----BEGIN "; } + * else { // ignore + * the fluff in + * between (Bag + * Attributes, etc.) + * } } + */ + + // parse private key + KeySpec keySpec = Pems.privateKeySpec(InputSuppliers + .of(pemPrivateKey)); + PrivateKey privateKey = crypto.rsaKeyFactory().generatePrivate( + keySpec); + + // populate keystore with private key and certs + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + @SuppressWarnings("unchecked") + Collection certs = (Collection) cf + .generateCertificates(new ByteArrayInputStream(pemCerts + .getBytes("UTF-8"))); + keyStore.load(null); + keyStore.setKeyEntry("dummy", privateKey, + keyStorePassword.toCharArray(), + certs.toArray(new java.security.cert.Certificate[0])); + + // System.out.println("private key: " + privateKey.getFormat() + + // "; " + // + privateKey.getAlgorithm() + "; class: " + + // privateKey.getClass().getName());// + "; " + new + // String(privateKey.getEncoded())); + + } + } catch (Exception e) { + /* + * KeyStoreException, IOException, NoSuchAlgorithmException, + * CertificateException, InvalidKeySpecException + */ + throw new AuthorizationException("Error loading certificate", e); + } + + return keyStore; + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPComputeServiceContextModule.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPComputeServiceContextModule.java new file mode 100644 index 0000000000..46f3646e6e --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPComputeServiceContextModule.java @@ -0,0 +1,140 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.config; + +import org.jclouds.compute.ComputeServiceAdapter; +import org.jclouds.compute.config.ComputeServiceAdapterContextModule; +import org.jclouds.compute.domain.Hardware; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.Processor; +import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.domain.Location; +import org.jclouds.fujitsu.fgcp.compute.functions.CPUToProcessor; +import org.jclouds.fujitsu.fgcp.compute.functions.DiskImageToImage; +import org.jclouds.fujitsu.fgcp.compute.functions.DiskImageToOperatingSystem; +import org.jclouds.fujitsu.fgcp.compute.functions.DiskToVolume; +import org.jclouds.fujitsu.fgcp.compute.functions.ServerTypeToHardware; +import org.jclouds.fujitsu.fgcp.compute.functions.VServerMetadataToNodeMetadata; +import org.jclouds.fujitsu.fgcp.compute.options.FGCPTemplateOptions; +import org.jclouds.fujitsu.fgcp.compute.strategy.FGCPComputeServiceAdapter; +import org.jclouds.fujitsu.fgcp.compute.strategy.VServerMetadata; +import org.jclouds.fujitsu.fgcp.domain.CPU; +import org.jclouds.fujitsu.fgcp.domain.Disk; +import org.jclouds.fujitsu.fgcp.domain.DiskImage; +import org.jclouds.fujitsu.fgcp.domain.ServerType; +import org.jclouds.functions.IdentityFunction; + +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; +//import org.jclouds.fujitsu.fgcp.compute.predicates.ServerStopped; + +/** + * Added in FGCPContextBuilder + * + * @author Dies Koper + */ +public class FGCPComputeServiceContextModule + extends + ComputeServiceAdapterContextModule { + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + protected void configure() { + super.configure(); + // installDependencies(); + + bind( + new TypeLiteral>() { + }).to(FGCPComputeServiceAdapter.class); + + // the following bind functions that map FGCP domain specific resources + // to jclouds' + bind(new TypeLiteral>() { + }).to(VServerMetadataToNodeMetadata.class); + bind(new TypeLiteral>() { + }).to(DiskImageToImage.class); + bind(new TypeLiteral>() { + }).to(DiskImageToOperatingSystem.class); + bind(new TypeLiteral>() { + }).to(ServerTypeToHardware.class); + bind(new TypeLiteral>() { + }).to(DiskToVolume.class); + bind(new TypeLiteral>() { + }).to(CPUToProcessor.class); + + // we aren't converting hardware from a provider-specific type + bind(new TypeLiteral>() { + }).to((Class) IdentityFunction.class); + bind(new TypeLiteral>() { + }).to((Class) IdentityFunction.class); + + bind(TemplateOptions.class).to(FGCPTemplateOptions.class); + + + // bind(new TypeLiteral>() { + // }).to((Class) ServerStopped.class); + + // need to look into the following later for to map (create) jclouds' + // location to FGCP. + // see LocationScope: + // PROVIDER: FGCP + // REGION: country?/country+state? + // ZONE: virtual DC: contractId + // NETWORK: VSYS? DMZ/SECURE1/SECURE2? + // RACK: N/A? + // HOST: N/A? + // there are no locations except the provider + // bind(new TypeLiteral>() { + // }).to(OnlyLocationOrFirstZone.class); + + // install(new FGCPBindComputeStrategiesByClass()); + // install(new FGCPBindComputeSuppliersByClass()); + // bind(ReviseParsedImage.class).to(AWSEC2ReviseParsedImage.class); + // bind(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class).to( + // CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class); + // bind(EC2HardwareSupplier.class).to(AWSEC2HardwareSupplier.class); + // bind(EC2TemplateBuilderImpl.class).to(AWSEC2TemplateBuilderImpl.class); + // bind(EC2GetNodeMetadataStrategy.class).to(AWSEC2GetNodeMetadataStrategy.class); + // bind(InstancePresent.class).to(AWSEC2InstancePresent.class); + // bind(EC2CreateNodesInGroupThenAddToSet.class).to(AWSEC2CreateNodesInGroupThenAddToSet.class); + // bind(RunningInstanceToNodeMetadata.class).to(AWSRunningInstanceToNodeMetadata.class); + } + + // @Provides + // @Singleton + // @Named("SECURITY") + // protected Predicate provideServerStopped(ServerStopped + // serverStopped, Timeouts timeouts) { + // return new RetryablePredicate(serverStopped, + // timeouts.nodeSuspended); + // } + + protected void installDependencies() { + // install(new FGCPComputeServiceDependenciesModule()); + } + + /* + * @Override protected TemplateBuilder provideTemplate(Injector injector, + * TemplateBuilder template) { return + * template.osFamily(CENTOS).os64Bit(true); } + */ +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/CPUToProcessor.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/CPUToProcessor.java new file mode 100644 index 0000000000..a26508e954 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/CPUToProcessor.java @@ -0,0 +1,44 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Function; +import org.jclouds.compute.domain.Processor; +import org.jclouds.fujitsu.fgcp.domain.CPU; + +import javax.inject.Singleton; + +/** + * Created by IntelliJ IDEA. + * + * @author Dies Koper + */ +@Singleton +public class CPUToProcessor implements Function { + + @Override + public Processor apply(CPU cpu) { + checkNotNull(cpu, "cpu"); + + return new Processor(Double.valueOf(cpu.getCores()), Double.valueOf(cpu + .getSpeedPerCore())); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToImage.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToImage.java new file mode 100644 index 0000000000..e5200da051 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToImage.java @@ -0,0 +1,80 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.Image.Status; +import org.jclouds.compute.domain.ImageBuilder; +import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.domain.LoginCredentials; +import org.jclouds.fujitsu.fgcp.domain.DiskImage; +import org.jclouds.location.suppliers.all.RegionToProviderOrJustProvider; + +import com.google.common.base.Function; +import com.google.common.collect.Iterables; + +/** + * Created by IntelliJ IDEA. + * + * @author Dies Koper + */ +@Singleton +public class DiskImageToImage implements Function { + + private final DiskImageToOperatingSystem diskImageToOperatingSystem; + private final RegionToProviderOrJustProvider regionSupplier; + + @Inject + public DiskImageToImage( + DiskImageToOperatingSystem diskImageToOperatingSystem, + RegionToProviderOrJustProvider locationSupplier) { + this.diskImageToOperatingSystem = checkNotNull( + diskImageToOperatingSystem, "diskImageToOperatingSystem"); + this.regionSupplier = checkNotNull(locationSupplier, "locationProvider"); + } + + @Override + public Image apply(DiskImage from) { + checkNotNull(from, "disk image"); + + ImageBuilder builder = new ImageBuilder(); + + builder.ids(from.getId()); + builder.name(from.getName()); + builder.description(from.getDescription()); + builder.location(Iterables.getOnlyElement(regionSupplier.get())); + // in fgcp, if the image is listed it is available + builder.status(Status.AVAILABLE); + + OperatingSystem os = diskImageToOperatingSystem.apply(from); + builder.operatingSystem(os); + String user = os.getFamily() == OsFamily.WINDOWS ? "Administrator" + : "root"; + builder.defaultCredentials(LoginCredentials.builder().identity(user) + .noPassword().build()); + + return builder.build(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystem.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystem.java new file mode 100644 index 0000000000..b1ce9a1aef --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystem.java @@ -0,0 +1,73 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.inject.Singleton; + +import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.util.ComputeServiceUtils; +import org.jclouds.fujitsu.fgcp.domain.DiskImage; + +import com.google.common.base.Function; + +/** + * + * @author Dies Koper + */ +@Singleton +public class DiskImageToOperatingSystem implements + Function { + + private static final Pattern OS_VERSION_PATTERN = Pattern + .compile("^.*?(\\d.*)\\s(32|64).*$"); + + @Override + public OperatingSystem apply(DiskImage image) { + checkNotNull(image, "disk image"); + + // convert to short name rhel to accommodate ComputeServiceUtils + // conventions + String shortOsName = image.getOsName().replace( + "Red Hat Enterprise Linux", "rhel"); + OsFamily osFamily = ComputeServiceUtils + .parseOsFamilyOrUnrecognized(shortOsName); + OperatingSystem.Builder builder = OperatingSystem.builder(); + + builder.name(image.getOsName()); + builder.family(osFamily); + builder.is64Bit(image.getOsName().contains("64bit") + || image.getOsName().contains("64 bit") + || image.getOsName().contains("x64")); + // OsType returns guest type (hvm, pv), which aws-ec2 is mapping to arch + builder.arch(image.getOsType()); + Matcher m = OS_VERSION_PATTERN.matcher(image.getOsName()); + if (m.matches()) { + builder.version(m.group(1)); + } + builder.description(image.getOsName()); + + return builder.build(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskToVolume.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskToVolume.java new file mode 100644 index 0000000000..c9f4067632 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskToVolume.java @@ -0,0 +1,53 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Function; +import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.domain.VolumeBuilder; +import org.jclouds.fujitsu.fgcp.domain.Disk; + +import javax.inject.Singleton; + +/** + * Created by IntelliJ IDEA. + * + * @author Dies Koper + */ +@Singleton +public class DiskToVolume implements Function { + + @Override + public Volume apply(Disk disk) { + checkNotNull(disk, "disk"); + + VolumeBuilder builder = new VolumeBuilder(); + + builder.size(1000f * Float.valueOf(disk.getSize())); + // "Disk"'s are additional disks; they can't be booted disk(?) + builder.bootDevice(false); + builder.durable(true); + builder.type(Volume.Type.SAN); + builder.id("type: " + disk.getType() + " usage: " + disk.getUsage()); + + return builder.build(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToFirewallId.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToFirewallId.java new file mode 100644 index 0000000000..2e91f2bb4a --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToFirewallId.java @@ -0,0 +1,51 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import com.google.common.base.Function; + +/** + * Determines the id of the firewall associated with a virtual system, server, + * load balancer or disk. + * + * @author Dies Koper + */ +@Singleton +public class ResourceIdToFirewallId implements Function { + + private ResourceIdToSystemId toSystemId; + + @Inject + private ResourceIdToFirewallId(ResourceIdToSystemId resourceIdToSystemId) { + this.toSystemId = checkNotNull(resourceIdToSystemId, + "resourceIdToSystemId"); + } + + @Override + public String apply(String id) { + checkNotNull(id, "resource id"); + + return toSystemId.apply(id) + "-S-0001"; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToSystemId.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToSystemId.java new file mode 100644 index 0000000000..01b1891cf7 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToSystemId.java @@ -0,0 +1,52 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.functions; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.inject.Singleton; + +import com.google.common.base.Function; + +/** + * Determines the id of the virtual system that a server, load balancer or disk + * is part of. + * + * @author Dies Koper + */ +@Singleton +public class ResourceIdToSystemId implements Function { + + @Override + public String apply(String id) { + checkNotNull(id, "resource id"); + + Pattern pattern = Pattern.compile("^(\\w+-\\w+)\\b.*"); + Matcher matcher = pattern.matcher((String) id); + + checkArgument(matcher.find(), + "no valid resource id found: " + id.toString()); + + return matcher.group(1); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ServerTypeToHardware.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ServerTypeToHardware.java new file mode 100644 index 0000000000..ec99cf56f4 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ServerTypeToHardware.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.compute.domain.Hardware; +import org.jclouds.compute.domain.HardwareBuilder; +import org.jclouds.compute.domain.Image; +import org.jclouds.fujitsu.fgcp.domain.ServerType; + +import com.google.common.base.Function; +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; + +/** + * Created by IntelliJ IDEA. + * + * @author Dies Koper + */ +@Singleton +public class ServerTypeToHardware implements Function { + private final CPUToProcessor cpuToProcessor; + private final DiskToVolume diskToVolume; + + @Inject + public ServerTypeToHardware(CPUToProcessor cpuToProcessor, + DiskToVolume diskToVolume) { + this.cpuToProcessor = checkNotNull(cpuToProcessor); + this.diskToVolume = checkNotNull(diskToVolume); + } + + @Override + public Hardware apply(ServerType from) { + checkNotNull(from, "ServerType"); + HardwareBuilder builder = new HardwareBuilder(); + + builder.ids(from.getId()); + builder.name(from.getName()); + builder.ram((int) (1000d * Double.valueOf(from.getMemory().getSize()))); + builder.processor(cpuToProcessor.apply(from.getCpu())); + builder.supportsImage(Predicates. alwaysTrue()); + // all servers are 64bit. The OS however may be 32 bit. + builder.is64Bit(true); + builder.volumes(Iterables.transform(from.getDisks(), diskToVolume)); + + return builder.build(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/SingleElementResponseToElement.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/SingleElementResponseToElement.java new file mode 100644 index 0000000000..b8677a4f96 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/SingleElementResponseToElement.java @@ -0,0 +1,34 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.fujitsu.fgcp.xml.internal.SingleElementResponse; + +import com.google.common.base.Function; + +public class SingleElementResponseToElement implements + Function { + + @Override + public Object apply(SingleElementResponse r) { + return checkNotNull(r, "response").getElement(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/VServerMetadataToNodeMetadata.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/VServerMetadataToNodeMetadata.java new file mode 100644 index 0000000000..66c390be0f --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/VServerMetadataToNodeMetadata.java @@ -0,0 +1,245 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.collect.Memoized; +import org.jclouds.compute.domain.Hardware; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.NodeMetadata.Status; +import org.jclouds.compute.domain.NodeMetadataBuilder; +import org.jclouds.compute.functions.GroupNamingConvention; +import org.jclouds.compute.reference.ComputeServiceConstants; +import org.jclouds.domain.Location; +import org.jclouds.domain.LoginCredentials; +import org.jclouds.fujitsu.fgcp.compute.strategy.VServerMetadata; +import org.jclouds.fujitsu.fgcp.domain.VServer; +import org.jclouds.fujitsu.fgcp.domain.VServerStatus; +import org.jclouds.fujitsu.fgcp.domain.VServerWithVNICs; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; + +/** + * @author Dies Koper + */ +@Singleton +public class VServerMetadataToNodeMetadata implements + Function { + + public static final Map vServerToStatus = ImmutableMap + . builder() + .put(VServerStatus.DEPLOYING, Status.PENDING) + .put(VServerStatus.RUNNING, Status.RUNNING) + .put(VServerStatus.STOPPING, Status.PENDING) + .put(VServerStatus.STOPPED, Status.SUSPENDED) + .put(VServerStatus.STARTING, Status.PENDING) + .put(VServerStatus.FAILOVER, Status.RUNNING) + .put(VServerStatus.UNEXPECTED_STOP, Status.SUSPENDED) + .put(VServerStatus.RESTORING, Status.PENDING) + .put(VServerStatus.BACKUP_ING, Status.PENDING) + .put(VServerStatus.ERROR, Status.ERROR) + .put(VServerStatus.START_ERROR, Status.ERROR) + .put(VServerStatus.STOP_ERROR, Status.ERROR) + .put(VServerStatus.CHANGE_TYPE, Status.PENDING) + .put(VServerStatus.REGISTERING, Status.PENDING) + .put(VServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED).build(); + + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; + + protected final Supplier> locations; + protected final Supplier> images; + protected final Supplier> hardwares; + protected final GroupNamingConvention nodeNamingConvention; + + private static class FindImageForVServer implements Predicate { + private final VServer server; + + private FindImageForVServer(VServer server) { + this.server = server; + } + + @Override + public boolean apply(Image input) { + return input.getId().equals(server.getDiskimageId()); + } + } + + protected Image parseImage(VServer from) { + try { + return Iterables.find(images.get(), new FindImageForVServer(from)); + } catch (NoSuchElementException e) { + logger.warn("could not find a matching image for server %s", from); + } + return null; + } + + private static class FindHardwareForServerType implements + Predicate { + private final String type; + + private FindHardwareForServerType(String type) { + this.type = type; + } + + @Override + public boolean apply(Hardware input) { + return input.getName().equals(type); + } + } + + protected Hardware parseHardware(String from) { + try { + return Iterables.find(hardwares.get(), + new FindHardwareForServerType(from)); + } catch (NoSuchElementException e) { + logger.warn( + "could not find a matching hardware for server type %s", + from); + } + return null; + } + + private static class FindLocationForVServer implements Predicate { + private final VServerWithVNICs server; + + private FindLocationForVServer(VServerWithVNICs server) { + this.server = server; + } + + @Override + public boolean apply(Location input) { + return input.getId().equals( + Iterables.getLast(server.getVnics()).getNetworkId()); + } + } + + protected Location parseLocation(VServerWithVNICs from) { + try { + return Iterables.find(locations.get(), new FindLocationForVServer( + from)); + } catch (NoSuchElementException e) { + logger.warn("could not find a matching realm for server %s", from); + } + return null; + } + + @Inject + VServerMetadataToNodeMetadata( + @Memoized Supplier> locations, + @Memoized Supplier> images, + @Memoized Supplier> hardwares, + GroupNamingConvention.Factory namingConvention) { + this.images = checkNotNull(images, "images"); + this.locations = checkNotNull(locations, "locations"); + this.hardwares = checkNotNull(hardwares, "hardwares"); + this.nodeNamingConvention = checkNotNull(namingConvention, + "namingConvention").createWithoutPrefix(); + } + + @Override + public NodeMetadata apply(VServerMetadata from) { + NodeMetadataBuilder builder = new NodeMetadataBuilder(); + + builder.ids(from.getId()); + builder.name(from.getName()); + builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from + .getName())); + if (from.getStatus() == null) + System.out.println("status null for: " + from.getId() + ": " + + from.getName()); + + builder.status(vServerToStatus.get(from.getStatus())); + builder.privateAddresses(ImmutableSet. of()); + builder.publicAddresses(ImmutableSet. of()); + + // + // if (from.getIps() != null) { + // + // builder.publicAddresses(Collections2.transform(from.getIps(), + // new Function() { + // + // @Override + // public String apply(PublicIP input) { + // return input.getAddress(); + // } + // + // })); + // } + + if (from.getServer() != null) { + + builder.imageId(from.getServer().getDiskimageId()); + builder.hardware(parseHardware(from.getServer().getType())); + + LoginCredentials.Builder credentialsBuilder = LoginCredentials + .builder().password(from.getInitialPassword()); + + Image image = parseImage(from.getServer()); + // image will not be found if server was created a while back and + // the image has since been destroyed or discontinued (like an old + // CentOS version) + if (image != null) { + + builder.operatingSystem(image.getOperatingSystem()); + String user = image.getDefaultCredentials().getUser(); + credentialsBuilder.identity(user); + } + + builder.credentials(credentialsBuilder.build()); + + if (from.getServer() instanceof VServerWithVNICs) { + + VServerWithVNICs server = (VServerWithVNICs) from.getServer(); + builder.location(parseLocation(server)); + List ips = new ArrayList(); + if (server.getVnics() != null && server.getVnics().iterator().next().getPrivateIp() != null) { + ips.add(server.getVnics().iterator().next().getPrivateIp()); + } + builder.privateAddresses(ips); + } + } + if (from.getTemplate() != null) { + // when creating a new node + builder.location(from.getTemplate().getLocation()); + } + + return builder.build(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/options/FGCPTemplateOptions.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/options/FGCPTemplateOptions.java new file mode 100644 index 0000000000..ca11f6c166 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/options/FGCPTemplateOptions.java @@ -0,0 +1,29 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.options; + +import org.jclouds.compute.options.TemplateOptions; + +/** + * + * @author Dies Koper + */ +public class FGCPTemplateOptions extends TemplateOptions { + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/ServerStopped.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/ServerStopped.java new file mode 100644 index 0000000000..bda281ca71 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/ServerStopped.java @@ -0,0 +1,63 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.predicates; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.fujitsu.fgcp.FGCPApi; +import org.jclouds.fujitsu.fgcp.domain.VServerStatus; +import org.jclouds.logging.Logger; + +import com.google.common.base.Predicate; + +/** + * + * @author Adrian Cole + * @author Dies Koper + * + */ +@Singleton +public class ServerStopped implements Predicate { + + private final FGCPApi api; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject + public ServerStopped(FGCPApi api) { + this.api = api; + } + + public boolean apply(String serverId) { + logger.trace("looking for status on server %s", serverId); + + VServerStatus status = api.getVirtualServerApi().getStatus(serverId); + logger.trace("looking for status on server %s: currently: %s", + serverId, status); + + if (status == VServerStatus.ERROR || status == VServerStatus.STOP_ERROR) + throw new IllegalStateException("server not around or in error: " + + status); + return status == VServerStatus.STOPPED; + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/SystemStatusNormal.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/SystemStatusNormal.java new file mode 100644 index 0000000000..881233560e --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/SystemStatusNormal.java @@ -0,0 +1,62 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.predicates; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.fujitsu.fgcp.FGCPApi; +import org.jclouds.fujitsu.fgcp.domain.VServerStatus; +import org.jclouds.fujitsu.fgcp.domain.VSystemStatus; +import org.jclouds.logging.Logger; + +import com.google.common.base.Predicate; + +/** + * + * @author Dies Koper + * + */ +@Singleton +public class SystemStatusNormal implements Predicate { + + private final FGCPApi api; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject + public SystemStatusNormal(FGCPApi api) { + this.api = api; + } + + public boolean apply(String systemId) { + logger.trace("looking for status on system %s", systemId); + + VSystemStatus status = api.getVirtualSystemApi().getStatus(systemId); + logger.trace("looking for status on system %s: currently: %s", + systemId, status); + + if (status == VSystemStatus.ERROR) + throw new IllegalStateException("system in error: " + status); + return status == VSystemStatus.NORMAL; + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/FGCPComputeServiceAdapter.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/FGCPComputeServiceAdapter.java new file mode 100644 index 0000000000..732a8a6d09 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/FGCPComputeServiceAdapter.java @@ -0,0 +1,294 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.strategy; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ExecutionException; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.compute.ComputeServiceAdapter; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.reference.ComputeServiceConstants; +import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; +import org.jclouds.domain.Location; +import org.jclouds.domain.LoginCredentials; +import org.jclouds.fujitsu.fgcp.FGCPApi; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.compute.functions.ResourceIdToFirewallId; +import org.jclouds.fujitsu.fgcp.compute.functions.ResourceIdToSystemId; +import org.jclouds.fujitsu.fgcp.compute.predicates.ServerStopped; +import org.jclouds.fujitsu.fgcp.compute.predicates.SystemStatusNormal; +import org.jclouds.fujitsu.fgcp.compute.strategy.VServerMetadata.Builder; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerConfiguration; +import org.jclouds.fujitsu.fgcp.domain.DiskImage; +import org.jclouds.fujitsu.fgcp.domain.ServerType; +import org.jclouds.fujitsu.fgcp.domain.VServer; +import org.jclouds.fujitsu.fgcp.domain.VServerStatus; +import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; +import org.jclouds.fujitsu.fgcp.domain.VServerWithVNICs; +import org.jclouds.fujitsu.fgcp.domain.VSystem; +import org.jclouds.fujitsu.fgcp.domain.VSystemWithDetails; +import org.jclouds.logging.Logger; +import org.jclouds.predicates.RetryablePredicate; + +import com.google.common.base.Predicate; +import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Defines the connection between the {@link org.jclouds.fujitsu.fgcp.FGCPApi} + * implementation and the jclouds {@link org.jclouds.compute.ComputeService}. + * Bound in FGCPComputeServiceAdapter. + * + * @author Dies Koper + */ +@Singleton +public class FGCPComputeServiceAdapter implements + ComputeServiceAdapter { + + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; + + private final FGCPApi api; + private final FGCPAsyncApi asyncApi; + protected Predicate serverStopped = null; + protected Predicate serverCreated = null; + protected Predicate systemNormal = null; + protected ResourceIdToFirewallId toFirewallId = null; + protected ResourceIdToSystemId toSystemId = null; + + @Inject + public FGCPComputeServiceAdapter(FGCPApi api, FGCPAsyncApi asyncApi, + ServerStopped serverStopped, SystemStatusNormal systemNormal, + Timeouts timeouts, ResourceIdToFirewallId toFirewallId, + ResourceIdToSystemId toSystemId) { + this.api = checkNotNull(api, "api"); + this.asyncApi = checkNotNull(asyncApi, "asyncApi"); + this.serverStopped = new RetryablePredicate( + checkNotNull(serverStopped), timeouts.nodeSuspended); + this.serverCreated = new RetryablePredicate( + checkNotNull(serverStopped), timeouts.nodeRunning); + this.systemNormal = new RetryablePredicate( + checkNotNull(systemNormal), timeouts.nodeTerminated); + this.toFirewallId = checkNotNull(toFirewallId, "ResourceIdToFirewallId"); + this.toSystemId = checkNotNull(toSystemId, "ResourceIdToSystemId"); + } + + /** + * {@inheritDoc} + */ + @Override + public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName( + String group, String name, Template template) { + // Find vsys (how? create new? default to first found?) + // Target network DMZ/SECURE1/SECURE2 (how? default to DMZ?) + // Determine remaining params: [vserverType,diskImageId,networkId] + // what if no vsys exists yet? Location.AU(.contractId) creates 3? tier + // skeleton vsys and DMZ is picked? + String id = api.getVirtualSystemApi().createServer(name, + template.getHardware().getName(), template.getImage().getId(), + template.getLocation().getId()); + + // wait until fully created (i.e. transitions to stopped status) + serverCreated.apply(id); + resumeNode(id); + VServerMetadata server = getNode(id); + + //do we need this? + server.setTemplate(template); + String user = template.getImage().getOperatingSystem().getFamily() == OsFamily.WINDOWS ? "Administrator" + : "root"; + + return new NodeAndInitialCredentials(server, + id, LoginCredentials.builder().identity(user) + .password(server.getInitialPassword()).build()); + } + + /** + * {@inheritDoc} + */ + @Override + public Iterable listHardwareProfiles() { + return api.getVirtualDCApi().listServerTypes(); + } + + /** + * {@inheritDoc} + */ + @Override + public Iterable listImages() { + return api.getVirtualDCApi().listDiskImages(); + } + + /** + * {@inheritDoc} + */ + @Override + public DiskImage getImage(String id) { + return api.getDiskImageApi().get(id); + } + + /** + * {@inheritDoc} + */ + @Override + public Iterable listLocations() { + // Not using the adapter to determine locations + // see SystemAndNetworkSegmentToLocationSupplier + return ImmutableSet. of(); + } + + /** + * {@inheritDoc} + */ + @Override + public VServerMetadata getNode(String id) { + Builder builder = VServerMetadata.builder(); + builder.id(id); + + List> futures = new ArrayList>(); + + futures.add(asyncApi.getVirtualServerApi().getDetails(id)); + futures.add(asyncApi.getVirtualServerApi().getStatus(id)); + futures.add(asyncApi.getVirtualServerApi().getInitialPassword(id)); + // mapped public ips? + String fwId = toFirewallId.apply(id); +// futures.add(asyncApi.getBuiltinServerApi().getConfiguration(fwId, +// BuiltinServerConfiguration.SLB_RULE)); + try { + List results = Futures.successfulAsList(futures).get(); + VServerWithDetails server = (VServerWithDetails) results.get(0); + VServerStatus status = (VServerStatus) results.get(1); + System.out.println("getNode(" + id + ")'s getDetails: " + status +" - " + server); + if (server == null) { + server = api.getVirtualServerApi().getDetails(id); + System.out.println("getNode(" + id + ")'s getDetails(2) returns: " + server); + } + builder.serverWithDetails(server); + builder.status(status == null ? VServerStatus.UNRECOGNIZED : status); +// System.out.println("status in adapter#getNode: " +// + (VServerStatus) results.get(1) +// +" for " +// + server.getId()); + builder.initialPassword((String) results.get(2)); +// SLB slb = ((BuiltinServer) results.get(4)).; +// slb. + } catch (InterruptedException e) { + throw Throwables.propagate(e); + } catch (ExecutionException e) { + throw Throwables.propagate(e); + } + return builder.build(); + } + + /** + * {@inheritDoc} + */ + @Override + public Iterable listNodes() { + ImmutableSet.Builder servers = ImmutableSet + . builder(); + + Set systems = api.getVirtualDCApi().listVirtualSystems(); + List> futures = new ArrayList>(); + for (VSystem system : systems) { + + futures.add(asyncApi.getVirtualSystemApi().getDetails( + system.getId())); + } + try { + for (VSystemWithDetails system : Futures.successfulAsList(futures) + .get()) { + + if (system != null) { + + for (VServerWithVNICs server : system.getServers()) { + + // skip FW (S-0001) and SLBs (>0 for SLB) + if (!server.getId().endsWith("-S-0001") && server.getVnics().iterator().next().getNicNo() == 0) { + + servers.add(getNode(server.getId())); +// Builder builder = VServerMetadata.builder(); +// builder.server(server); +// builder.status(VServerStatus.UNRECOGNIZED); +// servers.add(builder.build()); + } + } + } + } + } catch (InterruptedException e) { + throw Throwables.propagate(e); + } catch (ExecutionException e) { + throw Throwables.propagate(e); + } + + return servers.build(); + } + + /** + * {@inheritDoc} + */ + @Override + public void destroyNode(String id) { + api.getVirtualServerApi().destroy(id); + // wait until fully destroyed + String systemId = toSystemId.apply(id); + systemNormal.apply(systemId); + } + + /** + * {@inheritDoc} + */ + @Override + public void rebootNode(String id) { + suspendNode(id); + // wait until fully stopped + serverStopped.apply(id); + resumeNode(id); + } + + /** + * {@inheritDoc} + */ + @Override + public void resumeNode(String id) { + api.getVirtualServerApi().start(id); + } + + /** + * {@inheritDoc} + */ + @Override + public void suspendNode(String id) { + api.getVirtualServerApi().stop(id); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/VServerMetadata.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/VServerMetadata.java new file mode 100644 index 0000000000..e9835ac349 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/VServerMetadata.java @@ -0,0 +1,178 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute.strategy; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Set; + +import org.jclouds.compute.domain.Template; +import org.jclouds.fujitsu.fgcp.domain.DiskImage; +import org.jclouds.fujitsu.fgcp.domain.PublicIP; +import org.jclouds.fujitsu.fgcp.domain.VServer; +import org.jclouds.fujitsu.fgcp.domain.VServerStatus; +import org.jclouds.fujitsu.fgcp.domain.VServerWithVNICs; + +import com.google.common.collect.ImmutableSet; + +/** + * Holds metadata on a virtual server, both static (name, id, type, etc.) and + * dynamic (status, mapped public IPs, etc.). + * + * @author Dies Koper + */ +public class VServerMetadata { + + protected VServer server; + protected String id; + protected String name; + protected Template template; + protected String initialPassword; + protected VServerStatus status = VServerStatus.UNRECOGNIZED; + protected Set ips; + protected DiskImage image; + + public VServerMetadata(VServer server, String initialPassword, + VServerStatus status, DiskImage image, Set publicIps) { + this.server = checkNotNull(server, "server"); + this.initialPassword = initialPassword; + this.status = status; + this.image = image; + this.ips = publicIps; + id = server.getId(); + name = server.getName(); + } + + public VServerMetadata(String id, String name, Template template, + VServerStatus status) { + this.id = checkNotNull(id, "id"); + this.name = checkNotNull(name, "name"); + this.template = checkNotNull(template, "template"); + this.status = checkNotNull(status, "status"); + } + + public VServer getServer() { + return server; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public Template getTemplate() { + return template; + } + + public void setTemplate(Template template) { + this.template = template; + } + + public String getInitialPassword() { + return initialPassword; + } + + public VServerStatus getStatus() { + return status; + } + + public Set getIps() { + return ips; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private VServer server; + private VServerWithVNICs serverWithDetails; + private String id; + private String name; + private Template template; + private String initialPassword; + private VServerStatus status = VServerStatus.UNRECOGNIZED; + private Set publicIps = ImmutableSet.of(); + private DiskImage image; + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder template(Template template) { + this.template = template; + return this; + } + +// public Builder server(VServer server) { +// this.server = server; +// return this; +// } + + public Builder serverWithDetails(VServerWithVNICs serverWithDetails) { + this.serverWithDetails = serverWithDetails; + return this; + } + + public Builder initialPassword(String password) { + this.initialPassword = password; + return this; + } + + public Builder status(VServerStatus status) { + this.status = status; + return this; + } + + public Builder image(DiskImage image) { + this.image = image; + return this; + } + + public Builder publicIps(Set publicIps) { + this.publicIps = publicIps; + return this; + } + + public VServerMetadata build() { + if (initialPassword == null) initialPassword = ""; + if (server != null) { + return new VServerMetadata(server, initialPassword, status, + image, publicIps); + } else if (serverWithDetails != null) { + return new VServerMetadata(serverWithDetails, initialPassword, + status, image, publicIps); + } else { + // sometimes these fields are null because the server is returning a verify error + if (id == null) id = "dummy-id"; + if (name == null) name = "dummy-name"; + return new VServerMetadata(id, name, template, status); + } + } + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/AddressRange.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/AddressRange.java new file mode 100644 index 0000000000..032a718e16 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/AddressRange.java @@ -0,0 +1,57 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Describes the address range pool in a contract used for allocating private IP + * address network segments for virtual systems. + * + * @author Dies Koper + */ +@XmlRootElement(name = "addressrange") +public class AddressRange { + private String range; + + private String from; + + private String to; + + /** + * @return the range + */ + public String getRange() { + return range; + } + + /** + * @return the from + */ + public String getFrom() { + return from; + } + + /** + * @return the to + */ + public String getTo() { + return to; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServer.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServer.java new file mode 100644 index 0000000000..911b05c5f0 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServer.java @@ -0,0 +1,73 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents a built-in server, also called extended function module (EFM), + * such as a firewall or load balancer (SLB). + * + * @author Dies Koper + */ +@XmlRootElement(name = "efm") +public class BuiltinServer { + @XmlElement(name = "efmId") + private String id; + @XmlElement(name = "efmType") + private BuiltinServerType builtinServerType; + @XmlElement(name = "efmName") + private String name; + private String creator; + private String slbVip; + private Firewall firewall; + private SLB loadbalancer; + + public enum BuiltinServerType {FW, SLB} + + public String getId() { + return id; + } + + public BuiltinServerType getType() { + return builtinServerType; + } + + public String getName() { + return name; + } + + public String getCreator() { + return creator; + } + + public String getSlbVip() { + return slbVip; + } + + public Firewall getFirewall() { + return firewall; + } + + public SLB getLoadbalancer() { + return loadbalancer; + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerBackup.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerBackup.java new file mode 100644 index 0000000000..79374f9356 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerBackup.java @@ -0,0 +1,75 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Holds information on a backup of a built-in server, such as a firewall or + * load balancer (SLB). + * + * @author Dies Koper + */ +@XmlRootElement(name = "backup") +public class BuiltinServerBackup { + @XmlElement(name = "backupId") + private String id; + @XmlElement(name = "backupTime") + private String time; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the time + */ + public String getTime() { + return time; + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BuiltinServerBackup that = BuiltinServerBackup.class.cast(obj); + return Objects.equal(this.id, that.id); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("time", time).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerConfiguration.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerConfiguration.java new file mode 100644 index 0000000000..5f7fa6ac23 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerConfiguration.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.CaseFormat; + +/** + * Possible statuses of a built-in server, also called extended function module + * (EFM), such as a firewall or load balancer (SLB). + *

+ * In addition to statuses that apply to regular virtual servers, it includes + * statuses relevant to the upgrade process for functionality of the built-in + * server. + * + * @author Dies Koper + */ +public enum BuiltinServerConfiguration { + FW_NAT_RULE, + FW_DNS, + FW_POLICY, + FW_LOG, + FW_LIMIT_POLICY, + SLB_RULE, + SLB_LOAD_STATISTICS, + SLB_ERROR_STATISTICS, + SLB_CERTIFICATE_LIST, + EFM_UPDATE, + SLB_CONNECTION, + UNRECOGNIZED; + + public String value() { + return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); + } + + @Override + public String toString() { + return value(); + } + + public static BuiltinServerConfiguration fromValue(String configuration) { + try { + return valueOf(CaseFormat.UPPER_CAMEL + .to(CaseFormat.UPPER_UNDERSCORE, + checkNotNull(configuration, "configuration"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerStatus.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerStatus.java new file mode 100644 index 0000000000..4ee7ba279d --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerStatus.java @@ -0,0 +1,60 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.CaseFormat; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Possible statuses of a built-in server, also called extended function module + * (EFM), such as a firewall or load balancer (SLB). + *

+ * In addition to statuses that apply to regular virtual servers, it includes + * statuses relevant to the upgrade process for functionality of the built-in + * server. + * + * @author Dies Koper + */ +@XmlRootElement(name = "efmStatus") +public enum BuiltinServerStatus { + DEPLOYING, RUNNING, STOPPING, STOPPED, STARTING, FAILOVER, UNEXPECTED_STOP, RESTORING, BACKUP_ING, ERROR, EXECUTE_NETWORK_SERVER, START_ERROR, STOP_ERROR, UPDATE, BACKOUT, UNRECOGNIZED; + + public String value() { + return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); + } + + @Override + public String toString() { + return value(); + } + + public static BuiltinServerStatus fromValue(String status) { + try { + return valueOf(CaseFormat.UPPER_CAMEL + .to(CaseFormat.UPPER_UNDERSCORE, + checkNotNull(status, "status"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/CPU.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/CPU.java new file mode 100644 index 0000000000..b49b9e8196 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/CPU.java @@ -0,0 +1,77 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Describes the virtual CPU of a server. + * + * @author Dies Koper + */ +@XmlRootElement(name = "cpu") +public class CPU { + @XmlElement(name = "cpuArch") + private String arch; + @XmlElement(name = "cpuPerf") + private double speedPerCore; + @XmlElement(name = "numOfCpu") + private double cores; + + public String getArch() { + return arch; + } + + public double getSpeedPerCore() { + return speedPerCore; + } + + public double getCores() { + return cores; + } + + @Override + public int hashCode() { + return Objects.hashCode(cores, speedPerCore, arch); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CPU that = CPU.class.cast(obj); + return Objects.equal(this.cores, that.cores) + && Objects.equal(this.speedPerCore, that.speedPerCore) + && Objects.equal(this.arch, that.arch); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("cores", cores).add("speedPerCore", speedPerCore) + .add("arch", arch).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Cause.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Cause.java new file mode 100644 index 0000000000..c2863db2b5 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Cause.java @@ -0,0 +1,100 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + + +/** + * Represents a load balancer (SLB) log entry. + * + * @author Dies Koper + */ +public class Cause { + private String cat; + + private String status; + + private String filePath; + + private String current; + + private String before; + + private String today; + + private String yesterday; + + private String total; + + /** + * @return category + */ + public String getCat() { + return cat; + } + + /** + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * @return the filePath + */ + public String getFilePath() { + return filePath; + } + + /** + * @return the current + */ + public String getCurrent() { + return current; + } + + /** + * @return the before + */ + public String getBefore() { + return before; + } + + /** + * @return the today + */ + public String getToday() { + return today; + } + + /** + * @return the yesterday + */ + public String getYesterday() { + return yesterday; + } + + /** + * @return the total + */ + public String getTotal() { + return total; + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Direction.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Direction.java new file mode 100644 index 0000000000..b332fdcbb1 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Direction.java @@ -0,0 +1,113 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Grouping of firewall rules pertaining to a particular direction in network + * traffic, e.g. from the Internet to a server in the DMZ zone, or from a server + * in the SECURE2 zone to the SECURE1 zone, etc. + * + * @author Dies Koper + */ +public class Direction { + private String from; + private String to; + private Set policies = new LinkedHashSet(); + private Acceptable acceptable; + private Prefix prefix; + private int maxPolicyNum; + + enum Acceptable {OK, NG} + enum Prefix {free, src, dst, proto, srcport, dstport, action, rule, tab} + + /** + * @return the from + */ + public String getFrom() { + return from; + } + + /** + * @return the to + */ + public String getTo() { + return to; + } + + /** + * @return the policies + */ + public Set getPolicies() { + return policies == null ? ImmutableSet. of() : ImmutableSet + .copyOf(policies); + } + + /** + * @return the acceptable + */ + public Acceptable getAcceptable() { + return acceptable; + } + + /** + * @return the prefix + */ + public Prefix getPrefix() { + return prefix; + } + + /** + * @return the maxPolicyNum + */ + public int getMaxPolicyNum() { + return maxPolicyNum; + } + + @Override + public int hashCode() { + return Objects.hashCode(from, to); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Direction that = Direction.class.cast(obj); + return Objects.equal(this.from, that.from) + && Objects.equal(this.to, that.to); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("from", from) + .add("to", to).add("prefix", prefix).add("policies", policies) + .add("maxPolicyNum", maxPolicyNum) + .add("acceptable", acceptable).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Disk.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Disk.java new file mode 100644 index 0000000000..dae088f095 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Disk.java @@ -0,0 +1,85 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Describes a disk as part of the description of hardware represented by a + * virtual server. + * + * @author Dies Koper + */ +@XmlRootElement +public class Disk { + @XmlElement(name = "diskSize") + private String size; + + @XmlElement(name = "diskUsage") + private String usage; + + @XmlElement(name = "diskType") + private String type; + + public String getSize() { + return size; + } + + public String getUsage() { + return usage; + } + + public String getType() { + return type; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof Disk)) + return false; + + Disk disk = (Disk) o; + + if (size != null ? !size.equals(disk.size) : disk.size != null) + return false; + if (type != null ? !type.equals(disk.type) : disk.type != null) + return false; + if (usage != null ? !usage.equals(disk.usage) : disk.usage != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = size != null ? size.hashCode() : 0; + result = 31 * result + (usage != null ? usage.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "Disk{" + "size='" + size + '\'' + ", usage='" + usage + '\'' + + ", type='" + type + '\'' + '}'; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/DiskImage.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/DiskImage.java new file mode 100644 index 0000000000..5e2d3e1daf --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/DiskImage.java @@ -0,0 +1,200 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Represents a disk image with pre-installed OS and/or software. + *

+ * It is used as base for the system disk of a virtual server. + * + * @author Dies Koper + */ +@XmlRootElement(name = "diskimage") +public class DiskImage { + @XmlElement(name = "diskimageId") + private String id; + + @XmlElement(name = "diskimageName") + private String name; + + private int size; + + private String osName; + + private String osType; + + private String creatorName; + + private String registrant; + + private String licenseInfo; + + private String description; + + @XmlElementWrapper(name = "softwares") + @XmlElement(name = "software") + private Set software = new LinkedHashSet(); + + public String getId() { + return id; + } + + public int getSize() { + return size; + } + + public String getOsName() { + return osName; + } + + public String getOsType() { + return osType; + } + + public String getCreatorName() { + return creatorName; + } + + public String getRegistrant() { + return registrant; + } + + public String getLicenseInfo() { + return licenseInfo; + } + + public String getDescription() { + return description; + } + + public String getName() { + return name; + } + + public Set getSoftware() { + return software == null ? ImmutableSet. of() : ImmutableSet + .copyOf(software); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String id; + private String name; + private int size; + private String osName; + private String osType; + private String creatorName; + private String registrant; + private String licenseInfo; + private String description; + private Set software; + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder osName(String osName) { + this.osName = osName; + return this; + } + + public Builder osType(String osType) { + this.osType = osType; + return this; + } + + public Builder creatorName(String creatorName) { + this.creatorName = creatorName; + return this; + } + + public Builder registrant(String registrant) { + this.registrant = registrant; + return this; + } + + public Builder description(String description) { + this.description = description; + return this; + } + + public DiskImage build() { + DiskImage image = new DiskImage(); + + image.id = id; + image.name = name; + image.size = size; + image.osName = osName; + image.osType = osType; + image.creatorName = creatorName; + image.registrant = registrant; + image.licenseInfo = licenseInfo; + image.description = description; + image.software = software; + + return image; + } + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DiskImage that = DiskImage.class.cast(obj); + return Objects.equal(this.id, that.id); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("name", name).add("osName", osName).add("osType", osType) + .add("size", size).add("creatorName", creatorName) + .add("description", description) + .add("licenseInfo", licenseInfo).add("registrant", registrant) + .add("software", software).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ErrorStatistics.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ErrorStatistics.java new file mode 100644 index 0000000000..28cb1e764a --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ErrorStatistics.java @@ -0,0 +1,53 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.collect.ImmutableSet; + +/** + * Holds statistics of errors reported by a load balancer (SLB). + * + * @author Dies Koper + */ +@XmlRootElement(name = "errorstatistics") +public class ErrorStatistics { + private Period period; + private Set groups = new LinkedHashSet(); + + /** + * @return the period + */ + public Period getPeriod() { + return period; + } + + /** + * @return the groups + */ + public Set getGroups() { + return groups == null ? ImmutableSet. of() : ImmutableSet + .copyOf(groups); + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/EventLog.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/EventLog.java new file mode 100644 index 0000000000..bda7e2303e --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/EventLog.java @@ -0,0 +1,99 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Represents an entry in the event log. + * + * @author Dies Koper + */ +@XmlRootElement(name = "errorlog") +public class EventLog { + private String title; + private String message; + private String startDate; + private String expiry; + private String entryDate; + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * @return the startDate + */ + public String getStartDate() { + return startDate; + } + + /** + * @return the expiry + */ + public String getExpiry() { + return expiry; + } + + /** + * @return the entryDate + */ + public String getEntryDate() { + return entryDate; + } + + @Override + public int hashCode() { + return Objects.hashCode(entryDate, message, title); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + EventLog that = EventLog.class.cast(obj); + return Objects.equal(this.entryDate, that.entryDate) + && Objects.equal(this.message, that.message) + && Objects.equal(this.title, that.title); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("entryDate", entryDate).add("title", title) + .add("message", message).add("startDate", startDate) + .add("expiry", expiry).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Firewall.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Firewall.java new file mode 100644 index 0000000000..f466c054b1 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Firewall.java @@ -0,0 +1,133 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.collect.ImmutableSet; + +/** + * Represents a firewall (FW). + * + * @author Dies Koper + */ +@XmlRootElement(name = "fw") +public class Firewall { + private NAT nat; + private Set directions = new LinkedHashSet(); + private String log; + private String status; + private String category; + private String latestVersion; + private String comment; + private boolean firmUpdateExist; + private boolean configUpdateExist; + private String backout; + private String updateDate; + private String currentVersion; + + /** + * @return the nat + */ + public NAT getNat() { + return nat; + } + + /** + * @return the directions + */ + public Set getDirections() { + return directions == null ? ImmutableSet. of() + : ImmutableSet.copyOf(directions); + } + + /** + * @return the log + */ + public String getLog() { + return log; + } + + /** + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * @return the category + */ + public String getCategory() { + return category; + } + + /** + * @return the latestVersion + */ + public String getLatestVersion() { + return latestVersion; + } + + /** + * @return the comment + */ + public String getComment() { + return comment; + } + + /** + * @return the firmUpdateExist + */ + public boolean getFirmUpdateExist() { + return firmUpdateExist; + } + + /** + * @return the configUpdateExist + */ + public boolean getConfigUpdateExist() { + return configUpdateExist; + } + + /** + * @return the backout + */ + public String getBackout() { + return backout; + } + + /** + * @return the updateDate + */ + public String getUpdateDate() { + return updateDate; + } + + /** + * @return the currentVersion + */ + public String getCurrentVersion() { + return currentVersion; + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Group.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Group.java new file mode 100644 index 0000000000..40c36a4bbe --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Group.java @@ -0,0 +1,226 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlEnumValue; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Describes attributes of a software load balancer's (SLB) configuration. + * + * @author Dies Koper + */ +public class Group { + private int id; + + private String protocol; + + private int port1; + + private int port2; + + private String balanceType; + + private String uniqueType; + + private String monitorType; + + private int maxConnection; + + private int uniqueRetention; + + private int interval; + + private int timeout; + + private int retryCount; + + private int certNum; + + private Set causes; + + private RecoveryAction recoveryAction; + + private Set targets = new LinkedHashSet(); + + private String validity; + + enum RecoveryAction { + @XmlEnumValue("switch-back") + SWITCH_BACK, @XmlEnumValue("maintenance") + MAINTENANCE + } + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @return the protocol + */ + public String getProtocol() { + return protocol; + } + + /** + * @return the port1 + */ + public int getPort1() { + return port1; + } + + /** + * @return the port2 + */ + public int getPort2() { + return port2; + } + + /** + * @return the balanceType + */ + public String getBalanceType() { + return balanceType; + } + + /** + * @return the uniqueType + */ + public String getUniqueType() { + return uniqueType; + } + + /** + * @return the monitorType + */ + public String getMonitorType() { + return monitorType; + } + + /** + * @return the maxConnection + */ + public int getMaxConnection() { + return maxConnection; + } + + /** + * @return the uniqueRetention + */ + public int getUniqueRetention() { + return uniqueRetention; + } + + /** + * @return the interval + */ + public int getInterval() { + return interval; + } + + /** + * @return the timeout + */ + public int getTimeout() { + return timeout; + } + + /** + * @return the retryCount + */ + public int getRetryCount() { + return retryCount; + } + + /** + * @return the certNum + */ + public int getCertNum() { + return certNum; + } + + /** + * @return the causes + */ + public Set getCauses() { + return causes == null ? ImmutableSet. of() : ImmutableSet + .copyOf(causes); + } + + /** + * @return the recoveryAction + */ + public RecoveryAction getRecoveryAction() { + return recoveryAction; + } + + /** + * @return the targets + */ + public Set getTargets() { + return targets == null ? ImmutableSet. of() : ImmutableSet + .copyOf(targets); + } + + /** + * @return the validity + */ + public String getValidity() { + return validity; + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Group that = Group.class.cast(obj); + return Objects.equal(this.id, that.id); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("protocol", protocol).add("port1", port1) + .add("port2", port2).add("balanceType", balanceType) + .add("uniqueType", uniqueType).add("monitorType", monitorType) + .add("maxConnection", maxConnection) + .add("uniqueRetention", uniqueRetention) + .add("interval", interval).add("timeout", timeout) + .add("retryCount", retryCount).add("certNum", certNum) + .add("causes", causes).add("recoveryAction", recoveryAction) + .add("targets", targets).add("validity", validity).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Image.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Image.java new file mode 100644 index 0000000000..ed8fbacd31 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Image.java @@ -0,0 +1,114 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Holds information on the system disk image of a virtual server, including the + * OS and software pre-installed on it. + * + * @author Dies Koper + */ +public class Image { + private String id; + + private String serverCategory; + + private String serverApplication; + + private String cpuBit; + + private float sysvolSize; + + private int numOfMaxDisk; + + private int numOfMaxNic; + + @XmlElementWrapper(name = "softwares") + @XmlElement(name = "software") + private Set software = new LinkedHashSet(); + + public String getId() { + return id; + } + + public String getServerCategory() { + return serverCategory; + } + + public String getServerApplication() { + return serverApplication; + } + + public String getCpuBit() { + return cpuBit; + } + + public float getSysvolSize() { + return sysvolSize; + } + + public int getNumOfMaxDisk() { + return numOfMaxDisk; + } + + public int getNumOfMaxNic() { + return numOfMaxNic; + } + + public Set getSoftware() { + return software == null ? ImmutableSet. of() : ImmutableSet + .copyOf(software); + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Image that = Image.class.cast(obj); + return Objects.equal(this.id, that.id); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("serverCategory", serverCategory) + .add("serverApplication", serverApplication) + .add("cpuBit", cpuBit).add("sysvolSize", sysvolSize) + .add("numOfMaxDisk", numOfMaxDisk) + .add("numOfMaxNic", numOfMaxNic).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Information.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Information.java new file mode 100644 index 0000000000..a8a822f859 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Information.java @@ -0,0 +1,105 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import com.google.common.base.Objects; + +/** + * Holds information relating to the FGCP service. + * + * @author Dies Koper + */ +public class Information { + private int seqno; + private String title; + private String message; + private String startDate; + private String expiry; + private String entryDate; + + /** + * @return the seqno + */ + public int getSeqno() { + return seqno; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * @return the startDate + */ + public String getStartDate() { + return startDate; + } + + /** + * @return the expiry + */ + public String getExpiry() { + return expiry; + } + + /** + * @return the entryDate + */ + public String getEntryDate() { + return entryDate; + } + + @Override + public int hashCode() { + return Objects.hashCode(seqno, entryDate, message, title); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Information that = Information.class.cast(obj); + return Objects.equal(this.seqno, that.seqno) + && Objects.equal(this.entryDate, that.entryDate) + && Objects.equal(this.message, that.message) + && Objects.equal(this.title, that.title); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("seqno", seqno).add("entryDate", entryDate) + .add("title", title).add("message", message) + .add("startDate", startDate).add("expiry", expiry).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/IntermediateCACert.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/IntermediateCACert.java new file mode 100644 index 0000000000..7acc3871a0 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/IntermediateCACert.java @@ -0,0 +1,120 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Describes an intermediate CA certificate for use with a load balancer (SLB). + * + * @author Dies Koper + */ +@XmlRootElement(name = "ccacert") +public class IntermediateCACert implements Comparable { + private int ccacertNum; + + private String description; + + private String subject; + + private String issuer; + + private String validity; + + private String detail; + + /** + * @return the ccacertNum + */ + public int getCcacertNum() { + return ccacertNum; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @return the subject + */ + public String getSubject() { + return subject; + } + + /** + * @return the issuer + */ + public String getIssuer() { + return issuer; + } + + /** + * @return the validity + */ + public String getValidity() { + return validity; + } + + /** + * @return the detail + */ + public String getDetail() { + return detail; + } + + @Override + public int hashCode() { + return Objects.hashCode(ccacertNum, issuer, subject, validity); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + IntermediateCACert that = IntermediateCACert.class.cast(obj); + return Objects.equal(this.ccacertNum, that.ccacertNum) + && Objects.equal(this.issuer, that.issuer) + && Objects.equal(this.subject, that.subject) + && Objects.equal(this.validity, that.validity); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("ccacertNum", ccacertNum).add("issuer", issuer) + .add("subject", subject).add("validity", validity) + .add("description", description).add("detail", detail) + .toString(); + } + + @Override + public int compareTo(IntermediateCACert o) { + return ccacertNum - o.ccacertNum; + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/LoadStatistics.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/LoadStatistics.java new file mode 100644 index 0000000000..654e4fca5c --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/LoadStatistics.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Holds statistics of the load on a load balancer (SLB). + * + * @author Dies Koper + */ +@XmlRootElement(name = "loadstatistics") +public class LoadStatistics { + private Set groups = new LinkedHashSet(); + + /** + * @return the groups + */ + public Set getGroups() { + return groups == null ? ImmutableSet. of() : ImmutableSet + .copyOf(groups); + } + + @Override + public int hashCode() { + return Objects.hashCode(groups); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LoadStatistics that = LoadStatistics.class.cast(obj); + return Objects.equal(this.groups, that.groups); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("groups", groups).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Memory.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Memory.java new file mode 100644 index 0000000000..af3b0767b6 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Memory.java @@ -0,0 +1,66 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlElement; + +import com.google.common.base.Objects; + +/** + * Represents the memory of a virtual server. + * + * @author Dies Koper + */ +public class Memory implements Comparable { + @XmlElement(name = "memorySize") + private double size; + + public double getSize() { + return size; + } + + @Override + public int hashCode() { + return Objects.hashCode(size); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Memory that = Memory.class.cast(obj); + return Objects.equal(this.size, that.size); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("size", size) + .toString(); + } + + @Override + public int compareTo(Memory o) { + return Double.compare(size, o.size); + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/NAT.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/NAT.java new file mode 100644 index 0000000000..a753ed8395 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/NAT.java @@ -0,0 +1,65 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Holds the network address translation rules of a firewall. + * + * @author Dies Koper + */ +public class NAT { + private Set rules = new LinkedHashSet(); + + /** + * @return the rules + */ + public Set getRules() { + return rules == null ? ImmutableSet. of() : ImmutableSet + .copyOf(rules); + } + + @Override + public int hashCode() { + return Objects.hashCode(rules); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NAT that = NAT.class.cast(obj); + return Objects.equal(this.rules, that.rules); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("rules", rules).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PerformanceInfo.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PerformanceInfo.java new file mode 100644 index 0000000000..e9d9856182 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PerformanceInfo.java @@ -0,0 +1,149 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Holds the statistics of a virtual server. + * + * @author Dies Koper + */ +@XmlRootElement(name = "performanceinfo") +public class PerformanceInfo implements Comparable { + private long recordTime; + private double cpuUtilization; + private long diskReadRequestCount; + private long diskWriteRequestCount; + private long diskReadSector; + private long diskWriteSector; + private long nicInputByte; + private long nicOutputByte; + private long nicInputPacket; + private long nicOutputPacket; + + /** + * @return the recordTime + */ + public long getRecordTime() { + return recordTime; + } + + /** + * @return the cpuUtilization + */ + public double getCpuUtilization() { + return cpuUtilization; + } + + /** + * @return the diskReadRequestCount + */ + public long getDiskReadRequestCount() { + return diskReadRequestCount; + } + + /** + * @return the diskWriteRequestCount + */ + public long getDiskWriteRequestCount() { + return diskWriteRequestCount; + } + + /** + * @return the diskReadSector + */ + public long getDiskReadSector() { + return diskReadSector; + } + + /** + * @return the diskWriteSector + */ + public long getDiskWriteSector() { + return diskWriteSector; + } + + /** + * @return the nicInputByte + */ + public long getNicInputByte() { + return nicInputByte; + } + + /** + * @return the nicOutputByte + */ + public long getNicOutputByte() { + return nicOutputByte; + } + + /** + * @return the nicInputPacket + */ + public long getNicInputPacket() { + return nicInputPacket; + } + + /** + * @return the nicOutputPacket + */ + public long getNicOutputPacket() { + return nicOutputPacket; + } + + @Override + public int hashCode() { + return Objects.hashCode(recordTime); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PerformanceInfo that = PerformanceInfo.class.cast(obj); + return Objects.equal(this.recordTime, that.recordTime); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("recordTime", recordTime) + .add("cpuUtilization", cpuUtilization) + .add("diskReadRequestCount", diskReadRequestCount) + .add("diskWriteRequestCount", diskWriteRequestCount) + .add("diskReadSector", diskReadSector) + .add("diskWriteSector", diskWriteSector) + .add("nicInputByte", nicInputByte) + .add("nicOutputByte", nicOutputByte) + .add("nicInputPacket", nicInputPacket) + .add("nicOutputPacket", nicOutputPacket).toString(); + } + + @Override + public int compareTo(PerformanceInfo o) { + return (int) (recordTime - o.recordTime); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Period.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Period.java new file mode 100644 index 0000000000..b75173fe6c --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Period.java @@ -0,0 +1,61 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +/** + * Describes the period over which error statistics of a load balancer (SLB) are + * kept. + * + * @author Dies Koper + */ +public class Period { + private String current; + private String before; + private String today; + private String yesterday; + + /** + * @return the current + */ + public String getCurrent() { + return current; + } + + /** + * @return the before + */ + public String getBefore() { + return before; + } + + /** + * @return the today + */ + public String getToday() { + return today; + } + + /** + * @return the yesterday + */ + public String getYesterday() { + return yesterday; + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Policy.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Policy.java new file mode 100644 index 0000000000..e030c12793 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Policy.java @@ -0,0 +1,195 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlEnumValue; + +import com.google.common.base.Objects; + +/** + * Describes a firewall rule in detail. + * + * @author Dies Koper + */ +public class Policy implements Comparable { + private int id; + + private String src; + + private PolicyType srcType; + + private String srcPort; + + private Service dstService; + + private String dst; + + private PolicyType dstType; + + private String dstPort; + + private Protocol protocol; + + private Action action; + + private Log log; + + enum Service { + NONE, WSUS, DNS, NTP, @XmlEnumValue("yum") + YUM, KMS, @XmlEnumValue("Symantec") + SYMANTEC, RHUI + } + + enum PolicyType {IP, FQDN, FQDNF} + + enum Protocol { + @XmlEnumValue("tcp") + TCP, @XmlEnumValue("udp") + UDP, @XmlEnumValue("tcp-udp") + TCP_UDP, @XmlEnumValue("icmp") + ICMP + } + + enum Action { + @XmlEnumValue("Accept") + ACCEPT, @XmlEnumValue("Deny") + DENY + } + + enum Log { + @XmlEnumValue("On") + ON, @XmlEnumValue("Off") + OFF + } + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @return the src + */ + public String getSrc() { + return src; + } + + /** + * @return the srcType + */ + public PolicyType getSrcType() { + return srcType; + } + + /** + * @return the srcPort + */ + public String getSrcPort() { + return srcPort; + } + + /** + * @return the dstService + */ + public Service getDstService() { + return dstService; + } + + /** + * @return the dst + */ + public String getDst() { + return dst; + } + + /** + * @return the dstType + */ + public PolicyType getDstType() { + return dstType; + } + + /** + * @return the dstPort + */ + public String getDstPort() { + return dstPort; + } + + /** + * @return the protocol + */ + public Protocol getProtocol() { + return protocol; + } + + /** + * @return the action + */ + public Action getAction() { + return action; + } + + /** + * @return the log + */ + public Log getLog() { + return log; + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Policy that = Policy.class.cast(obj); + return Objects.equal(this.id, that.id); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("id", id) + .add("src", src) + .add("srcType", srcType) + .add("srcPort", srcPort) + .add("dstService", dstService) + .add("dst", dst) + .add("dstType", dstType) + .add("dstPort", dstPort) + .add("protocol", protocol) + .add("action", action) + .add("log", log).toString(); + } + + @Override + public int compareTo(Policy o) { + return id - o.id; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Product.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Product.java new file mode 100644 index 0000000000..447f81ea04 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Product.java @@ -0,0 +1,84 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlElement; + +import com.google.common.base.Objects; + +/** + * Represents a product for which usage information can be queried. + * + * @author Dies Koper + */ +public class Product { + @XmlElement(name = "productName") + private String name; + + private String unitName; + + private String usedPoints; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the unitName + */ + public String getUnitName() { + return unitName; + } + + /** + * @return the usedPoints + */ + public String getUsedPoints() { + return usedPoints; + } + + @Override + public int hashCode() { + return Objects.hashCode(name, unitName, usedPoints); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Product that = Product.class.cast(obj); + return Objects.equal(this.name, that.name) + && Objects.equal(this.unitName, that.unitName) + && Objects.equal(this.usedPoints, that.usedPoints); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("name", name) + .add("unitName", unitName).add("usedPoints", usedPoints) + .toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIP.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIP.java new file mode 100644 index 0000000000..698c462cee --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIP.java @@ -0,0 +1,94 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.xml.bind.annotation.XmlElement; + +import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; + +/** + * Represents a public IP address. + *

+ * A public IP address can be allocated to a virtual system, then needs to be + * enabled/attached before it can be mapped to a virtual server by configuring + * the NAT settings of virtual system's firewall. + * + * @author Dies Koper + */ +public class PublicIP { + + public static enum Version { + IPv4, IPv6, UNRECOGNIZED; + + @Override + public String toString() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, + name()); + } + + public static Version fromValue(String version) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to( + CaseFormat.UPPER_UNDERSCORE, + checkNotNull(version, "version"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + + } + + protected String address; + @XmlElement(name = "v4v6Flag") + protected Version version; + + public String getAddress() { + return address; + } + + public Version getVersion() { + return version; + } + + @Override + public int hashCode() { + return Objects.hashCode(address); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PublicIP that = PublicIP.class.cast(obj); + return Objects.equal(this.address, that.address); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("address", address).add("version", version).toString(); + } +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIPStatus.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIPStatus.java new file mode 100644 index 0000000000..3b10c95e35 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIPStatus.java @@ -0,0 +1,57 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.CaseFormat; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Possible statuses of a public IP address. + *

+ * An attached public IP address is enabled for a particular virtual system and + * or may not be mapped to a virtual server. + * + * @author Dies Koper + */ +@XmlRootElement(name = "publicipStatus") +public enum PublicIPStatus { + ATTACHED, ATTACHING, DETACHING, DETACHED, UNRECOGNIZED; + + public String value() { + return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); + } + + @Override + public String toString() { + return value(); + } + + public static PublicIPStatus fromValue(String status) { + try { + return valueOf(CaseFormat.UPPER_CAMEL + .to(CaseFormat.UPPER_UNDERSCORE, + checkNotNull(status, "status"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Rule.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Rule.java new file mode 100644 index 0000000000..6cd979822f --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Rule.java @@ -0,0 +1,84 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import com.google.common.base.Objects; + +/** + * Represents a network address translation or network address port translation + * rule. + *

+ * A rule either maps a public IP address to the NIC of a virtual server for + * incoming network traffic, or specifies the public IP address used as source + * address for traffic from all servers in the virtual system. + * + * @author Dies Koper + */ +public class Rule { + private String publicIp; + private String privateIp; + private boolean snapt; + + /** + * @return the publicIp + */ + public String getPublicIp() { + return publicIp; + } + + /** + * @return the privateIp + */ + public String getPrivateIp() { + return privateIp; + } + + /** + * @return the snapt + */ + public boolean isSnapt() { + return snapt; + } + + @Override + public int hashCode() { + return Objects.hashCode(privateIp, publicIp, snapt); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Rule that = Rule.class.cast(obj); + return Objects.equal(this.privateIp, that.privateIp) + && Objects.equal(this.publicIp, that.publicIp) + && Objects.equal(this.snapt, that.snapt); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("privateIp", privateIp).add("publicIp", publicIp) + .add("snapt", snapt).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/SLB.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/SLB.java new file mode 100644 index 0000000000..274c3b8caa --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/SLB.java @@ -0,0 +1,200 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.collect.ImmutableSet; + +/** + * Represents a software load balancer. + * + * @author Dies Koper + */ +@XmlRootElement(name = "slb") +public class SLB extends BuiltinServer { + private String ipAddress; + + private Set ccacerts = new LinkedHashSet(); + + private Set servercerts = new LinkedHashSet(); + + private Set groups; + + private String srcType; + + private String srcPort; + + private String status; + + private ErrorStatistics errorStatistics; + + private LoadStatistics loadStatistics; + + private String category; + + private String latestVersion; + + private String comment; + + private boolean firmUpdateExist; + + private boolean configUpdateExist; + + private boolean backout; + + private String updateDate; + + private String currentVersion; + + private String webAccelerator; + + /** + * @return the ipAddress + */ + public String getIpAddress() { + return ipAddress; + } + + /** + * @return the ccacerts + */ + public Set getCcacerts() { + return ccacerts == null ? ImmutableSet. of() + : ImmutableSet.copyOf(ccacerts); + } + + /** + * @return the servercerts + */ + public Set getServercerts() { + return servercerts == null ? ImmutableSet. of() + : ImmutableSet.copyOf(servercerts); + } + + /** + * @return the groups + */ + public Set getGroups() { + return groups == null ? ImmutableSet. of() : ImmutableSet + .copyOf(groups); + } + + /** + * @return the srcType + */ + public String getSrcType() { + return srcType; + } + + /** + * @return the srcPort + */ + public String getSrcPort() { + return srcPort; + } + + /** + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * @return the errorStatistics + */ + public ErrorStatistics getErrorStatistics() { + return errorStatistics; + } + + /** + * @return the loadStatistics + */ + public LoadStatistics getLoadStatistics() { + return loadStatistics; + } + + /** + * @return the category + */ + public String getCategory() { + return category; + } + + /** + * @return the latestVersion + */ + public String getLatestVersion() { + return latestVersion; + } + + /** + * @return the comment + */ + public String getComment() { + return comment; + } + + /** + * @return the firmUpdateExist + */ + public boolean getFirmUpdateExist() { + return firmUpdateExist; + } + + /** + * @return the configUpdateExist + */ + public boolean getConfigUpdateExist() { + return configUpdateExist; + } + + /** + * @return the backout + */ + public boolean getBackout() { + return backout; + } + + /** + * @return the updateDate + */ + public String getUpdateDate() { + return updateDate; + } + + /** + * @return the currentVersion + */ + public String getCurrentVersion() { + return currentVersion; + } + + /** + * @return the webAccelerator + */ + public String getWebAccelerator() { + return webAccelerator; + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerCert.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerCert.java new file mode 100644 index 0000000000..d1dfc0698f --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerCert.java @@ -0,0 +1,121 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Describes a server certificate for use with a load balancer (SLB). + * + * @author Dies Koper + */ +@XmlRootElement(name = "servercert") +public class ServerCert implements Comparable { + private int certNum; + + private String subject; + + private String issuer; + + private String validity; + + private int groupId; + + private String detail; + + /** + * @return the certNum + */ + public int getCertNum() { + return certNum; + } + + /** + * @return the subject + */ + public String getSubject() { + return subject; + } + + /** + * @return the issuer + */ + public String getIssuer() { + return issuer; + } + + /** + * @return the validity + */ + public String getValidity() { + return validity; + } + + /** + * @return the groupId + */ + public int getGroupId() { + return groupId; + } + + /** + * @return the detail + */ + public String getDetail() { + return detail; + } + + @Override + public int hashCode() { + return Objects.hashCode(certNum, groupId, issuer, subject, validity); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ServerCert that = ServerCert.class.cast(obj); + return Objects.equal(this.certNum, that.certNum) + && Objects.equal(this.groupId, that.groupId) + && Objects.equal(this.issuer, that.issuer) + && Objects.equal(this.subject, that.subject) + && Objects.equal(this.validity, that.validity); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("certNum", certNum).add("issuer", issuer) + .add("subject", subject).add("validity", validity) + .add("groupId", groupId).add("detail", detail).toString(); + } + + @Override + public int compareTo(ServerCert o) { + return (certNum - o.certNum) == 0 ? (groupId - o.groupId) + : (certNum - o.certNum); + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerType.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerType.java new file mode 100644 index 0000000000..b4a724809b --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerType.java @@ -0,0 +1,145 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * Describes the hardware of a virtual server. + * + * @author Dies Koper + */ +@XmlRootElement(name = "servertype") +public class ServerType implements Comparable { + private String id; + + private String name; + + private String label; + + private String comment; + + private String productId; + + private String productName; + + private String price; + + private String chargeType; + + private String expectedUsage; + + private CPU cpu; + + private Memory memory; + + @XmlElementWrapper(name = "disks") + @XmlElement(name = "disk") + private Set disks = Sets.newLinkedHashSet(); + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getLabel() { + return label; + } + + public String getComment() { + return comment; + } + + public String getProductId() { + return productId; + } + + public String getProductName() { + return productName; + } + + public String getPrice() { + return price; + } + + public String getChargeType() { + return chargeType; + } + + public String getExpectedUsage() { + return expectedUsage; + } + + public CPU getCpu() { + return cpu; + } + + public Memory getMemory() { + return memory; + } + + public Set getDisks() { + return disks == null ? ImmutableSet. of() : ImmutableSet + .copyOf(disks); + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ServerType that = ServerType.class.cast(obj); + return Objects.equal(this.id, that.id); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("name", name).add("label", label).add("comment", comment) + .add("productId", productId).add("productName", productName) + .add("price", price).add("chargeType", chargeType) + .add("expectedUsage", expectedUsage).add("cpu", cpu) + .add("memory", memory).add("disks", disks).toString(); + } + + @Override + public int compareTo(ServerType o) { + return memory == null ? -1 : memory.compareTo(o.memory); + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Software.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Software.java new file mode 100644 index 0000000000..cfff2a682e --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Software.java @@ -0,0 +1,103 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import com.google.common.base.Objects; + +/** + * Represents the software installed on a disk. + * + * @author Dies Koper + */ +public class Software { + private String name; + + private String id; + + private String category; + + private String version; + + private String officialVersion; + + private String patch; + + private String license; + + private String support; + + public String getName() { + return name; + } + + public String getId() { + return id; + } + + public String getCategory() { + return category; + } + + public String getVersion() { + return version; + } + + public String getOfficialVersion() { + return officialVersion; + } + + public String getPatch() { + return patch; + } + + public String getLicense() { + return license; + } + + public String getSupport() { + return support; + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Software that = Software.class.cast(obj); + return Objects.equal(this.id, that.id); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("name", name).add("category", category) + .add("version", version) + .add("officialVersion", officialVersion) + .add("support", support).add("patch", patch) + .add("license", license).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Target.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Target.java new file mode 100644 index 0000000000..44cd0fe727 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Target.java @@ -0,0 +1,126 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import com.google.common.base.Objects; + +/** + * Describes the target server of a load balancer. + * + * @author Dies Koper + */ +public class Target { + private String serverId; + + private String serverName; + + private String ipAddress; + + private String port1; + + private String port2; + + private String status; + + private String now; + + private String peak; + + /** + * @return the serverId + */ + public String getServerId() { + return serverId; + } + + /** + * @return the serverName + */ + public String getServerName() { + return serverName; + } + + /** + * @return the ipAddress + */ + public String getIpAddress() { + return ipAddress; + } + + /** + * @return the port1 + */ + public String getPort1() { + return port1; + } + + /** + * @return the port2 + */ + public String getPort2() { + return port2; + } + + /** + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * @return the now + */ + public String getNow() { + return now; + } + + /** + * @return the peak + */ + public String getPeak() { + return peak; + } + + @Override + public int hashCode() { + return Objects.hashCode(serverId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Target that = Target.class.cast(obj); + return Objects.equal(this.serverId, that.serverId); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("serverId", serverId).add("serverName", serverName) + .add("ipAddress", ipAddress).add("port1", port1) + .add("port2", port2).add("status", status).add("now", now) + .add("peak", peak).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/UsageInfo.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/UsageInfo.java new file mode 100644 index 0000000000..48cffa4b05 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/UsageInfo.java @@ -0,0 +1,94 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Describes the usage by a virtual system. + * + * @author Dies Koper + */ +@XmlRootElement(name = "usageinfo") +public class UsageInfo { + @XmlElement(name = "vsysId") + private String systemId; + @XmlElement(name = "vsysName") + private String systemName; + + @XmlElementWrapper(name = "products") + @XmlElement(name = "product") + private Set products = new LinkedHashSet(); + + /** + * @return the systemId + */ + public String getSystemId() { + return systemId; + } + + /** + * @return the systemName + */ + public String getSystemName() { + return systemName; + } + + /** + * @return the products + */ + public Set getProducts() { + return products == null ? ImmutableSet. of() : ImmutableSet + .copyOf(products); + } + + @Override + public int hashCode() { + return Objects.hashCode(systemId, systemName, products); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + UsageInfo that = UsageInfo.class.cast(obj); + return Objects.equal(this.systemId, that.systemId) + && Objects.equal(this.systemName, that.systemName) + && Objects.equal(this.products, that.products); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("systemId", systemId).add("systemName", systemName) + .add("products", products).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDisk.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDisk.java new file mode 100644 index 0000000000..e8784c4a98 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDisk.java @@ -0,0 +1,86 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Represents attachable storage in the form of a virtual disk. + * + * @author Dies Koper + */ +@XmlRootElement(name = "vdisk") +public class VDisk { + @XmlElement(name = "diskId") + private String id; + @XmlElement(name = "diskName") + private String name; + @XmlElement(name = "attachedTo") + private String attachedServer; + private String creator; + private double size; + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getAttachedServer() { + return attachedServer; + } + + public String getCreator() { + return creator; + } + + public double getSize() { + return size; + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + VDisk that = VDisk.class.cast(obj); + return Objects.equal(this.id, that.id); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("name", name).add("attachedServer", attachedServer) + .add("creator", creator).add("size", size).toString(); + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDiskStatus.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDiskStatus.java new file mode 100644 index 0000000000..cc4459426c --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDiskStatus.java @@ -0,0 +1,55 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.CaseFormat; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Possible statuses of an attachable virtual disk. + * + * @author Dies Koper + */ +@XmlRootElement(name = "vdiskStatus") +public enum VDiskStatus { + + NORMAL, BACKUP_ING, DEPLOYING, DETACHING, ATTACHING, RESTORING, ERROR, UNRECOGNIZED; + + public String value() { + return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); + } + + @Override + public String toString() { + return value(); + } + + public static VDiskStatus fromValue(String status) { + try { + return valueOf(CaseFormat.UPPER_CAMEL + .to(CaseFormat.UPPER_UNDERSCORE, + checkNotNull(status, "status"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNIC.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNIC.java new file mode 100644 index 0000000000..6fbf0770c2 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNIC.java @@ -0,0 +1,73 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Represents a virtual network interface card (NIC). + * + * @author Dies Koper + */ +@XmlRootElement(name = "vnic") +public class VNIC { + private String networkId; + + private String privateIp; + + private int nicNo; + + public String getNetworkId() { + return networkId; + } + + public String getPrivateIp() { + return privateIp; + } + + public int getNicNo() { + return nicNo; + } + + @Override + public int hashCode() { + return Objects.hashCode(networkId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + VNIC that = VNIC.class.cast(obj); + return Objects.equal(this.networkId, that.networkId); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues() + .add("networkId", networkId).add("privateIp", privateIp) + .add("nicNo", nicNo).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNet.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNet.java new file mode 100644 index 0000000000..77210c146e --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNet.java @@ -0,0 +1,61 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Represents a virtual network. + * + * @author Dies Koper + */ +@XmlRootElement(name = "vnet") +public class VNet { + + private String networkId; + + public String getNetworkId() { + return networkId; + } + + @Override + public int hashCode() { + return Objects.hashCode(networkId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + VNet that = VNet.class.cast(obj); + return Objects.equal(this.networkId, that.networkId); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).add("networkId", networkId) + .toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServer.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServer.java new file mode 100644 index 0000000000..b3db2991cc --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServer.java @@ -0,0 +1,84 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlElement; + +import com.google.common.base.Objects; + +/** + * Represents a virtual server. + * + * @author Dies Koper + */ +public class VServer { + @XmlElement(name = "vserverId") + protected String id; + @XmlElement(name = "vserverName") + protected String name; + @XmlElement(name = "vserverType") + protected String type; + protected String diskimageId; + protected String creator; + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getType() { + return type; + } + + public String getDiskimageId() { + return diskimageId; + } + + public String getCreator() { + return creator; + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + VServer that = VServer.class.cast(obj); + return Objects.equal(this.id, that.id); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("name", name).add("type", type).add("creator", creator) + .add("diskimageId", diskimageId).toString(); + } + +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerStatus.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerStatus.java new file mode 100644 index 0000000000..8576538965 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerStatus.java @@ -0,0 +1,54 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.CaseFormat; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Possible statuses of a virtual server. + * + * @author Dies Koper + */ +@XmlRootElement(name = "vserverStatus") +public enum VServerStatus { + DEPLOYING, RUNNING, STOPPING, STOPPED, STARTING, FAILOVER, UNEXPECTED_STOP, RESTORING, BACKUP_ING, ERROR, START_ERROR, STOP_ERROR, CHANGE_TYPE, REGISTERING, UNRECOGNIZED; + + public String value() { + return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); + } + + @Override + public String toString() { + return value(); + } + + public static VServerStatus fromValue(String status) { + try { + return valueOf(CaseFormat.UPPER_CAMEL + .to(CaseFormat.UPPER_UNDERSCORE, + checkNotNull(status, "status"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithDetails.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithDetails.java new file mode 100644 index 0000000000..d9613a41c2 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithDetails.java @@ -0,0 +1,59 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Represents a virtual server with virtual storage and NICs. + * + * @author Dies Koper + */ +@XmlRootElement(name = "vserver") +public class VServerWithDetails extends VServerWithVNICs { + @XmlElementWrapper(name = "vdisks") + @XmlElement(name = "vdisk") + protected Set vdisks = new LinkedHashSet(); + protected Image image; + + public Set getVdisks() { + return vdisks == null ? ImmutableSet. of() : ImmutableSet + .copyOf(vdisks); + } + + public Image getImage() { + return image; + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("name", name).add("type", type).add("creator", creator) + .add("diskimageId", diskimageId).add("vdisks", vdisks) + .add("vnics", vnics).add("image", image).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithVNICs.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithVNICs.java new file mode 100644 index 0000000000..3117241320 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithVNICs.java @@ -0,0 +1,29 @@ +package org.jclouds.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +public class VServerWithVNICs extends VServer { + + @XmlElementWrapper(name = "vnics") + @XmlElement(name = "vnic") + protected Set vnics = new LinkedHashSet(); + + public Set getVnics() { + return vnics == null ? ImmutableSet. of() : ImmutableSet + .copyOf(vnics); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("name", name).add("type", type).add("creator", creator) + .add("diskimageId", diskimageId).add("vnics", vnics).toString(); + } +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystem.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystem.java new file mode 100644 index 0000000000..ae86034ce3 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystem.java @@ -0,0 +1,84 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlElement; + +import com.google.common.base.Objects; + +/** + * Represents a virtual system. + * + * @author Dies Koper + */ +public class VSystem { + @XmlElement(name = "vsysId") + protected String id; + @XmlElement(name = "vsysName") + protected String name; + protected String creator; + @XmlElement(name = "baseDescriptor") + protected String template; + protected String description; + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getCreator() { + return creator; + } + + public String getTemplate() { + return template; + } + + public String getDescription() { + return description; + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + VSystem that = VSystem.class.cast(obj); + return Objects.equal(this.id, that.id); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("name", name).add("creator", creator) + .add("template", template).add("description", description) + .toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemDescriptor.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemDescriptor.java new file mode 100644 index 0000000000..46f448ab9d --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemDescriptor.java @@ -0,0 +1,104 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.collect.ImmutableSet; + +/** + * Describes a virtual system template. + * + * @author Dies Koper + */ +@XmlRootElement(name = "vsysdescriptor") +public class VSystemDescriptor { + @XmlElement(name = "vsysdescriptorId") + private String id; + + @XmlElement(name = "vsysdescriptorName") + private String name; + + private String creatorName; + + private String registrant; + + private String description; + + private String keyword; + + @XmlElementWrapper(name = "vservers") + @XmlElement(name = "vserver") + private Set servers = new LinkedHashSet(); + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the creatorName + */ + public String getCreatorName() { + return creatorName; + } + + /** + * @return the registrant + */ + public String getRegistrant() { + return registrant; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @return the keyword + */ + public String getKeyword() { + return keyword; + } + + /** + * @return the servers + */ + public Set getServers() { + return servers == null ? ImmutableSet. of() + : ImmutableSet.copyOf(servers); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemStatus.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemStatus.java new file mode 100644 index 0000000000..58e6e7a048 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemStatus.java @@ -0,0 +1,54 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.CaseFormat; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Possible statuses of a virtual system. + * + * @author Dies Koper + */ +@XmlRootElement(name = "vsysStatus") +public enum VSystemStatus { + NORMAL, RECONFIG_ING, DEPLOYING, ERROR, UNRECOGNIZED; + + public String value() { + return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); + } + + @Override + public String toString() { + return value(); + } + + public static VSystemStatus fromValue(String status) { + try { + return valueOf(CaseFormat.UPPER_CAMEL + .to(CaseFormat.UPPER_UNDERSCORE, + checkNotNull(status, "status"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemWithDetails.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemWithDetails.java new file mode 100644 index 0000000000..16839889a7 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemWithDetails.java @@ -0,0 +1,80 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.domain; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Represents a virtual system with servers, additional storage, public IP + * addresses and networks. + * + * @author Dies Koper + */ +@XmlRootElement(name = "vsys") +public class VSystemWithDetails extends VSystem { + @XmlElementWrapper(name = "vservers") + @XmlElement(name = "vserver") + private Set servers = new LinkedHashSet(); + @XmlElementWrapper(name = "vdisks") + @XmlElement(name = "vdisk") + private Set disks = new LinkedHashSet(); + @XmlElementWrapper(name = "publicips") + @XmlElement(name = "publicip") + private Set publicips = new LinkedHashSet(); + @XmlElementWrapper(name = "vnets") + @XmlElement(name = "vnet") + private Set networks = new LinkedHashSet(); + + public Set getServers() { + return servers == null ? ImmutableSet. of() : ImmutableSet + .copyOf(servers); + } + + public Set getDisks() { + return disks == null ? ImmutableSet. of() : ImmutableSet + .copyOf(disks); + } + + public Set getPublicips() { + return publicips == null ? ImmutableSet. of() : ImmutableSet + .copyOf(publicips); + } + + public Set getNetworks() { + return networks == null ? ImmutableSet. of() : ImmutableSet + .copyOf(networks); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("id", id) + .add("name", name).add("creator", creator) + .add("template", template).add("description", description) + .add("disks", disks).add("networks", networks) + .add("publicips", publicips).add("servers", servers).toString(); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/package-info.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/package-info.java new file mode 100644 index 0000000000..4f79fc1182 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/package-info.java @@ -0,0 +1,26 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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. + */ +@XmlSchema(namespace = "http://apioviss.jp.fujitsu.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@XmlAccessorType(XmlAccessType.FIELD) +package org.jclouds.fujitsu.fgcp.domain; + +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlSchema; + diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/filters/RequestAuthenticator.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/filters/RequestAuthenticator.java new file mode 100644 index 0000000000..9fecf69ca3 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/filters/RequestAuthenticator.java @@ -0,0 +1,242 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.filters; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.security.InvalidKeyException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.Signature; +import java.security.UnrecoverableKeyException; +import java.util.Calendar; +import java.util.Locale; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; +import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; + +import org.jclouds.Constants; +import org.jclouds.crypto.CryptoStreams; +import org.jclouds.date.TimeStamp; +import org.jclouds.encryption.internal.Base64; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.http.HttpException; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpRequestFilter; +import org.jclouds.http.HttpUtils; +import org.jclouds.http.internal.SignatureWire; +import org.jclouds.http.utils.Queries; +import org.jclouds.logging.Logger; +import org.jclouds.rest.RequestSigner; +import org.jclouds.rest.annotations.ApiVersion; +import org.jclouds.rest.annotations.Credential; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.Multimap; + +/** + * Generates and signs the access key id and adds the mandatory http header and + * request parameters to the request. + * + * @author Dies Koper + */ +@Singleton +public class RequestAuthenticator implements HttpRequestFilter, RequestSigner { + + @Resource + @Named(Constants.LOGGER_SIGNATURE) + private Logger signatureLog = Logger.NULL; + + final Provider calendarProvider; + final Signature signer; + final Provider builder; + final String apiVersion; + + public String signatureVersion = "1.0"; + public String signatureMethod = "SHA1withRSA"; + + private HttpUtils utils; + + @Inject + public RequestAuthenticator(@TimeStamp Provider calendarProvider, + Provider keyStoreProvider, + @Credential String keyPassword, Provider builder, + HttpUtils utils, SignatureWire signatureWire, + @ApiVersion String apiVersion) throws NoSuchAlgorithmException, + InvalidKeyException, KeyStoreException, UnrecoverableKeyException { + this.calendarProvider = checkNotNull(calendarProvider); + this.builder = checkNotNull(builder); + this.utils = checkNotNull(utils, "utils"); + this.apiVersion = checkNotNull(apiVersion, "apiVersion"); + + signer = Signature.getInstance(signatureMethod); + + KeyStore keyStore = checkNotNull(keyStoreProvider).get(); + String alias = keyStore.aliases().nextElement(); // there should be only + // one private key + PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, + keyPassword.toCharArray()); + + signer.initSign(privateKey); + } + + public HttpRequest filter(HttpRequest request) throws HttpException { + checkNotNull(request, "request must be present"); + + utils.logRequest(signatureLog, request, ">>"); + + // create accesskeyid + String accessKeyId = createStringToSign(request); + String signature = sign(accessKeyId); + + // leaving this in for now for reference in case I need it for multipart + // POSTs + // add parameters. Note that in case of a GET, url escaping is required + /* + * Multimap decodedParams = null; if + * (HttpMethod.GET.equals(request.getMethod())) { decodedParams = + * ModifyRequest.parseQueryToMap(request.getEndpoint().getRawQuery()); + * + * } else if (HttpMethod.POST.equals(request.getMethod())) { + * decodedParams = + * ModifyRequest.parseQueryToMap(request.getPayload().getRawContent() + * .toString()); } + * + * checkNotNull(decodedParams, "no query params found"); + * System.out.println("filter: request params before: " + + * decodedParams.toString()); addAuthenticationParams(decodedParams, + * accessKeyId, signature); addLocaleParam(decodedParams); + * System.out.println("filter: request params after : " + + * decodedParams.toString()); if (signatureWire.enabled()) + * signatureWire.output(decodedParams); + * + * + * request = setPayload(request, decodedParams); + */ + // only "en" and "ja" are allowed + String lang = Locale.JAPANESE.getLanguage().equals( + Locale.getDefault().getLanguage()) ? Locale.JAPANESE + .getLanguage() : Locale.ENGLISH.getLanguage(); + + if (HttpMethod.GET.equals(request.getMethod())) { + Multimap decodedParams = Queries + .parseQueryToMap(request.getEndpoint().getRawQuery()); + + if (!decodedParams.containsKey(RequestParameters.VERSION)) { + decodedParams.put(RequestParameters.VERSION, apiVersion); + } + decodedParams.put(RequestParameters.LOCALE, lang); + decodedParams.put(RequestParameters.ACCESS_KEY_ID, accessKeyId); + decodedParams.put(RequestParameters.SIGNATURE, signature); + request = request.toBuilder().replaceQueryParams(decodedParams) + .build(); + } else { + + String payload = request.getPayload().getRawContent().toString(); + payload = createXmlElementWithValue(payload, + RequestParameters.VERSION, apiVersion); + payload = createXmlElementWithValue(payload, + RequestParameters.LOCALE, lang); + payload = createXmlElementWithValue(payload, + RequestParameters.ACCESS_KEY_ID, accessKeyId); + payload = createXmlElementWithValue(payload, + RequestParameters.SIGNATURE, signature); + + // ensure there are no other query params left + request.setPayload(payload); + request.getPayload().getContentMetadata() + .setContentType(MediaType.TEXT_XML); + } + + // may need to do this elsewhere (see ConvertToGaeRequest) + HttpRequest filteredRequest = request.toBuilder() + .replaceHeader(HttpHeaders.USER_AGENT, "OViSS-API-CLIENT") + .build(); + + utils.logRequest(signatureLog, filteredRequest, ">>->"); + + return filteredRequest; + } + + String createXmlElementWithValue(String payload, String tag, String value) { + String startTag = String.format("<%s>", tag); + String endTag = String.format("", tag); + + return payload.replace(startTag + endTag, startTag + value + endTag); + } + + /* + * HttpRequest setPayload(HttpRequest request, Multimap + * decodedParams) { + * request.setPayload(ModifyRequest.makeQueryLine(decodedParams, null)); // + * request.getPayload().getContentMetadata().setContentType( + * "application/x-www-form-urlencoded"); return request; } + */ + + @VisibleForTesting + public String sign(String stringToSign) { + String signed; + + try { + signer.update(stringToSign.getBytes("UTF-8")); + signed = Base64.encodeBytes(signer.sign()).replace("\n", "\r\n"); +// signed = CryptoStreams.base64(signer.sign()); + } catch (Exception e) { + throw new HttpException("error signing request", e); + } + // if (signatureWire.enabled()) + // signatureWire.input(Strings2.toInputStream(signed)); + + return signed; + } + + @VisibleForTesting + public String generateAccessKeyId() { + Calendar cal = calendarProvider.get(); + String timezone = cal.getTimeZone().getDisplayName(Locale.ENGLISH); + String expires = String.valueOf(cal.getTime().getTime()); + + String signatureData = String.format("%s&%s&%s&%s", timezone, expires, + signatureVersion, signatureMethod); + try { + String accessKeyId = Base64.encodeBytes(signatureData.getBytes("UTF-8")); + return accessKeyId.replace("\n", "\r\n"); +// return CryptoStreams.base64(signatureData.getBytes("UTF-8")).; + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); // should never happen as + // signatureData contains only ASCII + } + } + + @Override + public String createStringToSign(HttpRequest input) { + return generateAccessKeyId(); + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/handlers/FGCPRetryIfNotProxyAuthenticationFailureHandler.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/handlers/FGCPRetryIfNotProxyAuthenticationFailureHandler.java new file mode 100644 index 0000000000..0104aaf61c --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/handlers/FGCPRetryIfNotProxyAuthenticationFailureHandler.java @@ -0,0 +1,47 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.handlers; + +import com.google.inject.Singleton; +import org.jclouds.http.HttpCommand; +import org.jclouds.http.HttpResponse; +import org.jclouds.http.HttpRetryHandler; +import org.jclouds.logging.Logger; + +import javax.annotation.Resource; + +/** + * Created by IntelliJ IDEA. + * + * @author Dies Koper + */ +@Singleton +public class FGCPRetryIfNotProxyAuthenticationFailureHandler implements + HttpRetryHandler { + @Resource + protected Logger logger = Logger.NULL; + + @Override + public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { + int statusCode = response.getStatusCode(); + System.out.println("Response status code: " + statusCode); + logger.error("StatusCode", statusCode); + return true; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/http/SSLContextWithKeysSupplier.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/http/SSLContextWithKeysSupplier.java new file mode 100644 index 0000000000..c0e20196a5 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/http/SSLContextWithKeysSupplier.java @@ -0,0 +1,71 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.http; + +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.UnrecoverableKeyException; + +import javax.inject.Inject; +import javax.inject.Singleton; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; + +import org.jclouds.http.HttpUtils; +import org.jclouds.http.config.SSLModule.TrustAllCerts; +import org.jclouds.rest.annotations.Credential; + +import com.google.common.base.Supplier; + +/** + * SSLContext supplier with a configured key manager to enable client + * authentication with certificates. + * + * @author Dies Koper + */ +@Singleton +public class SSLContextWithKeysSupplier implements Supplier { + private SSLContext sc; + + @Inject + SSLContextWithKeysSupplier(KeyStore keyStore, + @Credential String keyStorePassword, HttpUtils utils, + TrustAllCerts trustAllCerts) throws NoSuchAlgorithmException, + KeyStoreException, UnrecoverableKeyException, + KeyManagementException { + + TrustManager[] trustManager = null; + if (utils.trustAllCerts()) { + trustManager = new TrustManager[] { trustAllCerts }; + } + KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(keyStore, keyStorePassword.toCharArray()); + sc = SSLContext.getInstance("TLS"); + sc.init(kmf.getKeyManagers(), trustManager, new SecureRandom()); + } + + @Override + public SSLContext get() { + return sc; + } +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/location/SystemAndNetworkSegmentToLocationSupplier.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/location/SystemAndNetworkSegmentToLocationSupplier.java new file mode 100644 index 0000000000..569d3aedb8 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/location/SystemAndNetworkSegmentToLocationSupplier.java @@ -0,0 +1,120 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.location; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ExecutionException; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.domain.Location; +import org.jclouds.domain.LocationBuilder; +import org.jclouds.domain.LocationScope; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.domain.VNet; +import org.jclouds.fujitsu.fgcp.domain.VSystem; +import org.jclouds.fujitsu.fgcp.domain.VSystemWithDetails; +import org.jclouds.location.suppliers.LocationsSupplier; +import org.jclouds.location.suppliers.all.RegionToProviderOrJustProvider; + +import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; +import com.google.common.collect.Iterables; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Builds location hierarchy by querying the back-end for the networks of all + * virtual systems. + *

+ * Example: + *

+ * + *

+ * >location provider fgcp(-au)
+ * -> location region au/nsw
+ * --> location system vsys
+ * ---> location network DMZ/SECURE1/SECURE2
+ * 
+ * + * Todo: caching - provider/region won't change. if vsys still exists, network + * won't change + * + * @author Dies Koper + */ +@Singleton +public class SystemAndNetworkSegmentToLocationSupplier implements + LocationsSupplier { + + private final RegionToProviderOrJustProvider regionProvider; + private FGCPAsyncApi api; + + @Inject + SystemAndNetworkSegmentToLocationSupplier( + RegionToProviderOrJustProvider regionProvider, FGCPAsyncApi api) { + this.regionProvider = checkNotNull(regionProvider, + "regionToProviderOrJustProvider"); + this.api = checkNotNull(api, "api"); + } + + @Override + public Set get() { + Builder locations = ImmutableSet.builder(); + try { + List> futures = new ArrayList>(); + for (VSystem system : api.getVirtualDCApi().listVirtualSystems() + .get()) { + + futures.add(api.getVirtualSystemApi() + .getDetails(system.getId())); + } + for (VSystemWithDetails system : Futures.successfulAsList(futures) + .get()) { + + Location systemLocation = new LocationBuilder() + .scope(LocationScope.SYSTEM) + .parent(Iterables.getOnlyElement(regionProvider.get())) + .description(system.getName()).id(system.getId()) + .build(); + + for (VNet net : system.getNetworks()) { + + locations.add(new LocationBuilder() + .scope(LocationScope.NETWORK) + .parent(systemLocation) + .description( + net.getNetworkId().replaceFirst( + ".+(DMZ|SECURE.)", "\\1")) + .id(net.getNetworkId()).build()); + } + } + } catch (InterruptedException e) { + throw Throwables.propagate(e); + } catch (ExecutionException e) { + throw Throwables.propagate(e); + } + return locations.build(); + } +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/reference/RequestParameters.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/reference/RequestParameters.java new file mode 100644 index 0000000000..d4870c540d --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/reference/RequestParameters.java @@ -0,0 +1,81 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.reference; + +/** + * Configuration parameters and constants used in HTTP requests. + * + * @author Dies Koper + */ +public interface RequestParameters { + + /** + * Indicates the action to perform. Example: ListVSYS + */ + public static final String ACTION = "Action"; + + /** + * The API version to use. Example: 2011-01-31 + */ + public static final String VERSION = "Version"; + + /** + * The locale to use. Example: en + */ + public static final String LOCALE = "Locale"; + + /** + * The Access Key ID for the request sender. This identifies the account + * which will be charged for usage of the service. The account with which + * the Access Key ID is associated must be signed up for FGCP, or requests + * will not be accepted. AKIADQKE4SARGYLE + */ + public static final String ACCESS_KEY_ID = "AccessKeyId"; + + /** + * The date and time at which the request is signed, in the format + * YYYY-MM-DDThh:mm:ssZ. For more information, go to ISO 8601. Example: + * 2006-07-07T15:04:56Z + */ + public static final String TIMESTAMP = "Timestamp"; + + /** + * The date and time at which the signer included in the request expires, in + * the format YYYY-MM-DDThh:mm:ssZ. Example: 2006-07-07T15:04:56Z + */ + public static final String EXPIRES = "Expires"; + + /** + * The request signer. For more information, go to the Amazon Elastic + * Compute Cloud Developer Guide. Example: Qnpl4Qk/7tINHzfXCiT7VbBatDA= + */ + public static final String SIGNATURE = "Signature"; + + /** + * The hash algorithm you use to create the request signer. Valid value: + * SHA1withRSA. + */ + public static final String SIGNATURE_METHOD = "SignatureMethod"; + + /** + * The signer version you use to sign the request. Set this value to 1.0. + * + */ + public static final String SIGNATURE_VERSION = "SignatureVersion"; +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApi.java new file mode 100644 index 0000000000..2b4cbb658a --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApi.java @@ -0,0 +1,53 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.domain.VDisk; +import org.jclouds.fujitsu.fgcp.domain.VDiskStatus; + +/** + * API relating to additional storage. + * + * @author Dies Koper + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface AdditionalDiskApi { + + VDiskStatus getStatus(String id); + + VDisk get(String id); + + void update(String id, String name, String value); + + void backup(String id); + + void restore(String systemId, String backupId); + + void destroy(String id); + + void detach(String diskId, String serverId); + + void destroyBackup(String sysId, String backupId); + + // Set<> listBackups(String sysId); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskAsyncApi.java new file mode 100644 index 0000000000..440be5baf9 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskAsyncApi.java @@ -0,0 +1,112 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.binders.BindAlsoToSystemId; +import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; +import org.jclouds.fujitsu.fgcp.domain.VDisk; +import org.jclouds.fujitsu.fgcp.domain.VDiskStatus; +import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Transform; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Non-blocking API relating to additional storage. + * + * @author Dies Koper + */ +@RequestFilters(RequestAuthenticator.class) +@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@Consumes(MediaType.TEXT_XML) +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface AdditionalDiskAsyncApi { + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetVDiskStatus") + @Transform(SingleElementResponseToElement.class) + ListenableFuture getStatus( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetVDiskAttributes") + @Transform(SingleElementResponseToElement.class) + ListenableFuture get( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String id); + + @GET + @QueryParams(keys = "Action", values = "UpdateVDiskAttribute") + ListenableFuture update( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String id, + @QueryParam("attributeName") String name, + @QueryParam("attributeValue") String value); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "BackupVDisk") + ListenableFuture backup( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "RestoreVDisk") + ListenableFuture restore(@QueryParam("vsysId") String systemId, + @QueryParam("backupId") String backupId); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "DestroyVDisk") + ListenableFuture destroy( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "DetachVDisk") + ListenableFuture detach( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String diskId, + @QueryParam("vserverId") String serverId); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "DestroyVDiskBackup") + ListenableFuture destroyBackup(@QueryParam("vsysId") String sysId, + @QueryParam("backupId") String backupId); + + // Set<> listBackups(String sysId); + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApi.java new file mode 100644 index 0000000000..274b1fbce3 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApi.java @@ -0,0 +1,73 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerBackup; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerConfiguration; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerStatus; + +/** + * API relating to built-in servers, also called extended function module (EFM), + * such as a firewall or load balancer (SLB). + * + * @author Dies Koper + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface BuiltinServerApi { + + void start(String id); + + void stop(String id); + + void destroy(String id); + + void backup(String id); + + void restore(String id, String backupId); + + Set listBackups(String id); + + void destroyBackup(String id, String backupId); + + BuiltinServer get(String id); + + void update(String id, String name, String value); + + BuiltinServerStatus getStatus(String id); + + BuiltinServer getConfiguration(String id, BuiltinServerConfiguration configuration); + + // BuiltinServer getConfiguration(String id, BuiltinServerConfiguration configuration, ConfigurationRequest request); + // void updateConfiguration(String id, xml?); + /* +getDNSConfiguration(String id) +getNATConfiguration(String id) +getPolicyConfiguration(String id) +getLBConfiguration(String id) + + * UpdateEFMConfiguration + BuiltinServer getConfiguration(String id, BuiltinServerConfiguration configuration); + + */ +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerAsyncApi.java new file mode 100644 index 0000000000..569577fc4d --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerAsyncApi.java @@ -0,0 +1,145 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.binders.BindAlsoToSystemId; +import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerBackup; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerConfiguration; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerStatus; +import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Transform; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Non-blocking API relating to built-in servers, also called extended function + * module (EFM), such as a firewall or load balancer (SLB). + * + * @author Dies Koper + */ +@RequestFilters(RequestAuthenticator.class) +@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@Consumes(MediaType.TEXT_XML) +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface BuiltinServerAsyncApi { + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "StartEFM") + ListenableFuture start( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "StopEFM") + ListenableFuture stop( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "DestroyEFM") + ListenableFuture destroy( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "BackupEFM") + ListenableFuture backup( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "RestoreEFM") + ListenableFuture restore( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id, + @QueryParam("backupId") String backupId); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "ListEFMBackup") + ListenableFuture> listBackups( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "DestroyEFMBackup") + ListenableFuture destroyBackup( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id, + @QueryParam("backupId") String backupId); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetEFMAttributes") + @Transform(SingleElementResponseToElement.class) + ListenableFuture get( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "UpdateEFMAttribute") + ListenableFuture update( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id, + @QueryParam("attributeName") String name, + @QueryParam("attributeValue") String value); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetEFMStatus") + @Transform(SingleElementResponseToElement.class) + ListenableFuture getStatus( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetEFMConfiguration") + @Transform(SingleElementResponseToElement.class) + ListenableFuture getConfiguration( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id, + @QueryParam("configurationName") BuiltinServerConfiguration configuration); + +// @POST +// @JAXBResponseParser +// @QueryParams(keys = "Action", values = "GetEFMConfiguration") +// @Transform(SingleElementResponseToElement.class) +// ListenableFuture> getUpdateDetails(String id); + + // ListenableFuture + // updateConfiguration(@BinderParam(BindAlsoToSystemId.class) + // @QueryParam("efmId") String id, xml?); +// EFM_UPDATE, getUpdateStatus(String id); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageApi.java new file mode 100644 index 0000000000..610e61dbeb --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageApi.java @@ -0,0 +1,39 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.domain.DiskImage; + +/** + * API relating to disk images. + * + * @author Dies Koper + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface DiskImageApi { + + DiskImage get(String id); + + void update(String diskImageId, String localeId, String name, String value); + + void deregister(String id); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageAsyncApi.java new file mode 100644 index 0000000000..9b4d613f2f --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageAsyncApi.java @@ -0,0 +1,73 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; +import org.jclouds.fujitsu.fgcp.domain.DiskImage; +import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Transform; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Non-blocking API relating to disk images. + * + * @author Dies Koper + */ +@RequestFilters(RequestAuthenticator.class) +@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@Consumes(MediaType.TEXT_XML) +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface DiskImageAsyncApi { + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetDiskImageAttributes") + @Transform(SingleElementResponseToElement.class) + ListenableFuture get(@QueryParam("diskImageId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "UpdateDiskImageAttribute") + ListenableFuture update( + @QueryParam("diskImageId") String diskImageId, + @QueryParam("updateLcId") String localeId, + @QueryParam("attributeName") String name, + @QueryParam("attributeValue") String value); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "UnregisterDiskImage") + ListenableFuture deregister(@QueryParam("diskImageId") String id); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallApi.java new file mode 100644 index 0000000000..bfe54e95f7 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallApi.java @@ -0,0 +1,37 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.domain.Rule; + +/** + * API relating to a system's built-in server of type firewall. + * + * @author Dies Koper + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface FirewallApi extends BuiltinServerApi { + + Set getNATConfiguration(String id); + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallAsyncApi.java new file mode 100644 index 0000000000..df06dc9d5f --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallAsyncApi.java @@ -0,0 +1,79 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.binders.BindAlsoToSystemId; +import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerBackup; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerConfiguration; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerStatus; +import org.jclouds.fujitsu.fgcp.domain.Rule; +import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Transform; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Non-blocking API relating to a built-in server, also called extended function + * module (EFM), of type firewall. + * + * @author Dies Koper + */ +@RequestFilters(RequestAuthenticator.class) +@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@Consumes(MediaType.TEXT_XML) +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface FirewallAsyncApi extends BuiltinServerAsyncApi { + + @POST + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetEFMConfiguration") + @Transform(SingleElementResponseToElement.class) + ListenableFuture> getNATConfiguration(String id); + + /* + FW_NAT_RULE, getNATConfiguration(String id) + + FW_DNS, getDNSConfiguration(String id) + FW_POLICY, getPolicyConfiguration(String id) + + FW_LOG, getFirewallLogs(String id); + FW_LIMIT_POLICY, + + */ +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerApi.java new file mode 100644 index 0000000000..d1c6309a53 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerApi.java @@ -0,0 +1,33 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; + +/** + * API relating to a built-in server of type software load balancer (SLB). + * + * @author Dies Koper + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface LoadBalancerApi extends BuiltinServerApi { + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerAsyncApi.java new file mode 100644 index 0000000000..a7a645201b --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerAsyncApi.java @@ -0,0 +1,69 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.binders.BindAlsoToSystemId; +import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerBackup; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerConfiguration; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerStatus; +import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Transform; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Non-blocking API relating to a built-in server, also called extended function + * module (EFM), of type load balancer (SLB). + * + * @author Dies Koper + */ +@RequestFilters(RequestAuthenticator.class) +@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@Consumes(MediaType.TEXT_XML) +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface LoadBalancerAsyncApi extends BuiltinServerAsyncApi { + + /* + SLB_RULE, getLBConfiguration(String id) + SLB_LOAD_STATISTICS, getLoadBalancerStats(String id) + SLB_ERROR_STATISTICS, getLoadBalancerErrorStats(String id) + SLB_CERTIFICATE_LIST, getLoadBalancerCerts(String id) + SLB_CONNECTION, getLoadBalancerConnection(String id) + + */ +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApi.java new file mode 100644 index 0000000000..9bb40355ac --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApi.java @@ -0,0 +1,44 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.domain.PublicIP; +import org.jclouds.fujitsu.fgcp.domain.PublicIPStatus; + +/** + * API relating to public IP addresses. + * + * @author Dies Koper + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface PublicIPAddressApi { + + void attach(String systemId, String ip); + + void detach(String systemId, String ip); + + void free(String systemId, String ip); + + PublicIPStatus getStatus(String ip); + + PublicIP get(String ip); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressAsyncApi.java new file mode 100644 index 0000000000..0b50dc7fa5 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressAsyncApi.java @@ -0,0 +1,87 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; +import org.jclouds.fujitsu.fgcp.domain.PublicIP; +import org.jclouds.fujitsu.fgcp.domain.PublicIPStatus; +import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Transform; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Non-blocking API relating to public IP addresses. + * + * @author Dies Koper + */ +@RequestFilters(RequestAuthenticator.class) +@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@Consumes(MediaType.TEXT_XML) +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface PublicIPAddressAsyncApi { + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "AttachPublicIP") + ListenableFuture attach(@QueryParam("vsysId") String systemId, + @QueryParam("publicIp") String ip); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "DetachPublicIP") + ListenableFuture detach(@QueryParam("vsysId") String systemId, + @QueryParam("publicIp") String ip); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetPublicIPStatus") + @Transform(SingleElementResponseToElement.class) + ListenableFuture getStatus( + @QueryParam("publicIp") String ip); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetPublicIPAttributes") + @Transform(SingleElementResponseToElement.class) + ListenableFuture get(@QueryParam("publicIp") String ip); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "FreePublicIP") + ListenableFuture free(@QueryParam("vsysId") String systemId, + @QueryParam("publicIp") String ip); + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApi.java new file mode 100644 index 0000000000..e995a72de4 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApi.java @@ -0,0 +1,43 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; + +/** + * API relating to system templates, also referred to as virtual system + * descriptors. + * + * @author Dies Koper + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface SystemTemplateApi { + + VSystemDescriptor get(String id); + + void update(String id, String localeId, String name, String value); + + void deregister(String id); + + void deregisterPrivateTemplate(String id); + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateAsyncApi.java new file mode 100644 index 0000000000..74a93b2b3d --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateAsyncApi.java @@ -0,0 +1,81 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; +import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; +import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Transform; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Non-blocking API relating to system templates, also referred to as virtual + * system descriptors. + * + * @author Dies Koper + */ +@RequestFilters(RequestAuthenticator.class) +@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@Consumes(MediaType.TEXT_XML) +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface SystemTemplateAsyncApi { + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetVSYSDescriptorConfiguration") + @Transform(SingleElementResponseToElement.class) + ListenableFuture get( + @QueryParam("vsysDescriptorId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "UpdateVSYSDescriptorAttribute") + ListenableFuture update(@QueryParam("vsysDescriptorId") String id, + @QueryParam("updateLcId") String localeId, + @QueryParam("attributeName") String name, + @QueryParam("attributeValue") String value); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "UnregisterVSYSDescriptor") + ListenableFuture deregister( + @QueryParam("vsysDescriptorId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "UnregisterPrivateVSYSDescriptor") + ListenableFuture deregisterPrivateTemplate( + @QueryParam("vsysDescriptorId") String id); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApi.java new file mode 100644 index 0000000000..bb3ec3597a --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApi.java @@ -0,0 +1,75 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.domain.*; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * API relating to the virtual data center. + * + * @author Dies Koper + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface VirtualDCApi { + + String createVirtualSystem(String descriptorId, String name); + + Set listVirtualSystems(); + + // according to the manual it takes a 'String diskImageId' but value seems + // to be ignored + Set listServerTypes(); + + Set listDiskImages(); + + Set listDiskImages(String serverCategory, + String vsysDescriptorId); + + Map listPublicIPs(); + + void addAddressRange(String pipFrom, String pipTo); + + void createAddressPool(String pipFrom, String pipTo); + + void deleteAddressRange(String pipFrom, String pipTo); + + Set getAddressRange(); + + Set listVSYSDescriptor(); + + Set listVSYSDescriptor(String keyword, int estimateFrom, + int estimateTo); + + Set getEventLogs(boolean all); + + Set getEventLogs(); + + Set getInformation(boolean all); + + Set getInformation(); + + Set getSystemUsage(); + + Set getSystemUsage(String systemIds); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCAsyncApi.java new file mode 100644 index 0000000000..ec4bad9629 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCAsyncApi.java @@ -0,0 +1,189 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; +import org.jclouds.fujitsu.fgcp.domain.AddressRange; +import org.jclouds.fujitsu.fgcp.domain.DiskImage; +import org.jclouds.fujitsu.fgcp.domain.EventLog; +import org.jclouds.fujitsu.fgcp.domain.Information; +import org.jclouds.fujitsu.fgcp.domain.PublicIP; +import org.jclouds.fujitsu.fgcp.domain.ServerType; +import org.jclouds.fujitsu.fgcp.domain.UsageInfo; +import org.jclouds.fujitsu.fgcp.domain.VSystem; +import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; +import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Transform; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Non-blocking API relating to the virtual data center. + * + * @author Dies Koper + */ +@RequestFilters(RequestAuthenticator.class) +@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@Consumes(MediaType.TEXT_XML) +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface VirtualDCAsyncApi { + + // @POST + @GET + @JAXBResponseParser + // @XMLResponseParser(VSYSCreateHandler.class) + @QueryParams(keys = "Action", values = "CreateVSYS") + @Transform(SingleElementResponseToElement.class) + // @PayloadParams(keys = "Action", values = "CreateVSYS") + // @Produces(MediaType.TEXT_XML) + // @MapBinder(BindParamsToXmlPayload.class) + // ListenableFuture + // createVirtualSystem(@PayloadParam("vsysDescriptorId") String + // vsysDescriptorId, @PayloadParam("vsysName") String vsysName); + ListenableFuture createVirtualSystem( + @QueryParam("vsysDescriptorId") String descriptorId, + @QueryParam("vsysName") String name); + + @GET + @JAXBResponseParser + // @XMLResponseParser(VSYSListHandler.class) + @QueryParams(keys = "Action", values = "ListVSYS") + ListenableFuture> listVirtualSystems(); + + @GET + @JAXBResponseParser + // according to the manual it takes a 'String diskImageId' but value seems + // to be ignored + @QueryParams(keys = { "Action", "diskImageId" }, values = { + "ListServerType", "dummy" }) + // @XmlJavaTypeAdapter(SetOfServerTypesXMLAdapter.class) + // @XmlElement(type = ServerType.class) + ListenableFuture> listServerTypes(); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "ListDiskImage") + ListenableFuture> listDiskImages(); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "ListDiskImage") + ListenableFuture> listDiskImages( + @QueryParam("serverCategory") String serverCategory, + @QueryParam("vsysDescriptorId") String vsysDescriptorId); + + /** + * + * @return + * @see VirtualSystemAsyncApi#listPublicIPs(String) + */ + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "ListPublicIP") + ListenableFuture> listPublicIPs(); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "AddAddressRange") + ListenableFuture addAddressRange( + @QueryParam("pipFrom") String pipFrom, + @QueryParam("pipTo") String pipTo); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "CreateAddressPool") + ListenableFuture createAddressPool( + @QueryParam("pipFrom") String pipFrom, + @QueryParam("pipTo") String pipTo); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "DeleteAddressRange") + ListenableFuture deleteAddressRange( + @QueryParam("pipFrom") String pipFrom, + @QueryParam("pipTo") String pipTo); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetAddressRange") + ListenableFuture> getAddressRange(); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "ListVSYSDescriptor") + ListenableFuture> listVSYSDescriptor(); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "ListVSYSDescriptor") + ListenableFuture> listVSYSDescriptor( + @QueryParam("keyword") String keyword, + @QueryParam("estimateFrom") int estimateFrom, + @QueryParam("estimateTo") int estimateTo); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetEventLog") + ListenableFuture> getEventLogs(); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetEventLog") + ListenableFuture> getEventLogs(@QueryParam("all") boolean all); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetInformation") + ListenableFuture> getInformation(); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetInformation") + ListenableFuture> getInformation( + @QueryParam("all") boolean all); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetSystemUsage") + ListenableFuture> getSystemUsage(); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetSystemUsage") + ListenableFuture> getSystemUsage( + @QueryParam("systemIds") String systemIds); + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApi.java new file mode 100644 index 0000000000..70be613e2b --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApi.java @@ -0,0 +1,61 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.domain.PerformanceInfo; +import org.jclouds.fujitsu.fgcp.domain.VServer; +import org.jclouds.fujitsu.fgcp.domain.VServerStatus; +import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; + +/** + * API relating to virtual servers. + * + * @author Dies Koper + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface VirtualServerApi { + + void start(String id); + + void stop(String id); + + void stopForcefully(String id); + + void destroy(String id); + + VServer get(String id); + + VServerWithDetails getDetails(String id); + + void update(String id, String name, String value); + + VServerStatus getStatus(String id); + + String getInitialPassword(String id); + + void attachDisk(String serverId, String diskId); + + Set getPerformanceInformation(String id, String interval); + + void registerAsPrivateDiskImage(String xml); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerAsyncApi.java new file mode 100644 index 0000000000..5159c3bdce --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerAsyncApi.java @@ -0,0 +1,148 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.binders.BindAlsoToSystemId; +import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; +import org.jclouds.fujitsu.fgcp.domain.PerformanceInfo; +import org.jclouds.fujitsu.fgcp.domain.VServer; +import org.jclouds.fujitsu.fgcp.domain.VServerStatus; +import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; +import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Transform; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Non-blocking API relating to virtual servers. + * + * @author Dies Koper + */ +@RequestFilters(RequestAuthenticator.class) +@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@Consumes(MediaType.TEXT_XML) +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface VirtualServerAsyncApi { + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "StartVServer") + ListenableFuture start( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "StopVServer") + ListenableFuture stop( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = { "Action", "force" }, values = { "StopVServer", "true" }) + ListenableFuture stopForcefully( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "DestroyVServer") + ListenableFuture destroy( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetVServerAttributes") + @Transform(SingleElementResponseToElement.class) + ListenableFuture get( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetVServerConfiguration") + @Transform(SingleElementResponseToElement.class) + ListenableFuture getDetails( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "UpdateVServerAttribute") + ListenableFuture update( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id, + @QueryParam("attributeName") String name, + @QueryParam("attributeValue") String value); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetVServerStatus") + // @Transform(StringToVServerStatus.class) + @Transform(SingleElementResponseToElement.class) + ListenableFuture getStatus( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetVServerInitialPassword") + @Transform(SingleElementResponseToElement.class) + ListenableFuture getInitialPassword( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "AttachVDisk") + ListenableFuture attachDisk( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String serverId, + @QueryParam("vdiskId") String diskId); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetPerformanceInformation") + ListenableFuture> getPerformanceInformation( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("serverId") String id, + @QueryParam("interval") String interval); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetPerformanceInformation") + ListenableFuture> getPerformanceInformation( + @BinderParam(BindAlsoToSystemId.class) @QueryParam("serverId") String id, + @QueryParam("dataType") String dataType, + @QueryParam("interval") String interval); + + @POST + @JAXBResponseParser + @QueryParams(keys = "Action", values = "RegisterPrivateDiskImage") + ListenableFuture registerAsPrivateDiskImage(String xml); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApi.java new file mode 100644 index 0000000000..5ec70204ff --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApi.java @@ -0,0 +1,74 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; +import org.jclouds.fujitsu.fgcp.domain.PublicIP; +import org.jclouds.fujitsu.fgcp.domain.VDisk; +import org.jclouds.fujitsu.fgcp.domain.VServer; +import org.jclouds.fujitsu.fgcp.domain.VSystem; +import org.jclouds.fujitsu.fgcp.domain.VSystemStatus; +import org.jclouds.fujitsu.fgcp.domain.VSystemWithDetails; + +/** + * API relating to virtual systems. + * + * @author Dies Koper + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface VirtualSystemApi { + + void destroy(String id); + + VSystemStatus getStatus(String id); + + VSystem get(String id); + + VSystemWithDetails getDetails(String id); + + void update(String id, String name, String value); + + void updateConfiguration(String id, String name, String value); + + String createServer(String name, String type, String diskImageId, + String networkId); + + Set listServers(String id); + + String createBuiltinServer(String name, String networkId); + + Set listBuiltinServers(String id, String type); + + String createDisk(String id, String name, int size); + + Set listDisks(String id); + + void allocatePublicIP(String id); + + Set listPublicIPs(String id); + + String standByConsole(String id, String networkId); + + void registerAsPrivateVSYSDescriptor(String id, + String vsysDescriptorXMLFilePath); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemAsyncApi.java new file mode 100644 index 0000000000..c9d4d20b71 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemAsyncApi.java @@ -0,0 +1,174 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.fujitsu.fgcp.binders.BindAlsoToSystemId; +import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; +import org.jclouds.fujitsu.fgcp.domain.PublicIP; +import org.jclouds.fujitsu.fgcp.domain.VDisk; +import org.jclouds.fujitsu.fgcp.domain.VServer; +import org.jclouds.fujitsu.fgcp.domain.VSystem; +import org.jclouds.fujitsu.fgcp.domain.VSystemStatus; +import org.jclouds.fujitsu.fgcp.domain.VSystemWithDetails; +import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Transform; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Non-blocking API relating to virtual systems. + * + * @author Dies Koper + */ +@RequestFilters(RequestAuthenticator.class) +@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) +@Consumes(MediaType.TEXT_XML) +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface VirtualSystemAsyncApi { + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "DestroyVSYS") + ListenableFuture destroy(@QueryParam("vsysId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetVSYSStatus") + @Transform(SingleElementResponseToElement.class) + ListenableFuture getStatus(@QueryParam("vsysId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetVSYSAttributes") + @Transform(SingleElementResponseToElement.class) + ListenableFuture get(@QueryParam("vsysId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "GetVSYSConfiguration") + @Transform(SingleElementResponseToElement.class) + ListenableFuture getDetails( + @QueryParam("vsysId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "UpdateVSYSAttribute") + ListenableFuture update(@QueryParam("vsysId") String id, + @QueryParam("attributeName") String name, + @QueryParam("attributeValue") String value); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "UpdateVSYSConfiguration") + ListenableFuture updateConfiguration(@QueryParam("vsysId") String id, + @QueryParam("configurationName") String name, + @QueryParam("configurationValue") String value); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "CreateVServer") + @Transform(SingleElementResponseToElement.class) + ListenableFuture createServer( + @QueryParam("vserverName") String name, + @QueryParam("vserverType") String type, + @QueryParam("diskImageId") String diskImageId, + @BinderParam(BindAlsoToSystemId.class) @QueryParam("networkId") String networkId); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "ListVServer") + ListenableFuture> listServers(@QueryParam("vsysId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "CreateVDisk") + @Transform(SingleElementResponseToElement.class) + ListenableFuture createDisk(@QueryParam("vsysId") String id, + @QueryParam("vdiskName") String name, @QueryParam("size") int size); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "ListVDisk") + ListenableFuture> listDisks(@QueryParam("vsysId") String id); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "AllocatePublicIP") + ListenableFuture allocatePublicIP(@QueryParam("vsysId") String id); + + /** + * + * @return + * @see VirtualDCAsyncApi#listPublicIPs() + */ + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "ListPublicIP") + @Transform(SingleElementResponseToElement.class) + ListenableFuture> listPublicIPs( + @QueryParam("vsysId") String id); + + @GET + @JAXBResponseParser + // SLB is the only built-in server that can currently be created so + // hard-code it + @QueryParams(keys = { "Action", "efmType" }, values = { "CreateEFM", "SLB" }) + @Transform(SingleElementResponseToElement.class) + ListenableFuture createBuiltinServer( + @QueryParam("efmName") String name, + @BinderParam(BindAlsoToSystemId.class) @QueryParam("networkId") String networkId); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "ListEFM") + ListenableFuture> listBuiltinServers( + @QueryParam("vsysId") String id, @QueryParam("efmType") String type); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "StandByConsole") + @Transform(SingleElementResponseToElement.class) + ListenableFuture standByConsole(@QueryParam("vsysId") String id, + @QueryParam("networkId") String networkId); + + @GET + @JAXBResponseParser + @QueryParams(keys = "Action", values = "RegisterPrivateVSYSDescriptor") + ListenableFuture registerAsPrivateVSYSDescriptor( + @QueryParam("vsysId") String id, + @QueryParam("vsysDescriptorXMLFilePath") String vsysDescriptorXMLFilePath); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/BindParamsToXmlPayload.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/BindParamsToXmlPayload.java new file mode 100644 index 0000000000..0783787bd0 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/BindParamsToXmlPayload.java @@ -0,0 +1,96 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml; + +import com.google.common.base.Strings; +import org.jclouds.fujitsu.fgcp.reference.RequestParameters; +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.MapBinder; +import org.jclouds.rest.binders.BindToStringPayload; + +import javax.ws.rs.core.MediaType; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Map; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Not currently used but leaving for reference when implementing multipart POST + * methods. + * + * @author Dies Koper + */ +public class BindParamsToXmlPayload extends BindToStringPayload implements + MapBinder { + + @Override + public R bindToRequest(R request, + Map mapParams) { + String action = checkNotNull( + mapParams.remove(RequestParameters.ACTION), + RequestParameters.ACTION).toString(); + String version = Strings.nullToEmpty((String) mapParams + .remove(RequestParameters.VERSION)); + + StringBuilder xml = new StringBuilder(); + xml.append("\r\n"); + xml.append("\r\n"); + xml.append(" " + action + "\r\n"); + + for (Map.Entry entry : mapParams.entrySet()) { + String key = entry.getKey(); + xml.append(" <" + key + ">" + checkNotNull(mapParams.get(key)) + + "\r\n"); + } + + xml.append(" " + version + "\r\n"); + xml.append(" \r\n"); // value inserted in + // RequestAuthenticator#filter + xml.append(" \r\n"); // value inserted in + // RequestAuthenticator#filter + xml.append(" \r\n"); // value inserted in + // RequestAuthenticator#filter + xml.append(""); + + request = super.bindToRequest(request, xml); + request.getPayload().getContentMetadata() + .setContentType(MediaType.TEXT_XML); + + // remove version query param if set as it was moved to the xml body + URI uri = request.getEndpoint(); + URI uriWithoutQueryParams; + try { + uriWithoutQueryParams = new URI(uri.getScheme(), uri.getUserInfo(), + uri.getHost(), uri.getPort(), uri.getPath(), null, + uri.getFragment()); + } catch (URISyntaxException e) { + // should never happen as we're copying the components from a URI + uriWithoutQueryParams = uri; + } + + return (R) request.toBuilder().endpoint(uriWithoutQueryParams).build(); + } + + @Override + public R bindToRequest(R request, Object toBind) { + throw new IllegalArgumentException( + "BindParamsToXmlPayload needs bind parameters"); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/FGCPJAXBParser.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/FGCPJAXBParser.java new file mode 100644 index 0000000000..b5349ab859 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/FGCPJAXBParser.java @@ -0,0 +1,88 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml; + +import java.io.IOException; +import java.io.StringReader; + +import javax.inject.Singleton; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; +import org.jclouds.fujitsu.fgcp.xml.internal.ListServerTypeResponse; +import org.jclouds.fujitsu.fgcp.xml.internal.StatusQuerable; +import org.jclouds.http.HttpException; +import org.jclouds.xml.XMLParser; + +/** + * Parses XML documents using JAXB. + * + * @author Dies Koper + * @see org.jclouds.http.functions.ParseXMLWithJAXB + */ +@Singleton +public class FGCPJAXBParser implements XMLParser { + JAXBContext context; + + public FGCPJAXBParser() throws JAXBException { + context = JAXBContext.newInstance(VServerWithDetails.class.getPackage() + .getName() + + ":" + + ListServerTypeResponse.class.getPackage().getName(), + VServerWithDetails.class.getClassLoader()); + } + + @Override + public String toXML(final Object src) throws IOException { + return toXML(src, src.getClass()); + } + + @Override + public String toXML(final Object src, final Class type) + throws IOException { + throw new UnsupportedOperationException( + "only marshaling from XML is implemented"); + } + + @SuppressWarnings("unchecked") + @Override + public T fromXML(final String xml, final Class type) + throws IOException { + T response = null; + try { + StringReader reader = new StringReader(xml); + + Unmarshaller unmarshaller = context.createUnmarshaller(); + + response = (T) unmarshaller.unmarshal(reader); + } catch (Exception ex) { + throw new IOException("Could not unmarshal document", ex); + } + + if (((StatusQuerable) response).isError()) { + throw new HttpException( + ((StatusQuerable) response).getResponseMessage()); + } + + return response; + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateEFMResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateEFMResponse.java new file mode 100644 index 0000000000..237fde513f --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateEFMResponse.java @@ -0,0 +1,44 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Wrapper for CreateEFMResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "CreateEFMResponse") +public class CreateEFMResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private String efmId; + + @Override + public String toString() { + return getElement(); + } + + @Override + public String getElement() { + return efmId; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVDiskResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVDiskResponse.java new file mode 100644 index 0000000000..b31a637f9d --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVDiskResponse.java @@ -0,0 +1,44 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Wrapper for CreateVDiskResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "CreateVDiskResponse") +public class CreateVDiskResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private String vdiskId; + + @Override + public String toString() { + return getElement(); + } + + @Override + public String getElement() { + return vdiskId; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVSYSResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVSYSResponse.java new file mode 100644 index 0000000000..a18a3fada7 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVSYSResponse.java @@ -0,0 +1,44 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Wrapper for CreateVSYSResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "CreateVSYSResponse") +public class CreateVSYSResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private String vsysId; + + @Override + public String toString() { + return getElement(); + } + + @Override + public String getElement() { + return vsysId; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVServerResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVServerResponse.java new file mode 100644 index 0000000000..6170ee407a --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVServerResponse.java @@ -0,0 +1,44 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Wrapper for CreateVServerResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "CreateVServerResponse") +public class CreateVServerResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private String vserverId; + + @Override + public String toString() { + return getElement(); + } + + @Override + public String getElement() { + return vserverId; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetAddressRangeResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetAddressRangeResponse.java new file mode 100644 index 0000000000..9ea55713ac --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetAddressRangeResponse.java @@ -0,0 +1,50 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.AddressRange; + +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for GetAddressRangeResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetAddressRangeResponse") +public class GetAddressRangeResponse extends + SetWithStatusResponse { + @XmlElementWrapper(name = "addressranges") + @XmlElement(name = "addressrange") + private Set ranges = new LinkedHashSet(); + + @Override + protected Set delegate() { + return ranges == null ? ImmutableSet. of() : Collections + .unmodifiableSet(ranges); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetDiskImageAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetDiskImageAttributesResponse.java new file mode 100644 index 0000000000..ccef26f210 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetDiskImageAttributesResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import org.jclouds.fujitsu.fgcp.domain.DiskImage; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Wrapper for GetDiskImageAttributesResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetDiskImageAttributesResponse") +public class GetDiskImageAttributesResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(name = "diskimage") + private DiskImage diskImage; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + public DiskImage getElement() { + return diskImage; + } +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMAttributesResponse.java new file mode 100644 index 0000000000..9764a9e516 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMAttributesResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; + +/** + * Wrapper for GetEFMAttributesResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetEFMAttributesResponse") +public class GetEFMAttributesResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private BuiltinServer efm; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + public Object getElement() { + return efm; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMStatusResponse.java new file mode 100644 index 0000000000..34fa4c6204 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMStatusResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerStatus; + +/** + * Wrapper for GetEFMStatusResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetEFMStatusResponse") +public class GetEFMStatusResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private BuiltinServerStatus efmStatus; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + public Object getElement() { + return efmStatus; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEventLogResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEventLogResponse.java new file mode 100644 index 0000000000..c9f35d25e9 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEventLogResponse.java @@ -0,0 +1,49 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.EventLog; + +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for GetEventLogResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetEventLogResponse") +public class GetEventLogResponse extends SetWithStatusResponse { + @XmlElementWrapper(name = "eventlogs") + @XmlElement(name = "eventlog") + private Set logs = new LinkedHashSet(); + + @Override + protected Set delegate() { + return logs == null ? ImmutableSet. of() : Collections + .unmodifiableSet(logs); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPerformanceInformationResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPerformanceInformationResponse.java new file mode 100644 index 0000000000..e8c92909d1 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPerformanceInformationResponse.java @@ -0,0 +1,50 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.PerformanceInfo; + +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for GetPerformanceInformationResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetPerformanceInformationResponse") +public class GetPerformanceInformationResponse extends + SetWithStatusResponse { + @XmlElementWrapper(name = "performanceinfos") + @XmlElement(name = "performanceinfo") + private Set stats = new LinkedHashSet(); + + @Override + protected Set delegate() { + return stats == null ? ImmutableSet. of() + : Collections.unmodifiableSet(stats); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPAttributesResponse.java new file mode 100644 index 0000000000..d0a0488819 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPAttributesResponse.java @@ -0,0 +1,53 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.PublicIP; + + +import com.google.common.collect.Iterables; + +/** + * Wrapper for GetPublicIPAttributesResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetPublicIPAttributesResponse") +public class GetPublicIPAttributesResponse extends StatusResponse implements + SingleElementResponse { + @XmlElementWrapper(name = "publicips") + @XmlElement(name = "publicip") + private Set publicIPs; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + public Object getElement() { + return Iterables.getOnlyElement(publicIPs); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPStatusResponse.java new file mode 100644 index 0000000000..29e5ce91f3 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPStatusResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.PublicIPStatus; + +/** + * Wrapper for GetPublicIPStatusResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetPublicIPStatusResponse") +public class GetPublicIPStatusResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private PublicIPStatus publicipStatus; + + @Override + public String toString() { + return publicipStatus.toString(); + } + + @Override + public Object getElement() { + return publicipStatus; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVDiskAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVDiskAttributesResponse.java new file mode 100644 index 0000000000..0634f00c22 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVDiskAttributesResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VDisk; + +/** + * Wrapper for GetVDiskAttributesResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetVDiskAttributesResponse") +public class GetVDiskAttributesResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private VDisk vdisk; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + public Object getElement() { + return vdisk; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSAttributesResponse.java new file mode 100644 index 0000000000..0833a4df0e --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSAttributesResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VSystem; + +/** + * Wrapper for GetVSYSAttributesResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetVSYSAttributesResponse") +public class GetVSYSAttributesResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(name = "vsys") + private VSystem system; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + public Object getElement() { + return system; + } +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSConfigurationResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSConfigurationResponse.java new file mode 100644 index 0000000000..c593a3bb4b --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSConfigurationResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VSystemWithDetails; + +/** + * Wrapper for GetVSYSConfigurationResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetVSYSConfigurationResponse") +public class GetVSYSConfigurationResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(name = "vsys") + private VSystemWithDetails system; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + public Object getElement() { + return system; + } +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSDescriptorConfigurationResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSDescriptorConfigurationResponse.java new file mode 100644 index 0000000000..af21f20658 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSDescriptorConfigurationResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; + +/** + * Wrapper for GetVSYSDescriptorConfigurationResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetVSYSDescriptorConfigurationResponse") +public class GetVSYSDescriptorConfigurationResponse extends StatusResponse + implements SingleElementResponse { + @XmlElement + private VSystemDescriptor vsysdescriptor; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + public Object getElement() { + return vsysdescriptor; + } +} \ No newline at end of file diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSStatusResponse.java new file mode 100644 index 0000000000..08d1dc97d1 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSStatusResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VSystemStatus; + +/** + * Wrapper for GetVSYSStatusResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetVSYSStatusResponse") +public class GetVSYSStatusResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private VSystemStatus vsysStatus; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + public Object getElement() { + return vsysStatus; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerAttributesResponse.java new file mode 100644 index 0000000000..404cceca87 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerAttributesResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VServer; + +/** + * Wrapper for GetVServerAttributesResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetVServerAttributesResponse") +public class GetVServerAttributesResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private VServer vserver; + + @Override + public String toString() { + return vserver.toString(); + } + + @Override + public Object getElement() { + return vserver; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerConfigurationResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerConfigurationResponse.java new file mode 100644 index 0000000000..f69daa5f12 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerConfigurationResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; + +/** + * Wrapper for GetVServerConfigurationResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetVServerConfigurationResponse") +public class GetVServerConfigurationResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private VServerWithDetails vserver; + + @Override + public String toString() { + return vserver.toString(); + } + + @Override + public Object getElement() { + return vserver; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerInitialPasswordResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerInitialPasswordResponse.java new file mode 100644 index 0000000000..f5a1a162f5 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerInitialPasswordResponse.java @@ -0,0 +1,39 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Wrapper for GetVServerInitialPasswordResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetVServerInitialPasswordResponse") +public class GetVServerInitialPasswordResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private String initialPassword; + + @Override + public Object getElement() { + return initialPassword; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerStatusResponse.java new file mode 100644 index 0000000000..ea22965525 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerStatusResponse.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VServerStatus; + +/** + * Wrapper for GetVServerStatusResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "GetVServerStatusResponse") +public class GetVServerStatusResponse extends StatusResponse implements + SingleElementResponse { + @XmlElement(required = true) + private VServerStatus vserverStatus; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + public Object getElement() { + return vserverStatus; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListDiskImageResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListDiskImageResponse.java new file mode 100644 index 0000000000..5e19ad697b --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListDiskImageResponse.java @@ -0,0 +1,49 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.DiskImage; + +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for ListDiskImageResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "ListDiskImageResponse") +public class ListDiskImageResponse extends SetWithStatusResponse { + @XmlElementWrapper(name = "diskimages") + @XmlElement(name = "diskimage") + private Set diskImages = new LinkedHashSet(); + + @Override + protected Set delegate() { + return diskImages == null ? ImmutableSet. of() : Collections + .unmodifiableSet(diskImages); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMBackupResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMBackupResponse.java new file mode 100644 index 0000000000..a9026252a3 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMBackupResponse.java @@ -0,0 +1,50 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerBackup; + +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for ListEFMBackupResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "ListEFMBackupResponse") +public class ListEFMBackupResponse extends + SetWithStatusResponse { + @XmlElementWrapper(name = "backups") + @XmlElement(name = "backup") + private Set backup = new LinkedHashSet(); + + @Override + protected Set delegate() { + return backup == null ? ImmutableSet. of() + : Collections.unmodifiableSet(backup); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMResponse.java new file mode 100644 index 0000000000..9ebbb1a613 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMResponse.java @@ -0,0 +1,49 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; + +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for ListEFMResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "ListEFMResponse") +public class ListEFMResponse extends SetWithStatusResponse { + @XmlElementWrapper(name = "efms") + @XmlElement(name = "efm") + private Set efm = new LinkedHashSet(); + + @Override + protected Set delegate() { + return efm == null ? ImmutableSet. of() : Collections + .unmodifiableSet(efm); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListPublicIPResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListPublicIPResponse.java new file mode 100644 index 0000000000..2b6c1a1bf5 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListPublicIPResponse.java @@ -0,0 +1,70 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.PublicIP; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for ListPublicIPResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "ListPublicIPResponse") +public class ListPublicIPResponse extends + MapWithStatusResponse implements + SingleElementResponse { + @XmlElementWrapper(name = "publicips") + @XmlElement(name = "publicip") + private Set ips; + + @Override + public String toString() { + return getElement().toString(); + } + + @Override + protected Map delegate() { + Builder returnVal = ImmutableMap.builder(); + if (ips != null) { + + for (PublicIPWithSystemId ip : ips) { + returnVal.put(ip, ip.getVsysId()); + } + } + return returnVal.build(); + } + + @Override + public Set getElement() { + return ips == null ? ImmutableSet. of() : Collections + .unmodifiableSet(ips); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListServerTypeResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListServerTypeResponse.java new file mode 100644 index 0000000000..6d1e49e2ee --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListServerTypeResponse.java @@ -0,0 +1,48 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.ServerType; + +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for ListServerTypeResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "ListServerTypeResponse") +public class ListServerTypeResponse extends SetWithStatusResponse { + @XmlElementWrapper(name = "servertypes") + @XmlElement(name = "servertype") + private Set serverTypes; + + @Override + protected Set delegate() { + return serverTypes == null ? ImmutableSet. of() + : Collections.unmodifiableSet(serverTypes); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVDiskResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVDiskResponse.java new file mode 100644 index 0000000000..0489a93042 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVDiskResponse.java @@ -0,0 +1,49 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VDisk; + +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for ListVDiskResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "ListVDiskResponse") +public class ListVDiskResponse extends SetWithStatusResponse { + @XmlElementWrapper(name = "vdisks") + @XmlElement(name = "vdisk") + private Set disks = new LinkedHashSet(); + + @Override + protected Set delegate() { + return disks == null ? ImmutableSet. of() : Collections + .unmodifiableSet(disks); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVSYSResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVSYSResponse.java new file mode 100644 index 0000000000..90826f63da --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVSYSResponse.java @@ -0,0 +1,49 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VSystem; + +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for ListVSYSResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "ListVSYSResponse") +public class ListVSYSResponse extends SetWithStatusResponse { + @XmlElementWrapper(name = "vsyss") + @XmlElement(name = "vsys") + private Set systems = new LinkedHashSet(); + + @Override + protected Set delegate() { + return systems == null ? ImmutableSet. of() : Collections + .unmodifiableSet(systems); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVServerResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVServerResponse.java new file mode 100644 index 0000000000..802a779ba1 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVServerResponse.java @@ -0,0 +1,49 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.VServer; + +import com.google.common.collect.ImmutableSet; + +/** + * Wrapper for ListVServerResponse. + * + * @author Dies Koper + */ +@XmlRootElement(name = "ListVServerResponse") +public class ListVServerResponse extends SetWithStatusResponse { + @XmlElementWrapper(name = "vservers") + @XmlElement(name = "vserver") + private Set servers = new LinkedHashSet(); + + @Override + protected Set delegate() { + return servers == null ? ImmutableSet. of() : Collections + .unmodifiableSet(servers); + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/MapWithStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/MapWithStatusResponse.java new file mode 100644 index 0000000000..ffc54303a4 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/MapWithStatusResponse.java @@ -0,0 +1,58 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import com.google.common.collect.ForwardingMap; + +import javax.xml.bind.annotation.XmlElement; + +/** + * Special base class extending (forwardable) Map with fields for the elements + * that FGCP XML responses specify. + *

+ * This is useful for methods that return a set of elements that are better + * represented as key value pairs. + * + * @author Dies Koper + */ +public abstract class MapWithStatusResponse extends ForwardingMap + implements StatusQuerable { + @XmlElement(required = true) + private String responseMessage; + @XmlElement(required = true) + private String responseStatus; + + public String getResponseMessage() { + return responseMessage; + } + + public String getResponseStatus() { + return responseStatus; + } + + public boolean isError() { + return !"SUCCESS".equals(responseStatus); + } + + @Override + public String toString() { + return "StatusResponse{" + "responseMessage='" + responseMessage + '\'' + + ", responseStatus='" + responseStatus + '\'' + '}'; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/PublicIPWithSystemId.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/PublicIPWithSystemId.java new file mode 100644 index 0000000000..fd9f18cb30 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/PublicIPWithSystemId.java @@ -0,0 +1,43 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.fujitsu.fgcp.domain.PublicIP; + +/** + * Represents a public IP address with its system id. + * + * @author Dies Koper + */ +@XmlRootElement(name = "publicip") +public class PublicIPWithSystemId extends PublicIP { + private String vsysId; + + public String getVsysId() { + return vsysId; + } + + @Override + public String toString() { + return "PublicIP{" + "address='" + address + '\'' + ", IP version='" + + version + '\'' + ", vsysId='" + vsysId + '\'' + '}'; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SetWithStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SetWithStatusResponse.java new file mode 100644 index 0000000000..bb7158f10b --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SetWithStatusResponse.java @@ -0,0 +1,58 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import com.google.common.collect.ForwardingSet; + +import javax.xml.bind.annotation.XmlElement; + +/** + * Special base class extending (forwardable) Set with fields for the elements + * that FGCP XML responses specify. + *

+ * This is useful for methods that return a Set and the XML response has no + * other elements but the set of elements (and message and status of course). + * + * @author Dies Koper + */ +public abstract class SetWithStatusResponse extends ForwardingSet + implements StatusQuerable { + @XmlElement(required = true) + private String responseMessage; + @XmlElement(required = true) + private String responseStatus; + + public String getResponseMessage() { + return responseMessage; + } + + public String getResponseStatus() { + return responseStatus; + } + + public boolean isError() { + return !"SUCCESS".equals(responseStatus); + } + + @Override + public String toString() { + return delegate().toString(); + } + +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SingleElementResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SingleElementResponse.java new file mode 100644 index 0000000000..759586fe98 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SingleElementResponse.java @@ -0,0 +1,29 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +/** + * Wrapper for CreateVSYSResponse. + * + * @author Dies Koper + */ +public interface SingleElementResponse { + + Object getElement(); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusQuerable.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusQuerable.java new file mode 100644 index 0000000000..9046c68720 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusQuerable.java @@ -0,0 +1,32 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +/** + * Exposes methods to obtain the status and message from the API server. + * + * @author Dies Koper + */ +public interface StatusQuerable { + public String getResponseMessage(); + + public String getResponseStatus(); + + public boolean isError(); +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusResponse.java new file mode 100644 index 0000000000..7ea3361de3 --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusResponse.java @@ -0,0 +1,60 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Base class with fields for the elements that FGCP XML responses specify. + * + * @author Dies Koper + */ +public abstract class StatusResponse implements StatusQuerable { + @XmlElement(required = true) + private String responseMessage; + @XmlElement(required = true) + private String responseStatus; + + public String getResponseMessage() { + return responseMessage; + } + + public void setResponseMessage(String responseMessage) { + this.responseMessage = responseMessage; + } + + public String getResponseStatus() { + return responseStatus; + } + + public void setResponseStatus(String responseStatus) { + this.responseStatus = responseStatus; + } + + public boolean isError() { + return !"SUCCESS".equals(responseStatus); + } + + @Override + public String toString() { + return "StatusResponse{" + "responseMessage='" + responseMessage + '\'' + + ", responseStatus='" + responseStatus + '\'' + '}'; + } +} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/package-info.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/package-info.java new file mode 100644 index 0000000000..12b705bccc --- /dev/null +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/package-info.java @@ -0,0 +1,28 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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. + */ +@XmlSchema(namespace = "http://apioviss.jp.fujitsu.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +//@XmlJavaTypeAdapter(value=SetOfServerTypesXMLAdapter.class,type= Set.class) +//@XmlJavaTypeAdapter(value=SetOfServerTypesXMLAdapter.class,type= ListServerTypeResponse.class) +@XmlAccessorType(XmlAccessType.FIELD) +package org.jclouds.fujitsu.fgcp.xml.internal; + +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlSchema; + diff --git a/labs/fgcp/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/fgcp/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..f2a75c058f --- /dev/null +++ b/labs/fgcp/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.fujitsu.fgcp.FGCPApiMetadata \ No newline at end of file diff --git a/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/domain/jaxb.index b/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/domain/jaxb.index new file mode 100644 index 0000000000..4917877347 --- /dev/null +++ b/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/domain/jaxb.index @@ -0,0 +1,45 @@ +#listing of all classes in the domain package (at this time of writing) +#as some or all are likely to contain JAXB annotations +#note that even if (newer) classes are missing, as long as they are statically referenced from +#any of these classes they'll be included in the JAXB context. +AddressRange +BuiltinServer +BuiltinServerStatus +Cause +CPU +Direction +Disk +DiskImage +ErrorStatistics +EventLog +Firewall +Group +Image +Information +IntermediateCACert +LoadStatistics +Memory +NAT +PerformanceInfo +Period +Policy +Product +PublicIPStatus +Rule +ServerCert +ServerType +SLB +Software +Target +UsageInfo +VDisk +VDiskStatus +VNet +VNIC +VServer +VServerStatus +VServerWithDetails +VSystem +VSystemDescriptor +VSystemStatus +VSystemWithDetails \ No newline at end of file diff --git a/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/xml/internal/jaxb.index b/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/xml/internal/jaxb.index new file mode 100644 index 0000000000..3e4a1e887c --- /dev/null +++ b/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/xml/internal/jaxb.index @@ -0,0 +1,30 @@ +#listing of all classes in the xml.internal package (at this time of writing) +CreateVDiskResponse +CreateEFMResponse +CreateVServerResponse +CreateVSYSResponse +GetAddressRangeResponse +GetDiskImageAttributesResponse +GetEFMAttributesResponse +GetEFMStatusResponse +GetEventLogResponse +GetPublicIPAttributesResponse +GetPublicIPStatusResponse +GetVDiskAttributesResponse +GetVServerAttributesResponse +GetVServerConfigurationResponse +GetVServerInitialPasswordResponse +GetVServerStatusResponse +GetVSYSAttributesResponse +GetVSYSConfigurationResponse +GetVSYSDescriptorConfigurationResponse +GetVSYSStatusResponse +ListDiskImageResponse +ListEFMBackupResponse +ListEFMResponse +ListPublicIPResponse +ListServerTypeResponse +ListVDiskResponse +ListVServerResponse +ListVSYSResponse +PublicIPWithSystemId diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPBaseTemplateBuilderLiveTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPBaseTemplateBuilderLiveTest.java new file mode 100644 index 0000000000..54388cdaf3 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPBaseTemplateBuilderLiveTest.java @@ -0,0 +1,84 @@ +package org.jclouds.fujitsu.fgcp.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Properties; + +import org.jclouds.Constants; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; + +public abstract class FGCPBaseTemplateBuilderLiveTest extends + BaseTemplateBuilderLiveTest { + + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + + String proxy = System.getenv("http_proxy"); + if (proxy != null) { + + String[] parts = proxy.split("http://|:|@"); + + overrides.setProperty(Constants.PROPERTY_PROXY_HOST, + parts[parts.length - 2]); + overrides.setProperty(Constants.PROPERTY_PROXY_PORT, + parts[parts.length - 1]); + + if (parts.length >= 4) { + overrides.setProperty(Constants.PROPERTY_PROXY_USER, + parts[parts.length - 4]); + overrides.setProperty(Constants.PROPERTY_PROXY_PASSWORD, + parts[parts.length - 3]); + } + } + + // enables peer verification using the CAs bundled with the JRE (or + // value of javax.net.ssl.trustStore if set) + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "false"); + + return overrides; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return Predicates.not(new Predicate() { + + @Override + public boolean apply(OsFamilyVersion64Bit input) { + switch (input.family) { + case CENTOS: + return input.version.matches("5.[46]") + || input.version.equals("6.[2]"); + case WINDOWS: + return (input.version.equals("2008 R2 SE") || input.version + .equals("2008 R2 EE")) && input.is64Bit; + default: + return false; + } + } + + }); + } + + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = view.getComputeService().templateBuilder() + .build(); + assert defaultTemplate.getImage().getOperatingSystem().getVersion() + .matches("6.2") : defaultTemplate.getImage() + .getOperatingSystem().getVersion(); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), + true); + assertEquals(defaultTemplate.getImage().getOperatingSystem() + .getFamily(), OsFamily.CENTOS); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + +} \ No newline at end of file diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModuleTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModuleTest.java new file mode 100644 index 0000000000..9c1c8804ce --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModuleTest.java @@ -0,0 +1,98 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.compute; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.jclouds.crypto.Crypto; +import org.jclouds.fujitsu.fgcp.FGCPApiMetadata; + +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.security.spec.InvalidKeySpecException; +import java.util.Scanner; + +import static org.testng.Assert.*; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "FGCPRestClientModuleTest") +public class FGCPRestClientModuleTest { + + protected FGCPRestClientModule module; + protected Crypto crypto; + + @BeforeTest + protected void createCrypto() { + Injector i = Guice.createInjector(); + crypto = i.getInstance(Crypto.class); + } + + @BeforeTest + protected void createRestClientModule() { + Injector i = Guice.createInjector(); + module = i.getInstance(FGCPRestClientModule.class); + } + + public void testKeyStoreAsPkcs12() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException, KeyStoreException, CertificateException { + assertNotNull(crypto); + assertNotNull(module); + + // self-signed dummy cert: + // keytool -genkey -alias test-fgcp -keyalg RSA -keysize 1024 -validity 5475 -dname "CN=localhost" -keystore jclouds-test-fgcp.p12 -storepass jcloudsjclouds -storetype pkcs12 + String cert = "/certs/jclouds-test-fgcp.p12"; + String keyPassword = "jcloudsjclouds"; + + URL url = this.getClass().getResource(cert); + String certPath = url.getFile(); + + KeyStore ks = module.provideKeyStore(crypto, certPath, keyPassword); + + assertNotNull(ks.getCertificate("test-fgcp"), "cert with alias"); + } + +/* public void testKeyStoreAsPEM() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException, KeyStoreException, CertificateException { + assertNotNull(crypto); + assertNotNull(module); + + //openssl pkcs12 -nodes -in jclouds-test-fgcp.p12 -out jclouds-test-fgcp.pem +// String privKeyFilename = "D:\\UserCert.pem.pkcs12-nodes";//_nobags"; + String cert = "/certs/jclouds-test-fgcp.pem"; + String keyPassword = "jcloudsjclouds"; + + URL url = this.getClass().getResource(cert); + String certPath = url.getFile(); + Scanner scanner = new Scanner(new File(certPath)); + String content = scanner.useDelimiter("\\A").next(); + + KeyStore ks = module.provideKeyStore(crypto, content, keyPassword); + + assertNotNull(ks.getCertificate("test-fgcp"), "cert with alias"); + } +*/ +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPBaseComputeServiceLiveTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPBaseComputeServiceLiveTest.java new file mode 100644 index 0000000000..996965b12c --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPBaseComputeServiceLiveTest.java @@ -0,0 +1,187 @@ +package org.jclouds.fujitsu.fgcp.compute.config; + +import java.util.Properties; + +import org.jclouds.Constants; +import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.sshj.config.SshjSshClientModule; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + +public abstract class FGCPBaseComputeServiceLiveTest extends + BaseComputeServiceLiveTest { + + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + + String proxy = System.getenv("http_proxy"); + if (proxy != null) { + + String[] parts = proxy.split("http://|:|@"); + + overrides.setProperty(Constants.PROPERTY_PROXY_HOST, parts[parts.length - 2]); + overrides.setProperty(Constants.PROPERTY_PROXY_PORT, parts[parts.length - 1]); + + if (parts.length >= 4) { + overrides.setProperty(Constants.PROPERTY_PROXY_USER, parts[parts.length - 4]); + overrides.setProperty(Constants.PROPERTY_PROXY_PASSWORD, parts[parts.length - 3]); + } + } + + // enables peer verification using the CAs bundled with the JRE (or + // value of javax.net.ssl.trustStore if set) + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "false"); + + return overrides; + } + + @Override + protected Module getSshModule() { + return new SshjSshClientModule(); + } + + @Override + @Test(enabled = false, expectedExceptions = AuthorizationException.class) + public void testCorrectAuthException() throws Exception { + // http://code.google.com/p/jclouds/issues/detail?id=1060 + } + + // fgcp does not support metadata + @Override + protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap userMetadata) { + assert node.getUserMetadata().isEmpty() : String.format( + "node userMetadata not empty: %s %s", node, + node.getUserMetadata()); + } + + // node name can't be retrieved through the API and is therefore null + protected void checkResponseEqualsHostname(ExecResponse execResponse, + NodeMetadata node) { + assert node.getHostname() == null : node + " with hostname: " + + node.getHostname(); + } + + // tags are not (yet) supported for fgcp + protected void checkTagsInNodeEquals(NodeMetadata node, + ImmutableSet tags) { + assert node.getTags().isEmpty() : String.format( + "node tags found %s (%s) in node %s", node.getTags(), tags, node); + } + + /* + * public void testCreateAndRunAService() throws Exception { + * super.testCreateAndRunAService(); } + */ + + // this test requires network access to the VM it creates: + // before running it, start an SSL/VPN connection to the last updated vsys' + // DMZ. + // may also need to configure SNAT and FW rules to allow the VM to + // communicate out (53 for DNS, 80 for yum). + public void testAScriptExecutionAfterBootWithBasicTemplate() + throws Exception { + super.testAScriptExecutionAfterBootWithBasicTemplate(); + } + + @Override + @Test(enabled = false) + public void testOptionToNotBlock() throws Exception { + // start call returns before node reaches running state, but + // test may be failing due to the system being in a 're-configuring' + // state while destroying nodes of a previous test. + // http://code.google.com/p/jclouds/issues/detail?id=1066 + /* + org.jclouds.compute.RunNodesException: error running 1 node group(fgcp-aublock) location(UZXC0GRT-IZKDVGIL5-N-SECURE1) image(IMG_3c9820_71OW9NZC268) size(islanda-cbrm_140) options({inboundPorts=[], blockUntilRunning=false}) + Execution failures: + + 1) ExecutionException on fgcp-aublock-787: + java.util.concurrent.ExecutionException: java.lang.IllegalStateException: The status of Instance[UZXC0GRT-IZKDVGIL5] is [RECONFIG_ING]. + at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:289) + at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:276) + at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:111) + at org.jclouds.concurrent.FutureIterables$1.run(FutureIterables.java:134) + at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) + at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) + at java.lang.Thread.run(Unknown Source) + Caused by: java.lang.IllegalStateException: The status of Instance[UZXC0GRT-IZKDVGIL5] is [RECONFIG_ING]. + at org.jclouds.fujitsu.fgcp.xml.FGCPJAXBParser.fromXML(FGCPJAXBParser.java:75) + at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:91) + at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:86) + at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:73) + at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:54) + at com.google.common.base.Functions$FunctionComposition.apply(Functions.java:209) + at com.google.common.util.concurrent.Futures$3.apply(Futures.java:380) + at com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:522) + at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) + at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) + at java.lang.Thread.run(Unknown Source) + at org.jclouds.concurrent.config.DescribingExecutorService.submit(DescribingExecutorService.java:89) + at org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.createNodeInGroupWithNameAndTemplate(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:170) + at org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.execute(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:125) + at org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:213) + at org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:229) + at org.jclouds.compute.internal.BaseComputeServiceLiveTest.testOptionToNotBlock(BaseComputeServiceLiveTest.java:803) + */ + } + +/* @Override + @Test(enabled = false) + public void testCreateTwoNodesWithRunScript() { + } + + @Override + @Test(enabled = false) + public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() { + } + + @Override + @Test(enabled = false) + public void testGet() { + } +*/ +// @Override +// @Test(enabled = false) +// public void testConcurrentUseOfComputeServiceToCreateNodes() throws Exception { + // http://code.google.com/p/jclouds/issues/detail?id=1066 + /* + 1) ExecutionException on twin0-f6a: + java.util.concurrent.ExecutionException: org.jclouds.http.HttpResponseException: Error parsing input + {statusCode=200, message=OK, headers={Date=[Sun, 26 Aug 2012 01:22:50 GMT], Transfer-Encoding=[chunked], Set-Cookie=[JSESSIONID=8A07404DF0405E46B3A748C3763B0D9F; Path=/ovisspxy; Secure], Connection=[close]}, payload=[content=true, contentMetadata=[contentDisposition=null, contentEncoding=null, contentLanguage=null, contentLength=null, contentMD5=null, contentType=text/xml;charset=UTF-8, expires=null], written=false]} + at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:289) + at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:276) + at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:111) + at org.jclouds.concurrent.FutureIterables$1.run(FutureIterables.java:134) + at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) + at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) + at java.lang.Thread.run(Unknown Source) + Caused by: org.jclouds.http.HttpResponseException: Error parsing input + {statusCode=200, message=OK, headers={Date=[Sun, 26 Aug 2012 01:22:50 GMT], Transfer-Encoding=[chunked], Set-Cookie=[JSESSIONID=8A07404DF0405E46B3A748C3763B0D9F; Path=/ovisspxy; Secure], Connection=[close]}, payload=[content=true, contentMetadata=[contentDisposition=null, contentEncoding=null, contentLanguage=null, contentLength=null, contentMD5=null, contentType=text/xml;charset=UTF-8, expires=null], written=false]} + at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:78) + at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:1) + at com.google.common.base.Functions$FunctionComposition.apply(Functions.java:209) + at com.google.common.util.concurrent.Futures$3.apply(Futures.java:380) + at com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:522) + at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) + at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) + at java.lang.Thread.run(Unknown Source) + at org.jclouds.concurrent.config.DescribingExecutorService.submit(DescribingExecutorService.java:89) + at org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.createNodeInGroupWithNameAndTemplate(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:170) + at org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.execute(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:125) + at org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:213) + at org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:229) + at org.jclouds.compute.internal.BaseComputeServiceLiveTest$1.call(BaseComputeServiceLiveTest.java:442) + at org.jclouds.compute.internal.BaseComputeServiceLiveTest$1.call(BaseComputeServiceLiveTest.java:1) + ... 3 more + Caused by: org.jclouds.http.HttpException: The status of Instance[UZXC0GRT-9Q988189J] is [RECONFIG_ING]. + at org.jclouds.fujitsu.fgcp.xml.FGCPJAXBParser.fromXML(FGCPJAXBParser.java:81) + at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:91) +*/ +// } +} \ No newline at end of file diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystemTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystemTest.java new file mode 100644 index 0000000000..966ea07569 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystemTest.java @@ -0,0 +1,163 @@ +package org.jclouds.fujitsu.fgcp.compute.functions; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.fujitsu.fgcp.compute.functions.DiskImageToOperatingSystem; +import org.jclouds.fujitsu.fgcp.domain.DiskImage; +import org.jclouds.fujitsu.fgcp.domain.DiskImage.Builder; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "DiskImageToOperatingSystemTest") +public class DiskImageToOperatingSystemTest { + // Operating Systems available JAN 2012 (taken from osName) + private static final List operatingSystems = Arrays.asList( + // JP + "CentOS 5.6 32bit (English)", + "CentOS 5.6 64bit (English)", + "Red Hat Enterprise Linux 5.5 32bit (Japanese)", + "Red Hat Enterprise Linux 5.5 64bit (Japanese)", + "Windows Server 2003 R2 EE 32bit SP2 (日本語版) サポート付", + "Windows Server 2003 R2 EE 32bit SP2 (日本語版)", + "Windows Server 2008 R2 EE 64bit (日本語版) サポート付", + "Windows Server 2008 R2 EE 64bit (日本語版)", + "Windows Server 2008 R2 SE 64bit (日本語版) サポート付", + "Windows Server 2008 R2 SE 64bit (日本語版)", + "Windows Server 2008 SE 32bit SP2 (日本語版) サポート付", + "Windows Server 2008 SE 32bit SP2 (日本語版)", + // AU + "CentOS 5.4 64bit (English)", "CentOS 5.4 32bit (English)", + "Windows Server 2008 R2 SE 64bit (English)", + "Windows Server 2008 R2 EE 64bit (English)"); + + @Test + public void testConversion() { + for (String description : operatingSystems) { + Builder builder = DiskImage.builder(); + builder.osName(description); + builder.osType("hvm"); + builder.creatorName("creator"); + builder.registrant("registrant"); + builder.description("description"); + builder.id("ABCDEFGH"); + DiskImage image = builder.build(); + + OperatingSystem os = new DiskImageToOperatingSystem().apply(image); + + assertNotNull(os, description); + assertNotNull(os.getFamily(), description); + assertFalse(os.getFamily().equals(OsFamily.UNRECOGNIZED), + "OsFamily not recognised: " + description); + assertNotNull(os.getVersion(), "Version not recognised: " + + description); + assertEquals(os.getName(), description); + assertEquals(os.getDescription(), description); + assertNotNull(os.getArch(), description); + } + } + + @Test + public void testOsFamilyUnrecognized() { + DiskImage image = DiskImage.builder() + .osName("not a known operating system").build(); + + OperatingSystem os = new DiskImageToOperatingSystem().apply(image); + + assertNotNull(os); + assertEquals(os.getFamily(), OsFamily.UNRECOGNIZED); + } + + @Test + public void test64BitsWithSpace() { + DiskImage image = DiskImage.builder().osName("a (64 bit) os").build(); + + OperatingSystem os = new DiskImageToOperatingSystem().apply(image); + + assertNotNull(os); + assertTrue(os.is64Bit()); + } + + @Test + public void test64BitsNoSpace() { + DiskImage image = DiskImage.builder().osName("a (64bit) os").build(); + + OperatingSystem os = new DiskImageToOperatingSystem().apply(image); + + assertNotNull(os); + assertTrue(os.is64Bit()); + } + + @Test + public void test32BitsNoSpace() { + DiskImage image = DiskImage.builder().osName("a (32bit) os").build(); + + OperatingSystem os = new DiskImageToOperatingSystem().apply(image); + + assertNotNull(os); + assertFalse(os.is64Bit()); + } + + @Test + public void testx64NoSpace() { + DiskImage image = DiskImage.builder().osName("a (x64) os").build(); + + OperatingSystem os = new DiskImageToOperatingSystem().apply(image); + + assertNotNull(os); + assertTrue(os.is64Bit()); + } + + @Test + public void testWindowsVersion() { + DiskImage image = DiskImage.builder() + .osName("Windows Server 2008 R2 SE 64 bit").build(); + + OperatingSystem os = new DiskImageToOperatingSystem().apply(image); + + assertNotNull(os); + assertEquals(os.getVersion(), "2008 R2 SE"); + } + + @Test + public void testCentOSVersion() { + DiskImage image = DiskImage.builder() + .osName("CentOS 6.2 64bit (English)").build(); + + OperatingSystem os = new DiskImageToOperatingSystem().apply(image); + + assertNotNull(os); + assertEquals(os.getVersion(), "6.2"); + } + + @Test + public void testUnrecognizedOsVersion() { + DiskImage image = DiskImage.builder() + .osName("Windows Server 2099 (256 bit)").build(); + + OperatingSystem os = new DiskImageToOperatingSystem().apply(image); + + assertNotNull(os); + assertNull(os.getVersion()); + } + + @Test + public void testOsVersionMissing() { + DiskImage image = DiskImage.builder().osName("asd Server").build(); + + OperatingSystem os = new DiskImageToOperatingSystem().apply(image); + assertNotNull(os); + assertNull(os.getVersion(), "os.getVersion(): \'" + os.getVersion() + + "\'"); + } +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApiExpectTest.java new file mode 100644 index 0000000000..953fceb870 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApiExpectTest.java @@ -0,0 +1,157 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import static org.testng.Assert.assertEquals; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "AdditionalDiskApiExpectTest", singleThreaded = true) +public class AdditionalDiskApiExpectTest extends BaseFGCPRestApiExpectTest { + + public void testGet() { + HttpRequest request = buildGETWithQuery("Action=GetVDiskAttributes" + + "&vdiskId=CONTRACT-VSYS00001-D-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetVDiskAttributes-response.xml")) + .build(); + + AdditionalDiskApi api = requestSendsResponse(request, response) + .getAdditionalDiskApi(); + + assertEquals(api.get("CONTRACT-VSYS00001-D-0001").getSize(), 10.0); + } + + public void testGetStatus() { + HttpRequest request = buildGETWithQuery("Action=GetVDiskStatus" + + "&vdiskId=CONTRACT-VSYS00001-S-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetVDiskStatus-response.xml")) + .build(); + + AdditionalDiskApi api = requestSendsResponse(request, response) + .getAdditionalDiskApi(); + + // api is returning STOPPED which is not a documented status. Documentation error? +// assertEquals(api.getStatus("CONTRACT-VSYS00001-S-0001"), VDiskStatus.STOPPED); + } + + public void testUpdate() { + HttpRequest request = buildGETWithQuery("Action=UpdateVDiskAttribute" + + "&vdiskId=CONTRACT-VSYS00001-D-0001" + + "&attributeValue=new-name" + "&attributeName=updateName" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/UpdateVDiskAttribute-response.xml")) + .build(); + + AdditionalDiskApi api = requestSendsResponse(request, response) + .getAdditionalDiskApi(); + + api.update("CONTRACT-VSYS00001-D-0001", "updateName", "new-name"); + } + + public void testDestroy() { + HttpRequest request = buildGETWithQuery("Action=DestroyVDisk" + + "&vdiskId=CONTRACT-VSYS00001-D-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/DestroyVDisk-response.xml")) + .build(); + + AdditionalDiskApi api = requestSendsResponse(request, response) + .getAdditionalDiskApi(); + + api.destroy("CONTRACT-VSYS00001-D-0001"); + } + + public void testBackup() { + HttpRequest request = buildGETWithQuery("Action=BackupVDisk" + + "&vdiskId=CONTRACT-VSYS00001-D-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/BackupVDisk-response.xml")) + .build(); + + AdditionalDiskApi api = requestSendsResponse(request, response) + .getAdditionalDiskApi(); + + api.backup("CONTRACT-VSYS00001-D-0001"); + } + + public void testRestore() { + HttpRequest request = buildGETWithQuery("Action=RestoreVDisk" + + "&vsysId=CONTRACT-VSYS00001" + + "&backupId=003"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/RestoreVDisk-response.xml")) + .build(); + + AdditionalDiskApi api = requestSendsResponse(request, response) + .getAdditionalDiskApi(); + + api.restore("CONTRACT-VSYS00001", "003"); + } + + public void testDetach() { + HttpRequest request = buildGETWithQuery("Action=DetachVDisk" + + "&vdiskId=CONTRACT-VSYS00001-D-0001" + + "&vserverId=CONTRACT-VSYS00001-S-0006" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/DetachVDisk-response.xml")) + .build(); + + AdditionalDiskApi api = requestSendsResponse(request, response) + .getAdditionalDiskApi(); + + api.detach("CONTRACT-VSYS00001-D-0001", "CONTRACT-VSYS00001-S-0006"); + } + + public void testDestroyBackup() { + HttpRequest request = buildGETWithQuery("Action=DestroyVDiskBackup" + + "&vsysId=CONTRACT-VSYS00001" + + "&backupId=003"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/DestroyVDiskBackup-response.xml")) + .build(); + + AdditionalDiskApi api = requestSendsResponse(request, response) + .getAdditionalDiskApi(); + + api.destroyBackup("CONTRACT-VSYS00001", "003"); + } + +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPApiLiveTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPApiLiveTest.java new file mode 100644 index 0000000000..1da6e1fa84 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPApiLiveTest.java @@ -0,0 +1,84 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import java.util.Properties; + +import org.jclouds.Constants; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.fujitsu.fgcp.FGCPApi; +import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; +import org.jclouds.rest.RestContext; +import org.jclouds.sshj.config.SshjSshClientModule; +import org.testng.annotations.BeforeGroups; + +import com.google.inject.Module; + +/** + * @author Dies Koper + */ +public class BaseFGCPApiLiveTest extends BaseComputeServiceContextLiveTest { + + protected RestContext fgcpContext; + + public BaseFGCPApiLiveTest() { + provider = "fgcp"; + } + + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + + String proxy = System.getenv("http_proxy"); + if (proxy != null) { + + String[] parts = proxy.split("http://|:|@"); + + overrides.setProperty(Constants.PROPERTY_PROXY_HOST, + parts[parts.length - 2]); + overrides.setProperty(Constants.PROPERTY_PROXY_PORT, + parts[parts.length - 1]); + + if (parts.length >= 4) { + overrides.setProperty(Constants.PROPERTY_PROXY_USER, + parts[parts.length - 4]); + overrides.setProperty(Constants.PROPERTY_PROXY_PASSWORD, + parts[parts.length - 3]); + } + } + + // enables peer verification using the CAs bundled with the JRE (or + // value of javax.net.ssl.trustStore if set) + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "false"); + + return overrides; + } + + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + fgcpContext = view.unwrap(); + } + + @Override + protected Module getSshModule() { + return new SshjSshClientModule(); + } +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPRestApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPRestApiExpectTest.java new file mode 100644 index 0000000000..2fb42da3df --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPRestApiExpectTest.java @@ -0,0 +1,125 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import static org.testng.Assert.assertNotNull; + +import java.net.URI; +import java.net.URL; +import java.util.Calendar; +import java.util.Locale; +import java.util.TimeZone; + +import javax.ws.rs.core.MediaType; + +import org.jclouds.fujitsu.fgcp.FGCPApi; +import org.jclouds.fujitsu.fgcp.FGCPProviderMetadata; +import org.jclouds.fujitsu.fgcp.compute.FGCPRestClientModule; +import org.jclouds.http.HttpRequest; +import org.jclouds.io.Payload; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.internal.BaseRestClientExpectTest; + +import com.google.common.collect.ImmutableMultimap; +import com.google.inject.Module; + +/** + * @author Dies Koper + */ +public class BaseFGCPRestApiExpectTest extends + BaseRestClientExpectTest { + + public BaseFGCPRestApiExpectTest() { + provider = "fgcp"; + + // self-signed dummy cert: + // keytool -genkey -alias test-fgcp -keyalg RSA -keysize 1024 -validity 5475 -dname "CN=localhost" -keystore jclouds-test-fgcp.p12 -storepass jcloudsjclouds -storetype pkcs12 + String cert = "/certs/jclouds-test-fgcp.p12"; + URL url = this.getClass().getResource(cert); + assertNotNull(url, cert + " not found"); + + identity = url.getFile(); + credential = "jcloudsjclouds"; + } + + @ConfiguresRestClient + protected static final class TestFGCPRestClientModule extends + FGCPRestClientModule { + + @Override + protected Calendar provideCalendar() { + // pick country/TZ with no DST just in case to maintain constant + // time wherever the tests are run. + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-9"), + Locale.JAPAN); + cal.setTimeInMillis(1234567890); + return cal; + } + } + + @Override + protected Module createModule() { + return new TestFGCPRestClientModule(); + } + + @Override + protected ProviderMetadata createProviderMetadata() { + return new FGCPProviderMetadata(); + } + + @Override + public Payload payloadFromResource(String resource) { + return super.payloadFromResource("/responses" + resource); + } + + protected static HttpRequest buildGETWithQuery(String query) { + URI uri = URI.create("https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint" + + "?Version=2012-02-18" + + "&" + query + + "&Locale=en" + + "&AccessKeyId=R01ULTA5OjAwJjEyMzQ1Njc4OTAmMS4wJlNIQTF3aXRoUlNB" +// + "&Signature=G2rGfLAkbq0IURQfXIWYxj3BnMGbjRk4KPnZLAze3Lt4SMMRt8lkjqKvR5Cm%2BnFpDN7J6IprVCCsIrRq5BqPeXT6xtWyb6qMNds2BAr1h%2FJePGs0UosOh2tgPUMSFlZwLVjgNyrSa2zeHA3AEHjF6H1jqcWXXqfCAD4SOHaNavk%3D"); + + "&Signature=G2rGfLAkbq0IURQfXIWYxj3BnMGbjRk4KPnZLAze3Lt4SMMRt8lkjqKvR5Cm%2BnFpDN7J6IprVCCs%0D%0AIrRq5BqPeXT6xtWyb6qMNds2BAr1h%2FJePGs0UosOh2tgPUMSFlZwLVjgNyrSa2zeHA3AEHjF6H1j%0D%0AqcWXXqfCAD4SOHaNavk%3D"); + return HttpRequest + .builder() + .method("GET") + .endpoint(uri) + .addHeader("Accept", "text/xml") + .addHeader("User-Agent", "OViSS-API-CLIENT") + .build(); + } + + protected HttpRequest preparePOSTForAction(String action) { + return HttpRequest + .builder() + .method("POST") + .endpoint( + URI.create("https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint")) + .payload( + payloadFromResourceWithContentType( + "/" + action.toLowerCase() + "-request.xml", + MediaType.TEXT_XML)) + .headers( + ImmutableMultimap. builder() + .put("Accept", "text/xml") + .put("User-Agent", "OViSS-API-CLIENT").build()) + .build(); + } +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApiExpectTest.java new file mode 100644 index 0000000000..acb2f165c3 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApiExpectTest.java @@ -0,0 +1,215 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertEquals; + +import java.util.Set; + +import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerBackup; +import org.jclouds.fujitsu.fgcp.domain.BuiltinServerStatus; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "BuiltinServerApiExpectTest", singleThreaded = true) +public class BuiltinServerApiExpectTest extends BaseFGCPRestApiExpectTest { + + public void testStart() { + HttpRequest request = buildGETWithQuery("Action=StartEFM" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/StartEFM-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + + api.start("CONTRACT-VSYS00001-S-0001"); + } + + public void testStop() { + HttpRequest request = buildGETWithQuery("Action=StopEFM" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/StopEFM-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + + api.stop("CONTRACT-VSYS00001-S-0001"); + } + + public void testDestroy() { + HttpRequest request = buildGETWithQuery("Action=DestroyEFM" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/DestroyEFM-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + + api.destroy("CONTRACT-VSYS00001-S-0001"); + } + + public void testGet() { + HttpRequest request = buildGETWithQuery("Action=GetEFMAttributes" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetEFMAttributes-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + + assertEquals(api.get("CONTRACT-VSYS00001-S-0001").getType(), BuiltinServer.BuiltinServerType.FW); + } + +/* + public void testGetDetails() { + HttpRequest request = buildGETWithQuery("Action=GetEFMConfiguration" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetEFMConfiguration-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + +// assertNotNull(api.getDetails("CONTRACT-VSYS00001-S-0001")); + } +*/ + + public void testGetStatus() { + HttpRequest request = buildGETWithQuery("Action=GetEFMStatus" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetEFMStatus-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + + assertEquals(api.getStatus("CONTRACT-VSYS00001-S-0001"), BuiltinServerStatus.RUNNING); + } + + public void testUpdate() { + HttpRequest request = buildGETWithQuery("Action=UpdateEFMAttribute" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&attributeValue=new%20name" + + "&attributeName=vserverName" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/UpdateEFMAttribute-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + + api.update("CONTRACT-VSYS00001-S-0001", "vserverName", "new name"); + } + + public void testBackup() { + HttpRequest request = buildGETWithQuery("Action=BackupEFM" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/BackupEFM-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + + api.backup("CONTRACT-VSYS00001-S-0001"); + } + + public void testRestore() { + HttpRequest request = buildGETWithQuery("Action=RestoreEFM" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&backupId=003" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/RestoreEFM-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + + api.restore("CONTRACT-VSYS00001-S-0001", "003"); + } + + public void testListBackups() { + HttpRequest request = buildGETWithQuery("Action=ListEFMBackup" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/ListEFMBackup-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + + Set backups = api.listBackups("CONTRACT-VSYS00001-S-0001"); + assertNotNull(backups, "backups"); + assertEquals(backups.size(), 2); + assertEquals(backups.iterator().next().getId(), "001"); + assertEquals(backups.iterator().next().getTime(), "20121008201127"); + } + + public void testDestroyBackup() { + HttpRequest request = buildGETWithQuery("Action=DestroyEFMBackup" + + "&efmId=CONTRACT-VSYS00001-S-0001" + + "&backupId=003" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/DestroyEFMBackup-response.xml")) + .build(); + + BuiltinServerApi api = requestSendsResponse(request, response) + .getFirewallApi(); + + api.destroyBackup("CONTRACT-VSYS00001-S-0001", "003"); + } + +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/DiskImageApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/DiskImageApiExpectTest.java new file mode 100644 index 0000000000..d0ae9a027a --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/DiskImageApiExpectTest.java @@ -0,0 +1,79 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import static org.testng.Assert.assertEquals; + +import org.jclouds.fujitsu.fgcp.domain.DiskImage; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "DiskImageApiExpectTest", singleThreaded = true) +public class DiskImageApiExpectTest extends BaseFGCPRestApiExpectTest { + + public void testGet() { + HttpRequest request = buildGETWithQuery("Action=GetDiskImageAttributes" + + "&diskImageId=IMG_A1B2C3_1234567890ABCD"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/GetDiskImageAttributes-response.xml")) + .build(); + + DiskImageApi api = requestSendsResponse(request, response) + .getDiskImageApi(); + + DiskImage image = api.get("IMG_A1B2C3_1234567890ABCD"); + + assertEquals(image.getId(), "IMG_A1B2C3_1234567890ABCD"); + assertEquals(image.getCreatorName(), "ABCDEFGH"); + } + + public void testUpdate() { + HttpRequest request = buildGETWithQuery("Action=UpdateDiskImageAttribute" + + "&diskImageId=IMG_A1B2C3_1234567890ABCD" + + "&attributeName=updateName" + + "&updateLcId=en" + + "&attributeValue=new-name"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/UpdateDiskImageAttribute-response.xml")) + .build(); + + DiskImageApi api = requestSendsResponse(request, response) + .getDiskImageApi(); + + api.update("IMG_A1B2C3_1234567890ABCD", "en", "updateName", "new-name"); + } + + public void testDeregister() { + HttpRequest request = buildGETWithQuery("Action=UnregisterDiskImage" + + "&diskImageId=IMG_A1B2C3_1234567890ABCD"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/UnregisterDiskImage-response.xml")) + .build(); + + DiskImageApi api = requestSendsResponse(request, response) + .getDiskImageApi(); + + api.deregister("IMG_A1B2C3_1234567890ABCD"); + } + +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApiExpectTest.java new file mode 100644 index 0000000000..226ec070c2 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApiExpectTest.java @@ -0,0 +1,109 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import org.jclouds.fujitsu.fgcp.domain.PublicIP; +import org.jclouds.fujitsu.fgcp.domain.PublicIPStatus; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "PublicIPAddressApiExpectTest", singleThreaded = true) +public class PublicIPAddressApiExpectTest extends BaseFGCPRestApiExpectTest { + + public void testAttach() { + HttpRequest request = buildGETWithQuery("Action=AttachPublicIP" + + "&vsysId=CONTRACT-VSYS00001" + + "&publicIp=123.45.67.89"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/AttachPublicIP-response.xml")) + .build(); + + PublicIPAddressApi api = requestSendsResponse(request, response) + .getPublicIPAddressApi(); + + api.attach("CONTRACT-VSYS00001", "123.45.67.89"); + } + + public void testDetach() { + HttpRequest request = buildGETWithQuery("Action=DetachPublicIP" + + "&vsysId=CONTRACT-VSYS00001" + + "&publicIp=123.45.67.89"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/DetachPublicIP-response.xml")) + .build(); + + PublicIPAddressApi api = requestSendsResponse(request, response) + .getPublicIPAddressApi(); + + api.detach("CONTRACT-VSYS00001", "123.45.67.89"); + } + + public void testFree() { + HttpRequest request = buildGETWithQuery("Action=FreePublicIP" + + "&vsysId=CONTRACT-VSYS00001" + + "&publicIp=123.45.67.89"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/FreePublicIP-response.xml")) + .build(); + + PublicIPAddressApi api = requestSendsResponse(request, response) + .getPublicIPAddressApi(); + + api.free("CONTRACT-VSYS00001", "123.45.67.89"); + } + + public void testGetStatus() { + HttpRequest request = buildGETWithQuery("Action=GetPublicIPStatus" + + "&publicIp=123.45.67.89"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/GetPublicIPStatus-response.xml")) + .build(); + + PublicIPAddressApi api = requestSendsResponse(request, response) + .getPublicIPAddressApi(); + + PublicIPStatus status = api.getStatus("123.45.67.89"); + assertEquals(status, PublicIPStatus.ATTACHED); + } + + public void testGet() { + HttpRequest request = buildGETWithQuery("Action=GetPublicIPAttributes" + + "&publicIp=123.45.67.89"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/GetPublicIPAttributes-response.xml")) + .build(); + + PublicIPAddressApi api = requestSendsResponse(request, response) + .getPublicIPAddressApi(); + + PublicIP ip = api.get("123.45.67.89"); + + assertNotNull(ip, "ip"); + assertEquals(ip.getAddress(), "123.45.67.89"); + assertEquals(ip.getVersion(), PublicIP.Version.IPv4); + } + +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApiExpectTest.java new file mode 100644 index 0000000000..182c13faf6 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApiExpectTest.java @@ -0,0 +1,103 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import org.jclouds.fujitsu.fgcp.domain.VSystem; +import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "SystemTemplateApiExpectTest", singleThreaded = true) +public class SystemTemplateApiExpectTest extends BaseFGCPRestApiExpectTest { + + public void testGet() { + HttpRequest request = buildGETWithQuery("Action=GetVSYSDescriptorConfiguration" + + "&vsysDescriptorId=3-tier%20Skeleton"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetVSYSDescriptorConfiguration-response.xml")) + .build(); + SystemTemplateApi client = requestSendsResponse(request, response) + .getSystemTemplateApi(); + + VSystemDescriptor desc = client.get("3-tier Skeleton"); + assertNotNull(desc, "desc"); +// assertEquals(desc.) + } + + + public void testUpdate() { + HttpRequest request = buildGETWithQuery("Action=UpdateVSYSDescriptorAttribute" + + "&vsysDescriptorId=3-tier%20Skeleton" + "&attributeName=updateName" + + "&updateLcId=en" + + "&attributeValue=new-name"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/UpdateVSYSDescriptorAttribute-response.xml")) + .build(); + + SystemTemplateApi api = requestSendsResponse(request, response) + .getSystemTemplateApi(); + + api.update("3-tier Skeleton", "en", "updateName", "new-name"); + } + + public void testDeregister() { + HttpRequest request = buildGETWithQuery("Action=UnregisterVSYSDescriptor" + + "&vsysDescriptorId=3-tier%20Skeleton"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/UnregisterVSYSDescriptor-response.xml")) + .build(); + + SystemTemplateApi api = requestSendsResponse(request, response) + .getSystemTemplateApi(); + + api.deregister("3-tier Skeleton"); + } + + public void testDeregisterPrivateTemplate() { + HttpRequest request = buildGETWithQuery("Action=UnregisterPrivateVSYSDescriptor" + + "&vsysDescriptorId=3-tier%20Skeleton"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/UnregisterPrivateVSYSDescriptor-response.xml")) + .build(); + + SystemTemplateApi api = requestSendsResponse(request, response) + .getSystemTemplateApi(); + + api.deregisterPrivateTemplate("3-tier Skeleton"); + } +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiExpectTest.java new file mode 100644 index 0000000000..277a449fe6 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiExpectTest.java @@ -0,0 +1,207 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.util.Map; +import java.util.Set; + +import org.jclouds.fujitsu.fgcp.domain.AddressRange; +import org.jclouds.fujitsu.fgcp.domain.DiskImage; +import org.jclouds.fujitsu.fgcp.domain.EventLog; +import org.jclouds.fujitsu.fgcp.domain.PublicIP; +import org.jclouds.fujitsu.fgcp.domain.ServerType; +import org.jclouds.fujitsu.fgcp.domain.VSystem; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "VirtualDCApiExpectTest", singleThreaded = true) +public class VirtualDCApiExpectTest extends BaseFGCPRestApiExpectTest { + + public void testListVirtualSystems() { + HttpRequest request = buildGETWithQuery("Action=ListVSYS"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/ListVSYS-response.xml")) + .build(); + + VirtualDCApi api = requestSendsResponse(request, response).getVirtualDCApi(); + + Set vsysSet = api.listVirtualSystems(); + assertEquals(vsysSet.size(), 2); + } + + public void testCreateVirtualSystem() { + HttpRequest request = buildGETWithQuery("Action=CreateVSYS&vsysDescriptorId=myDescId&vsysName=myVSYS"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/CreateVSYS-response.xml")) + .build(); + VirtualDCApi api = requestSendsResponse(request, response) + .getVirtualDCApi(); + + String vsysId = api.createVirtualSystem("myDescId", "myVSYS"); + assertEquals(vsysId, "CONTRACT-VSYS00001", "vsysId: " + vsysId); + } + + + public void testListServerTypes() { + HttpRequest request = buildGETWithQuery("Action=ListServerType&diskImageId=dummy"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/ListServerType-response.xml")) + .build(); + VirtualDCApi api = requestSendsResponse(request, response) + .getVirtualDCApi(); + + Set serverTypes = api.listServerTypes(); + assertNotNull(serverTypes, "serverTypes"); + assertEquals(serverTypes.size(), 4, + "Unexpected number of server types: " + serverTypes.size()); + } + + public void testListPublicIPs() { + HttpRequest request = buildGETWithQuery("Action=ListPublicIP"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/ListPublicIP-response.xml")) + .build(); + VirtualDCApi api = requestSendsResponse(request, response) + .getVirtualDCApi(); + + Map ips = api.listPublicIPs(); + + assertNotNull(ips, "ips"); + assertEquals(ips.size(), 2, "Unexpected number of ips: " + ips.size()); + assertEquals(ips.keySet().size(), 2, "Unexpected number of ips: " + ips.size()); + assertTrue(ips.containsValue("ABCDEFGH-A123B456CE"), "missing system id"); + assertEquals(ips.keySet().iterator().next().getVersion(), PublicIP.Version.IPv4); + } + + public void testListDiskImages() { + HttpRequest request = buildGETWithQuery("Action=ListDiskImage"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/ListDiskImages-response.xml")) + .build(); + VirtualDCApi api = requestSendsResponse(request, response) + .getVirtualDCApi(); + + Set images = api.listDiskImages(); + + assertNotNull(images, "images"); + assertTrue(images.size() > 5, "Unexpected number of images: " + images.size()); + } + + public void testListDiskImage() { + HttpRequest request = buildGETWithQuery("Action=ListDiskImage&vsysDescriptorId=IMG_A1B2C3_1234567890ABCD"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/ListDiskImage-response.xml")) + .build(); + VirtualDCApi api = requestSendsResponse(request, response) + .getVirtualDCApi(); + + Set images = api.listDiskImages(null, "IMG_A1B2C3_1234567890ABCD"); + + assertNotNull(images, "images"); + assertTrue(images.size() == 1, "Unexpected number of images: " + images.size()); + } + + public void testGetAddressRange() { + HttpRequest request = buildGETWithQuery("Action=GetAddressRange"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/GetAddressRange-response.xml")) + .build(); + VirtualDCApi api = requestSendsResponse(request, response) + .getVirtualDCApi(); + + Set range = api.getAddressRange(); + assertNotNull(range); + assertEquals(range.size(), 1); + } + + public void testAddAddressRange() { + HttpRequest request = buildGETWithQuery("Action=AddAddressRange" + + "&pipFrom=192.168.0.0" + + "&pipTo=192.168.30.0"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/AddAddressRange-response.xml")) + .build(); + VirtualDCApi api = requestSendsResponse(request, response) + .getVirtualDCApi(); + + api.addAddressRange("192.168.0.0", "192.168.30.0"); + } + + public void testDeleteAddressRange() { + HttpRequest request = buildGETWithQuery("Action=DeleteAddressRange" + + "&pipFrom=192.168.0.0" + + "&pipTo=192.168.30.0"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/DeleteAddressRange-response.xml")) + .build(); + VirtualDCApi api = requestSendsResponse(request, response) + .getVirtualDCApi(); + + api.deleteAddressRange("192.168.0.0", "192.168.30.0"); + } + + public void testCreateAddressPool() { + HttpRequest request = buildGETWithQuery("Action=CreateAddressPool" + + "&pipFrom=192.168.0.0" + + "&pipTo=192.168.30.0"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/CreateAddressPool-response.xml")) + .build(); + VirtualDCApi api = requestSendsResponse(request, response) + .getVirtualDCApi(); + + api.createAddressPool("192.168.0.0", "192.168.30.0"); + } + + public void testGetEventLog() { + HttpRequest request = buildGETWithQuery("Action=GetEventLog"); + HttpResponse response = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/GetEventLog-response.xml")) + .build(); + VirtualDCApi api = requestSendsResponse(request, response) + .getVirtualDCApi(); + + Set logs = api.getEventLogs(); + assertNotNull(logs); + //TODO: get one with several +// assertEquals(logs.size(), 1); + } + + + +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiLiveTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiLiveTest.java new file mode 100644 index 0000000000..0e873ed543 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiLiveTest.java @@ -0,0 +1,77 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.util.Set; + +import org.jclouds.fujitsu.fgcp.domain.ServerType; +import org.jclouds.fujitsu.fgcp.domain.VSystem; +import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VirtualDCApiLiveTest") +public class VirtualDCApiLiveTest extends BaseFGCPApiLiveTest { + + private VirtualDCApi api; + + @BeforeGroups(groups = { "live" }) + public void setupContext() { + super.setupContext(); + api = fgcpContext.getApi().getVirtualDCApi(); + } + + public void testListVirtualSystems() { +/* Properties overrides = setupProperties(); + RestContext context = new RestContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), + overrides);*/ + + Set vsysSet = api.listVirtualSystems(); + assertNotNull(vsysSet, "vsysSet"); + assertTrue(vsysSet.size() > 0, "vsysSet.size() should be greater than 0"); + for (VSystem vsys : vsysSet) { + System.out.println(vsys); + } + } + +/* public void testCreateVirtualSystem() { + String vsysId = api.createVirtualSystem("abc", "def"); + + assertNotNull(vsysId, "vsysId"); + assertFalse(vsysId.equals(""), "vsysId is empty (\"\")"); + System.out.println("vsysId: " + vsysId); + }*/ + + public void testListServerTypes() { + Set serverTypes = api.listServerTypes(); + + assertNotNull(serverTypes, "serverTypes"); + assertTrue(serverTypes.size() == 4, "serverTypes.size should return 4, not " + serverTypes.size()); + +// System.out.println("listServerTypes: " + serverTypes); + } + + + +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApiExpectTest.java new file mode 100644 index 0000000000..198993c25d --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApiExpectTest.java @@ -0,0 +1,221 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.Assert.assertEquals; + +import org.jclouds.fujitsu.fgcp.domain.VServerStatus; +import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "VirtualServerApiExpectTest", singleThreaded = true) +public class VirtualServerApiExpectTest extends BaseFGCPRestApiExpectTest { + + public void testStart() { + HttpRequest request = buildGETWithQuery("Action=StartVServer" + + "&vserverId=CONTRACT-VSYS00001-S-0005" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/StartVServer-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + api.start("CONTRACT-VSYS00001-S-0005"); + } + + public void testStop() { + HttpRequest request = buildGETWithQuery("Action=StopVServer" + + "&vserverId=CONTRACT-VSYS00001-S-0005" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/StopVServer-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + api.stop("CONTRACT-VSYS00001-S-0005"); + } + + public void testStopForcefully() { + HttpRequest request = buildGETWithQuery("Action=StopVServer" + + "&force=true" + + "&vserverId=CONTRACT-VSYS00001-S-0005" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/StopVServer-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + api.stopForcefully("CONTRACT-VSYS00001-S-0005"); + } + + public void testDestroy() { + HttpRequest request = buildGETWithQuery("Action=DestroyVServer" + + "&vserverId=CONTRACT-VSYS00001-S-0005" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/DestroyVServer-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + api.destroy("CONTRACT-VSYS00001-S-0005"); + } + + public void testGet() { + HttpRequest request = buildGETWithQuery("Action=GetVServerAttributes" + + "&vserverId=CONTRACT-VSYS00001-S-0005" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetVServerAttributes-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + assertNotNull(api.get("CONTRACT-VSYS00001-S-0005")); + } + + public void testGetDetails() { + HttpRequest request = buildGETWithQuery("Action=GetVServerConfiguration" + + "&vserverId=CONTRACT-VSYS00001-S-0005" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetVServerConfiguration-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + VServerWithDetails server = api.getDetails("CONTRACT-VSYS00001-S-0005"); + assertNotNull(server); + assertEquals(server.getId(), "CONTRACT-VSYS00001-S-0005"); + assertEquals(server.getVnics().iterator().next().getNicNo(), 0); + assertEquals(server.getVnics().iterator().next().getPrivateIp(), "192.168.4.13"); + assertEquals(server.getVnics().iterator().next().getNetworkId(), "CONTRACT-VSYS00001-N-DMZ"); + assertEquals(server.getImage().getId(), "IMG_A1B2C3_1234567890ABCD"); + assertEquals(server.getImage().getSysvolSize(), 10.0f); + } + + public void testGetStatus() { + HttpRequest request = buildGETWithQuery("Action=GetVServerStatus" + + "&vserverId=CONTRACT-VSYS00001-S-0005" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetVServerStatus-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + assertEquals(api.getStatus("CONTRACT-VSYS00001-S-0005"), VServerStatus.STOPPED); + } + + public void testInitialPassword() { + HttpRequest request = buildGETWithQuery("Action=GetVServerInitialPassword" + + "&vserverId=CONTRACT-VSYS00001-S-0005" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetVServerInitialPassword-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + assertEquals(api.getInitialPassword("CONTRACT-VSYS00001-S-0005"), "mySecretpwd1"); + } + + public void testUpdate() { + HttpRequest request = buildGETWithQuery("Action=UpdateVServerAttribute" + + "&vserverId=CONTRACT-VSYS00001-S-0005" + + "&attributeValue=new%20name" + + "&attributeName=vserverName" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/UpdateVServerAttribute-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + api.update("CONTRACT-VSYS00001-S-0005", "vserverName", "new name"); + } + + public void testAttachDisk() { + HttpRequest request = buildGETWithQuery("Action=AttachVDisk" + + "&vserverId=CONTRACT-VSYS00001-S-0005" + + "&vdiskId=CONTRACT-VSYS00001-D-0001" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/AttachVDisk-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + api.attachDisk("CONTRACT-VSYS00001-S-0005", "CONTRACT-VSYS00001-D-0001"); + } + +/* public void testGetPerformanceInformation() { + HttpRequest request = buildGETWithQuery("Action=GetPerformanceInformation" + + "&serverId=CONTRACT-VSYS00001-S-0005" + + "&interval=10minute" + + "&vsysId=CONTRACT-VSYS00001"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetPerformanceInformation-response.xml")) + .build(); + + VirtualServerApi api = requestSendsResponse(request, response) + .getVirtualServerApi(); + + assertNotNull(api.getPerformanceInformation( + "CONTRACT-VSYS00001-S-0005", "10minute")); + } +*/ +} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApiExpectTest.java new file mode 100644 index 0000000000..31aaed1946 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApiExpectTest.java @@ -0,0 +1,259 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.fujitsu.fgcp.services; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.util.Set; + +import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; +import org.jclouds.fujitsu.fgcp.domain.PublicIP; +import org.jclouds.fujitsu.fgcp.domain.VDisk; +import org.jclouds.fujitsu.fgcp.domain.VServer; +import org.jclouds.fujitsu.fgcp.domain.VSystem; +import org.jclouds.fujitsu.fgcp.domain.VSystemStatus; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +/** + * @author Dies Koper + */ +@Test(groups = "unit", testName = "VirtualSystemApiExpectTest", singleThreaded = true) +public class VirtualSystemApiExpectTest extends BaseFGCPRestApiExpectTest { + + public void testGet() { + HttpRequest request = buildGETWithQuery("Action=GetVSYSAttributes&vsysId=ABCDEFGH-A123B456CE"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetVSYSAttributes-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + VSystem system = api.get("ABCDEFGH-A123B456CE"); + assertNotNull(system, "system"); + } + + public void testGetDetails() { + HttpRequest request = buildGETWithQuery("Action=GetVSYSConfiguration&vsysId=ABCDEFGH-A123B456CE"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/GetVSYSConfiguration-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + VSystem system = api.getDetails("ABCDEFGH-A123B456CE"); + assertNotNull(system, "system"); + } + + public void testGetStatus() { + HttpRequest request = buildGETWithQuery("Action=GetVSYSStatus" + + "&vsysId=ABCDEFGH-A123B456CE"); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/GetVSYSStatus-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + assertEquals(api.getStatus("ABCDEFGH-A123B456CE"), VSystemStatus.NORMAL); + } + + public void testUpdate() { + HttpRequest request = buildGETWithQuery("Action=UpdateVSYSAttribute" + + "&vsysId=ABCDEFGH-A123B456CE" + "&attributeValue=new-name" + + "&attributeName=updateName"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/UpdateVDiskAttribute-response.xml")) + .build(); + + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + api.update("ABCDEFGH-A123B456CE", "updateName", "new-name"); + } + + public void testListPublicIPs() { + HttpRequest request = buildGETWithQuery("Action=ListPublicIP" + + "&vsysId=ABCDEFGH-A123B456CE"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/ListPublicIP_one_vsys-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + Set ips = api.listPublicIPs("ABCDEFGH-A123B456CE"); + assertNotNull(ips, "ips"); + assertTrue(ips.size() == 2, "Unexpected number of ips: " + ips.size()); + assertEquals(ips.iterator().next().getVersion(), PublicIP.Version.IPv4); + } + + public void testListServers() { + HttpRequest request = buildGETWithQuery("Action=ListVServer" + + "&vsysId=ABCDEFGH-A123B456CE"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/ListVServer-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + Set servers = api.listServers("ABCDEFGH-A123B456CE"); + assertNotNull(servers, "servers"); + assertEquals(servers.size(), 2); + } + + public void testDisks() { + HttpRequest request = buildGETWithQuery("Action=ListVDisk" + + "&vsysId=ABCDEFGH-A123B456CE"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/ListVDisk-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + Set disks = api.listDisks("ABCDEFGH-A123B456CE"); + assertNotNull(disks, "disks"); + assertEquals(disks.size(), 1); + } + + public void testListBuiltinServers() { + HttpRequest request = buildGETWithQuery("Action=ListEFM" + + "&vsysId=ABCDEFGH-A123B456CE" + "&efmType=FW"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/ListEFM-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + Set fws = api.listBuiltinServers("ABCDEFGH-A123B456CE", "FW"); + assertNotNull(fws, "fws"); + assertEquals(fws.size(), 1); + } + + public void testAllocatePublicIP() { + HttpRequest request = buildGETWithQuery("Action=AllocatePublicIP&vsysId=ABCDEFGH-A123B456CE"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/AllocatePublicIP-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + api.allocatePublicIP("ABCDEFGH-A123B456CE"); + } + + public void testCreateBuiltinServer() { + HttpRequest request = buildGETWithQuery("Action=CreateEFM" + + "&efmType=SLB" + + "&efmName=web%20load%20balancer" + + "&networkId=ABCDEFGH-A123B456CE-N-DMZ" + + "&vsysId=ABCDEFGH-A123B456CE"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/CreateEFM-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + String id = api.createBuiltinServer("web load balancer", + "ABCDEFGH-A123B456CE-N-DMZ"); + assertEquals(id, "CONTRACT-EFM00001"); + } + + public void testCreateServer() { + HttpRequest request = buildGETWithQuery("Action=CreateVServer" + + "&vserverName=vm1" + + "&diskImageId=IMG_A1B2C3_1234567890ABCD" + + "&vserverType=economy" + + "&networkId=ABCDEFGH-A123B456CE-N-DMZ" + + "&vsysId=ABCDEFGH-A123B456CE"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/CreateVServer-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + String id = api.createServer("vm1", "economy", "IMG_A1B2C3_1234567890ABCD", + "ABCDEFGH-A123B456CE-N-DMZ"); + assertEquals(id, "ABCDEFGH-A123B456CE-S-0007"); + } + + public void testCreateDisk() { + HttpRequest request = buildGETWithQuery("Action=CreateVDisk" + + "&vsysId=ABCDEFGH-A123B456CE" + + "&size=10" + + "&vdiskName=disk1"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/CreateVDisk-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + String id = api.createDisk("ABCDEFGH-A123B456CE", "disk1", 10); + assertEquals(id, "ABCDEFGH-A123B456CE-S-0006"); + } + +/* + public void testRegisterAsPrivateImage() { + HttpRequest request = buildGETWithQuery("Action=AllocatePublicIP&vsysId=ABCDEFGH-A123B456CE"); + HttpResponse response = HttpResponse + .builder() + .statusCode(200) + .payload( + payloadFromResource("/AllocatePublicIP-response.xml")) + .build(); + VirtualSystemApi api = requestSendsResponse(request, response) + .getVirtualSystemApi(); + + api.registerAsPrivateVSYSDescriptor("ABCDEFGH-A123B456CE"); + } +*/ +} diff --git a/labs/fgcp/src/test/java/org/jclouds/http/internal/HttpInternalsLiveTest.java b/labs/fgcp/src/test/java/org/jclouds/http/internal/HttpInternalsLiveTest.java new file mode 100644 index 0000000000..7ab8c2a667 --- /dev/null +++ b/labs/fgcp/src/test/java/org/jclouds/http/internal/HttpInternalsLiveTest.java @@ -0,0 +1,38 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.http.internal; + +import static org.testng.Assert.assertNotNull; + +import org.jclouds.fujitsu.fgcp.services.BaseFGCPApiLiveTest; +import org.testng.annotations.Test; + +/** + * Created by IntelliJ IDEA. + * + * @author Dies Koper + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "HttpInternalsLiveTest") +public class HttpInternalsLiveTest extends BaseFGCPApiLiveTest { + + @Test + public void testTrustedSSLContext() { + assertNotNull(context.utils().injector().getInstance(JavaUrlHttpCommandExecutorService.class).sslContextSupplier); + } +} diff --git a/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.p12 b/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.p12 new file mode 100644 index 0000000000..6ff57866ca Binary files /dev/null and b/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.p12 differ diff --git a/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.pem b/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.pem new file mode 100644 index 0000000000..33da39687a --- /dev/null +++ b/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.pem @@ -0,0 +1,35 @@ +Bag Attributes + friendlyName: test-fgcp + localKeyID: 54 69 6D 65 20 31 33 32 36 36 38 34 30 33 32 34 35 31 +Key Attributes: +-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQCHj9j4voqoMfTVvsAUjxoJYCz9cXpmRzkPwoxOOP99bc+xnIEe +K8jOVrlCy0Zwr0fr+PZT15RX8tAzg69kP7WLiVBqYeW7TKZ+9b+HgxUvDd6aaj1C +SVdgHyQPmpcBLe2E2ADvbeEWYFiqhm5ms8Qes/Hb7S5Ct/Ux4R9UUrDnYQIDAQAB +AoGABkxrs1r/DEON8aR0PkBL4GWkkX4FRt1GTHIonLXPQR+qB8GSyjkUkmm7H9xc +AH5UZCVkJI8eqFtyywHyU0EWiTyd3pjkXIuWPcmtydTN3LwY6UZww07g7cAjQNsw +cSXDXfmpAWNoavJWsjd7EUQ1VnnJMDo8A3Jj8BgvF7mTlZUCQQDdMmmOJNBRmbZP +i9jfuggupIHNoJEyI8hQM1LQdyDYMojFZ/hz09vzuWzO1J4XpHtCa2Vuxq9hvC5R +6jKmcTI3AkEAnOQkvv2/2x7T6+7zx53xqFuGjHeNjuaHqTENoT2Gh0oug4IX0HPE +PTw9yVDqDCQe72jeSZZDLpejdF9tcyNHJwJBAIOkC/PfbucRXtGqfdBwK4xutR2G +UMMRTpaEZOXR8Aca1BD/1npAfKdpFBtnqAqUBhM6TSyHLDszPjHb+nbZ6TMCQGEM +Mrq9xd6qDBbmQX+Z8LDepLThAvyBFyuOP0sc/slTFsCcSVTVN29VgzazSYNnGIep +S88jFr2MaTyEBvTwvoMCQE9ZWyYcmpkHxH5X5j6Bpf+ksY6eLnlH/YSOa9Hw8vZY +SR2RvvhAa4UovUoyYJ3p0U/pO/h/W0p5TxIA3V+y7CY= +-----END RSA PRIVATE KEY----- +Bag Attributes + friendlyName: CN=localhost + localKeyID: 54 69 6D 65 20 31 33 32 36 36 38 34 30 33 32 34 35 31 +subject=/CN=localhost +issuer=/CN=localhost +-----BEGIN CERTIFICATE----- +MIIBnzCCAQigAwIBAgIETxOXgDANBgkqhkiG9w0BAQUFADAUMRIwEAYDVQQDEwls +b2NhbGhvc3QwHhcNMTIwMTE2MDMyMDMyWhcNMjcwMTEyMDMyMDMyWjAUMRIwEAYD +VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAIeP2Pi+ +iqgx9NW+wBSPGglgLP1xemZHOQ/CjE44/31tz7GcgR4ryM5WuULLRnCvR+v49lPX +lFfy0DODr2Q/tYuJUGph5btMpn71v4eDFS8N3ppqPUJJV2AfJA+alwEt7YTYAO9t +4RZgWKqGbmazxB6z8dvtLkK39THhH1RSsOdhAgMBAAEwDQYJKoZIhvcNAQEFBQAD +gYEANbfXtBVCUIZiQCU5LP/vKoKZMpE5X6s+kDqTJ3vntuczkN0qFWKIi9WABwAa +/Aq2IffJIu6rZgWchJqhN7+PeVOTfh9xRWE7QFHDrsuBYaicrki7RB1kKCQLtUpD +aZB5xlm5FhT2Hzkgkawdo5keD/+OcDqKVK2fEK8W6r61Spc= +-----END CERTIFICATE----- diff --git a/labs/fgcp/src/test/resources/log4j.xml b/labs/fgcp/src/test/resources/log4j.xml new file mode 100644 index 0000000000..eb276c1631 --- /dev/null +++ b/labs/fgcp/src/test/resources/log4j.xml @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/labs/fgcp/src/test/resources/logback.xml b/labs/fgcp/src/test/resources/logback.xml new file mode 100644 index 0000000000..a4a6a3f2c0 --- /dev/null +++ b/labs/fgcp/src/test/resources/logback.xml @@ -0,0 +1,64 @@ + + + + target/test-data/jclouds.log + + + %d %-5p [%c] [%thread] %m%n + + + + + target/test-data/jclouds-wire.log + + + %d %-5p [%c] [%thread] %m%n + + + + + target/test-data/jclouds-compute.log + + + %d %-5p [%c] [%thread] %m%n + + + + + target/test-data/jclouds-ssh.log + + + %d %-5p [%c] [%thread] %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/requests/CreateVSYS-request.xml b/labs/fgcp/src/test/resources/requests/CreateVSYS-request.xml new file mode 100644 index 0000000000..8dd318b518 --- /dev/null +++ b/labs/fgcp/src/test/resources/requests/CreateVSYS-request.xml @@ -0,0 +1,10 @@ + + + CreateVSYS + myDescId + myVSYS + 2011-01-31 + en + R01ULTA5OjAwJjEyMzQ1Njc4OTAmMS4wJlNIQTF3aXRoUlNB + G2rGfLAkbq0IURQfXIWYxj3BnMGbjRk4KPnZLAze3Lt4SMMRt8lkjqKvR5Cm+nFpDN7J6IprVCCsIrRq5BqPeXT6xtWyb6qMNds2BAr1h/JePGs0UosOh2tgPUMSFlZwLVjgNyrSa2zeHA3AEHjF6H1jqcWXXqfCAD4SOHaNavk= + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/AddAddressRange-response.xml b/labs/fgcp/src/test/resources/responses/AddAddressRange-response.xml new file mode 100644 index 0000000000..81265be495 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/AddAddressRange-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/AllocatePublicIP-response.xml b/labs/fgcp/src/test/resources/responses/AllocatePublicIP-response.xml new file mode 100644 index 0000000000..4411beb9f6 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/AllocatePublicIP-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/AttachPublicIP-response.xml b/labs/fgcp/src/test/resources/responses/AttachPublicIP-response.xml new file mode 100644 index 0000000000..bcc457fb19 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/AttachPublicIP-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/AttachVDisk-response.xml b/labs/fgcp/src/test/resources/responses/AttachVDisk-response.xml new file mode 100644 index 0000000000..0a385835ef --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/AttachVDisk-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/BackupEFM-response.xml b/labs/fgcp/src/test/resources/responses/BackupEFM-response.xml new file mode 100644 index 0000000000..39e69e3475 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/BackupEFM-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/BackupVDisk-response.xml b/labs/fgcp/src/test/resources/responses/BackupVDisk-response.xml new file mode 100644 index 0000000000..0018289051 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/BackupVDisk-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/CreateAddressPool-response.xml b/labs/fgcp/src/test/resources/responses/CreateAddressPool-response.xml new file mode 100644 index 0000000000..17988f5571 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/CreateAddressPool-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/CreateEFM-response.xml b/labs/fgcp/src/test/resources/responses/CreateEFM-response.xml new file mode 100644 index 0000000000..bd20f9a2b0 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/CreateEFM-response.xml @@ -0,0 +1,6 @@ + + + Processing was completed. + SUCCESS + CONTRACT-EFM00001 + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/CreateVDisk-response.xml b/labs/fgcp/src/test/resources/responses/CreateVDisk-response.xml new file mode 100644 index 0000000000..ae7d8a31e4 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/CreateVDisk-response.xml @@ -0,0 +1,6 @@ + + + Processing was completed. + SUCCESS + ABCDEFGH-A123B456CE-S-0006 + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/CreateVSYS-response.xml b/labs/fgcp/src/test/resources/responses/CreateVSYS-response.xml new file mode 100644 index 0000000000..425cbc76f9 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/CreateVSYS-response.xml @@ -0,0 +1,6 @@ + + + Processing was completed. + SUCCESS + CONTRACT-VSYS00001 + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/CreateVServer-response.xml b/labs/fgcp/src/test/resources/responses/CreateVServer-response.xml new file mode 100644 index 0000000000..81c51b985d --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/CreateVServer-response.xml @@ -0,0 +1,6 @@ + + + Processing was completed. + SUCCESS + ABCDEFGH-A123B456CE-S-0007 + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DeleteAddressRange-response.xml b/labs/fgcp/src/test/resources/responses/DeleteAddressRange-response.xml new file mode 100644 index 0000000000..e3cdd50388 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/DeleteAddressRange-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DestroyEFM-response.xml b/labs/fgcp/src/test/resources/responses/DestroyEFM-response.xml new file mode 100644 index 0000000000..aa8e374d0f --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/DestroyEFM-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DestroyEFMBackup-response.xml b/labs/fgcp/src/test/resources/responses/DestroyEFMBackup-response.xml new file mode 100644 index 0000000000..a2da3c49ba --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/DestroyEFMBackup-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DestroyVDisk-response.xml b/labs/fgcp/src/test/resources/responses/DestroyVDisk-response.xml new file mode 100644 index 0000000000..c66a6a9600 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/DestroyVDisk-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DestroyVDiskBackup-response.xml b/labs/fgcp/src/test/resources/responses/DestroyVDiskBackup-response.xml new file mode 100644 index 0000000000..af0088facd --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/DestroyVDiskBackup-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DestroyVServer-response.xml b/labs/fgcp/src/test/resources/responses/DestroyVServer-response.xml new file mode 100644 index 0000000000..c9fbbd2702 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/DestroyVServer-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DetachPublicIP-response.xml b/labs/fgcp/src/test/resources/responses/DetachPublicIP-response.xml new file mode 100644 index 0000000000..ee99b2e3fe --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/DetachPublicIP-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DetachVDisk-response.xml b/labs/fgcp/src/test/resources/responses/DetachVDisk-response.xml new file mode 100644 index 0000000000..877cb7423c --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/DetachVDisk-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/FreePublicIP-response.xml b/labs/fgcp/src/test/resources/responses/FreePublicIP-response.xml new file mode 100644 index 0000000000..7644e11a2b --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/FreePublicIP-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetAddressRange-response.xml b/labs/fgcp/src/test/resources/responses/GetAddressRange-response.xml new file mode 100644 index 0000000000..2eb92bdf74 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetAddressRange-response.xml @@ -0,0 +1,12 @@ + + + + + 192.168.0.0 + MANUAL + 192.168.255.255 + + + Processing was completed. + SUCCESS + diff --git a/labs/fgcp/src/test/resources/responses/GetDiskImageAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetDiskImageAttributes-response.xml new file mode 100644 index 0000000000..044d31df9a --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetDiskImageAttributes-response.xml @@ -0,0 +1,16 @@ + + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCD + CentOS 6.0 64bit(EN) + + CentOS 6.0 64bit (English) + pv + ABCDEFGH + 10.0 + + Processing was completed. + SUCCESS + diff --git a/labs/fgcp/src/test/resources/responses/GetEFMAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetEFMAttributes-response.xml new file mode 100644 index 0000000000..02f7bfeda4 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetEFMAttributes-response.xml @@ -0,0 +1,11 @@ + + + + CONTRACT-VSYS00001 + CONTRACT-VSYS00001-S-0001 + Firewall + FW + + Processing was completed. + SUCCESS + diff --git a/labs/fgcp/src/test/resources/responses/GetEFMStatus-response.xml b/labs/fgcp/src/test/resources/responses/GetEFMStatus-response.xml new file mode 100644 index 0000000000..960d939374 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetEFMStatus-response.xml @@ -0,0 +1,6 @@ + + + Processing was completed. + SUCCESS + RUNNING + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetEventLog-response.xml b/labs/fgcp/src/test/resources/responses/GetEventLog-response.xml new file mode 100644 index 0000000000..6d757f99d7 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetEventLog-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetPerformanceInformation-response.xml b/labs/fgcp/src/test/resources/responses/GetPerformanceInformation-response.xml new file mode 100644 index 0000000000..f34995aea8 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetPerformanceInformation-response.xml @@ -0,0 +1,9 @@ + + + 10minute + Processing was completed. + SUCCESS + CONTRACT-VSYS00001-S-0001 + my server + GENERAL + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetPublicIPAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetPublicIPAttributes-response.xml new file mode 100644 index 0000000000..c9cc6397a1 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetPublicIPAttributes-response.xml @@ -0,0 +1,11 @@ + + + + +

123.45.67.89
+ IPv4 +
+ + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetPublicIPStatus-response.xml b/labs/fgcp/src/test/resources/responses/GetPublicIPStatus-response.xml new file mode 100644 index 0000000000..d8eb549cc6 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetPublicIPStatus-response.xml @@ -0,0 +1,6 @@ + + + ATTACHED + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetVDiskAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetVDiskAttributes-response.xml new file mode 100644 index 0000000000..b0faecc099 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetVDiskAttributes-response.xml @@ -0,0 +1,12 @@ + + + Processing was completed. + SUCCESS + + CONTRACT-VSYS00001-D-0001 + CONTRACT + 10.0 + CONTRACT-VSYS00001-S-0006 + disk1 + + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetVDiskStatus-response.xml b/labs/fgcp/src/test/resources/responses/GetVDiskStatus-response.xml new file mode 100644 index 0000000000..5a0709ad48 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetVDiskStatus-response.xml @@ -0,0 +1,6 @@ + + + Processing was completed. + SUCCESS + STOPPED + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetVSYSAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetVSYSAttributes-response.xml new file mode 100644 index 0000000000..8f1044f249 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetVSYSAttributes-response.xml @@ -0,0 +1,12 @@ + + + Processing was completed. + SUCCESS + + 2-tier Skeleton + ABCDEFGH + 2-tier Skeleton + ABCDEFGH-I123J456K + my virtual system + + diff --git a/labs/fgcp/src/test/resources/responses/GetVSYSConfiguration-response.xml b/labs/fgcp/src/test/resources/responses/GetVSYSConfiguration-response.xml new file mode 100644 index 0000000000..ca01590dc0 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetVSYSConfiguration-response.xml @@ -0,0 +1,78 @@ + + + Processing was completed. + SUCCESS + + 2-tier Skeleton + NONE + ABCDEFGH + 2-tier Skeleton + + + ABCDEFGH + 10.0 + ABCDEFGH-I123J456K-D-0001 + DISK1 + + + + + ABCDEFGH-I123J456K-N-DMZ + + + ABCDEFGH-I123J456K-N-SECURE1 + + + + + ABCDEFGH + IMG_A1B2C3_1234567890ABCD + + + ABCDEFGH-I123J456K-N-DMZ + 4 + 192.168.32.11 + + + ABCDEFGH-I123J456K-N-SECURE1 + 5 + 192.168.33.11 + + + ABCDEFGH-I123J456K-S-0001 + Firewall + economy + + + ABCDEFGH + IMG_A1B2C3_1234567890ABCD + + + ABCDEFGH-I123J456K-N-DMZ + 0 + 192.168.32.13 + + + ABCDEFGH-I123J456K-S-0003 + CentOS 6.3 32bit(EN)1 + economy + + + ABCDEFGH + IMG_A1B2C3_1234567890ABCD + + + ABCDEFGH-I123J456K-N-SECURE1 + 0 + 192.168.33.12 + + + ABCDEFGH-I123J456K-S-0004 + CentOS 6.3 32bit(EN)2 + economy + + + ABCDEFGH-I123J456K + system 2 + + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetVSYSDescriptorConfiguration-response.xml b/labs/fgcp/src/test/resources/responses/GetVSYSDescriptorConfiguration-response.xml new file mode 100644 index 0000000000..5fa9adbcf7 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetVSYSDescriptorConfiguration-response.xml @@ -0,0 +1,21 @@ + + + Processing was completed. + SUCCESS + + ABCDEFGH + 3-tier Skeleton + 3-tier,Skeleton + ABCDEFGH + + + ABCDEFGH + IMG_A1B2C3_1234567890ABCD + Firewall + economy + + + 3-tier Skeleton + 3-tier Skeleton + + diff --git a/labs/fgcp/src/test/resources/responses/GetVSYSStatus-response.xml b/labs/fgcp/src/test/resources/responses/GetVSYSStatus-response.xml new file mode 100644 index 0000000000..552d4a27ee --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetVSYSStatus-response.xml @@ -0,0 +1,6 @@ + + + Processing was completed. + SUCCESS + NORMAL + diff --git a/labs/fgcp/src/test/resources/responses/GetVServerAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetVServerAttributes-response.xml new file mode 100644 index 0000000000..a18730ed4f --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetVServerAttributes-response.xml @@ -0,0 +1,12 @@ + + + Processing was completed. + SUCCESS + + CONTRACT + IMG_A1B2C3_1234567890ABCD + CONTRACT-VSYS00001-S-0001 + my VM + economy + + diff --git a/labs/fgcp/src/test/resources/responses/GetVServerConfiguration-response.xml b/labs/fgcp/src/test/resources/responses/GetVServerConfiguration-response.xml new file mode 100644 index 0000000000..36a8574b22 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetVServerConfiguration-response.xml @@ -0,0 +1,40 @@ + + + Processing was completed. + SUCCESS + + CONTRACT + IMG_A1B2C3_1234567890ABCD + + 32 + IMG_A1B2C3_1234567890ABCD + 14 + 8 + AP + GENERAL + + + OS + SW00000001 + + CentOS 5.4 32bit (English) + 5.4 + + + 5.4 + + + 10.0 + + + + CONTRACT-VSYS00001-N-DMZ + 0 + 192.168.4.13 + + + CONTRACT-VSYS00001-S-0005 + my VM + economy + + diff --git a/labs/fgcp/src/test/resources/responses/GetVServerInitialPassword-response.xml b/labs/fgcp/src/test/resources/responses/GetVServerInitialPassword-response.xml new file mode 100644 index 0000000000..c4816ed315 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetVServerInitialPassword-response.xml @@ -0,0 +1,6 @@ + + + mySecretpwd1 + Processing was completed. + SUCCESS + diff --git a/labs/fgcp/src/test/resources/responses/GetVServerStatus-response.xml b/labs/fgcp/src/test/resources/responses/GetVServerStatus-response.xml new file mode 100644 index 0000000000..d36f0fcd2b --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/GetVServerStatus-response.xml @@ -0,0 +1,6 @@ + + + Processing was completed. + SUCCESS + STOPPED + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListDiskImage-response.xml b/labs/fgcp/src/test/resources/responses/ListDiskImage-response.xml new file mode 100644 index 0000000000..765979a58a --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/ListDiskImage-response.xml @@ -0,0 +1,18 @@ + + + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCD + CentOS 6.0 64bit(EN) + + CentOS 6.0 64bit (English) + pv + ABCDEFGH + 10.0 + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListDiskImages-response.xml b/labs/fgcp/src/test/resources/responses/ListDiskImages-response.xml new file mode 100644 index 0000000000..c7f0e83f79 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/ListDiskImages-response.xml @@ -0,0 +1,118 @@ + + + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCA + + Included + Windows Server 2008 R2 EE 64bit (English) + hvm + ABCDEFGH + 40.0 + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCB + my image + + CentOS 6.2 64bit (English) + pv + ABCDEFGH + 10.0 + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCC + W2k8R2EE(EN) + Included + Windows Server 2008 R2 EE 64bit (English) + hvm + ABCDEFGH + 40.0 + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCD + CentOS 5.6 64bit(EN) + + CentOS 5.6 64bit (English) + pv + ABCDEFGH + 10.0 + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCE + W2k8R2SE/SQL2k8R2(EN) + Included + Windows Server 2008 R2 SE 64bit (English) + hvm + ABCDEFGH + 40.0 + + + Included + SQLServer 2008 R2 SE (English) + + + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCF + W2k8R2SE(EN) + Included + Windows Server 2008 R2 SE 64bit (English) + hvm + ABCDEFGH + 40.0 + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCG + CentOS 6.0 64bit(EN) + + CentOS 6.0 64bit (English) + pv + ABCDEFGH + 10.0 + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCH + CentOS 6.0 32bit(EN) + + CentOS 6.0 32bit (English) + pv + ABCDEFGH + 10.0 + + + ABCDEFGH + + IMG_A1B2C3_1234567890ABCI + W2k8R2SE/IIS(EN) + Included + Windows Server 2008 R2 SE 64bit (English) + hvm + ABCDEFGH + 40.0 + + + + Internet Information Server 7.5 + + + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListEFM-response.xml b/labs/fgcp/src/test/resources/responses/ListEFM-response.xml new file mode 100644 index 0000000000..3e4a1e3be6 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/ListEFM-response.xml @@ -0,0 +1,13 @@ + + + + + ABCDEFGH + ABCDEFGH-A123B456CE-S-0001 + Firewall + FW + + + Processing was completed. + SUCCESS + diff --git a/labs/fgcp/src/test/resources/responses/ListEFMBackup-response.xml b/labs/fgcp/src/test/resources/responses/ListEFMBackup-response.xml new file mode 100644 index 0000000000..780dbedd74 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/ListEFMBackup-response.xml @@ -0,0 +1,15 @@ + + + + + 001 + 20121008201127 + + + 002 + 20121009201127 + + + Processing was completed. + SUCCESS + diff --git a/labs/fgcp/src/test/resources/responses/ListPublicIP-response.xml b/labs/fgcp/src/test/resources/responses/ListPublicIP-response.xml new file mode 100644 index 0000000000..628620959b --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/ListPublicIP-response.xml @@ -0,0 +1,17 @@ + + + + +
123.45.67.89
+ IPv4 + ABCDEFGH-A123B456CE +
+ +
123.45.67.90
+ IPv4 + ABCDEFGH-A123B456CD +
+
+ Processing was completed. + SUCCESS +
diff --git a/labs/fgcp/src/test/resources/responses/ListPublicIP_one_vsys-response.xml b/labs/fgcp/src/test/resources/responses/ListPublicIP_one_vsys-response.xml new file mode 100644 index 0000000000..d470837270 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/ListPublicIP_one_vsys-response.xml @@ -0,0 +1,17 @@ + + + + +
123.45.67.88
+ IPv4 + ABCDEFGH-A123B456CE +
+ +
123.45.67.89
+ IPv4 + ABCDEFGH-A123B456CE +
+
+ Processing was completed. + SUCCESS +
diff --git a/labs/fgcp/src/test/resources/responses/ListServerType-response.xml b/labs/fgcp/src/test/resources/responses/ListServerType-response.xml new file mode 100644 index 0000000000..0c9cee612c --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/ListServerType-response.xml @@ -0,0 +1,82 @@ + + + Processing was completed. + SUCCESS + + + amount + + IA + 4.0 + 1 + + 744 + islanda-cbrm_144 + + 7.5 + + advanced + 0.3 + AUS-VM-0001-0003 + Advanced VM + + + amount + + IA + 1.0 + 1 + + 744 + islanda-cbrm_140 + + 1.7 + + economy + 0.1 + AUS-VM-0001-0001 + Economy VM + + + amount + + IA + 4.0 + 2 + + 744 + islanda-cbrm_146 + + 15.0 + + high_performance + 0.4 + AUS-VM-0001-0004 + High-Performance VM + + + amount + + IA + 2.0 + 1 + + + + 10 + Disk type + Disk purpose + + + 744 + islanda-cbrm_142 + + 3.4 + + standard + 0.3 + AUS-VM-0001-0002 + Standard VM + + + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListVDisk-response.xml b/labs/fgcp/src/test/resources/responses/ListVDisk-response.xml new file mode 100644 index 0000000000..e9e9242ce0 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/ListVDisk-response.xml @@ -0,0 +1,14 @@ + + + Processing was completed. + SUCCESS + + + ABCDEFGH-A123B456CE-S-0006 + ABCDEFGH + 10.0 + ABCDEFGH-A123B456CE-S-0006 + VM1 + + + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListVSYS-response.xml b/labs/fgcp/src/test/resources/responses/ListVSYS-response.xml new file mode 100644 index 0000000000..947f78715b --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/ListVSYS-response.xml @@ -0,0 +1,21 @@ + + + Processing was completed. + SUCCESS + + + 2-tier Skeleton + ABCDEFGH + 2-tier Skeleton + ABCDEFGH-I123J456K + expect test + + + 2-tier Skeleton + ABCDEFGH + 2-tier Skeleton + ABCDEFGH-L654J321I + expect test 2 + + + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListVServer-response.xml b/labs/fgcp/src/test/resources/responses/ListVServer-response.xml new file mode 100644 index 0000000000..643925db2a --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/ListVServer-response.xml @@ -0,0 +1,21 @@ + + + Processing was completed. + SUCCESS + + + ABCDEFGH + IMG_A1B2C3_1234567890ABCD + ABCDEFGH-A123B456CE-S-0005 + VM1 + economy + + + ABCDEFGH + IMG_A1B2C3_1234567890ABCD + ABCDEFGH-A123B456CE-S-0006 + VM2 + standard + + + diff --git a/labs/fgcp/src/test/resources/responses/RestoreEFM-response.xml b/labs/fgcp/src/test/resources/responses/RestoreEFM-response.xml new file mode 100644 index 0000000000..03a98713f5 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/RestoreEFM-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/RestoreVDisk-response.xml b/labs/fgcp/src/test/resources/responses/RestoreVDisk-response.xml new file mode 100644 index 0000000000..a4f4bd7262 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/RestoreVDisk-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/StartEFM-response.xml b/labs/fgcp/src/test/resources/responses/StartEFM-response.xml new file mode 100644 index 0000000000..1914e55354 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/StartEFM-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/StartVServer-response.xml b/labs/fgcp/src/test/resources/responses/StartVServer-response.xml new file mode 100644 index 0000000000..0648bb7a60 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/StartVServer-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/StopEFM-response.xml b/labs/fgcp/src/test/resources/responses/StopEFM-response.xml new file mode 100644 index 0000000000..332d315dfb --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/StopEFM-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/StopVServer-response.xml b/labs/fgcp/src/test/resources/responses/StopVServer-response.xml new file mode 100644 index 0000000000..332d315dfb --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/StopVServer-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UnregisterDiskImage-response.xml b/labs/fgcp/src/test/resources/responses/UnregisterDiskImage-response.xml new file mode 100644 index 0000000000..65d4052bc4 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/UnregisterDiskImage-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UnregisterPrivateVSYSDescriptor-response.xml b/labs/fgcp/src/test/resources/responses/UnregisterPrivateVSYSDescriptor-response.xml new file mode 100644 index 0000000000..fcb6dce2ad --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/UnregisterPrivateVSYSDescriptor-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UnregisterVSYSDescriptor-response.xml b/labs/fgcp/src/test/resources/responses/UnregisterVSYSDescriptor-response.xml new file mode 100644 index 0000000000..884e5fd625 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/UnregisterVSYSDescriptor-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UpdateDiskImageAttribute-response.xml b/labs/fgcp/src/test/resources/responses/UpdateDiskImageAttribute-response.xml new file mode 100644 index 0000000000..5210fc8844 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/UpdateDiskImageAttribute-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UpdateEFMAttribute-response.xml b/labs/fgcp/src/test/resources/responses/UpdateEFMAttribute-response.xml new file mode 100644 index 0000000000..935b9a2ccd --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/UpdateEFMAttribute-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UpdateVDiskAttribute-response.xml b/labs/fgcp/src/test/resources/responses/UpdateVDiskAttribute-response.xml new file mode 100644 index 0000000000..57ad9484d2 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/UpdateVDiskAttribute-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UpdateVSYSDescriptorAttribute-response.xml b/labs/fgcp/src/test/resources/responses/UpdateVSYSDescriptorAttribute-response.xml new file mode 100644 index 0000000000..d660beef84 --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/UpdateVSYSDescriptorAttribute-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UpdateVServerAttribute-response.xml b/labs/fgcp/src/test/resources/responses/UpdateVServerAttribute-response.xml new file mode 100644 index 0000000000..b1be00123b --- /dev/null +++ b/labs/fgcp/src/test/resources/responses/UpdateVServerAttribute-response.xml @@ -0,0 +1,5 @@ + + + Processing was completed. + SUCCESS + \ No newline at end of file diff --git a/labs/pom.xml b/labs/pom.xml index 5ed7f89b84..0ddb6ed9e2 100644 --- a/labs/pom.xml +++ b/labs/pom.xml @@ -58,5 +58,8 @@ smartos-ssh cloudstack-ec2 azure-management + fgcp + fgcp-au + fgcp-de