예제 #1
0
 def test_list_invalid_ips(self):
     self.assertRaises(
         errors.InvalidParameter,
         argument.List(argument.IPNetwork()).clean,
         None,
         ["0.0.0.0/"],
     )
예제 #2
0
class Bundle(resource.Resource):

    resource_name = "fuselage_bundle"

    connection = argument.Resource(Connection)
    resources = argument.List()

    root = argument.Resource(workspace.Workspace)
예제 #3
0
class ForwardedValues(Resource):

    resource_name = "forwarded_values"
    dot_ignore = True

    extra_serializers = {
        "Cookies":
        serializers.Dict(
            Forward=serializers.Argument("forward_cookies"),
            WhitelistedNames=CloudFrontList(
                serializers.Argument("cookie_whitelist")),
        )
    }
    query_string = argument.Boolean(field="QueryString", default=False)
    headers = argument.List(field="Headers",
                            serializer=CloudFrontList(serializers.List()))

    forward_cookies = argument.String(default="whitelist")
    cookie_whitelist = argument.List()
예제 #4
0
class AutoScalingGroup(Resource):

    resource_name = "auto_scaling_group"

    name = argument.String(field="AutoScalingGroupName")
    launch_configuration = argument.Resource(LaunchConfiguration,
                                             field="LaunchConfigurationName")
    min_size = argument.Integer(field="MinSize")
    max_size = argument.Integer(field="MaxSize")
    desired_capacity = argument.Integer(field="DesiredCapacity")
    default_cooldown = argument.Integer(default=300, field="DefaultCooldown")
    availability_zones = argument.List(
        field="AvailabilityZones",
        serializer=serializers.List(skip_empty=True))
    subnets = argument.ResourceList(
        Subnet,
        field="VPCZoneIdentifier",
        serializer=serializers.CommaSeperatedList(
            serializers.List(serializers.Identifier())),
    )
    load_balancers = argument.ResourceList(LoadBalancer,
                                           field="LoadBalancerNames",
                                           aws_update=False)
    health_check_type = argument.String(
        max=32,
        default=lambda instance: "ELB" if instance.load_balancers else None,
        field="HealthCheckType",
    )
    health_check_grace_period = argument.Integer(
        default=lambda instance: 480 if instance.load_balancers else None,
        field="HealthCheckGracePeriod",
    )
    placement_group = argument.String(max=255, field="PlacementGroup")
    termination_policies = argument.List(default=lambda i: ["Default"],
                                         field="TerminationPolicies")
    replacement_policy = argument.String(choices=['singleton', 'graceful'],
                                         default='graceful')

    account = argument.Resource(BaseAccount)
예제 #5
0
class DefaultCacheBehavior(Resource):

    resource_name = "default_cache_behaviour"
    dot_ignore = True

    extra_serializers = {
        # TrustedSigners are not supported yet, so include stub in serialized form
        "TrustedSigners":
        serializers.Const({
            "Enabled": False,
            "Quantity": 0,
        }),
        "AllowedMethods":
        CloudFrontList(
            inner=serializers.Context(serializers.Argument("allowed_methods"),
                                      serializers.List()),
            CachedMethods=serializers.Context(
                serializers.Argument("cached_methods"), CloudFrontList()),
        ),
    }

    target_origin = argument.String(field='TargetOriginId')
    forwarded_values = argument.Resource(
        ForwardedValues,
        default=lambda instance: dict(),
        field="ForwardedValues",
        serializer=serializers.Resource(),
    )
    viewer_protocol_policy = argument.String(
        choices=['allow-all', 'https-only', 'redirect-to-https'],
        default='allow-all',
        field="ViewerProtocolPolicy")
    min_ttl = argument.Integer(default=0, field="MinTTL")
    allowed_methods = argument.List(default=lambda x: ["GET", "HEAD"])
    cached_methods = argument.List(default=lambda x: ["GET", "HEAD"])
    smooth_streaming = argument.Boolean(default=False, field='SmoothStreaming')
예제 #6
0
파일: zone.py 프로젝트: yaybu/takeoff
class Zone(Resource):

    name = argument.String()

    prefix = argument.Integer(default=24)

    cidr_block = argument.IPNetwork()
    """ Is this zone on the public internet? """
    public = argument.Boolean(default=False)
    """ The availability zones to create this zone in """
    availability_zones = argument.List(
        argument.String(min=1, max=1),
        min=2,
        max=2,
        default=["a", "b"],
    )

    environment = argument.Resource(Environment)
예제 #7
0
class VpnConnection(Resource):

    resource_name = "vpn_connection"

    name = argument.String()
    customer_gateway = argument.Resource(CustomerGateway, field="CustomerGatewayId")
    vpn_gateway = argument.Resource(VpnGateway, field="VpnGatewayId")
    type = argument.String(default="ipsec.1", choices=["ipsec.1"], field="Type")

    static_routes_only = argument.Boolean(
        default=True,
        field="Options",
        serializer=serializers.Dict(StaticRoutesOnly=serializers.Boolean()),
    )

    static_routes = argument.List()
    # FIXME: This should somehow be a list of argument.IPNetwork

    tags = argument.Dict()
    vpc = argument.Resource(VPC)
예제 #8
0
class LoadBalancer(Resource):

    resource_name = "load_balancer"

    name = argument.String(field="LoadBalancerName")
    listeners = argument.ResourceList(
        Listener,
        field="Listeners",
        serializer=serializers.List(serializers.Resource()),
    )
    availability_zones = argument.List(field="AvailabilityZones")
    scheme = argument.String(choices=["internet-facing", "private"],
                             field="Scheme")
    subnets = argument.ResourceList(Subnet, field="Subnets")
    security_groups = argument.ResourceList(SecurityGroup,
                                            field="SecurityGroups")
    # tags = argument.Dict()

    health_check = argument.Resource(HealthCheck)
    attributes = argument.Resource(Attributes)

    account = argument.Resource(Account)
예제 #9
0
class Record(Resource):

    resource_name = "record"

    name = argument.String(field="Name")
    type = argument.String(field="Type")
    values = argument.List(field="ResourceRecords",
                           serializer=serializers.List(serializers.Dict(
                               Value=serializers.Identity(), ),
                                                       skip_empty=True))
    ttl = argument.Integer(min=0, field="TTL")

    set_identifier = argument.Integer(min=1, max=128, field="SetIdentifier")

    alias = argument.Resource(
        AliasTarget,
        field="AliasTarget",
        serializer=serializers.Resource(),
    )

    def clean_name(self, name):
        return _normalize(name)
예제 #10
0
 def test_not_a_list(self):
     self.assertRaises(errors.InvalidParameter,
                       argument.List().clean, None, {})
예제 #11
0
 def test_list_ips(self):
     result = argument.List(argument.IPNetwork()).clean(None, ["0.0.0.0/0"])
     self.assertTrue(isinstance(result, list))
     self.assertTrue(isinstance(result[0], netaddr.IPNetwork))
예제 #12
0
class Distribution(Resource):

    resource_name = "distribution"

    extra_serializers = {
        "CallerReference":
        serializers.Expression(lambda runner, object: runner.get_plan(object).
                               object.get('DistributionConfig', {}).get(
                                   'CallerReference', str(uuid.uuid4()))),
        "Aliases":
        CloudFrontList(
            serializers.Chain(
                serializers.Context(serializers.Argument("name"),
                                    serializers.ListOfOne()),
                serializers.Context(serializers.Argument("aliases"),
                                    serializers.List()),
            )),
        # We don't support GeoRestrictions yet - so include a stubbed default
        # when serializing
        "Restrictions":
        serializers.Const({
            "GeoRestriction": {
                "RestrictionType": "none",
                "Quantity": 0,
            },
        }),
    }

    name = argument.String()
    comment = argument.String(field='Comment',
                              default=lambda instance: instance.name)
    aliases = argument.List()
    root_object = argument.String(default='/', field="DefaultRootObject")
    enabled = argument.Boolean(default=True, field="Enabled")
    origins = argument.ResourceList(
        (S3Origin, CustomOrigin),
        field="Origins",
        serializer=CloudFrontResourceList(),
    )
    default_cache_behavior = argument.Resource(
        DefaultCacheBehavior,
        field="DefaultCacheBehavior",
        serializer=serializers.Resource(),
    )
    behaviors = argument.ResourceList(
        CacheBehavior,
        field="CacheBehaviors",
        serializer=CloudFrontResourceList(),
    )
    error_responses = argument.ResourceList(
        ErrorResponse,
        field="CustomErrorResponses",
        serializer=CloudFrontResourceList(),
    )
    logging = argument.Resource(
        LoggingConfig,
        default=lambda instance: dict(enabled=False),
        field="Logging",
        serializer=serializers.Resource(),
    )
    price_class = argument.String(
        default="PriceClass_100",
        choices=['PriceClass_100', 'PriceClass_200', 'PriceClass_All'],
        field="PriceClass",
    )
    viewer_certificate = argument.Resource(
        ViewerCertificate,
        field="ViewerCertificate",
        serializer=serializers.Resource(),
    )

    account = argument.Resource(Account)