Beispiel #1
0
    def release_address(self):
        if "PublicIp" in self.querystring:
            released = ec2_backend.release_address(address=self.querystring['PublicIp'][0])
        elif "AllocationId" in self.querystring:
            released = ec2_backend.release_address(allocation_id=self.querystring['AllocationId'][0])
        else:
            ec2_backend.raise_error("MissingParameter", "Invalid request, expect PublicIp/AllocationId parameter.")

        return Template(RELEASE_ADDRESS_RESPONSE).render()
Beispiel #2
0
    def disassociate_address(self):
        if "PublicIp" in self.querystring:
            disassociated = ec2_backend.disassociate_address(address=self.querystring['PublicIp'][0])
        elif "AssociationId" in self.querystring:
            disassociated = ec2_backend.disassociate_address(association_id=self.querystring['AssociationId'][0])
        else:
            ec2_backend.raise_error("MissingParameter", "Invalid request, expect PublicIp/AssociationId parameter.")

        return Template(DISASSOCIATE_ADDRESS_RESPONSE).render()
Beispiel #3
0
    def disassociate_address(self):
        if "PublicIp" in self.querystring:
            disassociated = ec2_backend.disassociate_address(address=self.querystring['PublicIp'][0])
        elif "AssociationId" in self.querystring:
            disassociated = ec2_backend.disassociate_address(association_id=self.querystring['AssociationId'][0])
        else:
            ec2_backend.raise_error("MissingParameter", "Invalid request, expect PublicIp/AssociationId parameter.")

        return Template(DISASSOCIATE_ADDRESS_RESPONSE).render()
Beispiel #4
0
    def release_address(self):
        if "PublicIp" in self.querystring:
            released = ec2_backend.release_address(address=self.querystring['PublicIp'][0])
        elif "AllocationId" in self.querystring:
            released = ec2_backend.release_address(allocation_id=self.querystring['AllocationId'][0])
        else:
            ec2_backend.raise_error("MissingParameter", "Invalid request, expect PublicIp/AllocationId parameter.")

        return Template(RELEASE_ADDRESS_RESPONSE).render()
Beispiel #5
0
    def associate_address(self):
        if "InstanceId" in self.querystring:
            instance = ec2_backend.get_instance(self.querystring['InstanceId'][0])
        elif "NetworkInterfaceId" in self.querystring:
            raise NotImplementedError("Lookup by allocation id not implemented")
        else:
            ec2_backend.raise_error("MissingParameter", "Invalid request, expect InstanceId/NetworkId parameter.")

        reassociate = False
        if "AllowReassociation" in self.querystring:
            reassociate = self.querystring['AllowReassociation'][0] == "true"

        if "PublicIp" in self.querystring:
            eip = ec2_backend.associate_address(instance, address=self.querystring['PublicIp'][0], reassociate=reassociate)
        elif "AllocationId" in self.querystring:
            eip = ec2_backend.associate_address(instance, allocation_id=self.querystring['AllocationId'][0], reassociate=reassociate)
        else:
            ec2_backend.raise_error("MissingParameter", "Invalid request, expect PublicIp/AllocationId parameter.")

        template = Template(ASSOCIATE_ADDRESS_RESPONSE)
        return template.render(address=eip)