Skip to content

Commit

Permalink
Merge branch 'master' into network-vpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Nurmi committed Jul 21, 2015
2 parents 73feec5 + 8bc4e01 commit 34b649c
Show file tree
Hide file tree
Showing 55 changed files with 709 additions and 5,068 deletions.
5 changes: 5 additions & 0 deletions admin-tools/eucalyptus_admin/commands/ec2/__init__.py
Expand Up @@ -30,6 +30,7 @@

from eucalyptus_admin.commands import EucalyptusAdmin
from eucalyptus_admin.exceptions import AWSError
from eucalyptus_admin.util import add_fake_region_name


class EC2(requestbuilder.service.BaseService):
Expand All @@ -41,6 +42,10 @@ class EC2(requestbuilder.service.BaseService):
ARGS = [Arg('-U', '--url', metavar='URL',
help='compute service endpoint URL')]

def configure(self):
requestbuilder.service.BaseService.configure(self)
add_fake_region_name(self)

def handle_http_error(self, response):
raise AWSError(response)

Expand Down
5 changes: 5 additions & 0 deletions admin-tools/eucalyptus_admin/commands/empyrean/__init__.py
Expand Up @@ -30,6 +30,7 @@

from eucalyptus_admin.commands import EucalyptusAdmin
from eucalyptus_admin.exceptions import AWSError
from eucalyptus_admin.util import add_fake_region_name


class Empyrean(requestbuilder.service.BaseService):
Expand All @@ -41,6 +42,10 @@ class Empyrean(requestbuilder.service.BaseService):
ARGS = [Arg('-U', '--url', metavar='URL',
help='bootstrap service endpoint URL')]

def configure(self):
requestbuilder.service.BaseService.configure(self)
add_fake_region_name(self)

def handle_http_error(self, response):
raise AWSError(response)

Expand Down
Expand Up @@ -24,9 +24,9 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from requestbuilder import Arg
from requestbuilder.mixins.formatting import TableOutputMixin

from eucalyptus_admin.commands.empyrean import EmpyreanRequest
from eucalyptus_admin.commands.mixins import TableOutputMixin


class DescribeAvailableServiceTypes(EmpyreanRequest, TableOutputMixin):
Expand Down
Expand Up @@ -23,11 +23,12 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from requestbuilder.mixins.formatting import TableOutputMixin

from eucalyptus_admin.commands.ec2.describeinstances import DescribeInstances
from eucalyptus_admin.commands.empyrean import EmpyreanRequest
from eucalyptus_admin.commands.empyrean.describeservices import \
DescribeServices
from eucalyptus_admin.commands.mixins import TableOutputMixin


class DescribeNodeControllers(EmpyreanRequest, TableOutputMixin):
Expand Down
Expand Up @@ -26,9 +26,9 @@
import sys

from requestbuilder import Arg, Filter, MutuallyExclusiveArgList
from requestbuilder.mixins.formatting import TableOutputMixin

from eucalyptus_admin.commands.empyrean import EmpyreanRequest
from eucalyptus_admin.commands.mixins import TableOutputMixin


class _RenamingFilter(Filter):
Expand Down
5 changes: 5 additions & 0 deletions admin-tools/eucalyptus_admin/commands/properties/__init__.py
Expand Up @@ -30,6 +30,7 @@

from eucalyptus_admin.commands import EucalyptusAdmin
from eucalyptus_admin.exceptions import AWSError
from eucalyptus_admin.util import add_fake_region_name


class Properties(requestbuilder.service.BaseService):
Expand All @@ -41,6 +42,10 @@ class Properties(requestbuilder.service.BaseService):
ARGS = [Arg('-U', '--url', metavar='URL', help='''Connect to the
service using a specific URL.''')]

def configure(self):
requestbuilder.service.BaseService.configure(self)
add_fake_region_name(self)

def handle_http_error(self, response):
raise AWSError(response)

Expand Down
Expand Up @@ -26,10 +26,9 @@
from requestbuilder import Arg

from eucalyptus_admin.commands.properties import PropertiesRequest
from eucalyptus_admin.commands.mixins import TableOutputMixin


class DescribeProperties(PropertiesRequest, TableOutputMixin):
class DescribeProperties(PropertiesRequest):
DESCRIPTION = "List the cloud's properties"
ARGS = [Arg('Property', metavar='PROPERTY', nargs='*',
help='limit results to specific properties')]
Expand Down
Expand Up @@ -23,20 +23,9 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import prettytable
from requestbuilder import Arg
import os


class TableOutputMixin(object):
ARGS = [Arg('--show-headers', action='store_true', route_to=None,
help='show column headers')]

def get_table(self, field_names):
table = prettytable.PrettyTable(field_names=field_names)
table.border = False
table.header = self.args.get('show_headers') or False
table.header_style = 'upper'
table.align = 'l' # left
table.left_padding_width = 0
table.right_padding_width = 2
return table
def add_fake_region_name(service):
if service.region_name is None and not os.getenv('AWS_AUTH_REGION'):
service.region_name = 'undefined-{0}'.format(os.getpid())
Expand Up @@ -2662,7 +2662,7 @@ void dispatchInternal( final ActivityContext context,

final DescribeAvailabilityZonesType describeAvailabilityZonesType
= new DescribeAvailabilityZonesType();
describeAvailabilityZonesType.setAvailabilityZoneSet( Lists.newArrayList( availabilityZones ) );
describeAvailabilityZonesType.getFilterSet().add( filter( "zone-name", Lists.newArrayList( availabilityZones ) ) );

client.dispatch( describeAvailabilityZonesType, callback );
}
Expand Down
Expand Up @@ -1241,7 +1241,7 @@ public void fire( final AutoScalingGroup autoScalingGroup ) {
final List<String> referenceErrors = activityManager.validateReferences(
autoScalingGroup.getOwner(),
Consumers.atomic( subnetsByZone ),
autoScalingGroup.getAvailabilityZones(),
request.availabilityZones( ),
Collections.<String>emptyList(), // load balancer names cannot be updated
subnetIds
);
Expand Down
22 changes: 13 additions & 9 deletions clc/modules/bootstrap/src/main/native/eucalyptus-bootstrap.c
Expand Up @@ -281,16 +281,20 @@ static void *signal_set(int sig, void *newHandler)
static int __get_pid(char *pidpath)
{
FILE *pidfile;
int pid;
if ((pidfile = fopen(pidpath, "r")) == NULL) {
return -1;
}
__abort(-1, (fscanf(pidfile, "%d", &pid) < 0), "Failed to read pid file.");
fclose(pidfile);
if (kill(pid, 0) == 0) {
return pid;
int pid = -1;

if ((pidfile = fopen(pidpath, "r")) != NULL) {
if (fscanf(pidfile, "%d", &pid) != 1) {
__error("Failed to read pid file: %s", pidpath);
}
fclose(pidfile);
if (pid > 0 && (kill(pid,0) != 0)) {
__error("PID: %d is nonexistant",pid);
pid = -1;
}
}
return -1;
__debug("pid return: %d", pid);
return pid;
}

static int __write_pid(char *pidpath)
Expand Down
@@ -1,5 +1,5 @@
/*************************************************************************
* Copyright 2009-2014 Eucalyptus Systems, Inc.
* Copyright 2009-2015 Eucalyptus Systems, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -36,6 +36,10 @@ public CloudFormationAWSCredentialsProvider( ) {
super( CloudFormationUserSupplier.INSTANCE );
}

public CloudFormationAWSCredentialsProvider( final int expirationSecs ) {
super( CloudFormationUserSupplier.INSTANCE, expirationSecs );
}

public enum CloudFormationUserSupplier implements Supplier<User> {
INSTANCE;

Expand Down
Expand Up @@ -52,6 +52,7 @@

import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;

/**
Expand Down Expand Up @@ -79,7 +80,7 @@ private enum CreateSteps implements Step {
@Override
public ResourceAction perform(ResourceAction resourceAction) throws Exception {
final AWSCloudFormationWaitConditionHandleResourceAction action = (AWSCloudFormationWaitConditionHandleResourceAction) resourceAction;
try ( final EucaS3Client s3c = EucaS3ClientFactory.getEucaS3Client( new CloudFormationAWSCredentialsProvider() ) ) {
try ( final EucaS3Client s3c = EucaS3ClientFactory.getEucaS3Client( new CloudFormationAWSCredentialsProvider( (int)TimeUnit.HOURS.toSeconds( 12 ) ) ) ) {
// look for an existing bucket...
String bucketName = null;
ObjectNode objectNode = null;
Expand Down
Expand Up @@ -50,6 +50,7 @@
import com.eucalyptus.loadbalancing.common.msgs.CreateLoadBalancerPolicyType;
import com.eucalyptus.loadbalancing.common.msgs.CreateLoadBalancerResponseType;
import com.eucalyptus.loadbalancing.common.msgs.CreateLoadBalancerType;
import com.eucalyptus.loadbalancing.common.msgs.CrossZoneLoadBalancing;
import com.eucalyptus.loadbalancing.common.msgs.DeleteLoadBalancerResponseType;
import com.eucalyptus.loadbalancing.common.msgs.DeleteLoadBalancerType;
import com.eucalyptus.loadbalancing.common.msgs.DescribeLoadBalancersResponseType;
Expand All @@ -59,8 +60,11 @@
import com.eucalyptus.loadbalancing.common.msgs.Instances;
import com.eucalyptus.loadbalancing.common.msgs.Listener;
import com.eucalyptus.loadbalancing.common.msgs.Listeners;
import com.eucalyptus.loadbalancing.common.msgs.LoadBalancerAttributes;
import com.eucalyptus.loadbalancing.common.msgs.LoadBalancerDescription;
import com.eucalyptus.loadbalancing.common.msgs.LoadBalancerNames;
import com.eucalyptus.loadbalancing.common.msgs.ModifyLoadBalancerAttributesResponseType;
import com.eucalyptus.loadbalancing.common.msgs.ModifyLoadBalancerAttributesType;
import com.eucalyptus.loadbalancing.common.msgs.PolicyAttribute;
import com.eucalyptus.loadbalancing.common.msgs.PolicyAttributes;
import com.eucalyptus.loadbalancing.common.msgs.PolicyNames;
Expand Down Expand Up @@ -279,7 +283,25 @@ public ResourceAction perform(ResourceAction resourceAction) throws Exception {
return action;
}
},
PLACEHOLDER_FOR_OTHER_FIELDS { //// placeholder for "AccessLoggingPolicy", "ConnectionDrainingPolicy", "CrossZone" : Boolean
SET_CROSS_ZONE_ATTRIBUTE {
@Override
public ResourceAction perform(ResourceAction resourceAction) throws Exception {
AWSElasticLoadBalancingLoadBalancerResourceAction action = (AWSElasticLoadBalancingLoadBalancerResourceAction) resourceAction;
ServiceConfiguration configuration = Topology.lookup(LoadBalancing.class);
if (action.properties.getCrossZone() != null && action.properties.getCrossZone() == Boolean.TRUE) {
ModifyLoadBalancerAttributesType modifyLoadBalancerAttributesType = MessageHelper.createMessage(ModifyLoadBalancerAttributesType.class, action.info.getEffectiveUserId());
modifyLoadBalancerAttributesType.setLoadBalancerName(action.info.getPhysicalResourceId());
LoadBalancerAttributes loadBalancerAttributes = new LoadBalancerAttributes();
CrossZoneLoadBalancing crossZoneLoadBalancing = new CrossZoneLoadBalancing();
crossZoneLoadBalancing.setEnabled(Boolean.TRUE);
loadBalancerAttributes.setCrossZoneLoadBalancing(crossZoneLoadBalancing);
modifyLoadBalancerAttributesType.setLoadBalancerAttributes(loadBalancerAttributes);
AsyncRequests.<ModifyLoadBalancerAttributesType, ModifyLoadBalancerAttributesResponseType>sendSync(configuration, modifyLoadBalancerAttributesType);
}
return action;
}
},
PLACEHOLDER_FOR_OTHER_FIELDS { //// placeholder for "AccessLoggingPolicy", "ConnectionDrainingPolicy"
@Override
public ResourceAction perform(ResourceAction resourceAction) throws Exception {
AWSElasticLoadBalancingLoadBalancerResourceAction action = (AWSElasticLoadBalancingLoadBalancerResourceAction) resourceAction;
Expand Down
Expand Up @@ -259,15 +259,6 @@ public boolean apply( Allocation allocInfo ) throws MetadataException, AuthExcep
" bytes of the instance is greater than the vmType " + vmType.getDisplayName( ) +
" size " + vmType.getDisk( ) + " GB." );
}
final MachineImageInfo emi = LookupMachine.INSTANCE.apply(imageId);
if(ImageMetadata.State.pending_available.equals(emi.getState())) {
if ( !Topology.isEnabled( ImagingBackend.class) )
throw new MetadataException("Partition image cannot be deployed without an adequately "
+ "provisioned Imaging Worker. Please contact your cloud administrator.");
if ( !verifyImagerCapacity(emi) )
throw new MetadataException("Partition image of this size cannot be deployed without an adequately "
+ "provisioned Imaging Worker. Please contact your cloud administrator.");
}
}
} catch ( VerificationException e ) {
throw e;
Expand All @@ -280,46 +271,6 @@ public boolean apply( Allocation allocInfo ) throws MetadataException, AuthExcep
}
return true;
}

private static long GIG = 1073741824l;
private static long MB = 1048576l;
// check if image can be converted
private static boolean verifyImagerCapacity(MachineImageInfo img) throws MetadataException {
String workerType = null;
try {
workerType = PropertyDirectory.getPropertyEntry("services.imaging.worker.instance_type").getValue();
} catch (IllegalAccessException e) {}
if (workerType == null )
return false;
String emiName = null;
try {
emiName = PropertyDirectory.getPropertyEntry("services.imaging.worker.image").getValue();
} catch (IllegalAccessException e) {}
if (!ImagingServiceProperties.stackExists(true))
throw new MetadataException("Partition image cannot be deployed without an enabled Imaging Service."
+ " Please contact your cloud administrator.");

List<VmTypeDetails> allTypes = EucalyptusClient.getInstance().describeVMTypes();
long diskSizeBytes = 0;
for(VmTypeDetails type:allTypes){
if (type.getName().equalsIgnoreCase(workerType)){
diskSizeBytes = type.getDisk() * GIG;
break;
}
}
// there is a chance that emi is de-registered
MachineImageInfo emi;
try {
emi = LookupMachine.INSTANCE.apply(emiName);
} catch (NoSuchElementException ex) {
throw new MetadataException("Partition image cannot be deployed without an enabled Imaging Service."
+ " Please contact your cloud administrator.");
}
long spaceLeft = diskSizeBytes - emi.getImageSizeBytes() - img.getImageSizeBytes() - 100*2*MB;
if (spaceLeft > 0)
return true;
return false;
}
}

enum KeyPairVerifier implements MetadataVerifier {
Expand Down
Expand Up @@ -371,30 +371,17 @@ public VmTypeInfo populateVirtualBootRecord( final VmType vmType, final Partitio
}
if ( this.getMachine( ) instanceof StaticDiskImage ) { // BootableImage+StaticDiskImage = MachineImageInfo
StaticDiskImage diskImage = (StaticDiskImage) this.getMachine( );
final MachineImageInfo emi = LookupMachine.INSTANCE.apply(this.getMachine().getDisplayName());
String manifestLocation = null;
// generate download manifest and replace machine URL
if(ImageMetadata.State.pending_available.equals(emi.getState())){
manifestLocation = DownloadManifestFactory.generatePresignedUrl(reservationId);
Images.setImageState(emi.getDisplayName(), ImageMetadata.State.pending_conversion);
}else if(ImageMetadata.State.pending_conversion.equals(emi.getState())){
manifestLocation = DownloadManifestFactory.generatePresignedUrl(reservationId);
}else{
// paravirtualized images have RunManifest that is located in the system bucket
// and is not accessible by users so there is nothing to check
if ( diskImage.getManifestLocation().equals( diskImage.getRunManifestLocation() )
&& !isEmptyString( diskImage.getManifestHash() )
&& !diskImage.getManifestHash().equals( ImageManifests.getManifestHash(
diskImage.getManifestLocation() )) )
throw new MetadataException("Instance manifest was changed after registration");
manifestLocation = DownloadManifestFactory.generateDownloadManifest(
if (!isEmptyString( diskImage.getManifestHash() )
&& !diskImage.getManifestHash().equals( ImageManifests.getManifestHash(
diskImage.getManifestLocation() )) )
throw new MetadataException("Instance manifest was changed after registration");
String manifestLocation = DownloadManifestFactory.generateDownloadManifest(
new ImageManifestFile(
diskImage.getRunManifestLocation( ),
diskImage.getManifestLocation( ),
BundleImageManifest.INSTANCE,
ImageConfiguration.getInstance( ).getMaxManifestSizeBytes( ) ),
partition.getNodeCertificate( ).getPublicKey( ),
reservationId, true);
}
vmTypeInfo.setRoot( diskImage.getDisplayName( ), manifestLocation,
this.getMachine( ).getImageSizeBytes() );
}
Expand Down

0 comments on commit 34b649c

Please sign in to comment.