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:31 UTC
[11/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/functions/AllCatalogsInOrg.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/AllCatalogsInOrg.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/AllCatalogsInOrg.java
deleted file mode 100644
index 011fae8..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/AllCatalogsInOrg.java
+++ /dev/null
@@ -1,57 +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.functions;
-
-import static com.google.common.collect.Iterables.transform;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.logging.Logger;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-import org.jclouds.trmk.vcloud_0_8.domain.Catalog;
-import org.jclouds.trmk.vcloud_0_8.domain.Org;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-
-import com.google.common.base.Function;
-
-/**
- * @author Adrian Cole
- */
-@Singleton
-public class AllCatalogsInOrg implements Function<Org, Iterable<? extends Catalog>> {
- @Resource
- public Logger logger = Logger.NULL;
-
- private final TerremarkVCloudApi aclient;
-
- @Inject
- AllCatalogsInOrg(TerremarkVCloudApi aclient) {
- this.aclient = aclient;
- }
-
- @Override
- public Iterable<? extends Catalog> apply(final Org org) {
- return transform(org.getCatalogs().values(),
- new Function<ReferenceType, Catalog>() {
- public Catalog apply(ReferenceType from) {
- return aclient.getCatalog(from.getHref());
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/AllVDCsInOrg.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/AllVDCsInOrg.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/AllVDCsInOrg.java
deleted file mode 100644
index 9f8b775..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/AllVDCsInOrg.java
+++ /dev/null
@@ -1,57 +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.functions;
-
-import static com.google.common.collect.Iterables.transform;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.logging.Logger;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-import org.jclouds.trmk.vcloud_0_8.domain.Org;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-
-import com.google.common.base.Function;
-
-/**
- * @author Adrian Cole
- */
-@Singleton
-public class AllVDCsInOrg implements Function<Org, Iterable<? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> {
- @Resource
- public Logger logger = Logger.NULL;
-
- private final TerremarkVCloudApi aclient;
-
- @Inject
- AllVDCsInOrg(TerremarkVCloudApi aclient) {
- this.aclient = aclient;
- }
-
- @Override
- public Iterable<? extends org.jclouds.trmk.vcloud_0_8.domain.VDC> apply(final Org org) {
- return transform(org.getVDCs().values(),
- new Function<ReferenceType, org.jclouds.trmk.vcloud_0_8.domain.VDC>() {
- public org.jclouds.trmk.vcloud_0_8.domain.VDC apply(ReferenceType from) {
- return aclient.getVDC(from.getHref());
- }
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameToEndpoint.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameToEndpoint.java
deleted file mode 100644
index a97685d..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameToEndpoint.java
+++ /dev/null
@@ -1,57 +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.functions;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.endpoints.Org;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-
-/**
- *
- * @author Adrian Cole
- */
-@Singleton
-public class OrgNameToEndpoint implements Function<Object, URI> {
- private final Supplier<Map<String, ReferenceType>> orgNameToEndpointSupplier;
- private final Supplier<ReferenceType> defaultOrg;
-
- @Inject
- public OrgNameToEndpoint(@Org Supplier<Map<String, ReferenceType>> orgNameToEndpointSupplier,
- @Org Supplier<ReferenceType> defaultOrg) {
- this.orgNameToEndpointSupplier = orgNameToEndpointSupplier;
- this.defaultOrg = defaultOrg;
- }
-
- public URI apply(Object from) {
- try {
- Map<String, ReferenceType> orgNameToEndpoint = orgNameToEndpointSupplier.get();
- return from == null ? defaultOrg.get().getHref() : orgNameToEndpoint.get(from).getHref();
- } catch (NullPointerException e) {
- throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpointSupplier.get().keySet());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToEndpoint.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToEndpoint.java
deleted file mode 100644
index 19078b5..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToEndpoint.java
+++ /dev/null
@@ -1,64 +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.functions;
-
-import java.net.URI;
-import java.util.Map;
-
-import org.jclouds.rest.ResourceNotFoundException;
-import org.jclouds.trmk.vcloud_0_8.domain.Org;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.common.collect.Maps;
-
-/**
- *
- * @author Adrian Cole
- */
-public abstract class OrgURIToEndpoint implements Function<Object, URI> {
-
- protected final Supplier<Map<String, ? extends Org>> orgMap;
- protected final Supplier<ReferenceType> defaultOrg;
-
- public OrgURIToEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
- @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultUri) {
- this.orgMap = orgMap;
- this.defaultOrg = defaultUri;
- }
-
- public URI apply(Object from) {
- Map<URI, ? extends Org> uriToOrg = Maps.uniqueIndex(orgMap.get().values(), new Function<Org, URI>() {
-
- @Override
- public URI apply(Org from) {
- return from.getHref();
- }
-
- });
- try {
- Org org = uriToOrg.get(from == null ? defaultOrg.get().getHref() : from);
- return getUriFromOrg(org);
- } catch (NullPointerException e) {
- throw new ResourceNotFoundException("org " + from + " not found in: " + uriToOrg, e);
- }
- }
-
- protected abstract URI getUriFromOrg(Org org);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToKeysListEndpoint.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToKeysListEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToKeysListEndpoint.java
deleted file mode 100644
index b5537cc..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToKeysListEndpoint.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.trmk.vcloud_0_8.functions;
-
-import java.net.URI;
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.trmk.vcloud_0_8.domain.Org;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-
-/**
- *
- * @author Adrian Cole
- */
-@Singleton
-public class OrgURIToKeysListEndpoint extends OrgURIToEndpoint implements Function<Object, URI> {
- @Inject
- public OrgURIToKeysListEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
- @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultUri) {
- super(orgMap, defaultUri);
- }
-
- public URI getUriFromOrg(Org org) {
- return org.getKeys().getHref();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgsForLocations.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgsForLocations.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgsForLocations.java
deleted file mode 100644
index ec0df6d..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgsForLocations.java
+++ /dev/null
@@ -1,72 +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.functions;
-
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.transform;
-
-import java.net.URI;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationScope;
-import org.jclouds.logging.Logger;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-import org.jclouds.trmk.vcloud_0_8.domain.Org;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Sets;
-
-/**
- * @author Adrian Cole
- */
-@Singleton
-public class OrgsForLocations implements Function<Iterable<? extends Location>, Iterable<? extends Org>> {
- @Resource
- public Logger logger = Logger.NULL;
- private final TerremarkVCloudApi aclient;
-
- @Inject
- OrgsForLocations(TerremarkVCloudApi aclient) {
- this.aclient = aclient;
- }
-
- /**
- * Zones are assignable, but we want regions. so we look for zones, whose
- * parent is region. then, we use a set to extract the unique set.
- */
- @Override
- public Iterable<? extends Org> apply(Iterable<? extends Location> from) {
- return transform(Sets.newLinkedHashSet(transform(filter(from, new Predicate<Location>() {
- public boolean apply(Location input) {
- return input.getScope() == LocationScope.ZONE;
- }
- }), new Function<Location, URI>() {
- public URI apply(Location from) {
- return URI.create(from.getParent().getId());
- }
- })), new Function<URI, Org>() {
- public Org apply(URI from) {
- return aclient.getOrg(from);
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgsForNames.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgsForNames.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgsForNames.java
deleted file mode 100644
index 5823bb8..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgsForNames.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.trmk.vcloud_0_8.functions;
-
-import static com.google.common.collect.Iterables.transform;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.logging.Logger;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-import org.jclouds.trmk.vcloud_0_8.domain.Org;
-
-import com.google.common.base.Function;
-
-/**
- * @author Adrian Cole
- */
-@Singleton
-public class OrgsForNames implements Function<Iterable<String>, Iterable<? extends Org>> {
- @Resource
- public Logger logger = Logger.NULL;
- private final TerremarkVCloudApi aclient;
-
- @Inject
- OrgsForNames(TerremarkVCloudApi aclient) {
- this.aclient = aclient;
- }
-
- @Override
- public Iterable<? extends Org> apply(Iterable<String> from) {
- return transform(from, new Function<String, Org>() {
- public Org apply(String from) {
- return aclient.findOrgNamed(from);
- }
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/ParseLoginResponseFromHeaders.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/ParseLoginResponseFromHeaders.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/ParseLoginResponseFromHeaders.java
deleted file mode 100644
index 5d073a7..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/ParseLoginResponseFromHeaders.java
+++ /dev/null
@@ -1,105 +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.functions;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.http.HttpUtils.releasePayload;
-
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.inject.Inject;
-import javax.inject.Provider;
-import javax.inject.Singleton;
-import javax.ws.rs.core.HttpHeaders;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.http.functions.ParseSax.Factory;
-import org.jclouds.trmk.vcloud_0_8.VCloudToken;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.domain.VCloudSession;
-import org.jclouds.trmk.vcloud_0_8.endpoints.Org;
-import org.jclouds.trmk.vcloud_0_8.xml.OrgListHandler;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-
-/**
- * This parses {@link VCloudSession} from HTTP headers.
- *
- * @author Adrian Cole
- */
-@Singleton
-public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCloudSession> {
- static final Pattern pattern = Pattern.compile("(vcloud-token)=?([^;]+)(;.*)?");
-
- private final ParseSax.Factory factory;
- private final Provider<OrgListHandler> orgHandlerProvider;
-
- @Inject
- private ParseLoginResponseFromHeaders(Factory factory, Provider<OrgListHandler> orgHandlerProvider) {
- this.factory = factory;
- this.orgHandlerProvider = orgHandlerProvider;
- }
-
- /**
- * parses the http response headers to create a new {@link VCloudSession} object.
- */
- public VCloudSession apply(HttpResponse from) {
- try {
- final String token = parseTokenFromHeaders(from);
- final Map<String, ReferenceType> org = factory.create(orgHandlerProvider.get()).parse(
- checkNotNull(from.getPayload().getInput(), "no payload in http response to login request %s", from));
-
- return new VCloudSession() {
- @VCloudToken
- public String getVCloudToken() {
- return token;
- }
-
- @Org
- public Map<String, ReferenceType> getOrgs() {
- return org;
- }
- };
- } finally {
- releasePayload(from);
- }
- }
-
- public String parseTokenFromHeaders(HttpResponse from) {
- String cookieHeader = from.getFirstHeaderOrNull("x-vcloud-authorization");
- if (cookieHeader != null) {
- Matcher matcher = pattern.matcher(cookieHeader);
- return matcher.find() ? matcher.group(2) : cookieHeader;
- } else {
- try {
- cookieHeader = Iterables.find(from.getHeaders().get(HttpHeaders.SET_COOKIE), Predicates.contains(pattern));
- Matcher matcher = pattern.matcher(cookieHeader);
- matcher.find();
- return matcher.group(2);
- } catch (NoSuchElementException e) {
- throw new HttpResponseException(String.format("Header %s or %s must be present", "x-vcloud-authorization",
- HttpHeaders.SET_COOKIE), null, from);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/ParseTaskFromLocationHeader.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/ParseTaskFromLocationHeader.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/ParseTaskFromLocationHeader.java
deleted file mode 100644
index f6b622a..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/ParseTaskFromLocationHeader.java
+++ /dev/null
@@ -1,51 +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.functions;
-
-import java.net.URI;
-import java.util.Date;
-
-import javax.inject.Singleton;
-import javax.ws.rs.core.HttpHeaders;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseException;
-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.internal.TaskImpl;
-
-import com.google.common.base.Function;
-
-/**
- *
- * @author Adrian Cole
- */
-@Singleton
-public class ParseTaskFromLocationHeader implements Function<HttpResponse, Task> {
-
- public Task apply(HttpResponse from) {
- String location = from.getFirstHeaderOrNull(HttpHeaders.LOCATION);
- if (location == null)
- location = from.getFirstHeaderOrNull("location");
- if (location != null) {
- return new TaskImpl(URI.create(location), null, TaskStatus.QUEUED, new Date(), null, null, null, null);
- } else {
- throw new HttpResponseException("no uri in headers or content", null, from);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VAppTemplatesForCatalogItems.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VAppTemplatesForCatalogItems.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VAppTemplatesForCatalogItems.java
deleted file mode 100644
index bd407fb..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VAppTemplatesForCatalogItems.java
+++ /dev/null
@@ -1,66 +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.functions;
-
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.transform;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.logging.Logger;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType;
-import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem;
-import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-
-/**
- * @author Adrian Cole
- */
-@Singleton
-public class VAppTemplatesForCatalogItems implements
- Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> {
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- public Logger logger = Logger.NULL;
- private final TerremarkVCloudApi aclient;
-
- @Inject
- VAppTemplatesForCatalogItems(TerremarkVCloudApi aclient) {
- this.aclient = aclient;
- }
-
- @Override
- public Iterable<? extends VAppTemplate> apply(Iterable<? extends CatalogItem> from) {
- return transform(filter(from, new Predicate<CatalogItem>() {
- public boolean apply(CatalogItem input) {
- return input.getEntity().getType().equals(TerremarkVCloudMediaType.VAPPTEMPLATE_XML);
- }
- }), new Function<CatalogItem, VAppTemplate>() {
- public VAppTemplate apply(CatalogItem from) {
- return aclient.getVAppTemplate(from.getEntity().getHref());
- }
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VAppTemplatesForResourceEntities.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VAppTemplatesForResourceEntities.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VAppTemplatesForResourceEntities.java
deleted file mode 100644
index 6a5055c..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VAppTemplatesForResourceEntities.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.functions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.transform;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.logging.Logger;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-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.VAppTemplate;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-
-/**
- * @author Adrian Cole
- */
-@Singleton
-public class VAppTemplatesForResourceEntities implements
- Function<Iterable<? extends ReferenceType>, Iterable<? extends VAppTemplate>> {
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- public Logger logger = Logger.NULL;
- private final TerremarkVCloudApi aclient;
-
- @Inject
- VAppTemplatesForResourceEntities(TerremarkVCloudApi aclient) {
- this.aclient = aclient;
- }
-
- @Override
- public Iterable<? extends VAppTemplate> apply(Iterable<? extends ReferenceType> from) {
- return transform(filter(checkNotNull(from, "named resources"), new Predicate<ReferenceType>() {
- public boolean apply(ReferenceType input) {
- return input.getType().equals(TerremarkVCloudMediaType.VAPPTEMPLATE_XML);
- }
- }), new Function<ReferenceType, VAppTemplate>() {
- public VAppTemplate apply(ReferenceType from) {
- return aclient.getVAppTemplate(from.getHref());
- }
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToInternetServicesEndpoint.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToInternetServicesEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToInternetServicesEndpoint.java
deleted file mode 100644
index 53e9d7b..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToInternetServicesEndpoint.java
+++ /dev/null
@@ -1,56 +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.functions;
-
-import java.net.URI;
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.rest.ResourceNotFoundException;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.endpoints.VDC;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-
-/**
- *
- * @author Adrian Cole
- */
-@Singleton
-public class VDCURIToInternetServicesEndpoint implements Function<Object, URI> {
- private final Supplier<Map<URI, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> orgVDCMap;
- private final Supplier<ReferenceType> defaultVDC;
-
- @Inject
- public VDCURIToInternetServicesEndpoint(
- Supplier<Map<URI, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> orgVDCMap, @VDC Supplier<ReferenceType> defaultVDC) {
- this.orgVDCMap = orgVDCMap;
- this.defaultVDC = defaultVDC;
- }
-
- public URI apply(Object from) {
- try {
- return orgVDCMap.get().get(from == null ? defaultVDC.get().getHref() : from).getInternetServices().getHref();
- } catch (NullPointerException e) {
- throw new ResourceNotFoundException("vdc " + from + " not found in " + orgVDCMap.get());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToPublicIPsEndpoint.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToPublicIPsEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToPublicIPsEndpoint.java
deleted file mode 100644
index 4f5139b..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToPublicIPsEndpoint.java
+++ /dev/null
@@ -1,56 +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.functions;
-
-import java.net.URI;
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.rest.ResourceNotFoundException;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.endpoints.VDC;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-
-/**
- *
- * @author Adrian Cole
- */
-@Singleton
-public class VDCURIToPublicIPsEndpoint implements Function<Object, URI> {
- private final Supplier<Map<URI, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> orgVDCMap;
- private final Supplier<ReferenceType> defaultVDC;
-
- @Inject
- public VDCURIToPublicIPsEndpoint(Supplier<Map<URI, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> orgVDCMap,
- @VDC Supplier<ReferenceType> defaultVDC) {
- this.orgVDCMap = orgVDCMap;
- this.defaultVDC = defaultVDC;
- }
-
- public URI apply(Object from) {
- try {
- return orgVDCMap.get().get(from == null ? defaultVDC.get().getHref() : from).getPublicIps().getHref();
- } catch (NullPointerException e) {
- throw new ResourceNotFoundException("vdc " + from + " not found in " + orgVDCMap.get());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java
deleted file mode 100644
index 949da8e..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java
+++ /dev/null
@@ -1,109 +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.handlers;
-
-import static org.jclouds.http.HttpUtils.releasePayload;
-
-import java.io.IOException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.annotation.Resource;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpCommand;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.logging.Logger;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.rest.InsufficientResourcesException;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.jclouds.util.Strings2;
-
-/**
- * This will parse and set an appropriate exception on the command object.
- *
- * @author Adrian Cole
- *
- */
-@Singleton
-public class ParseTerremarkVCloudErrorFromHttpResponse implements HttpErrorHandler {
- @Resource
- protected Logger logger = Logger.NULL;
- public static final Pattern RESOURCE_PATTERN = Pattern.compile(".*/v[^/]+/([^/]+)/([0-9]+)");
-
- public void handleError(HttpCommand command, HttpResponse response) {
- Exception exception = new HttpResponseException(command, response);
-
- try {
- String content = parseErrorFromContentOrNull(command, response);
- if (content != null)
- exception = new HttpResponseException(command, response, content);
- if (response.getMessage() != null
- && ((response.getMessage().indexOf("because there is a pending task running") != -1)
- || (response.getMessage().indexOf("because it is already powered off") != -1)
- || (response.getMessage().indexOf("exists") != -1)))
- exception = new IllegalStateException(response.getMessage(), exception);
- else if (response.getMessage() != null
- && ((response.getMessage().indexOf("There are no additional Public IPs available") != -1)))
- exception = new InsufficientResourcesException(response.getMessage(), exception);
- else
- switch (response.getStatusCode()) {
- case 400:
- exception = new IllegalArgumentException(response.getMessage(), exception);
- break;
- case 401:
- exception = new AuthorizationException(exception.getMessage(), exception);
- break;
- case 403: // TODO temporary as terremark mistakenly uses this for vApp
- // not found.
- case 404:
- String path = command.getCurrentRequest().getEndpoint().getPath();
- Matcher matcher = RESOURCE_PATTERN.matcher(path);
- String message;
- if (matcher.find()) {
- message = String.format("%s %s not found", matcher.group(1), matcher.group(2));
- } else {
- message = path;
- }
- exception = new ResourceNotFoundException(message, exception);
- break;
- case 405:
- exception = new UnsupportedOperationException(response.getMessage(), exception);
- break;
- case 501:
- if (response.getMessage() != null && (response.getMessage().indexOf("NotImplemented") != -1))
- exception = new UnsupportedOperationException(response.getMessage(), exception);
- }
- } finally {
- releasePayload(response);
- command.setException(exception);
- }
- }
-
- String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) {
- if (response.getPayload() != null) {
- try {
- return Strings2.toString(response.getPayload());
- } catch (IOException e) {
- logger.warn(e, "exception reading error from response", response);
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java
deleted file mode 100644
index 3c2464b..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.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.trmk.vcloud_0_8.internal;
-
-import static java.util.concurrent.TimeUnit.MINUTES;
-import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
-import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME;
-import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
-import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION;
-import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
-import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
-import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA;
-import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
-import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
-
-import java.util.Properties;
-
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.rest.internal.BaseHttpApiMetadata;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-
-/**
- * Implementation of {@link ApiMetadata} for Terremark's VCloud api.
-
- * @author Adrian Cole
- */
-public abstract class TerremarkVCloudApiMetadata extends BaseHttpApiMetadata<TerremarkVCloudApi> {
-
- protected TerremarkVCloudApiMetadata(Builder<?> builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- Properties properties = BaseHttpApiMetadata.defaultProperties();
- properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8");
- properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + "");
- properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd");
- properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, "allowInOut");
- properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NS, String.format("urn:tmrk:${%s}-${%s}",
- PROPERTY_TERREMARK_EXTENSION_NAME, PROPERTY_TERREMARK_EXTENSION_VERSION));
- properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE,
- String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA));
- properties.setProperty("jclouds.dns_name_length_min", "1");
- properties.setProperty("jclouds.dns_name_length_max", "15");
- // terremark can sometimes block extremely long times
- properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, MINUTES.toMillis(20) + "");
- return properties;
- }
-
- public abstract static class Builder<B extends Builder<B>> extends BaseHttpApiMetadata.Builder<TerremarkVCloudApi, B> {
-
- protected Builder() {
- identityName("Email")
- .credentialName("Password")
- .version("0.8")
- .defaultProperties(TerremarkVCloudApiMetadata.defaultProperties())
- .view(ComputeServiceContext.class);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginApi.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginApi.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginApi.java
deleted file mode 100644
index e862727..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginApi.java
+++ /dev/null
@@ -1,40 +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.internal;
-
-import java.io.Closeable;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.Endpoint;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType;
-import org.jclouds.trmk.vcloud_0_8.domain.VCloudSession;
-import org.jclouds.trmk.vcloud_0_8.functions.ParseLoginResponseFromHeaders;
-
-@Endpoint(org.jclouds.trmk.vcloud_0_8.endpoints.VCloudLogin.class)
-@RequestFilters(BasicAuthentication.class)
-public interface TerremarkVCloudLoginApi extends Closeable {
-
- @POST
- @ResponseParser(ParseLoginResponseFromHeaders.class)
- @Consumes(TerremarkVCloudMediaType.ORGLIST_XML)
- VCloudSession login();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsApi.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsApi.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsApi.java
deleted file mode 100644
index 979d948..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsApi.java
+++ /dev/null
@@ -1,35 +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.internal;
-
-import java.io.Closeable;
-import java.net.URI;
-import java.util.SortedMap;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-
-import org.jclouds.rest.annotations.XMLResponseParser;
-import org.jclouds.trmk.vcloud_0_8.xml.SupportedVersionsHandler;
-
-public interface TerremarkVCloudVersionsApi extends Closeable {
-
- @GET
- @XMLResponseParser(SupportedVersionsHandler.class)
- @Path("/versions")
- SortedMap<String, URI> getSupportedVersions();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/DefaultVDC.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/DefaultVDC.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/DefaultVDC.java
deleted file mode 100644
index cf2577f..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/DefaultVDC.java
+++ /dev/null
@@ -1,73 +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.location;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.find;
-
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.collect.Memoized;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationScope;
-import org.jclouds.location.suppliers.ImplicitLocationSupplier;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-import org.jclouds.trmk.vcloud_0_8.endpoints.VDC;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-
-@Singleton
-public class DefaultVDC implements ImplicitLocationSupplier {
- @Singleton
- public static final class IsDefaultVDC implements Predicate<Location> {
- private final Supplier<ReferenceType> defaultVDC;
-
- @Inject
- IsDefaultVDC(@VDC Supplier<ReferenceType> defaultVDC) {
- this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC");
- }
-
- @Override
- public boolean apply(Location input) {
- return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.get().getHref().toASCIIString());
- }
-
- @Override
- public String toString() {
- return "isDefaultVDC()";
- }
- }
-
- private final Supplier<Set<? extends Location>> locationsSupplier;
- private final DefaultVDC.IsDefaultVDC isDefaultVDC;
-
- @Inject
- DefaultVDC(@Memoized Supplier<Set<? extends Location>> locationsSupplier, DefaultVDC.IsDefaultVDC isDefaultVDC) {
- this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier");
- this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC");
- }
-
- @Override
- public Location get() {
- return find(locationsSupplier.get(), isDefaultVDC);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/OrgAndVDCToLocationSupplier.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/OrgAndVDCToLocationSupplier.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/OrgAndVDCToLocationSupplier.java
deleted file mode 100644
index bdf918c..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/OrgAndVDCToLocationSupplier.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.trmk.vcloud_0_8.location;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.jclouds.location.Iso3166;
-import org.jclouds.location.Provider;
-import org.jclouds.location.suppliers.LocationsSupplier;
-import org.jclouds.location.suppliers.all.JustProvider;
-import org.jclouds.trmk.vcloud_0_8.domain.Org;
-import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
-
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-import com.google.common.collect.Iterables;
-
-/**
- * @author Adrian Cole
- */
-@Singleton
-public class OrgAndVDCToLocationSupplier extends JustProvider implements LocationsSupplier {
-
- private final Supplier<Map<String, ReferenceType>> orgNameToResource;
- private final Supplier<Map<String, ? extends Org>> orgNameToVDCResource;
- private final Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier;
-
- @Inject
- OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider Supplier<URI> endpoint,
- @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<Map<String, ReferenceType>> orgNameToResource,
- Supplier<Map<String, ? extends Org>> orgNameToVDCResource,
- @Iso3166 Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier) {
- super(providerName, endpoint, isoCodes);
- this.orgNameToResource = checkNotNull(orgNameToResource, "orgNameToResource");
- this.orgNameToVDCResource = checkNotNull(orgNameToVDCResource, "orgNameToVDCResource");
- this.isoCodesByIdSupplier = checkNotNull(isoCodesByIdSupplier, "isoCodesByIdSupplier");
- }
-
- @Override
- public Set<? extends Location> get() {
- return buildJustProviderOrVDCs().build();
- }
-
- protected Builder<Location> buildJustProviderOrVDCs() {
- Builder<Location> locations = ImmutableSet.builder();
- Location provider = Iterables.getOnlyElement(super.get());
- if (orgNameToResource.get().size() == 0)
- return locations.add(provider);
- Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get();
- for (ReferenceType org : orgNameToResource.get().values()) {
- LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(org.getHref().toASCIIString())
- .description(org.getName()).parent(provider);
- if (isoCodesById.containsKey(org.getHref().toASCIIString()))
- builder.iso3166Codes(isoCodesById.get(org.getHref().toASCIIString()).get());
- Location orgL = builder.build();
- for (ReferenceType vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) {
- builder = new LocationBuilder().scope(LocationScope.ZONE).id(vdc.getHref().toASCIIString()).description(
- vdc.getName()).parent(orgL);
- if (isoCodesById.containsKey(vdc.getHref().toASCIIString()))
- builder.iso3166Codes(isoCodesById.get(vdc.getHref().toASCIIString()).get());
- locations.add(builder.build());
- }
- }
- return locations;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddInternetServiceOptions.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddInternetServiceOptions.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddInternetServiceOptions.java
deleted file mode 100644
index 3055259..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddInternetServiceOptions.java
+++ /dev/null
@@ -1,94 +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.options;
-
-import java.util.Map;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.trmk.vcloud_0_8.binders.BindAddInternetServiceToXmlPayload;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableMap;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-public class AddInternetServiceOptions extends BindAddInternetServiceToXmlPayload {
-
- @VisibleForTesting
- String description = null;
- @VisibleForTesting
- String enabled = "true";
- @VisibleForTesting
- Boolean monitorEnabled = null;
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- ImmutableMap.Builder<String, Object> copy = ImmutableMap.builder();
- copy.putAll(postParams);
- if (description != null)
- copy.put("description", description);
- copy.put("enabled", enabled);
- if (monitorEnabled != null)
- copy.put("monitor", monitorEnabled.toString());
- return super.bindToRequest(request, copy.build());
- }
-
- public AddInternetServiceOptions disabled() {
- this.enabled = "false";
- return this;
- }
-
- public AddInternetServiceOptions monitorDisabled() {
- this.monitorEnabled = false;
- return this;
- }
-
- public AddInternetServiceOptions withDescription(String description) {
- this.description = description;
- return this;
- }
-
- public static class Builder {
-
- /**
- * @see AddInternetServiceOptions#withDescription(String)
- */
- public static AddInternetServiceOptions withDescription(String description) {
- AddInternetServiceOptions options = new AddInternetServiceOptions();
- return options.withDescription(description);
- }
-
- /**
- * @see AddInternetServiceOptions#monitorDisabled()
- */
- public static AddInternetServiceOptions monitorDisabled() {
- AddInternetServiceOptions options = new AddInternetServiceOptions();
- return options.monitorDisabled();
- }
-
- /**
- * @see AddInternetServiceOptions#disabled()
- */
- public static AddInternetServiceOptions disabled() {
- AddInternetServiceOptions options = new AddInternetServiceOptions();
- return options.disabled();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddNodeOptions.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddNodeOptions.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddNodeOptions.java
deleted file mode 100644
index 2ac18da..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddNodeOptions.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.trmk.vcloud_0_8.options;
-
-import java.util.Map;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.trmk.vcloud_0_8.binders.BindAddNodeServiceToXmlPayload;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Maps;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-public class AddNodeOptions extends BindAddNodeServiceToXmlPayload {
-
- @VisibleForTesting
- String description = null;
- @VisibleForTesting
- String enabled = "true";
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- Map<String, Object> copy = Maps.newHashMap();
- copy.putAll(postParams);
- copy.put("description", description);
- copy.put("enabled", enabled);
- return super.bindToRequest(request, copy);
- }
-
- public AddNodeOptions disabled() {
- this.enabled = "false";
- return this;
- }
-
- public AddNodeOptions withDescription(String description) {
- this.description = description;
- return this;
- }
-
- public static class Builder {
-
- /**
- * @see AddNodeOptions#withDescription(String)
- */
- public static AddNodeOptions withDescription(String description) {
- AddNodeOptions options = new AddNodeOptions();
- return options.withDescription(description);
- }
-
- /**
- * @see AddNodeOptions#disabled()
- */
- public static AddNodeOptions disabled() {
- AddNodeOptions options = new AddNodeOptions();
- return options.disabled();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/CloneVAppOptions.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/CloneVAppOptions.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/CloneVAppOptions.java
deleted file mode 100644
index 3516d1f..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/CloneVAppOptions.java
+++ /dev/null
@@ -1,98 +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.options;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-public class CloneVAppOptions {
-
- private boolean deploy;
- private boolean powerOn;
- private String description;
-
- /**
- * the clone should be deployed after it is created
- */
- public CloneVAppOptions deploy() {
- this.deploy = true;
- return this;
- }
-
- /**
- * the clone should be powered on after it is deployed
- */
- public CloneVAppOptions powerOn() {
- checkState(deploy, "must set deploy before setting powerOn");
- powerOn = true;
- return this;
- }
-
- /**
- * the clone should be powered on after it is deployed
- */
- public CloneVAppOptions withDescription(String description) {
- checkNotNull(description, "description");
- this.description = description;
- return this;
- }
-
- public boolean isDeploy() {
- return deploy;
- }
-
- public boolean isPowerOn() {
- return powerOn;
- }
-
- public String getDescription() {
- return description;
- }
-
- public static class Builder {
-
- /**
- * @see CloneVAppOptions#deploy()
- */
- public static CloneVAppOptions deploy() {
- CloneVAppOptions options = new CloneVAppOptions();
- return options.deploy();
- }
-
- /**
- * @see CloneVAppOptions#powerOn()
- */
- public static CloneVAppOptions powerOn() {
- CloneVAppOptions options = new CloneVAppOptions();
- return options.powerOn();
- }
-
- /**
- * @see CloneVAppOptions#withDescription(String)
- */
- public static CloneVAppOptions withDescription(String description) {
- CloneVAppOptions options = new CloneVAppOptions();
- return options.withDescription(description);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/InstantiateVAppTemplateOptions.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/InstantiateVAppTemplateOptions.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/InstantiateVAppTemplateOptions.java
deleted file mode 100644
index 2d250bc..0000000
--- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/InstantiateVAppTemplateOptions.java
+++ /dev/null
@@ -1,477 +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.options;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.Set;
-
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.trmk.vcloud_0_8.domain.FenceMode;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-public class InstantiateVAppTemplateOptions {
- public static class NetworkConfig {
- @Nullable
- private final String networkName;
- private final URI parentNetwork;
- @Nullable
- private final FenceMode fenceMode;
-
- /**
- *
- * Create a new NetworkConfig.
- *
- * @param networkName
- * a valid {@networkConfig
- * org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection
- * network in the vapp template}, or null to have us choose
- * default
- * @param parentNetwork
- * a valid {@networkConfig
- * org.jclouds.vcloud.domain.Org#getNetworks in the Org}
- * @param fenceMode
- * how to manage the relationship between the two networks
- */
- public NetworkConfig(String networkName, URI parentNetwork, FenceMode fenceMode) {
- this.networkName = networkName;
- this.parentNetwork = checkNotNull(parentNetwork, "parentNetwork");
- this.fenceMode = fenceMode;
- }
-
- public NetworkConfig(URI parentNetwork) {
- this(null, parentNetwork, null);
- }
-
- /**
- * A name for the network. If the
- * {@link org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection}
- * includes a {@link NetworkSection.Network} network element, the name you
- * specify for the vApp network must match the name specified in that
- * element's name attribute.
- *
- * @return
- */
- public String getNetworkName() {
- return networkName;
- }
-
- /**
- *
- * @return A reference to the organization network to which this network
- * connects.
- */
- public URI getParentNetwork() {
- return parentNetwork;
- }
-
- /**
- * A value of bridged indicates that this vApp network is connected
- * directly to the organization network.
- */
- public FenceMode getFenceMode() {
- return fenceMode;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fenceMode == null) ? 0 : fenceMode.hashCode());
- result = prime * result + ((parentNetwork == null) ? 0 : parentNetwork.hashCode());
- result = prime * result + ((networkName == null) ? 0 : networkName.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- NetworkConfig other = (NetworkConfig) obj;
- if (fenceMode == null) {
- if (other.fenceMode != null)
- return false;
- } else if (!fenceMode.equals(other.fenceMode))
- return false;
- if (parentNetwork == null) {
- if (other.parentNetwork != null)
- return false;
- } else if (!parentNetwork.equals(other.parentNetwork))
- return false;
- if (networkName == null) {
- if (other.networkName != null)
- return false;
- } else if (!networkName.equals(other.networkName))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "[networkName=" + networkName + ", parentNetwork=" + parentNetwork + ", fenceMode=" + fenceMode + "]";
- }
- }
-
- private Set<NetworkConfig> networkConfig = Sets.newLinkedHashSet();
-
- private Boolean customizeOnInstantiate;
- private String cpuCount;
- private String memorySizeMegabytes;
-
- private boolean block = true;
- private boolean deploy = true;
- private boolean powerOn = true;
-
- private final Map<String, String> properties = Maps.newLinkedHashMap();
-
- public InstantiateVAppTemplateOptions sshKeyFingerprint(String sshKeyFingerprint) {
- productProperty("sshKeyFingerprint", sshKeyFingerprint);
- return this;
- }
-
- public InstantiateVAppTemplateOptions primaryDNS(String primaryDNS) {
- productProperty("primaryDNS", primaryDNS);
- return this;
- }
-
- public InstantiateVAppTemplateOptions secondaryDNS(String secondaryDNS) {
- productProperty("secondaryDNS", secondaryDNS);
- return this;
- }
-
- public InstantiateVAppTemplateOptions withPassword(String password) {
- productProperty("password", password);
- return this;
- }
-
- public InstantiateVAppTemplateOptions inGroup(String group) {
- productProperty("group", group);
- return this;
- }
-
- public InstantiateVAppTemplateOptions inRow(String row) {
- productProperty("row", row);
- return this;
- }
-
- public InstantiateVAppTemplateOptions productProperties(Map<String, String> properties) {
- this.properties.putAll(properties);
- return this;
- }
-
- public InstantiateVAppTemplateOptions productProperty(String key, String value) {
- this.properties.put(key, value);
- return this;
- }
-
- public Map<String, String> getProperties() {
- return properties;
- }
-
- public boolean shouldBlock() {
- return block;
- }
-
- public boolean shouldDeploy() {
- return deploy;
- }
-
- public boolean shouldPowerOn() {
- return powerOn;
- }
-
- /**
- * deploy the vapp after it is instantiated?
- */
- public InstantiateVAppTemplateOptions deploy(boolean deploy) {
- this.deploy = deploy;
- return this;
- }
-
- /**
- * powerOn the vapp after it is instantiated?
- */
- public InstantiateVAppTemplateOptions powerOn(boolean powerOn) {
- this.powerOn = powerOn;
- return this;
- }
-
- /**
- * block until instantiate or deployment operations complete?
- */
- public InstantiateVAppTemplateOptions block(boolean block) {
- this.block = block;
- return this;
- }
-
- /**
- * If true, then customization is executed for all children that include a
- * GuestCustomizationSection.
- */
- public InstantiateVAppTemplateOptions customizeOnInstantiate(boolean customizeOnInstantiate) {
- this.customizeOnInstantiate = customizeOnInstantiate;
- return this;
- }
-
- public InstantiateVAppTemplateOptions processorCount(int cpuCount) {
- checkArgument(cpuCount >= 1, "cpuCount must be positive");
- this.cpuCount = cpuCount + "";
- return this;
- }
-
- public InstantiateVAppTemplateOptions memory(long megabytes) {
- checkArgument(megabytes >= 1, "megabytes must be positive");
- this.memorySizeMegabytes = megabytes + "";
- return this;
- }
-
- /**
- * {@networkConfig VAppTemplate}s have internal networks that can be
- * connected in order to access the internet or other external networks.
- *
- * <h4>default behaviour if you don't use this option</h4> By default, we
- * connect the first internal {@networkConfig
- * org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection network in the
- * vapp template}to a default chosen from the org or specified via
- * {@networkConfig
- * org.jclouds.vcloud.reference.VCloudConstants#
- * PROPERTY_VCLOUD_DEFAULT_NETWORK} using the {@networkConfig
- * org.jclouds.vcloud.domain.FenceMode#BRIDGED} or an
- * override set by the property {@networkConfig
- * org.jclouds.vcloud.reference.VCloudConstants#
- * PROPERTY_VCLOUD_DEFAULT_FENCEMODE}.
- */
- public InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
- this.networkConfig.add(checkNotNull(networkConfig, "networkConfig"));
- return this;
- }
-
- public Set<NetworkConfig> getNetworkConfig() {
- return networkConfig;
- }
-
- public String getCpuCount() {
- return cpuCount;
- }
-
- public Boolean shouldCustomizeOnInstantiate() {
- return customizeOnInstantiate;
- }
-
- public String getMemorySizeMegabytes() {
- return memorySizeMegabytes;
- }
-
- public static class Builder {
-
- /**
- * @see InstantiateVAppTemplateOptions#block
- */
- public static InstantiateVAppTemplateOptions block(boolean block) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.block(block);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#deploy
- */
- public static InstantiateVAppTemplateOptions deploy(boolean deploy) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.deploy(deploy);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#powerOn
- */
- public static InstantiateVAppTemplateOptions powerOn(boolean powerOn) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.powerOn(powerOn);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#processorCount(int)
- */
- public static InstantiateVAppTemplateOptions processorCount(int cpuCount) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.processorCount(cpuCount);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#customizeOnInstantiate
- */
- public static InstantiateVAppTemplateOptions customizeOnInstantiate(Boolean customizeOnInstantiate) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.customizeOnInstantiate(customizeOnInstantiate);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#memory(int)
- */
- public static InstantiateVAppTemplateOptions memory(int megabytes) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.memory(megabytes);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#addNetworkConfig
- */
- public static InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.addNetworkConfig(networkConfig);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#withPassword(String)
- */
- public static InstantiateVAppTemplateOptions withPassword(String password) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.withPassword(password);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#inGroup(String)
- */
- public static InstantiateVAppTemplateOptions inGroup(String group) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.inGroup(group);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#inRow(String)
- */
- public static InstantiateVAppTemplateOptions inRow(String row) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.inRow(row);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#sshKeyFingerprint(String)
- */
- public static InstantiateVAppTemplateOptions sshKeyFingerprint(String sshKeyFingerprint) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.sshKeyFingerprint(sshKeyFingerprint);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#primaryDNS(String)
- */
- public static InstantiateVAppTemplateOptions primaryDNS(String primaryDNS) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.primaryDNS(primaryDNS);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#secondaryDNS(String)
- */
- public static InstantiateVAppTemplateOptions secondaryDNS(String secondaryDNS) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.secondaryDNS(secondaryDNS);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#productProperty(String, String)
- */
- public static InstantiateVAppTemplateOptions productProperty(String key, String value) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.productProperty(key, value);
- }
-
- /**
- * @see InstantiateVAppTemplateOptions#productProperties(Map<String ,
- * String>)
- */
- public static InstantiateVAppTemplateOptions productProperties(Map<String, String> properties) {
- InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
- return options.productProperties(properties);
- }
-
- }
-
- @Override
- public String toString() {
- return "[cpuCount=" + cpuCount + ", memorySizeMegabytes=" + memorySizeMegabytes + ", networkConfig="
- + networkConfig + ", customizeOnInstantiate=" + customizeOnInstantiate + ", deploy=" + deploy
- + ", powerOn=" + powerOn + "]";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (block ? 1231 : 1237);
- result = prime * result + ((cpuCount == null) ? 0 : cpuCount.hashCode());
- result = prime * result + ((customizeOnInstantiate == null) ? 0 : customizeOnInstantiate.hashCode());
- result = prime * result + (deploy ? 1231 : 1237);
- result = prime * result + ((memorySizeMegabytes == null) ? 0 : memorySizeMegabytes.hashCode());
- result = prime * result + ((networkConfig == null) ? 0 : networkConfig.hashCode());
- result = prime * result + (powerOn ? 1231 : 1237);
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- InstantiateVAppTemplateOptions other = (InstantiateVAppTemplateOptions) obj;
- if (block != other.block)
- return false;
- if (cpuCount == null) {
- if (other.cpuCount != null)
- return false;
- } else if (!cpuCount.equals(other.cpuCount))
- return false;
- if (customizeOnInstantiate == null) {
- if (other.customizeOnInstantiate != null)
- return false;
- } else if (!customizeOnInstantiate.equals(other.customizeOnInstantiate))
- return false;
- if (deploy != other.deploy)
- return false;
- if (memorySizeMegabytes == null) {
- if (other.memorySizeMegabytes != null)
- return false;
- } else if (!memorySizeMegabytes.equals(other.memorySizeMegabytes))
- return false;
- if (networkConfig == null) {
- if (other.networkConfig != null)
- return false;
- } else if (!networkConfig.equals(other.networkConfig))
- return false;
- if (powerOn != other.powerOn)
- return false;
- return true;
- }
-
-}