You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/11/29 17:41:07 UTC
[20/39] stratos git commit: Removing jclouds/cloudstack fork in
dependencies
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/UpdateVMGroupOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/UpdateVMGroupOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/UpdateVMGroupOptions.java
deleted file mode 100644
index 77097ac..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/UpdateVMGroupOptions.java
+++ /dev/null
@@ -1,52 +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.cloudstack.options;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Options used to control updates to VMGroups
- *
- * @see <a
- * href="http://download.cloud.com/releases/2.2.0/api/user/updateInstanceGroup.html"
- * />
- */
-public class UpdateVMGroupOptions extends BaseHttpRequestOptions {
-
- public static final UpdateVMGroupOptions NONE = new UpdateVMGroupOptions();
-
- /**
- * @param name new name of the VMGroup
- */
- public UpdateVMGroupOptions name(String name) {
- this.queryParameters.replaceValues("name", ImmutableSet.of(name));
- return this;
- }
-
- public static class Builder {
- /**
- * @see org.jclouds.cloudstack.options.UpdateVMGroupOptions#name
- */
- public static UpdateVMGroupOptions name(String name) {
- UpdateVMGroupOptions options = new UpdateVMGroupOptions();
- return options.name(name);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/UpdateZoneOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/UpdateZoneOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/UpdateZoneOptions.java
deleted file mode 100644
index ab22e96..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/UpdateZoneOptions.java
+++ /dev/null
@@ -1,258 +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.cloudstack.options;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.List;
-
-import org.jclouds.cloudstack.domain.AllocationState;
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Options used to control how a zone is updated
- *
- * @see <a href=
- * "http://download.cloud.com/releases/2.2.0/api_2.2.12/global_admin/updateZone.html"
- * />
- */
-public class UpdateZoneOptions extends BaseHttpRequestOptions {
-
- public static final UpdateZoneOptions NONE = new UpdateZoneOptions();
-
- /**
- * @param allocationState
- * allocation state of this Zone for allocation of new resources
- */
- public UpdateZoneOptions allocationState(AllocationState allocationState) {
- this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
- return this;
- }
-
- /**
- * @param details
- * the details for the Zone
- */
- public UpdateZoneOptions details(String details) {
- this.queryParameters.replaceValues("details", ImmutableSet.of(details));
- return this;
- }
-
- /**
- * @param dhcpProvider
- * the dhcp Provider for the Zone
- */
- public UpdateZoneOptions dhcpProvider(String dhcpProvider) {
- this.queryParameters.replaceValues("dhcpprovider", ImmutableSet.of(dhcpProvider));
- return this;
- }
-
- /**
- * @param externalDnsServers
- * the list of external DNS servers
- */
- public UpdateZoneOptions externalDns(List<String> externalDnsServers) {
- checkArgument(externalDnsServers.size() == 1 || externalDnsServers.size() == 2,
- "The list of DNS servers should have 1 or 2 elements");
- this.queryParameters.replaceValues("dns1",
- ImmutableSet.of(externalDnsServers.get(0)));
- if (externalDnsServers.size() == 2) {
- this.queryParameters.replaceValues("dns2",
- ImmutableSet.of(externalDnsServers.get(1)));
- }
- return this;
- }
-
- /**
- * @param internalDnsServers
- * the list of internal DNS for the Zone
- */
- public UpdateZoneOptions internalDns(List<String> internalDnsServers) {
- checkArgument(internalDnsServers.size() == 1 || internalDnsServers.size() == 2,
- "The list of internal DNS servers should have 1 or 2 elements");
- this.queryParameters.replaceValues("internaldns1",
- ImmutableSet.of(internalDnsServers.get(0)));
- if (internalDnsServers.size() == 2) {
- this.queryParameters.replaceValues("internaldns2",
- ImmutableSet.of(internalDnsServers.get(1)));
- }
- return this;
- }
-
- /**
- * @param dnsSearchOrder
- * the dns search order list
- */
- public UpdateZoneOptions dnsSearchOrder(String dnsSearchOrder) {
- this.queryParameters.replaceValues("dnssearchorder", ImmutableSet.of(dnsSearchOrder));
- return this;
- }
-
- /**
- * @param domainName
- * network domain name for the networks in zone
- */
- public UpdateZoneOptions domainName(String domainName) {
- this.queryParameters.replaceValues("domain", ImmutableSet.of(domainName));
- return this;
- }
-
- /**
- * @param guestCIDRAddress
- * the guest CIDR address for the Zone
- */
- public UpdateZoneOptions guestCIDRAddress(String guestCIDRAddress) {
- this.queryParameters.replaceValues("guestcidraddress", ImmutableSet.of(guestCIDRAddress));
- return this;
- }
-
- /**
- * @param securityGroupEnabled
- * true if network is security group enabled, false otherwise
- */
- public UpdateZoneOptions securityGroupEnabled(boolean securityGroupEnabled) {
- this.queryParameters.replaceValues("securitygroupenabled", ImmutableSet.of(securityGroupEnabled + ""));
- return this;
- }
-
- /**
- * You can only make a private Zone public, not the other way around
- */
- public UpdateZoneOptions makePublic() {
- this.queryParameters.replaceValues("ispublic", ImmutableSet.of("true"));
- return this;
- }
-
- /**
- * @param name
- * the name of the Zone
- */
- public UpdateZoneOptions name(String name) {
- this.queryParameters.replaceValues("name", ImmutableSet.of(name));
- return this;
- }
-
- /**
- * @param vlan
- * the VLAN for the Zone
- */
- public UpdateZoneOptions vlan(String vlan) {
- this.queryParameters.replaceValues("vlan", ImmutableSet.of(vlan));
- return this;
- }
-
- public static class Builder {
-
- /**
- * @see UpdateZoneOptions#allocationState
- */
- public static UpdateZoneOptions allocationState(AllocationState allocationState) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.allocationState(allocationState);
- }
-
- /**
- * @see UpdateZoneOptions#details
- */
- public static UpdateZoneOptions details(String details) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.details(details);
- }
-
- /**
- * @see UpdateZoneOptions#dhcpProvider
- */
- public static UpdateZoneOptions dhcpProvider(String dhcpProvider) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.dhcpProvider(dhcpProvider);
- }
-
- /**
- * @see UpdateZoneOptions#externalDns
- */
- public static UpdateZoneOptions externalDns(List<String> externalDnsServers) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.externalDns(externalDnsServers);
- }
-
- /**
- * @see UpdateZoneOptions#internalDns
- */
- public static UpdateZoneOptions internalDns(List<String> internalDnsServers) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.internalDns(internalDnsServers);
- }
-
- /**
- * @see UpdateZoneOptions#dnsSearchOrder
- */
- public static UpdateZoneOptions dnsSearchOrder(String dnsSearchOrder) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.dnsSearchOrder(dnsSearchOrder);
- }
-
- /**
- * @see UpdateZoneOptions#domainName
- */
- public static UpdateZoneOptions domainName(String domainName) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.domainName(domainName);
- }
-
- /**
- * @see UpdateZoneOptions#guestCIDRAddress
- */
- public static UpdateZoneOptions guestCIDRAddress(String guestCIDRAddress) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.guestCIDRAddress(guestCIDRAddress);
- }
-
- /**
- * @see UpdateZoneOptions#securityGroupEnabled
- */
- public static UpdateZoneOptions securityGroupEnabled(boolean securityGroupEnabled) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.securityGroupEnabled(securityGroupEnabled);
- }
-
- /**
- * @see UpdateZoneOptions#makePublic
- */
- public static UpdateZoneOptions makePublic() {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.makePublic();
- }
-
- /**
- * @see UpdateZoneOptions#name
- */
- public static UpdateZoneOptions name(String name) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.name(name);
- }
-
- /**
- * @see UpdateZoneOptions#vlan
- */
- public static UpdateZoneOptions vlan(String vlan) {
- UpdateZoneOptions options = new UpdateZoneOptions();
- return options.vlan(vlan);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/CorrectHypervisorForZone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/CorrectHypervisorForZone.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/CorrectHypervisorForZone.java
deleted file mode 100644
index e518763..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/CorrectHypervisorForZone.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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.Template;
-import org.jclouds.cloudstack.domain.Zone;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-
-/**
- * Templates can be present in a zone, and available, but not valid for launch
- * as their hypervisor isn't installed.
- */
-@Singleton
-public class CorrectHypervisorForZone implements Function<String, Predicate<Template>> {
- private final Supplier<Map<String, Set<String>>> hypervisorsSupplier;
-
- @Inject
- public CorrectHypervisorForZone(CloudStackApi client) {
- this(Suppliers.ofInstance(new CloudStackApiToZoneToHypervisors().apply(checkNotNull(client, "client"))));
- }
-
- public CorrectHypervisorForZone(Supplier<Map<String, Set<String>>> hypervisorsSupplier) {
- this.hypervisorsSupplier = checkNotNull(hypervisorsSupplier, "hypervisorsSupplier");
- }
-
- private static class CloudStackApiToZoneToHypervisors implements
- Function<CloudStackApi, Map<String, Set<String>>> {
-
- @Override
- public Map<String, Set<String>> apply(CloudStackApi client) {
- checkNotNull(client, "client");
- Builder<String, Set<String>> builder = ImmutableMap.builder();
- for (Zone zone : client.getZoneApi().listZones()) {
- builder.put(zone.getId(), client.getHypervisorApi().listHypervisorsInZone(zone.getId()));
- }
- return builder.build();
- }
- }
-
- @Override
- public Predicate<Template> apply(final String zoneId) {
-
- final Set<String> acceptableHypervisorsInZone;
- try {
- acceptableHypervisorsInZone = this.hypervisorsSupplier.get().get(zoneId);
- } catch (NullPointerException e) {
- throw new IllegalArgumentException("unknown zone: " + zoneId);
- }
- if (acceptableHypervisorsInZone.isEmpty())
- return Predicates.alwaysFalse();
- return new Predicate<Template>() {
-
- @Override
- public boolean apply(Template input) {
- return Predicates.in(acceptableHypervisorsInZone).apply(input.getHypervisor());
- }
-
- @Override
- public String toString() {
- return "hypervisorsInZone(" + zoneId + ", " + acceptableHypervisorsInZone + ")";
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/JobComplete.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/JobComplete.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/JobComplete.java
deleted file mode 100644
index 3e45521..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/JobComplete.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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.annotation.Resource;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudstack.AsyncJobException;
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.AsyncJob;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.inject.Inject;
-
-/**
- *
- * Tests to see if a job is in progress.
- */
-@Singleton
-public class JobComplete implements Predicate<String> {
-
- private final CloudStackApi client;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public JobComplete(CloudStackApi client) {
- this.client = client;
- }
-
- public boolean apply(String jobId) {
- logger.trace(">> looking for status on job %s", checkNotNull(jobId, "jobId"));
- AsyncJob<?> job = refresh(jobId);
- if (job == null) {
- return false;
- }
- logger.trace("%s: looking for job status %s: currently: %s", job.getId(), 1, job.getStatus());
- if (job.hasFailed()) {
-
- throw new AsyncJobException(String.format("job %s failed with exception %s",
- job.toString(), job.getError().toString()));
- }
- return job.hasSucceed();
- }
-
- private AsyncJob<?> refresh(String jobId) {
- return client.getAsyncJobApi().getAsyncJob(jobId);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/LoadBalancerRuleActive.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/LoadBalancerRuleActive.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/LoadBalancerRuleActive.java
deleted file mode 100644
index 7d7abc9..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/LoadBalancerRuleActive.java
+++ /dev/null
@@ -1,61 +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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.LoadBalancerRule;
-import org.jclouds.cloudstack.domain.LoadBalancerRule.State;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-
-/**
- *
- * Tests to see if a LoadBalancerRule is active
- */
-@Singleton
-public class LoadBalancerRuleActive implements Predicate<LoadBalancerRule> {
-
- private final CloudStackApi client;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public LoadBalancerRuleActive(CloudStackApi client) {
- this.client = client;
- }
-
- public boolean apply(LoadBalancerRule rule) {
- logger.trace("looking for state on rule %s", checkNotNull(rule, "rule"));
- rule = refresh(rule);
- if (rule == null)
- return false;
- logger.trace("%s: looking for rule state %s: currently: %s", rule.getId(), State.ACTIVE, rule.getState());
- return rule.getState() == State.ACTIVE;
- }
-
- private LoadBalancerRule refresh(LoadBalancerRule rule) {
- return client.getLoadBalancerApi().getLoadBalancerRule(rule.getId());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/NetworkOfferingPredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/NetworkOfferingPredicates.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/NetworkOfferingPredicates.java
deleted file mode 100644
index 680afbd..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/NetworkOfferingPredicates.java
+++ /dev/null
@@ -1,55 +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.cloudstack.predicates;
-
-import static com.google.common.base.Predicates.alwaysTrue;
-
-import org.jclouds.cloudstack.domain.GuestIPType;
-import org.jclouds.cloudstack.domain.NetworkOffering;
-import org.jclouds.cloudstack.domain.TrafficType;
-
-import com.google.common.base.Predicate;
-
-public class NetworkOfferingPredicates {
-
- /**
- *
- * @return true, if the offering supports creation of GuestVirtual Networks
- */
- public static Predicate<NetworkOffering> supportsGuestVirtualNetworks() {
- return new Predicate<NetworkOffering>() {
-
- @Override
- public boolean apply(NetworkOffering arg0) {
- return arg0.getTrafficType() == TrafficType.GUEST && arg0.getGuestIPType() == GuestIPType.VIRTUAL;
- }
-
- @Override
- public String toString() {
- return "supportsGuestVirtualNetworks()";
- }
- };
- }
-
- /**
- *
- * @return always returns true.
- */
- public static Predicate<NetworkOffering> any() {
- return alwaysTrue();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/NetworkPredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/NetworkPredicates.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/NetworkPredicates.java
deleted file mode 100644
index 0b89bc4..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/NetworkPredicates.java
+++ /dev/null
@@ -1,265 +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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.cloudstack.domain.GuestIPType;
-import org.jclouds.cloudstack.domain.Network;
-import org.jclouds.cloudstack.domain.NetworkService;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-
-public class NetworkPredicates {
-
- public static enum HasFirewallServiceWhichSupportsStaticNAT implements Predicate<Network> {
- INSTANCE;
-
- @Override
- public boolean apply(Network arg0) {
- return Iterables.any(checkNotNull(arg0, "network").getServices(), supportsStaticNAT);
- }
-
- @Override
- public String toString() {
- return supportsStaticNAT.toString();
- }
- }
-
- public static enum HasFirewallServiceWhichSupportsPortForwarding implements Predicate<Network> {
- INSTANCE;
-
- @Override
- public boolean apply(Network arg0) {
- return Iterables.any(checkNotNull(arg0, "network").getServices(), supportsPortForwarding);
- }
-
- @Override
- public String toString() {
- return supportsPortForwarding.toString();
- }
- }
-
- public static enum HasLoadBalancerService implements Predicate<Network> {
- INSTANCE;
-
- @Override
- public boolean apply(Network arg0) {
- return Iterables.any(checkNotNull(arg0, "network").getServices(), isLoadBalancerService);
- }
-
- @Override
- public String toString() {
- return isLoadBalancerService.toString();
- }
- }
-
- public static enum IsVirtualNetwork implements Predicate<Network> {
- INSTANCE;
-
- @Override
- public boolean apply(Network arg0) {
- boolean network = isVirtualNetwork.apply(checkNotNull(arg0, "network").getGuestIPType());
- return network;
- }
-
- @Override
- public String toString() {
- return isVirtualNetwork.toString();
- }
- }
-
- public static enum IsSharedNetwork implements Predicate<Network> {
- INSTANCE;
-
- @Override
- public boolean apply(Network arg0) {
- boolean network = isSharedNetwork.apply(checkNotNull(arg0, "network").getGuestIPType());
- return network;
- }
-
- @Override
- public String toString() {
- return isSharedNetwork.toString();
- }
- }
-
- public static enum IsIsolatedNetwork implements Predicate<Network> {
- INSTANCE;
-
- @Override
- public boolean apply(Network arg0) {
- boolean network = isIsolatedNetwork.apply(checkNotNull(arg0, "network").getGuestIPType());
- return network;
- }
-
- @Override
- public String toString() {
- return isIsolatedNetwork.toString();
- }
- }
-
-
- private static class DefaultNetworkInZone implements Predicate<Network> {
- private final String zoneId;
-
- public DefaultNetworkInZone(String zoneId) {
- this.zoneId = zoneId;
- }
-
- @Override
- public boolean apply(Network network) {
- return network.getZoneId().equals(zoneId) && network.isDefault();
- }
- }
-
- public static class NetworkServiceNamed implements Predicate<NetworkService> {
- private final String name;
-
- public NetworkServiceNamed(String name) {
- this.name = checkNotNull(name, "name");
- }
-
- @Override
- public boolean apply(NetworkService input) {
- return name.equals(checkNotNull(input, "networkService").getName());
- }
-
- @Override
- public String toString() {
- return "networkServiceNamed(" + name + ")";
- }
- }
-
- public static class GuestIPTypeIs implements Predicate<GuestIPType> {
- private final GuestIPType guestIPType;
-
- public GuestIPTypeIs(GuestIPType guestIPType) {
- this.guestIPType = guestIPType;
- }
-
- @Override
- public boolean apply(GuestIPType guestIPType) {
- return guestIPType == this.guestIPType;
- }
-
- @Override
- public String toString() {
- return "guestIPTypeIs(" + guestIPType + ')';
- }
- }
-
- public static class CapabilitiesInclude implements Predicate<NetworkService> {
- private final String capability;
-
- public CapabilitiesInclude(String capability) {
- this.capability = checkNotNull(capability, "capability");
- }
-
- @Override
- public boolean apply(NetworkService input) {
- return "true".equals(input.getCapabilities().get(capability));
- }
-
- @Override
- public String toString() {
- return "capabilitiesInclude(" + capability + ")";
- }
- }
-
- public static final Predicate<NetworkService> supportsStaticNAT = Predicates.and(new NetworkServiceNamed("Firewall"),
- new CapabilitiesInclude("StaticNat"));
-
- public static final Predicate<NetworkService> supportsPortForwarding = Predicates.and(new NetworkServiceNamed("Firewall"),
- new CapabilitiesInclude("PortForwarding"));
-
- public static final Predicate<NetworkService> isLoadBalancerService = new NetworkServiceNamed("Lb");
-
- public static final Predicate<GuestIPType> isVirtualNetwork = new GuestIPTypeIs(GuestIPType.VIRTUAL);
-
- public static final Predicate<GuestIPType> isIsolatedNetwork = new GuestIPTypeIs(GuestIPType.ISOLATED);
-
- public static final Predicate<GuestIPType> isSharedNetwork = new GuestIPTypeIs(GuestIPType.SHARED);
-
- /**
- *
- * @return true, if the network supports static NAT.
- */
- public static Predicate<Network> supportsStaticNAT() {
- return HasFirewallServiceWhichSupportsStaticNAT.INSTANCE;
- }
-
- /**
- *
- * @return true, if the network supports port forwarding.
- */
- public static Predicate<Network> supportsPortForwarding() {
- return HasFirewallServiceWhichSupportsPortForwarding.INSTANCE;
- }
-
- /**
- *
- * @return true, if the network supports load balancing.
- */
- public static Predicate<Network> hasLoadBalancerService() {
- return HasLoadBalancerService.INSTANCE;
- }
-
- /**
- *
- * @return true, if the network is a virtual network.
- */
- public static Predicate<Network> isVirtualNetwork() {
- return IsVirtualNetwork.INSTANCE;
- }
-
- /**
- *
- * @return true, if the network is an isolated network.
- */
- public static Predicate<Network> isIsolatedNetwork() {
- return IsIsolatedNetwork.INSTANCE;
- }
-
- /**
- *
- * @return true, if the network is a shared network.
- */
- public static Predicate<Network> isSharedNetwork() {
- return IsSharedNetwork.INSTANCE;
- }
-
- /**
- * Filters for default networks in a specific zone.
- *
- * @param zoneId the ID of the required zone.
- * @return networks in the zone that have the default flag set.
- */
- public static Predicate<Network> defaultNetworkInZone(final String zoneId) {
- return new DefaultNetworkInZone(zoneId);
- }
-
- /**
- *
- * @return always returns true.
- */
- public static Predicate<Network> any() {
- return Predicates.alwaysTrue();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/OSCategoryIn.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/OSCategoryIn.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/OSCategoryIn.java
deleted file mode 100644
index 48397d8..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/OSCategoryIn.java
+++ /dev/null
@@ -1,86 +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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.OSType;
-import org.jclouds.cloudstack.domain.Template;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.common.collect.Maps;
-
-@Singleton
-public class OSCategoryIn implements Function<Set<String>, Predicate<Template>> {
- private final Supplier<Map<String, String>> categoriesSupplier;
- private final Supplier<Set<OSType>> osTypesSupplier;
-
- @Inject
- public OSCategoryIn(CloudStackApi client) {
- this(Suppliers.ofInstance(checkNotNull(client, "client").getGuestOSApi().listOSCategories()), Suppliers
- .ofInstance(client.getGuestOSApi().listOSTypes()));
- }
-
- public OSCategoryIn(Supplier<Map<String, String>> categoriesSupplier, Supplier<Set<OSType>> osTypesSupplier) {
- this.categoriesSupplier = checkNotNull(categoriesSupplier, "categoriesSupplier");
- this.osTypesSupplier = checkNotNull(osTypesSupplier, "osTypesSupplier");
- }
-
- @Override
- public Predicate<Template> apply(final Set<String> acceptableCategories) {
- final Map<String, String> categories = categoriesSupplier.get();
- final Set<String> acceptableOSTypeIds = Maps.filterValues(
- Maps.transformValues(Maps.uniqueIndex(osTypesSupplier.get(), new Function<OSType, String>() {
-
- @Override
- public String apply(OSType input) {
- return input.getId();
- }
-
- }), new Function<OSType, String>() {
-
- @Override
- public String apply(OSType input) {
- return categories.get(input.getOSCategoryId());
- }
-
- }), Predicates.in(acceptableCategories)).keySet();
- return new Predicate<Template>() {
-
- @Override
- public boolean apply(Template input) {
- return Predicates.in(acceptableOSTypeIds).apply(input.getOSTypeId());
- }
-
- @Override
- public String toString() {
- return "OSCategoryIn(" + acceptableCategories + ")";
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/PublicIPAddressPredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/PublicIPAddressPredicates.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/PublicIPAddressPredicates.java
deleted file mode 100644
index a58ba47..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/PublicIPAddressPredicates.java
+++ /dev/null
@@ -1,85 +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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.cloudstack.domain.PublicIPAddress;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-
-public class PublicIPAddressPredicates {
-
- public static final class AssociatedWithNetwork implements Predicate<PublicIPAddress> {
- private final String networkId;
-
- public AssociatedWithNetwork(String networkId) {
- this.networkId = checkNotNull(networkId, "networkId");
- }
-
- @Override
- public boolean apply(PublicIPAddress input) {
- return networkId.equals(checkNotNull(input, "ipaddress").getAssociatedNetworkId());
- }
-
- @Override
- public String toString() {
- return "associatedWithNetwork(" + networkId + ")";
- }
- }
-
- public static enum Available implements Predicate<PublicIPAddress> {
- INSTANCE;
-
- @Override
- public boolean apply(PublicIPAddress arg0) {
- return !checkNotNull(arg0, "ipaddress").isSourceNAT() && !arg0.isStaticNAT()
- && arg0.getVirtualMachineId() == null && arg0.getState() == PublicIPAddress.State.ALLOCATED;
- }
-
- @Override
- public String toString() {
- return "available()";
- }
- }
-
- /**
- *
- * @return true, if the public ip address is not assigned to a VM or NAT rule
- */
- public static Predicate<PublicIPAddress> available() {
- return Available.INSTANCE;
- }
-
- /**
- *
- * @return true, if the public ip address is associated with the specified
- * network
- */
- public static Predicate<PublicIPAddress> associatedWithNetwork(final String networkId) {
- return new AssociatedWithNetwork(networkId);
- }
-
- /**
- *
- * @return always returns true.
- */
- public static Predicate<PublicIPAddress> any() {
- return Predicates.alwaysTrue();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/SecurityGroupPredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/SecurityGroupPredicates.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/SecurityGroupPredicates.java
deleted file mode 100644
index 4796d01..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/SecurityGroupPredicates.java
+++ /dev/null
@@ -1,236 +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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Predicates.alwaysTrue;
-
-import java.util.Set;
-
-import org.jclouds.cloudstack.domain.IngressRule;
-import org.jclouds.cloudstack.domain.SecurityGroup;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Multimap;
-
-public class SecurityGroupPredicates {
- /**
- *
- * @return true, if the security group contains an ingress rule with the given port in the port range
- */
- public static Predicate<SecurityGroup> portInRange(final int port) {
- return new Predicate<SecurityGroup>() {
-
- @Override
- public boolean apply(SecurityGroup group) {
- return Iterables.any(group.getIngressRules(), new Predicate<IngressRule>() {
- @Override
- public boolean apply(IngressRule rule) {
- return rule.getStartPort() <= port && rule.getEndPort() >= port;
- }
- });
- }
-
- @Override
- public String toString() {
- return "portInRange(" + port + ")";
- }
- };
- }
-
- /**
- *
- * @return true, if the security group contains an ingress rule with the given cidr
- */
- public static Predicate<SecurityGroup> hasCidr(final String cidr) {
- return new Predicate<SecurityGroup>() {
-
- @Override
- public boolean apply(SecurityGroup group) {
- return Iterables.any(group.getIngressRules(), new Predicate<IngressRule>() {
- @Override
- public boolean apply(IngressRule rule) {
- return rule.getCIDR() != null
- && rule.getCIDR().equals(cidr);
- }
- });
- }
-
- @Override
- public String toString() {
- return "hasCidr(" + cidr + ")";
- }
- };
- }
-
- /**
- *
- * @return true, if the security group contains an ingress rule with the given cidr and the given port in range
- */
- public static Predicate<SecurityGroup> portInRangeForCidr(final int port, final String cidr) {
- return new Predicate<SecurityGroup>() {
-
- @Override
- public boolean apply(SecurityGroup group) {
- return Iterables.any(group.getIngressRules(), new Predicate<IngressRule>() {
- @Override
- public boolean apply(IngressRule rule) {
- return rule.getCIDR() != null
- && rule.getCIDR().equals(cidr)
- && rule.getStartPort() <= port
- && rule.getEndPort() >= port;
- }
- });
- }
-
- @Override
- public String toString() {
- return "portInRangeForCidr(" + port + ", " + cidr + ")";
- }
- };
- }
-
- /**
- *
- * @return always returns true.
- */
- public static Predicate<SecurityGroup> any() {
- return alwaysTrue();
- }
-
- /**
- * matches name of the given security group
- *
- * @param name
- * @return predicate that matches name
- */
- public static Predicate<SecurityGroup> nameEquals(final String name) {
- checkNotNull(name, "name must be defined");
-
- return new Predicate<SecurityGroup>() {
- @Override
- public boolean apply(SecurityGroup ext) {
- return name.equals(ext.getName());
- }
-
- @Override
- public String toString() {
- return "nameEquals(" + name + ")";
- }
- };
- }
-
-
- /**
- * matches name of the given security group
- *
- * @param name
- * @return predicate that matches name
- */
- public static Predicate<SecurityGroup> nameMatches(final Predicate<String> name) {
- checkNotNull(name, "name must be defined");
-
- return new Predicate<SecurityGroup>() {
- @Override
- public boolean apply(SecurityGroup ext) {
- return name.apply(ext.getName());
- }
-
- @Override
- public String toString() {
- return "nameMatches(" + name + ")";
- }
- };
- }
-
- /**
- * matches IngressRules with the given protocol, start and end port, and
- * any of the given CIDRs.
- *
- * @param protocol
- * @param startPort
- * @param endPort
- * @param cidrs
- *
- * @return predicate that matches as described
- */
- public static Predicate<IngressRule> ruleCidrMatches(final String protocol,
- final int startPort,
- final int endPort,
- final Set<String> cidrs) {
- checkNotNull(protocol, "protocol");
- checkNotNull(cidrs, "cidrs");
-
- return new Predicate<IngressRule>() {
- @Override
- public boolean apply(IngressRule rule) {
- return protocol.equals(rule.getProtocol())
- && startPort == rule.getStartPort()
- && endPort == rule.getEndPort()
- && cidrs.contains(rule.getCIDR());
- }
-
- @Override
- public String toString() {
- return "ruleCidrMatches(protocol:" + protocol
- + ",startPort:" + startPort
- + ",endPort:" + endPort
- + ",cidrs:[" + cidrs
- + "])";
- }
- };
- }
-
- /**
- * matches IngressRules with the given protocol, start and end port, and
- * any of the given account/security group name pairs.
- *
- * @param protocol
- * @param startPort
- * @param endPort
- * @param accountGroupNames
- *
- * @return predicate that matches as described
- */
- public static Predicate<IngressRule> ruleGroupMatches(final String protocol,
- final int startPort,
- final int endPort,
- final Multimap<String, String> accountGroupNames) {
- checkNotNull(protocol, "protocol");
- checkNotNull(accountGroupNames, "accountGroupNames");
-
- return new Predicate<IngressRule>() {
- @Override
- public boolean apply(IngressRule rule) {
- return protocol.equals(rule.getProtocol())
- && startPort == rule.getStartPort()
- && endPort == rule.getEndPort()
- && accountGroupNames.containsEntry(rule.getAccount(), rule.getSecurityGroupName());
- }
-
- @Override
- public String toString() {
- return "ruleGroupMatches(protocol:" + protocol
- + ",startPort:" + startPort
- + ",endPort:" + endPort
- + ",accountGroupNames:[" + accountGroupNames
- + "])";
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/SshKeyPairPredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/SshKeyPairPredicates.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/SshKeyPairPredicates.java
deleted file mode 100644
index 72f34b0..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/SshKeyPairPredicates.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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.cloudstack.domain.SshKeyPair;
-
-import com.google.common.base.Predicate;
-
-/**
- * Predicates handy when working with SshKeyPairs
- */
-
-public class SshKeyPairPredicates {
-
-
- /**
- * matches name of the given key pair
- *
- * @param name
- * @return predicate that matches name
- */
- public static Predicate<SshKeyPair> nameMatches(final Predicate<String> name) {
- checkNotNull(name, "name must be defined");
-
- return new Predicate<SshKeyPair>() {
- @Override
- public boolean apply(SshKeyPair ext) {
- return name.apply(ext.getName());
- }
-
- @Override
- public String toString() {
- return "nameMatches(" + name + ")";
- }
- };
- }
-
- /**
- * matches name of the given keypair starts with the specified prefix
- *
- * @param name the prefix you are looking for
- * @return the predicate
- */
- public static Predicate<SshKeyPair> nameEquals(final String name) {
- checkNotNull(name, "name must be defined");
-
- return new Predicate<SshKeyPair>() {
- @Override
- public boolean apply(SshKeyPair ext) {
- return ext.getName() != null && ext.getName().equals(name);
- }
-
- @Override
- public String toString() {
- return "nameEquals(" + name + ")";
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/TemplatePredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/TemplatePredicates.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/TemplatePredicates.java
deleted file mode 100644
index 341356c..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/TemplatePredicates.java
+++ /dev/null
@@ -1,62 +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.cloudstack.predicates;
-
-import javax.inject.Singleton;
-
-import org.jclouds.cloudstack.domain.Template;
-
-import com.google.common.base.Predicate;
-
-@Singleton
-public class TemplatePredicates {
- public static Predicate<Template> isReady() {
- return Ready.INSTANCE;
- }
-
- public enum Ready implements Predicate<Template> {
- INSTANCE;
- @Override
- public boolean apply(Template arg0) {
- return arg0.isReady();
- }
-
- @Override
- public String toString() {
- return "isReady()";
- }
- }
-
- public static enum PasswordEnabled implements Predicate<Template> {
- INSTANCE;
-
- @Override
- public boolean apply(Template arg0) {
- return arg0.isPasswordEnabled();
- }
-
- @Override
- public String toString() {
- return "isPasswordEnabled()";
- }
- }
-
- public static Predicate<Template> isPasswordEnabled() {
- return PasswordEnabled.INSTANCE;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java
deleted file mode 100644
index b278cde..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.cloudstack.domain.Account;
-import org.jclouds.cloudstack.domain.User;
-import org.jclouds.cloudstack.domain.Account.Type;
-
-import com.google.common.base.Predicate;
-
-public class UserPredicates {
-
- public static class ApiKeyEquals implements Predicate<User> {
- private final String apiKey;
-
- public ApiKeyEquals(String apiKey) {
- this.apiKey = checkNotNull(apiKey, "apiKey");
- }
-
- @Override
- public boolean apply(User input) {
- return apiKey.equals(checkNotNull(input, "user").getApiKey());
- }
-
- @Override
- public String toString() {
- return "apiKeyEquals(" + apiKey + ")";
- }
- }
-
- /**
- *
- * @return true, if the user's apiKey is the following
- */
- public static Predicate<User> apiKeyEquals(String apiKey) {
- return new ApiKeyEquals(apiKey);
- }
-
- /**
- *
- * @return true, if the user's account type is the following
- */
- public static Predicate<User> accountTypeEquals(Account.Type type) {
- return new AccountTypeEquals(type);
- }
-
- public static class AccountTypeEquals implements Predicate<User> {
- public AccountTypeEquals(Type type) {
- this.type = checkNotNull(type, "type");
- }
-
- private final Account.Type type;
-
- @Override
- public boolean apply(User input) {
- return checkNotNull(input, "user").getAccountType() == type;
- }
-
- @Override
- public String toString() {
- return "accountTypeEquals(" + type + ")";
- }
- }
-
- /**
- *
- * @return true, if the account has user privileges
- */
- public static Predicate<User> isUserAccount() {
- return accountTypeEquals(Account.Type.USER);
- }
-
- /**
- * @return true, is the user is a domain admin
- */
- public static Predicate<User> isDomainAdminAccount() {
- return accountTypeEquals(Type.DOMAIN_ADMIN);
- }
-
- /**
- *
- * @return true, if the user is a global admin
- */
- public static Predicate<User> isAdminAccount() {
- return accountTypeEquals(Account.Type.ADMIN);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineDestroyed.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineDestroyed.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineDestroyed.java
deleted file mode 100644
index 7548e15..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineDestroyed.java
+++ /dev/null
@@ -1,62 +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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.annotation.Resource;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.VirtualMachine;
-import org.jclouds.cloudstack.domain.VirtualMachine.State;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.inject.Inject;
-
-/**
- *
- * Tests to see if a virtualMachine is running
- */
-@Singleton
-public class VirtualMachineDestroyed implements Predicate<VirtualMachine> {
-
- private final CloudStackApi client;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public VirtualMachineDestroyed(CloudStackApi client) {
- this.client = client;
- }
-
- public boolean apply(VirtualMachine virtualMachine) {
- logger.trace("looking for state on virtualMachine %s", checkNotNull(virtualMachine, "virtualMachine"));
- virtualMachine = refresh(virtualMachine);
- if (virtualMachine == null)
- return true;
- logger.trace("%s: looking for virtualMachine state %s: currently: %s", virtualMachine.getId(), State.DESTROYED,
- virtualMachine.getState());
- return virtualMachine.getState() == State.DESTROYED;
- }
-
- private VirtualMachine refresh(VirtualMachine virtualMachine) {
- return client.getVirtualMachineApi().getVirtualMachine(virtualMachine.getId());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineExpunged.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineExpunged.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineExpunged.java
deleted file mode 100644
index daf3943..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineExpunged.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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.annotation.Resource;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.VirtualMachine;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.inject.Inject;
-
-/**
- *
- * Tests to see if a virtualMachine is expunged from the system
- */
-@Singleton
-public class VirtualMachineExpunged implements Predicate<VirtualMachine> {
-
- private final CloudStackApi client;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public VirtualMachineExpunged(CloudStackApi client) {
- this.client = client;
- }
-
- public boolean apply(VirtualMachine virtualMachine) {
- logger.trace("looking for state on virtualMachine %s", checkNotNull(virtualMachine, "virtualMachine"));
- return refresh(virtualMachine) == null;
- }
-
- private VirtualMachine refresh(VirtualMachine virtualMachine) {
- return client.getVirtualMachineApi().getVirtualMachine(virtualMachine.getId());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineRunning.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineRunning.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineRunning.java
deleted file mode 100644
index fe2c37e..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/VirtualMachineRunning.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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.annotation.Resource;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.VirtualMachine;
-import org.jclouds.cloudstack.domain.VirtualMachine.State;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.inject.Inject;
-
-/**
- *
- * Tests to see if a virtualMachine is running
- */
-@Singleton
-public class VirtualMachineRunning implements Predicate<VirtualMachine> {
-
- private final CloudStackApi client;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public VirtualMachineRunning(CloudStackApi client) {
- this.client = client;
- }
-
- public boolean apply(VirtualMachine virtualMachine) {
- logger.trace("looking for state on virtualMachine %s", checkNotNull(virtualMachine, "virtualMachine"));
- virtualMachine = refresh(virtualMachine);
- if (virtualMachine == null)
- return false;
- logger.trace("%s: looking for virtualMachine state %s: currently: %s", virtualMachine.getId(), State.RUNNING,
- virtualMachine.getState());
- if (virtualMachine.getState() == State.ERROR)
- throw new IllegalStateException("virtualMachine in error state: " + virtualMachine);
- return virtualMachine.getState() == State.RUNNING;
- }
-
- private VirtualMachine refresh(VirtualMachine virtualMachine) {
- return client.getVirtualMachineApi().getVirtualMachine(virtualMachine.getId());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/ZonePredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/ZonePredicates.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/ZonePredicates.java
deleted file mode 100644
index ee44f69..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/predicates/ZonePredicates.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.cloudstack.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Predicates.alwaysTrue;
-
-import org.jclouds.cloudstack.domain.NetworkType;
-import org.jclouds.cloudstack.domain.Zone;
-
-import com.google.common.base.Predicate;
-
-public class ZonePredicates {
- /**
- *
- * @return true, if the zone supports {@link NetworkType.ADVANCED}
- */
- public static Predicate<Zone> supportsAdvancedNetworks() {
- return new Predicate<Zone>() {
-
- @Override
- public boolean apply(Zone zone) {
- return NetworkType.ADVANCED.equals(checkNotNull(zone, "zone").getNetworkType());
- }
-
- @Override
- public String toString() {
- return "supportsAdvancedNetworks()";
- }
- };
- }
-
- /**
- *
- * @return true, if the zone supports security groups
- */
- public static Predicate<Zone> supportsSecurityGroups() {
- return new Predicate<Zone>() {
-
- @Override
- public boolean apply(Zone input) {
- return input.isSecurityGroupsEnabled();
- }
-
- @Override
- public String toString() {
- return "supportsSecurityGroups()";
- }
- };
- }
-
- /**
- *
- * @return always returns true.
- */
- public static Predicate<Zone> any() {
- return alwaysTrue();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/strategy/BlockUntilJobCompletesAndReturnResult.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/strategy/BlockUntilJobCompletesAndReturnResult.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/strategy/BlockUntilJobCompletesAndReturnResult.java
deleted file mode 100644
index 83008b8..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/strategy/BlockUntilJobCompletesAndReturnResult.java
+++ /dev/null
@@ -1,69 +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.cloudstack.strategy;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.AsyncCreateResponse;
-import org.jclouds.cloudstack.domain.AsyncJob;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.common.util.concurrent.UncheckedExecutionException;
-
-@Singleton
-public class BlockUntilJobCompletesAndReturnResult {
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- protected Logger logger = Logger.NULL;
-
- private final CloudStackApi client;
- private final Predicate<String> jobComplete;
-
- @Inject
- public BlockUntilJobCompletesAndReturnResult(CloudStackApi client, Predicate<String> jobComplete) {
- this.client = checkNotNull(client, "client");
- this.jobComplete = checkNotNull(jobComplete, "jobComplete");
- }
-
- /**
- *
- * @param job
- * @return result of the job's execution
- * @throws ExecutionException
- * if the job contained an error
- */
- public <T> T apply(AsyncCreateResponse job) {
- boolean completed = jobComplete.apply(job.getJobId());
- logger.trace("<< job(%s) complete(%s)", job, completed);
- AsyncJob<T> jobWithResult = client.getAsyncJobApi().<T> getAsyncJob(job.getJobId());
- checkState(completed, "job %s failed to complete in time %s", job.getJobId(), jobWithResult);
- if (jobWithResult.getError() != null)
- throw new UncheckedExecutionException(String.format("job %s failed with exception %s", job.getJobId(),
- jobWithResult.getError().toString())) {
- };
- return jobWithResult.getResult();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/GetCurrentUser.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/GetCurrentUser.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/GetCurrentUser.java
deleted file mode 100644
index 8f65ab1..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/GetCurrentUser.java
+++ /dev/null
@@ -1,65 +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.cloudstack.suppliers;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.NoSuchElementException;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.User;
-import org.jclouds.cloudstack.predicates.UserPredicates;
-import org.jclouds.domain.Credentials;
-import org.jclouds.location.Provider;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.collect.Iterables;
-
-public class GetCurrentUser implements Supplier<User> {
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- private final CloudStackApi client;
- private final Supplier<Credentials> creds;
-
- @Inject
- public GetCurrentUser(CloudStackApi client, @Provider Supplier<Credentials> creds) {
- this.client = checkNotNull(client, "client");
- this.creds = checkNotNull(creds, "creds");
- }
-
- @Override
- public User get() {
- Iterable<User> users = Iterables.concat(client.getAccountApi().listAccounts());
- Predicate<User> apiKeyMatches = UserPredicates.apiKeyEquals(creds.get().identity);
- User currentUser = null;
- try {
- currentUser = Iterables.find(users, apiKeyMatches);
- } catch (NoSuchElementException e) {
- throw new NoSuchElementException(String.format("none of the following users match %s: %s", apiKeyMatches,
- users));
- }
-
- return currentUser;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/NetworksForCurrentUser.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/NetworksForCurrentUser.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/NetworksForCurrentUser.java
deleted file mode 100644
index 8ed3d50..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/NetworksForCurrentUser.java
+++ /dev/null
@@ -1,60 +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.cloudstack.suppliers;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.cloudstack.options.ListNetworksOptions.Builder.accountInDomain;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.Network;
-import org.jclouds.cloudstack.domain.User;
-import org.jclouds.cloudstack.features.NetworkApi;
-import org.jclouds.collect.Memoized;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.common.collect.Maps;
-
-public class NetworksForCurrentUser implements Supplier<Map<String, Network>> {
- private final CloudStackApi client;
- private final Supplier<User> currentUserSupplier;
-
- @Inject
- public NetworksForCurrentUser(CloudStackApi client, @Memoized Supplier<User> currentUserSupplier) {
- this.client = checkNotNull(client, "client");
- this.currentUserSupplier = checkNotNull(currentUserSupplier, "currentUserSupplier");
- }
-
- @Override
- public Map<String, Network> get() {
- User currentUser = currentUserSupplier.get();
- NetworkApi networkClient = client.getNetworkApi();
- return Maps.uniqueIndex(
- networkClient.listNetworks(accountInDomain(currentUser.getAccount(), currentUser.getDomainId())),
- new Function<Network, String>() {
-
- @Override
- public String apply(Network arg0) {
- return arg0.getId();
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/ProjectsForCurrentUser.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/ProjectsForCurrentUser.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/ProjectsForCurrentUser.java
deleted file mode 100644
index ecfebf3..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/ProjectsForCurrentUser.java
+++ /dev/null
@@ -1,60 +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.cloudstack.suppliers;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.cloudstack.options.ListProjectsOptions.Builder.accountInDomain;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.jclouds.cloudstack.CloudStackApi;
-import org.jclouds.cloudstack.domain.Project;
-import org.jclouds.cloudstack.domain.User;
-import org.jclouds.cloudstack.features.ProjectApi;
-import org.jclouds.collect.Memoized;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.common.collect.Maps;
-
-public class ProjectsForCurrentUser implements Supplier<Map<String, Project>> {
- private final CloudStackApi api;
- private final Supplier<User> currentUserSupplier;
-
- @Inject
- public ProjectsForCurrentUser(CloudStackApi api, @Memoized Supplier<User> currentUserSupplier) {
- this.api = checkNotNull(api, "api");
- this.currentUserSupplier = checkNotNull(currentUserSupplier, "currentUserSupplier");
- }
-
- @Override
- public Map<String, Project> get() {
- User currentUser = currentUserSupplier.get();
- ProjectApi projectApi = api.getProjectApi();
- return Maps.uniqueIndex(
- projectApi.listProjects(accountInDomain(currentUser.getAccount(), currentUser.getDomainId())),
- new Function<Project, String>() {
-
- @Override
- public String apply(Project arg0) {
- return arg0.getId();
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/ZoneIdToZoneSupplier.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/ZoneIdToZoneSupplier.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/ZoneIdToZoneSupplier.java
deleted file mode 100644
index 4485d01..0000000
--- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/suppliers/ZoneIdToZoneSupplier.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.cloudstack.suppliers;
-
-import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
-
-import java.util.concurrent.TimeUnit;
-
-import javax.inject.Named;
-
-import org.jclouds.cloudstack.domain.Zone;
-
-import com.google.common.base.Supplier;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.inject.Inject;
-
-/**
- * Supplies a cache that maps from zone IDs to zones.
- */
-public class ZoneIdToZoneSupplier implements Supplier<LoadingCache<String, Zone>> {
- private final LoadingCache<String, Zone> cache;
-
- @Inject
- public ZoneIdToZoneSupplier(CacheLoader<String, Zone> zoneIdToZone, @Named(PROPERTY_SESSION_INTERVAL) long expirationSecs) {
- cache = CacheBuilder.newBuilder().expireAfterWrite(expirationSecs, TimeUnit.SECONDS).build(zoneIdToZone);
- }
-
- @Override
- public LoadingCache<String, Zone> get() {
- return cache;
- }
-}