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"])
Beispiel #2
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)
Beispiel #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)
Beispiel #4
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"])