Ejemplo n.º 1
0
    def resource_setup(cls):
        super(InstanceRunTest, cls).resource_setup()
        if not cls.conclusion['A_I_IMAGES_READY']:
            raise cls.skipException("".join(("EC2 ", cls.__name__,
                                    ": requires ami/aki/ari manifest")))
        cls.zone = CONF.boto.aws_zone
        cls.materials_path = CONF.boto.s3_materials_path
        ami_manifest = CONF.boto.ami_manifest
        aki_manifest = CONF.boto.aki_manifest
        ari_manifest = CONF.boto.ari_manifest
        cls.instance_type = CONF.boto.instance_type
        cls.bucket_name = data_utils.rand_name("s3bucket")
        cls.keypair_name = data_utils.rand_name("keypair")
        cls.keypair = cls.ec2_client.create_key_pair(cls.keypair_name)
        cls.addResourceCleanUp(cls.ec2_client.delete_key_pair,
                               cls.keypair_name)
        bucket = cls.s3_client.create_bucket(cls.bucket_name)
        cls.addResourceCleanUp(cls.destroy_bucket,
                               cls.s3_client.connection_data,
                               cls.bucket_name)
        s3.s3_upload_dir(bucket, cls.materials_path)
        cls.images = {"ami":
                      {"name": data_utils.rand_name("ami-name"),
                       "location": cls.bucket_name + "/" + ami_manifest},
                      "aki":
                      {"name": data_utils.rand_name("aki-name"),
                       "location": cls.bucket_name + "/" + aki_manifest},
                      "ari":
                      {"name": data_utils.rand_name("ari-name"),
                       "location": cls.bucket_name + "/" + ari_manifest}}
        for image_type in ("aki", "ari"):
            image = cls.images[image_type]
            image["image_id"] = cls.ec2_client.register_image(
                name=image["name"],
                image_location=image["location"])
            cls.addResourceCleanUp(cls.ec2_client.deregister_image,
                                   image["image_id"])
        image = cls.images["ami"]
        image["image_id"] = cls.ec2_client.register_image(
            name=image["name"],
            image_location=image["location"],
            kernel_id=cls.images["aki"]["image_id"],
            ramdisk_id=cls.images["ari"]["image_id"])
        cls.addResourceCleanUp(cls.ec2_client.deregister_image,
                               image["image_id"])

        for image in cls.images.itervalues():
            def _state():
                retr = cls.ec2_client.get_image(image["image_id"])
                return retr.state
            state = wait.state_wait(_state, "available")
            if state != "available":
                for _image in cls.images.itervalues():
                    cls.ec2_client.deregister_image(_image["image_id"])
                raise exceptions.EC2RegisterImageException(
                    image_id=image["image_id"])
Ejemplo n.º 2
0
    def setUpClass(cls):
        super(InstanceRunTest, cls).setUpClass()
        if not cls.conclusion['A_I_IMAGES_READY']:
            raise cls.skipException("".join(("EC2 ", cls.__name__,
                                    ": requires ami/aki/ari manifest")))
        cls.os = clients.Manager()
        cls.s3_client = cls.os.s3_client
        cls.ec2_client = cls.os.ec2api_client
        cls.zone = cls.ec2_client.get_good_zone()
        config = cls.config
        cls.materials_path = config.boto.s3_materials_path
        ami_manifest = config.boto.ami_manifest
        aki_manifest = config.boto.aki_manifest
        ari_manifest = config.boto.ari_manifest
        cls.instance_type = config.boto.instance_type
        cls.bucket_name = rand_name("s3bucket-")
        cls.keypair_name = rand_name("keypair-")
        cls.keypair = cls.ec2_client.create_key_pair(cls.keypair_name)
        cls.addResourceCleanUp(cls.ec2_client.delete_key_pair,
                               cls.keypair_name)
        bucket = cls.s3_client.create_bucket(cls.bucket_name)
        cls.addResourceCleanUp(cls.destroy_bucket,
                               cls.s3_client.connection_data,
                               cls.bucket_name)
        s3_upload_dir(bucket, cls.materials_path)
        cls.images = {"ami":
                      {"name": rand_name("ami-name-"),
                       "location": cls.bucket_name + "/" + ami_manifest},
                      "aki":
                      {"name": rand_name("aki-name-"),
                       "location": cls.bucket_name + "/" + aki_manifest},
                      "ari":
                      {"name": rand_name("ari-name-"),
                       "location": cls.bucket_name + "/" + ari_manifest}}
        for image in cls.images.itervalues():
            image["image_id"] = cls.ec2_client.register_image(
                name=image["name"],
                image_location=image["location"])
            cls.addResourceCleanUp(cls.ec2_client.deregister_image,
                                   image["image_id"])

        for image in cls.images.itervalues():
            def _state():
                retr = cls.ec2_client.get_image(image["image_id"])
                return retr.state
            state = state_wait(_state, "available")
            if state != "available":
                for _image in cls.images.itervalues():
                    cls.ec2_client.deregister_image(_image["image_id"])
                raise exceptions.EC2RegisterImageException(image_id=
                                                           image["image_id"])
Ejemplo n.º 3
0
 def resource_setup(cls):
     super(S3ImagesTest, cls).resource_setup()
     if not cls.conclusion['A_I_IMAGES_READY']:
         raise cls.skipException("".join(("EC2 ", cls.__name__,
                                 ": requires ami/aki/ari manifest")))
     cls.materials_path = CONF.boto.s3_materials_path
     cls.ami_manifest = CONF.boto.ami_manifest
     cls.aki_manifest = CONF.boto.aki_manifest
     cls.ari_manifest = CONF.boto.ari_manifest
     cls.ami_path = cls.materials_path + os.sep + cls.ami_manifest
     cls.aki_path = cls.materials_path + os.sep + cls.aki_manifest
     cls.ari_path = cls.materials_path + os.sep + cls.ari_manifest
     cls.bucket_name = data_utils.rand_name("bucket")
     bucket = cls.s3_client.create_bucket(cls.bucket_name)
     cls.addResourceCleanUp(cls.destroy_bucket,
                            cls.s3_client.connection_data,
                            cls.bucket_name)
     s3.s3_upload_dir(bucket, cls.materials_path)
Ejemplo n.º 4
0
 def setUpClass(cls):
     super(S3ImagesTest, cls).setUpClass()
     if not cls.conclusion["A_I_IMAGES_READY"]:
         raise cls.skipException("".join(("EC2 ", cls.__name__, ": requires ami/aki/ari manifest")))
     cls.os = clients.Manager()
     cls.s3_client = cls.os.s3_client
     cls.images_client = cls.os.ec2api_client
     config = cls.config
     cls.materials_path = config.boto.s3_materials_path
     cls.ami_manifest = config.boto.ami_manifest
     cls.aki_manifest = config.boto.aki_manifest
     cls.ari_manifest = config.boto.ari_manifest
     cls.ami_path = cls.materials_path + os.sep + cls.ami_manifest
     cls.aki_path = cls.materials_path + os.sep + cls.aki_manifest
     cls.ari_path = cls.materials_path + os.sep + cls.ari_manifest
     cls.bucket_name = data_utils.rand_name("bucket-")
     bucket = cls.s3_client.create_bucket(cls.bucket_name)
     cls.addResourceCleanUp(cls.destroy_bucket, cls.s3_client.connection_data, cls.bucket_name)
     s3_upload_dir(bucket, cls.materials_path)