[PATCH] [Kimchi] Remove federation feature from Kimchi as it is now on Wok

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com> --- control/peers.py | 28 ---------- docs/API.md | 10 ---- docs/README-federation.md | 60 -------------------- kimchi.conf | 4 -- model/config.py | 8 +-- model/peers.py | 74 ------------------------ root.py | 8 --- tests/test_config.py.in | 3 +- tests/test_rest.py | 6 +- ui/js/kimchi.peers.js | 140 ---------------------------------------------- ui/js/src/kimchi.main.js | 3 - ui/pages/i18n.json.tmpl | 7 +-- 12 files changed, 7 insertions(+), 344 deletions(-) delete mode 100644 control/peers.py delete mode 100644 docs/README-federation.md delete mode 100644 model/peers.py delete mode 100644 ui/js/kimchi.peers.js diff --git a/control/peers.py b/control/peers.py deleted file mode 100644 index 5eaacdd..0000000 --- a/control/peers.py +++ /dev/null @@ -1,28 +0,0 @@ -# -# Project Kimchi -# -# Copyright IBM Corp, 2015-2017 -# -# 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 wok.control.base import SimpleCollection -from wok.control.utils import UrlSubNode - - -@UrlSubNode("peers", True) -class Peers(SimpleCollection): - def __init__(self, model): - super(Peers, self).__init__(model) - self.admin_methods = ['GET'] diff --git a/docs/API.md b/docs/API.md index 3ecc7a0..1f67879 100644 --- a/docs/API.md +++ b/docs/API.md @@ -820,7 +820,6 @@ Contains information about Kimchi configuration. **Methods:** * **GET**: Retrieve configuration information - * federation: True if federation feature is enabled, False otherwise. * version: The version of the kimchi service * **POST**: *See Configuration Actions* @@ -1052,15 +1051,6 @@ List of available groups. * free: Amount of free space in the volume group. * size: Total size of the volume group. -### Collection: Peers - -**URI:** /plugins/kimchi/peers - -**Methods:** - -* **GET**: Return the list of Kimchi peers in the same network - (It uses openSLP for discovering) - ### Simple Collection: OVSBridges **URI:** /plugins/kimchi/ovsbridges diff --git a/docs/README-federation.md b/docs/README-federation.md deleted file mode 100644 index 3554757..0000000 --- a/docs/README-federation.md +++ /dev/null @@ -1,60 +0,0 @@ -Kimchi Project - Federation Feature -=================================== - -Federation feature is a Kimchi mechanism to discover Wok peers in the same -network. It uses openSLP tool (http://www.openslp.org/) to register and find Wok -servers. - -By default this feature is disabled on Wok as it is not critical for KVM -virtualization and requires additional software installation. - -To enable it, do the following: - -1. Install openslp and openslp-server rpm packages, - or install slpd and slptool deb packages. - -2. openSLP uses port 427 (UDP) and port 427 (TCP) so make sure to open those - ports in your firewall configuration - - For system using firewalld, do: - sudo firewall-cmd --permanent --add-port=427/udp - sudo firewall-cmd --permanent --add-port=427/tcp - sudo firewall-cmd --reload - - For openSUSE systems, do: - sudo /sbin/SuSEfirewall2 open EXT TCP 427 - sudo /sbin/SuSEfirewall2 open EXT UDP 427 - - For system using iptables, do: - sudo iptables -A INPUT -p tcp --dport 427 -j ACCEPT - sudo iptables -A INPUT -p udp --dport 427 -j ACCEPT - -3. In addition to the openSLP ports, you also need to allow multicast in the - firewall configuration - - For system using firewalld, do: - sudo firewall-cmd --direct --add-rule ipv4 filter INPUT 0 -s <subnet> -j ACCEPT - - For openSUSE systems, do: - Add the subnet to the trusted networks listed on FW_TRUSTED_NETS in - /etc/sysconfig/SuSEfirewall2 file. - Make sure to restart /sbin/SuSEfirewall2 after modifying /etc/sysconfig/SuSEfirewall2 - - For system using iptables, do: - sudo iptables -A INPUT -s <subnet> -j ACCEPT - -4. Start slpd service and make sure it is up while running Wok - sudo service slpd start - -5. Enable federation on Wok by editing the /etc/wok/plugins.d/kimchi.conf file: - - federation = True - -6. Then start Wok service - sudo service wokd start - -The Wok server will be registered on openSLP on server starting up and will -be found by other Wok peers (with federation feature enabled) in the same -network. - -Enjoy! diff --git a/kimchi.conf b/kimchi.conf index 97a14bd..5e85e2b 100644 --- a/kimchi.conf +++ b/kimchi.conf @@ -3,9 +3,5 @@ enable = True [kimchi] -# Federation feature: register Wok server on openSLP and discover peers -# in the same network. Check README-federation for more details. -federation = False - # Automatically create ISO pool on server start up create_iso_pool = True diff --git a/model/config.py b/model/config.py index 78cdaeb..1db9afb 100644 --- a/model/config.py +++ b/model/config.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -24,7 +24,7 @@ from wok.basemodel import Singleton from wok.exception import NotFoundError from wok.utils import run_command, wok_log -from wok.plugins.kimchi.config import config, find_qemu_binary +from wok.plugins.kimchi.config import find_qemu_binary from wok.plugins.kimchi.config import get_kimchi_version from wok.plugins.kimchi.distroloader import DistroLoader from wok.plugins.kimchi.model.featuretests import FeatureTests @@ -39,9 +39,7 @@ class ConfigModel(object): pass def lookup(self, name): - kconfig = config.get('kimchi', {}) - return {'federation': kconfig.get('federation', False), - 'version': get_kimchi_version()} + return {'version': get_kimchi_version()} class CapabilitiesModel(object): diff --git a/model/peers.py b/model/peers.py deleted file mode 100644 index 0a4ee4b..0000000 --- a/model/peers.py +++ /dev/null @@ -1,74 +0,0 @@ -# -# Project Kimchi -# -# Copyright IBM Corp, 2015-2017 -# -# 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 cherrypy -import re -import socket - -from wok.config import config as wok_config -from wok.utils import run_command, wok_log - -from wok.plugins.kimchi.config import config - - -class PeersModel(object): - def __init__(self, **kargs): - # check federation feature is enabled on Kimchi server - if not config.get('kimchi', {}).get('federation', False): - return - - # register server on openslp - hostname = socket.getfqdn() - port = wok_config.get("server", "proxy_port") - self.url = hostname + ":" + port - - cmd = ["slptool", "register", - "service:wokd://%s" % self.url] - out, error, ret = run_command(cmd) - if out and len(out) != 0: - wok_log.error("Unable to register server on openSLP." - " Details: %s" % out) - cherrypy.engine.subscribe('exit', self._peer_deregister) - - def _peer_deregister(self): - cmd = ["slptool", "deregister", - "service:wokd://%s" % self.url] - out, error, ret = run_command(cmd) - if out and len(out) != 0: - wok_log.error("Unable to deregister server on openSLP." - " Details: %s" % out) - - def get_list(self): - # check federation feature is enabled on Kimchi server - if not config.get('kimchi', {}).get('federation', False): - return [] - - cmd = ["slptool", "findsrvs", "service:wokd"] - out, error, ret = run_command(cmd) - if ret != 0: - return [] - - peers = [] - for server in out.strip().split("\n"): - match = re.match("service:wokd://(.*?),.*", server) - peer = match.group(1) - if peer != self.url: - peers.append("https://" + peer) - - return peers diff --git a/root.py b/root.py index 4f131e7..d42e787 100644 --- a/root.py +++ b/root.py @@ -72,14 +72,6 @@ class Kimchi(WokRoot): self.domain = 'kimchi' self.messages = messages - self.extends = { - "/plugins/gingerbase": { - "host-dashboard.html": "/plugins/kimchi/js/kimchi.peers.js" - } - } - - self.depends = ['gingerbase'] - # Some paths or URI's present in the objectstore have changed after # Kimchi 2.0.0 release. Check here if an upgrade in the schema and data # are necessary. diff --git a/tests/test_config.py.in b/tests/test_config.py.in index 135097b..dd47130 100644 --- a/tests/test_config.py.in +++ b/tests/test_config.py.in @@ -80,8 +80,7 @@ class ConfigTests(unittest.TestCase): 'enable': True }, 'kimchi': { - 'federation': False, - 'create_iso_pool': True, + 'create_iso_pool': True }, '/': { 'tools.trailing_slash.on': False, diff --git a/tests/test_rest.py b/tests/test_rest.py index 852e4bd..f808478 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -1529,7 +1529,7 @@ class RestTests(unittest.TestCase): def test_config(self): resp = self.request('/plugins/kimchi/config').read() conf = json.loads(resp) - keys = ["federation", "version"] + keys = ["version"] self.assertEquals(keys, sorted(conf.keys())) def test_capabilities(self): @@ -1541,10 +1541,6 @@ class RestTests(unittest.TestCase): u'mem_hotplug_support', u'libvirtd_running'] self.assertEquals(sorted(keys), sorted(conf.keys())) - def test_peers(self): - resp = self.request('/plugins/kimchi/peers').read() - self.assertEquals([], json.loads(resp)) - def test_distros(self): resp = self.request('/plugins/kimchi/config/distros').read() distros = json.loads(resp) diff --git a/ui/js/kimchi.peers.js b/ui/js/kimchi.peers.js deleted file mode 100644 index 8b1a18d..0000000 --- a/ui/js/kimchi.peers.js +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Project Kimchi - * - * Copyright IBM Corp, 2016 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var kimchi = { - - getPeers: function(suc, err) { - wok.requestJSON({ - url: 'plugins/kimchi/peers', - type: 'GET', - contentType: 'application/json', - dataType: 'json', - resend: true, - success: suc, - error: err ? err : function(data) { - wok.message.error(data.responseJSON.reason); - } - }); - }, - - initPeers: function() { - - var peersAccordion = "<div class='panel-group federation-enabled accordion' id='peers-content-area-accordion' role='tablist' aria-multiselectable='true'>" + - "<h3>" + - "<a role='button' aria-expanded='true' data-toggle='collapse' data-parent='#peers-content-area-accordion' href='#peers-content-area' aria-expanded='false' aria-controls='peers-content-area' class=''>" + - "<span class='accordion-icon'></span>" + - "<span class='accordion-text' id='#peers-title'>"+i18n['KCHPEERS0001M']+"</span>" + - "</a>" + - "</h3>" + - "<div id='peers-content-area' class='panel-collapse collapse in' role='tabpanel' aria-labelledby='peers-title'>" + - "<div id='peers-alert-container'></div>" + - "<div class='row'>" + - "<div class='col-sm-12'>" + - "<table id='peers-list' class='table table-striped' cellspacing='0' width='100%''>" + - "<thead>" + - "<tr>" + - "<th><span class='sr-only'>" + i18n['KCHPEERS0001M'] + "</span></th>" + - "</tr>" + - "</thead>" + - "</table>" + - "</div>" + - "</div>" + - "<div class='wok-mask' role='presentation'>" + - "<div class='wok-mask-loader-container'>" + - "<div class='wok-mask-loading'>" + - "<div class='wok-mask-loading-icon'></div>" + - "<div class='wok-mask-loading-text'>" + i18n['WOKGRD6001M'] + "</div>" + - "</div>" + - "</div>" + - "</div>" + - "</div>" + - "</div>"; - - var peersDatatableTable; - var peers = new Array(); - - $('#peers-container > .container').append(peersAccordion); - - var peersDatatable = function(nwConfigDataSet) { - peersDatatableTable = $('#peers-list').DataTable({ - "processing": true, - "data": peers, - "language": { - "emptyTable": i18n['WOKSETT0010M'] - }, - "order": [], - "paging": false, - "dom": '<"row"<"col-sm-12"t>>', - "scrollY": "269px", - "scrollCollapse": true, - "columnDefs": [{ - "targets": 0, - "searchable": false, - "orderable": false, - "width": "100%", - "className": "tabular-data", - "render": function(data, type, full, meta) { - return '<a href="' + data + '" target="_blank">' + data + '</a>'; - } - }], - "initComplete": function(settings, json) { - $('#peers-content-area > .wok-mask').addClass('hidden'); - } - }); - }; - - var getPeers = function() { - kimchi.getPeers(function(result) { - peers.length = 0; - for (var i = 0; i < result.length; i++) { - var tempArr = []; - tempArr.push(result[i]); - peers.push(tempArr); - } - peersDatatable(peers); - }, function(err) { - wok.message.error(err.responseJSON.reason, '#peers-alert-container', true); - }); - }; - getPeers(); - - }, - - getConfig: function(suc, err, done) { - done = typeof done !== 'undefined' ? done : function() {}; - wok.requestJSON({ - url: "plugins/kimchi/config", - type: "GET", - contentType: "application/json", - dataType: "json", - success: suc, - error: err, - complete: done - }); - } -} - -$(document).ready(function() { - // Peers check - kimchi.getConfig(function(config) { - if (config.federation) { - $("#host-content-container").after('<div id="peers-container"><div class="container"></div></div>'); - kimchi.initPeers(); - } - }); -}); diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js index 47531ae..89df799 100644 --- a/ui/js/src/kimchi.main.js +++ b/ui/js/src/kimchi.main.js @@ -19,9 +19,6 @@ kimchi.config = undefined; kimchi.getConfig(function(result) { kimchi.config = result; - - if(kimchi.config.federation == true) - $('#peers').removeClass('hide-content'); }, function() { kimchi.config = {} }); diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl index 4510921..d44d4bd 100644 --- a/ui/pages/i18n.json.tmpl +++ b/ui/pages/i18n.json.tmpl @@ -1,7 +1,7 @@ #* * Project Kimchi * - * Copyright IBM Corp, 2014-2016 + * Copyright IBM Corp, 2014-2017 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -154,8 +154,5 @@ "KCHVMSTOR0007M": "$_("qed")", "KCHVMSTOR0008M": "$_("raw")", "KCHVMSTOR0009M": "$_("vmdk")", - "KCHVMSTOR0010M": "$_("vpc")", - - - "KCHPEERS0001M": "$_("Peers")" + "KCHVMSTOR0010M": "$_("vpc")" } -- 2.9.3

Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com> On 05/02/2017 01:59 PM, Aline Manera wrote:
Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com> --- control/peers.py | 28 ---------- docs/API.md | 10 ---- docs/README-federation.md | 60 -------------------- kimchi.conf | 4 -- model/config.py | 8 +-- model/peers.py | 74 ------------------------ root.py | 8 --- tests/test_config.py.in | 3 +- tests/test_rest.py | 6 +- ui/js/kimchi.peers.js | 140 ---------------------------------------------- ui/js/src/kimchi.main.js | 3 - ui/pages/i18n.json.tmpl | 7 +-- 12 files changed, 7 insertions(+), 344 deletions(-) delete mode 100644 control/peers.py delete mode 100644 docs/README-federation.md delete mode 100644 model/peers.py delete mode 100644 ui/js/kimchi.peers.js
diff --git a/control/peers.py b/control/peers.py deleted file mode 100644 index 5eaacdd..0000000 --- a/control/peers.py +++ /dev/null @@ -1,28 +0,0 @@ -# -# Project Kimchi -# -# Copyright IBM Corp, 2015-2017 -# -# 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 wok.control.base import SimpleCollection -from wok.control.utils import UrlSubNode - - -@UrlSubNode("peers", True) -class Peers(SimpleCollection): - def __init__(self, model): - super(Peers, self).__init__(model) - self.admin_methods = ['GET'] diff --git a/docs/API.md b/docs/API.md index 3ecc7a0..1f67879 100644 --- a/docs/API.md +++ b/docs/API.md @@ -820,7 +820,6 @@ Contains information about Kimchi configuration. **Methods:**
* **GET**: Retrieve configuration information - * federation: True if federation feature is enabled, False otherwise. * version: The version of the kimchi service * **POST**: *See Configuration Actions*
@@ -1052,15 +1051,6 @@ List of available groups. * free: Amount of free space in the volume group. * size: Total size of the volume group.
-### Collection: Peers - -**URI:** /plugins/kimchi/peers - -**Methods:** - -* **GET**: Return the list of Kimchi peers in the same network - (It uses openSLP for discovering) - ### Simple Collection: OVSBridges
**URI:** /plugins/kimchi/ovsbridges diff --git a/docs/README-federation.md b/docs/README-federation.md deleted file mode 100644 index 3554757..0000000 --- a/docs/README-federation.md +++ /dev/null @@ -1,60 +0,0 @@ -Kimchi Project - Federation Feature -=================================== - -Federation feature is a Kimchi mechanism to discover Wok peers in the same -network. It uses openSLP tool (http://www.openslp.org/) to register and find Wok -servers. - -By default this feature is disabled on Wok as it is not critical for KVM -virtualization and requires additional software installation. - -To enable it, do the following: - -1. Install openslp and openslp-server rpm packages, - or install slpd and slptool deb packages. - -2. openSLP uses port 427 (UDP) and port 427 (TCP) so make sure to open those - ports in your firewall configuration - - For system using firewalld, do: - sudo firewall-cmd --permanent --add-port=427/udp - sudo firewall-cmd --permanent --add-port=427/tcp - sudo firewall-cmd --reload - - For openSUSE systems, do: - sudo /sbin/SuSEfirewall2 open EXT TCP 427 - sudo /sbin/SuSEfirewall2 open EXT UDP 427 - - For system using iptables, do: - sudo iptables -A INPUT -p tcp --dport 427 -j ACCEPT - sudo iptables -A INPUT -p udp --dport 427 -j ACCEPT - -3. In addition to the openSLP ports, you also need to allow multicast in the - firewall configuration - - For system using firewalld, do: - sudo firewall-cmd --direct --add-rule ipv4 filter INPUT 0 -s <subnet> -j ACCEPT - - For openSUSE systems, do: - Add the subnet to the trusted networks listed on FW_TRUSTED_NETS in - /etc/sysconfig/SuSEfirewall2 file. - Make sure to restart /sbin/SuSEfirewall2 after modifying /etc/sysconfig/SuSEfirewall2 - - For system using iptables, do: - sudo iptables -A INPUT -s <subnet> -j ACCEPT - -4. Start slpd service and make sure it is up while running Wok - sudo service slpd start - -5. Enable federation on Wok by editing the /etc/wok/plugins.d/kimchi.conf file: - - federation = True - -6. Then start Wok service - sudo service wokd start - -The Wok server will be registered on openSLP on server starting up and will -be found by other Wok peers (with federation feature enabled) in the same -network. - -Enjoy! diff --git a/kimchi.conf b/kimchi.conf index 97a14bd..5e85e2b 100644 --- a/kimchi.conf +++ b/kimchi.conf @@ -3,9 +3,5 @@ enable = True
[kimchi] -# Federation feature: register Wok server on openSLP and discover peers -# in the same network. Check README-federation for more details. -federation = False - # Automatically create ISO pool on server start up create_iso_pool = True diff --git a/model/config.py b/model/config.py index 78cdaeb..1db9afb 100644 --- a/model/config.py +++ b/model/config.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -24,7 +24,7 @@ from wok.basemodel import Singleton from wok.exception import NotFoundError from wok.utils import run_command, wok_log
-from wok.plugins.kimchi.config import config, find_qemu_binary +from wok.plugins.kimchi.config import find_qemu_binary from wok.plugins.kimchi.config import get_kimchi_version from wok.plugins.kimchi.distroloader import DistroLoader from wok.plugins.kimchi.model.featuretests import FeatureTests @@ -39,9 +39,7 @@ class ConfigModel(object): pass
def lookup(self, name): - kconfig = config.get('kimchi', {}) - return {'federation': kconfig.get('federation', False), - 'version': get_kimchi_version()} + return {'version': get_kimchi_version()}
class CapabilitiesModel(object): diff --git a/model/peers.py b/model/peers.py deleted file mode 100644 index 0a4ee4b..0000000 --- a/model/peers.py +++ /dev/null @@ -1,74 +0,0 @@ -# -# Project Kimchi -# -# Copyright IBM Corp, 2015-2017 -# -# 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 cherrypy -import re -import socket - -from wok.config import config as wok_config -from wok.utils import run_command, wok_log - -from wok.plugins.kimchi.config import config - - -class PeersModel(object): - def __init__(self, **kargs): - # check federation feature is enabled on Kimchi server - if not config.get('kimchi', {}).get('federation', False): - return - - # register server on openslp - hostname = socket.getfqdn() - port = wok_config.get("server", "proxy_port") - self.url = hostname + ":" + port - - cmd = ["slptool", "register", - "service:wokd://%s" % self.url] - out, error, ret = run_command(cmd) - if out and len(out) != 0: - wok_log.error("Unable to register server on openSLP." - " Details: %s" % out) - cherrypy.engine.subscribe('exit', self._peer_deregister) - - def _peer_deregister(self): - cmd = ["slptool", "deregister", - "service:wokd://%s" % self.url] - out, error, ret = run_command(cmd) - if out and len(out) != 0: - wok_log.error("Unable to deregister server on openSLP." - " Details: %s" % out) - - def get_list(self): - # check federation feature is enabled on Kimchi server - if not config.get('kimchi', {}).get('federation', False): - return [] - - cmd = ["slptool", "findsrvs", "service:wokd"] - out, error, ret = run_command(cmd) - if ret != 0: - return [] - - peers = [] - for server in out.strip().split("\n"): - match = re.match("service:wokd://(.*?),.*", server) - peer = match.group(1) - if peer != self.url: - peers.append("https://" + peer) - - return peers diff --git a/root.py b/root.py index 4f131e7..d42e787 100644 --- a/root.py +++ b/root.py @@ -72,14 +72,6 @@ class Kimchi(WokRoot): self.domain = 'kimchi' self.messages = messages
- self.extends = { - "/plugins/gingerbase": { - "host-dashboard.html": "/plugins/kimchi/js/kimchi.peers.js" - } - } - - self.depends = ['gingerbase'] - # Some paths or URI's present in the objectstore have changed after # Kimchi 2.0.0 release. Check here if an upgrade in the schema and data # are necessary. diff --git a/tests/test_config.py.in b/tests/test_config.py.in index 135097b..dd47130 100644 --- a/tests/test_config.py.in +++ b/tests/test_config.py.in @@ -80,8 +80,7 @@ class ConfigTests(unittest.TestCase): 'enable': True }, 'kimchi': { - 'federation': False, - 'create_iso_pool': True, + 'create_iso_pool': True }, '/': { 'tools.trailing_slash.on': False, diff --git a/tests/test_rest.py b/tests/test_rest.py index 852e4bd..f808478 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -1529,7 +1529,7 @@ class RestTests(unittest.TestCase): def test_config(self): resp = self.request('/plugins/kimchi/config').read() conf = json.loads(resp) - keys = ["federation", "version"] + keys = ["version"] self.assertEquals(keys, sorted(conf.keys()))
def test_capabilities(self): @@ -1541,10 +1541,6 @@ class RestTests(unittest.TestCase): u'mem_hotplug_support', u'libvirtd_running'] self.assertEquals(sorted(keys), sorted(conf.keys()))
- def test_peers(self): - resp = self.request('/plugins/kimchi/peers').read() - self.assertEquals([], json.loads(resp)) - def test_distros(self): resp = self.request('/plugins/kimchi/config/distros').read() distros = json.loads(resp) diff --git a/ui/js/kimchi.peers.js b/ui/js/kimchi.peers.js deleted file mode 100644 index 8b1a18d..0000000 --- a/ui/js/kimchi.peers.js +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Project Kimchi - * - * Copyright IBM Corp, 2016 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var kimchi = { - - getPeers: function(suc, err) { - wok.requestJSON({ - url: 'plugins/kimchi/peers', - type: 'GET', - contentType: 'application/json', - dataType: 'json', - resend: true, - success: suc, - error: err ? err : function(data) { - wok.message.error(data.responseJSON.reason); - } - }); - }, - - initPeers: function() { - - var peersAccordion = "<div class='panel-group federation-enabled accordion' id='peers-content-area-accordion' role='tablist' aria-multiselectable='true'>" + - "<h3>" + - "<a role='button' aria-expanded='true' data-toggle='collapse' data-parent='#peers-content-area-accordion' href='#peers-content-area' aria-expanded='false' aria-controls='peers-content-area' class=''>" + - "<span class='accordion-icon'></span>" + - "<span class='accordion-text' id='#peers-title'>"+i18n['KCHPEERS0001M']+"</span>" + - "</a>" + - "</h3>" + - "<div id='peers-content-area' class='panel-collapse collapse in' role='tabpanel' aria-labelledby='peers-title'>" + - "<div id='peers-alert-container'></div>" + - "<div class='row'>" + - "<div class='col-sm-12'>" + - "<table id='peers-list' class='table table-striped' cellspacing='0' width='100%''>" + - "<thead>" + - "<tr>" + - "<th><span class='sr-only'>" + i18n['KCHPEERS0001M'] + "</span></th>" + - "</tr>" + - "</thead>" + - "</table>" + - "</div>" + - "</div>" + - "<div class='wok-mask' role='presentation'>" + - "<div class='wok-mask-loader-container'>" + - "<div class='wok-mask-loading'>" + - "<div class='wok-mask-loading-icon'></div>" + - "<div class='wok-mask-loading-text'>" + i18n['WOKGRD6001M'] + "</div>" + - "</div>" + - "</div>" + - "</div>" + - "</div>" + - "</div>"; - - var peersDatatableTable; - var peers = new Array(); - - $('#peers-container > .container').append(peersAccordion); - - var peersDatatable = function(nwConfigDataSet) { - peersDatatableTable = $('#peers-list').DataTable({ - "processing": true, - "data": peers, - "language": { - "emptyTable": i18n['WOKSETT0010M'] - }, - "order": [], - "paging": false, - "dom": '<"row"<"col-sm-12"t>>', - "scrollY": "269px", - "scrollCollapse": true, - "columnDefs": [{ - "targets": 0, - "searchable": false, - "orderable": false, - "width": "100%", - "className": "tabular-data", - "render": function(data, type, full, meta) { - return '<a href="' + data + '" target="_blank">' + data + '</a>'; - } - }], - "initComplete": function(settings, json) { - $('#peers-content-area > .wok-mask').addClass('hidden'); - } - }); - }; - - var getPeers = function() { - kimchi.getPeers(function(result) { - peers.length = 0; - for (var i = 0; i < result.length; i++) { - var tempArr = []; - tempArr.push(result[i]); - peers.push(tempArr); - } - peersDatatable(peers); - }, function(err) { - wok.message.error(err.responseJSON.reason, '#peers-alert-container', true); - }); - }; - getPeers(); - - }, - - getConfig: function(suc, err, done) { - done = typeof done !== 'undefined' ? done : function() {}; - wok.requestJSON({ - url: "plugins/kimchi/config", - type: "GET", - contentType: "application/json", - dataType: "json", - success: suc, - error: err, - complete: done - }); - } -} - -$(document).ready(function() { - // Peers check - kimchi.getConfig(function(config) { - if (config.federation) { - $("#host-content-container").after('<div id="peers-container"><div class="container"></div></div>'); - kimchi.initPeers(); - } - }); -}); diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js index 47531ae..89df799 100644 --- a/ui/js/src/kimchi.main.js +++ b/ui/js/src/kimchi.main.js @@ -19,9 +19,6 @@ kimchi.config = undefined; kimchi.getConfig(function(result) { kimchi.config = result; - - if(kimchi.config.federation == true) - $('#peers').removeClass('hide-content'); }, function() { kimchi.config = {} }); diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl index 4510921..d44d4bd 100644 --- a/ui/pages/i18n.json.tmpl +++ b/ui/pages/i18n.json.tmpl @@ -1,7 +1,7 @@ #* * Project Kimchi * - * Copyright IBM Corp, 2014-2016 + * Copyright IBM Corp, 2014-2017 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -154,8 +154,5 @@ "KCHVMSTOR0007M": "$_("qed")", "KCHVMSTOR0008M": "$_("raw")", "KCHVMSTOR0009M": "$_("vmdk")", - "KCHVMSTOR0010M": "$_("vpc")", - - - "KCHPEERS0001M": "$_("Peers")" + "KCHVMSTOR0010M": "$_("vpc")" }
participants (2)
-
Aline Manera
-
Daniel Henrique Barboza