示例#1
0
    def test_exactly_one_source_ami(self):
        ami_root_dev = builder.BlockDeviceMapping()
        b = builder.AmazonEbsSurrogate(
            access_key="dummy-access-key",
            secret_key="dummy-secret-key",
            instance_type="t2.micro",
            source_device_name="some_device",
            region="us-east-1",
            ami_root_device=[ami_root_dev],
        )

        with pytest.raises(ValueError) as excinfo:
            b.to_dict()
        assert 'AmazonEbsSurrogate: one of the following must be specified: source_ami, source_ami_filter' == str(
            excinfo.value)
示例#2
0
    def test_mutually_exclusive_security_group_ami(self):
        ami_root_dev = builder.BlockDeviceMapping()
        b = builder.AmazonEbsSurrogate(
            access_key="dummy-access-key",
            secret_key="dummy-secret-key",
            instance_type="t2.micro",
            source_device_name="some_device",
            region="us-east-1",
            ami_root_device=[ami_root_dev],
            source_ami="dummy-source-ami",
            security_group_id="sg-123",
            security_group_ids=["sg-123", "sg-456"],
        )

        with pytest.raises(ValueError) as excinfo:
            b.to_dict()
        assert 'AmazonEbsSurrogate: only one of the following can be specified: security_group_id, security_group_ids' == str(
            excinfo.value)
示例#3
0
    def test_mutually_exclusive_subnet_id(self):
        ami_root_dev = builder.BlockDeviceMapping()
        b = builder.AmazonEbsSurrogate(
            access_key="dummy-access-key",
            secret_key="dummy-secret-key",
            instance_type="t2.micro",
            source_device_name="some_device",
            region="us-east-1",
            ami_root_device=[ami_root_dev],
            source_ami="dummy-source-ami",
            subnet_id="subnet-12345def",
            subnet_filter=builder.AmazonSubnetFilter(
                filters={"tag:Class": "build"}, most_free=True, random=True),
        )

        with pytest.raises(ValueError) as excinfo:
            b.to_dict()
        assert 'AmazonEbsSurrogate: only one of the following can be specified: subnet_id, subnet_filter' == str(
            excinfo.value)