Ejemplo n.º 1
0
    def test_0000_setup(self):

        self._config = Environment.get_config()
        TestFirewallRule._logger = Environment.get_default_logger()
        TestFirewallRule._client = Environment.get_sys_admin_client()
        TestFirewallRule._runner = CliRunner()
        default_org = self._config['vcd']['default_org_name']
        TestFirewallRule._ext_nw = self._config['external_network']['name']
        self._login()
        TestFirewallRule._runner.invoke(org, ['use', default_org])
        result = TestFirewallRule._runner.invoke(
            gateway,
            args=[
                'services', 'firewall', 'create', TestFirewallRule.__name,
                '--name', TestFirewallRule.__firewall_rule_name, '--action',
                'accept', '--type', 'User', '--enabled', '--logging-enabled'
            ])
        self.assertEqual(0, result.exit_code)
        gateway_res = Environment.get_test_gateway(TestFirewallRule._client)
        gateway_obj = Gateway(TestFirewallRule._client,
                              href=gateway_res.get('href'))
        firewall_rules = gateway_obj.get_firewall_rules()
        for rule in firewall_rules.firewallRules.firewallRule:
            if rule.name == TestFirewallRule.__firewall_rule_name:
                TestFirewallRule._rule_id = rule.id
                break
Ejemplo n.º 2
0
    def test_0000_setup(self):

        self._config = Environment.get_config()
        TestFirewallRule._logger = Environment.get_default_logger()
        TestFirewallRule._client = Environment.get_sys_admin_client()
        TestFirewallRule._runner = CliRunner()
        default_org = self._config['vcd']['default_org_name']
        TestFirewallRule._ext_nw = self._config['external_network']['name']
        self._login()
        TestFirewallRule._runner.invoke(org, ['use', default_org])
        result = TestFirewallRule._runner.invoke(
            gateway,
            args=[
                'services', 'firewall', 'create', TestFirewallRule.__name,
                '--name', TestFirewallRule.__firewall_rule_name, '--action',
                'accept', '--type', 'User', '--enabled', '--logging-enabled'
            ])
        self.assertEqual(0, result.exit_code)
        gateway_res = Environment.get_test_gateway(TestFirewallRule._client)
        gateway_obj = Gateway(
            TestFirewallRule._client, href=gateway_res.get('href'))
        firewall_rules = gateway_obj.get_firewall_rules()
        for rule in firewall_rules.firewallRules.firewallRule:
            if rule.name == TestFirewallRule.__firewall_rule_name:
                TestFirewallRule._rule_id = rule.id
                break
Ejemplo n.º 3
0
    def test_0025_add_firewall_rule(self):
        """Add Firewall Rule's in the gateway."""

        gateway_obj = Gateway(TestGateway._client, self._name,
                              TestGateway._gateway.get('href'))
        gateway_obj.add_firewall_rule(TestGateway._firewall_rule_name)
        firewall_rule = gateway_obj.get_firewall_rules()
        # Verify
        matchFound = False
        for firewallRule in firewall_rule.firewallRules.firewallRule:
            if firewallRule['name'] == TestGateway._firewall_rule_name:
                matchFound = True
                break
        self.assertTrue(matchFound)
Ejemplo n.º 4
0
    def test_0095_add_firewall_rule(self):
        """Add Firewall Rule's in the gateway."""

        gateway_obj = Gateway(TestGateway._client, self._name,
                              TestGateway._gateway.get('href'))
        gateway_obj.add_firewall_rule(TestGateway._firewall_rule_name)
        firewall_rule = gateway_obj.get_firewall_rules()
        # Verify
        matchFound = False
        for firewallRule in firewall_rule.firewallRules.firewallRule:
            if firewallRule['name'] == TestGateway._firewall_rule_name:
                matchFound = True
                break
        self.assertTrue(matchFound)
Ejemplo n.º 5
0
    def update_firewall_rule_sequence(self, index):
        """Change firewall rule's sequence of gateway.

        :param int index: new sequence index of firewall rule.
        """
        index = int(index)
        gateway_res = Gateway(self.client, resource=self.parent)
        firewall_rule = gateway_res.get_firewall_rules()
        resource = self._get_resource()
        for rule in firewall_rule.firewallRules.firewallRule:
            if rule.id == resource.id:
                firewall_rule.firewallRules.remove(rule)
                firewall_rule.firewallRules.insert(index, rule)
                break
        return self.client.put_resource(self._build_firewall_rules_href(),
                                        firewall_rule,
                                        EntityType.DEFAULT_CONTENT_TYPE.value)
Ejemplo n.º 6
0
    def update_firewall_rule_sequence(self, index):
        """Change firewall rule's sequence of gateway.

        :param int index: new sequence index of firewall rule.
        """
        index = int(index)
        gateway_res = Gateway(self.client, resource=self.parent)
        firewall_rule = gateway_res.get_firewall_rules()
        resource = self._get_resource()
        for rule in firewall_rule.firewallRules.firewallRule:
            if rule.id == resource.id:
                firewall_rule.firewallRules.remove(rule)
                firewall_rule.firewallRules.insert(index, rule)
                break
        return self.client.put_resource(self._build_firewall_rules_href(),
                                        firewall_rule,
                                        EntityType.DEFAULT_CONTENT_TYPE.value)