Skip to content

Commit

Permalink
Merge branch '2015.06'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Lyall committed Jun 3, 2015
2 parents 7ea0c14 + 9f05a78 commit 3bdb9c2
Show file tree
Hide file tree
Showing 29 changed files with 1,030 additions and 627 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Expand Up @@ -19,7 +19,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.dasein</groupId>
<artifactId>dasein-cloud-aws</artifactId>
<version>2015.03.4</version>
<version>2015.06.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>dasein-cloud-aws</name>
Expand Down Expand Up @@ -62,7 +62,7 @@
<dependency>
<groupId>org.dasein</groupId>
<artifactId>dasein-cloud-core</artifactId>
<version>2015.03.1</version>
<version>2015.06.1</version>
<scope>compile</scope>
<optional>false</optional>
</dependency>
Expand Down Expand Up @@ -112,7 +112,7 @@
<dependency>
<groupId>org.dasein</groupId>
<artifactId>dasein-cloud-test</artifactId>
<version>2015.03.2-SNAPSHOT</version>
<version>2015.06.1</version>
<scope>test</scope>
<optional>false</optional>
</dependency>
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/dasein/cloud/aws/admin/AWSAdminServices.java
Expand Up @@ -22,13 +22,13 @@
import org.dasein.cloud.admin.AbstractAdminServices;
import org.dasein.cloud.aws.AWSCloud;

public class AWSAdminServices extends AbstractAdminServices {
private AWSCloud cloud;

public AWSAdminServices(AWSCloud cloud) { this.cloud = cloud; }
public class AWSAdminServices extends AbstractAdminServices<AWSCloud> {
public AWSAdminServices(AWSCloud provider) {
super(provider);
}

@Override
public ReservedInstance getPrepaymentSupport() {
return new ReservedInstance(cloud);
return new ReservedInstance(getProvider());
}
}
Expand Up @@ -22,6 +22,7 @@
import org.dasein.cloud.*;
import org.dasein.cloud.aws.AWSCloud;
import org.dasein.cloud.compute.*;
import org.dasein.cloud.util.NamingConstraints;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -152,4 +153,9 @@ public boolean supportsPublicLibrary(@Nonnull ImageClass imageClass) {
public boolean imageCaptureDestroysVM() throws CloudException, InternalException {
return false;
}

@Override
public @Nonnull NamingConstraints getImageNamingConstraints() throws CloudException, InternalException {
return NamingConstraints.getAlphaNumeric(3, 128).constrainedBy('(', ')', '.', '-', '/', '_');
}
}
22 changes: 1 addition & 21 deletions src/main/java/org/dasein/cloud/aws/compute/EBSSnapshot.java
Expand Up @@ -732,27 +732,7 @@ private void setPrivateShare(@Nonnull String snapshotId, boolean affirmative, @N
}
}

@Override
public boolean supportsSnapshotCopying() throws CloudException, InternalException {
return getCapabilities().supportsSnapshotCopying();
}

@Override
public boolean supportsSnapshotCreation() throws CloudException, InternalException {
return getCapabilities().supportsSnapshotCreation();
}

@Override
public boolean supportsSnapshotSharing() throws InternalException, CloudException {
return getCapabilities().supportsSnapshotSharing();
}

@Override
public boolean supportsSnapshotSharingWithPublic() throws InternalException, CloudException {
return getCapabilities().supportsSnapshotSharingWithPublic();
}

private @Nullable Snapshot toSnapshot(@Nullable Node node) throws CloudException {
private @Nullable Snapshot toSnapshot(@Nullable Node node) throws CloudException, InternalException {
if( node == null ) {
return null;
}
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.dasein.cloud.*;
import org.dasein.cloud.aws.AWSCloud;
import org.dasein.cloud.compute.SnapshotCapabilities;
import org.dasein.cloud.util.NamingConstraints;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -77,4 +78,9 @@ public boolean supportsSnapshotSharing() throws InternalException, CloudExceptio
public boolean supportsSnapshotSharingWithPublic() throws InternalException, CloudException {
return getProvider().getEC2Provider().isAWS();
}

@Override
public @Nonnull NamingConstraints getSnapshotNamingConstraints() throws CloudException, InternalException {
return NamingConstraints.getAlphaNumeric(0, 255);
}
}
56 changes: 18 additions & 38 deletions src/main/java/org/dasein/cloud/aws/compute/EBSVolume.java
Expand Up @@ -32,7 +32,9 @@
import org.dasein.cloud.ResourceStatus;
import org.dasein.cloud.Tag;
import org.dasein.cloud.aws.AWSCloud;
import org.dasein.cloud.aws.model.*;
import org.dasein.cloud.compute.*;
import org.dasein.cloud.compute.VolumeProduct;
import org.dasein.cloud.dc.DataCenter;
import org.dasein.cloud.identity.ServiceAction;
import org.dasein.cloud.util.APITrace;
Expand Down Expand Up @@ -247,44 +249,22 @@ public boolean isSubscribed() throws CloudException, InternalException {

@Override
public @Nonnull Iterable<VolumeProduct> listVolumeProducts() throws InternalException, CloudException {
APITrace.begin(getProvider(), "Volume.listVolumeProducts");
try {
Cache<VolumeProduct> cache = Cache.getInstance(getProvider(), "volumeProducts", VolumeProduct.class, CacheLevel.REGION);
Iterable<VolumeProduct> products = cache.get(getContext());

if( products == null ) {
ArrayList<VolumeProduct> prds = new ArrayList<VolumeProduct>();
ProviderContext ctx = getProvider().getContext();
float rawPrice = 0.11f;

if( ctx != null ) {
String regionId = ctx.getRegionId();

if( regionId != null ) {
if( regionId.equals("us-east-1") || regionId.equals("us-west-2") ) {
rawPrice = 0.10f;
}
else if( regionId.equals("ap-northeast-1") ) {
rawPrice = 0.12f;
}
else if( regionId.equals("sa-east-1") ) {
rawPrice = 0.19f;
}
}
}

prds.add(VolumeProduct.getInstance( VOLUME_PRODUCT_STANDARD, "Standard", "Standard EBS with no IOPS Guarantees", VolumeType.HDD, getMinimumVolumeSize(), "USD", 0, 0, rawPrice, 0f));
prds.add(VolumeProduct.getInstance( VOLUME_PRODUCT_IOPS, "IOPS EBS", "EBS Volume with IOPS guarantees", VolumeType.HDD, getMinimumVolumeSize(), "USD", 100, 4000, 0.125f, 0.1f));
prds.add(VolumeProduct.getInstance( VOLUME_PRODUCT_SSD, "SSD EBS", "SSD-based Persistent Volume", VolumeType.SSD, new Storage<Gigabyte>(1, Storage.GIGABYTE), "USD", 3, 3000, 0.1f, 0f));

cache.put(getContext(), prds);
products = prds;
}
return products;
}
finally {
APITrace.end();
}
VolumeProvider volumeProvider = VolumeProvider.fromFile("/org/dasein/cloud/aws/volproducts.json", "AWS");
String regionId = getContext().getRegionId();
List<org.dasein.cloud.aws.model.VolumeProduct> products = volumeProvider.getProducts();
List<VolumeProduct> volumeProducts = new ArrayList<VolumeProduct>();
for ( org.dasein.cloud.aws.model.VolumeProduct product : products ) {
VolumePrice price = volumeProvider.findProductPrice(regionId, product.getId());
if( price == null ) {
continue;
}
VolumeProduct volumeProduct = VolumeProduct.getInstance(product.getId(), product.getName(), product.getDescription(), VolumeType.valueOf(product.getType().toUpperCase()), product.getMinIops(), product.getMaxIops(), price.getMonthly(), price.getIops() );
volumeProduct.withMaxIopsRatio(product.getIopsToGb());
volumeProduct.withMaxVolumeSize(new Storage<Gigabyte>(product.getMaxSize(), Storage.GIGABYTE));
volumeProduct.withMinVolumeSize(new Storage<Gigabyte>(product.getMinSize(), Storage.GIGABYTE));
volumeProducts.add(volumeProduct);
}
return volumeProducts;
}

@Override
Expand Down
Expand Up @@ -104,10 +104,9 @@ public Storage<Gigabyte> getMinimumVolumeSize() throws InternalException, CloudE
return minVolSize;
}

@Nonnull
@Override
public NamingConstraints getVolumeNamingConstraints() throws CloudException, InternalException {
return null;
public @Nonnull NamingConstraints getVolumeNamingConstraints() throws CloudException, InternalException {
return NamingConstraints.getAlphaNumeric(0, 255);
}

@Nonnull
Expand All @@ -116,14 +115,18 @@ public String getProviderTermForVolume(@Nonnull Locale locale) {
return "volume";
}

@Nonnull
@Override
public Requirement getVolumeProductRequirement() throws InternalException, CloudException {
public @Nonnull Requirement getVolumeProductRequirement() throws InternalException, CloudException {
return ((getProvider().getEC2Provider().isEucalyptus() || getProvider().getEC2Provider().isOpenStack())
? Requirement.NONE
: Requirement.OPTIONAL);
}

@Override
public @Nonnull Requirement getDeviceIdOnAttachRequirement() throws InternalException, CloudException {
return Requirement.NONE;
}

@Override
public boolean isVolumeSizeDeterminedByProduct() throws InternalException, CloudException {
return false;
Expand Down
Expand Up @@ -22,21 +22,22 @@
import org.dasein.cloud.aws.AWSCloud;
import org.dasein.cloud.identity.AbstractIdentityServices;

public class AWSIdentityServices extends AbstractIdentityServices {
private AWSCloud cloud;

public AWSIdentityServices(AWSCloud cloud) { this.cloud = cloud; }

public class AWSIdentityServices extends AbstractIdentityServices<AWSCloud> {

public AWSIdentityServices(AWSCloud provider) {
super(provider);
}

@Override
public IAM getIdentityAndAccessSupport() {
if( cloud.getEC2Provider().isAWS() || cloud.getEC2Provider().isEnStratus() ) {
return new IAM(cloud);
if( getProvider().getEC2Provider().isAWS() || getProvider().getEC2Provider().isEnStratus() ) {
return new IAM(getProvider());
}
return null;
}

@Override
public Keypairs getShellKeySupport() {
return new Keypairs(cloud);
return new Keypairs(getProvider());
}
}
54 changes: 54 additions & 0 deletions src/main/java/org/dasein/cloud/aws/model/VolumePrice.java
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2009-2015 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.aws.model;

/**
* Created by stas on 14/04/2015.
*/
public class VolumePrice {
private String id;
private float monthly;
private float iops;

public float getIops() {
return iops;
}

public void setIops(float iops) {
this.iops = iops;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public float getMonthly() {
return monthly;
}

public void setMonthly(float monthly) {
this.monthly = monthly;
}

}

0 comments on commit 3bdb9c2

Please sign in to comment.