Skip to content

Commit

Permalink
Merge pull request #65 from TheWeatherCompany/merge-down-2014-05-23
Browse files Browse the repository at this point in the history
#66 Merge upstream Dasein changes into TWC fork.
  • Loading branch information
ckelner committed May 27, 2014
2 parents 841d623 + ddb2051 commit 2788b49
Show file tree
Hide file tree
Showing 37 changed files with 1,046 additions and 159 deletions.
Binary file removed .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
</plugins>
</build>

<distributionManagement>
<distributionManagement>
<repository>
<id>twcgrid</id>
<name>twcgrid-releases</name>
Expand All @@ -235,7 +235,7 @@
<name>twcgrid-snapshots</name>
<url>http://twcgrid.artifactoryonline.com/twcgrid/libs-snapshots-local</url>
</snapshotRepository>
</distributionManagement>
</distributionManagement>

<developers>
<developer>
Expand Down
Binary file removed src/.DS_Store
Binary file not shown.
Binary file removed src/main/.DS_Store
Binary file not shown.
Binary file removed src/main/java/.DS_Store
Binary file not shown.
Binary file removed src/main/java/org/.DS_Store
Binary file not shown.
Binary file removed src/main/java/org/dasein/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ public void removePublicShare(@Nonnull String providerImageId) throws CloudExcep
public @Nonnull Iterable<MachineImage> searchImages(@Nullable String accountNumber, @Nullable String keyword, @Nullable Platform platform, @Nullable Architecture architecture, @Nullable ImageClass ... imageClasses) throws CloudException, InternalException {
ImageFilterOptions options = ImageFilterOptions.getInstance();

if (accountNumber != null) {
options.withAccountNumber(accountNumber);
}
if( keyword != null ) {
options.matchingRegex(keyword);
}
Expand Down
31 changes: 30 additions & 1 deletion src/main/java/org/dasein/cloud/compute/AbstractVMSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,25 @@ public VirtualMachine modifyInstance(@Nonnull String vmId, @Nonnull String[] fir
throw new OperationNotSupportedException("Instance firewall modifications are not currently supported for " + getProvider().getCloudName());
}

public void cancelSpotDataFeedSubscription() throws CloudException, InternalException{
throw new OperationNotSupportedException("Spot Instances are not supported for " + getProvider().getCloudName());
}

@Override
public void cancelSpotInstanceRequest(String providerSpotInstanceRequestID) throws CloudException, InternalException{
throw new OperationNotSupportedException("Spot Instances are not supported for " + getProvider().getCloudName());
}

@Override
public @Nonnull VirtualMachine clone(@Nonnull String vmId, @Nonnull String intoDcId, @Nonnull String name, @Nonnull String description, boolean powerOn, @Nullable String... firewallIds) throws InternalException, CloudException {
throw new OperationNotSupportedException("VM cloning is not currently supported for " + getProvider().getCloudName());
}

@Override
public @Nonnull SpotInstanceRequest createSpotInstanceRequest(SIRequestCreateOptions options) throws CloudException, InternalException{
throw new OperationNotSupportedException("Spot Instances are not supported for " + getProvider().getCloudName());
}

@Override
@Deprecated
public @Nullable VMScalingCapabilities describeVerticalScalingCapabilities() throws CloudException, InternalException {
Expand All @@ -105,6 +119,11 @@ public void enableAnalytics(@Nonnull String vmId) throws InternalException, Clou
// NO-OP
}

@Override
public void enableSpotDataFeedSubscription(String s3BucketName) throws CloudException, InternalException{
throw new OperationNotSupportedException("Spot Instances are not supported for " + getProvider().getCloudName());
}

/**
* Provides the current provider context for the request in progress.
* @return the current provider context
Expand All @@ -127,7 +146,7 @@ public void enableAnalytics(@Nonnull String vmId) throws InternalException, Clou

@Override
public @Nullable String getPassword(@Nonnull String vmId) throws InternalException, CloudException {
return null;
return null;
}

@Override
Expand Down Expand Up @@ -513,6 +532,11 @@ public void populate(@Nonnull Jiterator<String> iterator) throws Exception {

@Override
public @Nonnull Iterable<VirtualMachineProduct> listProducts(@Nonnull Architecture architecture) throws InternalException, CloudException {
return listProducts(architecture, null);
}

@Override
public @Nonnull Iterable<VirtualMachineProduct> listProducts(@Nonnull Architecture architecture, String preferedDataCenterId) throws InternalException, CloudException {
APITrace.begin(getProvider(), "VM.listProducts");
try {
Cache<VirtualMachineProduct> cache = Cache.getInstance(getProvider(), "products" + architecture.name(), VirtualMachineProduct.class, CacheLevel.REGION_ACCOUNT, new TimePeriod<Day>(1, TimePeriod.DAY));
Expand Down Expand Up @@ -631,6 +655,11 @@ public void populate(@Nonnull Jiterator<String> iterator) throws Exception {
}
}

@Override
public Iterable<SpotPriceHistory> listSpotPriceHistories(SPHistoryFilterOptions options) throws CloudException, InternalException{
throw new OperationNotSupportedException("Spot Instances are not supported for " + getProvider().getCloudName());
}

@Override
@Deprecated
public Iterable<Architecture> listSupportedArchitectures() throws InternalException, CloudException {
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/dasein/cloud/compute/ImageFilterOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,17 @@ else if( matchesAny ) {
}
}
if( regex != null ) {
boolean matches = (image.getName().toLowerCase().matches(regex.toLowerCase()) || image.getDescription().toLowerCase().matches(regex.toLowerCase()));
boolean matches = (image.getName().matches(regex) || image.getDescription().matches(regex));

if (!matches) {
matches = image.getProviderMachineImageId().matches(regex);
}

if( !matches ) {
for( Map.Entry<String,String> tag : image.getTags().entrySet() ) {
String value = tag.getValue().toLowerCase();
String value = tag.getValue();

if( value != null && value.matches(regex.toLowerCase()) ) {
if( value != null && value.matches(regex) ) {
matches = true;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/dasein/cloud/compute/MachineImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public String toString() {
* @deprecated Use {@link #setTag(String, String)}
*/
public void addTag(Tag t) {
addTag(t.getKey(), t.getValue());
setTag(t.getKey(), t.getValue());
}

/**
Expand All @@ -474,7 +474,7 @@ public void addTag(Tag t) {
* @deprecated Use {@link #setTag(String, String)}
*/
public void addTag(String key, String value) {
getTags().put(key, value);
setTag(key, value);
}

/**
Expand Down
137 changes: 137 additions & 0 deletions src/main/java/org/dasein/cloud/compute/SIRequestCreateOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/**
* Copyright (C) 2009-2014 Dell, Inc.
* See annotations for authorship information
*
* ====================================================================
* 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.dasein.cloud.compute;

import org.dasein.cloud.CloudException;
import org.dasein.cloud.CloudProvider;
import org.dasein.cloud.InternalException;
import org.dasein.cloud.OperationNotSupportedException;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
* Options for creating Spot Instance Requests.
* @author Drew Lyall
* @version 2014.05 initial version
* @since 2014.05
*/
public class SIRequestCreateOptions{
private String providerMachineImageId;
private String providerProductId;
private int instanceCount;
private double maximumPrice;
private String launchGroup;
private long startDateTime;
private long expiryDateTime;
private SIRequestType type;
private String providerVlanId;
private String providerSubnetId;
private boolean isAutoAssignIP;
private String providerIAMRoleId;
private boolean isMonitoring;
private String userData;

/**
* Provides options for creating a Spot Instance Request
* @return an object representing the options for creating a Spot Instance
*/
static public SIRequestCreateOptions getInstance(@Nonnull String providerMachineImageId, @Nonnull String providerProductId, int instanceCount, double maximumPrice, @Nullable String launchGroup, long startDateTime, long expiryDateTime, @Nonnull SIRequestType type, @Nonnull String providerVlanId, @Nullable String providerSubnetId, boolean autoAssignIP, @Nullable String providerIAMRoleId, boolean monitoring, @Nullable String userData){
SIRequestCreateOptions opts = new SIRequestCreateOptions();
opts.providerMachineImageId = providerMachineImageId;
opts.providerProductId = providerProductId;
opts.instanceCount = instanceCount;
opts.maximumPrice = maximumPrice;
opts.launchGroup = launchGroup;
opts.startDateTime = startDateTime;
opts.expiryDateTime = expiryDateTime;
opts.type = type;
opts.providerVlanId = providerVlanId;
opts.providerSubnetId = providerSubnetId;
opts.isAutoAssignIP = autoAssignIP;
opts.providerIAMRoleId = providerIAMRoleId;
opts.isMonitoring = monitoring;
opts.userData = userData;

return opts;
}

public String getProviderMachineImageId(){
return providerMachineImageId;
}

public String getProviderProductId(){
return providerProductId;
}

public int getInstanceCount(){
return instanceCount;
}

public double getMaximumPrice(){
return maximumPrice;
}

public String getLaunchGroup(){
return launchGroup;
}

public long getStartDateTime(){
return startDateTime;
}

public long getExpiryDateTime(){
return expiryDateTime;
}

public SIRequestType getType(){
return type;
}

public String getProviderVlanId(){
return providerVlanId;
}

public String getProviderSubnetId(){
return providerSubnetId;
}

public boolean isAutoAssignIP(){
return isAutoAssignIP;
}

public String getProviderIAMRoleId(){
return providerIAMRoleId;
}

public @Nonnull SpotInstanceRequest build(CloudProvider provider)throws CloudException, InternalException{
ComputeServices services = provider.getComputeServices();
if(services == null){
throw new OperationNotSupportedException(provider.getCloudName() + " does not have support for compute services");
}

VirtualMachineSupport support = services.getVirtualMachineSupport();
if(support == null){
throw new OperationNotSupportedException(provider.getCloudName() + " does not have VM support");
}

return support.createSpotInstanceRequest(this);
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/dasein/cloud/compute/SIRequestStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.dasein.cloud.compute;

public enum SIRequestStatus{
OPEN, ACTIVE, CLOSED, CANCELLED, FAILED;
}
5 changes: 5 additions & 0 deletions src/main/java/org/dasein/cloud/compute/SIRequestType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.dasein.cloud.compute;

public enum SIRequestType{
ONE_TIME, PERSISTENT;
}

0 comments on commit 2788b49

Please sign in to comment.