[PATCH RFC] Discover Kimchi peers using openSLP

GET /peers [ "https://ubuntu-vm:8001", "https://rhel-vm:8001", ] How to test it? - Install openslp and openslp-server - Start opnslp service: servicd slpd start - Make sure to open openSLP port (427 UDP and TCP) on firewall I tested it using VMs as they are in the same host network. TODO: #1: Add option on Kimchi config file to enable/disable this feature #2: Update /config/capabilities to return if federation is enabled or not GET /config/capabilities { ... federation: enable|disable } #3: Create README-federation file to provide details on how to enable this feature #4: Update API.md, mockmodel and test cases Aline Manera (1): Discover Kimchi peers using openSLP src/kimchi/control/peers.py | 29 ++++++++++++++++++++++++++ src/kimchi/model/peers.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/kimchi/control/peers.py create mode 100644 src/kimchi/model/peers.py -- 1.9.3

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com> --- src/kimchi/control/peers.py | 29 ++++++++++++++++++++++++++ src/kimchi/model/peers.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/kimchi/control/peers.py create mode 100644 src/kimchi/model/peers.py diff --git a/src/kimchi/control/peers.py b/src/kimchi/control/peers.py new file mode 100644 index 0000000..f72a38c --- /dev/null +++ b/src/kimchi/control/peers.py @@ -0,0 +1,29 @@ +# +# Project Kimchi +# +# Copyright IBM, Corp. 2014 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +from kimchi.control.base import SimpleCollection +from kimchi.control.utils import UrlSubNode + + +@UrlSubNode("peers", True) +class Peers(SimpleCollection): + def __init__(self, model): + super(Peers, self).__init__(model) + self.role_key = 'peers' + self.admin_methods = ['GET'] diff --git a/src/kimchi/model/peers.py b/src/kimchi/model/peers.py new file mode 100644 index 0000000..d0f8808 --- /dev/null +++ b/src/kimchi/model/peers.py @@ -0,0 +1,50 @@ +# +# Project Kimchi +# +# Copyright IBM, Corp. 2014 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +import re +import socket + +from kimchi.config import config +from kimchi.utils import kimchi_log, run_command + + +class PeersModel(object): + def __init__(self, **kargs): + # TODO: only register server on openSLP if federation feature is + # enabled + # register server on openslp + hostname = socket.getfqdn(config.get("server", "host")) + port = config.get("server", "ssl_port") + + cmd = ["slptool", "register", + "service:kimchid://%s:%s" % (hostname, port)] + out, error, ret = run_command(cmd) + if len(out) != 0: + kimchi_log.info("Unable to register server on openSLP") + + def get_list(self): + peers = [] + + cmd = ["slptool", "findsrvs", "service:kimchid"] + out, error, ret = run_command(cmd) + for server in out.strip().split("\n"): + match = re.match("service:kimchid://(.*?),.*", server) + peers.append("https://" + match.group(1)) + + return peers -- 1.9.3

On 2014年08月16日 03:06, Aline Manera wrote:
GET /peers [ "https://ubuntu-vm:8001", "https://rhel-vm:8001", ]
How to test it? - Install openslp and openslp-server - Start opnslp service: servicd slpd start - Make sure to open openSLP port (427 UDP and TCP) on firewall SLP seems to be a good idea for our scenario, here I have some questions:
1.Do we need a centralized server(slpd) to track service or every host will have an slpd installed and can handle request? 2.How do we define peers--Even some hosts have kimchi service enabled, they are of different hardware/software which prevent them from migration. 3.Do we support peer discovery between hosts which located distantly with each other? Will the peer query time consuming? 4.What are kimchi peer discovery's use cases:a. migration, b. browse other hosts from one access point, c. others?
I tested it using VMs as they are in the same host network.
TODO: #1: Add option on Kimchi config file to enable/disable this feature #2: Update /config/capabilities to return if federation is enabled or not GET /config/capabilities { ... federation: enable|disable }
#3: Create README-federation file to provide details on how to enable this feature #4: Update API.md, mockmodel and test cases
Aline Manera (1): Discover Kimchi peers using openSLP
src/kimchi/control/peers.py | 29 ++++++++++++++++++++++++++ src/kimchi/model/peers.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/kimchi/control/peers.py create mode 100644 src/kimchi/model/peers.py

On 08/18/2014 03:54 AM, Royce Lv wrote:
On 2014年08月16日 03:06, Aline Manera wrote:
GET /peers [ "https://ubuntu-vm:8001", "https://rhel-vm:8001", ]
How to test it? - Install openslp and openslp-server - Start opnslp service: servicd slpd start - Make sure to open openSLP port (427 UDP and TCP) on firewall SLP seems to be a good idea for our scenario, here I have some questions:
1.Do we need a centralized server(slpd) to track service or every host will have an slpd installed and can handle request?
Every Kimchi server must have an slpd installed to handle the requests.
2.How do we define peers--Even some hosts have kimchi service enabled, they are of different hardware/software which prevent them from migration.
The idea here is only discover Kimchi peers in the same network. Of course, when we use it for migration we will need to include some restrictions.
3.Do we support peer discovery between hosts which located distantly with each other? Will the peer query time consuming?
Kimchi peers are in the same network. So long distant server will not fill this requirement.
4.What are kimchi peer discovery's use cases:a. migration, b. browse other hosts from one access point, c. others?
I can only think about A and B by now.
I tested it using VMs as they are in the same host network.
TODO: #1: Add option on Kimchi config file to enable/disable this feature #2: Update /config/capabilities to return if federation is enabled or not GET /config/capabilities { ... federation: enable|disable }
#3: Create README-federation file to provide details on how to enable this feature #4: Update API.md, mockmodel and test cases
Aline Manera (1): Discover Kimchi peers using openSLP
src/kimchi/control/peers.py | 29 ++++++++++++++++++++++++++ src/kimchi/model/peers.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/kimchi/control/peers.py create mode 100644 src/kimchi/model/peers.py
participants (2)
-
Aline Manera
-
Royce Lv