[PATCH] [Kimchi 0/9] Virt-Viewer launcher backend
by dhbarboza82@gmail.com
From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
This patch set adds the Virt-Viewer launcher backend to
Kimchi.
This feature consists of a new resource located in:
**URI:** /plugins/kimchi/vms/*:name*/snapshots/current
that retrieves a download link to a .vv file to be
used by a Virt-Viewer compatible desktop app to connect
to the remote virtual machine.
This backend takes cares of handling firewall rules to
allow the connection to be succesfull. Note that no firewall
port will be opened unless a download is made - if the user
decides to use noVNC or spice-html5 instead Kimchi will
not touch the host firewall.
Example:
[danielhb@arthas kimchi]$ curl -u root -H "Content-Type: application/json" -H "Accept: application/json" -X GET "http://localhost:8010/plugins/kimchi/vms/OpenSUSE-Leap-42.1/virtviewerfile"
Enter host password for user 'root':
[virt-viewer]
type=vnc
host=localhost
port=5904
After this call, port 5904 was opened in the host to allow for a
virt-viewer connection.
When shutting down the virtual machine or WoK, a cleanup is made
to close any ports left opened.
Daniel Henrique Barboza (9):
Virt-Viewer launcher: docs and i18n changes
Virt-Viewer launcher: Makefile and config changes
Virt-Viewer launcher: control/vms.py and model/vms.py changes
Virt-Viewer launcher: virtviewerfile module
Virt-Viewer launcher: test changes
Virt-Viewer launcher: adding FirewallManager class
Virt-Viewer launcher: test changes for firewall manager
Virt-Viewer launcher: libvirt events to control firewall
Virt-Viewer launcher: changes after adding libvirt event listening
Makefile.am | 2 +
config.py.in | 10 ++-
control/vms.py | 12 +++
docs/API.md | 6 ++
i18n.py | 2 +
model/virtviewerfile.py | 234 ++++++++++++++++++++++++++++++++++++++++++++++++
model/vms.py | 9 +-
tests/test_config.py.in | 6 ++
tests/test_model.py | 219 +++++++++++++++++++++++++++++++++++++++++++-
9 files changed, 494 insertions(+), 6 deletions(-)
create mode 100644 model/virtviewerfile.py
--
2.5.5
8 years, 4 months
[PATCH v2] [Wok] Use callback instead of log file for run_command output
by Lucio Correia
* Ignore empty messages
* Simplify exception message
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
src/wok/asynctask.py | 13 +++++--------
src/wok/utils.py | 42 +++++++++++++-----------------------------
2 files changed, 18 insertions(+), 37 deletions(-)
Changes in V2:
* removed unnecessary line
diff --git a/src/wok/asynctask.py b/src/wok/asynctask.py
index ec3fbc1..fb614a2 100644
--- a/src/wok/asynctask.py
+++ b/src/wok/asynctask.py
@@ -46,15 +46,12 @@ class AsyncTask(object):
self.thread.start()
def _status_cb(self, message, success=None):
- if success is None:
- self.message = message
- self._save_helper()
- return
-
if success is not None:
self.status = 'finished' if success else 'failed'
- self.message = message
- self._save_helper()
+
+ if message.strip():
+ self.message = message
+ self._save_helper()
def _save_helper(self):
obj = {}
@@ -73,4 +70,4 @@ class AsyncTask(object):
except Exception, e:
cherrypy.log.error_log.error("Error in async_task %s " % self.id)
cherrypy.log.error_log.error(traceback.format_exc())
- cb("Unexpected exception: %s" % e.message, False)
+ cb(e.message, False)
diff --git a/src/wok/utils.py b/src/wok/utils.py
index 4b3b0ac..c78a77a 100644
--- a/src/wok/utils.py
+++ b/src/wok/utils.py
@@ -175,16 +175,21 @@ def import_module(module_name, class_name=''):
return __import__(module_name, globals(), locals(), [class_name])
-def run_command(cmd, timeout=None, silent=False, tee=None,
- env_vars=None):
+def run_command(cmd, timeout=None, silent=False, out_cb=None, env_vars=None):
"""
cmd is a sequence of command arguments.
timeout is a float number in seconds.
timeout default value is None, means command run without timeout.
silent is bool, it will log errors using debug handler not error.
silent default value is False.
- tee is a file path to store the output of the command, like 'tee' command.
- tee default value is None, means output will not be logged.
+ out_cb is a callback that receives the whole command output every time a
+ new line is thrown by command. Default value is None, meaning that whole
+ output will be returned at the end of execution.
+
+ Returns a tuple (out, error, returncode) where:
+ out is the output thrown by command
+ error is an error message if applicable
+ returncode is an integer equal to the result of command execution
"""
# subprocess.kill() can leave descendants running
# and halting the execution. Using psutil to
@@ -202,24 +207,6 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
else:
timeout_flag[0] = True
- # function to append the given msg into the log_file
- def tee_log(msg=None, log_file=None):
- if (msg is None) or (log_file is None):
- return
-
- try:
- f = open(log_file, 'a')
- except IOError as e:
- msg = "Failed to open file %s: " % log_file
- wok_log.error("%s %s", msg, e)
- return
- msg += '\n'
- try:
- f.write(msg)
- except TypeError:
- f.write(msg.encode('utf_8'))
- f.close()
-
proc = None
timer = None
timeout_flag = [False]
@@ -239,9 +226,7 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
timer.start()
wok_log.debug("Run command: '%s'", " ".join(cmd))
- if tee is not None:
- if os.path.exists(tee):
- os.remove(tee)
+ if out_cb is not None:
output = []
while True:
line = ""
@@ -259,8 +244,7 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
output.append(line)
if not line:
break
- line = line.rstrip('\n\r')
- tee_log(line, tee)
+ out_cb(''.join(output))
out = ''.join(output)
error = proc.stderr.read()
returncode = proc.poll()
@@ -281,8 +265,8 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
else:
wok_log.error(msg)
- if tee is not None:
- tee_log(msg, tee)
+ if out_cb is not None:
+ out_cb(msg)
elif error:
wok_log.debug("error: %s returned from cmd: %s",
decode_value(error), decode_value(' '.join(cmd)))
--
1.9.1
8 years, 4 months
[PATCH] [Wok] Use callback instead of log file for run_command output
by Lucio Correia
* Ignore empty messages
* Simplify exception message
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
src/wok/asynctask.py | 13 +++++--------
src/wok/utils.py | 41 +++++++++++++----------------------------
2 files changed, 18 insertions(+), 36 deletions(-)
diff --git a/src/wok/asynctask.py b/src/wok/asynctask.py
index ec3fbc1..fb614a2 100644
--- a/src/wok/asynctask.py
+++ b/src/wok/asynctask.py
@@ -46,15 +46,12 @@ class AsyncTask(object):
self.thread.start()
def _status_cb(self, message, success=None):
- if success is None:
- self.message = message
- self._save_helper()
- return
-
if success is not None:
self.status = 'finished' if success else 'failed'
- self.message = message
- self._save_helper()
+
+ if message.strip():
+ self.message = message
+ self._save_helper()
def _save_helper(self):
obj = {}
@@ -73,4 +70,4 @@ class AsyncTask(object):
except Exception, e:
cherrypy.log.error_log.error("Error in async_task %s " % self.id)
cherrypy.log.error_log.error(traceback.format_exc())
- cb("Unexpected exception: %s" % e.message, False)
+ cb(e.message, False)
diff --git a/src/wok/utils.py b/src/wok/utils.py
index 4b3b0ac..d532f96 100644
--- a/src/wok/utils.py
+++ b/src/wok/utils.py
@@ -175,16 +175,21 @@ def import_module(module_name, class_name=''):
return __import__(module_name, globals(), locals(), [class_name])
-def run_command(cmd, timeout=None, silent=False, tee=None,
- env_vars=None):
+def run_command(cmd, timeout=None, silent=False, out_cb=None, env_vars=None):
"""
cmd is a sequence of command arguments.
timeout is a float number in seconds.
timeout default value is None, means command run without timeout.
silent is bool, it will log errors using debug handler not error.
silent default value is False.
- tee is a file path to store the output of the command, like 'tee' command.
- tee default value is None, means output will not be logged.
+ out_cb is a callback that receives the whole command output every time a
+ new line is thrown by command. Default value is None, meaning that whole
+ output will be returned at the end of execution.
+
+ Returns a tuple (out, error, returncode) where:
+ out is the output thrown by command
+ error is an error message if applicable
+ returncode is an integer equal to the result of command execution
"""
# subprocess.kill() can leave descendants running
# and halting the execution. Using psutil to
@@ -202,24 +207,6 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
else:
timeout_flag[0] = True
- # function to append the given msg into the log_file
- def tee_log(msg=None, log_file=None):
- if (msg is None) or (log_file is None):
- return
-
- try:
- f = open(log_file, 'a')
- except IOError as e:
- msg = "Failed to open file %s: " % log_file
- wok_log.error("%s %s", msg, e)
- return
- msg += '\n'
- try:
- f.write(msg)
- except TypeError:
- f.write(msg.encode('utf_8'))
- f.close()
-
proc = None
timer = None
timeout_flag = [False]
@@ -239,9 +226,7 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
timer.start()
wok_log.debug("Run command: '%s'", " ".join(cmd))
- if tee is not None:
- if os.path.exists(tee):
- os.remove(tee)
+ if out_cb is not None:
output = []
while True:
line = ""
@@ -260,7 +245,7 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
if not line:
break
line = line.rstrip('\n\r')
- tee_log(line, tee)
+ out_cb(''.join(output))
out = ''.join(output)
error = proc.stderr.read()
returncode = proc.poll()
@@ -281,8 +266,8 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
else:
wok_log.error(msg)
- if tee is not None:
- tee_log(msg, tee)
+ if out_cb is not None:
+ out_cb(msg)
elif error:
wok_log.debug("error: %s returned from cmd: %s",
decode_value(error), decode_value(' '.join(cmd)))
--
1.9.1
8 years, 4 months
[PATCH v4] [Wok 0/3] Adding DataTables.net plugin and Moment.js to Wok
by sguimaraes943@gmail.com
From: Samuel Guimarães <sguimaraes943(a)gmail.com>
Some files are minified. Let me know if they were corrupted by git send-email --no-validate
This commit adds DataTables.net jQuery plugin and Moment.js library to Wok.
DataTables.net is a table plugin that supports pagination, instance search and multi-column ordering. It also has a responsive module and it is compatible with many different CSS libraries.
In this commit it is included a customization for its Bootstrap integration and a default initialization script pre-loaded with Wok styles.
Moment.js is a lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates. It is required in order to filter and sort dates properly in Wok User Logs and Ginger Configuration Backup.
v2 - Added minified files that were ignored by .gitignore
v3 - Included DataTables plugins and separated files in different commits.
v4 - Fixed white-space and CSS errors
Samuel Guimarães (3):
Initial commit for Datatables.net and Moment.JS
Added Moment.JS file with locales
Added DataTables.net JS minified files
configure.ac | 3 +
ui/css/Makefile.am | 8 +-
ui/css/datatables.bootstrap.css | 255 +++++++++++++++++++++++++
ui/css/src/datatables.bootstrap.scss | 302 ++++++++++++++++++++++++++++++
ui/js/src/wok.datatables.js | 42 +++++
ui/libs/Makefile.am | 2 +-
ui/libs/datatables/Makefile.am | 23 +++
ui/libs/datatables/css/Makefile.am | 21 +++
ui/libs/datatables/css/datatables.min.css | 24 +++
ui/libs/datatables/datatables.min.js | 273 +++++++++++++++++++++++++++
ui/libs/moment/LICENSE | 22 +++
ui/libs/moment/Makefile.am | 21 +++
ui/libs/moment/moment-with-locales.min.js | 76 ++++++++
ui/pages/login.html.tmpl | 4 +
ui/pages/wok-ui.html.tmpl | 4 +
15 files changed, 1077 insertions(+), 3 deletions(-)
create mode 100644 ui/css/datatables.bootstrap.css
create mode 100644 ui/css/src/datatables.bootstrap.scss
create mode 100644 ui/js/src/wok.datatables.js
create mode 100644 ui/libs/datatables/Makefile.am
create mode 100644 ui/libs/datatables/css/Makefile.am
create mode 100644 ui/libs/datatables/css/datatables.min.css
create mode 100644 ui/libs/datatables/datatables.min.js
create mode 100644 ui/libs/moment/LICENSE
create mode 100644 ui/libs/moment/Makefile.am
create mode 100644 ui/libs/moment/moment-with-locales.min.js
--
1.9.3
8 years, 4 months
[PATCH v5 0/3] [Wok] Initial commit for Datatables.net and Moment.JS
by sguimaraes943@gmail.com
From: Samuel Guimarães <sguimaraes943(a)gmail.com>
Some files are minified. Let me know if they were corrupted by git send-email --no-validate
This commit adds DataTables.net jQuery plugin and Moment.js library to Wok.
DataTables.net is a table plugin that supports pagination, instance search and multi-column ordering. It also has a responsive module and it is compatible with many different CSS libraries.
In this commit it is included a customization for its Bootstrap integration and a default initialization script pre-loaded with Wok styles.
Moment.js is a lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates. It is required in order to filter and sort dates properly in Wok User Logs and Ginger Configuration Backup.
v2 - Added minified files that were ignored by .gitignore
v3 - Included DataTables plugins and separated files in different commits.
v4 - Fixed white-space and CSS errors
v5 - Included license for Datatables files in libs folder and CSS
Samuel Guimarães (3):
Initial commit for Datatables.net and Moment.JS
Added Moment.JS file with locales
Added DataTables.net JS minified files
configure.ac | 4 +
ui/css/Makefile.am | 8 +-
ui/css/datatables.bootstrap.css | 262 +++++++++++++++++++++++++
ui/css/src/datatables.bootstrap.scss | 310 ++++++++++++++++++++++++++++++
ui/js/src/wok.datatables.js | 42 ++++
ui/libs/Makefile.am | 2 +-
ui/libs/datatables/LICENSE | 22 +++
ui/libs/datatables/Makefile.am | 19 ++
ui/libs/datatables/css/Makefile.am | 21 ++
ui/libs/datatables/css/datatables.min.css | 24 +++
ui/libs/datatables/js/Makefile.am | 21 ++
ui/libs/datatables/js/datatables.min.js | 273 ++++++++++++++++++++++++++
ui/libs/moment/LICENSE | 22 +++
ui/libs/moment/Makefile.am | 21 ++
ui/libs/moment/moment-with-locales.min.js | 76 ++++++++
ui/pages/login.html.tmpl | 4 +
ui/pages/wok-ui.html.tmpl | 4 +
17 files changed, 1132 insertions(+), 3 deletions(-)
create mode 100644 ui/css/datatables.bootstrap.css
create mode 100644 ui/css/src/datatables.bootstrap.scss
create mode 100644 ui/js/src/wok.datatables.js
create mode 100644 ui/libs/datatables/LICENSE
create mode 100644 ui/libs/datatables/Makefile.am
create mode 100644 ui/libs/datatables/css/Makefile.am
create mode 100644 ui/libs/datatables/css/datatables.min.css
create mode 100644 ui/libs/datatables/js/Makefile.am
create mode 100644 ui/libs/datatables/js/datatables.min.js
create mode 100644 ui/libs/moment/LICENSE
create mode 100644 ui/libs/moment/Makefile.am
create mode 100644 ui/libs/moment/moment-with-locales.min.js
--
1.9.3
8 years, 4 months
[PATCH] [Kimchi] Disable ISOs with wrong permission and add mouse hover message
by peterpnns@gmail.com
From: peterpennings <peterpnns(a)gmail.com>
This patch turns impossible to select an ISO which does not have user's permission. Including so, a message and an icon to show it.
peterpennings (1):
Disable ISOs templates with wrong permission
ui/css/kimchi.css | 11 +++++++++++
ui/css/src/modules/_templates.scss | 9 +++++++++
ui/js/src/kimchi.template_add_main.js | 12 +++++++++++-
ui/pages/template-add.html.tmpl | 3 ++-
4 files changed, 33 insertions(+), 2 deletions(-)
--
2.5.0
8 years, 4 months
[PATCHv2] [Kimchi] Add UI netboot support for adding templates; add loading icon when switching back to image src
by Socorro Stoppler
v2:
Add loading icon when switching back to image src radio button
per feedback from pvital
v1:
Add UI netboot support for adding templates
Signed-off-by: Socorro Stoppler <socorro(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.template_add_main.js | 74 ++++++++++++++++++++++++++++++++---
ui/pages/template-add.html.tmpl | 29 +++++++++-----
2 files changed, 89 insertions(+), 14 deletions(-)
diff --git a/ui/js/src/kimchi.template_add_main.js b/ui/js/src/kimchi.template_add_main.js
index 948f710..28057a7 100644
--- a/ui/js/src/kimchi.template_add_main.js
+++ b/ui/js/src/kimchi.template_add_main.js
@@ -17,6 +17,7 @@
*/
kimchi.template_add_main = function() {
"use strict";
+ var currentPage = 'iso-local-box';
$('#loading-isos').removeClass('hidden');
kimchi.deepScanHandler = null;
var isos = [];
@@ -53,6 +54,7 @@ kimchi.template_add_main = function() {
$('#local-iso-field').hide();
$('#select-all-local-iso').prop('checked', false);
$('#btn-template-local-iso-create').attr('disabled', 'disabled');
+ $('#btn-template-netboot-create').attr('disabled', 'disabled');
$('#iso-search').hide();
$('#iso-more').hide();
$('#iso-search-loading').hide();
@@ -64,6 +66,7 @@ kimchi.template_add_main = function() {
$('#iso-url').val(''); // 4 - Remote folder path text
$('#btn-template-file-create').attr('disabled', 'disabled').css('display', 'inline-block'); // 1 - Folder path
$('#btn-template-local-iso-create').attr('disabled', 'disabled').css('display', 'none'); // 2 - Selected ISOs
+ $('#btn-template-netboot-create').attr('disabled', 'disabled').css('display', 'none'); // 3 - Netboot
$('#select-all-local-iso, #select-all-remote-iso').prop('checked', false); // False to all select-all checkboxes
$('#list-local-iso [type="checkbox"], #list-remote-iso [type="checkbox"]').prop('checked', false); // False to all list checkboxes
};
@@ -98,6 +101,7 @@ kimchi.template_add_main = function() {
$('#iso-url').val('');
$('#btn-template-file-create').attr('disabled', 'disabled').css('display', 'inline-block');
$('#btn-template-local-iso-create').attr('disabled', 'disabled').css('display', 'none'); // 2 - Selected ISOs
+ $('#btn-template-netboot-create').attr('disabled', 'disabled').css('display', 'none'); // 3 - Netboot
$('#select-all-local-iso, #select-all-remote-iso').prop('checked', false); // False to all select-all checkboxes
$('#list-local-iso [type="checkbox"], #list-remote-iso [type="checkbox"]').prop('checked', false); // False to all list checkboxes
};
@@ -116,6 +120,7 @@ kimchi.template_add_main = function() {
} else {
$('#btn-template-file-create').attr('disabled', 'disabled');
}
+ $('#btn-template-netboot-create').attr('disabled', 'disabled').css('display', 'none'); // 3 - Netboot
});
initLocalIsoField();
@@ -222,12 +227,11 @@ kimchi.template_add_main = function() {
$('#iso-file').parent().removeClass('has-error');
$('#btn-template-file-create').attr('disabled', 'disabled').css('display', 'none'); // 1 - Folder path
-
$('#btn-template-local-iso-create').removeAttr('disabled').css('display', 'inline-block'); // 2 - Selected ISOs
-
} else {
$('#btn-template-local-iso-create').attr('disabled', 'disabled');
}
+ $('#btn-template-netboot-create').attr('disabled', 'disabled').css('display', 'none'); // 3 - Netboot
});
$('#list-local-iso').on('click', '[type="checkbox"]', function() {
@@ -238,6 +242,7 @@ kimchi.template_add_main = function() {
$('#btn-template-file-create').attr('disabled', 'disabled').css('display', 'none'); // 1 - Folder path
$('#btn-template-local-iso-create').attr('disabled', 'disabled').css('display', 'inline-block'); // 2 - Selected ISOs
+ $('#btn-template-netboot-create').attr('disabled', 'disabled').css('display', 'none'); // 3 - Netboot
if (checkedLength) {
$('#btn-template-local-iso-create').removeAttr('disabled');
@@ -250,6 +255,16 @@ kimchi.template_add_main = function() {
}
});
+ $('#btn-template-netboot-create').click(function() {
+ var data = {
+ "source_media": {"type": "netboot"}
+ };
+ addTemplate(data, function() {
+ $('#btn-template-netboot-create').text(i18n['KCHAPI6005M']);
+ $('#btn-template-netboot-create').prop('disabled', false);
+ });
+ });
+
$('#btn-template-local-iso-create').click(function() {
$('input', '#iso-file-box').prop('disabled', true);
$('#btn-template-local-iso-create').text(i18n['KCHAPI6008M']);
@@ -299,11 +314,9 @@ kimchi.template_add_main = function() {
$('#iso-url').val('');
$('#btn-template-file-create').attr('disabled', 'disabled').css('display', 'none'); // 1 - Folder path
-
$('#btn-template-local-iso-create').attr('disabled', 'disabled').css('display', 'none'); // 2 - Selected ISOs
-
+ $('#btn-template-netboot-create').attr('disabled', 'disabled').css('display', 'none'); // 3 - Netboot
$('#select-all-local-iso, #select-all-remote-iso').prop('checked', false); // False to all select-all checkboxes
-
$('#list-local-iso [type="checkbox"], #list-remote-iso [type="checkbox"]').prop('checked', false); // False to all list checkboxes
};
@@ -340,6 +353,57 @@ kimchi.template_add_main = function() {
$('input#iso-url').parent().toggleClass('has-error', !isValid);
}, 0);
});
+
+ $('#image-src').change(function() {
+ if (this.checked) {
+ if (currentPage === 'netboot-path') {
+ kimchi.switchPage(currentPage, 'iso-local-box', 'right');
+ }
+ currentPage = 'iso-local-box';
+ $('#template-add-window .modal-body .template-pager').animate({
+ height: "635px"
+ }, 400);
+ initLocalIsoField();
+ initIsoFileField();
+ $('#loading-isos').removeClass('hidden');
+ kimchi.listIsos(function(local_isos) { //local ISOs
+ kimchi.listDistros(function(remote_isos) { //remote ISOs
+
+ isos = local_isos.concat(remote_isos); //all isos
+ if (isos && isos.length) {
+ showLocalIsoField(isos);
+ $('#iso-more').show();
+ } else {
+ $('#iso-search').show();
+ }
+ $('#loading-isos').fadeOut(100, function() {});
+ });
+ }, function(err) {
+ wok.message.error(err.responseJSON.reason, '#local-iso-error-container');
+ $('#loading-isos').fadeOut(300, function() {
+ $('#loading-isos').addClass('hidden');
+ });
+ });
+ setupFilters();
+ enabledRemoteIso();
+ }
+ });
+
+ $('#netboot-src').change(function() {
+ if (this.checked) {
+ if (currentPage === 'iso-local-box') {
+ kimchi.switchPage(currentPage, 'netboot-path', 'left');
+ }
+ currentPage = 'netboot-path';
+ $('#template-add-window .modal-body .template-pager').animate({
+ height: "300px"
+ }, 400);
+ $('#btn-template-file-create').attr('disabled', 'disabled').css('display', 'none'); // 1 - Folder path
+ $('#btn-template-local-iso-create').attr('disabled', 'disabled').css('display', 'none'); // 2 - Selected ISOs
+ $('#btn-template-netboot-create').removeAttr('disabled').css('display', 'inline-block'); // 3 - Netboot
+ }
+ });
+
//do create
var addTemplate = function(data, callback) {
kimchi.createTemplate(data, function() {
diff --git a/ui/pages/template-add.html.tmpl b/ui/pages/template-add.html.tmpl
index 4226a8f..87d6cb4 100644
--- a/ui/pages/template-add.html.tmpl
+++ b/ui/pages/template-add.html.tmpl
@@ -30,11 +30,18 @@
<div class="modal-body">
<div class="template-modal-container">
<div id="alert-modal-container"></div>
+ <div>
+ <h5>$_("Where is the source media for this template? ")</h5>
+ <input type="radio" checked="checked" name="iso-source" id="image-src" value="image-src" class="wok-radio">
+ <label for="image-src">$_("Image Template")</label>
+ <input type="radio" name="iso-source" id="netboot-src" value="netboot-src" class="wok-radio">
+ <label for="netboot-src">$_("Netboot Template")</label>
+ </div>
</div>
<div class="template-pager">
<div class="page-list">
<div class="page" id="iso-local-box">
- <div id="loading-isos">
+ <div id="loading-isos hidden">
<div class="wok-mask-loader-container">
<div class="wok-mask-loading">
<div class="wok-mask-loading-icon"></div>
@@ -103,16 +110,20 @@
</div>
</div>
</div>
- </div>
- </div>
- <div class="modal-footer">
- <button class="btn btn-default" id="btn-template-file-create" disabled="disabled">$_("Create")</button>
- <button class="btn btn-default" id="btn-template-local-iso-create" disabled="disabled">$_("Create")</button>
- <button class="btn btn-default" data-dismiss="modal" type="button">$_("Cancel")</button>
- </div>
-</div>
+ <div class="page" id="netboot-path">
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button class="btn btn-default" id="btn-template-file-create" disabled="disabled">$_("Create")</button>
+ <button class="btn btn-default" id="btn-template-local-iso-create" disabled="disabled">$_("Create")</button>
+ <button class="btn btn-default" id="btn-template-netboot-create" disabled="disabled">$_("Create")</button>
+ <button class="btn btn-default" data-dismiss="modal" type="button">$_("Cancel")</button>
+ </div>
+ </div>
<script>
kimchi.template_add_main();
</script>
+</div>
</body>
</html>
--
2.5.0
8 years, 4 months
[PATCH] [Kimchi] Save last view for templates - fix for issue# 799
by Socorro Stoppler
This patch addresses github issue# 799. The last view of the Templates tab
is not being remembered either after switching tabs or exiting Kimchi. When
switching view from List to Gallery (or vice versa), the next time the
user goes back to the Templates tab, whatever view it was last on should
be what is shown when going back to the Templates tab. Thanks to samhenri
in helping resolve the last issue.
Signed-off-by: Socorro Stoppler <socorro(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.template_main.js | 63 +++++++++++++++++++++++++++++++++++----
1 file changed, 57 insertions(+), 6 deletions(-)
diff --git a/ui/js/src/kimchi.template_main.js b/ui/js/src/kimchi.template_main.js
index 22a3509..ed49246 100644
--- a/ui/js/src/kimchi.template_main.js
+++ b/ui/js/src/kimchi.template_main.js
@@ -30,7 +30,7 @@ kimchi.doListTemplates = function() {
}
listHtml += wok.substitute(templateHtml, value);
});
- $('.wok-vm-list').removeClass('hidden');
+ $('ul#templates-grid').removeClass('hidden');
$('#templates-container').removeClass('hidden');
$('#templateList').html(listHtml);
kimchi.templateBindClick();
@@ -39,7 +39,7 @@ kimchi.doListTemplates = function() {
} else {
$('#templateList').html('');
$('#noTemplates').show();
- $('.wok-vm-list').addClass('hidden');
+ $('ul#templates-grid').addClass('hidden');
$('#templates-container').addClass('hidden');
$('.wok-mask').fadeOut(300, function() {});
}
@@ -58,10 +58,47 @@ kimchi.doListTemplates = function() {
};
kimchi.toggleTemplatesGallery = function() {
- $(".wok-vm-list, .wok-vm-gallery").toggleClass("wok-vm-list wok-vm-gallery");
- $(".wok-list, .wok-gallery").toggleClass("wok-list wok-gallery");
- var text = $('#gallery-table-button span.text').text();
- $('#gallery-table-button span.text').text(text == i18n['KCHTMPL6005M'] ? i18n['KCHTMPL6004M'] : i18n['KCHTMPL6005M']);
+ $(".wok-vm-list, .wok-vm-gallery").toggleClass("wok-vm-list wok-vm-gallery");
+ $(".wok-list, .wok-gallery").toggleClass("wok-list wok-gallery");
+ var text = $('#gallery-table-button span.text').text();
+ $('#gallery-table-button span.text').text(text == i18n['KCHTMPL6005M'] ? i18n['KCHTMPL6004M'] : i18n['KCHTMPL6005M']);
+ var buttonText = $('#gallery-table-button span.text').text();
+ if (buttonText.indexOf("Gallery") !== -1) {
+ // Currently in list view
+ kimchi.setTemplateView("templateView", "list");
+ } else {
+ // Currently in gallery
+ kimchi.setTemplateView("templateView", "gallery");
+ }
+};
+
+kimchi.setTemplateView = function(name, value) {
+ window.localStorage.setItem(name, value);
+};
+
+kimchi.readTemplateView = function(name) {
+ var viewName = window.localStorage.getItem(name);
+ if (viewName !== "") {
+ return viewName;
+ } else {
+ return null;
+ }
+};
+
+kimchi.showTemplateGallery = function() {
+ $(".wok-vm-list").addClass("wok-vm-gallery");
+ $(".wok-list").addClass("wok-gallery");
+ $(".wok-vm-gallery").removeClass("wok-vm-list");
+ $(".wok-gallery").removeClass("wok-list");
+ $('#gallery-table-button span.text').text(i18n['KCHTMPL6004M']);
+};
+
+kimchi.showTemplateList = function() {
+ $(".wok-vm-gallery").addClass("wok-vm-list");
+ $(".wok-gallery").addClass("wok-list");
+ $(".wok-vm-list").removeClass("wok-vm-gallery");
+ $(".wok-list").removeClass("wok-gallery");
+ $('#gallery-table-button span.text').text(i18n['KCHTMPL6005M']);
};
kimchi.templateBindClick = function() {
@@ -117,6 +154,20 @@ kimchi.hideTitle = function() {
kimchi.template_main = function() {
$('body').addClass('wok-list');
+ var viewFound = kimchi.readTemplateView("templateView");
+ if (viewFound) {
+ if(viewFound === "gallery") {
+ // should be showing gallery
+ kimchi.showTemplateGallery();
+ } else {
+ // Should be showing list
+ kimchi.showTemplateList();
+ }
+ } else {
+ // Default to showing list
+ kimchi.showTemplateList();
+ }
+
if (wok.tabMode['templates'] === 'admin') {
$('.tools').attr('style', 'display');
$("#template-add").on("click", function(event) {
--
2.5.0
8 years, 4 months
[PATCH] [Kimchi] model/vms.py: changing all interfaces VM
by dhbarboza82@gmail.com
From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
This patch changes XPATH_DOMAIN_MAC and XPATH_DOMAIN_MAC_BY_ADDRESS
to include search and replace of all mac addresses, not
just those that belongs to type='network' interfaces.
Signed-off-by: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
---
model/vms.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/model/vms.py b/model/vms.py
index 7745027..6a309fc 100644
--- a/model/vms.py
+++ b/model/vms.py
@@ -86,9 +86,8 @@ VM_OFFLINE_UPDATE_PARAMS = ['cpu_info', 'graphics', 'groups', 'memory',
XPATH_DOMAIN_DISK = "/domain/devices/disk[@device='disk']/source/@file"
XPATH_DOMAIN_DISK_BY_FILE = "./devices/disk[@device='disk']/source[@file='%s']"
XPATH_DOMAIN_NAME = '/domain/name'
-XPATH_DOMAIN_MAC = "/domain/devices/interface[@type='network']/mac/@address"
-XPATH_DOMAIN_MAC_BY_ADDRESS = "./devices/interface[@type='network']/"\
- "mac[@address='%s']"
+XPATH_DOMAIN_MAC = "/domain/devices/interface/mac/@address"
+XPATH_DOMAIN_MAC_BY_ADDRESS = "./devices/interface/mac[@address='%s']"
XPATH_DOMAIN_MEMORY = '/domain/memory'
XPATH_DOMAIN_MEMORY_UNIT = '/domain/memory/@unit'
XPATH_DOMAIN_UUID = '/domain/uuid'
--
2.5.5
8 years, 4 months
[PATCH] [Kimchi] Github #972: spice-html5 dir incorrect
by dhbarboza82@gmail.com
From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
Before this patch, spice_dir was given by:
self.spice_dir = self.add_prefix('ui/spice-html5')
This results in the '/usr/share/wok/ui/spice-html5' dir when
installing Kimchi in an Opensuse Leap system, which is not
where the spice-html5 files are located. This is probably
a remnant of the Kimchi -> WoK transition.
This patch changes it to:
self.spice_dir = os.path.join(self.ui_dir, 'spice-html5')
That will give us '/usr/share/wok/plugins/kimchi/ui/spice-html5'
instead, making spice-html5 work as intended in Opensuse or
any other distro that requires the --with-spice-html5 flag
in autogen.sh.
Signed-off-by: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
---
config.py.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config.py.in b/config.py.in
index e645d5d..937f1ec 100644
--- a/config.py.in
+++ b/config.py.in
@@ -102,7 +102,7 @@ class KimchiPaths(PluginPaths):
'spice-html5/pages/spice_auto.html')
if __with_spice__ == 'yes':
- self.spice_dir = self.add_prefix('ui/spice-html5')
+ self.spice_dir = os.path.join(self.ui_dir, 'spice-html5')
elif os.path.exists('@datadir@/spice-html5'):
self.spice_dir = '@datadir@/spice-html5'
else:
--
2.5.5
8 years, 4 months