Add agent modules and states

Add REST API wrapper for agents, l3_agents and dhcp_agents

Change-Id: I63ce0a4224b7cd4d65ce80f1efd0c5cfb6f0617e
Closes-Issue: PROD-22594
diff --git a/_modules/neutronv2/arg_converter.py b/_modules/neutronv2/arg_converter.py
new file mode 100644
index 0000000..f2bc76d
--- /dev/null
+++ b/_modules/neutronv2/arg_converter.py
@@ -0,0 +1,61 @@
+from neutronv2 import lists
+from neutronv2 import common
+import functools
+import inspect
+from uuid import UUID
+
+
+def _check_uuid(val):
+    try:
+        return str(UUID(val)) == val
+    except (TypeError, ValueError, AttributeError):
+        return False
+
+
+resource_lists = {
+    'network': lists.network_list,
+    'subnet': lists.subnet_list,
+    'subnetpool': lists.subnetpool_list,
+    'agent': lists.agent_list,
+    'router': lists.router_list,
+}
+
+
+response_keys = {
+    'network': 'networks',
+    'subnet': 'subnets',
+    'subnetpool': 'subnetpools',
+    'agent': 'agents',
+    'router': 'routers',
+}
+
+
+def get_by_name_or_uuid_multiple(resource_arg_name_pairs):
+    def wrap(func):
+        @functools.wraps(func)
+        def wrapped_f(*args, **kwargs):
+            largs = list(args)
+            inspect_args = inspect.getargspec(
+                func.func_closure[0].cell_contents)
+            for (resource, arg_name) in resource_arg_name_pairs:
+                arg_index = inspect_args.args.index(arg_name)
+                if arg_name in kwargs:
+                    ref = kwargs.pop(arg_name, None)
+                else:
+                    ref = largs.pop(arg_index)
+                cloud_name = kwargs['cloud_name']
+                if _check_uuid(ref):
+                    kwargs[arg_name] = ref
+                else:
+                    # Then we have name not uuid
+                    resp_key = response_keys[resource]
+                    resp = resource_lists[resource](
+                        name=ref, cloud_name=cloud_name)[resp_key]
+                    if len(resp) == 0:
+                        raise common.ResourceNotFound(resp_key, ref)
+                    elif len(resp) > 1:
+                        raise common.MultipleResourcesFound(resp_key, ref)
+                    kwargs[arg_name] = resp[0]['id']
+            return func(*largs, **kwargs)
+        return wrapped_f
+    return wrap