You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2013/09/30 18:15:29 UTC
[09/17] JCLOUDS-304. Remove broken terremark providers
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/SupportedVersionsHandler.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/SupportedVersionsHandler.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/SupportedVersionsHandler.java
deleted file mode 100644
index a697c84..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/SupportedVersionsHandler.java
+++ /dev/null
@@ -1,59 +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.trmk.vcloud_0_8.xml;
-
-import java.net.URI;
-import java.util.SortedMap;
-
-import org.jclouds.http.functions.ParseSax;
-
-import com.google.common.collect.Maps;
-
-/**
- * @author Adrian Cole
- */
-public class SupportedVersionsHandler extends ParseSax.HandlerWithResult<SortedMap<String, URI>> {
- private StringBuilder currentText = new StringBuilder();
-
- private SortedMap<String, URI> contents = Maps.newTreeMap();
- private String version;
- private URI location;
-
- public SortedMap<String, URI> getResult() {
- return contents;
- }
-
- public void endElement(String uri, String name, String qName) {
- if (qName.equals("Version")) {
- version = currentOrNull();
- } else if (qName.equals("LoginUrl")) {
- location = URI.create(currentOrNull());
- } else if (qName.equals("VersionInfo")) {
- contents.put(version, location);
- }
- 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/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/TaskHandler.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/TaskHandler.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/TaskHandler.java
deleted file mode 100644
index ba0a9b1..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/TaskHandler.java
+++ /dev/null
@@ -1,126 +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.trmk.vcloud_0_8.xml;
-
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-
-import org.jclouds.date.DateService;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.logging.Logger;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.domain.Task;
-import org.jclouds.trmk.vcloud_0_8.domain.TaskStatus;
-import org.jclouds.trmk.vcloud_0_8.domain.VCloudError;
-import org.jclouds.trmk.vcloud_0_8.domain.internal.TaskImpl;
-import org.jclouds.trmk.vcloud_0_8.util.Utils;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * @author Adrian Cole
- */
-public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
- protected final DateService dateService;
- private String operation;
- private ReferenceType taskLink;
- private ReferenceType owner;
- private TaskStatus status;
- private Date startTime;
- private Date endTime;
- private Date expiryTime;
- private Task task;
- private VCloudError error;
- private boolean inOwner;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public TaskHandler(DateService dateService) {
- this.dateService = dateService;
- }
-
- public Task getResult() {
- return task;
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
- Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
- if (qName.equalsIgnoreCase("Task")) {
- if (attributes.get("href") != null && !inOwner)// queued tasks may not have an
- // href yet
- taskLink = Utils.newReferenceType(attributes);
- status = TaskStatus.fromValue(attributes.get("status"));
- operation = attributes.get("operation");
- if (attributes.containsKey("startTime"))
- startTime = parseDate(attributes.get("startTime"));
- if (attributes.containsKey("endTime"))
- endTime = parseDate(attributes.get("endTime"));
- if (attributes.containsKey("expiryTime"))
- expiryTime = parseDate(attributes.get("expiryTime"));
- // TODO technically the old Result object should only be owner for copy and delete tasks
- } else if (qName.equals("Owner") || qName.equals("Result")) {
- owner = Utils.newReferenceType(attributes);
- } else if (qName.equals("Link") && "self".equals(attributes.get("rel"))) {
- taskLink = Utils.newReferenceType(attributes);
- } else if (qName.equals("Error")) {
- error = Utils.newError(attributes);
- }
- }
-
- private Date parseDate(String toParse) {
- try {
- return dateService.iso8601DateParse(toParse);
- } catch (RuntimeException e) {
- if (e.getCause() instanceof ParseException) {
- if (!toParse.endsWith("Z"))
- toParse += "Z";
- return dateService.iso8601SecondsDateParse(toParse);
- } else {
- logger.error(e, "error parsing date");
- }
- }
- return null;
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) {
- if (qName.equalsIgnoreCase("Task")) {
- this.task = new TaskImpl(taskLink.getHref(), operation, status, startTime, endTime, expiryTime, owner, error);
- operation = null;
- taskLink = null;
- status = null;
- startTime = null;
- endTime = null;
- owner = null;
- error = null;
- } else if (qName.equalsIgnoreCase("Owner")) {
- inOwner = false;
- }
- }
-
- public void characters(char ch[], int start, int length) {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/TasksListHandler.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/TasksListHandler.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/TasksListHandler.java
deleted file mode 100644
index b9ed43e..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/TasksListHandler.java
+++ /dev/null
@@ -1,74 +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.trmk.vcloud_0_8.xml;
-
-import java.util.Map;
-import java.util.SortedSet;
-
-import javax.inject.Inject;
-
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.domain.Task;
-import org.jclouds.trmk.vcloud_0_8.domain.TasksList;
-import org.jclouds.trmk.vcloud_0_8.domain.internal.TasksListImpl;
-import org.jclouds.trmk.vcloud_0_8.util.Utils;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.Sets;
-
-/**
- * @author Adrian Cole
- */
-public class TasksListHandler extends ParseSax.HandlerWithResult<TasksList> {
-
- private SortedSet<Task> tasks = Sets.newTreeSet();
- private final TaskHandler taskHandler;
- private ReferenceType resource;
-
- @Inject
- public TasksListHandler(TaskHandler taskHandler) {
- this.taskHandler = taskHandler;
- }
-
- public TasksList getResult() {
- return new TasksListImpl(resource.getHref(), tasks);
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
- Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
- if (qName.equals("TasksList")) {
- resource = Utils.newReferenceType(attributes);
- } else if (qName.equals("Link") && "self".equals(attributes.get("rel"))) {
- resource = Utils.newReferenceType(attributes);
- } else {
- taskHandler.startElement(uri, localName, qName, attrs);
- }
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- taskHandler.endElement(uri, localName, qName);
- if (qName.equals("Task")) {
- this.tasks.add(taskHandler.getResult());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppExtendedInfoHandler.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppExtendedInfoHandler.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppExtendedInfoHandler.java
deleted file mode 100644
index 6df70cb..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppExtendedInfoHandler.java
+++ /dev/null
@@ -1,116 +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.trmk.vcloud_0_8.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-
-import java.net.URI;
-
-import org.jclouds.http.functions.ParseSax.HandlerWithResult;
-import org.jclouds.trmk.vcloud_0_8.domain.ComputePoolReference;
-import org.jclouds.trmk.vcloud_0_8.domain.NetworkAdapter;
-import org.jclouds.trmk.vcloud_0_8.domain.Subnet;
-import org.jclouds.trmk.vcloud_0_8.domain.VAppExtendedInfo;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableList;
-
-/**
- * @author Seshu Pasam, Adrian Cole
- */
-public class VAppExtendedInfoHandler extends HandlerWithResult<VAppExtendedInfo> {
-
- private StringBuilder currentText = new StringBuilder();
-
- private VAppExtendedInfo.Builder builder = VAppExtendedInfo.builder();
- private NetworkAdapter.Builder adapterBuilder = NetworkAdapter.builder();
- private Subnet.Builder subnetBuilder = Subnet.builder();
- private ComputePoolReference.Builder poolBuilder = ComputePoolReference.builder();
- private boolean inAdapters;
- private boolean inSubnet;
- private boolean inComputePool;
-
- @Override
- public VAppExtendedInfo getResult() {
- return builder.build();
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- if (qName.equals("NetworkAdapters")) {
- inAdapters = true;
- } else if (qName.equals("Subnet")) {
- inSubnet = true;
- } else if (qName.equals("ComputePoolReference")) {
- inComputePool = true;
- }
- }
-
- public void endElement(String uri, String name, String qName) {
- String current = currentOrNull(currentText);
- if (current != null) {
- if (qName.equals("Id")) {
- builder.id(current);
- } else if (qName.equals("Tags")) {
- builder.tags(ImmutableList.copyOf(Splitter.on(',').split(current)));
- } else if (qName.equals("LongName")) {
- builder.longName(current);
- } else if (qName.equals("Href")) {
- URI href = URI.create(current);
- if (inSubnet) {
- subnetBuilder.href(href);
- } else if (inComputePool) {
- poolBuilder.href(href);
- } else {
- builder.href(href);
- }
- } else if (qName.equals("Name")) {
- if (inSubnet) {
- subnetBuilder.name(current);
- } else if (inAdapters) {
- adapterBuilder.name(current);
- } else if (inComputePool) {
- poolBuilder.name(current);
- } else {
- builder.name(current);
- }
- } else if (qName.equals("MacAddress")) {
- adapterBuilder.macAddress(current);
- }
- } else if (qName.equals("NetworkAdapters")) {
- inAdapters = false;
- } else if (qName.equals("NetworkAdapter")) {
- builder.networkAdapter(adapterBuilder.build());
- adapterBuilder = NetworkAdapter.builder();
- } else if (qName.equals("Subnet")) {
- adapterBuilder.subnet(subnetBuilder.build());
- subnetBuilder = Subnet.builder();
- inSubnet = false;
- } else if (qName.equals("ComputePoolReference")) {
- builder.computePoolReference(poolBuilder.build());
- poolBuilder = ComputePoolReference.builder();
- inComputePool = false;
- }
- 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/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppHandler.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppHandler.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppHandler.java
deleted file mode 100644
index 25b781e..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppHandler.java
+++ /dev/null
@@ -1,142 +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.trmk.vcloud_0_8.xml;
-
-import static org.jclouds.trmk.vcloud_0_8.util.Utils.newReferenceType;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-
-import org.jclouds.cim.ResourceAllocationSettingData;
-import org.jclouds.cim.VirtualSystemSettingData;
-import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
-import org.jclouds.cim.xml.VirtualSystemSettingDataHandler;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.logging.Logger;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.domain.Status;
-import org.jclouds.trmk.vcloud_0_8.domain.VApp;
-import org.jclouds.trmk.vcloud_0_8.domain.internal.VAppImpl;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ListMultimap;
-import com.google.common.collect.Sets;
-
-/**
- * @author Adrian Cole
- */
-public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
- private final VirtualSystemSettingDataHandler systemHandler;
- private final ResourceAllocationSettingDataHandler allocationHandler;
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public VAppHandler(VirtualSystemSettingDataHandler systemHandler,
- ResourceAllocationSettingDataHandler allocationHandler) {
- this.systemHandler = systemHandler;
- this.allocationHandler = allocationHandler;
- }
-
- protected VirtualSystemSettingData system;
- protected Set<ResourceAllocationSettingData> allocations = Sets.newLinkedHashSet();
- protected Status status;
- protected final ListMultimap<String, String> networkToAddresses = ArrayListMultimap.create();
- protected StringBuilder currentText = new StringBuilder();
- protected String operatingSystemDescription;
- protected boolean inOs;
- protected String networkName;
- protected String name;
- protected Integer osType;
- protected URI location;
- protected Long size;
- protected ReferenceType vDC;
- protected Set<ReferenceType> extendedInfo = Sets.newLinkedHashSet();
-
- public VApp getResult() {
- return new VAppImpl(name, location, status, size, vDC, networkToAddresses, osType, operatingSystemDescription,
- system, allocations, extendedInfo);
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
- Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
- if (qName.equals("VApp")) {
- ReferenceType resource = newReferenceType(attributes);
- name = resource.getName();
- location = resource.getHref();
- String statusString = attributes.get("status");
- status = Status.fromValue(statusString);
- if (attributes.containsKey("size"))
- size = Long.valueOf(attributes.get("size"));
- } else if (qName.equals("Link")) { // type should never be missing
- if (attributes.containsKey("type")) {
- if (attributes.get("type").equals(TerremarkVCloudMediaType.VDC_XML)) {
- vDC = newReferenceType(attributes);
- } else {
- extendedInfo.add(newReferenceType(attributes));
- }
- }
- } else if (qName.equals("OperatingSystemSection")) {
- inOs = true;
- if (attributes.containsKey("id"))
- osType = Integer.parseInt(attributes.get("id"));
- } else if (qName.endsWith("NetworkConnection")) {
- networkName = attributes.get("Network");
- } else {
- systemHandler.startElement(uri, localName, qName, attrs);
- allocationHandler.startElement(uri, localName, qName, attrs);
- }
-
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (qName.equals("OperatingSystemSection")) {
- inOs = false;
- } else if (inOs && qName.equals("Description")) {
- operatingSystemDescription = currentText.toString().trim();
- } else if (qName.endsWith("IpAddress")) {
- networkToAddresses.put(networkName, currentText.toString().trim());
- } else if (qName.equals("System")) {
- systemHandler.endElement(uri, localName, qName);
- system = systemHandler.getResult();
- } else if (qName.equals("Item")) {
- allocationHandler.endElement(uri, localName, qName);
- allocations.add(allocationHandler.getResult());
- } else {
- systemHandler.endElement(uri, localName, qName);
- allocationHandler.endElement(uri, localName, qName);
- }
- currentText = new StringBuilder();
- }
-
- @Override
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- systemHandler.characters(ch, start, length);
- allocationHandler.characters(ch, start, length);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppTemplateHandler.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppTemplateHandler.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppTemplateHandler.java
deleted file mode 100644
index 391690c..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VAppTemplateHandler.java
+++ /dev/null
@@ -1,67 +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.trmk.vcloud_0_8.xml;
-
-import static org.jclouds.trmk.vcloud_0_8.util.Utils.newReferenceType;
-import static org.jclouds.util.SaxUtils.cleanseAttributes;
-import static org.jclouds.util.SaxUtils.currentOrNull;
-
-import java.util.Map;
-
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.domain.Status;
-import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
-import org.jclouds.trmk.vcloud_0_8.domain.internal.VAppTemplateImpl;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * @author Adrian Cole
- */
-public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate> {
- private StringBuilder currentText = new StringBuilder();
-
- private ReferenceType catalog;
- private String description;
- private Status status;
-
- public VAppTemplate getResult() {
- return new VAppTemplateImpl(catalog.getName(), catalog.getHref(), description, status);
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
- Map<String, String> attributes = cleanseAttributes(attrs);
- if (qName.equals("VAppTemplate")) {
- catalog = newReferenceType(attributes);
- if (attributes.containsKey("status"))
- status = Status.fromValue(attributes.get("status"));
- }
- }
-
- public void endElement(String uri, String name, String qName) {
- if (qName.equals("Description")) {
- description = 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/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VDCHandler.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VDCHandler.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VDCHandler.java
deleted file mode 100644
index b8145d5..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/VDCHandler.java
+++ /dev/null
@@ -1,95 +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.trmk.vcloud_0_8.xml;
-
-import static org.jclouds.trmk.vcloud_0_8.util.Utils.newReferenceType;
-import static org.jclouds.trmk.vcloud_0_8.util.Utils.putReferenceType;
-import static org.jclouds.util.SaxUtils.cleanseAttributes;
-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.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.domain.VDC;
-import org.jclouds.trmk.vcloud_0_8.domain.internal.VDCImpl;
-import org.jclouds.trmk.vcloud_0_8.util.Utils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.Maps;
-
-/**
- * @author Adrian Cole
- */
-public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
-
- protected StringBuilder currentText = new StringBuilder();
-
- protected ReferenceType vDC;
- protected String description;
-
- protected Map<String, ReferenceType> resourceEntities = Maps.newLinkedHashMap();
- protected Map<String, ReferenceType> availableNetworks = Maps.newLinkedHashMap();
-
- private ReferenceType catalog;
- private ReferenceType publicIps;
- private ReferenceType internetServices;
-
- public VDC getResult() {
- return new VDCImpl(vDC.getName(), vDC.getType(), vDC.getHref(), description, catalog, publicIps,
- internetServices, resourceEntities, availableNetworks);
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
- Map<String, String> attributes = cleanseAttributes(attrs);
- super.startElement(uri, localName, qName, attrs);
- if (qName.endsWith("Vdc")) {
- vDC = newReferenceType(attributes);
- } else if (qName.endsWith("Network")) {
- putReferenceType(availableNetworks, attributes);
- } else if (qName.endsWith("ResourceEntity")) {
- putReferenceType(resourceEntities, attributes);
- } else if (equalsOrSuffix(qName, "Link")) {
- String name = attributes.get("name");
- if (name.equals("Internet Services")) {
- internetServices = Utils.newReferenceType(attributes);
- } else if (name.equals("Public IPs")) {
- publicIps = Utils.newReferenceType(attributes);
- } else {
- String type = attributes.get("type");
- if (type.equals(TerremarkVCloudMediaType.CATALOG_XML)) {
- catalog = Utils.newReferenceType(attributes);
- }
- }
- }
- }
-
- public void endElement(String uri, String name, String qName) {
- if (equalsOrSuffix(qName, "Description")) {
- description = 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/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/resources/ConfigureInternetService.xml
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/resources/ConfigureInternetService.xml b/common/trmk/src/main/resources/ConfigureInternetService.xml
deleted file mode 100644
index d2b4b6d..0000000
--- a/common/trmk/src/main/resources/ConfigureInternetService.xml
+++ /dev/null
@@ -1,22 +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.
-
--->
-<InternetService xmlns="{ns}"
- xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
- <Id>{id}</Id>{options}
-</InternetService>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/resources/CreateInternetService.xml
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/resources/CreateInternetService.xml b/common/trmk/src/main/resources/CreateInternetService.xml
deleted file mode 100644
index 2c55666..0000000
--- a/common/trmk/src/main/resources/CreateInternetService.xml
+++ /dev/null
@@ -1,28 +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.
-
--->
-<CreateInternetServiceRequest
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns="{ns}">
- <Name>{name}</Name>
- <Protocol>{protocol}</Protocol>
- <Port>{port}</Port>
- <Enabled>{enabled}</Enabled>
- {description}
- {monitor}
-</CreateInternetServiceRequest>
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/resources/CreateKey.xml
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/resources/CreateKey.xml b/common/trmk/src/main/resources/CreateKey.xml
deleted file mode 100644
index 55c8d0f..0000000
--- a/common/trmk/src/main/resources/CreateKey.xml
+++ /dev/null
@@ -1,23 +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.
-
--->
-<CreateKeyRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="{ns}">
- <Name>{name}</Name>
- <IsDefault>{isDefault}</IsDefault>
-</CreateKeyRequest>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/resources/CreateNodeService.xml
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/resources/CreateNodeService.xml b/common/trmk/src/main/resources/CreateNodeService.xml
deleted file mode 100644
index c4132f9..0000000
--- a/common/trmk/src/main/resources/CreateNodeService.xml
+++ /dev/null
@@ -1,26 +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.
-
--->
-<CreateNodeServiceRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="{ns}">
- <IpAddress>{ipAddress}</IpAddress>
- <Name>{name}</Name>
- <Port>{port}</Port>
- <Enabled>{enabled}</Enabled>
- {description}
-</CreateNodeServiceRequest>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkApiLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkApiLiveTest.java
deleted file mode 100644
index e52666c..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkApiLiveTest.java
+++ /dev/null
@@ -1,795 +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.trmk.vcloud_0_8;
-
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.find;
-import static com.google.common.collect.Iterables.size;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration.Builder.changeNameTo;
-import static org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration.Builder.deleteDiskWithAddressOnParent;
-import static org.jclouds.trmk.vcloud_0_8.options.CloneVAppOptions.Builder.deploy;
-import static org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.Builder.processorCount;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-
-import org.jclouds.apis.BaseApiLiveTest;
-import org.jclouds.cim.CIMPredicates;
-import org.jclouds.cim.ResourceAllocationSettingData;
-import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
-import org.jclouds.predicates.SocketOpen;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.ssh.SshClient;
-import org.jclouds.ssh.SshClient.Factory;
-import org.jclouds.ssh.SshException;
-import org.jclouds.sshj.config.SshjSshClientModule;
-import org.jclouds.trmk.vcloud_0_8.domain.Catalog;
-import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem;
-import org.jclouds.trmk.vcloud_0_8.domain.CustomizationParameters;
-import org.jclouds.trmk.vcloud_0_8.domain.InternetService;
-import org.jclouds.trmk.vcloud_0_8.domain.KeyPair;
-import org.jclouds.trmk.vcloud_0_8.domain.Network;
-import org.jclouds.trmk.vcloud_0_8.domain.Node;
-import org.jclouds.trmk.vcloud_0_8.domain.Org;
-import org.jclouds.trmk.vcloud_0_8.domain.Protocol;
-import org.jclouds.trmk.vcloud_0_8.domain.PublicIpAddress;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.domain.Status;
-import org.jclouds.trmk.vcloud_0_8.domain.Task;
-import org.jclouds.trmk.vcloud_0_8.domain.VApp;
-import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
-import org.jclouds.trmk.vcloud_0_8.domain.VDC;
-import org.jclouds.trmk.vcloud_0_8.options.AddInternetServiceOptions;
-import org.jclouds.trmk.vcloud_0_8.options.CloneVAppOptions;
-import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
-import org.jclouds.trmk.vcloud_0_8.predicates.TaskSuccess;
-import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants;
-import org.testng.annotations.AfterGroups;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.net.HostAndPort;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-
-@Test(groups = "live", singleThreaded = true)
-public abstract class TerremarkApiLiveTest extends BaseApiLiveTest<TerremarkVCloudApi> {
-
- protected String expectedOs = "Ubuntu Linux (64-bit)";
- protected String itemName = "Ubuntu JeOS 9.10 (64-bit)";
-
- protected Factory sshFactory;
- protected String publicIp;
- protected InternetService is;
- protected Node node;
- protected VApp vApp;
- protected Predicate<HostAndPort> socketTester;
- protected Predicate<URI> successTester;
- protected Injector injector;
-
- protected VApp clone;
- protected VDC vdc;
- protected String serverName;
- protected KeyPair key;
-
- public static final String PREFIX = System.getProperty("user.name") + "-terremark";
-
- public TerremarkApiLiveTest() {
- this.provider = "trmk-vcloudexpress";
- StringBuilder name = new StringBuilder();
- for (int i = 0; i < 15; i++)
- name.append("d");
- serverName = name.toString();// "adriantest";
- }
-
- @Test
- public void testKeysList() throws Exception {
- for (Org org : orgs) {
- TerremarkVCloudApi vCloudExpressClient = TerremarkVCloudApi.class.cast(api);
- Set<KeyPair> response = vCloudExpressClient.listKeyPairsInOrg(org.getHref());
- assertNotNull(response);
- }
- }
-
- @Test
- public void testGetAllInternetServices() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType vdc : org.getVDCs().values()) {
- for (InternetService service : api.getAllInternetServicesInVDC(vdc.getHref())) {
- assertNotNull(api.getNodes(service.getId()));
- }
- }
- }
- }
-
- @Test
- public void testCreateInternetServiceMonitorDisabled() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType vdc : org.getVDCs().values()) {
- Set<PublicIpAddress> publicIpAddresses = api.getPublicIpsAssociatedWithVDC(vdc.getHref());
- PublicIpAddress publicIp = publicIpAddresses.iterator().next();
- InternetService service = api.addInternetServiceToExistingIp(publicIp.getId(), PREFIX
- + "-no-monitoring", Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled());
- api.deleteInternetService(service.getId());
- }
- }
- }
-
- @Test
- public void testGetPublicIpsAssociatedWithVDC() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType vdc : org.getVDCs().values()) {
- for (PublicIpAddress ip : api.getPublicIpsAssociatedWithVDC(vdc.getHref())) {
- assertNotNull(api.getInternetServicesOnPublicIp(ip.getId()));
- assertNotNull(api.getPublicIp(ip.getId()));
- }
- }
- }
- }
-
- @Test
- public void testGetConfigCustomizationOptions() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType catalog : org.getCatalogs().values()) {
- Catalog response = api.getCatalog(catalog.getHref());
- for (ReferenceType resource : response.values()) {
- if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
- CatalogItem item = api.findCatalogItemInOrgCatalogNamed(org.getName(), catalog.getName(),
- resource.getName());
- assert api.getCustomizationOptions(item.getCustomizationOptions().getHref()) != null;
- }
- }
- }
- }
- }
-
- @Test(enabled = true)
- public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
- IOException {
- prepare();
-
- long hardDisk = 4194304;
-
- // long hardDisk = 4194304 / 4 * 10;
- // String catalogOs = "CentOS 5.3 (64-bit)";
- // String expectedOs = "Red Hat Enterprise Linux 5 (64-bit)";
-
- // lookup the datacenter you are deploying into
- vdc = api.findVDCInOrgNamed(null, null);
-
- // create an options object to collect the configuration we want.
- InstantiateVAppTemplateOptions instantiateOptions = createInstantiateOptions().sshKeyFingerprint(
- key.getFingerPrint());
-
- CatalogItem item = api.findCatalogItemInOrgCatalogNamed(null, null, itemName);
-
- assert item != null;
-
- // if this template supports setting the root password, let's add it to
- // our options
- CustomizationParameters customizationOptions = api.getCustomizationOptions(item.getCustomizationOptions()
- .getHref());
-
- if (customizationOptions.canCustomizePassword())
- instantiateOptions.withPassword("robotsarefun");
-
- VAppTemplate vAppTemplate = api.getVAppTemplate(item.getEntity().getHref());
-
- assert vAppTemplate != null;
-
- // instantiate, noting vApp returned has minimal details
- vApp = api.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName,
- instantiateOptions);
-
- assertEquals(vApp.getStatus(), Status.RESOLVED);
-
- // in terremark, this should be a no-op, as it should simply return the
- // above task, which is
- // already deploying
- Task deployTask = api.deployVApp(vApp.getHref());
-
- // check to see the result of calling deploy twice
- deployTask = api.deployVApp(vApp.getHref());
- assertEquals(deployTask.getHref(), deployTask.getHref());
-
- vApp = api.getVApp(vApp.getHref());
-
- assertEquals(vApp.getStatus(), Status.RESOLVED);
-
- try {// per docs, this is not supported
- api.cancelTask(deployTask.getHref());
- } catch (UnsupportedOperationException e) {
- }
-
- assert successTester.apply(deployTask.getHref());
- System.out.printf("%d: done deploying vApp%n", System.currentTimeMillis());
-
- vApp = api.getVApp(vApp.getHref());
-
- ReferenceType vAppResource = api.findVDCInOrgNamed(null, null).getResourceEntities().get(serverName);
- assertEquals(vAppResource.getHref(), vApp.getHref());
-
- int processorCount = 1;
- long memory = 512;
- verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk);
- assertEquals(vApp.getStatus(), Status.OFF);
-
- assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
- System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
-
- vApp = api.getVApp(vApp.getHref());
- assertEquals(vApp.getStatus(), Status.ON);
- }
-
- protected InstantiateVAppTemplateOptions createInstantiateOptions() {
- return processorCount(1).memory(512).sshKeyFingerprint(key.getFingerPrint());
- }
-
- protected void prepare() {
- Org org = api.findOrgNamed(null);
- try {
- key = api.generateKeyPairInOrg(org.getHref(), "livetest", false);
- } catch (IllegalStateException e) {
- key = api.findKeyPairInOrg(org.getHref(), "livetest");
- api.deleteKeyPair(key.getId());
- key = api.generateKeyPairInOrg(org.getHref(), "livetest", false);
- }
- assertNotNull(key);
- assertEquals(key.getName(), "livetest");
- assertNotNull(key.getPrivateKey());
- assertNotNull(key.getFingerPrint());
- assertEquals(key.isDefault(), false);
- assertEquals(key.getFingerPrint(), api.findKeyPairInOrg(org.getHref(), key.getName()).getFingerPrint());
- }
-
- protected abstract Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(VApp vApp);
-
- @Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn")
- public void testAddInternetService() throws InterruptedException, ExecutionException, TimeoutException, IOException {
- Entry<InternetService, PublicIpAddress> entry = getNewInternetServiceAndIpForSSH(vApp);
- is = entry.getKey();
- publicIp = entry.getValue().getAddress();
- }
-
- @Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn")
- public void testCloneVApp() throws IOException {
- assert successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
- System.out.printf("%d: done powering off vApp%n", System.currentTimeMillis());
-
- StringBuilder name = new StringBuilder();
- for (int i = 0; i < 15; i++)
- name.append("b");
- String newName = name.toString();
-
- CloneVAppOptions options = deploy().powerOn().withDescription("The description of " + newName);
-
- System.out.printf("%d: cloning vApp%n", System.currentTimeMillis());
- Task task = api.cloneVAppInVDC(vdc.getHref(), vApp.getHref(), newName, options);
-
- // wait for the task to complete
- assert successTester.apply(task.getHref());
- System.out.printf("%d: done cloning vApp%n", System.currentTimeMillis());
-
- assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
- System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
-
- // refresh task to get the new vApp location
- task = api.getTask(task.getHref());
-
- clone = api.getVApp(task.getOwner().getHref());
- assertEquals(clone.getStatus(), Status.ON);
-
- assertEquals(clone.getName(), newName);
- assertEquals(clone.getNetworkToAddresses().values().size(), 1);
- }
-
- @Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
- public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
- node = api.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()), vApp.getName()
- + "-SSH", 22);
- loopAndCheckPass();
- }
-
- protected void loopAndCheckPass() throws IOException {
- for (int i = 0; i < 5; i++) {// retry loop TODO replace with predicate.
- try {
- doCheckPass(publicIp);
- return;
- } catch (SshException e) {
- try {
- Thread.sleep(10 * 1000);
- } catch (InterruptedException e1) {
- }
- continue;
- }
- }
- }
-
- @Test(enabled = true, dependsOnMethods = "testPublicIp")
- public void testConfigureNode() throws InterruptedException, ExecutionException, TimeoutException, IOException {
- api.configureNode(node.getId(), node.getName(), node.isEnabled(), "holy cow");
- }
-
- @Test(enabled = true, dependsOnMethods = "testPublicIp")
- public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException, IOException {
-
- try {// per docs, this is not supported
- api.undeployVApp(vApp.getHref());
- fail("Expected UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- }
-
- try {// per docs, this is not supported
- api.suspendVApp(vApp.getHref());
- fail("Expected UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- }
-
- assert successTester.apply(api.resetVApp(vApp.getHref()).getHref());
-
- vApp = api.getVApp(vApp.getHref());
-
- assertEquals(vApp.getStatus(), Status.ON);
-
- // TODO we need to determine whether shutdown is supported before invoking
- // it.
- // api.shutdownVApp(vApp.getId());
- // vApp = api.getVApp(vApp.getId());
- // assertEquals(vApp.getStatus(), VAppStatus.ON);
-
- assert successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
-
- vApp = api.getVApp(vApp.getHref());
- assertEquals(vApp.getStatus(), Status.OFF);
- }
-
- @Test(enabled = true, dependsOnMethods = "testLifeCycle")
- public void testConfigure() throws InterruptedException, ExecutionException, TimeoutException, IOException {
-
- vApp = api.getVApp(vApp.getHref());
-
- Task task = api.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1)
- .addDisk(25 * 1048576).addDisk(25 * 1048576));
-
- assert successTester.apply(task.getHref());
-
- vApp = api.getVApp(vApp.getHref());
- assertEquals(vApp.getName(), "eduardo");
- assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
- .getVirtualQuantity().longValue(), 1);
- assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY))
- .getVirtualQuantity().longValue(), 1536);
- assertEquals(size(filter(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))),
- 3);
-
- assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
-
- loopAndCheckPass();
-
- assert successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
-
- // extract the disks on the vApp sorted by addressOnParent
- List<ResourceAllocationSettingData> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(),
- CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)));
-
- // delete the second disk
- task = api.configureVApp(vApp,
- deleteDiskWithAddressOnParent(Integer.parseInt(disks.get(1).getAddressOnParent())));
-
- assert successTester.apply(task.getHref());
-
- assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
- loopAndCheckPass();
- }
-
- protected void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs, int processorCount,
- long memory, long hardDisk) {
- assertEquals(vApp.getName(), serverName);
- assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
- assertEquals((int) find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
- .getVirtualQuantity().longValue(), processorCount);
- assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY))
- .getVirtualQuantity().longValue(), memory);
- assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))
- .getVirtualQuantity().longValue(), hardDisk);
- assertEquals(vApp.getSize().longValue(),
- find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))
- .getVirtualQuantity().longValue());
- }
-
- protected void doCheckPass(String address) throws IOException {
- HostAndPort socket = HostAndPort.fromParts(address, 22);
-
- System.out.printf("%d: %s awaiting ssh service to start%n", System.currentTimeMillis(), socket);
- assert socketTester.apply(socket);
- System.out.printf("%d: %s ssh service started%n", System.currentTimeMillis(), socket);
-
- SshClient ssh = getConnectionFor(socket);
- try {
- ssh.connect();
- System.out.printf("%d: %s ssh ssh made%n", System.currentTimeMillis(), socket);
- System.out.println(ssh.exec("df -h"));
- System.out.println(ssh.exec("ls -al /dev/sd*"));
- System.out.println(ssh.exec("echo '$Ep455l0ud!2'|sudo -S fdisk -l"));
- } finally {
- if (ssh != null)
- ssh.disconnect();
- }
- }
-
- protected abstract SshClient getConnectionFor(HostAndPort socket);
-
- @AfterGroups(groups = { "live" })
- void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
- if (node != null)
- api.deleteNode(node.getId());
- if (is != null)
- api.deleteInternetService(is.getId());
- if (key != null)
- api.deleteKeyPair(key.getId());
- if (vApp != null) {
- try {
- successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
- } catch (Exception e) {
-
- }
- api.deleteVApp(vApp.getHref());
- }
- if (clone != null) {
- try {
- successTester.apply(api.powerOffVApp(clone.getHref()).getHref());
- } catch (Exception e) {
-
- }
- api.deleteVApp(clone.getHref());
- }
- }
-
- @Override
- protected TerremarkVCloudApi create(Properties props, Iterable<Module> modules) {
- Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
- sshFactory = injector.getInstance(SshClient.Factory.class);
-
- // longer than default internet service timeout
- socketTester = retry(injector.getInstance(SocketOpen.class), 300, 10, SECONDS);
- successTester = retry(injector.getInstance(TaskSuccess.class), 650, 10, SECONDS);
- api = injector.getInstance(TerremarkVCloudApi.class);
- orgs = listOrgs();
- return api;
- }
-
- @Test
- public void testOrg() throws Exception {
- for (Org org : orgs) {
- assertNotNull(org);
- assertNotNull(org.getName());
- assert org.getCatalogs().size() >= 1;
- assert org.getTasksLists().size() >= 1;
- assert org.getVDCs().size() >= 1;
- assertEquals(api.findOrgNamed(org.getName()), org);
- }
- }
-
- @Test
- public void testPropertiesCanOverrideDefaultOrg() throws Exception {
- for (Org org : orgs) {
- TerremarkVCloudApi newApi = null;
- try {
- newApi = create(
- overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName())),
- setupModules());
- assertEquals(newApi.findOrgNamed(null), org);
- } finally {
- newApi.close();
- }
- }
- }
-
- public Properties overrideDefaults(Map<String, String> overrides) {
- Properties properties = setupProperties();
- properties.putAll(overrides);
- return properties;
- }
-
- @Test
- public void testCatalog() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType cat : org.getCatalogs().values()) {
- Catalog response = api.getCatalog(cat.getHref());
- assertNotNull(response);
- assertNotNull(response.getName());
- assertNotNull(response.getHref());
- assertEquals(api.findCatalogInOrgNamed(org.getName(), response.getName()), response);
- }
- }
- }
-
- @Test
- public void testPropertiesCanOverrideDefaultCatalog() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType cat : org.getCatalogs().values()) {
- TerremarkVCloudApi newApi = null;
- try {
- newApi = create(
- overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
- VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName())), setupModules());
- assertEquals(newApi.findCatalogInOrgNamed(null, null), api.getCatalog(cat.getHref()));
- } finally {
- newApi.close();
- }
- }
- }
- }
-
- @Test
- public void testGetVDCNetwork() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType vdc : org.getVDCs().values()) {
- VDC response = api.getVDC(vdc.getHref());
- for (ReferenceType resource : response.getAvailableNetworks().values()) {
- if (resource.getType().equals(TerremarkVCloudMediaType.NETWORK_XML)) {
- try {
- Network net = api.getNetwork(resource.getHref());
- assertNotNull(net);
- assertNotNull(net.getName());
- assertNotNull(net.getHref());
- assertEquals(
- api.findNetworkInOrgVDCNamed(org.getName(), response.getName(), net.getName()), net);
- } catch (AuthorizationException e) {
-
- }
- }
- }
- }
- }
- }
-
- @Test
- public void testPropertiesCanOverrideDefaultNetwork() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType vdc : org.getVDCs().values()) {
- VDC response = api.getVDC(vdc.getHref());
- for (ReferenceType net : response.getAvailableNetworks().values()) {
- TerremarkVCloudApi newApi = null;
- try {
- newApi = create(
- overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
- VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName(),
- VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName())), setupModules());
- assertEquals(newApi.findNetworkInOrgVDCNamed(null, null, net.getName()),
- api.getNetwork(net.getHref()));
- } finally {
- newApi.close();
- }
- }
- }
- }
- }
-
- @Test
- public void testGetCatalogItem() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType cat : org.getCatalogs().values()) {
- Catalog response = api.getCatalog(cat.getHref());
- for (ReferenceType resource : response.values()) {
- if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
- CatalogItem item = api.getCatalogItem(resource.getHref());
- verifyCatalogItem(item);
- }
- }
- }
- }
- }
-
- protected void verifyCatalogItem(CatalogItem item) {
- assertNotNull(item);
- assertNotNull(item);
- assertNotNull(item.getEntity());
- assertNotNull(item.getHref());
- assertNotNull(item.getProperties());
- assertNotNull(item.getType());
- }
-
- @Test
- public void testFindCatalogItem() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType cat : org.getCatalogs().values()) {
- Catalog response = api.getCatalog(cat.getHref());
- for (ReferenceType resource : response.values()) {
- if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
- CatalogItem item = api.findCatalogItemInOrgCatalogNamed(org.getName(), response.getName(),
- resource.getName());
- verifyCatalogItem(item);
- }
- }
- }
- }
- }
-
- @Test
- public void testDefaultVDC() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType vdc : org.getVDCs().values()) {
- VDC response = api.getVDC(vdc.getHref());
- assertNotNull(response);
- assertNotNull(response.getName());
- assertNotNull(response.getHref());
- assertNotNull(response.getResourceEntities());
- assertNotNull(response.getAvailableNetworks());
- assertNotNull(response.getCatalog());
- assertNotNull(response.getInternetServices());
- assertNotNull(response.getPublicIps());
- assertEquals(api.getVDC(response.getHref()), response);
- }
- }
- }
-
- @Test
- public void testPropertiesCanOverrideDefaultVDC() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType vdc : org.getVDCs().values()) {
- TerremarkVCloudApi newApi = null;
- try {
- newApi = create(
- overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
- VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName())), setupModules());
- assertEquals(newApi.findVDCInOrgNamed(null, null), api.getVDC(vdc.getHref()));
- } finally {
- newApi.close();
- }
- }
- }
- }
-
- @Test
- public void testDefaultTasksList() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType tasksList : org.getTasksLists().values()) {
- org.jclouds.trmk.vcloud_0_8.domain.TasksList response = api.findTasksListInOrgNamed(org.getName(),
- tasksList.getName());
- assertNotNull(response);
- assertNotNull(response.getLocation());
- assertNotNull(response.getTasks());
- assertEquals(api.getTasksList(response.getLocation()).getLocation(), response.getLocation());
- }
- }
- }
-
- @Test
- public void testPropertiesCanOverrideDefaultTasksList() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType tasksList : org.getTasksLists().values()) {
- TerremarkVCloudApi newApi = null;
- try {
- newApi = create(
- overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
- VCloudConstants.PROPERTY_VCLOUD_DEFAULT_TASKSLIST, tasksList.getName())), setupModules());
- assertEquals(newApi.findTasksListInOrgNamed(null, null),
- api.getTasksList(tasksList.getHref()));
- } finally {
- newApi.close();
- }
- }
- }
- }
-
- @Test
- public void testGetTask() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType tasksList : org.getTasksLists().values()) {
- org.jclouds.trmk.vcloud_0_8.domain.TasksList response = api.findTasksListInOrgNamed(org.getName(),
- tasksList.getName());
- assertNotNull(response);
- assertNotNull(response.getLocation());
- assertNotNull(response.getTasks());
- if (response.getTasks().size() > 0) {
- Task task = response.getTasks().last();
- assertEquals(api.getTask(task.getHref()).getHref(), task.getHref());
- }
- }
- }
- }
-
- protected Iterable<Org> orgs;
-
- protected Iterable<Org> listOrgs() {
- return Iterables.transform(api.listOrgs().values(), new Function<ReferenceType, Org>() {
-
- @Override
- public Org apply(ReferenceType arg0) {
- return api.getOrg(arg0.getHref());
- }
-
- });
- }
-
- @Test
- public void testGetVAppTemplate() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType cat : org.getCatalogs().values()) {
- Catalog response = api.getCatalog(cat.getHref());
- for (ReferenceType resource : response.values()) {
- if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
- CatalogItem item = api.getCatalogItem(resource.getHref());
- if (item.getEntity().getType().equals(TerremarkVCloudMediaType.VAPPTEMPLATE_XML)) {
- assertNotNull(api.getVAppTemplate(item.getEntity().getHref()));
- }
- }
- }
- }
- }
- }
-
- @Test
- public void testGetVApp() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType vdc : org.getVDCs().values()) {
- VDC response = api.getVDC(vdc.getHref());
- for (ReferenceType item : response.getResourceEntities().values()) {
- if (item.getType().equals(TerremarkVCloudMediaType.VAPP_XML)) {
- try {
- VApp app = api.getVApp(item.getHref());
- assertNotNull(app);
- } catch (RuntimeException e) {
-
- }
- }
- }
- }
- }
- }
-
- @Test
- public void testFindVAppTemplate() throws Exception {
- for (Org org : orgs) {
- for (ReferenceType cat : org.getCatalogs().values()) {
- Catalog response = api.getCatalog(cat.getHref());
- for (ReferenceType resource : response.values()) {
- if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
- CatalogItem item = api.getCatalogItem(resource.getHref());
- if (item.getEntity().getType().equals(TerremarkVCloudMediaType.VAPPTEMPLATE_XML)) {
- assertNotNull(api.findVAppTemplateInOrgCatalogNamed(org.getName(), response.getName(), item
- .getEntity().getName()));
- }
- }
- }
- }
- }
- }
-
- @Override
- protected Iterable<Module> setupModules() {
- return ImmutableSet.<Module> of(getLoggingModule(), new SshjSshClientModule());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindAddInternetServiceToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindAddInternetServiceToXmlPayloadTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindAddInternetServiceToXmlPayloadTest.java
deleted file mode 100644
index 95af55c..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindAddInternetServiceToXmlPayloadTest.java
+++ /dev/null
@@ -1,117 +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.trmk.vcloud_0_8.binders;
-
-import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotEquals;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Maps;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Provides;
-import com.google.inject.name.Names;
-
-/**
- * Tests behavior of {@code BindAddInternetServiceToXmlPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class BindAddInternetServiceToXmlPayloadTest {
- Injector injector = Guice.createInjector(new AbstractModule() {
-
- @Override
- protected void configure() {
- bindConstant().annotatedWith(Names.named(PROPERTY_TERREMARK_EXTENSION_NS)).to(
- "urn:tmrk:vCloudExpressExtensions-1.6");
- }
-
- @Singleton
- @Provides
- @Named("CreateInternetService")
- String provideInstantiateVAppTemplateParams() throws IOException {
- InputStream is = getClass().getResourceAsStream("/CreateInternetService.xml");
- return Strings2.toStringAndClose(is);
- }
- });
-
- public void testApplyInputStream() throws IOException {
- String expected = Strings2.toStringAndClose(getClass().getResourceAsStream(
- "/CreateInternetService-test.xml"));
- HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build();
- BindAddInternetServiceToXmlPayload binder = injector
- .getInstance(BindAddInternetServiceToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- map.put("name", "name");
- map.put("protocol", "TCP");
- map.put("port", "22");
- map.put("enabled", "true");
- map.put("description", "name TCP 22");
- binder.bindToRequest(request, map);
- assertEquals(request.getPayload().getRawContent(), expected);
- }
-
- public void testDisableMonitoringEnabled() throws IOException {
- HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build();
- BindAddInternetServiceToXmlPayload binder = injector
- .getInstance(BindAddInternetServiceToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- map.put("name", "name");
- map.put("protocol", "TCP");
- map.put("port", "22");
- map.put("enabled", "true");
-
- map.put("monitor", "true");
-
- binder.bindToRequest(request, map);
- String rawContent = (String) request.getPayload().getRawContent();
- assertEquals(-1, rawContent.indexOf("<MonitorType>Disabled</MonitorType>"));
- }
-
- public void testDisableMonitoringDisabled() throws IOException {
- HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build();
- BindAddInternetServiceToXmlPayload binder = injector
- .getInstance(BindAddInternetServiceToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- map.put("name", "name");
- map.put("protocol", "TCP");
- map.put("port", "22");
- map.put("enabled", "true");
-
- map.put("monitor", "false");
-
- binder.bindToRequest(request, map);
- String rawContent = (String) request.getPayload().getRawContent();
- assertNotEquals(-1, rawContent.indexOf("<MonitorType>Disabled</MonitorType>"));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindAddNodeServiceToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindAddNodeServiceToXmlPayloadTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindAddNodeServiceToXmlPayloadTest.java
deleted file mode 100644
index 06b9b1b..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindAddNodeServiceToXmlPayloadTest.java
+++ /dev/null
@@ -1,77 +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.trmk.vcloud_0_8.binders;
-
-import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Maps;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Provides;
-import com.google.inject.name.Names;
-
-/**
- * Tests behavior of {@code BindAddNodeServiceToXmlPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class BindAddNodeServiceToXmlPayloadTest {
- Injector injector = Guice.createInjector(new AbstractModule() {
-
- @Override
- protected void configure() {
- bindConstant().annotatedWith(Names.named(PROPERTY_TERREMARK_EXTENSION_NS)).to(
- "urn:tmrk:vCloudExpressExtensions-1.6");
- }
-
- @Singleton
- @Provides
- @Named("CreateNodeService")
- String provideInstantiateVAppTemplateParams() throws IOException {
- InputStream is = getClass().getResourceAsStream("/CreateNodeService.xml");
- return Strings2.toStringAndClose(is);
- }
- });
-
- public void testApplyInputStream() throws IOException {
- String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/CreateNodeService-test.xml"));
- HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build();
- BindAddNodeServiceToXmlPayload binder = injector.getInstance(BindAddNodeServiceToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- map.put("name", "Node for Jim");
- map.put("ipAddress", "172.16.20.3");
- map.put("port", "80");
- map.put("enabled", "false");
- map.put("description", "Some test node");
- assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindCloneVAppParamsToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindCloneVAppParamsToXmlPayloadTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindCloneVAppParamsToXmlPayloadTest.java
deleted file mode 100644
index 485fa70..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindCloneVAppParamsToXmlPayloadTest.java
+++ /dev/null
@@ -1,83 +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.trmk.vcloud_0_8.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Map;
-import java.util.Properties;
-
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.trmk.vcloud_0_8.internal.BasePayloadTest;
-import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata;
-import org.jclouds.trmk.vcloud_0_8.options.CloneVAppOptions;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.name.Names;
-
-/**
- * Tests behavior of {@code BindCloneVAppParamsToXmlPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class BindCloneVAppParamsToXmlPayloadTest extends BasePayloadTest {
- Injector injector = Guice.createInjector(new AbstractModule() {
-
- @Override
- protected void configure() {
- Properties props = TerremarkVCloudApiMetadata.defaultProperties();
- props.setProperty("jclouds.vcloud.xml.ns", "http://www.vmware.com/vcloud/v0.8");
- props.setProperty("jclouds.vcloud.xml.schema", "http://vcloud.safesecureweb.com/ns/vcloud.xsd");
- Names.bindProperties(binder(), props);
- }
- });
-
- public void testWithDescriptionDeployOn() throws Exception {
- String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp.xml"));
-
- CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().withDescription(
- "The description of the new vApp");
- GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(options));
-
- BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- map.put("newName", "new-linux-server");
- map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/201");
- assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
- }
-
- public void testDefault() throws Exception {
- String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml"));
-
- GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
-
- BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- map.put("newName", "my-vapp");
- map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/4181");
- assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java
deleted file mode 100644
index 17f5f9d..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java
+++ /dev/null
@@ -1,89 +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.trmk.vcloud_0_8.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Map;
-
-import javax.inject.Singleton;
-
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.domain.internal.ReferenceTypeImpl;
-import org.jclouds.trmk.vcloud_0_8.endpoints.Network;
-import org.jclouds.trmk.vcloud_0_8.internal.BasePayloadTest;
-import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata;
-import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
-import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.NetworkConfig;
-import org.jclouds.util.Strings2;
-import org.nnsoft.guice.rocoto.Rocoto;
-import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Provides;
-
-/**
- * Tests behavior of {@code BindInstantiateVAppTemplateParamsToXmlPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class BindInstantiateVAppTemplateParamsToXmlPayloadTest extends BasePayloadTest {
- Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
-
- @Override
- protected void bindConfigurations() {
- bindProperties(TerremarkVCloudApiMetadata.defaultProperties());
- }
-
- @Network
- @Provides
- @Singleton
- Supplier<ReferenceType> provideNetwork() {
- return Suppliers.<ReferenceType> ofInstance(new ReferenceTypeImpl(null, null, URI
- .create("https://vcloud.safesecureweb.com/network/1990")));
- }
- }));
-
- public void testAllOptions() throws IOException {
-
- String expected = Strings2.toStringAndClose(getClass().getResourceAsStream(
- "/InstantiateVAppTemplateParams-options-test.xml"));
-
- GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(InstantiateVAppTemplateOptions.Builder
- .processorCount(2).memory(512).inGroup("group").withPassword("password").inRow("row")
- .addNetworkConfig(new NetworkConfig(URI.create("http://network")))));
-
- BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
- .getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- map.put("name", "name");
- map.put("template", "https://vcloud/vAppTemplate/3");
- assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
- }
-
-}