mirror of https://github.com/apache/jclouds.git
Removed all unnecessary interfaces from strategies
Removed all interfaces from the strategy classes that only have one implementation.
This commit is contained in:
parent
5ba08d8448
commit
f39c1add89
|
@ -19,19 +19,96 @@
|
|||
|
||||
package org.jclouds.abiquo.strategy.cloud;
|
||||
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualMachine;
|
||||
import org.jclouds.abiquo.domain.network.Ip;
|
||||
import org.jclouds.abiquo.strategy.ListEntities;
|
||||
import org.jclouds.abiquo.strategy.cloud.internal.ListAttachedNicsImpl;
|
||||
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 static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualMachine;
|
||||
import org.jclouds.abiquo.domain.network.ExternalIp;
|
||||
import org.jclouds.abiquo.domain.network.Ip;
|
||||
import org.jclouds.abiquo.domain.network.PrivateIp;
|
||||
import org.jclouds.abiquo.domain.network.PublicIp;
|
||||
import org.jclouds.abiquo.domain.network.UnmanagedIp;
|
||||
import org.jclouds.abiquo.domain.util.LinkUtils;
|
||||
import org.jclouds.abiquo.rest.internal.ExtendedUtils;
|
||||
import org.jclouds.abiquo.strategy.ListEntities;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.abiquo.model.rest.RESTLink;
|
||||
import com.abiquo.server.core.infrastructure.network.ExternalIpDto;
|
||||
import com.abiquo.server.core.infrastructure.network.PrivateIpDto;
|
||||
import com.abiquo.server.core.infrastructure.network.PublicIpDto;
|
||||
import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* List all NICs attached to a given virtual machine.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@ImplementedBy(ListAttachedNicsImpl.class)
|
||||
public interface ListAttachedNics extends ListEntities<Ip<?, ?>, VirtualMachine> {
|
||||
@Singleton
|
||||
public class ListAttachedNics implements ListEntities<Ip<?, ?>, VirtualMachine> {
|
||||
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ExtendedUtils extendedUtils;
|
||||
|
||||
@Inject
|
||||
public ListAttachedNics(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final ExtendedUtils extendedUtils) {
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.extendedUtils = checkNotNull(extendedUtils, "extendedUtils");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Ip<?, ?>> execute(final VirtualMachine parent) {
|
||||
parent.refresh();
|
||||
Iterable<RESTLink> nicLinks = LinkUtils.filterNicLinks(parent.unwrap().getLinks());
|
||||
return listIps(nicLinks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Ip<?, ?>> execute(final VirtualMachine parent, final Predicate<Ip<?, ?>> selector) {
|
||||
return filter(execute(parent), selector);
|
||||
}
|
||||
|
||||
private Iterable<Ip<?, ?>> listIps(final Iterable<RESTLink> nicLinks) {
|
||||
return transform(nicLinks, new Function<RESTLink, Ip<?, ?>>() {
|
||||
@Override
|
||||
public Ip<?, ?> apply(final RESTLink input) {
|
||||
HttpResponse response = extendedUtils.getAbiquoHttpClient().get(input);
|
||||
|
||||
if (input.getType().equals(PrivateIpDto.BASE_MEDIA_TYPE)) {
|
||||
ParseXMLWithJAXB<PrivateIpDto> parser = new ParseXMLWithJAXB<PrivateIpDto>(extendedUtils.getXml(),
|
||||
TypeLiteral.get(PrivateIpDto.class));
|
||||
|
||||
return wrap(context, PrivateIp.class, parser.apply(response));
|
||||
} else if (input.getType().equals(PublicIpDto.BASE_MEDIA_TYPE)) {
|
||||
ParseXMLWithJAXB<PublicIpDto> parser = new ParseXMLWithJAXB<PublicIpDto>(extendedUtils.getXml(),
|
||||
TypeLiteral.get(PublicIpDto.class));
|
||||
|
||||
return wrap(context, PublicIp.class, parser.apply(response));
|
||||
} else if (input.getType().equals(ExternalIpDto.BASE_MEDIA_TYPE)) {
|
||||
ParseXMLWithJAXB<ExternalIpDto> parser = new ParseXMLWithJAXB<ExternalIpDto>(extendedUtils.getXml(),
|
||||
TypeLiteral.get(ExternalIpDto.class));
|
||||
|
||||
return wrap(context, ExternalIp.class, parser.apply(response));
|
||||
} else if (input.getType().equals(UnmanagedIpDto.BASE_MEDIA_TYPE)) {
|
||||
ParseXMLWithJAXB<UnmanagedIpDto> parser = new ParseXMLWithJAXB<UnmanagedIpDto>(extendedUtils.getXml(),
|
||||
TypeLiteral.get(UnmanagedIpDto.class));
|
||||
|
||||
return wrap(context, UnmanagedIp.class, parser.apply(response));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported media type: " + input.getType());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,18 +19,86 @@
|
|||
|
||||
package org.jclouds.abiquo.strategy.cloud;
|
||||
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualAppliance;
|
||||
import org.jclouds.abiquo.strategy.ListRootEntities;
|
||||
import org.jclouds.abiquo.strategy.cloud.internal.ListVirtualAppliancesImpl;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualAppliance;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
|
||||
import org.jclouds.abiquo.strategy.ListRootEntities;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.abiquo.server.core.cloud.VirtualApplianceDto;
|
||||
import com.abiquo.server.core.cloud.VirtualAppliancesDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* List virtual appliances in each virtual datacenter.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@ImplementedBy(ListVirtualAppliancesImpl.class)
|
||||
public interface ListVirtualAppliances extends ListRootEntities<VirtualAppliance> {
|
||||
@Singleton
|
||||
public class ListVirtualAppliances implements ListRootEntities<VirtualAppliance> {
|
||||
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ListVirtualDatacenters listVirtualDatacenters;
|
||||
|
||||
protected final ExecutorService userExecutor;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListVirtualAppliances(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor,
|
||||
final ListVirtualDatacenters listVirtualDatacenters) {
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.listVirtualDatacenters = checkNotNull(listVirtualDatacenters, "listVirtualDatacenters");
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualAppliance> execute() {
|
||||
// Find virtual appliances in concurrent requests
|
||||
Iterable<VirtualDatacenter> vdcs = listVirtualDatacenters.execute();
|
||||
Iterable<VirtualApplianceDto> vapps = listConcurrentVirtualAppliances(vdcs);
|
||||
|
||||
return wrap(context, VirtualAppliance.class, vapps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualAppliance> execute(final Predicate<VirtualAppliance> selector) {
|
||||
return filter(execute(), selector);
|
||||
}
|
||||
|
||||
private Iterable<VirtualApplianceDto> listConcurrentVirtualAppliances(final Iterable<VirtualDatacenter> vdcs) {
|
||||
Iterable<VirtualAppliancesDto> vapps = transformParallel(vdcs,
|
||||
new Function<VirtualDatacenter, Future<? extends VirtualAppliancesDto>>() {
|
||||
@Override
|
||||
public Future<VirtualAppliancesDto> apply(final VirtualDatacenter input) {
|
||||
return context.getAsyncApi().getCloudApi().listVirtualAppliances(input.unwrap());
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting virtual appliances");
|
||||
|
||||
return DomainWrapper.join(vapps);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,28 +19,98 @@
|
|||
|
||||
package org.jclouds.abiquo.strategy.cloud;
|
||||
|
||||
import java.util.List;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
|
||||
import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions;
|
||||
import org.jclouds.abiquo.strategy.ListRootEntities;
|
||||
import org.jclouds.abiquo.strategy.cloud.internal.ListVirtualDatacentersImpl;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.abiquo.server.core.cloud.VirtualDatacenterDto;
|
||||
import com.abiquo.server.core.cloud.VirtualDatacentersDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.ImplementedBy;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* List virtual datacenters.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@ImplementedBy(ListVirtualDatacentersImpl.class)
|
||||
public interface ListVirtualDatacenters extends ListRootEntities<VirtualDatacenter> {
|
||||
Iterable<VirtualDatacenter> execute(VirtualDatacenterOptions virtualDatacenterOptions);
|
||||
@Singleton
|
||||
public class ListVirtualDatacenters implements ListRootEntities<VirtualDatacenter> {
|
||||
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
Iterable<VirtualDatacenter> execute(List<Integer> virtualDatacenterIds);
|
||||
protected final ExecutorService userExecutor;
|
||||
|
||||
Iterable<VirtualDatacenter> execute(Predicate<VirtualDatacenter> selector,
|
||||
VirtualDatacenterOptions virtualDatacenterOptions);
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListVirtualDatacenters(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) {
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualDatacenter> execute() {
|
||||
VirtualDatacenterOptions virtualDatacenterOptions = VirtualDatacenterOptions.builder().build();
|
||||
|
||||
return execute(virtualDatacenterOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualDatacenter> execute(final Predicate<VirtualDatacenter> selector) {
|
||||
return filter(execute(), selector);
|
||||
}
|
||||
|
||||
public Iterable<VirtualDatacenter> execute(final VirtualDatacenterOptions virtualDatacenterOptions) {
|
||||
VirtualDatacentersDto result = context.getApi().getCloudApi().listVirtualDatacenters(virtualDatacenterOptions);
|
||||
return wrap(context, VirtualDatacenter.class, result.getCollection());
|
||||
}
|
||||
|
||||
public Iterable<VirtualDatacenter> execute(final Predicate<VirtualDatacenter> selector,
|
||||
final VirtualDatacenterOptions virtualDatacenterOptions) {
|
||||
return filter(execute(virtualDatacenterOptions), selector);
|
||||
}
|
||||
|
||||
public Iterable<VirtualDatacenter> execute(final List<Integer> virtualDatacenterIds) {
|
||||
// Find virtual datacenters in concurrent requests
|
||||
return listConcurrentVirtualDatacenters(virtualDatacenterIds);
|
||||
}
|
||||
|
||||
private Iterable<VirtualDatacenter> listConcurrentVirtualDatacenters(final List<Integer> ids) {
|
||||
Iterable<VirtualDatacenterDto> vdcs = transformParallel(ids,
|
||||
new Function<Integer, Future<? extends VirtualDatacenterDto>>() {
|
||||
@Override
|
||||
public Future<VirtualDatacenterDto> apply(final Integer input) {
|
||||
return context.getAsyncApi().getCloudApi().getVirtualDatacenter(input);
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting virtual datacenters");
|
||||
|
||||
return DomainWrapper.wrap(context, VirtualDatacenter.class, Lists.newArrayList(vdcs));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,19 +19,93 @@
|
|||
|
||||
package org.jclouds.abiquo.strategy.cloud;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualAppliance;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualMachine;
|
||||
import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions;
|
||||
import org.jclouds.abiquo.strategy.ListRootEntities;
|
||||
import org.jclouds.abiquo.strategy.cloud.internal.ListVirtualMachinesImpl;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
|
||||
import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* List virtual machines in each virtual datacenter and each virtual appliance.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@ImplementedBy(ListVirtualMachinesImpl.class)
|
||||
public interface ListVirtualMachines extends ListRootEntities<VirtualMachine> {
|
||||
Iterable<VirtualMachine> execute(VirtualMachineOptions options);
|
||||
@Singleton
|
||||
public class ListVirtualMachines implements ListRootEntities<VirtualMachine> {
|
||||
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ExecutorService userExecutor;
|
||||
|
||||
protected final ListVirtualAppliances listVirtualAppliances;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListVirtualMachines(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor,
|
||||
final ListVirtualAppliances listVirtualAppliances) {
|
||||
super();
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.listVirtualAppliances = checkNotNull(listVirtualAppliances, "listVirtualAppliances");
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachine> execute() {
|
||||
return execute(VirtualMachineOptions.builder().disablePagination().build());
|
||||
}
|
||||
|
||||
public Iterable<VirtualMachine> execute(final VirtualMachineOptions options) {
|
||||
// Find virtual machines in concurrent requests
|
||||
Iterable<VirtualAppliance> vapps = listVirtualAppliances.execute();
|
||||
Iterable<VirtualMachineWithNodeExtendedDto> vms = listConcurrentVirtualMachines(vapps, options);
|
||||
|
||||
return wrap(context, VirtualMachine.class, vms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachine> execute(final Predicate<VirtualMachine> selector) {
|
||||
return filter(execute(), selector);
|
||||
}
|
||||
|
||||
private Iterable<VirtualMachineWithNodeExtendedDto> listConcurrentVirtualMachines(
|
||||
final Iterable<VirtualAppliance> vapps, final VirtualMachineOptions options) {
|
||||
Iterable<VirtualMachinesWithNodeExtendedDto> vms = transformParallel(vapps,
|
||||
new Function<VirtualAppliance, Future<? extends VirtualMachinesWithNodeExtendedDto>>() {
|
||||
@Override
|
||||
public Future<VirtualMachinesWithNodeExtendedDto> apply(final VirtualAppliance input) {
|
||||
return context.getAsyncApi().getCloudApi().listVirtualMachines(input.unwrap(), options);
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting virtual machines");
|
||||
|
||||
return DomainWrapper.join(vms);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.cloud.internal;
|
||||
|
||||
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 static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualMachine;
|
||||
import org.jclouds.abiquo.domain.network.ExternalIp;
|
||||
import org.jclouds.abiquo.domain.network.Ip;
|
||||
import org.jclouds.abiquo.domain.network.PrivateIp;
|
||||
import org.jclouds.abiquo.domain.network.PublicIp;
|
||||
import org.jclouds.abiquo.domain.network.UnmanagedIp;
|
||||
import org.jclouds.abiquo.domain.util.LinkUtils;
|
||||
import org.jclouds.abiquo.rest.internal.ExtendedUtils;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListAttachedNics;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.abiquo.model.rest.RESTLink;
|
||||
import com.abiquo.server.core.infrastructure.network.ExternalIpDto;
|
||||
import com.abiquo.server.core.infrastructure.network.PrivateIpDto;
|
||||
import com.abiquo.server.core.infrastructure.network.PublicIpDto;
|
||||
import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* List all NICs attached to a given virtual machine.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Singleton
|
||||
public class ListAttachedNicsImpl implements ListAttachedNics {
|
||||
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ExtendedUtils extendedUtils;
|
||||
|
||||
@Inject
|
||||
public ListAttachedNicsImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final ExtendedUtils extendedUtils) {
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.extendedUtils = checkNotNull(extendedUtils, "extendedUtils");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Ip<?, ?>> execute(final VirtualMachine parent) {
|
||||
parent.refresh();
|
||||
Iterable<RESTLink> nicLinks = LinkUtils.filterNicLinks(parent.unwrap().getLinks());
|
||||
return listIps(nicLinks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Ip<?, ?>> execute(final VirtualMachine parent, final Predicate<Ip<?, ?>> selector) {
|
||||
return filter(execute(parent), selector);
|
||||
}
|
||||
|
||||
private Iterable<Ip<?, ?>> listIps(final Iterable<RESTLink> nicLinks) {
|
||||
return transform(nicLinks, new Function<RESTLink, Ip<?, ?>>() {
|
||||
@Override
|
||||
public Ip<?, ?> apply(final RESTLink input) {
|
||||
HttpResponse response = extendedUtils.getAbiquoHttpClient().get(input);
|
||||
|
||||
if (input.getType().equals(PrivateIpDto.BASE_MEDIA_TYPE)) {
|
||||
ParseXMLWithJAXB<PrivateIpDto> parser = new ParseXMLWithJAXB<PrivateIpDto>(extendedUtils.getXml(),
|
||||
TypeLiteral.get(PrivateIpDto.class));
|
||||
|
||||
return wrap(context, PrivateIp.class, parser.apply(response));
|
||||
} else if (input.getType().equals(PublicIpDto.BASE_MEDIA_TYPE)) {
|
||||
ParseXMLWithJAXB<PublicIpDto> parser = new ParseXMLWithJAXB<PublicIpDto>(extendedUtils.getXml(),
|
||||
TypeLiteral.get(PublicIpDto.class));
|
||||
|
||||
return wrap(context, PublicIp.class, parser.apply(response));
|
||||
} else if (input.getType().equals(ExternalIpDto.BASE_MEDIA_TYPE)) {
|
||||
ParseXMLWithJAXB<ExternalIpDto> parser = new ParseXMLWithJAXB<ExternalIpDto>(extendedUtils.getXml(),
|
||||
TypeLiteral.get(ExternalIpDto.class));
|
||||
|
||||
return wrap(context, ExternalIp.class, parser.apply(response));
|
||||
} else if (input.getType().equals(UnmanagedIpDto.BASE_MEDIA_TYPE)) {
|
||||
ParseXMLWithJAXB<UnmanagedIpDto> parser = new ParseXMLWithJAXB<UnmanagedIpDto>(extendedUtils.getXml(),
|
||||
TypeLiteral.get(UnmanagedIpDto.class));
|
||||
|
||||
return wrap(context, UnmanagedIp.class, parser.apply(response));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported media type: " + input.getType());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.cloud.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualAppliance;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.abiquo.server.core.cloud.VirtualApplianceDto;
|
||||
import com.abiquo.server.core.cloud.VirtualAppliancesDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* List virtual appliance in each virtual datacenter.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Singleton
|
||||
public class ListVirtualAppliancesImpl implements ListVirtualAppliances {
|
||||
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ListVirtualDatacenters listVirtualDatacenters;
|
||||
|
||||
protected final ExecutorService userExecutor;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListVirtualAppliancesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor,
|
||||
final ListVirtualDatacenters listVirtualDatacenters) {
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.listVirtualDatacenters = checkNotNull(listVirtualDatacenters, "listVirtualDatacenters");
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualAppliance> execute() {
|
||||
// Find virtual appliances in concurrent requests
|
||||
Iterable<VirtualDatacenter> vdcs = listVirtualDatacenters.execute();
|
||||
Iterable<VirtualApplianceDto> vapps = listConcurrentVirtualAppliances(vdcs);
|
||||
|
||||
return wrap(context, VirtualAppliance.class, vapps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualAppliance> execute(final Predicate<VirtualAppliance> selector) {
|
||||
return filter(execute(), selector);
|
||||
}
|
||||
|
||||
private Iterable<VirtualApplianceDto> listConcurrentVirtualAppliances(final Iterable<VirtualDatacenter> vdcs) {
|
||||
Iterable<VirtualAppliancesDto> vapps = transformParallel(vdcs,
|
||||
new Function<VirtualDatacenter, Future<? extends VirtualAppliancesDto>>() {
|
||||
@Override
|
||||
public Future<VirtualAppliancesDto> apply(final VirtualDatacenter input) {
|
||||
return context.getAsyncApi().getCloudApi().listVirtualAppliances(input.unwrap());
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting virtual appliances");
|
||||
|
||||
return DomainWrapper.join(vapps);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.cloud.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
|
||||
import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.abiquo.server.core.cloud.VirtualDatacenterDto;
|
||||
import com.abiquo.server.core.cloud.VirtualDatacentersDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* List virtual datacenters.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
* @author Francesc Montserrat
|
||||
*/
|
||||
@Singleton
|
||||
public class ListVirtualDatacentersImpl implements ListVirtualDatacenters {
|
||||
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ExecutorService userExecutor;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListVirtualDatacentersImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) {
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualDatacenter> execute() {
|
||||
VirtualDatacenterOptions virtualDatacenterOptions = VirtualDatacenterOptions.builder().build();
|
||||
|
||||
return execute(virtualDatacenterOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualDatacenter> execute(final Predicate<VirtualDatacenter> selector) {
|
||||
return filter(execute(), selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualDatacenter> execute(final VirtualDatacenterOptions virtualDatacenterOptions) {
|
||||
VirtualDatacentersDto result = context.getApi().getCloudApi().listVirtualDatacenters(virtualDatacenterOptions);
|
||||
return wrap(context, VirtualDatacenter.class, result.getCollection());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualDatacenter> execute(final Predicate<VirtualDatacenter> selector,
|
||||
final VirtualDatacenterOptions virtualDatacenterOptions) {
|
||||
return filter(execute(virtualDatacenterOptions), selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualDatacenter> execute(final List<Integer> virtualDatacenterIds) {
|
||||
// Find virtual datacenters in concurrent requests
|
||||
return listConcurrentVirtualDatacenters(virtualDatacenterIds);
|
||||
}
|
||||
|
||||
private Iterable<VirtualDatacenter> listConcurrentVirtualDatacenters(final List<Integer> ids) {
|
||||
Iterable<VirtualDatacenterDto> vdcs = transformParallel(ids,
|
||||
new Function<Integer, Future<? extends VirtualDatacenterDto>>() {
|
||||
@Override
|
||||
public Future<VirtualDatacenterDto> apply(final Integer input) {
|
||||
return context.getAsyncApi().getCloudApi().getVirtualDatacenter(input);
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting virtual datacenters");
|
||||
|
||||
return DomainWrapper.wrap(context, VirtualDatacenter.class, Lists.newArrayList(vdcs));
|
||||
}
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.cloud.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualAppliance;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualMachine;
|
||||
import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListVirtualMachines;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
|
||||
import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* List virtual machines in each virtual datacenter and each virtual appliance.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Singleton
|
||||
public class ListVirtualMachinesImpl implements ListVirtualMachines {
|
||||
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ExecutorService userExecutor;
|
||||
|
||||
protected final ListVirtualAppliances listVirtualAppliances;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListVirtualMachinesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor,
|
||||
final ListVirtualAppliances listVirtualAppliances) {
|
||||
super();
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.listVirtualAppliances = checkNotNull(listVirtualAppliances, "listVirtualAppliances");
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachine> execute() {
|
||||
return execute(VirtualMachineOptions.builder().disablePagination().build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachine> execute(final VirtualMachineOptions options) {
|
||||
// Find virtual machines in concurrent requests
|
||||
Iterable<VirtualAppliance> vapps = listVirtualAppliances.execute();
|
||||
Iterable<VirtualMachineWithNodeExtendedDto> vms = listConcurrentVirtualMachines(vapps, options);
|
||||
|
||||
return wrap(context, VirtualMachine.class, vms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachine> execute(final Predicate<VirtualMachine> selector) {
|
||||
return filter(execute(), selector);
|
||||
}
|
||||
|
||||
private Iterable<VirtualMachineWithNodeExtendedDto> listConcurrentVirtualMachines(
|
||||
final Iterable<VirtualAppliance> vapps, final VirtualMachineOptions options) {
|
||||
Iterable<VirtualMachinesWithNodeExtendedDto> vms = transformParallel(vapps,
|
||||
new Function<VirtualAppliance, Future<? extends VirtualMachinesWithNodeExtendedDto>>() {
|
||||
@Override
|
||||
public Future<VirtualMachinesWithNodeExtendedDto> apply(final VirtualAppliance input) {
|
||||
return context.getAsyncApi().getCloudApi().listVirtualMachines(input.unwrap(), options);
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting virtual machines");
|
||||
|
||||
return DomainWrapper.join(vms);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,19 +19,87 @@
|
|||
|
||||
package org.jclouds.abiquo.strategy.enterprise;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
|
||||
import org.jclouds.abiquo.domain.enterprise.Enterprise;
|
||||
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
|
||||
import org.jclouds.abiquo.strategy.ListEntities;
|
||||
import org.jclouds.abiquo.strategy.enterprise.internal.ListVirtualMachineTemplatesImpl;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto;
|
||||
import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* List all virtual machine templates available to an enterprise.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@ImplementedBy(ListVirtualMachineTemplatesImpl.class)
|
||||
public interface ListVirtualMachineTemplates extends ListEntities<VirtualMachineTemplate, Enterprise> {
|
||||
@Singleton
|
||||
public class ListVirtualMachineTemplates implements ListEntities<VirtualMachineTemplate, Enterprise> {
|
||||
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ExecutorService userExecutor;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListVirtualMachineTemplates(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) {
|
||||
super();
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachineTemplate> execute(final Enterprise parent) {
|
||||
// Find virtual machine templates in concurrent requests
|
||||
Iterable<Datacenter> dcs = parent.listAllowedDatacenters();
|
||||
Iterable<VirtualMachineTemplateDto> templates = listConcurrentTemplates(parent, dcs);
|
||||
|
||||
return wrap(context, VirtualMachineTemplate.class, templates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachineTemplate> execute(final Enterprise parent,
|
||||
final Predicate<VirtualMachineTemplate> selector) {
|
||||
return filter(execute(parent), selector);
|
||||
}
|
||||
|
||||
private Iterable<VirtualMachineTemplateDto> listConcurrentTemplates(final Enterprise parent,
|
||||
final Iterable<Datacenter> dcs) {
|
||||
Iterable<VirtualMachineTemplatesDto> templates = transformParallel(dcs,
|
||||
new Function<Datacenter, Future<? extends VirtualMachineTemplatesDto>>() {
|
||||
@Override
|
||||
public Future<VirtualMachineTemplatesDto> apply(final Datacenter input) {
|
||||
return context.getAsyncApi().getVirtualMachineTemplateApi()
|
||||
.listVirtualMachineTemplates(parent.getId(), input.getId());
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting virtual machine templates");
|
||||
|
||||
return DomainWrapper.join(templates);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.enterprise.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||
import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
|
||||
import org.jclouds.abiquo.domain.enterprise.Enterprise;
|
||||
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
|
||||
import org.jclouds.abiquo.strategy.enterprise.ListVirtualMachineTemplates;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto;
|
||||
import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* List all virtual machine templates available to an enterprise.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Singleton
|
||||
public class ListVirtualMachineTemplatesImpl implements ListVirtualMachineTemplates {
|
||||
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ExecutorService userExecutor;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListVirtualMachineTemplatesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) {
|
||||
super();
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachineTemplate> execute(final Enterprise parent) {
|
||||
// Find virtual machine templates in concurrent requests
|
||||
Iterable<Datacenter> dcs = parent.listAllowedDatacenters();
|
||||
Iterable<VirtualMachineTemplateDto> templates = listConcurrentTemplates(parent, dcs);
|
||||
|
||||
return wrap(context, VirtualMachineTemplate.class, templates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachineTemplate> execute(final Enterprise parent,
|
||||
final Predicate<VirtualMachineTemplate> selector) {
|
||||
return filter(execute(parent), selector);
|
||||
}
|
||||
|
||||
private Iterable<VirtualMachineTemplateDto> listConcurrentTemplates(final Enterprise parent,
|
||||
final Iterable<Datacenter> dcs) {
|
||||
Iterable<VirtualMachineTemplatesDto> templates = transformParallel(dcs,
|
||||
new Function<Datacenter, Future<? extends VirtualMachineTemplatesDto>>() {
|
||||
@Override
|
||||
public Future<VirtualMachineTemplatesDto> apply(final Datacenter input) {
|
||||
return context.getAsyncApi().getVirtualMachineTemplateApi()
|
||||
.listVirtualMachineTemplates(parent.getId(), input.getId());
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting virtual machine templates");
|
||||
|
||||
return DomainWrapper.join(templates);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,18 +19,98 @@
|
|||
|
||||
package org.jclouds.abiquo.strategy.infrastructure;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
|
||||
import org.jclouds.abiquo.domain.infrastructure.Machine;
|
||||
import org.jclouds.abiquo.strategy.ListRootEntities;
|
||||
import org.jclouds.abiquo.strategy.infrastructure.internal.ListMachinesImpl;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
import com.abiquo.server.core.infrastructure.DatacentersDto;
|
||||
import com.abiquo.server.core.infrastructure.MachineDto;
|
||||
import com.abiquo.server.core.infrastructure.MachinesDto;
|
||||
import com.abiquo.server.core.infrastructure.RackDto;
|
||||
import com.abiquo.server.core.infrastructure.RacksDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* List machines in each datacenter and rack.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@ImplementedBy(ListMachinesImpl.class)
|
||||
public interface ListMachines extends ListRootEntities<Machine> {
|
||||
@Singleton
|
||||
public class ListMachines implements ListRootEntities<Machine> {
|
||||
protected RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ExecutorService userExecutor;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListMachines(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) {
|
||||
super();
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Machine> execute() {
|
||||
// Find machines in concurrent requests
|
||||
DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters();
|
||||
Iterable<Datacenter> datacenters = wrap(context, Datacenter.class, result.getCollection());
|
||||
Iterable<RackDto> racks = listConcurrentRacks(datacenters);
|
||||
Iterable<MachineDto> machines = listConcurrentMachines(racks);
|
||||
|
||||
return wrap(context, Machine.class, machines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Machine> execute(final Predicate<Machine> selector) {
|
||||
return filter(execute(), selector);
|
||||
}
|
||||
|
||||
private Iterable<RackDto> listConcurrentRacks(final Iterable<Datacenter> datacenters) {
|
||||
Iterable<RacksDto> racks = transformParallel(datacenters, new Function<Datacenter, Future<? extends RacksDto>>() {
|
||||
@Override
|
||||
public Future<RacksDto> apply(final Datacenter input) {
|
||||
return context.getAsyncApi().getInfrastructureApi().listRacks(input.unwrap());
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting racks");
|
||||
|
||||
return DomainWrapper.join(racks);
|
||||
}
|
||||
|
||||
private Iterable<MachineDto> listConcurrentMachines(final Iterable<RackDto> racks) {
|
||||
Iterable<MachinesDto> machines = transformParallel(racks, new Function<RackDto, Future<? extends MachinesDto>>() {
|
||||
@Override
|
||||
public Future<MachinesDto> apply(final RackDto input) {
|
||||
return context.getAsyncApi().getInfrastructureApi().listMachines(input);
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting machines");
|
||||
|
||||
return DomainWrapper.join(machines);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.infrastructure.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.abiquo.AbiquoApi;
|
||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
|
||||
import org.jclouds.abiquo.domain.infrastructure.Machine;
|
||||
import org.jclouds.abiquo.strategy.infrastructure.ListMachines;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.abiquo.server.core.infrastructure.DatacentersDto;
|
||||
import com.abiquo.server.core.infrastructure.MachineDto;
|
||||
import com.abiquo.server.core.infrastructure.MachinesDto;
|
||||
import com.abiquo.server.core.infrastructure.RackDto;
|
||||
import com.abiquo.server.core.infrastructure.RacksDto;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* List machines in each datacenter and rack.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Singleton
|
||||
public class ListMachinesImpl implements ListMachines {
|
||||
protected RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
protected final ExecutorService userExecutor;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
||||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListMachinesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) {
|
||||
super();
|
||||
this.context = checkNotNull(context, "context");
|
||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Machine> execute() {
|
||||
// Find machines in concurrent requests
|
||||
DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters();
|
||||
Iterable<Datacenter> datacenters = wrap(context, Datacenter.class, result.getCollection());
|
||||
Iterable<RackDto> racks = listConcurrentRacks(datacenters);
|
||||
Iterable<MachineDto> machines = listConcurrentMachines(racks);
|
||||
|
||||
return wrap(context, Machine.class, machines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Machine> execute(final Predicate<Machine> selector) {
|
||||
return filter(execute(), selector);
|
||||
}
|
||||
|
||||
private Iterable<RackDto> listConcurrentRacks(final Iterable<Datacenter> datacenters) {
|
||||
Iterable<RacksDto> racks = transformParallel(datacenters, new Function<Datacenter, Future<? extends RacksDto>>() {
|
||||
@Override
|
||||
public Future<RacksDto> apply(final Datacenter input) {
|
||||
return context.getAsyncApi().getInfrastructureApi().listRacks(input.unwrap());
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting racks");
|
||||
|
||||
return DomainWrapper.join(racks);
|
||||
}
|
||||
|
||||
private Iterable<MachineDto> listConcurrentMachines(final Iterable<RackDto> racks) {
|
||||
Iterable<MachinesDto> machines = transformParallel(racks, new Function<RackDto, Future<? extends MachinesDto>>() {
|
||||
@Override
|
||||
public Future<MachinesDto> apply(final RackDto input) {
|
||||
return context.getAsyncApi().getInfrastructureApi().listMachines(input);
|
||||
}
|
||||
}, userExecutor, maxTime, logger, "getting machines");
|
||||
|
||||
return DomainWrapper.join(machines);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.cloud.internal;
|
||||
package org.jclouds.abiquo.strategy.cloud;
|
||||
|
||||
import static com.google.common.collect.Iterables.size;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -32,6 +32,7 @@ import org.jclouds.abiquo.domain.network.PublicIp;
|
|||
import org.jclouds.abiquo.domain.network.UnmanagedNetwork;
|
||||
import org.jclouds.abiquo.predicates.network.IpPredicates;
|
||||
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListAttachedNics;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -39,13 +40,13 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Live tests for the {@link ListAttachedNicsImpl} strategy.
|
||||
* Live tests for the {@link ListAttachedNics} strategy.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Test(groups = "api", testName = "ListAttachedNicsImplLiveApiTest")
|
||||
public class ListAttachedNicsImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListAttachedNicsImpl strategy;
|
||||
@Test(groups = "api", testName = "ListAttachedNicsLiveApiTest")
|
||||
public class ListAttachedNicsLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListAttachedNics strategy;
|
||||
|
||||
private PrivateIp privateIp;
|
||||
|
||||
|
@ -56,7 +57,7 @@ public class ListAttachedNicsImplLiveApiTest extends BaseAbiquoStrategyLiveApiTe
|
|||
@Override
|
||||
@BeforeClass(groups = "api")
|
||||
protected void setupStrategy() {
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListAttachedNicsImpl.class);
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListAttachedNics.class);
|
||||
|
||||
privateIp = env.privateNetwork.listUnusedIps().get(0);
|
||||
assertNotNull(privateIp);
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.cloud.internal;
|
||||
package org.jclouds.abiquo.strategy.cloud;
|
||||
|
||||
import static com.google.common.collect.Iterables.size;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -27,22 +27,23 @@ import static org.testng.Assert.assertTrue;
|
|||
import org.jclouds.abiquo.domain.cloud.VirtualAppliance;
|
||||
import org.jclouds.abiquo.predicates.cloud.VirtualAppliancePredicates;
|
||||
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Live tests for the {@link ListVirtualAppliancesImpl} strategy.
|
||||
* Live tests for the {@link ListVirtualAppliances} strategy.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Test(groups = "api", testName = "ListVirtualAppliancesImplLiveApiTest")
|
||||
public class ListVirtualAppliancesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListVirtualAppliancesImpl strategy;
|
||||
@Test(groups = "api", testName = "ListVirtualAppliancesLiveApiTest")
|
||||
public class ListVirtualAppliancesLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListVirtualAppliances strategy;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = "api")
|
||||
protected void setupStrategy() {
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualAppliancesImpl.class);
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualAppliances.class);
|
||||
}
|
||||
|
||||
public void testExecute() {
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.cloud.internal;
|
||||
package org.jclouds.abiquo.strategy.cloud;
|
||||
|
||||
import static com.google.common.collect.Iterables.size;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -28,22 +28,23 @@ import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
|
|||
import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions;
|
||||
import org.jclouds.abiquo.predicates.cloud.VirtualDatacenterPredicates;
|
||||
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Live tests for the {@link ListVirtualDatacentersImpl} strategy.
|
||||
* Live tests for the {@link ListVirtualDatacenters} strategy.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Test(groups = "api", testName = "ListVirtualDatacentersImplLiveApiTest")
|
||||
public class ListVirtualDatacentersImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListVirtualDatacentersImpl strategy;
|
||||
@Test(groups = "api", testName = "ListVirtualDatacentersLiveApiTest")
|
||||
public class ListVirtualDatacentersLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListVirtualDatacenters strategy;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = "api")
|
||||
protected void setupStrategy() {
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualDatacentersImpl.class);
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualDatacenters.class);
|
||||
}
|
||||
|
||||
public void testExecute() {
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.cloud.internal;
|
||||
package org.jclouds.abiquo.strategy.cloud;
|
||||
|
||||
import static com.google.common.collect.Iterables.size;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -30,22 +30,23 @@ import java.util.List;
|
|||
import org.jclouds.abiquo.domain.cloud.VirtualMachine;
|
||||
import org.jclouds.abiquo.predicates.cloud.VirtualMachinePredicates;
|
||||
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListVirtualMachines;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Live tests for the {@link ListVirtualMachinesImpl} strategy.
|
||||
* Live tests for the {@link ListVirtualMachines} strategy.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Test(groups = "api", testName = "ListVirtualMachinesImplLiveApiTest")
|
||||
public class ListVirtualMachinesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListVirtualMachinesImpl strategy;
|
||||
@Test(groups = "api", testName = "ListVirtualMachinesLiveApiTest")
|
||||
public class ListVirtualMachinesLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListVirtualMachines strategy;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = "api")
|
||||
protected void setupStrategy() {
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachinesImpl.class);
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachines.class);
|
||||
}
|
||||
|
||||
public void testExecute() {
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.enterprise.internal;
|
||||
package org.jclouds.abiquo.strategy.enterprise;
|
||||
|
||||
import static com.google.common.collect.Iterables.size;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -27,23 +27,24 @@ import static org.testng.Assert.assertTrue;
|
|||
import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
|
||||
import org.jclouds.abiquo.predicates.cloud.VirtualMachineTemplatePredicates;
|
||||
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
|
||||
import org.jclouds.abiquo.strategy.cloud.internal.ListVirtualAppliancesImpl;
|
||||
import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances;
|
||||
import org.jclouds.abiquo.strategy.enterprise.ListVirtualMachineTemplates;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Live tests for the {@link ListVirtualAppliancesImpl} strategy.
|
||||
* Live tests for the {@link ListVirtualAppliances} strategy.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Test(groups = "api", testName = "ListVirtualMachineTemplatesImplLiveApiTest")
|
||||
public class ListVirtualMachineTemplatesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListVirtualMachineTemplatesImpl strategy;
|
||||
@Test(groups = "api", testName = "ListVirtualMachineTemplatesLiveApiTest")
|
||||
public class ListVirtualMachineTemplatesLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListVirtualMachineTemplates strategy;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = "api")
|
||||
protected void setupStrategy() {
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachineTemplatesImpl.class);
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachineTemplates.class);
|
||||
}
|
||||
|
||||
public void testExecute() {
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.abiquo.strategy.infrastructure.internal;
|
||||
package org.jclouds.abiquo.strategy.infrastructure;
|
||||
|
||||
import static com.google.common.collect.Iterables.size;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -27,22 +27,23 @@ import static org.testng.Assert.assertTrue;
|
|||
import org.jclouds.abiquo.domain.infrastructure.Machine;
|
||||
import org.jclouds.abiquo.predicates.infrastructure.MachinePredicates;
|
||||
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
|
||||
import org.jclouds.abiquo.strategy.infrastructure.ListMachines;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Live tests for the {@link ListMachinesImpl} strategy.
|
||||
* Live tests for the {@link ListMachines} strategy.
|
||||
*
|
||||
* @author Ignasi Barrera
|
||||
*/
|
||||
@Test(groups = "api", testName = "ListMachinesImplLiveApiTest")
|
||||
public class ListMachinesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListMachinesImpl strategy;
|
||||
@Test(groups = "api", testName = "ListMachinesLiveApiTest")
|
||||
public class ListMachinesLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
|
||||
private ListMachines strategy;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = "api")
|
||||
protected void setupStrategy() {
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListMachinesImpl.class);
|
||||
this.strategy = env.context.getUtils().getInjector().getInstance(ListMachines.class);
|
||||
}
|
||||
|
||||
public void testExecute() {
|
Loading…
Reference in New Issue