def test_open_provider_port(self):
        """Verify open port op will use the correct EC2 API."""
        log = self.capture_logging("juju.ec2", level=logging.DEBUG)
        machine = ProviderMachine("i-foobar", "x1.example.com")
        self.ec2.authorize_security_group(
            "juju-moon-machine-1", ip_protocol="tcp", from_port="80",
            to_port="80", cidr_ip="0.0.0.0/0")
        self.mocker.result(succeed(True))
        self.mocker.replay()

        provider = self.get_provider()
        yield open_provider_port(provider, machine, "machine-1", 80, "tcp")
        self.assertIn(
            "Opened 80/tcp on provider machine 'i-foobar'",
            log.getvalue())
示例#2
0
    def test_open_provider_port(self):
        """Verify open port op will use the correct EC2 API."""
        log = self.capture_logging("juju.ec2", level=logging.DEBUG)
        machine = ProviderMachine("i-foobar", "x1.example.com")
        self.ec2.authorize_security_group("juju-moon-machine-1",
                                          ip_protocol="tcp",
                                          from_port="80",
                                          to_port="80",
                                          cidr_ip="0.0.0.0/0")
        self.mocker.result(succeed(True))
        self.mocker.replay()

        provider = self.get_provider()
        yield open_provider_port(provider, machine, "machine-1", 80, "tcp")
        self.assertIn("Opened 80/tcp on provider machine 'i-foobar'",
                      log.getvalue())
    def test_open_provider_port_unknown_instance(self):
        """Verify open port op will use the correct EC2 API."""
        machine = ProviderMachine("i-foobar", "x1.example.com")
        self.ec2.authorize_security_group(
            "juju-moon-machine-1", ip_protocol="tcp", from_port="80",
            to_port="80", cidr_ip="0.0.0.0/0")
        self.mocker.result(fail(self.get_ec2_error("i-foobar")))
        self.mocker.replay()

        provider = self.get_provider()
        ex = yield self.assertFailure(
            open_provider_port(provider, machine, "machine-1", 80, "tcp"),
            ProviderInteractionError)
        self.assertEqual(
            str(ex),
            "Unexpected EC2Error opening 80/tcp on machine i-foobar: "
            "The instance ID 'i-foobar' does not exist")
示例#4
0
    def test_open_provider_port_unknown_instance(self):
        """Verify open port op will use the correct EC2 API."""
        machine = ProviderMachine("i-foobar", "x1.example.com")
        self.ec2.authorize_security_group("juju-moon-machine-1",
                                          ip_protocol="tcp",
                                          from_port="80",
                                          to_port="80",
                                          cidr_ip="0.0.0.0/0")
        self.mocker.result(fail(self.get_ec2_error("i-foobar")))
        self.mocker.replay()

        provider = self.get_provider()
        ex = yield self.assertFailure(
            open_provider_port(provider, machine, "machine-1", 80, "tcp"),
            ProviderInteractionError)
        self.assertEqual(
            str(ex), "Unexpected EC2Error opening 80/tcp on machine i-foobar: "
            "The instance ID 'i-foobar' does not exist")