[lmiwbem/f20] fix CIMIndicationListener API compatibility
Peter Hatina
phatina at fedoraproject.org
Wed Jul 23 12:33:42 UTC 2014
commit 6cc6df09b9c056160da0cdba879908798ffaebd1
Author: Peter Hatina <phatina at redhat.com>
Date: Wed Jul 23 14:24:15 2014 +0200
fix CIMIndicationListener API compatibility
lmiwbem-06-listener-api-compat.patch | 190 ++++++++++++++++++++++++++++++++++
lmiwbem.spec | 7 +-
2 files changed, 196 insertions(+), 1 deletions(-)
---
diff --git a/lmiwbem-06-listener-api-compat.patch b/lmiwbem-06-listener-api-compat.patch
new file mode 100644
index 0000000..d11790c
--- /dev/null
+++ b/lmiwbem-06-listener-api-compat.patch
@@ -0,0 +1,190 @@
+commit 3fa42a97947fd3dd87c8aabb449d6e395ebf5a4b
+Author: Peter Hatina <phatina at redhat.com>
+Date: Wed Jul 23 10:54:21 2014 +0200
+
+ fix CIMIndicationListener API due to compatibility
+
+diff --git a/src/lmiwbem_listener.cpp b/src/lmiwbem_listener.cpp
+index 3d0f832..43a07d0 100644
+--- a/src/lmiwbem_listener.cpp
++++ b/src/lmiwbem_listener.cpp
+@@ -101,29 +101,59 @@ void CIMIndicationConsumer::consumeIndication(
+
+ // ----------------------------------------------------------------------------
+
+-CIMIndicationListener::CIMIndicationListener()
++CIMIndicationListener::CIMIndicationListener(
++ const bp::object &hostname,
++ const bp::object &port,
++ const bp::object &certfile,
++ const bp::object &keyfile,
++ const bp::object &trust_store)
+ : m_listener()
+ , m_consumer(this)
+ , m_handlers()
++ , m_port(0)
++ , m_hostname()
++ , m_certfile()
++ , m_keyfile()
++ , m_trust_store(CIMConstants::defaultTrustStore())
+ {
++ // hostname is present due to compatibility. Pegasus::CIMListener doesn't
++ // provide an API to pass listening address for bind(), now.
++ m_hostname = lmi::extract_or_throw<std::string>(hostname, "hostname");
++ m_port = lmi::extract_or_throw<Pegasus::Uint32>(port, "port");
++
++ if (!isnone(certfile))
++ m_certfile = lmi::extract_or_throw<std::string>(certfile, "certfile");
++ if (!isnone(keyfile))
++ m_keyfile = lmi::extract_or_throw<std::string>(keyfile, "keyfile");
++ if (!isnone(trust_store))
++ m_trust_store = lmi::extract_or_throw<std::string>(trust_store, "trust_store");
+ }
+
+ void CIMIndicationListener::init_type()
+ {
+ CIMBase<CIMIndicationListener>::init_type(
+- bp::class_<CIMIndicationListener>("CIMIndicationListener", bp::init<>())
++ bp::class_<CIMIndicationListener>("CIMIndicationListener", bp::no_init)
++ .def(bp::init<
++ const bp::object &,
++ const bp::object &,
++ const bp::object &,
++ const bp::object &,
++ const bp::object &>((
++ bp::arg("hostname"),
++ bp::arg("port"),
++ bp::arg("certfile") = bp::object(),
++ bp::arg("keyfile") = bp::object(),
++ bp::arg("trust_store") = bp::object()),
++ "Constructs a :py:class:`.CIMIndicationListener` object.\n\n"
++ ":param str hostname: bind hostname\n"
++ ":param int port: listening port\n"
++ ":param str certfile: path to X509 certificate\n"
++ ":param str keyfile: path to X509 private key; may be None,\n"
++ "\tif cert_file also contains private key\n"
++ ":param str trust_store: path to trust store"))
+ .def("start", &CIMIndicationListener::start,
+- (bp::arg("port"),
+- bp::arg("cert_file") = bp::object(),
+- bp::arg("key_file") = bp::object(),
+- bp::arg("trust_store") = bp::object()),
+- "start(port, cert_file=None, key_file=None, trust_store=None)\n\n"
+- "Starts indication listener.\n\n"
+- ":param int port: listening port\n"
+- ":param str cert_file: path to X509 certificate\n"
+- ":param str key_file: path to X509 private key; may be None,\n"
+- "\tif cert_file also contains private key\n"
+- ":param str trust_store: path to trust store")
++ "start()\n\n"
++ "Starts indication listener.\n\n")
+ .def("stop", &CIMIndicationListener::stop,
+ "stop()\n\n"
+ "Stops indication listener.")
+@@ -148,6 +178,9 @@ void CIMIndicationListener::init_type()
+ "Property storing flag, which indicates, if the indication\n"
+ "listener uses secure connection.\n\n"
+ ":rtype: bool")
++ .add_property("hostname", &CIMIndicationListener::getHostname,
++ "Property storing bind hostname.\n\n"
++ ":rtype: str")
+ .add_property("port", &CIMIndicationListener::getPort,
+ "Property storing listening port.\n\n"
+ ":rtype: int")
+@@ -156,43 +189,23 @@ void CIMIndicationListener::init_type()
+ ":rtype: list"));
+ }
+
+-void CIMIndicationListener::start(
+- const bp::object &port_,
+- const bp::object &cert_file,
+- const bp::object &key_file,
+- const bp::object &trust_store)
++void CIMIndicationListener::start()
+ {
+ if (m_listener)
+ return;
+
+- Pegasus::Uint32 port = lmi::extract_or_throw<Pegasus::Uint32>(port_, "port");
+- m_listener.reset(new Pegasus::CIMListener(port));
++ // TODO: Patch TOG-Pegasus client to accest bind hostname.
++ m_listener.reset(new Pegasus::CIMListener(m_port));
+ if (!m_listener)
+ throw_RuntimeError("Can't create CIMListener");
+
+- std::string std_cert_file;
+- std::string std_key_file;
+- std::string std_trust_store = CIMConstants::defaultTrustStore();
+- if (!isnone(cert_file)) {
+- std_cert_file = lmi::extract_or_throw<std::string>(
+- cert_file, "cert_file");
+- }
+- if (!isnone(key_file)) {
+- std_key_file = lmi::extract_or_throw<std::string>(
+- key_file, "key_file");
+- }
+- if (!isnone(trust_store)) {
+- std_trust_store = lmi::extract_or_throw<std::string>(
+- trust_store, "trust_store");
+- }
+-
+ try {
+- if (!std_cert_file.empty()) {
++ if (!m_certfile.empty()) {
+ // Pegasus::SSLContext will be freed by Pegasus::CIMListener
+ Pegasus::SSLContext *ctx = new Pegasus::SSLContext(
+- Pegasus::String(std_trust_store.c_str()),
+- Pegasus::String(std_cert_file.c_str()),
+- Pegasus::String(std_key_file.c_str()),
++ Pegasus::String(m_trust_store.c_str()),
++ Pegasus::String(m_certfile.c_str()),
++ Pegasus::String(m_keyfile.c_str()),
+ Pegasus::String::EMPTY, // CRL path
+ NULL, // verification callback
+ Pegasus::String::EMPTY);
+diff --git a/src/lmiwbem_listener.h b/src/lmiwbem_listener.h
+index a49bc29..11ffb4d 100644
+--- a/src/lmiwbem_listener.h
++++ b/src/lmiwbem_listener.h
+@@ -75,20 +75,22 @@ private:
+ class CIMIndicationListener: public CIMBase<CIMIndicationListener>
+ {
+ public:
+- CIMIndicationListener();
++ CIMIndicationListener(
++ const bp::object &hostname,
++ const bp::object &port,
++ const bp::object &certfile,
++ const bp::object &keyfile,
++ const bp::object &trust_store);
+
+ static void init_type();
+
+- void start(
+- const bp::object &port_,
+- const bp::object &cert_file,
+- const bp::object &key_file,
+- const bp::object &trust_store);
++ void start();
+ void stop();
+
+ bool isAlive() const { return m_listener && m_listener->isAlive(); }
+ bool usesSSL() const;
+
++ std::string getHostname() const { return m_hostname; }
+ int getPort() const { return m_listener ? m_listener->getPortNumber() : -1; }
+
+ bp::object addHandler(
+@@ -107,6 +109,12 @@ private:
+ CIMIndicationConsumer m_consumer;
+
+ handler_map_t m_handlers;
++
++ Pegasus::Uint32 m_port;
++ std::string m_hostname;
++ std::string m_certfile;
++ std::string m_keyfile;
++ std::string m_trust_store;
+ };
+
+ #endif // LMIWBEM_LISTENER_H
diff --git a/lmiwbem.spec b/lmiwbem.spec
index f67952d..4f338e2 100644
--- a/lmiwbem.spec
+++ b/lmiwbem.spec
@@ -1,6 +1,6 @@
Name: lmiwbem
Version: 0.2.0
-Release: 7%{?dist}
+Release: 8%{?dist}
Summary: Python WBEM Client
License: LGPLv2+
URL: https://github.com/phatina/lmiwbem
@@ -10,6 +10,7 @@ Patch1: lmiwbem-02-fix-value-type-deduction.patch
Patch2: lmiwbem-03-platform-support.patch
Patch3: lmiwbem-04-fix-gil-deadlocks.patch
Patch4: lmiwbem-05-fix-init.patch
+Patch5: lmiwbem-06-listener-api-compat.patch
BuildRequires: autoconf
BuildRequires: automake
@@ -42,6 +43,7 @@ Group: Documentation
%patch2 -p1 -b .platform-support
%patch3 -p1 -b .fix-gil-deadlocks
%patch4 -p1 -b .fix-init
+%patch5 -p1 -b .fix-listener-api-compat
%build
autoreconf -if
@@ -61,6 +63,9 @@ find %{buildroot} -name '*.la' | xargs rm -f
%{_docdir}/%{name}-%{version}/html
%changelog
+* Wed Jul 23 2014 Peter Hatina <phatina at redhat.com> - 0.2.0-8
+- fix CIMIndicationListener API compatibility
+
* Mon Jul 14 2014 Peter Hatina <phatina at redhat.com> - 0.2.0-7
- fix missing symbol in __init__.py's __all__
More information about the scm-commits
mailing list