From ea481b1aa8f1bcabc1052b918c03b25a1fc7ac20 Mon Sep 17 00:00:00 2001
From: Jeremy Bicha <jbicha@ubuntu.com>
Date: Mon, 9 Jan 2017 03:11:58 -0500
Subject: [PATCH 2/2] Build with python3

Closes: #850669
---
 debian/control                                     |  9 +++
 .../0002-fix-python3-with-openvswitch.patch        | 72 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 debian/rules                                       |  2 +-
 4 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 debian/patches/0002-fix-python3-with-openvswitch.patch

diff --git a/debian/control b/debian/control
index 030762c..ad1911f 100644
--- a/debian/control
+++ b/debian/control
@@ -4,6 +4,14 @@ Uploaders: Michael Vogt <mvo@debian.org>
 Section: admin
 Priority: optional
 Build-Depends: debhelper (>= 9),
+               python3-all,
+               python3-crypto,
+               python3-nose,
+               python3-passlib,
+               python3-setuptools,
+               python3-yaml,
+               python3-jinja2 <!nocheck>,
+               python3-six <!nocheck>,
                python-all,
                python-crypto,
                python-setuptools,
@@ -23,6 +31,7 @@ Package: ansible
 Architecture: all
 Depends: ${misc:Depends},
          ${python:Depends},
+         ${python3:Depends},
          python-crypto,
          python-yaml,
          openssh-client | python-paramiko,
diff --git a/debian/patches/0002-fix-python3-with-openvswitch.patch b/debian/patches/0002-fix-python3-with-openvswitch.patch
new file mode 100644
index 0000000..06af3c3
--- /dev/null
+++ b/debian/patches/0002-fix-python3-with-openvswitch.patch
@@ -0,0 +1,72 @@
+From d439271f685c01ace04025f27e7046dd35d988f8 Mon Sep 17 00:00:00 2001
+From: Michael Scherer <misc@zarb.org>
+Date: Tue, 18 Oct 2016 18:14:02 +0200
+Subject: [PATCH] Make openvswitch* pass py3 sanity check
+
+https://github.com/ansible/ansible-modules-extras/commit/d439271
+---
+ network/openvswitch_bridge.py                | 7 +++++--
+ network/openvswitch_port.py                  | 7 +++++--
+ test/utils/shippable/sanity-skip-python3.txt | 2 --
+ 3 files changed, 10 insertions(+), 6 deletions(-)
+
+diff --git a/network/openvswitch_bridge.py b/network/openvswitch_bridge.py
+index 68528dd..abe89df 100644
+--- a/lib/ansible/modules/extras/network/openvswitch_bridge.py
++++ b/lib/ansible/modules/extras/network/openvswitch_bridge.py
+@@ -143,7 +143,8 @@ def check(self):
+                 changed = True
+             elif self.state == 'present' and not self.exists():
+                 changed = True
+-        except Exception, earg:
++        except Exception:
++            earg = get_exception()
+             self.module.fail_json(msg=str(earg))
+ 
+         # pylint: enable=W0703
+@@ -189,7 +190,8 @@ def run(self):
+                            self.set_external_id(key, None)):
+                             changed = True
+ 
+-        except Exception, earg:
++        except Exception:
++            earg = get_exception()
+             self.module.fail_json(msg=str(earg))
+         # pylint: enable=W0703
+         self.module.exit_json(changed=changed)
+@@ -267,4 +269,5 @@ def main():
+ 
+ # import module snippets
+ from ansible.module_utils.basic import *
++from ansible.module_utils.pycompat24 import get_exception
+ main()
+diff --git a/network/openvswitch_port.py b/network/openvswitch_port.py
+index c2224b5..d2bf31a 100644
+--- a/lib/ansible/modules/extras/network/openvswitch_port.py
++++ b/lib/ansible/modules/extras/network/openvswitch_port.py
+@@ -204,7 +204,8 @@ def check(self):
+                 changed = True
+             else:
+                 changed = False
+-        except Exception, earg:
++        except Exception:
++            earg = get_exception()
+             self.module.fail_json(msg=str(earg))
+         self.module.exit_json(changed=changed)
+ 
+@@ -235,7 +236,8 @@ def run(self):
+                         external_id = fmt_opt % (self.port, key, value)
+                         changed = self.set(external_id) or changed
+                 ##
+-        except Exception, earg:
++        except Exception:
++            earg = get_exception()
+             self.module.fail_json(msg=str(earg))
+         self.module.exit_json(changed=changed)
+ 
+@@ -269,4 +271,5 @@ def main():
+ 
+ # import module snippets
+ from ansible.module_utils.basic import *
++from ansible.module_utils.pycompat24 import get_exception
+ main()
diff --git a/debian/patches/series b/debian/patches/series
index 69731bc..dde177e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 0001-add-console-manpage.patch
+0002-fix-python3-with-openvswitch.patch
diff --git a/debian/rules b/debian/rules
index 15808e0..b9265e3 100755
--- a/debian/rules
+++ b/debian/rules
@@ -2,7 +2,7 @@
 export PYBUILD_NAME=ansible
 
 %:
-	dh $@ --with python2 --buildsystem=pybuild
+	dh $@ --with python2,python3 --buildsystem=pybuild
 
 # Investigate why the tests are failing
 override_dh_auto_test:
-- 
2.10.2

