Exemple #1
0
 def test_update_policy_target_group_unset_apg(self):
     """policy-target-group-update."""
     resource = 'policy_target_group'
     cmd = gbp.UpdatePolicyTargetGroup(test_cli20.MyApp(sys.stdout), None)
     my_id = 'my-id'
     application_policy_group_id = ''
     args = [
         my_id, '--application-policy-group', application_policy_group_id
     ]
     params = {'application_policy_group_id': None}
     self._test_update_resource(resource, cmd, my_id, args, params)
Exemple #2
0
 def test_update_network_service_policy(self):
     """network-service-policy-update  myid --name myname --tags a b."""
     resource = 'network_service_policy'
     cmd = gbp.UpdateNetworkServicePolicy(test_cli20.MyApp(sys.stdout),
                                          None)
     self._test_update_resource(
         resource, cmd, 'myid',
         ['myid', '--name', 'myname', '--tags', 'a', 'b'], {
             'name': 'myname',
             'tags': ['a', 'b'],
         })
Exemple #3
0
 def test_update_servicechain_instance_with_chainspec_and_port(self):
     resource = 'servicechain_instance'
     cmd = sc.UpdateServiceChainInstance(test_cli20.MyApp(sys.stdout), None)
     body = {
         'name': 'newname',
         'servicechain_spec': 'my-spec-id',
         'port': 'my-port-id'
     }
     args = ['myid', '--name', 'newname',
             '--service-chain-spec', 'my-spec-id',
             '--port', 'my-port-id']
     self._test_update_resource(resource, cmd, 'myid', args, body)
 def test_create_l3_policy_with_mandatory_params(self):
     resource = 'l3_policy'
     cmd = gbp.CreateL3Policy(test_cli20.MyApp(sys.stdout), None)
     name = 'my-name'
     tenant_id = 'my-tenant'
     my_id = 'my-id'
     args = ['--tenant-id', tenant_id,
             name]
     position_names = ['name', ]
     position_values = [name, ]
     self._test_create_resource(resource, cmd, name, my_id, args,
                                position_names, position_values,
                                tenant_id=tenant_id)
Exemple #5
0
 def test_create_servicechain_instance_with_mandatory_params(self):
     """service-chain-instance-create with all mandatory params."""
     resource = 'servicechain_instance'
     cmd = sc.CreateServiceChainInstance(test_cli20.MyApp(sys.stdout), None)
     name = 'my-name'
     tenant_id = 'my-tenant'
     my_id = 'my-id'
     args = ['--tenant-id', tenant_id, name]
     position_names = ['name', ]
     position_values = [name, ]
     self._test_create_resource(resource, cmd, name, my_id, args,
                                position_names, position_values,
                                tenant_id=tenant_id)
 def test_update_servicechain_spec_with_nodes(self):
     resource = 'servicechain_spec'
     cmd = servicechain.UpdateServiceChainSpec(test_cli20.MyApp(sys.stdout),
                                               None)
     nodes_arg = 'node1 node2'
     nodes_res = ['node1', 'node2']
     description = 'My Service Chain Spec'
     body = {
         'nodes': nodes_res,
         'description': description
     }
     args = ['myid', '--nodes', nodes_arg, '--description', description]
     self._test_update_resource(resource, cmd, 'myid', args, body)
 def test_create_policy_target_group_with_mandatory_params(self):
     """policy-target-group-create with all mandatory params."""
     resource = 'policy_target_group'
     cmd = gbp.CreatePolicyTargetGroup(test_cli20.MyApp(sys.stdout), None)
     name = 'my-name'
     tenant_id = 'my-tenant'
     my_id = 'my-id'
     args = ['--tenant-id', tenant_id,
             name]
     position_names = ['name', ]
     position_values = [name, ]
     self._test_create_resource(resource, cmd, name, my_id, args,
                                position_names, position_values,
                                tenant_id=tenant_id)
 def test_update_external_segment_with_external_route_no_nexthop(self):
     resource = 'external_segment'
     cmd = gbp.UpdateExternalSegment(test_cli20.MyApp(sys.stdout), None)
     my_id = 'someid'
     external_route = 'destination=172.16.1.0/24,nexthop'
     expected_external_routes = [{
         'destination': '172.16.1.0/24',
         'nexthop': None
     }]
     args = ['--external-route', external_route, my_id]
     params = {
         'external_routes': expected_external_routes,
     }
     self._test_update_resource(resource, cmd, my_id, args, params)
Exemple #9
0
 def test_create_nat_pool_with_mandatory_params(self):
     """nat-pool-create with all mandatory params."""
     resource = 'nat_pool'
     cmd = gbp.CreateNatPool(test_cli20.MyApp(sys.stdout), None)
     name = 'my-name'
     tenant_id = 'my-tenant'
     my_id = 'my-id'
     args = ['--tenant-id', tenant_id,
             name]
     position_names = ['name', ]
     position_values = [name, ]
     self._test_create_resource(resource, cmd, name, my_id, args,
                                position_names, position_values,
                                tenant_id=tenant_id)
Exemple #10
0
 def test_update_servicechain_node_with_type_and_config(self):
     resource = 'servicechain_node'
     cmd = servicechain.UpdateServiceChainNode(test_cli20.MyApp(sys.stdout),
                                               None)
     body = {
         'name': 'newname',
         'service_type': 'service_type1',
         'config': 'config1',
     }
     args = [
         'myid', '--name', 'newname', '--servicetype', 'service_type1',
         '--config', 'config1'
     ]
     self._test_update_resource(resource, cmd, 'myid', args, body)
Exemple #11
0
 def test_create_nsp_with_mandatory_params(self):
     """network-service-policy-create with mandatory params."""
     resource = 'network_service_policy'
     cmd = gbp.CreateNetworkServicePolicy(test_cli20.MyApp(sys.stdout),
                                          None)
     name = 'my-name'
     tenant_id = 'my-tenant'
     my_id = 'my-id'
     args = ['--tenant-id', tenant_id,
             name]
     position_names = ['name', ]
     position_values = [name, ]
     self._test_create_resource(resource, cmd, name, my_id, args,
                                position_names, position_values,
                                tenant_id=tenant_id)
 def test_list_policy_targets_with_fixed_ips(self):
     resources = "policy_targets"
     cmd = gbp.ListPolicyTarget(test_cli20.MyApp(sys.stdout), None)
     fixed_ips = [{
         "subnet_id": "30422057-d6df-4c90-8314-aefb5e326666",
         "ip_address": "10.0.0.12"
     }, {
         "subnet_id": "30422057-d6df-4c90-8314-aefb5e326666",
         "ip_address": "10.0.0.4"
     }]
     contents = [{'name': 'name1', 'fixed_ips': fixed_ips}]
     self._test_list_resources(resources,
                               cmd,
                               True,
                               response_contents=contents)
Exemple #13
0
 def test_update_external_policy_unset_prs(self):
     resource = 'external_policy'
     cmd = gbp.UpdateExternalPolicy(test_cli20.MyApp(sys.stdout), None)
     my_id = 'someid'
     provided_policy_rule_sets = ""
     consumed_policy_rule_sets = ""
     args = [
         '--provided-policy-rule-sets', provided_policy_rule_sets,
         '--consumed-policy-rule-sets', consumed_policy_rule_sets, my_id
     ]
     params = {
         'provided_policy_rule_sets': {},
         'consumed_policy_rule_sets': {},
     }
     self._test_update_resource(resource, cmd, my_id, args, params)
 def test_update_policy_target_group_unset_prs(self):
     """policy-target-group-update."""
     resource = 'policy_target_group'
     cmd = gbp.UpdatePolicyTargetGroup(test_cli20.MyApp(sys.stdout), None)
     my_id = 'my-id'
     provided_prs = ""
     consumed_prs = ""
     args = [my_id,
             '--provided-policy-rule-sets', provided_prs,
             '--consumed-policy-rule-sets', consumed_prs
             ]
     params = {
         'provided_policy_rule_sets': {},
         'consumed_policy_rule_sets': {}
     }
     self._test_update_resource(resource, cmd, my_id, args, params)
Exemple #15
0
 def test_update_servicechain_node_with_all_params(self):
     resource = 'servicechain_node'
     cmd = servicechain.UpdateServiceChainNode(test_cli20.MyApp(sys.stdout),
                                               None)
     shared = 'true'
     body = {
         'name': 'new_name',
         'description': 'new_description',
         'service_profile_id': 'new_service_profile_id',
         'shared': shared,
     }
     args = [
         'myid', '--name', 'new_name', '--description', 'new_description',
         '--service-profile', 'new_service_profile_id', '--shared', shared
     ]
     self._test_update_resource(resource, cmd, 'myid', args, body)
 def test_create_l3_policy_with_allowed_vm_names(self):
     resource = 'l3_policy'
     cmd = gbp.CreateL3Policy(test_cli20.MyApp(sys.stdout), None)
     name = 'name'
     tenant_id = 'mytenant'
     my_id = 'someid'
     allowed_vm_names = "^safe_vm*,good_vm*"
     args = ['--tenant-id', tenant_id,
             '--allowed-vm-names', allowed_vm_names,
             name]
     position_names = ['name', ]
     position_values = [name, ]
     self._test_create_resource(resource, cmd, name, my_id, args,
                                position_names, position_values,
                                tenant_id=tenant_id,
                                allowed_vm_names=['^safe_vm*', 'good_vm*'])
Exemple #17
0
 def test_create_policy_target_group_with_all_params(self):
     """policy-target-group-create with all params."""
     resource = 'policy_target_group'
     cmd = gbp.CreatePolicyTargetGroup(test_cli20.MyApp(sys.stdout), None)
     my_id = 'my-id'
     tenant_id = 'my-tenant'
     name = 'my-name'
     description = 'ptg description'
     application_policy_group_id = 'application_policy_group_id'
     l2_policy_id = 'l2_policy_id'
     provided_prs = "icmp-prs=false,web-prs=true"
     consumed_prs = "ssh-prs=true,ftp-prs=false"
     network_service_policy_id = 'network_service_policy_id'
     shared = 'true'
     intra_ptg_allow = 'false'
     args = [
         name, '--tenant-id', tenant_id, '--description', description,
         '--application-policy-group-id', application_policy_group_id,
         '--l2-policy-id', l2_policy_id, '--provided-policy-rule-sets',
         provided_prs, '--consumed-policy-rule-sets', consumed_prs,
         '--network-service-policy-id', network_service_policy_id,
         '--shared', shared, '--intra-ptg-allow', intra_ptg_allow
     ]
     position_names = [
         'name', 'description', 'application_policy_group_id',
         'l2_policy_id', 'provided_policy_rule_sets',
         'consumed_policy_rule_sets', 'network_service_policy_id'
     ]
     provided_policy_rule_sets = {'icmp-prs': 'false', 'web-prs': 'true'}
     consumed_policy_rule_sets = {'ssh-prs': 'true', 'ftp-prs': 'false'}
     position_values = [
         name, description, application_policy_group_id, l2_policy_id,
         provided_policy_rule_sets, consumed_policy_rule_sets,
         network_service_policy_id
     ]
     self._test_create_resource(resource,
                                cmd,
                                name,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                tenant_id=tenant_id,
                                shared=shared,
                                intra_ptg_allow=intra_ptg_allow)
 def test_update_servicechain_node_with_all_params(self):
     resource = 'servicechain_spec'
     cmd = servicechain.UpdateServiceChainSpec(test_cli20.MyApp(sys.stdout),
                                               None)
     shared = 'true'
     nodes_arg = 'node1,node2'
     nodes_res = ['node1', 'node2']
     body = {
         'name': 'new_name',
         'description': 'new_description',
         'nodes': nodes_res,
         'shared': shared
     }
     args = [
         'myid', '--name', 'new_name', '--description', 'new_description',
         '--nodes', nodes_arg, '--shared', shared
     ]
     self._test_update_resource(resource, cmd, 'myid', args, body)
 def test_create_external_segment_with_all_params(self):
     """external-segment-create with all params."""
     resource = 'external_segment'
     cmd = gbp.CreateExternalSegment(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     tenant_id = 'mytenant'
     description = 'My External Segment'
     my_id = 'someid'
     ip_version = '4'
     cidr = '192.168.0.0/24'
     external_route = 'destination=172.16.1.0/24,nexthop=192.168.0.10'
     expected_external_routes = [{
         'destination': '172.16.1.0/24',
         'nexthop': '192.168.0.10'
     }]
     port_address_translation = 'true'
     shared = 'true'
     args = [
         '--tenant-id', tenant_id, '--description', description,
         '--ip-version', ip_version, '--cidr', cidr, '--external-route',
         external_route, '--port-address-translation',
         port_address_translation, '--shared', shared, name
     ]
     position_names = [
         'name',
     ]
     position_values = [
         name,
     ]
     self._test_create_resource(
         resource,
         cmd,
         name,
         my_id,
         args,
         position_names,
         position_values,
         tenant_id=tenant_id,
         description=description,
         ip_version=4,
         cidr=cidr,
         external_routes=expected_external_routes,
         port_address_translation=port_address_translation,
         shared=shared)
 def test_create_l3_policy_with_all_params(self):
     """l3-policy-create with all params."""
     resource = 'l3_policy'
     cmd = gbp.CreateL3Policy(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     tenant_id = 'mytenant'
     description = 'My L3 Policy'
     my_id = 'someid'
     ip_version = '4'
     ip_pool = '172.16.0.0/12'
     subnet_prefix_length = '24'
     external_segment = 'seg_uuid1=1.1.1.0:2.2.2.0'
     expected_external_segments = {'seg_uuid1': ['1.1.1.0', '2.2.2.0']}
     routers = 'uuid1,uuid2'
     shared = 'true'
     args = [
         '--tenant-id', tenant_id, '--description', description,
         '--ip-version', ip_version, '--ip-pool', ip_pool,
         '--subnet-prefix-length', subnet_prefix_length,
         '--external-segment', external_segment, '--routers', routers,
         '--shared', shared, name
     ]
     position_names = [
         'name',
     ]
     position_values = [
         name,
     ]
     self._test_create_resource(
         resource,
         cmd,
         name,
         my_id,
         args,
         position_names,
         position_values,
         tenant_id=tenant_id,
         description=description,
         ip_version=4,
         ip_pool=ip_pool,
         subnet_prefix_length=24,
         routers=['uuid1', 'uuid2'],
         external_segments=expected_external_segments,
         shared=shared)
Exemple #21
0
 def test_create_l2_policy_with_reuse_bd(self):
     """l2-policy-create with reuse_bd option."""
     resource = 'l2_policy'
     cmd = gbp.CreateL2Policy(test_cli20.MyApp(sys.stdout), None)
     my_id = 'my-id'
     tenant_id = 'my-tenant'
     name = 'my-name'
     target_l2p = 'another-l2p'
     args = [name, '--tenant-id', tenant_id, '--reuse-bd', target_l2p]
     position_names = ['name', 'reuse_bd']
     position_values = [name, target_l2p]
     self._test_create_resource(resource,
                                cmd,
                                name,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                tenant_id=tenant_id)
Exemple #22
0
 def test_create_external_policy_with_all_params(self):
     """external-policy-create with all params."""
     resource = 'external_policy'
     cmd = gbp.CreateExternalPolicy(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     tenant_id = 'mytenant'
     description = 'My External Policy'
     my_id = 'someid'
     provided_policy_rule_sets = "prs1=true,prs2=true"
     consumed_policy_rule_sets = "prs3=true,prs4=true"
     external_segments = "ES1,ES2"
     shared = 'true'
     args = [
         '--tenant-id', tenant_id, '--description', description,
         '--provided-policy-rule-sets', provided_policy_rule_sets,
         '--consumed-policy-rule-sets', consumed_policy_rule_sets,
         '--external-segments', external_segments, '--shared', shared, name
     ]
     position_names = [
         'name',
     ]
     position_values = [
         name,
     ]
     self._test_create_resource(resource,
                                cmd,
                                name,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                tenant_id=tenant_id,
                                description=description,
                                provided_policy_rule_sets={
                                    'prs1': 'true',
                                    'prs2': 'true'
                                },
                                consumed_policy_rule_sets={
                                    'prs3': 'true',
                                    'prs4': 'true'
                                },
                                external_segments=['ES1', 'ES2'],
                                shared=shared)
 def test_create_l3_policy_with_external_segment(self):
     """l3-policy-create with all params."""
     resource = 'l3_policy'
     cmd = gbp.CreateL3Policy(test_cli20.MyApp(sys.stdout), None)
     name = 'name'
     tenant_id = 'mytenant'
     my_id = 'someid'
     external_segment = 'seg_uuid1'
     expected_external_segments = {'seg_uuid1': []}
     args = ['--tenant-id', tenant_id,
             '--external-segment', external_segment,
             name]
     position_names = ['name', ]
     position_values = [name, ]
     self._test_create_resource(resource, cmd, name, my_id, args,
                                position_names, position_values,
                                tenant_id=tenant_id,
                                external_segments=
                                expected_external_segments)
Exemple #24
0
 def test_update_nat_pool_with_all_params(self):
     resource = 'nat_pool'
     cmd = gbp.UpdateNatPool(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     description = 'My Nat Pool'
     my_id = 'someid'
     external_segment_id = "segmentid"
     shared = 'true'
     args = [
         '--name', name, '--description', description, '--external-segment',
         external_segment_id, '--shared', shared, my_id
     ]
     params = {
         'name': name,
         'description': description,
         'external_segment_id': external_segment_id,
         'shared': shared
     }
     self._test_update_resource(resource, cmd, my_id, args, params)
 def test_update_policy_target_fixed_ip(self):
     resource = 'policy_target'
     cmd = gbp.UpdatePolicyTarget(test_cli20.MyApp(sys.stdout), None)
     myid = 'myid'
     subnet_id = 'subnet_id'
     ip_addr = '123.123.123.123'
     args = [
         myid, '--fixed-ip',
         "subnet_id=%(subnet_id)s,ip_address=%(ip_addr)s" % {
             'subnet_id': subnet_id,
             'ip_addr': ip_addr
         }
     ]
     updated_fields = {
         "fixed_ips": [{
             'subnet_id': subnet_id,
             'ip_address': ip_addr
         }]
     }
     self._test_update_resource(resource, cmd, myid, args, updated_fields)
Exemple #26
0
 def test_update_l2_policy_with_all_params(self):
     """l2-policy-update."""
     resource = 'l2_policy'
     cmd = gbp.UpdateL2Policy(test_cli20.MyApp(sys.stdout), None)
     my_id = 'someid'
     name = 'l2policy'
     description = 'l2policy description'
     l3_policy_id = 'l3p'
     shared = 'True'
     args = [
         my_id, '--name', name, '--description', description,
         '--l3-policy-id', l3_policy_id, '--shared', shared
     ]
     params = {
         'name': name,
         'description': description,
         'l3_policy_id': l3_policy_id,
         'shared': True
     }
     self._test_update_resource(resource, cmd, my_id, args, params)
 def test_create_servicechain_spec_with_all_params(self):
     """service-chain-spec-create with all params."""
     resource = 'servicechain_spec'
     cmd = servicechain.CreateServiceChainSpec(test_cli20.MyApp(sys.stdout),
                                               None)
     name = 'my-name'
     nodes_arg = 'node1 node2'
     nodes_res = ['node1', 'node2']
     tenant_id = 'my-tenant'
     description = 'My Service Chain Spec'
     my_id = 'my-id'
     args = ['--nodes', nodes_arg,
             '--tenant-id', tenant_id,
             '--description', description,
             name]
     position_names = ['name', ]
     position_values = [name, ]
     self._test_create_resource(resource, cmd, name, my_id, args,
                                position_names, position_values,
                                nodes=nodes_res, tenant_id=tenant_id,
                                description=description)
 def test_update_l3_policy_unset_external_segment(self):
     resource = 'l3_policy'
     cmd = gbp.UpdateL3Policy(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     description = 'My L3 Policy'
     my_id = 'someid'
     subnet_prefix_length = '24'
     external_segment = ''
     expected_external_segments = {}
     args = [
         '--name', name, '--description', description,
         '--subnet-prefix-length', subnet_prefix_length,
         '--external-segment', external_segment, my_id
     ]
     params = {
         'name': name,
         'description': description,
         'subnet_prefix_length': 24,
         'external_segments': expected_external_segments,
     }
     self._test_update_resource(resource, cmd, my_id, args, params)
Exemple #29
0
 def test_create_external_policy_with_mandatory_params(self):
     """external-policy-create with all mandatory params."""
     resource = 'external_policy'
     cmd = gbp.CreateExternalPolicy(test_cli20.MyApp(sys.stdout), None)
     name = 'my-name'
     tenant_id = 'my-tenant'
     my_id = 'my-id'
     args = ['--tenant-id', tenant_id, name]
     position_names = [
         'name',
     ]
     position_values = [
         name,
     ]
     self._test_create_resource(resource,
                                cmd,
                                name,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                tenant_id=tenant_id)
 def test_update_policy_action_with_allparams(self):
     resource = 'policy_action'
     action_type = "allow"
     action_value = "1234"
     shared = 'True'
     my_id = 'someid'
     cmd = gbp.UpdatePolicyAction(test_cli20.MyApp(sys.stdout), None)
     body = {
         'action_type': action_type,
         'action_value': action_value,
         'shared': True
     }
     args = [
         my_id,
         '--action-type',
         action_type,
         '--action-value',
         action_value,
         '--shared',
         shared,
     ]
     self._test_update_resource(resource, cmd, my_id, args, body)