Exemple #1
0
 def __init__(self, instance=None, aws_access_key_id=None,
              aws_secret_access_key=None, aws_user_id=None, 
              ec2_cert=None, ec2_private_key=None, prefix='image', 
              bucket=None, description=None,
              kernel_id=None, ramdisk_id=None, 
              remove_image_files=False, **kwargs):
     self.host = instance # starcluster.node.Node instance
     self.access_key = aws_access_key_id
     self.secret_key = aws_secret_access_key
     self.userid = aws_user_id
     self.private_key = ec2_private_key
     self.bucket = bucket
     self.prefix = prefix
     self.description = description
     self.kernel_id = kernel_id
     self.ramdisk_id = ramdisk_id
     self.cert = ec2_cert
     self.remove_image_files = remove_image_files
     for name in self.bucket.split("/"):
         if not utils.is_valid_bucket_name(name):
             raise exception.InvalidBucketName(self.bucket)
     if not utils.is_valid_image_name(self.prefix):
         raise exception.InvalidImageName(self.prefix)
     self.ec2 = awsutils.EasyEC2(
         aws_access_key_id = self.access_key, 
         aws_secret_access_key = self.secret_key,
     )
     if not self.cert:
         try:
             self.cert = os.environ['EC2_CERT']
         except KeyError,e:
             raise exception.EC2CertRequired()
Exemple #2
0
 def __init__(self,
              easy_ec2,
              instance_id,
              key_location,
              aws_user_id,
              ec2_cert,
              ec2_private_key,
              bucket,
              image_name='image',
              description=None,
              kernel_id=None,
              ramdisk_id=None,
              remove_image_files=False,
              **kwargs):
     super(S3ImageCreator,
           self).__init__(easy_ec2, instance_id, key_location, description,
                          kernel_id, ramdisk_id)
     self.userid = aws_user_id
     self.cert = ec2_cert
     self.private_key = ec2_private_key
     self.bucket = bucket
     self.prefix = image_name
     self.description = description
     self.remove_image_files = remove_image_files
     for name in self.bucket.split("/"):
         if not utils.is_valid_bucket_name(name):
             raise exception.InvalidBucketName(self.bucket)
     if not utils.is_valid_image_name(self.prefix):
         raise exception.InvalidImageName(self.prefix)
     if not self.cert:
         try:
             self.cert = os.environ['EC2_CERT']
         except KeyError:
             raise exception.EC2CertRequired()
     if not self.private_key:
         try:
             self.private_key = os.environ['EC2_PRIVATE_KEY']
         except KeyError:
             raise exception.EC2PrivateKeyRequired()
     if not self.userid:
         raise exception.AWSUserIdRequired()
     if not os.path.exists(self.cert):
         raise exception.EC2CertDoesNotExist(self.cert)
     if not os.path.exists(self.private_key):
         raise exception.EC2PrivateKeyDoesNotExist(self.private_key)
     self.config_dict = {
         'access_key': self.ec2.aws_access_key_id,
         'secret_key': self.ec2.aws_secret_access_key,
         'private_key': os.path.split(self.private_key)[-1],
         'userid': self.userid,
         'cert': os.path.split(self.cert)[-1],
         'bucket': self.bucket,
         'prefix': self.prefix,
         'arch': self.host.architecture,
         'bmap': self._instance_store_bmap_str()
     }
Exemple #3
0
 def __init__(
     self,
     easy_ec2,
     instance_id,
     key_location,
     aws_user_id,
     ec2_cert,
     ec2_private_key,
     bucket,
     image_name="image",
     description=None,
     kernel_id=None,
     ramdisk_id=None,
     remove_image_files=False,
     **kwargs
 ):
     super(S3ImageCreator, self).__init__(easy_ec2, instance_id, key_location, description, kernel_id, ramdisk_id)
     self.userid = aws_user_id
     self.cert = ec2_cert
     self.private_key = ec2_private_key
     self.bucket = bucket
     self.prefix = image_name
     self.description = description
     self.remove_image_files = remove_image_files
     for name in self.bucket.split("/"):
         if not utils.is_valid_bucket_name(name):
             raise exception.InvalidBucketName(self.bucket)
     if not utils.is_valid_image_name(self.prefix):
         raise exception.InvalidImageName(self.prefix)
     if not self.cert:
         try:
             self.cert = os.environ["EC2_CERT"]
         except KeyError:
             raise exception.EC2CertRequired()
     if not self.private_key:
         try:
             self.private_key = os.environ["EC2_PRIVATE_KEY"]
         except KeyError:
             raise exception.EC2PrivateKeyRequired()
     if not self.userid:
         raise exception.AWSUserIdRequired()
     if not os.path.exists(self.cert):
         raise exception.EC2CertDoesNotExist(self.cert)
     if not os.path.exists(self.private_key):
         raise exception.EC2PrivateKeyDoesNotExist(self.private_key)
     self.config_dict = {
         "access_key": self.ec2.aws_access_key_id,
         "secret_key": self.ec2.aws_secret_access_key,
         "private_key": os.path.split(self.private_key)[-1],
         "userid": self.userid,
         "cert": os.path.split(self.cert)[-1],
         "bucket": self.bucket,
         "prefix": self.prefix,
         "arch": self.host.architecture,
         "bmap": self._instance_store_bmap_str(),
     }