mirror of https://github.com/apache/jclouds.git
Line ending changes and POM formatting.
This commit is contained in:
parent
d0dd757cfb
commit
550384bd22
|
@ -1,79 +1,79 @@
|
||||||
#set( $lcaseClientName = ${clientName.toLowerCase()} )
|
#set( $lcaseClientName = ${clientName.toLowerCase()} )
|
||||||
#set( $symbol_dollar = '$' )
|
#set( $symbol_dollar = '$' )
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
${symbol_dollar}HeadURL${symbol_dollar}
|
${symbol_dollar}HeadURL${symbol_dollar}
|
||||||
${symbol_dollar}Revision${symbol_dollar}
|
${symbol_dollar}Revision${symbol_dollar}
|
||||||
${symbol_dollar}Date${symbol_dollar}
|
${symbol_dollar}Date${symbol_dollar}
|
||||||
|
|
||||||
Copyright (C) 2009 Cloud Conscious, LLC <info@cloudconscious.com>
|
Copyright (C) 2009 Cloud Conscious, LLC <info@cloudconscious.com>
|
||||||
|
|
||||||
====================================================================
|
====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
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">
|
<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">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-project</artifactId>
|
<artifactId>jclouds-project</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<relativePath>../project/pom.xml</relativePath>
|
<relativePath>../project/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>${groupId}</groupId>
|
<groupId>${groupId}</groupId>
|
||||||
<artifactId>jclouds-${artifactId}</artifactId>
|
<artifactId>jclouds-${artifactId}</artifactId>
|
||||||
<name>jclouds ${clientName} core</name>
|
<name>jclouds ${clientName} core</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>jclouds components to access ${clientName}</description>
|
<description>jclouds components to access ${clientName}</description>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/${lcaseClientName}</connection>
|
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/${lcaseClientName}</connection>
|
||||||
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/${lcaseClientName}</developerConnection>
|
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/${lcaseClientName}</developerConnection>
|
||||||
<url>http://jclouds.googlecode.com/svn/trunk/${lcaseClientName}</url>
|
<url>http://jclouds.googlecode.com/svn/trunk/${lcaseClientName}</url>
|
||||||
</scm>
|
</scm>
|
||||||
<properties>
|
<properties>
|
||||||
<jclouds.test.user>${clientUser}</jclouds.test.user>
|
<jclouds.test.user>${clientUser}</jclouds.test.user>
|
||||||
<jclouds.test.key>${clientPassword}</jclouds.test.key>
|
<jclouds.test.key>${clientPassword}</jclouds.test.key>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${symbol_dollar}{project.groupId}</groupId>
|
<groupId>${symbol_dollar}{project.groupId}</groupId>
|
||||||
<artifactId>jclouds-core</artifactId>
|
<artifactId>jclouds-core</artifactId>
|
||||||
<version>${symbol_dollar}{project.version}</version>
|
<version>${symbol_dollar}{project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${symbol_dollar}{project.groupId}</groupId>
|
<groupId>${symbol_dollar}{project.groupId}</groupId>
|
||||||
<artifactId>jclouds-core</artifactId>
|
<artifactId>jclouds-core</artifactId>
|
||||||
<version>${symbol_dollar}{project.version}</version>
|
<version>${symbol_dollar}{project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>1.2.14</version>
|
<version>1.2.14</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${symbol_dollar}{project.groupId}</groupId>
|
<groupId>${symbol_dollar}{project.groupId}</groupId>
|
||||||
<artifactId>jclouds-log4j</artifactId>
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
<version>${symbol_dollar}{project.version}</version>
|
<version>${symbol_dollar}{project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,125 +1,125 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.compute;
|
package org.jclouds.aws.ec2.compute;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2Client;
|
import org.jclouds.aws.ec2.EC2Client;
|
||||||
import org.jclouds.aws.ec2.compute.config.EC2ComputeServiceContextModule.GetRegionFromNodeOrDefault;
|
import org.jclouds.aws.ec2.compute.config.EC2ComputeServiceContextModule.GetRegionFromNodeOrDefault;
|
||||||
import org.jclouds.aws.ec2.compute.domain.KeyPairCredentials;
|
import org.jclouds.aws.ec2.compute.domain.KeyPairCredentials;
|
||||||
import org.jclouds.aws.ec2.compute.domain.PortsRegionTag;
|
import org.jclouds.aws.ec2.compute.domain.PortsRegionTag;
|
||||||
import org.jclouds.aws.ec2.compute.domain.RegionTag;
|
import org.jclouds.aws.ec2.compute.domain.RegionTag;
|
||||||
import org.jclouds.aws.ec2.domain.RunningInstance;
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.internal.BaseComputeService;
|
import org.jclouds.compute.internal.BaseComputeService;
|
||||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||||
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
||||||
import org.jclouds.compute.util.ComputeUtils;
|
import org.jclouds.compute.util.ComputeUtils;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class EC2ComputeService extends BaseComputeService {
|
public class EC2ComputeService extends BaseComputeService {
|
||||||
protected final EC2Client ec2Client;
|
protected final EC2Client ec2Client;
|
||||||
protected final GetRegionFromNodeOrDefault getRegionFromNodeOrDefault;
|
protected final GetRegionFromNodeOrDefault getRegionFromNodeOrDefault;
|
||||||
protected final Map<RegionTag, KeyPairCredentials> credentialsMap;
|
protected final Map<RegionTag, KeyPairCredentials> credentialsMap;
|
||||||
protected final Map<PortsRegionTag, String> securityGroupMap;
|
protected final Map<PortsRegionTag, String> securityGroupMap;
|
||||||
protected final Predicate<RunningInstance> instanceStateTerminated;
|
protected final Predicate<RunningInstance> instanceStateTerminated;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2ComputeService(ComputeServiceContext context,
|
protected EC2ComputeService(ComputeServiceContext context,
|
||||||
Provider<Map<String, ? extends Image>> images,
|
Provider<Map<String, ? extends Image>> images,
|
||||||
Provider<Map<String, ? extends Size>> sizes,
|
Provider<Map<String, ? extends Size>> sizes,
|
||||||
Provider<Map<String, ? extends Location>> locations,
|
Provider<Map<String, ? extends Location>> locations,
|
||||||
ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
|
ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
|
||||||
RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
||||||
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
||||||
Provider<TemplateBuilder> templateBuilderProvider, ComputeUtils utils,
|
Provider<TemplateBuilder> templateBuilderProvider, ComputeUtils utils,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, EC2Client ec2Client,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, EC2Client ec2Client,
|
||||||
GetRegionFromNodeOrDefault getRegionFromNodeOrDefault,
|
GetRegionFromNodeOrDefault getRegionFromNodeOrDefault,
|
||||||
Map<RegionTag, KeyPairCredentials> credentialsMap,
|
Map<RegionTag, KeyPairCredentials> credentialsMap,
|
||||||
Map<PortsRegionTag, String> securityGroupMap,
|
Map<PortsRegionTag, String> securityGroupMap,
|
||||||
@Named("TERMINATED") Predicate<RunningInstance> instanceStateTerminated) {
|
@Named("TERMINATED") Predicate<RunningInstance> instanceStateTerminated) {
|
||||||
super(context, images, sizes, locations, listNodesStrategy, getNodeMetadataStrategy,
|
super(context, images, sizes, locations, listNodesStrategy, getNodeMetadataStrategy,
|
||||||
runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
|
runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
|
||||||
templateBuilderProvider, utils, executor);
|
templateBuilderProvider, utils, executor);
|
||||||
this.ec2Client = ec2Client;
|
this.ec2Client = ec2Client;
|
||||||
this.getRegionFromNodeOrDefault = getRegionFromNodeOrDefault;
|
this.getRegionFromNodeOrDefault = getRegionFromNodeOrDefault;
|
||||||
this.credentialsMap = credentialsMap;
|
this.credentialsMap = credentialsMap;
|
||||||
this.securityGroupMap = securityGroupMap;
|
this.securityGroupMap = securityGroupMap;
|
||||||
this.instanceStateTerminated = instanceStateTerminated;
|
this.instanceStateTerminated = instanceStateTerminated;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteSecurityGroup(Region region, String tag) {
|
private void deleteSecurityGroup(Region region, String tag) {
|
||||||
if (ec2Client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, tag).size() > 0) {
|
if (ec2Client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, tag).size() > 0) {
|
||||||
logger.debug(">> deleting securityGroup(%s)", tag);
|
logger.debug(">> deleting securityGroup(%s)", tag);
|
||||||
ec2Client.getSecurityGroupServices().deleteSecurityGroupInRegion(region, tag);
|
ec2Client.getSecurityGroupServices().deleteSecurityGroupInRegion(region, tag);
|
||||||
securityGroupMap.remove(new PortsRegionTag(region, tag, null)); // TODO: test this clear
|
securityGroupMap.remove(new PortsRegionTag(region, tag, null)); // TODO: test this clear
|
||||||
// happens
|
// happens
|
||||||
logger.debug("<< deleted securityGroup(%s)", tag);
|
logger.debug("<< deleted securityGroup(%s)", tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteKeyPair(Region region, String tag) {
|
private void deleteKeyPair(Region region, String tag) {
|
||||||
if (ec2Client.getKeyPairServices().describeKeyPairsInRegion(region, tag).size() > 0) {
|
if (ec2Client.getKeyPairServices().describeKeyPairsInRegion(region, tag).size() > 0) {
|
||||||
logger.debug(">> deleting keyPair(%s)", tag);
|
logger.debug(">> deleting keyPair(%s)", tag);
|
||||||
ec2Client.getKeyPairServices().deleteKeyPairInRegion(region, tag);
|
ec2Client.getKeyPairServices().deleteKeyPairInRegion(region, tag);
|
||||||
credentialsMap.remove(new RegionTag(region, tag)); // TODO: test this clear happens
|
credentialsMap.remove(new RegionTag(region, tag)); // TODO: test this clear happens
|
||||||
logger.debug("<< deleted keyPair(%s)", tag);
|
logger.debug("<< deleted keyPair(%s)", tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyNodesWithTag(String tag) {
|
public void destroyNodesWithTag(String tag) {
|
||||||
super.destroyNodesWithTag(tag);
|
super.destroyNodesWithTag(tag);
|
||||||
Iterable<? extends NodeMetadata> nodes = Iterables.filter(getNodesWithTag(tag).values(),
|
Iterable<? extends NodeMetadata> nodes = Iterables.filter(getNodesWithTag(tag).values(),
|
||||||
new Predicate<NodeMetadata>() {
|
new Predicate<NodeMetadata>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(NodeMetadata input) {
|
public boolean apply(NodeMetadata input) {
|
||||||
return input.getState() == NodeState.TERMINATED;
|
return input.getState() == NodeState.TERMINATED;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (Iterables.size(nodes) > 0) {
|
if (Iterables.size(nodes) > 0) {
|
||||||
Region region = getRegionFromNodeOrDefault.apply(Iterables.get(nodes, 0));
|
Region region = getRegionFromNodeOrDefault.apply(Iterables.get(nodes, 0));
|
||||||
deleteKeyPair(region, tag);
|
deleteKeyPair(region, tag);
|
||||||
deleteSecurityGroup(region, tag);
|
deleteSecurityGroup(region, tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,8 +28,8 @@
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>jclouds-speedtest-sqs</artifactId>
|
<artifactId>jclouds-speedtest-sqs</artifactId>
|
||||||
<name>tests speed of sqs across regions</name>
|
<name>Speed tests of SQS across regions</name>
|
||||||
<description>creates a queue in all amazon regions and then tests performance against it</description>
|
<description>Creates a queue in all amazon regions and then tests performance against it</description>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
|
|
|
@ -1,155 +1,155 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute;
|
package org.jclouds.compute;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.internal.BaseComputeService;
|
import org.jclouds.compute.internal.BaseComputeService;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides portable access to launching compute instances.
|
* Provides portable access to launching compute instances.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(BaseComputeService.class)
|
@ImplementedBy(BaseComputeService.class)
|
||||||
public interface ComputeService {
|
public interface ComputeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a reference to the context that created this ComputeService.
|
* @return a reference to the context that created this ComputeService.
|
||||||
*/
|
*/
|
||||||
ComputeServiceContext getContext();
|
ComputeServiceContext getContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a new template builder for this service
|
* Makes a new template builder for this service
|
||||||
*/
|
*/
|
||||||
TemplateBuilder templateBuilder();
|
TemplateBuilder templateBuilder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The get sizes command shows you the options including virtual cpu count, memory, and disks.
|
* The get sizes command shows you the options including virtual cpu count, memory, and disks.
|
||||||
* cpu count is not a portable quantity across clouds, as they are measured differently. However,
|
* cpu count is not a portable quantity across clouds, as they are measured differently. However,
|
||||||
* it is a good indicator of relative speed within a cloud. memory is measured in megabytes and
|
* it is a good indicator of relative speed within a cloud. memory is measured in megabytes and
|
||||||
* disks in gigabytes.
|
* disks in gigabytes.
|
||||||
*
|
*
|
||||||
* @return a map of sizes by ID, conceding that in some clouds the "id" is not used.
|
* @return a map of sizes by ID, conceding that in some clouds the "id" is not used.
|
||||||
*/
|
*/
|
||||||
Map<String, ? extends Size> getSizes();
|
Map<String, ? extends Size> getSizes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Images define the operating system and metadata related to a node. In some clouds, Images are
|
* Images define the operating system and metadata related to a node. In some clouds, Images are
|
||||||
* bound to a specific region, and their identifiers are different across these regions. For this
|
* bound to a specific region, and their identifiers are different across these regions. For this
|
||||||
* reason, you should consider matching image requirements like operating system family with
|
* reason, you should consider matching image requirements like operating system family with
|
||||||
* TemplateBuilder as opposed to choosing an image explicitly. The getImages() command returns a
|
* TemplateBuilder as opposed to choosing an image explicitly. The getImages() command returns a
|
||||||
* map of images by id.
|
* map of images by id.
|
||||||
*/
|
*/
|
||||||
Map<String, ? extends Image> getImages();
|
Map<String, ? extends Image> getImages();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* all nodes available to the current user by id. If possible, the returned set will include
|
* all nodes available to the current user by id. If possible, the returned set will include
|
||||||
* {@link NodeMetadata} objects.
|
* {@link NodeMetadata} objects.
|
||||||
*/
|
*/
|
||||||
Map<String, ? extends ComputeMetadata> getNodes();
|
Map<String, ? extends ComputeMetadata> getNodes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The get locations command returns all the valid locations for nodes. A location has a scope,
|
* The get locations command returns all the valid locations for nodes. A location has a scope,
|
||||||
* which is typically region or zone. A region is a general area, like eu-west, where a zone is
|
* which is typically region or zone. A region is a general area, like eu-west, where a zone is
|
||||||
* similar to a datacenter. If a location has a parent, that implies it is within that location.
|
* similar to a datacenter. If a location has a parent, that implies it is within that location.
|
||||||
* For example a location can be a rack, whose parent is likely to be a zone.
|
* For example a location can be a rack, whose parent is likely to be a zone.
|
||||||
*/
|
*/
|
||||||
Map<String, ? extends Location> getLocations();
|
Map<String, ? extends Location> getLocations();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* The compute api treats nodes as a group based on a tag you specify. Using this tag, you can
|
* The compute api treats nodes as a group based on a tag you specify. Using this tag, you can
|
||||||
* choose to operate one or many nodes as a logical unit without regard to the implementation
|
* choose to operate one or many nodes as a logical unit without regard to the implementation
|
||||||
* details of the cloud.
|
* details of the cloud.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* The set that is returned will include credentials you can use to ssh into the nodes. The "key"
|
* The set that is returned will include credentials you can use to ssh into the nodes. The "key"
|
||||||
* part of the credentials is either a password or a private key. You have to inspect the value
|
* part of the credentials is either a password or a private key. You have to inspect the value
|
||||||
* to determine this.
|
* to determine this.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* if (node.getCredentials().key.startsWith("-----BEGIN RSA PRIVATE KEY-----"))
|
* if (node.getCredentials().key.startsWith("-----BEGIN RSA PRIVATE KEY-----"))
|
||||||
* // it is a private key, not a password.
|
* // it is a private key, not a password.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* <p/>
|
* <p/>
|
||||||
* Note. if all you want to do is execute a script at bootup, you should consider use of the
|
* Note. if all you want to do is execute a script at bootup, you should consider use of the
|
||||||
* runscript option.
|
* runscript option.
|
||||||
* <p/>
|
* <p/>
|
||||||
* If resources such as security groups are needed, they will be reused or created for you.
|
* If resources such as security groups are needed, they will be reused or created for you.
|
||||||
* Inbound port 22 will always be opened up.
|
* Inbound port 22 will always be opened up.
|
||||||
*
|
*
|
||||||
* @param tag
|
* @param tag
|
||||||
* - common identifier to group nodes by, cannot contain hyphens
|
* - common identifier to group nodes by, cannot contain hyphens
|
||||||
* @param count
|
* @param count
|
||||||
* - how many to fire up.
|
* - how many to fire up.
|
||||||
* @param template
|
* @param template
|
||||||
* - how to configure the nodes
|
* - how to configure the nodes
|
||||||
* @return all of the nodes the api was able to launch in a running state.
|
* @return all of the nodes the api was able to launch in a running state.
|
||||||
*/
|
*/
|
||||||
Map<String, ? extends NodeMetadata> runNodesWithTag(String tag, int count, Template template);
|
Map<String, ? extends NodeMetadata> runNodesWithTag(String tag, int count, Template template);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* destroy the node. If it is the only node in a tag set, the dependent resources will also be
|
* destroy the node. If it is the only node in a tag set, the dependent resources will also be
|
||||||
* destroyed.
|
* destroyed.
|
||||||
*/
|
*/
|
||||||
void destroyNode(ComputeMetadata node);
|
void destroyNode(ComputeMetadata node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nodes which are tagged are treated as a logical set. Using the delete command, you can save
|
* nodes which are tagged are treated as a logical set. Using the delete command, you can save
|
||||||
* time by removing the nodes in parallel. When the last node in a set is destroyed, any indirect
|
* time by removing the nodes in parallel. When the last node in a set is destroyed, any indirect
|
||||||
* resources it uses, such as keypairs, are also destroyed.
|
* resources it uses, such as keypairs, are also destroyed.
|
||||||
*/
|
*/
|
||||||
void destroyNodesWithTag(String tag);
|
void destroyNodesWithTag(String tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reboot the node.
|
* reboot the node.
|
||||||
*/
|
*/
|
||||||
void rebootNode(ComputeMetadata node);
|
void rebootNode(ComputeMetadata node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nodes which are tagged are treated as a logical set. Using this command, you can save time by
|
* nodes which are tagged are treated as a logical set. Using this command, you can save time by
|
||||||
* rebooting the nodes in parallel.
|
* rebooting the nodes in parallel.
|
||||||
*/
|
*/
|
||||||
void rebootNodesWithTag(String tag);
|
void rebootNodesWithTag(String tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a node by its id
|
* Find a node by its id
|
||||||
*/
|
*/
|
||||||
NodeMetadata getNodeMetadata(ComputeMetadata node);
|
NodeMetadata getNodeMetadata(ComputeMetadata node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all nodes matching the tag.
|
* get all nodes matching the tag.
|
||||||
*
|
*
|
||||||
* @param tag
|
* @param tag
|
||||||
*/
|
*/
|
||||||
Map<String, ? extends NodeMetadata> getNodesWithTag(String tag);
|
Map<String, ? extends NodeMetadata> getNodesWithTag(String tag);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
6
pom.xml
6
pom.xml
|
@ -21,8 +21,8 @@
|
||||||
--><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">
|
--><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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>jclouds-project</artifactId>
|
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-project</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<relativePath>project/pom.xml</relativePath>
|
<relativePath>project/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
@ -49,8 +49,8 @@
|
||||||
<module>rimuhosting</module>
|
<module>rimuhosting</module>
|
||||||
<module>twitter</module>
|
<module>twitter</module>
|
||||||
<module>vcloud</module>
|
<module>vcloud</module>
|
||||||
<module>gogrid</module>
|
<module>gogrid</module>
|
||||||
</modules>
|
</modules>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -1,276 +1,276 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
package org.jclouds.tools.ant.taskdefs.compute;
|
package org.jclouds.tools.ant.taskdefs.compute;
|
||||||
|
|
||||||
import static org.jclouds.compute.util.ComputeUtils.isKeyAuth;
|
import static org.jclouds.compute.util.ComputeUtils.isKeyAuth;
|
||||||
import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.buildComputeMap;
|
import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.buildComputeMap;
|
||||||
import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.createTemplateFromElement;
|
import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.createTemplateFromElement;
|
||||||
import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.ipOrEmptyString;
|
import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.ipOrEmptyString;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import org.apache.tools.ant.Task;
|
import org.apache.tools.ant.Task;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.http.HttpUtils;
|
import org.jclouds.http.HttpUtils;
|
||||||
|
|
||||||
import com.google.common.base.CaseFormat;
|
import com.google.common.base.CaseFormat;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
public class ComputeTask extends Task {
|
public class ComputeTask extends Task {
|
||||||
|
|
||||||
private final Map<URI, ComputeServiceContext> computeMap;
|
private final Map<URI, ComputeServiceContext> computeMap;
|
||||||
private String provider;
|
private String provider;
|
||||||
private String actions;
|
private String actions;
|
||||||
private NodeElement nodeElement;
|
private NodeElement nodeElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* we don't have a reference to the project during the constructor, so we need to defer expansion
|
* we don't have a reference to the project during the constructor, so we need to defer expansion
|
||||||
* with a Provider.
|
* with a Provider.
|
||||||
*/
|
*/
|
||||||
private final Provider<Project> projectProvider = new Provider<Project>() {
|
private final Provider<Project> projectProvider = new Provider<Project>() {
|
||||||
@Override
|
@Override
|
||||||
public Project get() {
|
public Project get() {
|
||||||
return getProject();
|
return getProject();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public ComputeTask(@Nullable Map<URI, ComputeServiceContext> computeMap) {
|
public ComputeTask(@Nullable Map<URI, ComputeServiceContext> computeMap) {
|
||||||
this.computeMap = computeMap != null ? computeMap : buildComputeMap(projectProvider);
|
this.computeMap = computeMap != null ? computeMap : buildComputeMap(projectProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputeTask() throws IOException {
|
public ComputeTask() throws IOException {
|
||||||
this(null);
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Action {
|
public static enum Action {
|
||||||
CREATE, GET, LIST, LIST_DETAILS, DESTROY, LIST_IMAGES, LIST_SIZES, LIST_LOCATIONS
|
CREATE, GET, LIST, LIST_DETAILS, DESTROY, LIST_IMAGES, LIST_SIZES, LIST_LOCATIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* makes a connection to the compute service and invokes
|
* makes a connection to the compute service and invokes
|
||||||
*/
|
*/
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
ComputeServiceContext context = computeMap.get(HttpUtils.createUri(provider));
|
ComputeServiceContext context = computeMap.get(HttpUtils.createUri(provider));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (String action : Splitter.on(',').split(actions)) {
|
for (String action : Splitter.on(',').split(actions)) {
|
||||||
Action act = Action.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE,
|
Action act = Action.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE,
|
||||||
action));
|
action));
|
||||||
invokeActionOnService(act, context.getComputeService());
|
invokeActionOnService(act, context.getComputeService());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeActionOnService(Action action, ComputeService computeService) {
|
private void invokeActionOnService(Action action, ComputeService computeService) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case CREATE:
|
case CREATE:
|
||||||
case GET:
|
case GET:
|
||||||
case DESTROY:
|
case DESTROY:
|
||||||
if (nodeElement != null) {
|
if (nodeElement != null) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case CREATE:
|
case CREATE:
|
||||||
create(computeService);
|
create(computeService);
|
||||||
break;
|
break;
|
||||||
case GET:
|
case GET:
|
||||||
get(computeService);
|
get(computeService);
|
||||||
break;
|
break;
|
||||||
case DESTROY:
|
case DESTROY:
|
||||||
destroy(computeService);
|
destroy(computeService);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.log("missing node element for action: " + action, Project.MSG_ERR);
|
this.log("missing node element for action: " + action, Project.MSG_ERR);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LIST:
|
case LIST:
|
||||||
list(computeService);
|
list(computeService);
|
||||||
break;
|
break;
|
||||||
case LIST_DETAILS:
|
case LIST_DETAILS:
|
||||||
listDetails(computeService);
|
listDetails(computeService);
|
||||||
break;
|
break;
|
||||||
case LIST_IMAGES:
|
case LIST_IMAGES:
|
||||||
listImages(computeService);
|
listImages(computeService);
|
||||||
break;
|
break;
|
||||||
case LIST_SIZES:
|
case LIST_SIZES:
|
||||||
listSizes(computeService);
|
listSizes(computeService);
|
||||||
break;
|
break;
|
||||||
case LIST_LOCATIONS:
|
case LIST_LOCATIONS:
|
||||||
listLocations(computeService);
|
listLocations(computeService);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.log("bad action: " + action, Project.MSG_ERR);
|
this.log("bad action: " + action, Project.MSG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listDetails(ComputeService computeService) {
|
private void listDetails(ComputeService computeService) {
|
||||||
log("list details");
|
log("list details");
|
||||||
for (ComputeMetadata node : computeService.getNodes().values()) {// TODO
|
for (ComputeMetadata node : computeService.getNodes().values()) {// TODO
|
||||||
// parallel
|
// parallel
|
||||||
logDetails(computeService, node);
|
logDetails(computeService, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listImages(ComputeService computeService) {
|
private void listImages(ComputeService computeService) {
|
||||||
log("list images");
|
log("list images");
|
||||||
for (Image image : computeService.getImages().values()) {// TODO
|
for (Image image : computeService.getImages().values()) {// TODO
|
||||||
log(String
|
log(String
|
||||||
.format(
|
.format(
|
||||||
" image location=%s, id=%s, name=%s, version=%s, arch=%s, osfam=%s, osdesc=%s, desc=%s",
|
" image location=%s, id=%s, name=%s, version=%s, arch=%s, osfam=%s, osdesc=%s, desc=%s",
|
||||||
image.getLocationId(), image.getId(), image.getName(), image
|
image.getLocationId(), image.getId(), image.getName(), image
|
||||||
.getVersion(), image.getArchitecture(), image.getOsFamily(),
|
.getVersion(), image.getArchitecture(), image.getOsFamily(),
|
||||||
image.getOsDescription(), image.getDescription()));
|
image.getOsDescription(), image.getDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listSizes(ComputeService computeService) {
|
private void listSizes(ComputeService computeService) {
|
||||||
log("list sizes");
|
log("list sizes");
|
||||||
for (Size size : computeService.getSizes().values()) {// TODO
|
for (Size size : computeService.getSizes().values()) {// TODO
|
||||||
log(String.format(" size id=%s, cores=%s, ram=%s, disk=%s", size.getId(), size
|
log(String.format(" size id=%s, cores=%s, ram=%s, disk=%s", size.getId(), size
|
||||||
.getCores(), size.getRam(), size.getDisk()));
|
.getCores(), size.getRam(), size.getDisk()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listLocations(ComputeService computeService) {
|
private void listLocations(ComputeService computeService) {
|
||||||
log("list locations");
|
log("list locations");
|
||||||
for (Location location : computeService.getLocations().values()) {// TODO
|
for (Location location : computeService.getLocations().values()) {// TODO
|
||||||
log(String.format(" location id=%s, scope=%s, description=%s, parent=%s, assignable=%s",
|
log(String.format(" location id=%s, scope=%s, description=%s, parent=%s, assignable=%s",
|
||||||
location.getId(), location.getScope(), location.getDescription(), location
|
location.getId(), location.getScope(), location.getDescription(), location
|
||||||
.getParent(), location.isAssignable()));
|
.getParent(), location.isAssignable()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void list(ComputeService computeService) {
|
private void list(ComputeService computeService) {
|
||||||
log("list");
|
log("list");
|
||||||
for (ComputeMetadata node : computeService.getNodes().values()) {
|
for (ComputeMetadata node : computeService.getNodes().values()) {
|
||||||
log(String.format(" location=%s, id=%s, tag=%s", node.getLocationId(), node.getId(),
|
log(String.format(" location=%s, id=%s, tag=%s", node.getLocationId(), node.getId(),
|
||||||
node.getName()));
|
node.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void create(ComputeService computeService) {
|
private void create(ComputeService computeService) {
|
||||||
String tag = nodeElement.getTag();
|
String tag = nodeElement.getTag();
|
||||||
|
|
||||||
log(String.format("create tag: %s, count: %d, size: %s, os: %s", tag, nodeElement.getCount(),
|
log(String.format("create tag: %s, count: %d, size: %s, os: %s", tag, nodeElement.getCount(),
|
||||||
nodeElement.getSize(), nodeElement.getOs()));
|
nodeElement.getSize(), nodeElement.getOs()));
|
||||||
|
|
||||||
Template template = createTemplateFromElement(nodeElement, computeService);
|
Template template = createTemplateFromElement(nodeElement, computeService);
|
||||||
|
|
||||||
for (NodeMetadata createdNode : computeService.runNodesWithTag(tag, nodeElement.getCount(),
|
for (NodeMetadata createdNode : computeService.runNodesWithTag(tag, nodeElement.getCount(),
|
||||||
template).values()) {
|
template).values()) {
|
||||||
logDetails(computeService, createdNode);
|
logDetails(computeService, createdNode);
|
||||||
addNodeDetailsAsProjectProperties(createdNode);
|
addNodeDetailsAsProjectProperties(createdNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addNodeDetailsAsProjectProperties(NodeMetadata createdNode) {
|
private void addNodeDetailsAsProjectProperties(NodeMetadata createdNode) {
|
||||||
if (nodeElement.getIdproperty() != null)
|
if (nodeElement.getIdproperty() != null)
|
||||||
getProject().setProperty(nodeElement.getIdproperty(), createdNode.getId());
|
getProject().setProperty(nodeElement.getIdproperty(), createdNode.getId());
|
||||||
if (nodeElement.getHostproperty() != null)
|
if (nodeElement.getHostproperty() != null)
|
||||||
getProject().setProperty(nodeElement.getHostproperty(),
|
getProject().setProperty(nodeElement.getHostproperty(),
|
||||||
ipOrEmptyString(createdNode.getPublicAddresses()));
|
ipOrEmptyString(createdNode.getPublicAddresses()));
|
||||||
if (nodeElement.getPasswordproperty() != null && !isKeyAuth(createdNode))
|
if (nodeElement.getPasswordproperty() != null && !isKeyAuth(createdNode))
|
||||||
getProject().setProperty(nodeElement.getPasswordproperty(),
|
getProject().setProperty(nodeElement.getPasswordproperty(),
|
||||||
createdNode.getCredentials().key);
|
createdNode.getCredentials().key);
|
||||||
if (nodeElement.getUsernameproperty() != null)
|
if (nodeElement.getUsernameproperty() != null)
|
||||||
getProject().setProperty(nodeElement.getUsernameproperty(),
|
getProject().setProperty(nodeElement.getUsernameproperty(),
|
||||||
createdNode.getCredentials().account);
|
createdNode.getCredentials().account);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroy(ComputeService computeService) {
|
private void destroy(ComputeService computeService) {
|
||||||
log(String.format("destroy tag: %s", nodeElement.getTag()));
|
log(String.format("destroy tag: %s", nodeElement.getTag()));
|
||||||
computeService.destroyNodesWithTag(nodeElement.getTag());
|
computeService.destroyNodesWithTag(nodeElement.getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void get(ComputeService computeService) {
|
private void get(ComputeService computeService) {
|
||||||
log(String.format("get tag: %s", nodeElement.getTag()));
|
log(String.format("get tag: %s", nodeElement.getTag()));
|
||||||
for (ComputeMetadata node : computeService.getNodesWithTag(nodeElement.getTag()).values()) {
|
for (ComputeMetadata node : computeService.getNodesWithTag(nodeElement.getTag()).values()) {
|
||||||
logDetails(computeService, node);
|
logDetails(computeService, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logDetails(ComputeService computeService, ComputeMetadata node) {
|
private void logDetails(ComputeService computeService, ComputeMetadata node) {
|
||||||
NodeMetadata metadata = node instanceof NodeMetadata ? NodeMetadata.class.cast(node)
|
NodeMetadata metadata = node instanceof NodeMetadata ? NodeMetadata.class.cast(node)
|
||||||
: computeService.getNodeMetadata(node);
|
: computeService.getNodeMetadata(node);
|
||||||
log(String
|
log(String
|
||||||
.format(
|
.format(
|
||||||
" node id=%s, name=%s, tag=%s, location=%s, state=%s, publicIp=%s, privateIp=%s, extra=%s",
|
" node id=%s, name=%s, tag=%s, location=%s, state=%s, publicIp=%s, privateIp=%s, extra=%s",
|
||||||
metadata.getId(), metadata.getName(), metadata.getTag(), metadata
|
metadata.getId(), metadata.getName(), metadata.getTag(), metadata
|
||||||
.getLocationId(), metadata.getState(), ComputeTaskUtils
|
.getLocationId(), metadata.getState(), ComputeTaskUtils
|
||||||
.ipOrEmptyString(metadata.getPublicAddresses()),
|
.ipOrEmptyString(metadata.getPublicAddresses()),
|
||||||
ipOrEmptyString(metadata.getPrivateAddresses()), metadata.getExtra()));
|
ipOrEmptyString(metadata.getPrivateAddresses()), metadata.getExtra()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the configured {@link NodeElement} element
|
* @return the configured {@link NodeElement} element
|
||||||
*/
|
*/
|
||||||
public final NodeElement createNodes() {
|
public final NodeElement createNodes() {
|
||||||
if (getNodes() == null) {
|
if (getNodes() == null) {
|
||||||
this.nodeElement = new NodeElement();
|
this.nodeElement = new NodeElement();
|
||||||
}
|
}
|
||||||
return this.nodeElement;
|
return this.nodeElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeElement getNodes() {
|
public NodeElement getNodes() {
|
||||||
return this.nodeElement;
|
return this.nodeElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getActions() {
|
public String getActions() {
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActions(String actions) {
|
public void setActions(String actions) {
|
||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeElement getNodeElement() {
|
public NodeElement getNodeElement() {
|
||||||
return nodeElement;
|
return nodeElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNodeElement(NodeElement nodeElement) {
|
public void setNodeElement(NodeElement nodeElement) {
|
||||||
this.nodeElement = nodeElement;
|
this.nodeElement = nodeElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProvider(String provider) {
|
public void setProvider(String provider) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProvider() {
|
public String getProvider() {
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,202 +1,202 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.compute;
|
package org.jclouds.vcloud.compute;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.http.HttpResponseException;
|
import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.domain.Task;
|
import org.jclouds.vcloud.domain.Task;
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
import org.jclouds.vcloud.domain.VAppStatus;
|
import org.jclouds.vcloud.domain.VAppStatus;
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BaseVCloudComputeClient implements VCloudComputeClient {
|
public class BaseVCloudComputeClient implements VCloudComputeClient {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
protected final VCloudClient client;
|
protected final VCloudClient client;
|
||||||
protected final Predicate<String> taskTester;
|
protected final Predicate<String> taskTester;
|
||||||
protected final Predicate<VApp> notFoundTester;
|
protected final Predicate<VApp> notFoundTester;
|
||||||
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState;
|
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BaseVCloudComputeClient(VCloudClient client, Predicate<String> successTester,
|
public BaseVCloudComputeClient(VCloudClient client, Predicate<String> successTester,
|
||||||
@Named("NOT_FOUND") Predicate<VApp> notFoundTester,
|
@Named("NOT_FOUND") Predicate<VApp> notFoundTester,
|
||||||
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.taskTester = successTester;
|
this.taskTester = successTester;
|
||||||
this.notFoundTester = notFoundTester;
|
this.notFoundTester = notFoundTester;
|
||||||
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> start(String vDCId, String name, String templateId, int minCores,
|
public Map<String, String> start(String vDCId, String name, String templateId, int minCores,
|
||||||
int minMegs, Long diskSize, Map<String, String> properties, int... portsToOpen) {
|
int minMegs, Long diskSize, Map<String, String> properties, int... portsToOpen) {
|
||||||
logger
|
logger
|
||||||
.debug(
|
.debug(
|
||||||
">> instantiating vApp vDC(%s) name(%s) template(%s) minCores(%d) minMegs(%d) diskSize(%d) properties(%s) ",
|
">> instantiating vApp vDC(%s) name(%s) template(%s) minCores(%d) minMegs(%d) diskSize(%d) properties(%s) ",
|
||||||
vDCId, name, templateId, minCores, minMegs, diskSize, properties);
|
vDCId, name, templateId, minCores, minMegs, diskSize, properties);
|
||||||
InstantiateVAppTemplateOptions options = processorCount(minCores).memory(minMegs)
|
InstantiateVAppTemplateOptions options = processorCount(minCores).memory(minMegs)
|
||||||
.productProperties(properties);
|
.productProperties(properties);
|
||||||
if (diskSize != null)
|
if (diskSize != null)
|
||||||
options.disk(diskSize);
|
options.disk(diskSize);
|
||||||
VApp vAppResponse = client.instantiateVAppTemplateInVDC(vDCId, name, templateId, options);
|
VApp vAppResponse = client.instantiateVAppTemplateInVDC(vDCId, name, templateId, options);
|
||||||
logger.debug("<< instantiated VApp(%s)", vAppResponse.getId());
|
logger.debug("<< instantiated VApp(%s)", vAppResponse.getId());
|
||||||
|
|
||||||
logger.debug(">> deploying vApp(%s)", vAppResponse.getId());
|
logger.debug(">> deploying vApp(%s)", vAppResponse.getId());
|
||||||
|
|
||||||
Task task = client.deployVApp(vAppResponse.getId());
|
Task task = client.deployVApp(vAppResponse.getId());
|
||||||
if (!taskTester.apply(task.getId())) {
|
if (!taskTester.apply(task.getId())) {
|
||||||
throw new TaskException("deploy", vAppResponse, task);
|
throw new TaskException("deploy", vAppResponse, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("<< deployed vApp(%s)", vAppResponse.getId());
|
logger.debug("<< deployed vApp(%s)", vAppResponse.getId());
|
||||||
|
|
||||||
logger.debug(">> powering vApp(%s)", vAppResponse.getId());
|
logger.debug(">> powering vApp(%s)", vAppResponse.getId());
|
||||||
try {
|
try {
|
||||||
task = client.powerOnVApp(vAppResponse.getId());
|
task = client.powerOnVApp(vAppResponse.getId());
|
||||||
if (!taskTester.apply(task.getId())) {
|
if (!taskTester.apply(task.getId())) {
|
||||||
throw new TaskException("powerOn", vAppResponse, task);
|
throw new TaskException("powerOn", vAppResponse, task);
|
||||||
}
|
}
|
||||||
} catch (HttpResponseException e) {
|
} catch (HttpResponseException e) {
|
||||||
if (e.getResponse().getStatusCode() == 400
|
if (e.getResponse().getStatusCode() == 400
|
||||||
&& client.getVApp(vAppResponse.getId()).getStatus() == VAppStatus.ON) {
|
&& client.getVApp(vAppResponse.getId()).getStatus() == VAppStatus.ON) {
|
||||||
// TODO temporary hack because some vcloud implementations automatically transition to
|
// TODO temporary hack because some vcloud implementations automatically transition to
|
||||||
// powerOn from deploy
|
// powerOn from deploy
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
logger.debug("<< on vApp(%s)", vAppResponse.getId());
|
logger.debug("<< on vApp(%s)", vAppResponse.getId());
|
||||||
|
|
||||||
Map<String, String> response = parseResponse(vAppResponse);
|
Map<String, String> response = parseResponse(vAppResponse);
|
||||||
checkState(response.containsKey("id"), "bad configuration: [id] should be in response");
|
checkState(response.containsKey("id"), "bad configuration: [id] should be in response");
|
||||||
checkState(response.containsKey("username"),
|
checkState(response.containsKey("username"),
|
||||||
"bad configuration: [username] should be in response");
|
"bad configuration: [username] should be in response");
|
||||||
checkState(response.containsKey("password"),
|
checkState(response.containsKey("password"),
|
||||||
"bad configuration: [password] should be in response");
|
"bad configuration: [password] should be in response");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, String> parseResponse(VApp vAppResponse) {
|
protected Map<String, String> parseResponse(VApp vAppResponse) {
|
||||||
Map<String, String> config = Maps.newLinkedHashMap();// Allows nulls
|
Map<String, String> config = Maps.newLinkedHashMap();// Allows nulls
|
||||||
config.put("id", vAppResponse.getId());
|
config.put("id", vAppResponse.getId());
|
||||||
config.put("username", null);
|
config.put("username", null);
|
||||||
config.put("password", null);
|
config.put("password", null);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reboot(String id) {
|
public void reboot(String id) {
|
||||||
VApp vApp = client.getVApp(id);
|
VApp vApp = client.getVApp(id);
|
||||||
logger.debug(">> resetting vApp(%s)", vApp.getId());
|
logger.debug(">> resetting vApp(%s)", vApp.getId());
|
||||||
Task task = client.resetVApp(vApp.getId());
|
Task task = client.resetVApp(vApp.getId());
|
||||||
if (!taskTester.apply(task.getId())) {
|
if (!taskTester.apply(task.getId())) {
|
||||||
throw new TaskException("resetVApp", vApp, task);
|
throw new TaskException("resetVApp", vApp, task);
|
||||||
}
|
}
|
||||||
logger.debug("<< on vApp(%s)", vApp.getId());
|
logger.debug("<< on vApp(%s)", vApp.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop(String id) {
|
public void stop(String id) {
|
||||||
VApp vApp = client.getVApp(id);
|
VApp vApp = client.getVApp(id);
|
||||||
if (vApp.getStatus() != VAppStatus.OFF) {
|
if (vApp.getStatus() != VAppStatus.OFF) {
|
||||||
logger.debug(">> powering off vApp(%s), current status: %s", vApp.getId(), vApp
|
logger.debug(">> powering off vApp(%s), current status: %s", vApp.getId(), vApp
|
||||||
.getStatus());
|
.getStatus());
|
||||||
Task task = client.powerOffVApp(vApp.getId());
|
Task task = client.powerOffVApp(vApp.getId());
|
||||||
if (!taskTester.apply(task.getId())) {
|
if (!taskTester.apply(task.getId())) {
|
||||||
throw new TaskException("powerOff", vApp, task);
|
throw new TaskException("powerOff", vApp, task);
|
||||||
}
|
}
|
||||||
logger.debug("<< off vApp(%s)", vApp.getId());
|
logger.debug("<< off vApp(%s)", vApp.getId());
|
||||||
}
|
}
|
||||||
logger.debug(">> deleting vApp(%s)", vApp.getId());
|
logger.debug(">> deleting vApp(%s)", vApp.getId());
|
||||||
client.deleteVApp(id);
|
client.deleteVApp(id);
|
||||||
boolean successful = notFoundTester.apply(vApp);
|
boolean successful = notFoundTester.apply(vApp);
|
||||||
logger.debug("<< deleted vApp(%s) completed(%s)", vApp.getId(), successful);
|
logger.debug("<< deleted vApp(%s) completed(%s)", vApp.getId(), successful);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TaskException extends VAppException {
|
public static class TaskException extends VAppException {
|
||||||
|
|
||||||
private final Task task;
|
private final Task task;
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
private static final long serialVersionUID = 251801929573211256L;
|
private static final long serialVersionUID = 251801929573211256L;
|
||||||
|
|
||||||
public TaskException(String type, VApp vApp, Task task) {
|
public TaskException(String type, VApp vApp, Task task) {
|
||||||
super(String.format("failed to %s vApp %s status %s;task %s status %s", type,
|
super(String.format("failed to %s vApp %s status %s;task %s status %s", type,
|
||||||
vApp.getId(), vApp.getStatus(), task.getLocation(), task.getStatus()), vApp);
|
vApp.getId(), vApp.getStatus(), task.getLocation(), task.getStatus()), vApp);
|
||||||
this.task = task;
|
this.task = task;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task getTask() {
|
public Task getTask() {
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class VAppException extends RuntimeException {
|
public static class VAppException extends RuntimeException {
|
||||||
|
|
||||||
private final VApp vApp;
|
private final VApp vApp;
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
private static final long serialVersionUID = 251801929573211256L;
|
private static final long serialVersionUID = 251801929573211256L;
|
||||||
|
|
||||||
public VAppException(String message, VApp vApp) {
|
public VAppException(String message, VApp vApp) {
|
||||||
super(message);
|
super(message);
|
||||||
this.vApp = vApp;
|
this.vApp = vApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VApp getvApp() {
|
public VApp getvApp() {
|
||||||
return vApp;
|
return vApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<InetAddress> getPrivateAddresses(String id) {
|
public Set<InetAddress> getPrivateAddresses(String id) {
|
||||||
return ImmutableSet.of();
|
return ImmutableSet.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<InetAddress> getPublicAddresses(String id) {
|
public Set<InetAddress> getPublicAddresses(String id) {
|
||||||
VApp vApp = client.getVApp(id);
|
VApp vApp = client.getVApp(id);
|
||||||
return Sets.newHashSet(vApp.getNetworkToAddresses().values());
|
return Sets.newHashSet(vApp.getNetworkToAddresses().values());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue