You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2014/12/23 05:27:03 UTC
[39/51] [partial] stratos git commit: dropping jclouds 1.8.0 clone
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java
deleted file mode 100644
index cac4b2d..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import org.jclouds.ec2.domain.Subnet;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-import com.google.inject.Inject;
-
-/**
- * @see <a href="http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSubnets.html" >xml</a>
- */
-public class DescribeSubnetsResponseHandler extends
- ParseSax.HandlerForGeneratedRequestWithResult<FluentIterable<Subnet>> {
- private final SubnetHandler subnetHandler;
-
- private StringBuilder currentText = new StringBuilder();
- private boolean inSubnetSet;
- private boolean inTagSet;
- private Builder<Subnet> subnets = ImmutableSet.<Subnet> builder();
-
- @Inject
- public DescribeSubnetsResponseHandler(SubnetHandler subnetHandler) {
- this.subnetHandler = subnetHandler;
- }
-
- @Override
- public FluentIterable<Subnet> getResult() {
- return FluentIterable.from(subnets.build());
- }
-
- @Override
- public void startElement(String url, String name, String qName, Attributes attributes) {
- if (equalsOrSuffix(qName, "subnetSet")) {
- inSubnetSet = true;
- } else if (inSubnetSet) {
- if (equalsOrSuffix(qName, "tagSet")) {
- inTagSet = true;
- }
- subnetHandler.startElement(url, name, qName, attributes);
- }
- }
-
- @Override
- public void endElement(String uri, String name, String qName) {
- if (equalsOrSuffix(qName, "subnetSet")) {
- inSubnetSet = false;
- } else if (equalsOrSuffix(qName, "tagSet")) {
- inTagSet = false;
- subnetHandler.endElement(uri, name, qName);
- } else if (equalsOrSuffix(qName, "item") && !inTagSet) {
- subnets.add(subnetHandler.getResult());
- } else if (inSubnetSet) {
- subnetHandler.endElement(uri, name, qName);
- }
-
- currentText = new StringBuilder();
- }
-
- @Override
- public void characters(char ch[], int start, int length) {
- if (inSubnetSet) {
- subnetHandler.characters(ch, start, length);
- } else {
- currentText.append(ch, start, length);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java
deleted file mode 100644
index 9efd6fb..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import org.jclouds.ec2.domain.Tag;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-import com.google.inject.Inject;
-
-/**
- * @see <a
- * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeTags.html"
- * >xml</a>
- */
-public class DescribeTagsResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<FluentIterable<Tag>> {
-
- private final TagHandler tagHander;
-
- private StringBuilder currentText = new StringBuilder();
- private Builder<Tag> tags = ImmutableSet.<Tag> builder();
- private boolean inTags;
-
- @Inject
- public DescribeTagsResponseHandler(TagHandler tagHander) {
- this.tagHander = tagHander;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public FluentIterable<Tag> getResult() {
- return FluentIterable.from(tags.build());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
- if (equalsOrSuffix(qName, "tagSet")) {
- inTags = true;
- }
- if (inTags) {
- tagHander.startElement(url, name, qName, attributes);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (equalsOrSuffix(qName, "tagSet")) {
- inTags = false;
- } else if (equalsOrSuffix(qName, "item")) {
- tags.add(tagHander.getResult());
- } else if (inTags) {
- tagHander.endElement(uri, name, qName);
- }
- currentText = new StringBuilder();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- if (inTags) {
- tagHander.characters(ch, start, length);
- } else {
- currentText.append(ch, start, length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java
deleted file mode 100644
index aa51fa3..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import org.jclouds.ec2.domain.Volume;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.Sets;
-
-public class DescribeVolumesResponseHandler extends ParseSax.HandlerWithResult<Set<Volume>> {
-
- private Set<Volume> volumes = Sets.newLinkedHashSet();
- private final CreateVolumeResponseHandler volumeHandler;
-
- private boolean inAttachmentSet;
-
- @Inject
- public DescribeVolumesResponseHandler(CreateVolumeResponseHandler volumeHandler) {
- this.volumeHandler = volumeHandler;
- }
-
- public Set<Volume> getResult() {
- return volumes;
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes)
- throws SAXException {
- if (qName.equals("attachmentSet")) {
- inAttachmentSet = true;
- }
- volumeHandler.startElement(uri, localName, qName, attributes);
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- volumeHandler.endElement(uri, localName, qName);
- if (qName.equals("attachmentSet")) {
- inAttachmentSet = false;
- } else if (qName.equals("item") && !inAttachmentSet) {
- this.volumes.add(volumeHandler.getResult());
- }
- }
-
- public void characters(char ch[], int start, int length) {
- volumeHandler.characters(ch, start, length);
- }
-
- @Override
- public DescribeVolumesResponseHandler setContext(HttpRequest request) {
- volumeHandler.setContext(request);
- super.setContext(request);
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java
deleted file mode 100644
index 3c342b1..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.io.BaseEncoding.base64;
-
-import java.util.regex.Pattern;
-
-import org.jclouds.http.functions.ParseSax;
-
-/**
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-GetConsoleOutput.html">
- * ApiReference query GetConsoleOutput</a>
- */
-public class GetConsoleOutputResponseHandler extends ParseSax.HandlerWithResult<String> {
-
- private StringBuilder currentText = new StringBuilder();
- private String output;
-
- @Override
- public String getResult() {
- return output;
- }
-
- private static final Pattern whitespace = Pattern.compile("\\s");
-
- @Override
- public void endElement(String uri, String name, String qName) {
- if (qName.equalsIgnoreCase("output")) {
- this.output = new String(base64().decode(whitespace.matcher(currentText).replaceAll("")), UTF_8);
- }
- currentText = new StringBuilder();
- }
-
- @Override
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java
deleted file mode 100644
index 124af5e..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import javax.inject.Inject;
-
-import org.jclouds.date.DateCodec;
-import org.jclouds.date.DateCodecFactory;
-import org.jclouds.ec2.domain.PasswordData;
-import org.jclouds.http.functions.ParseSax;
-
-public class GetPasswordDataResponseHandler extends ParseSax.HandlerWithResult<PasswordData> {
- protected final DateCodec dateCodec;
-
-
- @Inject
- protected GetPasswordDataResponseHandler(DateCodecFactory dateCodecFactory) {
- this.dateCodec = dateCodecFactory.iso8601();
- }
-
- private StringBuilder currentText = new StringBuilder();
- private PasswordData.Builder builder = PasswordData.builder();
-
- @Override
- public PasswordData getResult() {
- return builder.build();
- }
-
- public void endElement(String uri, String name, String qName) {
- if (qName.equals("instanceId")) {
- builder.instanceId(currentText.toString().trim());
- } else if (qName.equals("timestamp")) {
- builder.timestamp(dateCodec.toDate(currentText.toString().trim()));
- } else if (qName.equals("passwordData")) {
- builder.passwordData(currentText.toString().trim());
- }
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java
deleted file mode 100644
index 9d1939c..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import org.jclouds.http.functions.ParseSax;
-
-/**
- *
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-RegisterImage.html"
- * />
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-CreateImage.html"
- * />
- */
-public class ImageIdHandler extends ParseSax.HandlerWithResult<String> {
-
- private StringBuilder currentText = new StringBuilder();
- private String imageId;
-
- public String getResult() {
- return imageId;
- }
-
- public void endElement(String uri, String name, String qName) {
-
- if (qName.equalsIgnoreCase("ImageId")) {
- this.imageId = currentText.toString().trim();
- }
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java
deleted file mode 100644
index 1fb81b6..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
-import org.jclouds.http.functions.ParseSax;
-
-/**
- *
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeInstanceAttribute.html"
- * />
- */
-public class InstanceInitiatedShutdownBehaviorHandler extends
- ParseSax.HandlerWithResult<InstanceInitiatedShutdownBehavior> {
-
- private StringBuilder currentText = new StringBuilder();
- private InstanceInitiatedShutdownBehavior behavior;
-
- public InstanceInitiatedShutdownBehavior getResult() {
- return behavior;
- }
-
- public void endElement(String uri, String name, String qName) {
- if (qName.equalsIgnoreCase("value")) {
- this.behavior = InstanceInitiatedShutdownBehavior.fromValue(currentText.toString().trim());
- }
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java
deleted file mode 100644
index 5290e6b..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import org.jclouds.aws.util.AWSUtils;
-import org.jclouds.ec2.domain.InstanceState;
-import org.jclouds.ec2.domain.InstanceStateChange;
-import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult;
-import org.jclouds.location.Region;
-import org.xml.sax.Attributes;
-
-import com.google.common.base.Supplier;
-import com.google.common.collect.Sets;
-
-/**
- * Parses the following XML document:
- * <p/>
- * TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/"
- * StartInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/" StopInstancesResponse
- * xmlns="http://ec2.amazonaws.com/doc/2010-08-31/"
- *
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-TerminateInstancesResponseInfoType.html"
- * />
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-StartInstancesResponseInfoType.html"
- * />
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-StopInstancesResponseInfoType.html"
- * />
- */
-public class InstanceStateChangeHandler extends
- HandlerForGeneratedRequestWithResult<Set<InstanceStateChange>> {
- private StringBuilder currentText = new StringBuilder();
- @Inject
- @Region
- Supplier<String> defaultRegion;
-
- Set<InstanceStateChange> instances = Sets.newLinkedHashSet();
- private InstanceState shutdownState;
- private InstanceState previousState;
- private String instanceId;
-
- private boolean inCurrentState;
-
- private boolean inPreviousState;
-
- @Override
- public Set<InstanceStateChange> getResult() {
- return instances;
- }
-
- public void startElement(String uri, String name, String qName, Attributes attrs) {
- if (qName.equals("shutdownState") || qName.equals("currentState")) {
- inCurrentState = true;
- } else if (qName.equals("previousState")) {
- inPreviousState = true;
- }
- }
-
- public void endElement(String uri, String name, String qName) {
-
- if (qName.equals("instanceId")) {
- this.instanceId = currentOrNull();
- } else if (qName.equals("shutdownState") || qName.equals("currentState")) {
- inCurrentState = false;
- } else if (qName.equals("previousState")) {
- inPreviousState = false;
- } else if (qName.equals("name")) {
- if (inCurrentState) {
- shutdownState = InstanceState.fromValue(currentOrNull());
- } else if (inPreviousState) {
- previousState = InstanceState.fromValue(currentOrNull());
- }
- } else if (qName.equals("item")) {
- String region = AWSUtils.findRegionInArgsOrNull(getRequest());
- if (region == null)
- region = defaultRegion.get();
- instances.add(new InstanceStateChange(region, instanceId, shutdownState, previousState));
- this.instanceId = null;
- this.shutdownState = null;
- this.previousState = null;
- }
-
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-
- protected String currentOrNull() {
- String returnVal = currentText.toString().trim();
- return returnVal.equals("") ? null : returnVal;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceTypeHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceTypeHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceTypeHandler.java
deleted file mode 100644
index 6572c0e..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceTypeHandler.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import org.jclouds.http.functions.ParseSax;
-
-/**
- *
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeInstanceAttribute.html"
- * />
- */
-public class InstanceTypeHandler extends
- ParseSax.HandlerWithResult<String> {
-
- private StringBuilder currentText = new StringBuilder();
- private String type;
-
- public String getResult() {
- return type;
- }
-
- public void endElement(String uri, String name, String qName) {
- if (qName.equalsIgnoreCase("value")) {
- this.type = currentText.toString().trim();
- }
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java
deleted file mode 100644
index 83393fb..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.net.domain.IpPermission;
-import org.jclouds.net.domain.IpProtocol;
-import org.xml.sax.SAXException;
-
-public class IpPermissionHandler extends ParseSax.HandlerForGeneratedRequestWithResult<IpPermission> {
-
- private StringBuilder currentText = new StringBuilder();
- private IpPermission.Builder builder = IpPermission.builder();
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IpPermission getResult() {
- try {
- return builder.build();
- } finally {
- builder = IpPermission.builder();
- }
- }
-
- private String userId;
- private String groupId;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (equalsOrSuffix(qName, "ipProtocol")) {
- // Algorete: ipProtocol can be an empty tag on EC2 clone (e.g.
- // OpenStack EC2)
- builder.ipProtocol(IpProtocol.fromValue(currentOrNegative(currentText)));
- } else if (equalsOrSuffix(qName, "fromPort")) {
- // Algorete: fromPort can be an empty tag on EC2 clone (e.g. OpenStack
- // EC2)
- builder.fromPort(Integer.parseInt(currentOrNegative(currentText)));
- } else if (equalsOrSuffix(qName, "toPort")) {
- // Algorete: toPort can be an empty tag on EC2 clone (e.g. OpenStack
- // EC2)
- builder.toPort(Integer.parseInt(currentOrNegative(currentText)));
- } else if (equalsOrSuffix(qName, "cidrIp")) {
- builder.cidrBlock(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "userId")) {
- this.userId = currentOrNull(currentText);
- } else if (equalsOrSuffix(qName, "groupName") || equalsOrSuffix(qName, "groupId")) {
- this.groupId = currentOrNull(currentText);
- } else if (equalsOrSuffix(qName, "item")) {
- if (userId != null && groupId != null)
- builder.tenantIdGroupNamePair(userId, groupId);
- userId = groupId = null;
- }
- currentText = new StringBuilder();
- }
-
- private static String currentOrNegative(StringBuilder currentText) {
- String returnVal = currentText.toString().trim();
- return returnVal.equals("") ? "-1" : returnVal;
- }
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java
deleted file mode 100644
index 59f8f8f..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-
-import javax.inject.Inject;
-
-import org.jclouds.aws.util.AWSUtils;
-import org.jclouds.ec2.domain.KeyPair;
-import org.jclouds.ec2.domain.KeyPair.Builder;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.location.Region;
-
-import com.google.common.base.Supplier;
-
-/**
- *
- * @see <a href=
- * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateKeyPair.html"
- * />
- */
-public class KeyPairResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<KeyPair> {
- private final Supplier<String> defaultRegion;
- private Builder builder;
-
- @Inject
- public KeyPairResponseHandler(@Region Supplier<String> defaultRegion) {
- this.defaultRegion = defaultRegion;
- }
-
- @Override
- public void startDocument() {
- builder = KeyPair.builder().region(defaultRegion.get());
- }
-
- private StringBuilder currentText = new StringBuilder();
-
- public KeyPair getResult() {
- String region = AWSUtils.findRegionInArgsOrNull(getRequest());
- if (region != null)
- builder.region(region);
- try {
- return builder.build();
- } finally {
- builder = KeyPair.builder().region(defaultRegion.get());
- }
- }
-
- public void endElement(String uri, String name, String qName) {
- if (qName.equals("keyFingerprint")) {
- builder.sha1OfPrivateKey(currentOrNull(currentText));
- } else if (qName.equals("keyMaterial")) {
- builder.keyMaterial(currentOrNull(currentText));
- } else if (qName.equals("keyName")) {
- builder.keyName(currentOrNull(currentText));
- }
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java
deleted file mode 100644
index 0eef83f..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import java.util.Set;
-
-import org.jclouds.ec2.domain.Permission;
-import org.jclouds.http.functions.ParseSax;
-
-import com.google.common.collect.Sets;
-
-/**
- *
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeImageAttribute.html"
- * />
- */
-public class PermissionHandler extends ParseSax.HandlerWithResult<Permission> {
-
- private StringBuilder currentText = new StringBuilder();
- private Set<String> userIds = Sets.newHashSet();
- private Set<String> groups = Sets.newHashSet();
-
- public Permission getResult() {
- return new Permission(userIds, groups);
- }
-
- public void endElement(String uri, String name, String qName) {
-
- if (qName.equalsIgnoreCase("group")) {
- groups.add(currentText.toString().trim());
- } else if (qName.equalsIgnoreCase("userId")) {
- userIds.add(currentText.toString().trim());
- }
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java
deleted file mode 100644
index 4593989..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import javax.inject.Inject;
-
-import org.jclouds.date.DateCodecFactory;
-import org.jclouds.ec2.domain.Reservation;
-import org.jclouds.ec2.domain.RunningInstance;
-import org.jclouds.location.Region;
-
-import com.google.common.base.Supplier;
-
-/**
- * Parses the following XML document:
- * <p/>
- * RunInstancesResponse xmlns="http:
- *
- * @see <a href="http: />
- */
-public class RunInstancesResponseHandler extends BaseReservationHandler<Reservation<? extends RunningInstance>> {
-
- @Inject
- public RunInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
- super(dateCodecFactory, defaultRegion);
- }
-
- @Override
- public Reservation<? extends RunningInstance> getResult() {
- return newReservation();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SecurityGroupHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SecurityGroupHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SecurityGroupHandler.java
deleted file mode 100644
index f5ea378..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SecurityGroupHandler.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import org.jclouds.aws.util.AWSUtils;
-import org.jclouds.ec2.domain.SecurityGroup;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult;
-import org.jclouds.location.Region;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.base.Supplier;
-import com.google.inject.Inject;
-
-public class SecurityGroupHandler extends ParseSax.HandlerForGeneratedRequestWithResult<SecurityGroup> {
-
- protected final IpPermissionHandler ipPermissionHandler;
- protected final Supplier<String> defaultRegion;
-
- protected StringBuilder currentText = new StringBuilder();
- protected SecurityGroup.Builder<?> builder;
- protected boolean inIpPermissions;
-
- protected int itemDepth;
-
- protected String region;
-
- @Inject
- public SecurityGroupHandler(IpPermissionHandler ipPermissionHandler, @Region Supplier<String> defaultRegion) {
- this.ipPermissionHandler = ipPermissionHandler;
- this.defaultRegion = defaultRegion;
- }
-
- protected SecurityGroup.Builder<?> builder() {
- return SecurityGroup.builder().region(region);
- }
-
- @Override
- public HandlerForGeneratedRequestWithResult<SecurityGroup> setContext(HttpRequest request) {
- region = AWSUtils.findRegionInArgsOrNull(GeneratedHttpRequest.class.cast(request));
- if (region == null)
- region = defaultRegion.get();
- builder = builder();
- return super.setContext(request);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public SecurityGroup getResult() {
- try {
- return builder.build();
- } finally {
- builder = builder();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
- if (equalsOrSuffix(qName, "item")) {
- itemDepth++;
- } else if (equalsOrSuffix(qName, "ipPermissions")) {
- inIpPermissions = true;
- }
- if (inIpPermissions) {
- ipPermissionHandler.startElement(url, name, qName, attributes);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (equalsOrSuffix(qName, "item")) {
- endItem(uri, name, qName);
- itemDepth--;
- } else if (equalsOrSuffix(qName, "ipPermissions")) {
- inIpPermissions = false;
- itemDepth = 0;
- } else if (inIpPermissions) {
- ipPermissionHandler.endElement(uri, name, qName);
- } else if (equalsOrSuffix(qName, "groupName")) {
- builder.name(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "groupId")) {
- builder.id(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "ownerId")) {
- builder.ownerId(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "groupDescription")) {
- builder.description(currentOrNull(currentText));
- }
- currentText = new StringBuilder();
- }
-
- protected void endItem(String uri, String name, String qName) throws SAXException {
- if (inIpPermissions) {
- if (itemDepth == 2)
- builder.ipPermission(ipPermissionHandler.getResult());
- else
- ipPermissionHandler.endElement(uri, name, qName);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- if (inIpPermissions) {
- ipPermissionHandler.characters(ch, start, length);
- } else {
- currentText.append(ch, start, length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java
deleted file mode 100644
index bf4ebc6..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import java.util.Date;
-
-import javax.inject.Inject;
-
-import org.jclouds.aws.util.AWSUtils;
-import org.jclouds.date.DateCodec;
-import org.jclouds.date.DateCodecFactory;
-import org.jclouds.ec2.domain.Snapshot;
-import org.jclouds.ec2.domain.Snapshot.Status;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.location.Region;
-
-import com.google.common.base.Supplier;
-
-public class SnapshotHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Snapshot> {
- private StringBuilder currentText = new StringBuilder();
-
- protected final DateCodec dateCodec;
- protected final Supplier<String> defaultRegion;
-
- private String id;
- private String volumeId;
- private int volumeSize;
- private Status status;
- private Date startTime;
- private int progress;
- private String ownerId;
- private String description;
- private String ownerAlias;
-
- @Inject
- public SnapshotHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
- this.dateCodec = dateCodecFactory.iso8601();
- this.defaultRegion = defaultRegion;
- }
-
- public Snapshot getResult() {
- String region = AWSUtils.findRegionInArgsOrNull(getRequest());
- if (region == null)
- region = defaultRegion.get();
- Snapshot snapshot = new Snapshot(region, id, volumeId, volumeSize, status, startTime,
- progress, ownerId, description, ownerAlias);
- this.id = null;
- this.volumeId = null;
- this.volumeSize = 0;
- this.status = null;
- this.startTime = null;
- this.progress = 0;
- this.ownerId = null;
- this.description = null;
- this.ownerAlias = null;
- return snapshot;
- }
-
- public void endElement(String uri, String name, String qName) {
- if (qName.equals("snapshotId")) {
- id = currentText.toString().trim();
- } else if (qName.equals("volumeId")) {
- volumeId = currentText.toString().trim();
- } else if (qName.equals("volumeSize")) {
- volumeSize = Integer.parseInt(currentText.toString().trim());
- } else if (qName.equals("status")) {
- status = Snapshot.Status.fromValue(currentText.toString().trim());
- } else if (qName.equals("startTime")) {
- startTime = dateCodec.toDate(currentText.toString().trim());
- } else if (qName.equals("progress")) {
- String progressString = currentText.toString().trim();
- if (!progressString.equals("")) {
- progressString = progressString.substring(0, progressString.length() - 1);
- progress = Integer.parseInt(progressString);
- }
- } else if (qName.equals("ownerId")) {
- ownerId = currentText.toString().trim();
- } else if (qName.equals("description")) {
- description = currentText.toString().trim();
- } else if (qName.equals("ownerAlias")) {
- ownerAlias = currentText.toString().trim();
- }
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/StringValueHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/StringValueHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/StringValueHandler.java
deleted file mode 100644
index 5e1d0e5..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/StringValueHandler.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import org.jclouds.http.functions.ParseSax;
-
-/**
- *
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeInstanceAttribute.html"
- * />
- */
-public class StringValueHandler extends
- ParseSax.HandlerWithResult<String> {
-
- private StringBuilder currentText = new StringBuilder();
- private String value;
-
- public String getResult() {
- return value;
- }
-
- public void endElement(String uri, String name, String qName) {
- if (qName.equalsIgnoreCase("value")) {
- this.value = currentText.toString().trim();
- }
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java
deleted file mode 100644
index f254140..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import javax.inject.Inject;
-
-import org.jclouds.ec2.domain.Subnet;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-
-/**
- * @see <a href="http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-ItemType-SubnetType.html" >xml</a>
- */
-public class SubnetHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Subnet> {
- private StringBuilder currentText = new StringBuilder();
- private Subnet.Builder builder = Subnet.builder();
- private final TagSetHandler tagSetHandler;
- private boolean inTagSet;
-
- @Inject
- public SubnetHandler(TagSetHandler tagSetHandler) {
- this.tagSetHandler = tagSetHandler;
- }
-
- @Override
- public Subnet getResult() {
- try {
- return builder.build();
- } finally {
- builder = Subnet.builder();
- }
- }
-
- @Override
- public void startElement(String uri, String name, String qName, Attributes attrs) {
- if (equalsOrSuffix(qName, "tagSet")) {
- inTagSet = true;
- }
- if (inTagSet) {
- tagSetHandler.startElement(uri, name, qName, attrs);
- }
- }
-
- @Override
- public void endElement(String uri, String name, String qName) {
- if (equalsOrSuffix(qName, "tagSet")) {
- inTagSet = false;
- builder.tags(tagSetHandler.getResult());
- } else if (inTagSet) {
- tagSetHandler.endElement(uri, name, qName);
- } else if (equalsOrSuffix(qName, "subnetId")) {
- builder.subnetId(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "state")) {
- builder.subnetState(Subnet.State.fromValue(currentOrNull(currentText)));
- } else if (equalsOrSuffix(qName, "vpcId")) {
- builder.vpcId(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "cidrBlock")) {
- builder.cidrBlock(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "availableIpAddressCount")) {
- builder.availableIpAddressCount(Integer.parseInt(currentOrNull(currentText)));
- } else if (equalsOrSuffix(qName, "availabilityZone")) {
- builder.availabilityZone(currentOrNull(currentText));
- }
- currentText = new StringBuilder();
- }
-
- @Override
- public void characters(char ch[], int start, int length) {
- if (inTagSet) {
- tagSetHandler.characters(ch, start, length);
- } else {
- currentText.append(ch, start, length);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java
deleted file mode 100644
index d3f34d0..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import org.jclouds.ec2.domain.Tag;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.SAXException;
-
-import com.google.common.base.Strings;
-
-/**
- * @see <a
- * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeTags.html"
- * >xml</a>
- */
-public class TagHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Tag> {
-
- private StringBuilder currentText = new StringBuilder();
- private Tag.Builder builder = Tag.builder();
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Tag getResult() {
- try {
- return builder.build();
- } finally {
- builder = Tag.builder();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (equalsOrSuffix(qName, "resourceId")) {
- builder.resourceId(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "resourceType")) {
- builder.resourceType(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "key")) {
- builder.key(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "value")) {
- // empty is same as not present
- builder.value(Strings.emptyToNull(currentOrNull(currentText)));
- }
- currentText = new StringBuilder();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java
deleted file mode 100644
index af8eea1..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import java.util.Map;
-
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableMap;
-
-public class TagSetHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Map<String, String>> {
- private StringBuilder currentText = new StringBuilder();
-
- private ImmutableMap.Builder<String, String> result;
- private boolean inItem = false;
- private String key;
- private String value;
-
- public Map<String, String> getResult() {
- return result.build();
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) {
- if (equalsOrSuffix(qName, "tagSet")) {
- result = ImmutableMap.builder();
- } else if (qName.equals("item")) {
- inItem = true;
- key = null;
- value = null;
- }
- currentText = new StringBuilder();
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) {
- if (qName.equals("item")) {
- inItem = false;
- if (key != null) {
- result.put(key, Strings.nullToEmpty(value));
- }
- }
- if (inItem) {
- if (qName.equals("key")) {
- key = currentOrNull(currentText);
- } else if (qName.equals("value")) {
- value = currentOrNull(currentText);
- }
- }
- }
-
- @Override
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java
deleted file mode 100644
index 0b42861..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2.xml;
-
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.io.BaseEncoding.base64;
-
-/**
- *
- * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeInstanceAttribute.html"
- * />
- */
-public class UnencodeStringValueHandler extends StringValueHandler {
-
- @Override
- public String getResult() {
- String result = super.getResult();
- if (result != null)
- result = new String(base64().decode(result), UTF_8);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
deleted file mode 100644
index dce15a1..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
+++ /dev/null
@@ -1 +0,0 @@
-org.jclouds.ec2.EC2ApiMetadata
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java
deleted file mode 100644
index efeaf96..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.ec2;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.ec2.options.RunInstancesOptions.Builder.asType;
-import static org.jclouds.util.Predicates2.retry;
-import static org.jclouds.scriptbuilder.domain.Statements.exec;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-
-import org.jclouds.aws.AWSResponseException;
-import org.jclouds.compute.domain.ExecResponse;
-import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.ec2.domain.BlockDevice;
-import org.jclouds.ec2.domain.Image.EbsBlockDevice;
-import org.jclouds.ec2.domain.InstanceState;
-import org.jclouds.ec2.domain.InstanceType;
-import org.jclouds.ec2.domain.KeyPair;
-import org.jclouds.ec2.domain.PublicIpInstanceIdPair;
-import org.jclouds.ec2.domain.Reservation;
-import org.jclouds.ec2.domain.RunningInstance;
-import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
-import org.jclouds.ec2.predicates.InstanceHasIpAddress;
-import org.jclouds.ec2.predicates.InstanceStateRunning;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.net.domain.IpProtocol;
-import org.jclouds.predicates.SocketOpen;
-import org.jclouds.scriptbuilder.ScriptBuilder;
-import org.jclouds.scriptbuilder.domain.OsFamily;
-import org.jclouds.ssh.SshClient;
-import org.jclouds.ssh.SshException;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-import com.google.common.net.HostAndPort;
-import com.google.inject.Injector;
-
-/**
- * Follows the book Cloud Application Architectures ISBN: 978-0-596-15636-7
- * <p/>
- * adds in functionality to boot a lamp instance: http://alestic.com/2009/06/ec2-user-data-scripts
- * <p/>
- * Generally disabled, as it incurs higher fees.
- */
-@Test(groups = "live", enabled = false, singleThreaded = true, testName = "CloudApplicationArchitecturesEC2ApiLiveTest")
-public class CloudApplicationArchitecturesEC2ApiLiveTest extends BaseComputeServiceContextLiveTest {
- public CloudApplicationArchitecturesEC2ApiLiveTest() {
- provider = "ec2";
- }
-
- private EC2Api client;
- protected SshClient.Factory sshFactory;
- private String instancePrefix = System.getProperty("user.name") + ".ec2";
- private KeyPair keyPair;
- private String securityGroupName;
- private String instanceId;
- private String address;
-
- private Predicate<HostAndPort> socketTester;
- private Predicate<RunningInstance> hasIpTester;
- private Predicate<RunningInstance> runningTester;
-
- @BeforeClass(groups = { "integration", "live" })
- public void setupContext() {
- super.setupContext();
- Injector injector = view.utils().injector();
- client = injector.getInstance(EC2Api.class);
- sshFactory = injector.getInstance(SshClient.Factory.class);
- runningTester = retry(new InstanceStateRunning(client), 180, 5, SECONDS);
- hasIpTester = retry(new InstanceHasIpAddress(client), 180, 5, SECONDS);
- SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
- socketTester = retry(socketOpen, 180, 1, SECONDS);
- }
-
- @Test(enabled = false)
- void testCreateSecurityGroupIngressCidr() throws InterruptedException, ExecutionException, TimeoutException {
- securityGroupName = instancePrefix + "ingress";
-
- try {
- client.getSecurityGroupApi().get().deleteSecurityGroupInRegion(null, securityGroupName);
- } catch (Exception e) {
- }
-
- client.getSecurityGroupApi().get().createSecurityGroupInRegion(null, securityGroupName, securityGroupName);
- for (int port : new int[] { 80, 443, 22 }) {
- client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(null, securityGroupName,
- IpProtocol.TCP, port, port, "0.0.0.0/0");
- }
- }
-
- @Test(enabled = false)
- void testCreateKeyPair() throws InterruptedException, ExecutionException, TimeoutException {
- String keyName = instancePrefix + "1";
- try {
- client.getKeyPairApi().get().deleteKeyPairInRegion(null, keyName);
- } catch (Exception e) {
-
- }
- client.getKeyPairApi().get().deleteKeyPairInRegion(null, keyName);
-
- keyPair = client.getKeyPairApi().get().createKeyPairInRegion(null, keyName);
- assertNotNull(keyPair);
- assertNotNull(keyPair.getKeyMaterial());
- assertNotNull(keyPair.getSha1OfPrivateKey());
- assertEquals(keyPair.getKeyName(), keyName);
- }
-
- @Test(enabled = false, dependsOnMethods = { "testCreateKeyPair", "testCreateSecurityGroupIngressCidr" })
- public void testCreateRunningInstance() throws Exception {
- String script = new ScriptBuilder() // lamp install script
- .addStatement(exec("runurl run.alestic.com/apt/upgrade"))//
- .addStatement(exec("runurl run.alestic.com/install/lamp"))//
- .render(OsFamily.UNIX);
-
- RunningInstance instance = null;
- while (instance == null) {
- try {
-
- System.out.printf("%d: running instance%n", System.currentTimeMillis());
- Reservation<? extends RunningInstance> reservation = client.getInstanceApi().get().runInstancesInRegion(
- null, null, // allow
- // ec2
- // to
- // chose
- // an
- // availability
- // zone
- "ami-ccf615a5", // alestic ami allows auto-invoke of
- // user data scripts
- 1, // minimum instances
- 1, // maximum instances
- asType(InstanceType.M1_SMALL) // smallest instance size
- .withKeyName(keyPair.getKeyName()) // key I
- // created
- // above
- .withSecurityGroup(securityGroupName) // group I
- // created
- // above
- .withUserData(script.getBytes())); // script to
- // run as root
-
- instance = Iterables.getOnlyElement(reservation);
-
- } catch (HttpResponseException htpe) {
- if (htpe.getResponse().getStatusCode() == 400)
- continue;
- throw htpe;
- }
- }
- assertNotNull(instance.getId());
- instanceId = instance.getId();
- assertEquals(instance.getInstanceState(), InstanceState.PENDING);
- instance = blockUntilWeCanSshIntoInstance(instance);
-
- verifyInstanceProperties(script);
- tryToChangeStuff();
- sshPing(instance);
- System.out.printf("%d: %s ssh connection made%n", System.currentTimeMillis(), instanceId);
-
- }
-
- private void verifyInstanceProperties(String script) {
- assertEquals(script, client.getInstanceApi().get().getUserDataForInstanceInRegion(null, instanceId));
-
- assertEquals(null, client.getInstanceApi().get().getRootDeviceNameForInstanceInRegion(null, instanceId));
-
- assert client.getInstanceApi().get().getRamdiskForInstanceInRegion(null, instanceId).startsWith("ari-");
-
- assertEquals(false, client.getInstanceApi().get().isApiTerminationDisabledForInstanceInRegion(null, instanceId));
-
- assert client.getInstanceApi().get().getKernelForInstanceInRegion(null, instanceId).startsWith("aki-");
-
- assertEquals(InstanceType.M1_SMALL,
- client.getInstanceApi().get().getInstanceTypeForInstanceInRegion(null, instanceId));
-
- assertEquals(InstanceInitiatedShutdownBehavior.TERMINATE, client.getInstanceApi().get()
- .getInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, instanceId));
-
- assertEquals(ImmutableMap.<String, EbsBlockDevice> of(), client.getInstanceApi().get()
- .getBlockDeviceMappingForInstanceInRegion(null, instanceId));
- }
-
- private void setApiTerminationDisabledForInstanceInRegion() {
- client.getInstanceApi().get().setApiTerminationDisabledForInstanceInRegion(null, instanceId, true);
- assertEquals(true, client.getInstanceApi().get().isApiTerminationDisabledForInstanceInRegion(null, instanceId));
- client.getInstanceApi().get().setApiTerminationDisabledForInstanceInRegion(null, instanceId, false);
- assertEquals(false, client.getInstanceApi().get().isApiTerminationDisabledForInstanceInRegion(null, instanceId));
- }
-
- private void tryToChangeStuff() {
- setApiTerminationDisabledForInstanceInRegion();
- setUserDataForInstanceInRegion();
- setRamdiskForInstanceInRegion();
- setKernelForInstanceInRegion();
- setInstanceTypeForInstanceInRegion();
- setInstanceInitiatedShutdownBehaviorForInstanceInRegion();
- setBlockDeviceMappingForInstanceInRegion();
- }
-
- private void setUserDataForInstanceInRegion() {
- try {
- client.getInstanceApi().get().setUserDataForInstanceInRegion(null, instanceId, "test".getBytes());
- fail("shouldn't be allowed, as instance needs to be stopped");
- } catch (AWSResponseException e) {
- assertEquals("IncorrectInstanceState", e.getError().getCode());
- }
- }
-
- private void setRamdiskForInstanceInRegion() {
- try {
- String ramdisk = client.getInstanceApi().get().getRamdiskForInstanceInRegion(null, instanceId);
- client.getInstanceApi().get().setRamdiskForInstanceInRegion(null, instanceId, ramdisk);
- fail("shouldn't be allowed, as instance needs to be stopped");
- } catch (AWSResponseException e) {
- assertEquals("IncorrectInstanceState", e.getError().getCode());
- }
- }
-
- private void setKernelForInstanceInRegion() {
- try {
- String oldKernel = client.getInstanceApi().get().getKernelForInstanceInRegion(null, instanceId);
- client.getInstanceApi().get().setKernelForInstanceInRegion(null, instanceId, oldKernel);
- fail("shouldn't be allowed, as instance needs to be stopped");
- } catch (AWSResponseException e) {
- assertEquals("IncorrectInstanceState", e.getError().getCode());
- }
- }
-
- private void setInstanceTypeForInstanceInRegion() {
- try {
- client.getInstanceApi().get().setInstanceTypeForInstanceInRegion(null, instanceId, InstanceType.C1_MEDIUM);
- fail("shouldn't be allowed, as instance needs to be stopped");
- } catch (AWSResponseException e) {
- assertEquals("IncorrectInstanceState", e.getError().getCode());
- }
- }
-
- private void setBlockDeviceMappingForInstanceInRegion() {
- Map<String, BlockDevice> mapping = Maps.newLinkedHashMap();
- try {
- client.getInstanceApi().get().setBlockDeviceMappingForInstanceInRegion(null, instanceId, mapping);
- fail("shouldn't be allowed, as instance needs to be ebs based-ami");
- } catch (AWSResponseException e) {
- assertEquals("InvalidParameterCombination", e.getError().getCode());
- }
- }
-
- private void setInstanceInitiatedShutdownBehaviorForInstanceInRegion() {
- try {
- client.getInstanceApi().get().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, instanceId,
- InstanceInitiatedShutdownBehavior.STOP);
- fail("shouldn't be allowed, as instance needs to be ebs based-ami");
- } catch (AWSResponseException e) {
- assertEquals("UnsupportedInstanceAttribute", e.getError().getCode());
- }
- }
-
- @Test(enabled = false, dependsOnMethods = "testCreateRunningInstance")
- void testReboot() throws InterruptedException, ExecutionException, TimeoutException, IOException {
- RunningInstance instance = getInstance(instanceId);
- System.out.printf("%d: %s rebooting instance %n", System.currentTimeMillis(), instanceId);
- client.getInstanceApi().get().rebootInstancesInRegion(null, instanceId);
- Thread.sleep(1000);
- instance = getInstance(instanceId);
- blockUntilWeCanSshIntoInstance(instance);
- SshClient ssh = sshFactory.create(HostAndPort.fromParts(instance.getIpAddress(), 22),
- LoginCredentials.builder().user("root").privateKey(keyPair.getKeyMaterial()).build());
- try {
- ssh.connect();
- ExecResponse uptime = ssh.exec("uptime");
- assert uptime.getOutput().indexOf("0 min") != -1 : "reboot didn't work: " + uptime;
- } finally {
- if (ssh != null)
- ssh.disconnect();
- }
- }
-
- @Test(enabled = false, dependsOnMethods = "testReboot")
- void testElasticIpAddress() throws InterruptedException, ExecutionException, TimeoutException, IOException {
- address = client.getElasticIPAddressApi().get().allocateAddressInRegion(null);
- assertNotNull(address);
-
- PublicIpInstanceIdPair compare = Iterables.getLast(client.getElasticIPAddressApi().get()
- .describeAddressesInRegion(null, address));
-
- assertEquals(compare.getPublicIp(), address);
- assert compare.getInstanceId() == null;
-
- client.getElasticIPAddressApi().get().associateAddressInRegion(null, address, instanceId);
-
- compare = Iterables.getLast(client.getElasticIPAddressApi().get().describeAddressesInRegion(null, address));
-
- assertEquals(compare.getPublicIp(), address);
- assertEquals(compare.getInstanceId(), instanceId);
-
- Reservation<? extends RunningInstance> reservation = Iterables.getOnlyElement(client.getInstanceApi().get()
- .describeInstancesInRegion(null, instanceId));
-
- assertNotNull(Iterables.getOnlyElement(reservation).getIpAddress());
- assertNotEquals(address, Iterables.getOnlyElement(reservation).getIpAddress());
-
- doCheckKey(address);
-
- client.getElasticIPAddressApi().get().disassociateAddressInRegion(null, address);
-
- compare = Iterables.getLast(client.getElasticIPAddressApi().get().describeAddressesInRegion(null, address));
-
- assertEquals(compare.getPublicIp(), address);
- assert compare.getInstanceId() == null;
-
- reservation = Iterables.getOnlyElement(client.getInstanceApi().get().describeInstancesInRegion(null, instanceId));
- // assert reservation.getRunningInstances().last().getIpAddress() == null;
- // TODO
- }
-
- private RunningInstance blockUntilWeCanSshIntoInstance(RunningInstance instance) throws UnknownHostException {
- System.out.printf("%d: %s awaiting instance to run %n", System.currentTimeMillis(), instance.getId());
- assert runningTester.apply(instance);
-
- instance = getInstance(instance.getId());
-
- System.out
- .printf("%d: %s awaiting instance to have ip assigned %n", System.currentTimeMillis(), instance.getId());
- assert hasIpTester.apply(instance);
-
- System.out.printf("%d: %s awaiting ssh service to start%n", System.currentTimeMillis(), instance.getIpAddress());
- assert socketTester.apply(HostAndPort.fromParts(instance.getIpAddress(), 22));
-
- System.out.printf("%d: %s ssh service started%n", System.currentTimeMillis(), instance.getDnsName());
- sshPing(instance);
- System.out.printf("%d: %s ssh connection made%n", System.currentTimeMillis(), instance.getId());
-
- System.out.printf("%d: %s awaiting http service to start%n", System.currentTimeMillis(), instance.getIpAddress());
- assert socketTester.apply(HostAndPort.fromParts(instance.getIpAddress(), 80));
- System.out.printf("%d: %s http service started%n", System.currentTimeMillis(), instance.getDnsName());
- return instance;
- }
-
- private RunningInstance getInstance(String instanceId) {
- // search my identity for the instance I just created
- Set<? extends Reservation<? extends RunningInstance>> reservations = client.getInstanceApi().get()
- .describeInstancesInRegion(null, instanceId); // last parameter
- // (ids) narrows the
- // search
-
- return Iterables.getOnlyElement(Iterables.getOnlyElement(reservations));
- }
-
- /**
- * this tests "personality" as the file looked up was sent during instance creation
- *
- * @throws UnknownHostException
- */
- private void sshPing(RunningInstance newDetails) throws UnknownHostException {
- try {
- doCheckKey(newDetails);
- } catch (SshException e) {// try twice in case there is a network timeout
- try {
- Thread.sleep(10 * 1000);
- } catch (InterruptedException e1) {
- }
- doCheckKey(newDetails);
- }
- }
-
- private void doCheckKey(RunningInstance newDetails) throws UnknownHostException {
- doCheckKey(newDetails.getIpAddress());
- }
-
- private void doCheckKey(String address) {
- SshClient ssh = sshFactory.create(HostAndPort.fromParts(address, 22),
- LoginCredentials.builder().user("root").privateKey(keyPair.getKeyMaterial()).build());
- try {
- ssh.connect();
- ExecResponse hello = ssh.exec("echo hello");
- assertEquals(hello.getOutput().trim(), "hello");
- } finally {
- if (ssh != null)
- ssh.disconnect();
- }
- }
-
- @AfterTest
- void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
- if (address != null)
- client.getElasticIPAddressApi().get().releaseAddressInRegion(null, address);
- if (instanceId != null)
- client.getInstanceApi().get().terminateInstancesInRegion(null, instanceId);
- if (keyPair != null)
- client.getKeyPairApi().get().deleteKeyPairInRegion(null, keyPair.getKeyName());
- if (securityGroupName != null)
- client.getSecurityGroupApi().get().deleteSecurityGroupInRegion(null, securityGroupName);
- }
-
-}