mirror of https://github.com/apache/jclouds.git
first commit
This commit is contained in:
parent
5ea05a3066
commit
69ef3fa7ea
|
@ -0,0 +1,2 @@
|
|||
|
||||
|
|
@ -0,0 +1 @@
|
|||
runNodesWithTag: when ask for more than 1 node, cloning step fails cause of concurrent access to the originale virtual disk to be cloned.
|
|
@ -0,0 +1,138 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
|
||||
Copyright (C) 2010 Cloud Conscious, LLC.
|
||||
<info@cloudconscious.com>
|
||||
|
||||
====================================================================
|
||||
Licensed 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.
|
||||
====================================================================
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-project</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>jclouds-vsphere</artifactId>
|
||||
<name>jclouds example components for a vijava lib for vSphere</name>
|
||||
<properties>
|
||||
<!-- when instances are hung, open a ticket and add here -->
|
||||
<jclouds.compute.blacklist.nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist.nodes>
|
||||
<test.libvirt.endpoint>test:///default</test.libvirt.endpoint>
|
||||
<test.libvirt.apiversion>1.0</test.libvirt.apiversion>
|
||||
<test.libvirt.identity>FIXME</test.libvirt.identity>
|
||||
<test.libvirt.credential>FIXME</test.libvirt.credential>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jvnet.hudson</groupId>
|
||||
<artifactId>vijava</artifactId>
|
||||
<version>2120100824</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jamesmurty.utils</groupId>
|
||||
<artifactId>java-xmlbuilder</artifactId>
|
||||
<version>0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-compute</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-compute</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.14</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-log4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-jsch</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>live</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>test.libvirt.endpoint</name>
|
||||
<value>${test.libvirt.endpoint}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>test.libvirt.apiversion</name>
|
||||
<value>${test.libvirt.apiversion}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>test.libvirt.identity</name>
|
||||
<value>${test.libvirt.identity}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>test.libvirt.credential</name>
|
||||
<value>${test.libvirt.credential}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.compute.blacklist.nodes</name>
|
||||
<value>${jclouds.compute.blacklist.nodes}</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* This would be replaced with the real java object related to the underlying data center
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Datacenter {
|
||||
|
||||
public int id;
|
||||
public String name;
|
||||
|
||||
public Datacenter(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that == null)
|
||||
return false;
|
||||
return Objects.equal(this.toString(), that.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).add("id", id).add("name", name).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* This would be replaced with the real java object related to the underlying image
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Image {
|
||||
|
||||
public int id;
|
||||
public String name;
|
||||
|
||||
public Image(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that == null)
|
||||
return false;
|
||||
return Objects.equal(this.toString(), that.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).add("id", id).add("name", name).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere;
|
||||
|
||||
/**
|
||||
* Configuration properties and constants used in libvirt local connections.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface ViConstants {
|
||||
public static final String PROPERTY_LIBVIRT_DOMAIN_DIR = "jclouds.libvirt.domain.dir";
|
||||
}
|
||||
|
||||
|
||||
//public static final String PROPERTY_AUTH_TAG = "jclouds.aws.auth.tag";
|
||||
//public static final String PROPERTY_HEADER_TAG = "jclouds.aws.header.tag";
|
|
@ -0,0 +1,113 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.collect.Memoized;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.TemplateBuilder;
|
||||
import org.jclouds.compute.internal.BaseComputeService;
|
||||
import org.jclouds.compute.options.TemplateOptions;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||
import org.jclouds.compute.strategy.ResumeNodeStrategy;
|
||||
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.compute.strategy.SuspendNodeStrategy;
|
||||
import org.jclouds.compute.util.ComputeUtils;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import com.vmware.vim25.mo.ServiceInstance;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author andrea.turli
|
||||
*
|
||||
*/
|
||||
@Singleton
|
||||
public class ViComputeService extends BaseComputeService {
|
||||
|
||||
private final ServiceInstance client;
|
||||
|
||||
@Inject
|
||||
protected ViComputeService(ComputeServiceContext context,
|
||||
Map<String, Credentials> credentialStore,
|
||||
@Memoized Supplier<Set<? extends Image>> images,
|
||||
@Memoized Supplier<Set<? extends Hardware>> hardwareProfiles,
|
||||
@Memoized Supplier<Set<? extends Location>> locations,
|
||||
ListNodesStrategy listNodesStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy,
|
||||
RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
||||
RebootNodeStrategy rebootNodeStrategy,
|
||||
DestroyNodeStrategy destroyNodeStrategy,
|
||||
ResumeNodeStrategy resumeNodeStrategy,
|
||||
SuspendNodeStrategy suspendNodeStrategy,
|
||||
Provider<TemplateBuilder> templateBuilderProvider,
|
||||
Provider<TemplateOptions> templateOptionsProvider,
|
||||
@Named("NODE_RUNNING") Predicate<NodeMetadata> nodeRunning,
|
||||
@Named("NODE_TERMINATED") Predicate<NodeMetadata> nodeTerminated,
|
||||
@Named("NODE_SUSPENDED") Predicate<NodeMetadata> nodeSuspended, ComputeUtils utils,
|
||||
Timeouts timeouts,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
|
||||
ServiceInstance client) {
|
||||
super(context, credentialStore, images, hardwareProfiles, locations,
|
||||
listNodesStrategy, getNodeMetadataStrategy,
|
||||
runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
|
||||
resumeNodeStrategy, suspendNodeStrategy, templateBuilderProvider,
|
||||
templateOptionsProvider, nodeRunning, nodeTerminated, nodeSuspended,
|
||||
utils, timeouts, executor);
|
||||
|
||||
this.client = client;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyNode(String id) {
|
||||
super.destroyNode(id);
|
||||
}
|
||||
|
||||
protected <T> T propogate(Exception e) {
|
||||
Throwables.propagate(e);
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute;
|
||||
|
||||
import static org.jclouds.vsphere.ViConstants.PROPERTY_LIBVIRT_DOMAIN_DIR;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
|
||||
import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
|
||||
import org.jclouds.vsphere.Datacenter;
|
||||
import org.jclouds.vsphere.Image;
|
||||
import org.jclouds.vsphere.compute.domain.ViComputeServiceContextModule;
|
||||
|
||||
import com.google.inject.Module;
|
||||
import com.vmware.vim25.mo.VirtualMachine;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ViComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder {
|
||||
|
||||
public ViComputeServiceContextBuilder(Properties props) {
|
||||
super(props);
|
||||
|
||||
if (!properties.containsKey(PROPERTY_LIBVIRT_DOMAIN_DIR))
|
||||
properties.setProperty(PROPERTY_LIBVIRT_DOMAIN_DIR, "/etc/libvirt/qemu");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(createContextModule());
|
||||
}
|
||||
|
||||
public StandaloneComputeServiceContextModule<VirtualMachine, VirtualMachine, Image, Datacenter> createContextModule() {
|
||||
return new ViComputeServiceContextModule();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ViComputeServiceContextSpec extends RestContextSpec<ComputeService, ComputeService> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ViComputeServiceContextSpec(String endpoint, String identity, String credential, Iterable<Module> modules) {
|
||||
super("vsphere", endpoint, "1", identity, credential, ComputeService.class, ComputeService.class,
|
||||
PropertiesBuilder.class, (Class) ViComputeServiceContextBuilder.class, modules);
|
||||
}
|
||||
|
||||
public ViComputeServiceContextSpec(String endpoint, String identity, String credential) {
|
||||
this(endpoint, identity, credential, ImmutableSet.<Module>of());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.vsphere.ViConstants.PROPERTY_LIBVIRT_DOMAIN_DIR;
|
||||
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_SUSPENDED;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
|
||||
/**
|
||||
* Builds properties used in Libvirt Clients
|
||||
*
|
||||
* @author Andrea Turli
|
||||
*/
|
||||
public class ViPropertiesBuilder extends PropertiesBuilder {
|
||||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_LIBVIRT_DOMAIN_DIR, "/etc/libvirt/qemu");
|
||||
|
||||
properties.setProperty(PROPERTY_TIMEOUT_NODE_SUSPENDED, 120 * 1000 + "");
|
||||
// auth fail sometimes happens in EC2, as the rc.local script that injects the
|
||||
// authorized key executes after ssh has started
|
||||
properties.setProperty("jclouds.ssh.max_retries", "7");
|
||||
properties.setProperty("jclouds.ssh.retryable_messages",
|
||||
"Auth fail,invalid data,End of IO Stream Read,Connection reset,socket is not established");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public ViPropertiesBuilder(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public ViPropertiesBuilder() {
|
||||
super();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute.domain;
|
||||
|
||||
import static org.jclouds.vsphere.ViConstants.PROPERTY_LIBVIRT_DOMAIN_DIR;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.compute.ComputeServiceAdapter;
|
||||
import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.TemplateBuilder;
|
||||
import org.jclouds.compute.suppliers.DefaultLocationSupplier;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.rest.annotations.Provider;
|
||||
import org.jclouds.vsphere.Datacenter;
|
||||
import org.jclouds.vsphere.Image;
|
||||
import org.jclouds.vsphere.compute.functions.DatacenterToLocation;
|
||||
import org.jclouds.vsphere.compute.functions.ViImageToImage;
|
||||
import org.jclouds.vsphere.compute.functions.VirtualMachineToHardware;
|
||||
import org.jclouds.vsphere.compute.functions.VirtualMachineToNodeMetadata;
|
||||
import org.jclouds.vsphere.compute.strategy.ViComputeServiceAdapter;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.name.Names;
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import com.vmware.vim25.mo.ServiceInstance;
|
||||
import com.vmware.vim25.mo.VirtualMachine;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ViComputeServiceContextModule extends
|
||||
StandaloneComputeServiceContextModule<VirtualMachine, VirtualMachine, Image, Datacenter> {
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
bind(new TypeLiteral<ComputeServiceAdapter<VirtualMachine, VirtualMachine, Image, Datacenter>>() {
|
||||
}).to(ViComputeServiceAdapter.class);
|
||||
bind(new TypeLiteral<Supplier<Location>>() {
|
||||
}).to(DefaultLocationSupplier.class);
|
||||
bind(new TypeLiteral<Function<VirtualMachine, NodeMetadata>>() {
|
||||
}).to(VirtualMachineToNodeMetadata.class);
|
||||
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
|
||||
}).to(ViImageToImage.class);
|
||||
bind(new TypeLiteral<Function<VirtualMachine, Hardware>>() {
|
||||
}).to(VirtualMachineToHardware.class);
|
||||
bind(new TypeLiteral<Function<Datacenter, Location>>() {
|
||||
}).to(DatacenterToLocation.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected ServiceInstance createConnection(@Provider URI endpoint, @Named(Constants.PROPERTY_IDENTITY) String identity,
|
||||
@Named(Constants.PROPERTY_CREDENTIAL) String credential) throws RemoteException, MalformedURLException {
|
||||
System.out.println(endpoint);
|
||||
System.out.println(identity);
|
||||
System.out.println(credential);
|
||||
return new ServiceInstance(endpoint.toURL(), identity, credential, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
||||
String domainDir = injector.getInstance(Key.get(String.class, Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
|
||||
String hardwareId = searchForHardwareIdInDomainDir(domainDir);
|
||||
String image = searchForImageIdInDomainDir(domainDir);
|
||||
return template.hardwareId(hardwareId).imageId(image) ;
|
||||
}
|
||||
|
||||
|
||||
private String searchForImageIdInDomainDir(String domainDir) {
|
||||
// TODO
|
||||
return "1";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String searchForHardwareIdInDomainDir(String domainDir) {
|
||||
|
||||
Collection<File> xmlDomains = FileUtils.listFiles( new File(domainDir), new WildcardFileFilter("*.xml"), null);
|
||||
String uuid = "";
|
||||
try {
|
||||
String fromXML = Files.toString(Iterables.get(xmlDomains, 0), Charsets.UTF_8);
|
||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
||||
uuid = builder.xpathFind("/domain/uuid").getElement().getTextContent();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SAXException e) {
|
||||
e.printStackTrace();
|
||||
} catch (XPathExpressionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Map<String, URI> regions = newLinkedHashMap();
|
||||
for (String region : Splitter.on(',').split(regionString)) {
|
||||
regions.put(
|
||||
region,
|
||||
URI.create(injector.getInstance(Key.get(String.class,
|
||||
Names.named(Constants.PROPERTY_ENDPOINT + "." + region)))));
|
||||
}
|
||||
return regions;
|
||||
*/
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute.functions;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.vsphere.Datacenter;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class DatacenterToLocation implements Function<Datacenter, Location> {
|
||||
|
||||
@Override
|
||||
public Location apply(Datacenter from) {
|
||||
return new LocationImpl(LocationScope.ZONE, from.id + "", from.name, null);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute.functions;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.vsphere.Datacenter;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class LibvirtNodeToLocation implements Function<Datacenter, Location> {
|
||||
|
||||
@Override
|
||||
public Location apply(Datacenter from) {
|
||||
return new LocationImpl(LocationScope.ZONE, from.id + "", from.name, null);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute.functions;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.ImageBuilder;
|
||||
import org.jclouds.compute.domain.OperatingSystemBuilder;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ViImageToImage implements Function<org.jclouds.vsphere.Image, Image> {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Override
|
||||
public Image apply(org.jclouds.vsphere.Image from) {
|
||||
|
||||
ImageBuilder builder = new ImageBuilder();
|
||||
builder.ids(from.id + "");
|
||||
builder.name(from.name);
|
||||
builder.description(from.name);
|
||||
|
||||
OsFamily family = null;
|
||||
try {
|
||||
family = OsFamily.fromValue(from.name);
|
||||
builder.operatingSystem(new OperatingSystemBuilder().name(from.name).family(family).description(from.name).build());
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.debug("<< didn't match os(%s)", from);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute.functions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpression;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.HardwareBuilder;
|
||||
import org.jclouds.compute.domain.Processor;
|
||||
import org.jclouds.compute.domain.Volume;
|
||||
import org.jclouds.compute.domain.internal.VolumeImpl;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import com.vmware.vim25.mo.VirtualMachine;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class VirtualMachineToHardware implements Function<VirtualMachine, Hardware> {
|
||||
|
||||
@Override
|
||||
public Hardware apply(VirtualMachine from) {
|
||||
HardwareBuilder builder = new HardwareBuilder();
|
||||
|
||||
builder.id(from.getMOR().get_value() + "");
|
||||
builder.providerId(from.getMOR().get_value() + "");
|
||||
builder.name(from.getName());
|
||||
List<Processor> processors = Lists.newArrayList();
|
||||
for (int i = 0; i < from.getConfig().getHardware().getNumCPU(); i++) {
|
||||
processors.add(new Processor(i + 1, 1));
|
||||
}
|
||||
builder.processors(processors);
|
||||
|
||||
builder.ram((int) from.getConfig().getHardware().getMemoryMB());
|
||||
List<Volume> volumes = Lists.newArrayList();
|
||||
|
||||
/*
|
||||
XMLBuilder xmlBuilder = XMLBuilder.parse(new InputSource(new StringReader(from.getXMLDesc(0))));
|
||||
Document doc = xmlBuilder.getDocument();
|
||||
XPathExpression expr = XPathFactory.newInstance().newXPath().compile("//devices/disk[@device='disk']/source/@file");
|
||||
NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
|
||||
String diskFileName = nodes.item(0).getNodeValue();
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
StorageVol storageVol = from.getConnect().storageVolLookupByPath(diskFileName);
|
||||
String id = storageVol.getKey();
|
||||
float size = new Long(storageVol.getInfo().capacity).floatValue();
|
||||
volumes.add(new VolumeImpl(id, Volume.Type.LOCAL, size, null, true, false));
|
||||
}
|
||||
*/
|
||||
|
||||
// TODO
|
||||
builder.volumes((List<Volume>) volumes);
|
||||
Float size = new Float(21345);
|
||||
String id = "dglffdbdflmb";
|
||||
volumes.add(new VolumeImpl(id, Volume.Type.LOCAL, size, null, true, false));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
protected <T> T propagate(Exception e) {
|
||||
Throwables.propagate(e);
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute.functions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.collect.FindResourceInSet;
|
||||
import org.jclouds.collect.Memoized;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.compute.domain.OperatingSystemBuilder;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.Location;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.vmware.vim25.VirtualMachinePowerState;
|
||||
import com.vmware.vim25.mo.VirtualMachine;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, NodeMetadata> {
|
||||
|
||||
public static final Map<VirtualMachinePowerState, NodeState> domainStateToNodeState =
|
||||
ImmutableMap.<VirtualMachinePowerState, NodeState> builder()
|
||||
.put(VirtualMachinePowerState.poweredOn, NodeState.RUNNING)//
|
||||
//.put(VirtualMachinePowerState.suspended, NodeState.PENDING)//
|
||||
.put(VirtualMachinePowerState.suspended, NodeState.SUSPENDED)//
|
||||
.put(VirtualMachinePowerState.poweredOff, NodeState.TERMINATED)//
|
||||
.build();
|
||||
|
||||
private final Function<VirtualMachine, Hardware> findHardwareForDomain;
|
||||
private final FindLocationForDomain findLocationForDomain;
|
||||
private final FindImageForDomain findImageForDomain;
|
||||
private final Map<String, Credentials> credentialStore;
|
||||
|
||||
@Inject
|
||||
VirtualMachineToNodeMetadata(Map<String, Credentials> credentialStore, Function<VirtualMachine, Hardware> findHardwareForDomain,
|
||||
FindLocationForDomain findLocationForDomain, FindImageForDomain findImageForDomain) {
|
||||
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
||||
this.findHardwareForDomain = checkNotNull(findHardwareForDomain, "findHardwareForDomain");
|
||||
this.findLocationForDomain = checkNotNull(findLocationForDomain, "findLocationForDomain");
|
||||
this.findImageForDomain = checkNotNull(findImageForDomain, "findImageForDomain");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata apply(VirtualMachine from) {
|
||||
|
||||
// convert the result object to a jclouds NodeMetadata
|
||||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||
try {
|
||||
builder.id(from.getMOR().get_value() + "");
|
||||
builder.providerId(from.getConfig().getLocationId() + "");
|
||||
builder.name(from.getName());
|
||||
builder.location(findLocationForDomain.apply(from));
|
||||
builder.tag(parseTagFromName(from.getName()));
|
||||
|
||||
builder.operatingSystem(new OperatingSystemBuilder().description(from.getConfig().getGuestFullName()).build());
|
||||
builder.hardware(findHardwareForDomain.apply(from));
|
||||
|
||||
builder.state(domainStateToNodeState.get(from.getRuntime().getPowerState()));
|
||||
// builder.publicAddresses(ImmutableSet.<String> of(from.publicAddress));
|
||||
// builder.privateAddresses(ImmutableSet.<String> of(from.privateAddress));
|
||||
builder.credentials(credentialStore.get("node#" + from.getMOR().get_value()));
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class FindImageForDomain extends FindResourceInSet<VirtualMachine, Image> {
|
||||
|
||||
@Inject
|
||||
public FindImageForDomain(@Memoized Supplier<Set<? extends Image>> hardware) {
|
||||
super(hardware);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(VirtualMachine from, Image input) {
|
||||
// TODO
|
||||
// return input.getProviderId().equals(from.imageId + "");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class FindLocationForDomain extends FindResourceInSet<VirtualMachine, Location> {
|
||||
|
||||
@Inject
|
||||
public FindLocationForDomain(@Memoized Supplier<Set<? extends Location>> hardware) {
|
||||
super(hardware);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(VirtualMachine from, Location input) {
|
||||
// TODO
|
||||
// return input.getId().equals(from.datacenter + "");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,316 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute.strategy;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.vsphere.ViConstants.PROPERTY_LIBVIRT_DOMAIN_DIR;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.compute.ComputeServiceAdapter;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.vsphere.Datacenter;
|
||||
import org.jclouds.vsphere.Image;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.name.Named;
|
||||
import com.vmware.vim25.InvalidProperty;
|
||||
import com.vmware.vim25.RuntimeFault;
|
||||
import com.vmware.vim25.mo.InventoryNavigator;
|
||||
import com.vmware.vim25.mo.ManagedEntity;
|
||||
import com.vmware.vim25.mo.ServiceInstance;
|
||||
import com.vmware.vim25.mo.VirtualMachine;
|
||||
|
||||
/**
|
||||
* defines the connection between the {@link Libvirt} implementation and the jclouds
|
||||
* {@link ComputeService}
|
||||
*
|
||||
*/
|
||||
@Singleton
|
||||
public class ViComputeServiceAdapter implements ComputeServiceAdapter<VirtualMachine, VirtualMachine, Image, Datacenter> {
|
||||
|
||||
private final ServiceInstance client;
|
||||
|
||||
@Inject
|
||||
public ViComputeServiceAdapter(ServiceInstance client) {
|
||||
this.client = checkNotNull(client, "client");
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachine runNodeWithTagAndNameAndStoreCredentials(String tag,
|
||||
String name, Template template,
|
||||
Map<String, Credentials> credentialStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public Domain runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template,
|
||||
Map<String, Credentials> credentialStore) {
|
||||
try {
|
||||
String domainName = tag;
|
||||
Domain domain = client.domainLookupByName(domainName);
|
||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(domain.getXMLDesc(0))));
|
||||
Document doc = builder.getDocument();
|
||||
String xpathString = "//devices/disk[@device='disk']/source/@file";
|
||||
XPathExpression expr = XPathFactory.newInstance().newXPath().compile(xpathString);
|
||||
NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
|
||||
String diskFileName = nodes.item(0).getNodeValue();
|
||||
StorageVol storageVol = client.storageVolLookupByPath(diskFileName);
|
||||
|
||||
// cloning volume
|
||||
String poolName = storageVol.storagePoolLookupByVolume().getName();
|
||||
StoragePool storagePool = client.storagePoolLookupByName(poolName);
|
||||
StorageVol clonedVol = null;
|
||||
boolean cloned = false;
|
||||
int retry = 0;
|
||||
while(!cloned && retry<10) {
|
||||
try {
|
||||
clonedVol = cloneVolume(storagePool, storageVol);
|
||||
cloned = true;
|
||||
} catch (LibvirtException e) {
|
||||
retry++;
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
// define Domain
|
||||
String xmlFinal = generateClonedDomainXML(domain.getXMLDesc(0), clonedVol);
|
||||
Domain newDomain = client.domainDefineXML(xmlFinal);
|
||||
newDomain.create();
|
||||
// store the credentials so that later functions can use them
|
||||
credentialStore.put(domain.getUUIDString() + "", new Credentials("identity", "credential"));
|
||||
return newDomain;
|
||||
} catch (LibvirtException e) {
|
||||
return propogate(e);
|
||||
} catch (Exception e) {
|
||||
return propogate(e);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachine> listHardwareProfiles() {
|
||||
return listNodes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Image> listImages() {
|
||||
/*
|
||||
int i = 1;
|
||||
try {
|
||||
String[] domains = client.listDefinedDomains();
|
||||
List<Image> images = Lists.newArrayList();
|
||||
for (String domainName : domains) {
|
||||
images.add(new Image(i++, domainName));
|
||||
}
|
||||
return images;
|
||||
} catch (Exception e) {
|
||||
return propogate(e);
|
||||
}
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualMachine> listNodes() {
|
||||
try {
|
||||
ManagedEntity[] vmEntities = new InventoryNavigator(client.getRootFolder()).searchManagedEntities("VirtualMachine");
|
||||
List<VirtualMachine> vms = Lists.newArrayList();
|
||||
for (ManagedEntity entity : vmEntities) {
|
||||
System.out.println(entity.getName());
|
||||
vms.add((VirtualMachine) entity);
|
||||
}
|
||||
return vms;
|
||||
} catch (InvalidProperty e) {
|
||||
return propogate(e);
|
||||
} catch (RuntimeFault e) {
|
||||
return propogate(e);
|
||||
} catch (RemoteException e) {
|
||||
return propogate(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Datacenter> listLocations() {
|
||||
ManagedEntity[] datacenterEntities;
|
||||
try {
|
||||
datacenterEntities = new InventoryNavigator(client.getRootFolder()).searchManagedEntities("Datacenter");
|
||||
List<Datacenter> datacenters = Lists.newArrayList();
|
||||
for (int i = 0; i< datacenterEntities.length; i++) {
|
||||
datacenters.add(new Datacenter(i, datacenterEntities[i].getName()));
|
||||
}
|
||||
return datacenters;
|
||||
} catch (InvalidProperty e) {
|
||||
return propogate(e);
|
||||
} catch (RuntimeFault e) {
|
||||
return propogate(e);
|
||||
} catch (RemoteException e) {
|
||||
return propogate(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachine getNode(String id) {
|
||||
VirtualMachine vm = null;
|
||||
/*
|
||||
try {
|
||||
d = client.domainLookupByUUIDString(id);
|
||||
} catch (LibvirtException e) {
|
||||
if (e.getMessage().indexOf("Domain not found: no domain with matching uuid") != -1)
|
||||
return null;
|
||||
propogate(e);
|
||||
}
|
||||
*/
|
||||
return vm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyNode(String id) {
|
||||
/*
|
||||
try {
|
||||
client.domainLookupByUUIDString(id).destroy();
|
||||
|
||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(
|
||||
client.domainLookupByUUIDString(id).getXMLDesc(0)
|
||||
)));
|
||||
String diskFileName = builder.xpathFind("//devices/disk[@device='disk']/source").getElement().getAttribute("file");
|
||||
StorageVol storageVol = client.storageVolLookupByPath(diskFileName);
|
||||
storageVol.delete(0);
|
||||
client.domainLookupByUUIDString(id).undefine();
|
||||
|
||||
} catch (LibvirtException e) {
|
||||
propogate(e);
|
||||
} catch (Exception e) {
|
||||
propogate(e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebootNode(String id) {
|
||||
/*
|
||||
try {
|
||||
client.domainLookupByUUIDString(id).reboot(0);
|
||||
} catch (LibvirtException e) {
|
||||
propogate(e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resumeNode(String id) {
|
||||
/*
|
||||
try {
|
||||
client.domainLookupByUUIDString(id).resume();
|
||||
} catch (LibvirtException e) {
|
||||
propogate(e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suspendNode(String id) {
|
||||
/*
|
||||
try {
|
||||
client.domainLookupByUUIDString(id).suspend();
|
||||
} catch (LibvirtException e) {
|
||||
propogate(e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected <T> T propogate(Exception e) {
|
||||
Throwables.propagate(e);
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
private static StorageVol cloneVolume(StoragePool storagePool, StorageVol from) throws LibvirtException,
|
||||
XPathExpressionException, ParserConfigurationException, SAXException, IOException, TransformerException {
|
||||
return storagePool.storageVolCreateXMLFrom(generateClonedVolumeXML(from.getXMLDesc(0)), from, 0);
|
||||
}
|
||||
|
||||
private static String generateClonedVolumeXML(String fromXML) throws ParserConfigurationException, SAXException,
|
||||
IOException, XPathExpressionException, TransformerException {
|
||||
|
||||
Properties outputProperties = generateOutputXMLProperties();
|
||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
||||
String nodeNamingConvention = "%s-%s";
|
||||
String tag = "-clone";
|
||||
String suffix = String.format(nodeNamingConvention, tag, Integer.toHexString(new SecureRandom().nextInt(4095)));
|
||||
builder.xpathFind("//volume/name").t(suffix);
|
||||
builder.xpathFind("//volume/key").t(suffix);
|
||||
builder.xpathFind("//volume/target/path").t(suffix);
|
||||
|
||||
return builder.asString(outputProperties);
|
||||
}
|
||||
|
||||
private static String generateClonedDomainXML(String fromXML, StorageVol clonedVol) throws ParserConfigurationException, SAXException,
|
||||
IOException, XPathExpressionException, TransformerException, LibvirtException {
|
||||
|
||||
Properties outputProperties = generateOutputXMLProperties();
|
||||
|
||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
||||
|
||||
String nodeNamingConvention = "%s-%s";
|
||||
String tag = "-clone";
|
||||
String suffix = String.format(nodeNamingConvention, tag, Integer.toHexString(new SecureRandom().nextInt(4095)));
|
||||
builder.xpathFind("//domain/name").t(suffix);
|
||||
// change uuid domain
|
||||
Element oldChild = builder.xpathFind("//domain/uuid").getElement();
|
||||
Node newNode = oldChild.cloneNode(true);
|
||||
newNode.getFirstChild().setNodeValue(UUID.randomUUID().toString());
|
||||
builder.getDocument().getDocumentElement().replaceChild(newNode, oldChild);
|
||||
|
||||
//String fromVolPath = builder.xpathFind("//domain/devices/disk/source").getElement().getAttribute("file");
|
||||
builder.xpathFind("//domain/devices/disk/source").a("file", clonedVol.getPath());
|
||||
// generate valid MAC address
|
||||
String fromMACaddress = builder.xpathFind("//domain/devices/interface/mac").getElement().getAttribute("address");
|
||||
String lastMACoctet = Integer.toHexString(new SecureRandom().nextInt(255));
|
||||
builder.xpathFind("//domain/devices/interface/mac").a("address",
|
||||
fromMACaddress.substring(0, fromMACaddress.lastIndexOf(":")+1) + lastMACoctet
|
||||
);
|
||||
return builder.asString(outputProperties);
|
||||
}
|
||||
|
||||
private static Properties generateOutputXMLProperties() {
|
||||
Properties outputProperties = new Properties();
|
||||
// Explicitly identify the output as an XML document
|
||||
outputProperties.put(javax.xml.transform.OutputKeys.METHOD, "xml");
|
||||
// Pretty-print the XML output (doesn't work in all cases)
|
||||
outputProperties.put(javax.xml.transform.OutputKeys.INDENT, "yes");
|
||||
// Get 2-space indenting when using the Apache transformer
|
||||
outputProperties.put("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||
return outputProperties;
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.jclouds.vsphere.compute;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.vsphere.compute.ViComputeServiceContextBuilder;
|
||||
import org.jclouds.vsphere.compute.ViComputeServiceContextSpec;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author andrea.turli
|
||||
*
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ViComputeServiceContextBuilderTest {
|
||||
|
||||
@Test
|
||||
public void testCreateContextModule() {
|
||||
assertNotNull(new ViComputeServiceContextBuilder(new Properties()).createContextModule());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCanBuildWithComputeService() {
|
||||
ComputeServiceContext context = new ComputeServiceContextFactory()
|
||||
.createContext(new ViComputeServiceContextSpec("https://10.38.102.196/sdk", "Administrator", "41.U17Sh"));
|
||||
context.getComputeService().listNodes();
|
||||
context.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.vsphere.compute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.vsphere.compute.ViComputeServiceContextSpec;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "vsphere.ViExperimentLiveTest")
|
||||
public class ViExperimentLiveTest {
|
||||
protected String provider = "vsphere";
|
||||
protected String identity;
|
||||
protected String credential;
|
||||
protected String endpoint;
|
||||
protected String apiversion;
|
||||
|
||||
@BeforeClass
|
||||
protected void setupCredentials() {
|
||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||
credential = System.getProperty("test." + provider + ".credential");
|
||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndExperiment() {
|
||||
ComputeServiceContext context = null;
|
||||
try {
|
||||
context = new ComputeServiceContextFactory().createContext(new ViComputeServiceContextSpec(
|
||||
endpoint, identity, credential));
|
||||
context.getComputeService().listNodes();
|
||||
|
||||
|
||||
/*
|
||||
* /* System.out.println("images " + context.getComputeService().listImages());
|
||||
* System.out.println("nodes " + context.getComputeService().listNodes());
|
||||
* System.out.println("hardware profiles " +
|
||||
* context.getComputeService().listHardwareProfiles());
|
||||
*/
|
||||
|
||||
|
||||
/* Template defaultTemplate = context.getComputeService().templateBuilder()
|
||||
.hardwareId("d106ae67-5a1b-8f91-b311-83c93bcb0a1f").imageId("1") //.locationId("")
|
||||
.build();*/
|
||||
|
||||
|
||||
/*
|
||||
* We will probably make a default template out of properties at some point You can control
|
||||
* the default template via overriding a method in standalonecomputeservicexontextmodule
|
||||
*/
|
||||
|
||||
Set<? extends NodeMetadata> nodeMetadataSet = context.getComputeService().runNodesWithTag("tty", 1);
|
||||
for (NodeMetadata nodeMetadata : nodeMetadataSet) {
|
||||
/*
|
||||
* context.getComputeService().suspendNode(nodeMetadata.getId());
|
||||
* context.getComputeService().resumeNode(nodeMetadata.getId());
|
||||
*/
|
||||
context.getComputeService().destroyNode(nodeMetadata.getId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (context != null)
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
|
||||
Copyright (C) 2009 Cloud Conscious, LLC.
|
||||
<info@cloudconscious.com>
|
||||
|
||||
====================================================================
|
||||
Licensed 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.
|
||||
====================================================================
|
||||
-->
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
|
||||
<!--
|
||||
For more configuration infromation and examples see the Apache
|
||||
Log4j website: http://logging.apache.org/log4j/
|
||||
-->
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||
debug="false">
|
||||
|
||||
<!-- A time/date based rolling appender -->
|
||||
<appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="File" value="target/test-data/jclouds-wire.log" />
|
||||
<param name="Append" value="true" />
|
||||
|
||||
<!-- Rollover at midnight each day -->
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||
|
||||
<param name="Threshold" value="TRACE" />
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
|
||||
<!--
|
||||
The full pattern: Date MS Priority [Category]
|
||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||
-->
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- A time/date based rolling appender -->
|
||||
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="File" value="target/test-data/jclouds.log" />
|
||||
<param name="Append" value="true" />
|
||||
|
||||
<!-- Rollover at midnight each day -->
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||
|
||||
<param name="Threshold" value="TRACE" />
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
|
||||
<!--
|
||||
The full pattern: Date MS Priority [Category]
|
||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||
-->
|
||||
</layout>
|
||||
</appender>
|
||||
<!-- A time/date based rolling appender -->
|
||||
<appender name="COMPUTEFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="File" value="target/test-data/jclouds-compute.log" />
|
||||
<param name="Append" value="true" />
|
||||
|
||||
<!-- Rollover at midnight each day -->
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||
|
||||
<param name="Threshold" value="TRACE" />
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
|
||||
<!--
|
||||
The full pattern: Date MS Priority [Category]
|
||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||
-->
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="ASYNCCOMPUTE" class="org.apache.log4j.AsyncAppender">
|
||||
<appender-ref ref="COMPUTEFILE" />
|
||||
</appender>
|
||||
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
|
||||
<appender-ref ref="FILE" />
|
||||
</appender>
|
||||
|
||||
<appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
|
||||
<appender-ref ref="WIREFILE" />
|
||||
</appender>
|
||||
|
||||
<!-- ================ -->
|
||||
<!-- Limit categories -->
|
||||
<!-- ================ -->
|
||||
|
||||
<category name="org.jclouds">
|
||||
<priority value="DEBUG" />
|
||||
<appender-ref ref="ASYNC" />
|
||||
</category>
|
||||
|
||||
<category name="jclouds.headers">
|
||||
<priority value="DEBUG" />
|
||||
<appender-ref ref="ASYNCWIRE" />
|
||||
</category>
|
||||
<category name="jclouds.wire">
|
||||
<priority value="DEBUG" />
|
||||
<appender-ref ref="ASYNCWIRE" />
|
||||
</category>
|
||||
|
||||
<category name="jclouds.compute">
|
||||
<priority value="TRACE" />
|
||||
<appender-ref ref="ASYNCCOMPUTE" />
|
||||
</category>
|
||||
<!-- ======================= -->
|
||||
<!-- Setup the Root category -->
|
||||
<!-- ======================= -->
|
||||
|
||||
<root>
|
||||
<priority value="DEBUG" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
Loading…
Reference in New Issue