Ejemplo n.º 1
0
    def test_compile_mapping_keys(self):
        expected_node_handler = "NodeHandler"
        expected_cluster_handler = "ClusterCollectionHandler"
        mapping = {
            r"/nodes/(?P<obj_id>\d+)/?$": expected_node_handler,
            r"/clusters/?$": expected_cluster_handler
        }

        compiled_mapping = utils.compile_mapping_keys(mapping=mapping)

        def check_match_strings(string_to_match, expected_value,
                                check_not_found=True):
            for matcher, handler_name in six.iteritems(compiled_mapping):
                if matcher.match(string_to_match):
                    self.assertEqual(handler_name, expected_value)
                    break
            else:
                if check_not_found:
                    raise AssertionError("Match not found in compiled mapping")

        test_cases = [
            {"string_to_match": "/nodes/1",
             "expected_value": expected_node_handler},
            {"string_to_match": "/clusters/",
             "expected_value": expected_cluster_handler},
            {"string_to_match": "/settings/",
             "expected_value": "",
             "check_not_found": False},
        ]

        for kw in test_cases:
            check_match_strings(**kw)
Ejemplo n.º 2
0
compiled_urls_actions_mapping = utils.compile_mapping_keys({
    r'.*/clusters/(?P<cluster_id>\d+)/changes/?$': {
        'action_name': 'deploy_changes',
        'action_group': 'cluster_changes'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/provision/?$': {
        'action_name': 'provision',
        'action_group': 'cluster_changes'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/deploy/?$': {
        'action_name': 'deploy',
        'action_group': 'cluster_changes'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/stop_deployment/?$': {
        'action_name': 'stop_deployment',
        'action_group': 'cluster_changes'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/reset/?$': {
        'action_name': 'reset',
        'action_group': 'cluster_changes'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/update/?$': {
        'action_name': 'update',
        'action_group': 'cluster_changes'
    },
    r'.*/clusters/?$': {
        'action_name': 'cluster_collection',
        'action_group': 'cluster_changes'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/?$': {
        'action_name': 'cluster_instance',
        'action_group': 'cluster_changes'
    },
    (r'.*/clusters/(?P<cluster_id>\d+)'
     r'/network_configuration/nova_network/?$'): {
        'action_name': 'nova_network',
        'action_group': 'network_configuration'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/network_configuration/neutron/?$': {
        'action_name': 'neutron',
        'action_group': 'network_configuration'
    },
    (r'.*/clusters/(?P<cluster_id>\d+)/network_configuration/'
     r'nova_network/verify/?$'): {
        'action_name': 'nova_network',
        'action_group': 'network_verification'
    },
    (r'.*/clusters/(?P<cluster_id>\d+)/network_configuration/'
     r'neutron/verify/?$'): {
        'action_name': 'neutron',
        'action_group': 'network_verification'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/attributes/?$': {
        'action_name': 'attributes',
        'action_group': 'cluster_attributes'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/attributes/defaults/?$': {
        'action_name': 'attributes_defaults',
        'action_group': 'cluster_attributes'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/orchestrator/deployment/?$': {
        'action_name': 'deployment_info',
        'action_group': 'orchestrator'
    },
    r'.*/clusters/(?P<cluster_id>\d+)/orchestrator/provisioning/?$': {
        'action_name': 'provisioning_info',
        'action_group': 'orchestrator'
    },
    r'.*/settings/?$': {
        'action_name': 'master_node_settings',
        'action_group': 'master_node_settings'
    },
    r'.*/releases/?$': {
        'action_name': 'releases_collection',
        'action_group': 'release_changes'
    },
    r'.*/releases/(?P<obj_id>\d+)/?$': {
        'action_name': 'release_instance',
        'action_group': 'release_changes'
    },
    r'.*/tasks/?$': {
        'action_name': 'tasks_collection',
        'action_group': 'tasks_changes'
    },
    r'.*/tasks/(?P<obj_id>\d+)/?$': {
        'action_name': 'task_instance',
        'action_group': 'tasks_changes'
    },
})
Ejemplo n.º 3
0
compiled_urls_actions_mapping = utils.compile_mapping_keys(
    {
        r'.*/clusters/(?P<cluster_id>\d+)/changes/?$': {
            'action_name': 'deploy_changes',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/provision/?$': {
            'action_name': 'provision',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/deploy/?$': {
            'action_name': 'deploy',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/stop_deployment/?$': {
            'action_name': 'stop_deployment',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/reset/?$': {
            'action_name': 'reset',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/update/?$': {
            'action_name': 'update',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/?$': {
            'action_name': 'cluster_collection',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/?$': {
            'action_name': 'cluster_instance',
            'action_group': 'cluster_changes'
        },
        (r'.*/clusters/(?P<cluster_id>\d+)'
         r'/network_configuration/nova_network/?$'): {
             'action_name': 'nova_network',
             'action_group': 'network_configuration'
         },
        r'.*/clusters/(?P<cluster_id>\d+)/network_configuration/neutron/?$': {
            'action_name': 'neutron',
            'action_group': 'network_configuration'
        },
        (r'.*/clusters/(?P<cluster_id>\d+)/network_configuration/'
         r'nova_network/verify/?$'): {
             'action_name': 'nova_network',
             'action_group': 'network_verification'
         },
        (r'.*/clusters/(?P<cluster_id>\d+)/network_configuration/'
         r'neutron/verify/?$'): {
             'action_name': 'neutron',
             'action_group': 'network_verification'
         },
        r'.*/clusters/(?P<cluster_id>\d+)/attributes/?$': {
            'action_name': 'attributes',
            'action_group': 'cluster_attributes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/attributes/defaults/?$': {
            'action_name': 'attributes_defaults',
            'action_group': 'cluster_attributes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/orchestrator/deployment/?$': {
            'action_name': 'deployment_info',
            'action_group': 'orchestrator'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/orchestrator/provisioning/?$': {
            'action_name': 'provisioning_info',
            'action_group': 'orchestrator'
        },
        r'.*/settings/?$': {
            'action_name': 'master_node_settings',
            'action_group': 'master_node_settings'
        },
        r'.*/releases/?$': {
            'action_name': 'releases_collection',
            'action_group': 'release_changes'
        },
        r'.*/releases/(?P<obj_id>\d+)/?$': {
            'action_name': 'release_instance',
            'action_group': 'release_changes'
        },
        r'.*/tasks/?$': {
            'action_name': 'tasks_collection',
            'action_group': 'tasks_changes'
        },
        r'.*/tasks/(?P<obj_id>\d+)/?$': {
            'action_name': 'task_instance',
            'action_group': 'tasks_changes'
        },
    }
)
Ejemplo n.º 4
0
compiled_urls_actions_mapping = utils.compile_mapping_keys(
    {
        r'.*/clusters/(?P<cluster_id>\d+)/changes/?$': {
            'action_name': 'deploy_changes',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/provision/?$': {
            'action_name': 'provision',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/deploy/?$': {
            'action_name': 'deploy',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/stop_deployment/?$': {
            'action_name': 'stop_deployment',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/reset/?$': {
            'action_name': 'reset',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/update/?$': {
            'action_name': 'update',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/?$': {
            'action_name': 'cluster_collection',
            'action_group': 'cluster_changes'
        },
        r'.*/clusters/(?P<cluster_id>\d+)/?$': {
            'action_name': 'cluster_instance',
            'action_group': 'cluster_changes'
        }
    }
)
Ejemplo n.º 5
0
compiled_urls_actions_mapping = utils.compile_mapping_keys(
    {
        r".*/clusters/(?P<cluster_id>\d+)/changes/?$": {
            "action_name": "deploy_changes",
            "action_group": "cluster_changes",
        },
        r".*/clusters/(?P<cluster_id>\d+)/provision/?$": {
            "action_name": "provision",
            "action_group": "cluster_changes",
        },
        r".*/clusters/(?P<cluster_id>\d+)/deploy/?$": {"action_name": "deploy", "action_group": "cluster_changes"},
        r".*/clusters/(?P<cluster_id>\d+)/stop_deployment/?$": {
            "action_name": "stop_deployment",
            "action_group": "cluster_changes",
        },
        r".*/clusters/(?P<cluster_id>\d+)/reset/?$": {"action_name": "reset", "action_group": "cluster_changes"},
        r".*/clusters/(?P<cluster_id>\d+)/update/?$": {"action_name": "update", "action_group": "cluster_changes"},
        r".*/clusters/?$": {"action_name": "cluster_collection", "action_group": "cluster_changes"},
        r".*/clusters/(?P<cluster_id>\d+)/?$": {"action_name": "cluster_instance", "action_group": "cluster_changes"},
        (r".*/clusters/(?P<cluster_id>\d+)" r"/network_configuration/nova_network/?$"): {
            "action_name": "nova_network",
            "action_group": "network_configuration",
        },
        r".*/clusters/(?P<cluster_id>\d+)/network_configuration/neutron/?$": {
            "action_name": "neutron",
            "action_group": "network_configuration",
        },
        (r".*/clusters/(?P<cluster_id>\d+)/network_configuration/" r"nova_network/verify/?$"): {
            "action_name": "nova_network",
            "action_group": "network_verification",
        },
        (r".*/clusters/(?P<cluster_id>\d+)/network_configuration/" r"neutron/verify/?$"): {
            "action_name": "neutron",
            "action_group": "network_verification",
        },
        r".*/clusters/(?P<cluster_id>\d+)/attributes/?$": {
            "action_name": "attributes",
            "action_group": "cluster_attributes",
        },
        r".*/clusters/(?P<cluster_id>\d+)/attributes/defaults/?$": {
            "action_name": "attributes_defaults",
            "action_group": "cluster_attributes",
        },
        r".*/clusters/(?P<cluster_id>\d+)/orchestrator/deployment/?$": {
            "action_name": "deployment_info",
            "action_group": "orchestrator",
        },
        r".*/clusters/(?P<cluster_id>\d+)/orchestrator/provisioning/?$": {
            "action_name": "provisioning_info",
            "action_group": "orchestrator",
        },
        r".*/settings/?$": {"action_name": "master_node_settings", "action_group": "master_node_settings"},
        r".*/releases/?$": {"action_name": "releases_collection", "action_group": "release_changes"},
        r".*/releases/(?P<obj_id>\d+)/?$": {"action_name": "release_instance", "action_group": "release_changes"},
        r".*/tasks/?$": {"action_name": "tasks_collection", "action_group": "tasks_changes"},
        r".*/tasks/(?P<obj_id>\d+)/?$": {"action_name": "task_instance", "action_group": "tasks_changes"},
    }
)