コード例 #1
0
 def test_0050_edit(self):
     firewall_obj = FirewallRule(TestFirewallRules._org_client,
                                 TestFirewallRules._name,
                                 TestFirewallRules._rule_id)
     ext_net_resource = TestFirewallRules._external_network.get_resource()
     source_object = [
         ext_net_resource.get('name') + ':gatewayinterface',
         OvdcNetConstants.routed_net_name + ':network', '2.3.2.2:ip'
     ]
     destination_object = [
         ext_net_resource.get('name') + ':gatewayinterface',
         OvdcNetConstants.routed_net_name + ':network', '2.3.2.2:ip'
     ]
     source = [{
         'tcp': {
             'any': 'any'
         }
     }, {
         'icmp': {
             'any': 'any'
         }
     }, {
         'any': {
             'any': 'any'
         }
     }]
     new_name = 'Rule_New_Name_Test'
     firewall_obj.edit(source_object, destination_object, source, new_name)
     # Verify
     firewall_obj._reload()
     firewall_res = firewall_obj.resource
     self.assertTrue(hasattr(firewall_res.source, 'vnicGroupId'))
     self.assertTrue(hasattr(firewall_res.source, 'groupingObjectId'))
     self.assertTrue(hasattr(firewall_res.source, 'ipAddress'))
     self.assertTrue(hasattr(firewall_res.destination, 'vnicGroupId'))
     self.assertTrue(hasattr(firewall_res.destination, 'groupingObjectId'))
     self.assertTrue(hasattr(firewall_res.destination, 'ipAddress'))
     self.assertTrue(hasattr(firewall_res.application, 'service'))
     self.assertEqual(firewall_res.name, 'Rule_New_Name_Test')
     # revert back name change to old name
     firewall_obj.edit(source_object, destination_object, source,
                       TestFirewallRules._firewall_rule_name)
コード例 #2
0
 def test_0050_edit(self):
     firewall_obj = FirewallRule(TestFirewallRules._org_client,
                                 TestFirewallRules._name,
                                 TestFirewallRules._rule_id)
     ext_net_resource = TestFirewallRules._external_network.get_resource()
     source_object = [
         ext_net_resource.get('name') + ':gatewayinterface',
         OvdcNetConstants.routed_net_name + ':network', '2.3.2.2:ip'
     ]
     destination_object = [
         ext_net_resource.get('name') + ':gatewayinterface',
         OvdcNetConstants.routed_net_name + ':network', '2.3.2.2:ip'
     ]
     source = [{
         'tcp': {
             'any': 'any'
         }
     }, {
         'icmp': {
             'any': 'any'
         }
     }, {
         'any': {
             'any': 'any'
         }
     }]
     new_name = 'Rule_New_Name_Test'
     firewall_obj.edit(source_object, destination_object, source, new_name)
     # Verify
     firewall_obj._reload()
     firewall_res = firewall_obj.resource
     self.assertTrue(hasattr(firewall_res.source, 'vnicGroupId'))
     self.assertTrue(hasattr(firewall_res.source, 'groupingObjectId'))
     self.assertTrue(hasattr(firewall_res.source, 'ipAddress'))
     self.assertTrue(hasattr(firewall_res.destination, 'vnicGroupId'))
     self.assertTrue(hasattr(firewall_res.destination, 'groupingObjectId'))
     self.assertTrue(hasattr(firewall_res.destination, 'ipAddress'))
     self.assertTrue(hasattr(firewall_res.application, 'service'))
     self.assertEqual(firewall_res.name, 'Rule_New_Name_Test')
     # revert back name change to old name
     firewall_obj.edit(source_object, destination_object, source,
                       TestFirewallRules._firewall_rule_name)
コード例 #3
0
ファイル: firewall_rule.py プロジェクト: rocknes/vcd-cli
def update_firewall(ctx, name, rule_id, source_values, destination_values,
                    services, new_name):
    try:
        restore_session(ctx, vdc_required=True)
        client = ctx.obj['client']
        firewall = FirewallRule(client, gateway_name=name, resource_id=rule_id)
        if source_values:
            firewall.validate_types(source_values, 'source')
        if destination_values:
            firewall.validate_types(destination_values, 'destination')
        application_services = []
        if services:
            for service in services:
                application_services.append(tuple_to_dict([service]))

        firewall.edit(source_values, destination_values, application_services,
                      new_name)

        stdout('Firewall rule updated successfully.', ctx)
    except Exception as e:
        stderr(e, ctx)
コード例 #4
0
ファイル: firewall_rule.py プロジェクト: vmware/vca-cli
def update_firewall(ctx, name, rule_id, source_values, destination_values,
                    services, new_name):
    try:
        restore_session(ctx, vdc_required=True)
        client = ctx.obj['client']
        firewall = FirewallRule(client, gateway_name=name, resource_id=rule_id)
        if source_values:
            firewall.validate_types(source_values, 'source')
        if destination_values:
            firewall.validate_types(destination_values, 'destination')
        application_services = []
        if services:
            for service in services:
                application_services.append(tuple_to_dict([service]))

        firewall.edit(source_values, destination_values, application_services,
                      new_name)

        stdout('Firewall rule updated successfully.', ctx)
    except Exception as e:
        stderr(e, ctx)
コード例 #5
0
 def test_0051_edit_from_any_to_any(self):
     firewall_obj = FirewallRule(TestFirewallRules._org_client,
                                 TestFirewallRules._name,
                                 TestFirewallRules._rule_id)
     source_object = [
         'any'
     ]
     destination_object = [
         'any'
     ]
     source = [{
         'tcp': {
             'any': 'any'
         }
     }, {
         'icmp': {
             'any': 'any'
         }
     }, {
         'any': {
             'any': 'any'
         }
     }]
     firewall_obj.edit(source_object, destination_object, source, TestFirewallRules._name)