Create neutronv2 module for ports

Co-Authored-By: Oleg Bondarev <obondarev@mirantis.com>
Change-Id: I605a50e92331cc6e7bb18ffb3b7a79d0aeae0880
diff --git a/_modules/neutronv2/__init__.py b/_modules/neutronv2/__init__.py
index e275af6..74b6fb1 100644
--- a/_modules/neutronv2/__init__.py
+++ b/_modules/neutronv2/__init__.py
@@ -12,6 +12,7 @@
 from neutronv2 import subnets
 from neutronv2 import agents
 from neutronv2 import routers
+from neutronv2 import ports
 from neutronv2 import common
 
 
@@ -61,6 +62,13 @@
 router_interface_add = routers.router_interface_add
 router_interface_remove = routers.router_interface_remove
 
+port_list = lists.port_list
+port_create = ports.port_create
+port_delete = ports.port_delete
+port_update = ports.port_update
+port_get_details = ports.port_get_details
+
+
 wait_for_network_services = agents.wait_for_network_services
 
 wait_for_api_ready = common.wait_for_api_ready
@@ -79,6 +87,7 @@
     'dhcp_agent_network_remove', 'dhcp_agent_network_schedule',
     'router_list', 'router_create', 'router_delete', 'router_get_details',
     'router_interface_add', 'router_interface_remove', 'router_update',
+    'port_create', 'port_delete', 'port_update', 'port_list', 'port_get_details',
 )
 
 
diff --git a/_modules/neutronv2/arg_converter.py b/_modules/neutronv2/arg_converter.py
index f2bc76d..99cb8fe 100644
--- a/_modules/neutronv2/arg_converter.py
+++ b/_modules/neutronv2/arg_converter.py
@@ -18,6 +18,7 @@
     'subnetpool': lists.subnetpool_list,
     'agent': lists.agent_list,
     'router': lists.router_list,
+    'port': lists.port_list,
 }
 
 
@@ -27,6 +28,7 @@
     'subnetpool': 'subnetpools',
     'agent': 'agents',
     'router': 'routers',
+    'port': 'ports',
 }
 
 
diff --git a/_modules/neutronv2/lists.py b/_modules/neutronv2/lists.py
index 1b56392..eea4a7a 100644
--- a/_modules/neutronv2/lists.py
+++ b/_modules/neutronv2/lists.py
@@ -34,3 +34,9 @@
 def router_list(**kwargs):
     url = '/routers?{}'.format(urlencode(kwargs))
     return url, {}
+
+
+@send('get')
+def port_list(**kwargs):
+    url = '/ports?{}'.format(urlencode(kwargs))
+    return url, {}
\ No newline at end of file
diff --git a/_modules/neutronv2/ports.py b/_modules/neutronv2/ports.py
new file mode 100644
index 0000000..ab9482b
--- /dev/null
+++ b/_modules/neutronv2/ports.py
@@ -0,0 +1,40 @@
+from neutronv2.common import send
+from neutronv2.arg_converter import get_by_name_or_uuid_multiple
+
+try:
+    from urllib.parse import urlencode
+except ImportError:
+    from urllib import urlencode
+
+
+@get_by_name_or_uuid_multiple([('port', 'port_id')])
+@send('get')
+def port_get_details(port_id, **kwargs):
+    url = '/ports/{}?{}'.format(port_id, urlencode(kwargs))
+    return url, {}
+
+
+@get_by_name_or_uuid_multiple([('port', 'port_id')])
+@send('put')
+def port_update(port_id, **kwargs):
+    url = '/ports/{}'.format(port_id)
+    json = {
+        'port': kwargs,
+    }
+    return url, {'json': json}
+
+
+@get_by_name_or_uuid_multiple([('port', 'port_id')])
+@send('delete')
+def port_delete(port_id, **kwargs):
+    url = '/port/{}'.format(port_id)
+    return url, {}
+
+
+@send('post')
+def port_create(**kwargs):
+    url = '/ports'
+    json = {
+        'port': kwargs,
+    }
+    return url, {'json': json}