Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
Signed-off-by: Gustavo Y. Ribeiro <gyr(a)linux.vnet.ibm.com>
---
plugins/kimchi/API.json | 12 +-
plugins/kimchi/mockmodel.py | 8 +-
plugins/kimchi/model/debugreports.py | 7 +-
plugins/kimchi/model/host.py | 4 +-
plugins/kimchi/model/networks.py | 4 +-
plugins/kimchi/model/storagepools.py | 7 +-
plugins/kimchi/model/storagevolumes.py | 4 +-
plugins/kimchi/model/vms.py | 11 +-
plugins/kimchi/model/vmsnapshots.py | 4 +-
plugins/kimchi/osinfo.py | 14 +-
plugins/kimchi/screenshot.py | 2 +-
plugins/kimchi/tests/test_authorization.py | 56 ++--
plugins/kimchi/tests/test_exception.py | 12 +-
plugins/kimchi/tests/test_host.py | 47 ++-
plugins/kimchi/tests/test_mock_network.py | 2 +-
plugins/kimchi/tests/test_mock_storagepool.py | 10 +-
plugins/kimchi/tests/test_mock_storagevolume.py | 8 +-
plugins/kimchi/tests/test_mockmodel.py | 21 +-
plugins/kimchi/tests/test_model.py | 45 ++-
plugins/kimchi/tests/test_model_network.py | 14 +-
plugins/kimchi/tests/test_model_storagepool.py | 12 +-
plugins/kimchi/tests/test_model_storagevolume.py | 15 +-
plugins/kimchi/tests/test_rest.py | 454 ++++++++++----------
plugins/kimchi/tests/test_server.py | 34 +-
plugins/kimchi/tests/test_template.py | 76 ++--
plugins/kimchi/ui/css/theme-default/guest-edit.css | 6 +-
plugins/kimchi/ui/css/theme-default/host.css | 4 +-
plugins/kimchi/ui/css/theme-default/list.css | 2 +-
plugins/kimchi/ui/css/theme-default/network.css | 4 +-
.../kimchi/ui/css/theme-default/report-rename.css | 2 +-
plugins/kimchi/ui/css/theme-default/storage.css | 2 +-
.../kimchi/ui/css/theme-default/template_add.css | 6 +-
plugins/kimchi/ui/js/src/kimchi.api.js | 193 ++++-----
plugins/kimchi/ui/js/src/kimchi.guest_add_main.js | 2 +-
plugins/kimchi/ui/js/src/kimchi.guest_edit_main.js | 6 +-
plugins/kimchi/ui/js/src/kimchi.guest_main.js | 12 +-
.../kimchi/ui/js/src/kimchi.guest_media_main.js | 2 +-
plugins/kimchi/ui/js/src/kimchi.host.js | 14 +-
plugins/kimchi/ui/js/src/kimchi.storage_main.js | 6 +-
.../kimchi/ui/js/src/kimchi.template_edit_main.js | 2 +-
plugins/kimchi/ui/js/src/kimchi.template_main.js | 8 +-
plugins/kimchi/ui/pages/error.html.tmpl | 4 +-
plugins/kimchi/ui/pages/guest-add.html.tmpl | 2 +-
plugins/kimchi/ui/pages/guest.html.tmpl | 2 +-
plugins/kimchi/ui/pages/storagepool-add.html.tmpl | 2 +-
plugins/kimchi/ui/pages/tabs/storage.html.tmpl | 2 +-
plugins/kimchi/ui/pages/template-add.html.tmpl | 2 +-
plugins/sample/ui/js/util.js | 2 +-
ui/pages/error.html.tmpl | 4 +-
49 files changed, 605 insertions(+), 569 deletions(-)
diff --git a/plugins/kimchi/API.json b/plugins/kimchi/API.json
index e8da7d9..f1f58ff 100644
--- a/plugins/kimchi/API.json
+++ b/plugins/kimchi/API.json
@@ -257,14 +257,14 @@
"template": {
"description": "The URI of a template to use when
building a VM",
"type": "string",
- "pattern": "^/templates/(.*?)/?$",
+ "pattern":
"^/plugins/kimchi/templates/(.*?)/?$",
"required": true,
"error": "KCHVM0012E"
},
"storagepool": {
"description": "Assign a specefic Storage Pool to the
new VM",
"type": "string",
- "pattern": "^/storagepools/[^/]+/?$",
+ "pattern":
"^/plugins/kimchi/storagepools/[^/]+/?$",
"error": "KCHVM0013E"
},
"graphics": { "$ref":
"#/kimchitype/graphics" }
@@ -428,7 +428,7 @@
"icon": {
"description": "The template icon path",
"type": "string",
- "pattern": "^images/",
+ "pattern": "^/plugins/kimchi/images/",
"error": "KCHTMPL0009E"
},
"os_distro": {
@@ -493,7 +493,7 @@
"storagepool": {
"description": "Location of the storage pool",
"type": "string",
- "pattern": "^/storagepools/[^/]+/?$",
+ "pattern":
"^/plugins/kimchi/storagepools/[^/]+/?$",
"error": "KCHTMPL0015E"
},
"networks": {
@@ -600,7 +600,7 @@
"icon": {
"description": "The template icon path",
"type": "string",
- "pattern": "^images/",
+ "pattern": "^/plugins/kimchi/images/",
"error": "KCHTMPL0009E"
},
"os_distro": {
@@ -664,7 +664,7 @@
"storagepool": {
"description": "Location of the storage pool",
"type": "string",
- "pattern": "^/storagepools/[^/]+/?$",
+ "pattern":
"^/plugins/kimchi/storagepools/[^/]+/?$",
"error": "KCHTMPL0015E"
},
"networks": {
diff --git a/plugins/kimchi/mockmodel.py b/plugins/kimchi/mockmodel.py
index 88eb033..d51ab9e 100644
--- a/plugins/kimchi/mockmodel.py
+++ b/plugins/kimchi/mockmodel.py
@@ -49,7 +49,7 @@ from wok.xmlutils.utils import xml_item_update
fake_user = {'root': 'letmein!'}
-mockmodel_defaults = {'storagepool': '/storagepools/default-pool',
+mockmodel_defaults = {'storagepool':
'/plugins/kimchi/storagepools/default-pool',
'domain': 'test', 'arch': 'i686'}
@@ -246,7 +246,7 @@ class MockModel(Model):
return MockModel._libvirt_get_vol_path(pool, vol)
def _gen_debugreport_file(self, name):
- return add_task('/debugreports/%s' % name, self._create_log,
+ return add_task('/plugins/kimchi/debugreports/%s' % name,
self._create_log,
self.objstore, name)
def _create_log(self, cb, name):
@@ -355,7 +355,7 @@ class MockModel(Model):
return self._mock_swupdate.pkgs[pkg_name]
def _mock_host_swupdate(self, args=None):
- task_id = add_task('/host/swupdate', self._mock_swupdate.doUpdate,
+ task_id = add_task('/plugins/kimchi/host/swupdate',
self._mock_swupdate.doUpdate,
self.objstore)
return self.task_lookup(task_id)
@@ -407,7 +407,7 @@ class MockModel(Model):
def _mock_vmsnapshots_create(self, vm_name, params):
name = params.get('name', unicode(int(time.time())))
params = {'vm_name': vm_name, 'name': name}
- taskid = add_task(u'/vms/%s/snapshots/%s' % (vm_name, name),
+ taskid = add_task(u'/plugins/kimchi/vms/%s/snapshots/%s' % (vm_name,
name),
self._vmsnapshots_create_task, self.objstore, params)
return self.task_lookup(taskid)
diff --git a/plugins/kimchi/model/debugreports.py b/plugins/kimchi/model/debugreports.py
index ea5853d..aff2152 100644
--- a/plugins/kimchi/model/debugreports.py
+++ b/plugins/kimchi/model/debugreports.py
@@ -62,8 +62,8 @@ class DebugReportsModel(object):
gen_cmd = self.get_system_report_tool()
if gen_cmd is not None:
- return add_task('/debugreports/%s' % name, gen_cmd, self.objstore,
- name)
+ return add_task('/plugins/kimchi/debugreports/%s' % name, gen_cmd,
+ self.objstore, name)
raise OperationFailed("KCHDR0002E")
@@ -172,7 +172,8 @@ class DebugReportModel(object):
ctime = os.stat(file_target).st_mtime
ctime = time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime(ctime))
file_target = os.path.split(file_target)[-1]
- file_target = os.path.join("/data/debugreports", file_target)
+ file_target = os.path.join("plugins/kimchi/data/debugreports",
+ file_target)
return {'uri': file_target,
'ctime': ctime}
diff --git a/plugins/kimchi/model/host.py b/plugins/kimchi/model/host.py
index 2a78a88..09b0a09 100644
--- a/plugins/kimchi/model/host.py
+++ b/plugins/kimchi/model/host.py
@@ -132,8 +132,8 @@ class HostModel(object):
raise OperationFailed('KCHPKGUPD0001E')
wok_log.debug('Host is going to be updated.')
- taskid = add_task('/host/swupdate', swupdate.doUpdate, self.objstore,
- None)
+ taskid = add_task('/plugins/kimchi/host/swupdate', swupdate.doUpdate,
+ self.objstore, None)
return self.task.lookup(taskid)
def shutdown(self, args=None):
diff --git a/plugins/kimchi/model/networks.py b/plugins/kimchi/model/networks.py
index 594bfca..3723e4c 100644
--- a/plugins/kimchi/model/networks.py
+++ b/plugins/kimchi/model/networks.py
@@ -27,7 +27,7 @@ from xml.sax.saxutils import escape
from wok import netinfo
from wok import network as knetwork
-from wok.config import paths
+from wok.config import PluginPaths
from wok.exception import InvalidOperation, InvalidParameter
from wok.exception import MissingParameter, NotFoundError, OperationFailed
from ..osinfo import defaults as tmpl_defaults
@@ -52,7 +52,7 @@ class NetworksModel(object):
conn = self.conn.get()
error_msg = ("Please, check the configuration in %s/template.conf to "
- "ensure it lists only valid networks." % paths.conf_dir)
+ "ensure it lists only valid networks." %
PluginPaths('kimchi').conf_dir)
for net_name in networks:
try:
diff --git a/plugins/kimchi/model/storagepools.py b/plugins/kimchi/model/storagepools.py
index 2514ce4..51269da 100644
--- a/plugins/kimchi/model/storagepools.py
+++ b/plugins/kimchi/model/storagepools.py
@@ -23,7 +23,7 @@ import sys
from lxml.builder import E
-from wok.config import config, paths
+from wok.config import config, PluginPaths
from ..scan import Scanner
from wok.exception import InvalidOperation, MissingParameter
from wok.exception import NotFoundError, OperationFailed
@@ -82,7 +82,8 @@ class StoragePoolsModel(object):
pools['ISO'] = {'path': '/var/lib/kimchi/isos'}
error_msg = ("Please, check the configuration in %s/template.conf to "
- "ensure it has a valid storage pool." % paths.conf_dir)
+ "ensure it has a valid storage pool." %
+ PluginPaths('kimchi').conf_dir)
conn = self.conn.get()
for pool_name in pools:
@@ -232,7 +233,7 @@ class StoragePoolsModel(object):
params['path'] = self.scanner.scan_dir_prepare(params['name'])
scan_params['pool_path'] = params['path']
- task_id = add_task('/storagepools/%s' % ISO_POOL_NAME,
+ task_id = add_task('/plugins/kimchi/storagepools/%s' % ISO_POOL_NAME,
self.scanner.start_scan, self.objstore, scan_params)
# Record scanning-task/storagepool mapping for future querying
try:
diff --git a/plugins/kimchi/model/storagevolumes.py
b/plugins/kimchi/model/storagevolumes.py
index 908fbc4..6bc203a 100644
--- a/plugins/kimchi/model/storagevolumes.py
+++ b/plugins/kimchi/model/storagevolumes.py
@@ -114,7 +114,7 @@ class StorageVolumesModel(object):
raise InvalidParameter('KCHVOL0001E', {'name': name})
params['pool'] = pool_name
- targeturi = '/storagepools/%s/storagevolumes/%s' % (pool_name, name)
+ targeturi = '/plugins/kimchi/storagepools/%s/storagevolumes/%s' %
(pool_name, name)
taskid = add_task(targeturi, create_func, self.objstore, params)
return self.task.lookup(taskid)
@@ -403,7 +403,7 @@ class StorageVolumeModel(object):
'name': name,
'new_pool': new_pool,
'new_name': new_name}
- taskid = add_task(u'/storagepools/%s/storagevolumes/%s' %
+ taskid = add_task(u'/plugins/kimchi/storagepools/%s/storagevolumes/%s' %
(pool, new_name), self._clone_task, self.objstore,
params)
return self.task.lookup(taskid)
diff --git a/plugins/kimchi/model/vms.py b/plugins/kimchi/model/vms.py
index 2e9721d..96e5084 100644
--- a/plugins/kimchi/model/vms.py
+++ b/plugins/kimchi/model/vms.py
@@ -107,7 +107,7 @@ class VMsModel(object):
t.validate()
data = {'name': name, 'template': t,
'graphics': params.get('graphics', {})}
- taskid = add_task(u'/vms/%s' % name, self._create_task,
+ taskid = add_task(u'/plugins/kimchi/vms/%s' % name, self._create_task,
self.objstore, data)
return self.task.lookup(taskid)
@@ -245,16 +245,17 @@ class VMModel(object):
task_names = session.get_list('task')
for tn in task_names:
t = session.get('task', tn)
- if t['target_uri'].startswith('/vms/'):
- uri_name = t['target_uri'][5:] # 5 = len('/vms/')
+ if t['target_uri'].startswith('/plugins/kimchi/vms/'):
+ uri_name =
t['target_uri'].lstrip('/plugins/kimchi/vms/')
vms_being_created.append(uri_name)
current_vm_names = self.vms.get_list() + vms_being_created
new_name = get_next_clone_name(current_vm_names, name)
# create a task with the actual clone function
- taskid = add_task(u'/vms/%s/clone' % new_name, self._clone_task,
- self.objstore, {'name': name, 'new_name':
new_name})
+ taskid = add_task(u'/plugins/kimchi/vms/%s/clone' % new_name,
+ self._clone_task, self.objstore,
+ {'name': name, 'new_name': new_name})
return self.task.lookup(taskid)
diff --git a/plugins/kimchi/model/vmsnapshots.py b/plugins/kimchi/model/vmsnapshots.py
index 60de253..0724adc 100644
--- a/plugins/kimchi/model/vmsnapshots.py
+++ b/plugins/kimchi/model/vmsnapshots.py
@@ -72,8 +72,8 @@ class VMSnapshotsModel(object):
name = params.get('name', unicode(int(time.time())))
task_params = {'vm_name': vm_name, 'name': name}
- taskid = add_task(u'/vms/%s/snapshots/%s' % (vm_name, name),
- self._create_task, self.objstore, task_params)
+ taskid = add_task(u'/plugins/kimchi/vms/%s/snapshots/%s' % (vm_name,
+ name), self._create_task, self.objstore, task_params)
return self.task.lookup(taskid)
def _create_task(self, cb, params):
diff --git a/plugins/kimchi/osinfo.py b/plugins/kimchi/osinfo.py
index d2aab71..5fe1e07 100644
--- a/plugins/kimchi/osinfo.py
+++ b/plugins/kimchi/osinfo.py
@@ -26,7 +26,7 @@ from collections import defaultdict
from configobj import ConfigObj
from distutils.version import LooseVersion
-from wok.config import paths
+from wok.config import PluginPaths
SUPPORTED_ARCHS = {'x86': ('i386', 'i686', 'x86_64'),
@@ -86,7 +86,7 @@ modern_version_bases = {'x86': {'debian': '6.0',
'ubuntu': '7.10',
icon_available_distros = [icon[5:-4] for icon in glob.glob1('%s/images/'
- % paths.ui_dir, 'icon-*.png')]
+ % PluginPaths('kimchi').ui_dir, 'icon-*.png')]
def _get_tmpl_defaults():
@@ -116,7 +116,7 @@ def _get_tmpl_defaults():
default_config = ConfigObj(tmpl_defaults)
# Load template configuration file
- config_file = os.path.join(paths.conf_dir, 'template.conf')
+ config_file = os.path.join(PluginPaths('kimchi').conf_dir,
'template.conf')
config = ConfigObj(config_file)
# Merge default configuration with file configuration
@@ -133,7 +133,8 @@ def _get_tmpl_defaults():
# Parse storage section to get storage pool and disks values
storage_section = default_config.pop('storage')
- defaults['storagepool'] = '/storagepools/' +
storage_section.pop('pool')
+ defaults['storagepool'] = '/plugins/kimchi/storagepools/' + \
+ storage_section.pop('pool')
defaults['disks'] = []
for disk in storage_section.keys():
data = storage_section[disk]
@@ -206,8 +207,9 @@ def lookup(distro, version):
params.update(custom_specs.get(distro, {}).get(version, {}))
if distro in icon_available_distros:
- params['icon'] = 'images/icon-%s.png' % distro
+ params['icon'] = 'plugins/kimchi/images/icon-%s.png' % distro
else:
- params['icon'] = 'images/icon-vm.png'
+ params['icon'] = 'plugins/kimchi/images/icon-vm.png'
+
return params
diff --git a/plugins/kimchi/screenshot.py b/plugins/kimchi/screenshot.py
index 05701dd..1cac964 100644
--- a/plugins/kimchi/screenshot.py
+++ b/plugins/kimchi/screenshot.py
@@ -68,7 +68,7 @@ class VMScreenshot(object):
if now - last_update > self.OUTDATED_SECS:
self._clean_extra(self.LIVE_WINDOW)
self._generate_thumbnail()
- return '/data/screenshots/%s' %\
+ return 'plugins/kimchi/data/screenshots/%s' %\
os.path.basename(self.info['thumbnail'])
def _clean_extra(self, window=-1):
diff --git a/plugins/kimchi/tests/test_authorization.py
b/plugins/kimchi/tests/test_authorization.py
index 6513b67..695b512 100644
--- a/plugins/kimchi/tests/test_authorization.py
+++ b/plugins/kimchi/tests/test_authorization.py
@@ -64,62 +64,62 @@ class AuthorizationTests(unittest.TestCase):
def test_nonroot_access(self):
# Non-root users can access static host information
- resp = self.request('/host', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/host', '{}', 'GET')
self.assertEquals(403, resp.status)
# Non-root users can access host stats
- resp = self.request('/host/stats', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/host/stats', '{}',
'GET')
self.assertEquals(403, resp.status)
# Non-root users can not reboot/shutdown host system
- resp = self.request('/host/reboot', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/host/reboot', '{}',
'POST')
self.assertEquals(403, resp.status)
- resp = self.request('/host/shutdown', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/host/shutdown', '{}',
'POST')
self.assertEquals(403, resp.status)
# Non-root users can not get or debug reports
- resp = self.request('/debugreports', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/debugreports', '{}',
'GET')
self.assertEquals(403, resp.status)
- resp = self.request('/debugreports', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/debugreports', '{}',
'POST')
self.assertEquals(403, resp.status)
# Non-root users can not create or delete network (only get)
- resp = self.request('/networks', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/networks', '{}',
'GET')
self.assertEquals(200, resp.status)
- resp = self.request('/networks', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/networks', '{}',
'POST')
self.assertEquals(403, resp.status)
- resp = self.request('/networks/default/activate', '{}',
'POST')
+ resp = self.request('/plugins/kimchi/networks/default/activate',
'{}', 'POST')
self.assertEquals(403, resp.status)
- resp = self.request('/networks/default', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/networks/default', '{}',
'DELETE')
self.assertEquals(403, resp.status)
# Non-root users can not create or delete storage pool (only get)
- resp = self.request('/storagepools', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/storagepools', '{}',
'GET')
self.assertEquals(200, resp.status)
- resp = self.request('/storagepools', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/storagepools', '{}',
'POST')
self.assertEquals(403, resp.status)
- resp = self.request('/storagepools/default/activate', '{}',
'POST')
+ resp = self.request('/plugins/kimchi/storagepools/default/activate',
'{}', 'POST')
self.assertEquals(403, resp.status)
- resp = self.request('/storagepools/default', '{}',
'DELETE')
+ resp = self.request('/plugins/kimchi/storagepools/default', '{}',
'DELETE')
self.assertEquals(403, resp.status)
# Non-root users can not update or delete a template
# but he can get and create a new one
- resp = self.request('/templates', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/templates', '{}',
'GET')
self.assertEquals(403, resp.status)
req = json.dumps({'name': 'test', 'cdrom': fake_iso})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(403, resp.status)
- resp = self.request('/templates/test', '{}', 'PUT')
+ resp = self.request('/plugins/kimchi/templates/test', '{}',
'PUT')
self.assertEquals(403, resp.status)
- resp = self.request('/templates/test', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/templates/test', '{}',
'DELETE')
self.assertEquals(403, resp.status)
# Non-root users can only get vms authorized to them
model.templates_create({'name': u'test', 'cdrom':
fake_iso})
task_info = model.vms_create({'name': u'test-me',
- 'template': '/templates/test'})
+ 'template':
'/plugins/kimchi/templates/test'})
wait_task(model.task_lookup, task_info['id'])
model.vm_update(u'test-me',
@@ -127,39 +127,39 @@ class AuthorizationTests(unittest.TestCase):
'groups': []})
task_info = model.vms_create({'name': u'test-usera',
- 'template': '/templates/test'})
+ 'template':
'/plugins/kimchi/templates/test'})
wait_task(model.task_lookup, task_info['id'])
non_root = list(set(model.users_get_list()) - set(['root']))[0]
model.vm_update(u'test-usera', {'users': [non_root],
'groups': []})
task_info = model.vms_create({'name': u'test-groupa',
- 'template': '/templates/test'})
+ 'template':
'/plugins/kimchi/templates/test'})
wait_task(model.task_lookup, task_info['id'])
a_group = model.groups_get_list()[0]
model.vm_update(u'test-groupa', {'groups': [a_group]})
- resp = self.request('/vms', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/vms', '{}', 'GET')
self.assertEquals(200, resp.status)
vms_data = json.loads(resp.read())
self.assertEquals([u'test-groupa', u'test-me'],
sorted([v['name'] for v in vms_data]))
- resp = self.request('/vms', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(403, resp.status)
# Create a vm using mockmodel directly to test Resource access
task_info = model.vms_create({'name': 'kimchi-test',
- 'template': '/templates/test'})
+ 'template':
'/plugins/kimchi/templates/test'})
wait_task(model.task_lookup, task_info['id'])
- resp = self.request('/vms/kimchi-test', '{}', 'PUT')
+ resp = self.request('/plugins/kimchi/vms/kimchi-test', '{}',
'PUT')
self.assertEquals(403, resp.status)
- resp = self.request('/vms/kimchi-test', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/vms/kimchi-test', '{}',
'DELETE')
self.assertEquals(403, resp.status)
# Non-root users can only update VMs authorized by them
- resp = self.request('/vms/test-me/start', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-me/start', '{}',
'POST')
self.assertEquals(200, resp.status)
- resp = self.request('/vms/test-usera/start', '{}',
'POST')
+ resp = self.request('/plugins/kimchi/vms/test-usera/start', '{}',
'POST')
self.assertEquals(403, resp.status)
model.template_delete('test')
diff --git a/plugins/kimchi/tests/test_exception.py
b/plugins/kimchi/tests/test_exception.py
index 834a275..32b6baf 100644
--- a/plugins/kimchi/tests/test_exception.py
+++ b/plugins/kimchi/tests/test_exception.py
@@ -57,7 +57,7 @@ class ExceptionTests(unittest.TestCase):
"""
setup_server('production')
# test 404
- resp = json.loads(request(host, ssl_port, '/vms/blah').read())
+ resp = json.loads(request(host, ssl_port,
'/plugins/kimchi/vms/blah').read())
self.assertEquals('404 Not Found', resp.get('code'))
# test 405 wrong method
@@ -67,7 +67,7 @@ class ExceptionTests(unittest.TestCase):
self.assertEquals(msg, resp.get('reason'))
# test 400 parse error
- resp = json.loads(request(host, ssl_port, '/vms', '{',
'POST').read())
+ resp = json.loads(request(host, ssl_port, '/plugins/kimchi/vms',
'{', 'POST').read())
msg = u'KCHAPI0006E: Unable to parse JSON request'
self.assertEquals('400 Bad Request', resp.get('code'))
self.assertEquals(msg, resp.get('reason'))
@@ -75,7 +75,7 @@ class ExceptionTests(unittest.TestCase):
# test 400 missing required parameter
req = json.dumps({})
- resp = json.loads(request(host, ssl_port, '/vms', req,
'POST').read())
+ resp = json.loads(request(host, ssl_port, '/plugins/kimchi/vms', req,
'POST').read())
self.assertEquals('400 Bad Request', resp.get('code'))
m = u"KCHVM0016E: Specify a template to create a virtual machine from"
self.assertEquals(m, resp.get('reason'))
@@ -87,7 +87,7 @@ class ExceptionTests(unittest.TestCase):
"""
setup_server()
# test 404
- resp = json.loads(request(host, ssl_port, '/vms/blah').read())
+ resp = json.loads(request(host, ssl_port,
'/plugins/kimchi/vms/blah').read())
self.assertEquals('404 Not Found', resp.get('code'))
# test 405 wrong method
@@ -97,7 +97,7 @@ class ExceptionTests(unittest.TestCase):
self.assertEquals(msg, resp.get('reason'))
# test 400 parse error
- resp = json.loads(request(host, ssl_port, '/vms', '{',
'POST').read())
+ resp = json.loads(request(host, ssl_port, '/plugins/kimchi/vms',
'{', 'POST').read())
msg = u'KCHAPI0006E: Unable to parse JSON request'
self.assertEquals('400 Bad Request', resp.get('code'))
self.assertEquals(msg, resp.get('reason'))
@@ -105,7 +105,7 @@ class ExceptionTests(unittest.TestCase):
# test 400 missing required parameter
req = json.dumps({})
- resp = json.loads(request(host, ssl_port, '/vms', req,
'POST').read())
+ resp = json.loads(request(host, ssl_port, '/plugins/kimchi/vms', req,
'POST').read())
m = u"KCHVM0016E: Specify a template to create a virtual machine from"
self.assertEquals('400 Bad Request', resp.get('code'))
self.assertEquals(m, resp.get('reason'))
diff --git a/plugins/kimchi/tests/test_host.py b/plugins/kimchi/tests/test_host.py
index 7770148..5a18490 100644
--- a/plugins/kimchi/tests/test_host.py
+++ b/plugins/kimchi/tests/test_host.py
@@ -62,7 +62,7 @@ class HostTests(unittest.TestCase):
self.request = partial(request, host, ssl_port)
def test_hostinfo(self):
- resp = self.request('/host').read()
+ resp = self.request('/plugins/kimchi/host').read()
info = json.loads(resp)
keys = ['os_distro', 'os_version', 'os_codename',
'cpu_model',
'memory', 'cpus']
@@ -78,7 +78,7 @@ class HostTests(unittest.TestCase):
time.sleep(1)
stats_keys = ['cpu_utilization', 'memory',
'disk_read_rate',
'disk_write_rate', 'net_recv_rate',
'net_sent_rate']
- resp = self.request('/host/stats').read()
+ resp = self.request('/plugins/kimchi/host/stats').read()
stats = json.loads(resp)
self.assertEquals(sorted(stats_keys), sorted(stats.keys()))
@@ -94,41 +94,43 @@ class HostTests(unittest.TestCase):
self.assertIn('buffers', memory_stats)
self.assertIn('avail', memory_stats)
- resp = self.request('/host/stats/history').read()
+ resp = self.request('/plugins/kimchi/host/stats/history').read()
history = json.loads(resp)
self.assertEquals(sorted(stats_keys), sorted(history.keys()))
def test_host_actions(self):
def _task_lookup(taskid):
- return json.loads(self.request('/tasks/%s' % taskid).read())
+ return json.loads(self.request('/plugins/kimchi/tasks/%s' %
+ taskid).read())
- resp = self.request('/host/shutdown', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/host/shutdown', '{}',
'POST')
self.assertEquals(200, resp.status)
- resp = self.request('/host/reboot', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/host/reboot', '{}',
'POST')
self.assertEquals(200, resp.status)
# Test system update
- resp = self.request('/host/packagesupdate', None, 'GET')
+ resp = self.request('/plugins/kimchi/host/packagesupdate', None,
'GET')
pkgs = json.loads(resp.read())
self.assertEquals(3, len(pkgs))
pkg_keys = ['package_name', 'repository', 'arch',
'version']
for p in pkgs:
name = p['package_name']
- resp = self.request('/host/packagesupdate/' + name, None,
'GET')
+ resp = self.request('/plugins/kimchi/host/packagesupdate/' + name,
+ None, 'GET')
info = json.loads(resp.read())
self.assertEquals(sorted(pkg_keys), sorted(info.keys()))
- resp = self.request('/host/swupdate', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/host/swupdate', '{}',
'POST')
task = json.loads(resp.read())
task_params = [u'id', u'message', u'status',
u'target_uri']
self.assertEquals(sorted(task_params), sorted(task.keys()))
- resp = self.request('/tasks/' + task[u'id'], None,
'GET')
+ resp = self.request('/plugins/kimchi/tasks/' + task[u'id'], None,
'GET')
task_info = json.loads(resp.read())
self.assertEquals(task_info['status'], 'running')
wait_task(_task_lookup, task_info['id'])
- resp = self.request('/tasks/' + task[u'id'], None,
'GET')
+ resp = self.request('/plugins/kimchi/tasks/' + task[u'id'], None,
'GET')
task_info = json.loads(resp.read())
self.assertEquals(task_info['status'], 'finished')
self.assertIn(u'All packages updated', task_info['message'])
@@ -136,14 +138,15 @@ class HostTests(unittest.TestCase):
self.assertEquals(0, len(pkgs))
def test_host_partitions(self):
- resp = self.request('/host/partitions')
+ resp = self.request('/plugins/kimchi/host/partitions')
self.assertEquals(200, resp.status)
partitions = json.loads(resp.read())
keys = ['name', 'path', 'type', 'fstype',
'size', 'mountpoint',
'available']
for item in partitions:
- resp = self.request('/host/partitions/%s' % item['name'])
+ resp = self.request('/plugins/kimchi/host/partitions/%s' %
+ item['name'])
info = json.loads(resp.read())
self.assertEquals(sorted(info.keys()), sorted(keys))
@@ -152,33 +155,36 @@ class HostTests(unittest.TestCase):
for dev in devices:
self.assertEquals(dev['device_type'], dev_type)
- resp = self.request('/host/devices?_cap=scsi_host')
+ resp = self.request('/plugins/kimchi/host/devices?_cap=scsi_host')
nodedevs = json.loads(resp.read())
# Mockmodel brings 3 preconfigured scsi fc_host
self.assertEquals(3, len(nodedevs))
- nodedev = json.loads(self.request('/host/devices/scsi_host2').read())
+ nodedev = json.loads(self.request(
+ '/plugins/kimchi/host/devices/scsi_host2').read())
# Mockmodel generates random wwpn and wwnn
self.assertEquals('scsi_host2', nodedev['name'])
self.assertEquals('fc_host', nodedev['adapter']['type'])
self.assertEquals(16, len(nodedev['adapter']['wwpn']))
self.assertEquals(16, len(nodedev['adapter']['wwnn']))
- devs = json.loads(self.request('/host/devices').read())
+ devs = json.loads(self.request('/plugins/kimchi/host/devices').read())
dev_names = [dev['name'] for dev in devs]
for dev_type in ('pci', 'usb_device', 'scsi'):
- resp = self.request('/host/devices?_cap=%s' % dev_type)
+ resp = self.request('/plugins/kimchi/host/devices?_cap=%s' %
+ dev_type)
devsByType = json.loads(resp.read())
names = [dev['name'] for dev in devsByType]
self.assertTrue(set(names) <= set(dev_names))
asset_devices_type(devsByType, dev_type)
- resp = self.request('/host/devices?_passthrough=true')
+ resp = self.request('/plugins/kimchi/host/devices?_passthrough=true')
passthru_devs = [dev['name'] for dev in json.loads(resp.read())]
self.assertTrue(set(passthru_devs) <= set(dev_names))
for dev_type in ('pci', 'usb_device', 'scsi'):
- resp = self.request('/host/devices?_cap=%s&_passthrough=true' %
+ resp = self.request(
+ '/plugins/kimchi/host/devices?_cap=%s&_passthrough=true'
%
dev_type)
filteredDevs = json.loads(resp.read())
filteredNames = [dev['name'] for dev in filteredDevs]
@@ -186,7 +192,8 @@ class HostTests(unittest.TestCase):
asset_devices_type(filteredDevs, dev_type)
for dev in passthru_devs:
- resp = self.request('/host/devices?_passthrough_affected_by=%s' %
+ resp = self.request(
+ '/plugins/kimchi/host/devices?_passthrough_affected_by=%s' %
dev)
affected_devs = [dev['name'] for dev in json.loads(resp.read())]
self.assertTrue(set(affected_devs) <= set(dev_names))
diff --git a/plugins/kimchi/tests/test_mock_network.py
b/plugins/kimchi/tests/test_mock_network.py
index 4e390b1..749b9c3 100644
--- a/plugins/kimchi/tests/test_mock_network.py
+++ b/plugins/kimchi/tests/test_mock_network.py
@@ -63,7 +63,7 @@ class MockNetworkTests(unittest.TestCase):
def test_vlan_tag_bridge(self):
# Verify the current system has at least one interface to create a
# bridged network
- interfaces = json.loads(self.request('/interfaces?type=nic').read())
+ interfaces =
json.loads(self.request('/plugins/kimchi/interfaces?type=nic').read())
if len(interfaces) > 0:
iface = interfaces[0]['name']
_do_network_test(self, model, {'name': u'bridge-network',
diff --git a/plugins/kimchi/tests/test_mock_storagepool.py
b/plugins/kimchi/tests/test_mock_storagepool.py
index c72708b..b96d72d 100644
--- a/plugins/kimchi/tests/test_mock_storagepool.py
+++ b/plugins/kimchi/tests/test_mock_storagepool.py
@@ -60,15 +60,15 @@ class MockStoragepoolTests(unittest.TestCase):
model.reset()
def _task_lookup(self, taskid):
- return json.loads(self.request('/tasks/%s' % taskid).read())
+ return json.loads(self.request('/plugins/kimchi/tasks/%s' %
taskid).read())
def test_storagepool(self):
# MockModel always returns 2 partitions (vdx, vdz)
- partitions = json.loads(self.request('/host/partitions').read())
+ partitions =
json.loads(self.request('/plugins/kimchi/host/partitions').read())
devs = [dev['path'] for dev in partitions]
# MockModel always returns 3 FC devices
- fc_devs = json.loads(self.request('/host/devices?_cap=fc_host').read())
+ fc_devs =
json.loads(self.request('/plugins/kimchi/host/devices?_cap=fc_host').read())
fc_devs = [dev['name'] for dev in fc_devs]
poolDefs = [
@@ -87,10 +87,10 @@ class MockStoragepoolTests(unittest.TestCase):
def _do_test(params):
name = params['name']
- uri = '/storagepools/%s' % name.encode('utf-8')
+ uri = '/plugins/kimchi/storagepools/%s' %
name.encode('utf-8')
req = json.dumps(params)
- resp = self.request('/storagepools', req, 'POST')
+ resp = self.request('/plugins/kimchi/storagepools', req,
'POST')
self.assertEquals(201, resp.status)
# activate the storage pool
diff --git a/plugins/kimchi/tests/test_mock_storagevolume.py
b/plugins/kimchi/tests/test_mock_storagevolume.py
index 3dd16b7..0065305 100644
--- a/plugins/kimchi/tests/test_mock_storagevolume.py
+++ b/plugins/kimchi/tests/test_mock_storagevolume.py
@@ -61,11 +61,11 @@ class MockStorageVolumeTests(unittest.TestCase):
def test_storagevolume(self):
# MockModel always returns 2 partitions (vdx, vdz)
- partitions = json.loads(self.request('/host/partitions').read())
+ partitions =
json.loads(self.request('/plugins/kimchi/host/partitions').read())
devs = [dev['path'] for dev in partitions]
# MockModel always returns 3 FC devices
- fc_devs = json.loads(self.request('/host/devices?_cap=fc_host').read())
+ fc_devs =
json.loads(self.request('/plugins/kimchi/host/devices?_cap=fc_host').read())
fc_devs = [dev['name'] for dev in fc_devs]
poolDefs = [
@@ -84,9 +84,9 @@ class MockStorageVolumeTests(unittest.TestCase):
for pool in poolDefs:
pool_name = pool['name']
- uri = '/storagepools/%s' % pool_name.encode('utf-8')
+ uri = '/plugins/kimchi/storagepools/%s' %
pool_name.encode('utf-8')
req = json.dumps(pool)
- resp = self.request('/storagepools', req, 'POST')
+ resp = self.request('/plugins/kimchi/storagepools', req,
'POST')
self.assertEquals(201, resp.status)
# activate the storage pool
resp = self.request(uri + '/activate', '{}', 'POST')
diff --git a/plugins/kimchi/tests/test_mockmodel.py
b/plugins/kimchi/tests/test_mockmodel.py
index 03ad445..133a61e 100644
--- a/plugins/kimchi/tests/test_mockmodel.py
+++ b/plugins/kimchi/tests/test_mockmodel.py
@@ -64,18 +64,18 @@ class MockModelTests(unittest.TestCase):
def test_screenshot_refresh(self):
# Create a VM
req = json.dumps({'name': 'test', 'cdrom': fake_iso})
- request(host, ssl_port, '/templates', req, 'POST')
+ request(host, ssl_port, '/plugins/kimchi/templates', req,
'POST')
req = json.dumps({'name': 'test-vm', 'template':
'/templates/test'})
- resp = request(host, ssl_port, '/vms', req, 'POST')
+ resp = request(host, ssl_port, '/plugins/kimchi/vms', req,
'POST')
task = json.loads(resp.read())
wait_task(model.task_lookup, task['id'])
# Test screenshot refresh for running vm
- request(host, ssl_port, '/vms/test-vm/start', '{}',
'POST')
- resp = request(host, ssl_port, '/vms/test-vm/screenshot')
+ request(host, ssl_port, '/plugins/kimchi/vms/test-vm/start',
'{}', 'POST')
+ resp = request(host, ssl_port, '/plugins/kimchi/vms/test-vm/screenshot')
self.assertEquals(200, resp.status)
self.assertEquals('image/png', resp.getheader('content-type'))
- resp1 = request(host, ssl_port, '/vms/test-vm')
+ resp1 = request(host, ssl_port, '/plugins/kimchi/vms/test-vm')
rspBody = resp1.read()
testvm_Data = json.loads(rspBody)
screenshotURL = testvm_Data['screenshot']
@@ -91,13 +91,14 @@ class MockModelTests(unittest.TestCase):
def test_vm_list_sorted(self):
req = json.dumps({'name': 'test', 'cdrom': fake_iso})
- request(host, ssl_port, '/templates', req, 'POST')
+ request(host, ssl_port, '/plugins/kimchi/templates', req,
'POST')
def add_vm(name):
# Create a VM
- req = json.dumps({'name': name, 'template':
'/templates/test'})
- task = json.loads(request(host, ssl_port, '/vms', req,
- 'POST').read())
+ req = json.dumps({'name': name,
+ 'template':
'/plugins/kimchi/templates/test'})
+ task = json.loads(request(host, ssl_port, '/plugins/kimchi/vms',
+ req, 'POST').read())
wait_task(model.task_lookup, task['id'])
vms = [u'abc', u'bca', u'cab', u'xba']
@@ -111,7 +112,7 @@ class MockModelTests(unittest.TestCase):
model.templates_create({'name': u'test',
'cdrom': fake_iso})
task = model.vms_create({'name': u'test-vm',
- 'template': '/templates/test'})
+ 'template':
'/plugins/kimchi/templates/test'})
wait_task(model.task_lookup, task['id'])
vms = model.vms_get_list()
self.assertEquals(2, len(vms))
diff --git a/plugins/kimchi/tests/test_model.py b/plugins/kimchi/tests/test_model.py
index 7f90274..157ba62 100644
--- a/plugins/kimchi/tests/test_model.py
+++ b/plugins/kimchi/tests/test_model.py
@@ -128,7 +128,7 @@ class ModelTests(unittest.TestCase):
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'test')
- params = {'name': 'kimchi-vm', 'template':
'/templates/test'}
+ params = {'name': 'kimchi-vm', 'template':
'/plugins/kimchi/templates/test'}
task = inst.vms_create(params)
rollback.prependDefer(inst.vm_delete, 'kimchi-vm')
inst.task_wait(task['id'], 10)
@@ -264,12 +264,13 @@ class ModelTests(unittest.TestCase):
"icon": "images/icon-vm.png",
"os_distro": "unknown",
"os_version": "unknown",
"disks": [{"base": vol_path,
"size": 10}],
- "storagepool": "/storagepools/default"}
+ "storagepool":
"/plugins/kimchi/storagepools/default"}
with inst.objstore as session:
session.store('template', tmpl_name, tmpl_info)
- params = {'name': 'kimchi-vm', 'template':
'/templates/img-tmpl'}
+ params = {'name': 'kimchi-vm',
+ 'template': '/plugins/kimchi/templates/img-tmpl'}
task = inst.vms_create(params)
inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, 'kimchi-vm')
@@ -289,7 +290,8 @@ class ModelTests(unittest.TestCase):
params = {'name': 'test', 'disks': [], 'cdrom':
UBUNTU_ISO}
inst.templates_create(params)
with RollbackContext() as rollback:
- params = {'name': 'kimchi-vnc', 'template':
'/templates/test'}
+ params = {'name': 'kimchi-vnc',
+ 'template': '/plugins/kimchi/templates/test'}
task1 = inst.vms_create(params)
inst.task_wait(task1['id'])
rollback.prependDefer(inst.vm_delete, 'kimchi-vnc')
@@ -299,7 +301,7 @@ class ModelTests(unittest.TestCase):
self.assertEquals('127.0.0.1',
info['graphics']['listen'])
graphics = {'type': 'spice', 'listen':
'127.0.0.1'}
- params = {'name': 'kimchi-spice', 'template':
'/templates/test',
+ params = {'name': 'kimchi-spice', 'template':
'/plugins/kimchi/templates/test',
'graphics': graphics}
task2 = inst.vms_create(params)
inst.task_wait(task2['id'])
@@ -330,7 +332,8 @@ class ModelTests(unittest.TestCase):
rollback.prependDefer(inst.network_deactivate, net_name)
for vm_name in ['kimchi-ifaces', 'kimchi-ifaces-running']:
- params = {'name': vm_name, 'template':
'/templates/test'}
+ params = {'name': vm_name,
+ 'template': '/plugins/kimchi/templates/test'}
task = inst.vms_create(params)
inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, vm_name)
@@ -433,7 +436,8 @@ class ModelTests(unittest.TestCase):
params = {'name': 'test', 'disks': [],
'cdrom': UBUNTU_ISO}
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'test')
- params = {'name': vm_name, 'template':
'/templates/test'}
+ params = {'name': vm_name,
+ 'template': '/plugins/kimchi/templates/test'}
task1 = inst.vms_create(params)
inst.task_wait(task1['id'])
rollback.prependDefer(inst.vm_delete, vm_name)
@@ -477,7 +481,7 @@ class ModelTests(unittest.TestCase):
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'old_distro_template')
params = {'name': vm_name,
- 'template': '/templates/old_distro_template'}
+ 'template':
'/plugins/kimchi/templates/old_distro_template'}
task2 = inst.vms_create(params)
inst.task_wait(task2['id'])
rollback.prependDefer(inst.vm_delete, vm_name)
@@ -499,7 +503,8 @@ class ModelTests(unittest.TestCase):
params = {'name': 'test', 'disks': [],
'cdrom': UBUNTU_ISO}
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'test')
- params = {'name': vm_name, 'template':
'/templates/test'}
+ params = {'name': vm_name,
+ 'template': '/plugins/kimchi/templates/test'}
task = inst.vms_create(params)
inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, vm_name)
@@ -589,7 +594,8 @@ class ModelTests(unittest.TestCase):
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'test')
- params = {'name': 'test-vm-1', 'template':
'/templates/test'}
+ params = {'name': 'test-vm-1',
+ 'template': '/plugins/kimchi/templates/test'}
task = inst.vms_create(params)
inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, 'test-vm-1')
@@ -607,7 +613,8 @@ class ModelTests(unittest.TestCase):
inst.templates_create(orig_params)
with RollbackContext() as rollback:
- params = {'name': 'kimchi-vm1', 'template':
'/templates/test'}
+ params = {'name': 'kimchi-vm1',
+ 'template': '/plugins/kimchi/templates/test'}
task1 = inst.vms_create(params)
inst.task_wait(task1['id'])
rollback.prependDefer(utils.rollback_wrapper, inst.vm_delete,
@@ -639,8 +646,10 @@ class ModelTests(unittest.TestCase):
inst.templates_create(orig_params)
with RollbackContext() as rollback:
- params_1 = {'name': 'kimchi-vm1', 'template':
'/templates/test'}
- params_2 = {'name': 'kimchi-vm2', 'template':
'/templates/test'}
+ params_1 = {'name': 'kimchi-vm1',
+ 'template': '/plugins/kimchi/templates/test'}
+ params_2 = {'name': 'kimchi-vm2',
+ 'template': '/plugins/kimchi/templates/test'}
task1 = inst.vms_create(params_1)
inst.task_wait(task1['id'])
rollback.prependDefer(utils.rollback_wrapper, inst.vm_delete,
@@ -824,7 +833,8 @@ class ModelTests(unittest.TestCase):
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'test')
- params = {'name': u'kīмсhī-∨м', 'template':
u'/templates/test'}
+ params = {'name': u'kīмсhī-∨м',
+ 'template': u'/plugins/kimchi/templates/test'}
task = inst.vms_create(params)
inst.task_wait(task['id'])
rollback.prependDefer(utils.rollback_wrapper, inst.vm_delete,
@@ -849,7 +859,8 @@ class ModelTests(unittest.TestCase):
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'test')
- params = {'name': 'kimchi-vm', 'template':
'/templates/test'}
+ params = {'name': 'kimchi-vm',
+ 'template': '/plugins/kimchi/templates/test'}
task = inst.vms_create(params)
inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, 'kimchi-vm')
@@ -914,7 +925,7 @@ class ModelTests(unittest.TestCase):
with RollbackContext() as rollback:
params = {'name': 'test', 'disks': [],
'cdrom': UBUNTU_ISO,
- 'storagepool': '/storagepools/default-pool',
+ 'storagepool':
'/plugins/kimchi/storagepools/default-pool',
'domain': 'test',
'arch': 'i686'}
@@ -922,7 +933,7 @@ class ModelTests(unittest.TestCase):
rollback.prependDefer(inst.template_delete, 'test')
params = {'name': 'kimchi-vm',
- 'template': '/templates/test'}
+ 'template': '/plugins/kimchi/templates/test'}
task = inst.vms_create(params)
inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, 'kimchi-vm')
diff --git a/plugins/kimchi/tests/test_model_network.py
b/plugins/kimchi/tests/test_model_network.py
index d557b3c..37f5652 100644
--- a/plugins/kimchi/tests/test_model_network.py
+++ b/plugins/kimchi/tests/test_model_network.py
@@ -59,11 +59,11 @@ def tearDownModule():
def _do_network_test(self, model, params):
with RollbackContext() as rollback:
net_name = params['name']
- uri = '/networks/%s' % net_name.encode('utf-8')
+ uri = '/plugins/kimchi/networks/%s' % net_name.encode('utf-8')
# Create a network
req = json.dumps(params)
- resp = self.request('/networks', req, 'POST')
+ resp = self.request('/plugins/kimchi/networks', req, 'POST')
rollback.prependDefer(rollback_wrapper, model.network_delete,
net_name)
self.assertEquals(201, resp.status)
@@ -100,7 +100,7 @@ class NetworkTests(unittest.TestCase):
self.request = partial(request, host, ssl_port)
def test_get_networks(self):
- networks = json.loads(self.request('/networks').read())
+ networks = json.loads(self.request('/plugins/kimchi/networks').read())
self.assertIn('default', [net['name'] for net in networks])
with RollbackContext() as rollback:
@@ -111,16 +111,16 @@ class NetworkTests(unittest.TestCase):
'connection': 'nat',
'subnet': '127.0.10%i.0/24' % i})
- resp = self.request('/networks', req, 'POST')
+ resp = self.request('/plugins/kimchi/networks', req,
'POST')
rollback.prependDefer(model.network_delete, name)
self.assertEquals(201, resp.status)
network = json.loads(resp.read())
self.assertEquals([], network["vms"])
- nets = json.loads(self.request('/networks').read())
+ nets = json.loads(self.request('/plugins/kimchi/networks').read())
self.assertEquals(len(networks) + 5, len(nets))
- network = json.loads(self.request('/networks/network-1').read())
+ network =
json.loads(self.request('/plugins/kimchi/networks/network-1').read())
keys = [u'name', u'connection', u'interface',
u'subnet', u'dhcp',
u'vms', u'in_use', u'autostart',
u'state', u'persistent']
self.assertEquals(sorted(keys), sorted(network.keys()))
@@ -134,7 +134,7 @@ class NetworkTests(unittest.TestCase):
# Verify the current system has at least one interface to create a
# bridged network
- interfaces = json.loads(self.request('/interfaces?type=nic').read())
+ interfaces =
json.loads(self.request('/plugins/kimchi/interfaces?type=nic').read())
if len(interfaces) > 0:
iface = interfaces[0]['name']
networks.append({'name': u'bridge-network',
'connection': 'bridge',
diff --git a/plugins/kimchi/tests/test_model_storagepool.py
b/plugins/kimchi/tests/test_model_storagepool.py
index a01adc0..1326731 100644
--- a/plugins/kimchi/tests/test_model_storagepool.py
+++ b/plugins/kimchi/tests/test_model_storagepool.py
@@ -61,7 +61,7 @@ class StoragepoolTests(unittest.TestCase):
self.request = partial(request, host, ssl_port)
def test_get_storagepools(self):
- storagepools = json.loads(self.request('/storagepools').read())
+ storagepools =
json.loads(self.request('/plugins/kimchi/storagepools').read())
self.assertIn('default', [pool['name'] for pool in
storagepools])
with RollbackContext() as rollback:
@@ -70,7 +70,7 @@ class StoragepoolTests(unittest.TestCase):
name = u'kīмсhī-storagepool-%i' % i
req = json.dumps({'name': name, 'type': 'dir',
'path': '/var/lib/libvirt/images/%i' %
i})
- resp = self.request('/storagepools', req, 'POST')
+ resp = self.request('/plugins/kimchi/storagepools', req,
'POST')
rollback.prependDefer(model.storagepool_delete, name)
self.assertEquals(201, resp.status)
@@ -78,11 +78,11 @@ class StoragepoolTests(unittest.TestCase):
# Pool name must be unique
req = json.dumps({'name': name, 'type': 'dir',
'path': '/var/lib/libvirt/images/%i' %
i})
- resp = self.request('/storagepools', req, 'POST')
+ resp = self.request('/plugins/kimchi/storagepools', req,
'POST')
self.assertEquals(400, resp.status)
# Verify pool information
- resp = self.request('/storagepools/%s' %
name.encode("utf-8"))
+ resp = self.request('/plugins/kimchi/storagepools/%s' %
name.encode("utf-8"))
p = json.loads(resp.read())
keys = [u'name', u'state', u'capacity',
u'allocated',
u'available', u'path', u'source',
u'type',
@@ -94,11 +94,11 @@ class StoragepoolTests(unittest.TestCase):
self.assertEquals(True, p['autostart'])
self.assertEquals(0, p['nr_volumes'])
- pools = json.loads(self.request('/storagepools').read())
+ pools =
json.loads(self.request('/plugins/kimchi/storagepools').read())
self.assertEquals(len(storagepools) + 3, len(pools))
# Reserved pool return 400
req = json.dumps({'name': 'kimchi_isos', 'type':
'dir',
'path': '/var/lib/libvirt/images/%i' % i})
- resp = request(host, ssl_port, '/storagepools', req, 'POST')
+ resp = request(host, ssl_port, '/plugins/kimchi/storagepools', req,
'POST')
self.assertEquals(400, resp.status)
diff --git a/plugins/kimchi/tests/test_model_storagevolume.py
b/plugins/kimchi/tests/test_model_storagevolume.py
index d47b4e3..103948e 100644
--- a/plugins/kimchi/tests/test_model_storagevolume.py
+++ b/plugins/kimchi/tests/test_model_storagevolume.py
@@ -62,13 +62,13 @@ def tearDownModule():
def _do_volume_test(self, model, host, ssl_port, pool_name):
def _task_lookup(taskid):
- return json.loads(self.request('/tasks/%s' % taskid).read())
+ return json.loads(self.request('/plugins/kimchi/tasks/%s' %
taskid).read())
- uri = '/storagepools/%s/storagevolumes' % pool_name.encode('utf-8')
+ uri = '/plugins/kimchi/storagepools/%s/storagevolumes' %
pool_name.encode('utf-8')
resp = self.request(uri)
self.assertEquals(200, resp.status)
- resp = self.request('/storagepools/%s' % pool_name.encode('utf-8'))
+ resp = self.request('/plugins/kimchi/storagepools/%s' %
pool_name.encode('utf-8'))
pool_info = json.loads(resp.read())
with RollbackContext() as rollback:
# Create storage volume with 'capacity'
@@ -85,7 +85,7 @@ def _do_volume_test(self, model, host, ssl_port, pool_name):
self.assertEquals(202, resp.status)
task_id = json.loads(resp.read())['id']
wait_task(_task_lookup, task_id)
- status = json.loads(self.request('/tasks/%s' % task_id).read())
+ status = json.loads(self.request('/plugins/kimchi/tasks/%s' %
task_id).read())
self.assertEquals('finished', status['status'])
vol_info = json.loads(self.request(vol_uri).read())
vol_info['name'] = vol
@@ -129,7 +129,7 @@ def _do_volume_test(self, model, host, ssl_port, pool_name):
rollback.prependDefer(model.storagevolume_delete, pool_name,
cloned_vol_name)
wait_task(_task_lookup, task['id'])
- task = json.loads(self.request('/tasks/%s' %
task['id']).read())
+ task = json.loads(self.request('/plugins/kimchi/tasks/%s' %
task['id']).read())
self.assertEquals('finished', task['status'])
resp = self.request(uri + '/' +
cloned_vol_name.encode('utf-8'))
@@ -168,7 +168,8 @@ def _do_volume_test(self, model, host, ssl_port, pool_name):
self.assertEquals(202, resp.status)
task_id = json.loads(resp.read())['id']
wait_task(_task_lookup, task_id)
- status = json.loads(self.request('/tasks/%s' % task_id).read())
+ status = json.loads(self.request('/plugins/kimchi/tasks/%s' %
+ task_id).read())
self.assertEquals('ready for upload', status['message'])
# Upload volume content
@@ -249,7 +250,7 @@ class StorageVolumeTests(unittest.TestCase):
self.request = partial(request, host, ssl_port)
def test_get_storagevolume(self):
- uri = '/storagepools/default/storagevolumes'
+ uri = '/plugins/kimchi/storagepools/default/storagevolumes'
resp = self.request(uri)
self.assertEquals(200, resp.status)
diff --git a/plugins/kimchi/tests/test_rest.py b/plugins/kimchi/tests/test_rest.py
index f390abb..69db7a7 100644
--- a/plugins/kimchi/tests/test_rest.py
+++ b/plugins/kimchi/tests/test_rest.py
@@ -96,14 +96,14 @@ class RestTests(unittest.TestCase):
self.assertEquals(code, resp.status)
def test_get_vms(self):
- vms = json.loads(self.request('/vms').read())
+ vms = json.loads(self.request('/plugins/kimchi/vms').read())
# test_rest.py uses MockModel() which connects to libvirt URI
# test:///default. By default this driver already has one VM created
self.assertEquals(1, len(vms))
# Create a template as a base for our VMs
req = json.dumps({'name': 'test', 'cdrom': fake_iso})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
test_users = ['root']
@@ -111,17 +111,17 @@ class RestTests(unittest.TestCase):
# Now add a couple of VMs to the mock model
for i in xrange(10):
name = 'vm-%i' % i
- req = json.dumps({'name': name, 'template':
'/templates/test',
+ req = json.dumps({'name': name, 'template':
'/plugins/kimchi/templates/test',
'users': test_users, 'groups':
test_groups})
- resp = self.request('/vms', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
- vms = json.loads(self.request('/vms').read())
+ vms = json.loads(self.request('/plugins/kimchi/vms').read())
self.assertEquals(11, len(vms))
- vm = json.loads(self.request('/vms/vm-1').read())
+ vm = json.loads(self.request('/plugins/kimchi/vms/vm-1').read())
self.assertEquals('vm-1', vm['name'])
self.assertEquals('shutoff', vm['state'])
self.assertEquals([], vm['users'])
@@ -129,123 +129,124 @@ class RestTests(unittest.TestCase):
def test_edit_vm(self):
req = json.dumps({'name': 'test', 'cdrom': fake_iso})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
- req = json.dumps({'name': 'vm-1', 'template':
'/templates/test'})
- resp = self.request('/vms', req, 'POST')
+ req = json.dumps({'name': 'vm-1',
+ 'template': '/plugins/kimchi/templates/test'})
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
- vm = json.loads(self.request('/vms/vm-1').read())
+ vm = json.loads(self.request('/plugins/kimchi/vms/vm-1').read())
self.assertEquals('vm-1', vm['name'])
- resp = self.request('/vms/vm-1/start', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/vms/vm-1/start', '{}',
'POST')
self.assertEquals(200, resp.status)
req = json.dumps({'unsupported-attr': 'attr'})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
req = json.dumps({'name': 'new-vm'})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
req = json.dumps({'cpus': 3})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(200, resp.status)
# Check if there is support to memory hotplug, once vm is running
- resp = self.request('/config/capabilities').read()
+ resp = self.request('/plugins/kimchi/config/capabilities').read()
conf = json.loads(resp)
req = json.dumps({'memory': 2048})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
if conf['mem_hotplug_support']:
self.assertEquals(200, resp.status)
else:
self.assertEquals(400, resp.status)
req = json.dumps({"graphics": {'passwd': "abcdef"}})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
info = json.loads(resp.read())
self.assertEquals('abcdef',
info["graphics"]["passwd"])
self.assertEquals(None, info["graphics"]["passwdValidTo"])
- resp = self.request('/vms/vm-1/poweroff', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/vms/vm-1/poweroff', '{}',
'POST')
self.assertEquals(200, resp.status)
req = json.dumps({"graphics": {'passwd': "123456",
'passwdValidTo': 20}})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
info = json.loads(resp.read())
self.assertEquals('123456',
info["graphics"]["passwd"])
self.assertGreaterEqual(20,
info["graphics"]["passwdValidTo"])
req = json.dumps({'name': 12})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
req = json.dumps({'name': ''})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
req = json.dumps({'cpus': -2})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
req = json.dumps({'cpus': 'four'})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
req = json.dumps({'memory': 100})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
req = json.dumps({'memory': 'ten gigas'})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
req = json.dumps({'name': 'new-name', 'cpus': 5,
'UUID': 'notallowed'})
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
params = {'name': u'∨м-црdαtеd', 'cpus': 5,
'memory': 3072}
req = json.dumps(params)
- resp = self.request('/vms/vm-1', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
self.assertEquals(303, resp.status)
- vm = json.loads(self.request('/vms/∨м-црdαtеd', req).read())
+ vm = json.loads(self.request('/plugins/kimchi/vms/∨м-црdαtеd',
req).read())
for key in params.keys():
self.assertEquals(params[key], vm[key])
# change only VM users - groups are not changed (default is empty)
- resp = self.request('/users', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/users', '{}',
'GET')
users = json.loads(resp.read())
req = json.dumps({'users': users})
- resp = self.request('/vms/∨м-црdαtеd', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/∨м-црdαtеd', req,
'PUT')
self.assertEquals(200, resp.status)
- info = json.loads(self.request('/vms/∨м-црdαtеd', '{}').read())
+ info = json.loads(self.request('/plugins/kimchi/vms/∨м-црdαtеd',
'{}').read())
self.assertEquals(users, info['users'])
# change only VM groups - users are not changed (default is empty)
- resp = self.request('/groups', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/groups', '{}',
'GET')
groups = json.loads(resp.read())
req = json.dumps({'groups': groups})
- resp = self.request('/vms/∨м-црdαtеd', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/∨м-црdαtеd', req,
'PUT')
self.assertEquals(200, resp.status)
- info = json.loads(self.request('/vms/∨м-црdαtеd', '{}').read())
+ info = json.loads(self.request('/plugins/kimchi/vms/∨м-црdαtеd',
'{}').read())
self.assertEquals(groups, info['groups'])
# change VM users (wrong value) and groups
# when an error occurs, everything fails and nothing is changed
req = json.dumps({'users': ['userdoesnotexist'],
'groups': []})
- resp = self.request('/vms/∨м-црdαtеd', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/∨м-црdαtеd', req,
'PUT')
self.assertEquals(400, resp.status)
# change VM users and groups (wrong value)
# when an error occurs, everything fails and nothing is changed
req = json.dumps({'users': [], 'groups':
['groupdoesnotexist']})
- resp = self.request('/vms/∨м-црdαtеd', req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/∨м-црdαtеd', req,
'PUT')
self.assertEquals(400, resp.status)
def test_vm_lifecycle(self):
@@ -253,31 +254,32 @@ class RestTests(unittest.TestCase):
req = json.dumps({'name': 'test', 'disks':
[{'size': 1}],
'icon': 'images/icon-debian.png',
'cdrom': fake_iso})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
# Create a VM
- req = json.dumps({'name': 'test-vm', 'template':
'/templates/test'})
- resp = self.request('/vms', req, 'POST')
+ req = json.dumps({'name': 'test-vm',
+ 'template': '/plugins/kimchi/templates/test'})
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
self.assertEquals(202, resp.status)
# Verify the VM
- vm = json.loads(self.request('/vms/test-vm').read())
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
self.assertEquals('shutoff', vm['state'])
self.assertEquals('images/icon-debian.png', vm['icon'])
# Verify the volume was created
- vol_uri = '/storagepools/default-pool/storagevolumes/%s-0.img'
+ vol_uri =
'/plugins/kimchi/storagepools/default-pool/storagevolumes/%s-0.img'
resp = self.request(vol_uri % vm['uuid'])
vol = json.loads(resp.read())
self.assertEquals(1 << 30, vol['capacity'])
self.assertEquals(['test-vm'], vol['used_by'])
# Start the VM
- resp = self.request('/vms/test-vm/start', '{}', 'POST')
- vm = json.loads(self.request('/vms/test-vm').read())
+ resp = self.request('/plugins/kimchi/vms/test-vm/start', '{}',
'POST')
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
self.assertEquals('running', vm['state'])
# Test screenshot
@@ -286,32 +288,32 @@ class RestTests(unittest.TestCase):
self.assertTrue(resp.getheader('Content-type').startswith('image'))
# Clone a running VM
- resp = self.request('/vms/test-vm/clone', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/clone', '{}',
'POST')
self.assertEquals(400, resp.status)
# Force poweroff the VM
- resp = self.request('/vms/test-vm/poweroff', '{}',
'POST')
- vm = json.loads(self.request('/vms/test-vm').read())
+ resp = self.request('/plugins/kimchi/vms/test-vm/poweroff', '{}',
'POST')
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
self.assertEquals('shutoff', vm['state'])
# Test create VM with same name fails with 400
- req = json.dumps({'name': 'test-vm', 'template':
'/templates/test'})
- resp = self.request('/vms', req, 'POST')
+ req = json.dumps({'name': 'test-vm', 'template':
'/plugins/kimchi/templates/test'})
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(400, resp.status)
# Clone a VM
- resp = self.request('/vms/test-vm/clone', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/clone', '{}',
'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
- task = json.loads(self.request('/tasks/%s' % task['id'],
'{}').read())
+ task = json.loads(self.request('/plugins/kimchi/tasks/%s' %
task['id'], '{}').read())
self.assertEquals('finished', task['status'])
clone_vm_name = task['target_uri'].split('/')[-2]
self.assertTrue(re.match(u'test-vm-clone-\d+', clone_vm_name))
- resp = self.request('/vms/test-vm', '{}')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}')
original_vm_info = json.loads(resp.read())
- resp = self.request('/vms/%s' % clone_vm_name, '{}')
+ resp = self.request('/plugins/kimchi/vms/%s' % clone_vm_name,
'{}')
self.assertEquals(200, resp.status)
clone_vm_info = json.loads(resp.read())
@@ -327,20 +329,21 @@ class RestTests(unittest.TestCase):
# Create a snapshot on a stopped VM
params = {'name': 'test-snap'}
- resp = self.request('/vms/test-vm/snapshots', json.dumps(params),
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots',
json.dumps(params),
'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
- task = json.loads(self.request('/tasks/%s' % task['id']).read())
+ task = json.loads(self.request('/plugins/kimchi/tasks/%s' %
task['id']).read())
self.assertEquals('finished', task['status'])
# Look up a non-existing snapshot
- resp = self.request('/vms/test-vm/snapshots/snap404', '{}',
'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots/snap404',
+ '{}', 'GET')
self.assertEquals(404, resp.status)
# Look up a snapshot
- resp = self.request('/vms/test-vm/snapshots/%s' % params['name'],
'{}',
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots/%s' %
params['name'], '{}',
'GET')
self.assertEquals(200, resp.status)
snap = json.loads(resp.read())
@@ -349,90 +352,90 @@ class RestTests(unittest.TestCase):
self.assertEquals(u'', snap['parent'])
self.assertEquals(u'shutoff', snap['state'])
- resp = self.request('/vms/test-vm/snapshots', '{}',
'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots',
'{}', 'GET')
self.assertEquals(200, resp.status)
snaps = json.loads(resp.read())
self.assertEquals(1, len(snaps))
# Look up current snapshot (the one created above)
- resp = self.request('/vms/test-vm/snapshots/current', '{}',
'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots/current',
'{}', 'GET')
self.assertEquals(200, resp.status)
snap = json.loads(resp.read())
self.assertEquals(params['name'], snap['name'])
- resp = self.request('/vms/test-vm/snapshots', '{}',
'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots',
'{}', 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
snap_name = task['target_uri'].split('/')[-1]
wait_task(self._task_lookup, task['id'])
- resp = self.request('/tasks/%s' % task['id'], '{}',
'GET')
+ resp = self.request('/plugins/kimchi/tasks/%s' % task['id'],
'{}', 'GET')
task = json.loads(resp.read())
self.assertEquals('finished', task['status'])
- resp = self.request('/vms/test-vm/snapshots', '{}',
'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots',
'{}', 'GET')
self.assertEquals(200, resp.status)
snaps = json.loads(resp.read())
self.assertEquals(2, len(snaps))
# Look up current snapshot (the one created above)
- resp = self.request('/vms/test-vm/snapshots/current', '{}',
'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots/current',
'{}', 'GET')
self.assertEquals(200, resp.status)
snap = json.loads(resp.read())
self.assertEquals(snap_name, snap['name'])
# Revert to snapshot
- resp = self.request('/vms/test-vm/snapshots/%s/revert' %
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots/%s/revert' %
params['name'], '{}', 'POST')
self.assertEquals(200, resp.status)
snap = json.loads(resp.read())
- resp = self.request('/vms/test-vm', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'GET')
self.assertEquals(200, resp.status)
vm = json.loads(resp.read())
self.assertEquals(vm['state'], snap['state'])
- resp = self.request('/vms/test-vm/snapshots/current', '{}',
'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots/current',
'{}', 'GET')
self.assertEquals(200, resp.status)
current_snap = json.loads(resp.read())
self.assertEquals(snap, current_snap)
# Delete a snapshot
- resp = self.request('/vms/test-vm/snapshots/%s' %
params['name'],
+ resp = self.request('/plugins/kimchi/vms/test-vm/snapshots/%s' %
params['name'],
'{}', 'DELETE')
self.assertEquals(204, resp.status)
# Suspend the VM
- resp = self.request('/vms/test-vm', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'GET')
self.assertEquals(200, resp.status)
vm = json.loads(resp.read())
self.assertEquals(vm['state'], 'shutoff')
- resp = self.request('/vms/test-vm/suspend', '{}',
'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/suspend', '{}',
'POST')
self.assertEquals(400, resp.status)
- resp = self.request('/vms/test-vm/start', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/start', '{}',
'POST')
self.assertEquals(200, resp.status)
- resp = self.request('/vms/test-vm', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'GET')
self.assertEquals(200, resp.status)
vm = json.loads(resp.read())
self.assertEquals(vm['state'], 'running')
- resp = self.request('/vms/test-vm/suspend', '{}',
'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/suspend', '{}',
'POST')
self.assertEquals(200, resp.status)
- resp = self.request('/vms/test-vm', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'GET')
self.assertEquals(200, resp.status)
vm = json.loads(resp.read())
self.assertEquals(vm['state'], 'paused')
# Resume the VM
- resp = self.request('/vms/test-vm/resume', '{}', 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/resume', '{}',
'POST')
self.assertEquals(200, resp.status)
- resp = self.request('/vms/test-vm', '{}', 'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'GET')
self.assertEquals(200, resp.status)
vm = json.loads(resp.read())
self.assertEquals(vm['state'], 'running')
# Delete the VM
- resp = self.request('/vms/test-vm', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'DELETE')
self.assertEquals(204, resp.status)
# Delete the Template
- resp = self.request('/templates/test', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/templates/test', '{}',
'DELETE')
self.assertEquals(204, resp.status)
# Verify the volume was deleted
@@ -441,87 +444,88 @@ class RestTests(unittest.TestCase):
def test_vm_graphics(self):
# Create a Template
req = json.dumps({'name': 'test', 'cdrom': fake_iso})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
# Create a VM with default args
- req = json.dumps({'name': 'test-vm', 'template':
'/templates/test'})
- resp = self.request('/vms', req, 'POST')
+ req = json.dumps({'name': 'test-vm',
+ 'template': '/plugins/kimchi/templates/test'})
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
# Verify the VM
- vm = json.loads(self.request('/vms/test-vm').read())
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
self.assertEquals('127.0.0.1', vm['graphics']['listen'])
self.assertEquals('vnc', vm['graphics']['type'])
# Delete the VM
- resp = self.request('/vms/test-vm', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'DELETE')
self.assertEquals(204, resp.status)
# Create a VM with specified graphics type and listen
graphics = {'type': 'vnc', 'listen':
'127.0.0.1'}
- req = json.dumps({'name': 'test-vm', 'template':
'/templates/test',
+ req = json.dumps({'name': 'test-vm', 'template':
'/plugins/kimchi/templates/test',
'graphics': graphics})
- resp = self.request('/vms', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
# Verify the VM
- vm = json.loads(self.request('/vms/test-vm').read())
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
self.assertEquals('127.0.0.1', vm['graphics']['listen'])
self.assertEquals('vnc', vm['graphics']['type'])
# Delete the VM
- resp = self.request('/vms/test-vm', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'DELETE')
self.assertEquals(204, resp.status)
# Create a VM with listen as ipv6 address
graphics = {'type': 'spice', 'listen':
'fe00::0'}
- req = json.dumps({'name': 'test-vm', 'template':
'/templates/test',
+ req = json.dumps({'name': 'test-vm', 'template':
'/plugins/kimchi/templates/test',
'graphics': graphics})
- resp = self.request('/vms', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
# Verify the VM
- vm = json.loads(self.request('/vms/test-vm').read())
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
self.assertEquals('fe00::0', vm['graphics']['listen'])
self.assertEquals('spice', vm['graphics']['type'])
# Delete the VM
- resp = self.request('/vms/test-vm', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'DELETE')
self.assertEquals(204, resp.status)
# Create a VM with specified graphics type and default listen
graphics = {'type': 'spice'}
- req = json.dumps({'name': 'test-vm', 'template':
'/templates/test',
+ req = json.dumps({'name': 'test-vm', 'template':
'/plugins/kimchi/templates/test',
'graphics': graphics})
- resp = self.request('/vms', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
# Verify the VM
- vm = json.loads(self.request('/vms/test-vm').read())
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
self.assertEquals('127.0.0.1', vm['graphics']['listen'])
self.assertEquals('spice', vm['graphics']['type'])
# Delete the VM
- resp = self.request('/vms/test-vm', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'DELETE')
self.assertEquals(204, resp.status)
# Try to create a VM with invalid graphics type
graphics = {'type': 'invalid'}
- req = json.dumps({'name': 'test-vm', 'template':
'/templates/test',
+ req = json.dumps({'name': 'test-vm', 'template':
'/plugins/kimchi/templates/test',
'graphics': graphics})
- resp = self.request('/vms', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(400, resp.status)
# Try to create a VM with invalid graphics listen
graphics = {'type': 'spice', 'listen':
'invalid'}
- req = json.dumps({'name': 'test-vm', 'template':
'/templates/test',
+ req = json.dumps({'name': 'test-vm', 'template':
'/plugins/kimchi/templates/test',
'graphics': graphics})
- resp = self.request('/vms', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(400, resp.status)
# Delete the Template
- resp = self.request('/templates/test', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/templates/test', '{}',
'DELETE')
self.assertEquals(204, resp.status)
def test_vm_storage_devices(self):
@@ -529,25 +533,25 @@ class RestTests(unittest.TestCase):
with RollbackContext() as rollback:
# Create a template as a base for our VMs
req = json.dumps({'name': 'test', 'cdrom':
fake_iso})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req,
'POST')
self.assertEquals(201, resp.status)
# Delete the template
rollback.prependDefer(self.request,
- '/templates/test', '{}',
'DELETE')
+ '/plugins/kimchi/templates/test', '{}',
'DELETE')
# Create a VM with default args
req = json.dumps({'name': 'test-vm',
- 'template': '/templates/test'})
- resp = self.request('/vms', req, 'POST')
+ 'template':
'/plugins/kimchi/templates/test'})
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
# Delete the VM
rollback.prependDefer(self.request,
- '/vms/test-vm', '{}',
'DELETE')
+ '/plugins/kimchi/vms/test-vm', '{}',
'DELETE')
# Check storage devices
- resp = self.request('/vms/test-vm/storages', '{}',
'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm/storages',
'{}', 'GET')
devices = json.loads(resp.read())
self.assertEquals(2, len(devices))
dev_types = []
@@ -563,7 +567,7 @@ class RestTests(unittest.TestCase):
req = json.dumps({'dev': 'hdx',
'type': 'cdrom',
'path': '/tmp/nonexistent.iso'})
- resp = self.request('/vms/test-vm/storages', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/storages', req,
'POST')
self.assertEquals(400, resp.status)
# Create temp storage pool
@@ -572,9 +576,9 @@ class RestTests(unittest.TestCase):
'allocated': 512,
'path': '/tmp',
'type': 'dir'})
- resp = self.request('/storagepools', req, 'POST')
+ resp = self.request('/plugins/kimchi/storagepools', req,
'POST')
self.assertEquals(201, resp.status)
- resp = self.request('/storagepools/tmp/activate', req,
'POST')
+ resp = self.request('/plugins/kimchi/storagepools/tmp/activate', req,
'POST')
self.assertEquals(200, resp.status)
# 'name' is required for this type of volume
@@ -582,7 +586,7 @@ class RestTests(unittest.TestCase):
'allocation': 512,
'type': 'disk',
'format': 'raw'})
- resp = self.request('/storagepools/tmp/storagevolumes',
+ resp =
self.request('/plugins/kimchi/storagepools/tmp/storagevolumes',
req, 'POST')
self.assertEquals(400, resp.status)
req = json.dumps({'name': "attach-volume",
@@ -590,7 +594,7 @@ class RestTests(unittest.TestCase):
'allocation': 512,
'type': 'disk',
'format': 'raw'})
- resp = self.request('/storagepools/tmp/storagevolumes',
+ resp =
self.request('/plugins/kimchi/storagepools/tmp/storagevolumes',
req, 'POST')
self.assertEquals(202, resp.status)
time.sleep(1)
@@ -602,7 +606,7 @@ class RestTests(unittest.TestCase):
'pool': 'tmp',
'vol': 'attach-volume',
'path': '/tmp/existent.iso'})
- resp = self.request('/vms/test-vm/storages', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/storages', req,
'POST')
self.assertEquals(400, resp.status)
# Attach disk with both path and volume specified
@@ -611,21 +615,21 @@ class RestTests(unittest.TestCase):
'pool': 'tmp',
'vol': 'attach-volume',
'path': '/tmp/existent.iso'})
- resp = self.request('/vms/test-vm/storages', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/storages', req,
'POST')
self.assertEquals(400, resp.status)
# Attach disk with only pool specified
req = json.dumps({'dev': 'hdx',
'type': 'cdrom',
'pool': 'tmp'})
- resp = self.request('/vms/test-vm/storages', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/storages', req,
'POST')
self.assertEquals(400, resp.status)
# Attach disk with pool and vol specified
req = json.dumps({'type': 'disk',
'pool': 'tmp',
'vol': 'attach-volume'})
- resp = self.request('/vms/test-vm/storages', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/storages', req,
'POST')
self.assertEquals(201, resp.status)
cd_info = json.loads(resp.read())
self.assertEquals('disk', cd_info['type'])
@@ -633,7 +637,7 @@ class RestTests(unittest.TestCase):
# Attach a cdrom with existent dev name
req = json.dumps({'type': 'cdrom',
'path': '/tmp/existent.iso'})
- resp = self.request('/vms/test-vm/storages', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/storages', req,
'POST')
self.assertEquals(201, resp.status)
cd_info = json.loads(resp.read())
cd_dev = cd_info['dev']
@@ -641,34 +645,34 @@ class RestTests(unittest.TestCase):
self.assertEquals('/tmp/existent.iso', cd_info['path'])
# Delete the file and cdrom
rollback.prependDefer(self.request,
- '/vms/test-vm/storages/hdx', '{}',
'DELETE')
+ '/plugins/kimchi/vms/test-vm/storages/hdx',
'{}', 'DELETE')
os.remove('/tmp/existent.iso')
# Change path of storage cdrom
cdrom =
u'http://fedora.mirrors.tds.net/pub/fedora/releases/20/'\
'Live/x86_64/Fedora-Live-Desktop-x86_64-20-1.iso'
req = json.dumps({'path': cdrom})
- resp = self.request('/vms/test-vm/storages/' + cd_dev, req,
'PUT')
+ resp = self.request('/plugins/kimchi/vms/test-vm/storages/' + cd_dev,
req, 'PUT')
self.assertEquals(200, resp.status)
cd_info = json.loads(resp.read())
self.assertEquals(urlparse.urlparse(cdrom).path,
urlparse.urlparse(cd_info['path']).path)
# Test GET
- devs = json.loads(self.request('/vms/test-vm/storages').read())
+ devs =
json.loads(self.request('/plugins/kimchi/vms/test-vm/storages').read())
self.assertEquals(4, len(devs))
# Detach storage cdrom
- resp = self.request('/vms/test-vm/storages/' + cd_dev,
+ resp = self.request('/plugins/kimchi/vms/test-vm/storages/' +
cd_dev,
'{}', 'DELETE')
self.assertEquals(204, resp.status)
# Test GET
- devs = json.loads(self.request('/vms/test-vm/storages').read())
+ devs =
json.loads(self.request('/plugins/kimchi/vms/test-vm/storages').read())
self.assertEquals(3, len(devs))
- resp = self.request('/storagepools/tmp/deactivate', {},
'POST')
+ resp = self.request('/plugins/kimchi/storagepools/tmp/deactivate',
{}, 'POST')
self.assertEquals(200, resp.status)
- resp = self.request('/storagepools/tmp', {}, 'DELETE')
+ resp = self.request('/plugins/kimchi/storagepools/tmp', {},
'DELETE')
self.assertEquals(204, resp.status)
def test_vm_iface(self):
@@ -676,38 +680,38 @@ class RestTests(unittest.TestCase):
with RollbackContext() as rollback:
# Create a template as a base for our VMs
req = json.dumps({'name': 'test', 'cdrom':
fake_iso})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req,
'POST')
self.assertEquals(201, resp.status)
# Delete the template
rollback.prependDefer(self.request,
- '/templates/test', '{}',
'DELETE')
+ '/plugins/kimchi/templates/test', '{}',
'DELETE')
# Create a VM with default args
req = json.dumps({'name': 'test-vm',
- 'template': '/templates/test'})
- resp = self.request('/vms', req, 'POST')
+ 'template':
'/plugins/kimchi/templates/test'})
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
# Delete the VM
rollback.prependDefer(self.request,
- '/vms/test-vm', '{}',
'DELETE')
+ '/plugins/kimchi/vms/test-vm', '{}',
'DELETE')
# Create a network
req = json.dumps({'name': 'test-network',
'connection': 'nat',
'net': '127.0.1.0/24'})
- resp = self.request('/networks', req, 'POST')
+ resp = self.request('/plugins/kimchi/networks', req, 'POST')
self.assertEquals(201, resp.status)
# Delete the network
rollback.prependDefer(self.request,
- '/networks/test-network', '{}',
'DELETE')
+ '/plugins/kimchi/networks/test-network',
'{}', 'DELETE')
- ifaces = json.loads(self.request('/vms/test-vm/ifaces').read())
+ ifaces =
json.loads(self.request('/plugins/kimchi/vms/test-vm/ifaces').read())
self.assertEquals(1, len(ifaces))
for iface in ifaces:
- res = json.loads(self.request('/vms/test-vm/ifaces/%s' %
+ res =
json.loads(self.request('/plugins/kimchi/vms/test-vm/ifaces/%s' %
iface['mac']).read())
self.assertEquals('default', res['network'])
self.assertEquals(17, len(res['mac']))
@@ -716,14 +720,15 @@ class RestTests(unittest.TestCase):
# try to attach an interface without specifying 'model'
req = json.dumps({'type': 'network'})
- resp = self.request('/vms/test-vm/ifaces', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/ifaces', req,
+ 'POST')
self.assertEquals(400, resp.status)
# attach network interface to vm
req = json.dumps({"type": "network",
"network": "test-network",
"model": "virtio"})
- resp = self.request('/vms/test-vm/ifaces', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/ifaces', req,
'POST')
self.assertEquals(201, resp.status)
iface = json.loads(resp.read())
@@ -736,15 +741,15 @@ class RestTests(unittest.TestCase):
newMacAddr = '54:50:e3:44:8a:af'
req = json.dumps({"network": "default",
"model": "virtio",
"type": "network", "mac":
newMacAddr})
- resp = self.request('/vms/test-vm/ifaces/%s' % iface['mac'],
- req, 'PUT')
+ resp = self.request('/plugins/kimchi/vms/test-vm/ifaces/%s' %
+ iface['mac'], req, 'PUT')
self.assertEquals(303, resp.status)
- iface = json.loads(self.request('/vms/test-vm/ifaces/%s' %
+ iface =
json.loads(self.request('/plugins/kimchi/vms/test-vm/ifaces/%s' %
newMacAddr).read())
self.assertEquals(newMacAddr, iface['mac'])
# detach network interface from vm
- resp = self.request('/vms/test-vm/ifaces/%s' % iface['mac'],
+ resp = self.request('/plugins/kimchi/vms/test-vm/ifaces/%s' %
iface['mac'],
'{}', 'DELETE')
self.assertEquals(204, resp.status)
@@ -752,7 +757,7 @@ class RestTests(unittest.TestCase):
# Create a Template
req = json.dumps({'name': 'test', 'cdrom': fake_iso,
'disks': [{'size': 1}]})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
# Create alternate storage
@@ -761,33 +766,34 @@ class RestTests(unittest.TestCase):
'allocated': 512,
'path': '/tmp',
'type': 'dir'})
- resp = self.request('/storagepools', req, 'POST')
+ resp = self.request('/plugins/kimchi/storagepools', req, 'POST')
self.assertEquals(201, resp.status)
- resp = self.request('/storagepools/alt/activate', req, 'POST')
+ resp = self.request('/plugins/kimchi/storagepools/alt/activate', req,
'POST')
self.assertEquals(200, resp.status)
# Create a VM
- req = json.dumps({'name': 'test-vm', 'template':
'/templates/test',
- 'storagepool': '/storagepools/alt'})
- resp = self.request('/vms', req, 'POST')
+ req = json.dumps({'name': 'test-vm',
+ 'template': '/plugins/kimchi/templates/test',
+ 'storagepool':
'/plugins/kimchi/storagepools/alt'})
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
- resp = self.request('/vms/test-vm', {}, 'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm', {}, 'GET')
vm_info = json.loads(resp.read())
# Test template not changed after vm customise its pool
- t = json.loads(self.request('/templates/test').read())
- self.assertEquals(t['storagepool'],
'/storagepools/default-pool')
+ t = json.loads(self.request('/plugins/kimchi/templates/test').read())
+ self.assertEquals(t['storagepool'],
'/plugins/kimchi/storagepools/default-pool')
# Verify the volume was created
- vol_uri = '/storagepools/alt/storagevolumes/%s-0.img' %
vm_info['uuid']
+ vol_uri = '/plugins/kimchi/storagepools/alt/storagevolumes/%s-0.img' %
vm_info['uuid']
resp = self.request(vol_uri)
vol = json.loads(resp.read())
self.assertEquals(1 << 30, vol['capacity'])
# Delete the VM
- resp = self.request('/vms/test-vm', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'DELETE')
self.assertEquals(204, resp.status)
# Verify the volume was deleted
@@ -798,71 +804,72 @@ class RestTests(unittest.TestCase):
req = json.dumps({'name': 'scsi_fc_pool',
'type': 'scsi',
'source': {'adapter_name':
'scsi_host2'}})
- resp = self.request('/storagepools', req, 'POST')
+ resp = self.request('/plugins/kimchi/storagepools', req, 'POST')
self.assertEquals(201, resp.status)
# Test create vms using lun of this pool
# activate the storage pool
- resp = self.request('/storagepools/scsi_fc_pool/activate', '{}',
+ resp = self.request('/plugins/kimchi/storagepools/scsi_fc_pool/activate',
'{}',
'POST')
# Create template fails because SCSI volume is missing
tmpl_params = {'name': 'test_fc_pool', 'cdrom':
fake_iso,
- 'storagepool': '/storagepools/scsi_fc_pool'}
+ 'storagepool':
'/plugins/kimchi/storagepools/scsi_fc_pool'}
req = json.dumps(tmpl_params)
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(400, resp.status)
# Choose SCSI volume to create template
- resp = self.request('/storagepools/scsi_fc_pool/storagevolumes')
+ resp =
self.request('/plugins/kimchi/storagepools/scsi_fc_pool/storagevolumes')
lun_name = json.loads(resp.read())[0]['name']
tmpl_params['disks'] = [{'index': 0, 'volume':
lun_name}]
req = json.dumps(tmpl_params)
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
# Create vm in scsi pool
req = json.dumps({'name': 'test-vm',
- 'template': '/templates/test_fc_pool'})
- resp = self.request('/vms', req, 'POST')
+ 'template':
'/plugins/kimchi/templates/test_fc_pool'})
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
# Start the VM
- resp = self.request('/vms/test-vm/start', '{}', 'POST')
- vm = json.loads(self.request('/vms/test-vm').read())
+ resp = self.request('/plugins/kimchi/vms/test-vm/start', '{}',
'POST')
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
self.assertEquals('running', vm['state'])
# Force poweroff the VM
- resp = self.request('/vms/test-vm/poweroff', '{}',
'POST')
- vm = json.loads(self.request('/vms/test-vm').read())
+ resp = self.request('/plugins/kimchi/vms/test-vm/poweroff', '{}',
'POST')
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
self.assertEquals('shutoff', vm['state'])
# Delete the VM
- resp = self.request('/vms/test-vm', '{}', 'DELETE')
+ resp = self.request('/plugins/kimchi/vms/test-vm', '{}',
'DELETE')
self.assertEquals(204, resp.status)
def test_unnamed_vms(self):
# Create a Template
req = json.dumps({'name': 'test', 'cdrom': fake_iso})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
# Create 5 unnamed vms from this template
for i in xrange(1, 6):
- req = json.dumps({'template': '/templates/test'})
- task = json.loads(self.request('/vms', req, 'POST').read())
+ req = json.dumps({'template':
'/plugins/kimchi/templates/test'})
+ task = json.loads(self.request('/plugins/kimchi/vms',
+ req, 'POST').read())
wait_task(self._task_lookup, task['id'])
- resp = self.request('/vms/test-vm-%i' % i, {}, 'GET')
+ resp = self.request('/plugins/kimchi/vms/test-vm-%i' % i, {},
'GET')
self.assertEquals(resp.status, 200)
- count = len(json.loads(self.request('/vms').read()))
+ count = len(json.loads(self.request('/plugins/kimchi/vms').read()))
self.assertEquals(6, count)
def test_create_vm_without_template(self):
req = json.dumps({'name': 'vm-without-template'})
- resp = self.request('/vms', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(400, resp.status)
resp = json.loads(resp.read())
self.assertIn(u"KCHVM0016E:", resp['reason'])
@@ -870,32 +877,32 @@ class RestTests(unittest.TestCase):
def test_create_vm_with_bad_template_uri(self):
req = json.dumps({'name': 'vm-bad-template',
'template': '/mytemplate'})
- resp = self.request('/vms', req, 'POST')
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(400, resp.status)
resp = json.loads(resp.read())
self.assertIn(u"KCHVM0012E", resp['reason'])
def test_create_vm_with_img_based_template(self):
resp = json.loads(
- self.request('/storagepools/default-pool/storagevolumes').read())
+
self.request('/plugins/kimchi/storagepools/default-pool/storagevolumes').read())
self.assertEquals(0, len(resp))
# Create a Template
mock_base = '/tmp/mock.img'
open(mock_base, 'w').close()
req = json.dumps({'name': 'test', 'disks':
[{'base': mock_base}]})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
- req = json.dumps({'template': '/templates/test'})
- resp = self.request('/vms', req, 'POST')
+ req = json.dumps({'template': '/plugins/kimchi/templates/test'})
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
# Test storage volume created with backing store of base file
resp = json.loads(
- self.request('/storagepools/default-pool/storagevolumes').read())
+
self.request('/plugins/kimchi/storagepools/default-pool/storagevolumes').read())
self.assertEquals(1, len(resp))
def _create_pool(self, name):
@@ -904,24 +911,24 @@ class RestTests(unittest.TestCase):
'allocated': 5120,
'path': '/var/lib/libvirt/images/',
'type': 'dir'})
- resp = self.request('/storagepools', req, 'POST')
+ resp = self.request('/plugins/kimchi/storagepools', req, 'POST')
self.assertEquals(201, resp.status)
# Verify the storage pool
- storagepool = json.loads(self.request('/storagepools/%s'
+ storagepool = json.loads(self.request('/plugins/kimchi/storagepools/%s'
% name).read())
self.assertEquals('inactive', storagepool['state'])
return name
def _delete_pool(self, name):
# Delete the storage pool
- resp = self.request('/storagepools/%s' % name, '{}',
'DELETE')
+ resp = self.request('/plugins/kimchi/storagepools/%s' % name,
'{}', 'DELETE')
self.assertEquals(204, resp.status)
def test_iso_scan_shallow(self):
# fake environment preparation
self._create_pool('pool-3')
- self.request('/storagepools/pool-3/activate', '{}',
'POST')
+ self.request('/plugins/kimchi/storagepools/pool-3/activate',
'{}', 'POST')
params = {'name': 'fedora.iso',
'capacity': 1073741824, # 1 GiB
'type': 'file',
@@ -930,7 +937,7 @@ class RestTests(unittest.TestCase):
wait_task(self._task_lookup, task_info['id'])
storagevolume = json.loads(self.request(
- '/storagepools/kimchi_isos/storagevolumes/').read())[0]
+
'/plugins/kimchi/storagepools/kimchi_isos/storagevolumes/').read())[0]
self.assertEquals('fedora.iso', storagevolume['name'])
self.assertEquals('iso', storagevolume['format'])
self.assertEquals('/var/lib/libvirt/images/fedora.iso',
@@ -948,83 +955,84 @@ class RestTests(unittest.TestCase):
'cdrom': storagevolume['path'],
'os_distro': storagevolume['os_distro'],
'os_version': storagevolume['os_version']})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
# Verify the template
- t = json.loads(self.request('/templates/test').read())
+ t = json.loads(self.request('/plugins/kimchi/templates/test').read())
self.assertEquals('test', t['name'])
self.assertEquals('fedora', t['os_distro'])
self.assertEquals('17', t['os_version'])
self.assertEquals(get_template_default('old', 'memory'),
t['memory'])
# Deactivate or destroy scan pool return 405
- resp = self.request('/storagepools/kimchi_isos/storagevolumes'
+ resp =
self.request('/plugins/kimchi/storagepools/kimchi_isos/storagevolumes'
'/deactivate', '{}', 'POST')
self.assertEquals(405, resp.status)
- resp = self.request('/storagepools/kimchi_isos/storagevolumes',
+ resp =
self.request('/plugins/kimchi/storagepools/kimchi_isos/storagevolumes',
'{}', 'DELETE')
self.assertEquals(405, resp.status)
# Delete the template
- resp = self.request('/templates/%s' % t['name'], '{}',
'DELETE')
+ resp = self.request('/plugins/kimchi/templates/%s' % t['name'],
'{}', 'DELETE')
self.assertEquals(204, resp.status)
- resp = self.request('/storagepools/pool-3/deactivate', '{}',
'POST')
+ resp = self.request('/plugins/kimchi/storagepools/pool-3/deactivate',
'{}', 'POST')
self.assertEquals(200, resp.status)
self._delete_pool('pool-3')
def test_screenshot_refresh(self):
# Create a VM
req = json.dumps({'name': 'test', 'cdrom': fake_iso})
- resp = self.request('/templates', req, 'POST')
- req = json.dumps({'name': 'test-vm', 'template':
'/templates/test'})
- resp = self.request('/vms', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
+ req = json.dumps({'name': 'test-vm',
+ 'template': '/plugins/kimchi/templates/test'})
+ resp = self.request('/plugins/kimchi/vms', req, 'POST')
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
# Test screenshot for shut-off state vm
- resp = self.request('/vms/test-vm/screenshot')
+ resp = self.request('/plugins/kimchi/vms/test-vm/screenshot')
self.assertEquals(404, resp.status)
# Test screenshot for running vm
- resp = self.request('/vms/test-vm/start', '{}', 'POST')
- vm = json.loads(self.request('/vms/test-vm').read())
+ resp = self.request('/plugins/kimchi/vms/test-vm/start', '{}',
'POST')
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
resp = self.request(vm['screenshot'], method='HEAD')
self.assertEquals(200, resp.status)
self.assertTrue(resp.getheader('Content-type').startswith('image'))
# Test screenshot sub-resource redirect
- resp = self.request('/vms/test-vm/screenshot')
+ resp = self.request('/plugins/kimchi/vms/test-vm/screenshot')
self.assertEquals(200, resp.status)
self.assertEquals('image/png', resp.getheader('content-type'))
lastMod1 = resp.getheader('last-modified')
# Take another screenshot instantly and compare the last Modified date
- resp = self.request('/vms/test-vm/screenshot')
+ resp = self.request('/plugins/kimchi/vms/test-vm/screenshot')
lastMod2 = resp.getheader('last-modified')
self.assertEquals(lastMod2, lastMod1)
- resp = self.request('/vms/test-vm/screenshot', '{}',
'DELETE')
+ resp = self.request('/plugins/kimchi/vms/test-vm/screenshot',
'{}', 'DELETE')
self.assertEquals(405, resp.status)
# No screenshot after stopped the VM
- self.request('/vms/test-vm/poweroff', '{}', 'POST')
- resp = self.request('/vms/test-vm/screenshot')
+ self.request('/plugins/kimchi/vms/test-vm/poweroff', '{}',
'POST')
+ resp = self.request('/plugins/kimchi/vms/test-vm/screenshot')
self.assertEquals(404, resp.status)
# Picture link not available after VM deleted
- self.request('/vms/test-vm/start', '{}', 'POST')
- vm = json.loads(self.request('/vms/test-vm').read())
+ self.request('/plugins/kimchi/vms/test-vm/start', '{}',
'POST')
+ vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
img_lnk = vm['screenshot']
- self.request('/vms/test-vm', '{}', 'DELETE')
+ self.request('/plugins/kimchi/vms/test-vm', '{}',
'DELETE')
resp = self.request(img_lnk)
self.assertEquals(404, resp.status)
def test_interfaces(self):
- resp = self.request('/interfaces').read()
+ resp = self.request('/plugins/kimchi/interfaces').read()
self.assertIn('name', resp)
interfaces = json.loads(resp)
keys = ['name', 'type', 'ipaddr', 'netmask',
'status']
@@ -1032,39 +1040,39 @@ class RestTests(unittest.TestCase):
self.assertEquals(sorted(keys), sorted(interface.keys()))
def _task_lookup(self, taskid):
- return json.loads(self.request('/tasks/%s' % taskid).read())
+ return json.loads(self.request('/plugins/kimchi/tasks/%s' %
taskid).read())
def test_tasks(self):
- id1 = add_task('/tasks/1', self._async_op, model.objstore)
- id2 = add_task('/tasks/2', self._except_op, model.objstore)
- id3 = add_task('/tasks/3', self._intermid_op, model.objstore)
+ id1 = add_task('/plugins/kimchi/tasks/1', self._async_op,
model.objstore)
+ id2 = add_task('/plugins/kimchi/tasks/2', self._except_op,
model.objstore)
+ id3 = add_task('/plugins/kimchi/tasks/3', self._intermid_op,
model.objstore)
target_uri = urllib2.quote('^/tasks/*', safe="")
filter_data = 'status=running&target_uri=%s' % target_uri
- tasks = json.loads(self.request('/tasks?%s' % filter_data).read())
+ tasks = json.loads(self.request('/plugins/kimchi/tasks?%s' %
filter_data).read())
self.assertEquals(3, len(tasks))
- tasks = json.loads(self.request('/tasks').read())
+ tasks = json.loads(self.request('/plugins/kimchi/tasks').read())
tasks_ids = [int(t['id']) for t in tasks]
self.assertEquals(set([id1, id2, id3]) - set(tasks_ids), set([]))
wait_task(self._task_lookup, id2)
- foo2 = json.loads(self.request('/tasks/%s' % id2).read())
+ foo2 = json.loads(self.request('/plugins/kimchi/tasks/%s' % id2).read())
keys = ['id', 'status', 'message', 'target_uri']
self.assertEquals(sorted(keys), sorted(foo2.keys()))
self.assertEquals('failed', foo2['status'])
wait_task(self._task_lookup, id3)
- foo3 = json.loads(self.request('/tasks/%s' % id3).read())
+ foo3 = json.loads(self.request('/plugins/kimchi/tasks/%s' % id3).read())
self.assertEquals('in progress', foo3['message'])
self.assertEquals('running', foo3['status'])
def test_config(self):
- resp = self.request('/config').read()
+ resp = self.request('/plugins/kimchi/config').read()
conf = json.loads(resp)
keys = ["display_proxy_port", "version"]
self.assertEquals(keys, sorted(conf.keys()))
def test_capabilities(self):
- resp = self.request('/config/capabilities').read()
+ resp = self.request('/plugins/kimchi/config/capabilities').read()
conf = json.loads(resp)
keys = [u'libvirt_stream_protocols', u'qemu_stream',
u'qemu_spice',
@@ -1074,11 +1082,11 @@ class RestTests(unittest.TestCase):
self.assertEquals(sorted(keys), sorted(conf.keys()))
def test_peers(self):
- resp = self.request('/peers').read()
+ resp = self.request('/plugins/kimchi/peers').read()
self.assertEquals([], json.loads(resp))
def test_distros(self):
- resp = self.request('/config/distros').read()
+ resp = self.request('/plugins/kimchi/config/distros').read()
distros = json.loads(resp)
for distro in distros:
self.assertIn('name', distro)
@@ -1088,7 +1096,8 @@ class RestTests(unittest.TestCase):
# Test in X86
ident = "Fedora 20"
- resp = self.request('/config/distros/%s' % urllib2.quote(ident)).read()
+ resp = self.request('/plugins/kimchi/config/distros/%s' %
+ urllib2.quote(ident)).read()
distro = json.loads(resp)
if os.uname()[4] in ['x86_64', 'amd64']:
self.assertEquals(distro['name'], ident)
@@ -1102,7 +1111,8 @@ class RestTests(unittest.TestCase):
# Test in PPC
ident = "Fedora 20 (PPC64)"
- resp = self.request('/config/distros/%s' % urllib2.quote(ident)).read()
+ resp = self.request('/plugins/kimchi/config/distros/%s' %
+ urllib2.quote(ident)).read()
distro = json.loads(resp)
if os.uname()[4] == 'ppc64':
self.assertEquals(distro['name'], ident)
@@ -1115,48 +1125,48 @@ class RestTests(unittest.TestCase):
self.assertIn('KCHDISTRO0001E', distro.get('reason'))
def test_debugreports(self):
- resp = request(host, ssl_port, '/debugreports')
+ resp = request(host, ssl_port, '/plugins/kimchi/debugreports')
self.assertEquals(200, resp.status)
def _report_delete(self, name):
- request(host, ssl_port, '/debugreports/%s' % name, '{}',
'DELETE')
+ request(host, ssl_port, '/plugins/kimchi/debugreports/%s' % name,
'{}', 'DELETE')
def test_create_debugreport(self):
req = json.dumps({'name': 'report1'})
with RollbackContext() as rollback:
- resp = request(host, ssl_port, '/debugreports', req, 'POST')
+ resp = request(host, ssl_port, '/plugins/kimchi/debugreports', req,
'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
# make sure the debugreport doesn't exist until the
# the task is finished
wait_task(self._task_lookup, task['id'])
rollback.prependDefer(self._report_delete, 'report2')
- resp = request(host, ssl_port, '/debugreports/report1')
+ resp = request(host, ssl_port,
'/plugins/kimchi/debugreports/report1')
debugreport = json.loads(resp.read())
self.assertEquals("report1", debugreport['name'])
self.assertEquals(200, resp.status)
req = json.dumps({'name': 'report2'})
- resp = request(host, ssl_port, '/debugreports/report1',
+ resp = request(host, ssl_port,
'/plugins/kimchi/debugreports/report1',
req, 'PUT')
self.assertEquals(303, resp.status)
def test_debugreport_download(self):
req = json.dumps({'name': 'report1'})
with RollbackContext() as rollback:
- resp = request(host, ssl_port, '/debugreports', req, 'POST')
+ resp = request(host, ssl_port, '/plugins/kimchi/debugreports', req,
'POST')
self.assertEquals(202, resp.status)
task = json.loads(resp.read())
# make sure the debugreport doesn't exist until the
# the task is finished
wait_task(self._task_lookup, task['id'], 20)
rollback.prependDefer(self._report_delete, 'report1')
- resp = request(host, ssl_port, '/debugreports/report1')
+ resp = request(host, ssl_port,
'/plugins/kimchi/debugreports/report1')
debugreport = json.loads(resp.read())
self.assertEquals("report1", debugreport['name'])
self.assertEquals(200, resp.status)
- resp = request(host, ssl_port, '/debugreports/report1/content')
+ resp = request(host, ssl_port,
'/plugins/kimchi/debugreports/report1/content')
self.assertEquals(200, resp.status)
- resp = request(host, ssl_port, '/debugreports/report1')
+ resp = request(host, ssl_port,
'/plugins/kimchi/debugreports/report1')
debugre = json.loads(resp.read())
resp = request(host, ssl_port, debugre['uri'])
self.assertEquals(200, resp.status)
@@ -1167,7 +1177,7 @@ class RestTests(unittest.TestCase):
if field in t.keys():
self.assertEquals(t[field], res[field])
- base_uri = '/host/repositories'
+ base_uri = '/plugins/kimchi/host/repositories'
resp = self.request(base_uri)
self.assertEquals(200, resp.status)
# Already have one repo in Kimchi's system
diff --git a/plugins/kimchi/tests/test_server.py b/plugins/kimchi/tests/test_server.py
index 228a9b5..48a8589 100644
--- a/plugins/kimchi/tests/test_server.py
+++ b/plugins/kimchi/tests/test_server.py
@@ -132,13 +132,13 @@ class ServerTests(unittest.TestCase):
"""
A non-existent path should return HTTP:404
"""
- url_list = ['/doesnotexist', '/vms/blah']
+ url_list = ['/plugins/kimchi/doesnotexist',
'/plugins/kimchi/vms/blah']
for url in url_list:
resp = self.request(url)
self.assertEquals(404, resp.status)
# Verify it works for DELETE too
- resp = self.request('/templates/blah', '', 'DELETE')
+ resp = self.request('/plugins/kimchi/templates/blah', '',
'DELETE')
self.assertEquals(404, resp.status)
def test_accepts(self):
@@ -177,10 +177,10 @@ class ServerTests(unittest.TestCase):
def test_auth_unprotected(self):
hdrs = {'AUTHORIZATION': ''}
- uris = ['/js/kimchi.min.js',
- '/css/theme-default.min.css',
+ uris = ['/plugins/kimchi/js/kimchi.min.js',
+ '/plugins/kimchi/css/theme-default.min.css',
+ '/plugins/kimchi/images/icon-vm.png',
'/libs/jquery-1.10.0.min.js',
- '/images/icon-vm.png',
'/login.html',
'/logout']
@@ -190,9 +190,9 @@ class ServerTests(unittest.TestCase):
def test_auth_protected(self):
hdrs = {'AUTHORIZATION': ''}
- uris = ['/vms',
- '/vms/doesnotexist',
- '/tasks']
+ uris = ['/plugins/kimchi/vms',
+ '/plugins/kimchi/vms/doesnotexist',
+ '/plugins/kimchi/tasks']
for uri in uris:
resp = self.request(uri, None, 'GET', hdrs)
@@ -201,7 +201,7 @@ class ServerTests(unittest.TestCase):
def test_auth_bad_creds(self):
# Test HTTPBA
hdrs = {'AUTHORIZATION': "Basic " +
base64.b64encode("nouser:badpass")}
- resp = self.request('/vms', None, 'GET', hdrs)
+ resp = self.request('/plugins/kimchi/vms', None, 'GET', hdrs)
self.assertEquals(401, resp.status)
# Test REST API
@@ -216,7 +216,7 @@ class ServerTests(unittest.TestCase):
hdrs = {"X-Requested-With": "XMLHttpRequest"}
# Try our request (Note that request() will add a valid HTTPBA header)
- resp = self.request('/vms', None, 'GET', hdrs)
+ resp = self.request('/plugins/kimchi/vms', None, 'GET', hdrs)
self.assertEquals(401, resp.status)
self.assertEquals(None, resp.getheader('WWW-Authenticate'))
@@ -226,7 +226,7 @@ class ServerTests(unittest.TestCase):
'Accept': 'application/json'}
# Test we are logged out
- resp = self.request('/tasks', None, 'GET', hdrs)
+ resp = self.request('/plugins/kimchi/tasks', None, 'GET', hdrs)
self.assertEquals(401, resp.status)
# Execute a login call
@@ -246,7 +246,7 @@ class ServerTests(unittest.TestCase):
hdrs['Cookie'] = cookie
# Test we are logged in with the cookie
- resp = self.request('/tasks', None, 'GET', hdrs)
+ resp = self.request('/plugins/kimchi/tasks', None, 'GET', hdrs)
self.assertEquals(200, resp.status)
# Execute a logout call
@@ -255,7 +255,7 @@ class ServerTests(unittest.TestCase):
del hdrs['Cookie']
# Test we are logged out
- resp = self.request('/tasks', None, 'GET', hdrs)
+ resp = self.request('/plugins/kimchi/tasks', None, 'GET', hdrs)
self.assertEquals(401, resp.status)
def test_get_param(self):
@@ -265,22 +265,22 @@ class ServerTests(unittest.TestCase):
# Create 2 different templates
req = json.dumps({'name': 'test-tmpl1', 'cdrom':
mockiso})
- self.request('/templates', req, 'POST')
+ self.request('/plugins/kimchi/templates', req, 'POST')
req = json.dumps({'name': 'test-tmpl2', 'cdrom':
mockiso})
- self.request('/templates', req, 'POST')
+ self.request('/plugins/kimchi/templates', req, 'POST')
# Remove mock iso
os.unlink(mockiso)
# Get the templates
- resp = self.request('/templates')
+ resp = self.request('/plugins/kimchi/templates')
self.assertEquals(200, resp.status)
res = json.loads(resp.read())
self.assertEquals(2, len(res))
# Get a specific template
- resp = self.request('/templates?name=test-tmpl1')
+ resp = self.request('/plugins/kimchi/templates?name=test-tmpl1')
self.assertEquals(200, resp.status)
res = json.loads(resp.read())
self.assertEquals(1, len(res))
diff --git a/plugins/kimchi/tests/test_template.py
b/plugins/kimchi/tests/test_template.py
index b263b63..a1a828b 100644
--- a/plugins/kimchi/tests/test_template.py
+++ b/plugins/kimchi/tests/test_template.py
@@ -61,58 +61,58 @@ class TemplateTests(unittest.TestCase):
model.reset()
def test_tmpl_lifecycle(self):
- resp = self.request('/templates')
+ resp = self.request('/plugins/kimchi/templates')
self.assertEquals(200, resp.status)
self.assertEquals(0, len(json.loads(resp.read())))
# Create a template without cdrom and disk specified fails with 400
t = {'name': 'test', 'os_distro': 'ImagineOS',
'os_version': '1.0', 'memory': 1024, 'cpus':
1,
- 'storagepool': '/storagepools/alt'}
+ 'storagepool': '/plugins/kimchi/storagepools/alt'}
req = json.dumps(t)
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(400, resp.status)
# Create a template
t = {'name': 'test', 'cdrom': '/tmp/mock.iso'}
req = json.dumps(t)
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
# Verify the template
keys = ['name', 'icon', 'invalid', 'os_distro',
'os_version', 'cpus',
'memory', 'cdrom', 'disks',
'storagepool', 'networks',
'folder', 'graphics', 'cpu_info']
- tmpl = json.loads(self.request('/templates/test').read())
+ tmpl = json.loads(self.request('/plugins/kimchi/templates/test').read())
self.assertEquals(sorted(tmpl.keys()), sorted(keys))
# Verify if default disk format was configured
self.assertEquals(tmpl['disks'][0]['format'], 'qcow2')
# Clone a template
- resp = self.request('/templates/test/clone', '{}',
'POST')
+ resp = self.request('/plugins/kimchi/templates/test/clone', '{}',
'POST')
self.assertEquals(303, resp.status)
# Verify the cloned template
- tmpl_cloned = json.loads(self.request('/templates/test-clone1').read())
+ tmpl_cloned =
json.loads(self.request('/plugins/kimchi/templates/test-clone1').read())
del tmpl['name']
del tmpl_cloned['name']
self.assertEquals(tmpl, tmpl_cloned)
# Delete the cloned template
- resp = self.request('/templates/test-clone1', '{}',
'DELETE')
+ resp = self.request('/plugins/kimchi/templates/test-clone1',
'{}', 'DELETE')
self.assertEquals(204, resp.status)
# Create a template with same name fails with 400
req = json.dumps({'name': 'test', 'cdrom':
'/tmp/mock.iso'})
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(400, resp.status)
# Create an image based template
open('/tmp/mock.img', 'w').close()
t = {'name': 'test_img_template', 'disks':
[{'base': '/tmp/mock.img'}]}
req = json.dumps(t)
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
os.remove('/tmp/mock.img')
@@ -120,24 +120,24 @@ class TemplateTests(unittest.TestCase):
t = {'name': 'test-format', 'cdrom':
'/tmp/mock.iso',
'disks': [{'index': 0, 'size': 10, 'format':
'vmdk'}]}
req = json.dumps(t)
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
- tmpl = json.loads(self.request('/templates/test-format').read())
+ tmpl =
json.loads(self.request('/plugins/kimchi/templates/test-format').read())
self.assertEquals(tmpl['disks'][0]['format'], 'vmdk')
def test_customized_tmpl(self):
# Create a template
t = {'name': 'test', 'cdrom': '/tmp/mock.iso'}
req = json.dumps(t)
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
- tmpl = json.loads(self.request('/templates/test').read())
+ tmpl = json.loads(self.request('/plugins/kimchi/templates/test').read())
# Update name
new_name = u'kīмсhīTmpl'
- new_tmpl_uri = '/templates/%s' % new_name.encode('utf-8')
+ new_tmpl_uri = '/plugins/kimchi/templates/%s' %
new_name.encode('utf-8')
req = json.dumps({'name': new_name})
- resp = self.request('/templates/test', req, 'PUT')
+ resp = self.request('/plugins/kimchi/templates/test', req,
'PUT')
self.assertEquals(303, resp.status)
resp = self.request(new_tmpl_uri)
update_tmpl = json.loads(resp.read())
@@ -147,11 +147,11 @@ class TemplateTests(unittest.TestCase):
self.assertEquals(tmpl, update_tmpl)
# Update icon
- req = json.dumps({'icon': 'images/icon-fedora.png'})
+ req = json.dumps({'icon': 'kimchi/images/icon-fedora.png'})
resp = self.request(new_tmpl_uri, req, 'PUT')
self.assertEquals(200, resp.status)
update_tmpl = json.loads(resp.read())
- self.assertEquals('images/icon-fedora.png', update_tmpl['icon'])
+ self.assertEquals('kimchi/images/icon-fedora.png',
update_tmpl['icon'])
# Update os_distro and os_version
req = json.dumps({'os_distro': 'fedora', 'os_version':
'21'})
@@ -246,7 +246,7 @@ class TemplateTests(unittest.TestCase):
# Create a template
t = {'name': 'test', 'cdrom': '/tmp/mock.iso'}
req = json.dumps(t)
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
# Create networks to be used for testing
@@ -257,7 +257,7 @@ class TemplateTests(unittest.TestCase):
# Verify the current system has at least one interface to create a
# bridged network
- interfaces = json.loads(self.request('/interfaces?type=nic').read())
+ interfaces =
json.loads(self.request('/plugins/kimchi/interfaces?type=nic').read())
if len(interfaces) > 0:
iface = interfaces[0]['name']
networks.append({'name': u'bridge-network',
'connection': 'bridge',
@@ -267,25 +267,25 @@ class TemplateTests(unittest.TestCase):
tmpl_nets = []
for net in networks:
- self.request('/networks', json.dumps(net), 'POST')
+ self.request('/plugins/kimchi/networks', json.dumps(net),
'POST')
tmpl_nets.append(net['name'])
req = json.dumps({'networks': tmpl_nets})
- resp = self.request('/templates/test', req, 'PUT')
+ resp = self.request('/plugins/kimchi/templates/test', req,
'PUT')
self.assertEquals(200, resp.status)
def test_customized_storagepool(self):
# Create a template
t = {'name': 'test', 'cdrom': '/tmp/mock.iso'}
req = json.dumps(t)
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
# MockModel always returns 2 partitions (vdx, vdz)
- partitions = json.loads(self.request('/host/partitions').read())
+ partitions =
json.loads(self.request('/plugins/kimchi/host/partitions').read())
devs = [dev['path'] for dev in partitions]
# MockModel always returns 3 FC devices
- fc_devs = json.loads(self.request('/host/devices?_cap=fc_host').read())
+ fc_devs =
json.loads(self.request('/plugins/kimchi/host/devices?_cap=fc_host').read())
fc_devs = [dev['name'] for dev in fc_devs]
poolDefs = [
@@ -303,8 +303,8 @@ class TemplateTests(unittest.TestCase):
'source': {'devices': [devs[0]]}}]
for pool in poolDefs:
- self.request('/storagepools', json.dumps(pool), 'POST')
- pool_uri = '/storagepools/%s' %
pool['name'].encode('utf-8')
+ self.request('/plugins/kimchi/storagepools', json.dumps(pool),
'POST')
+ pool_uri = '/plugins/kimchi/storagepools/%s' %
pool['name'].encode('utf-8')
self.request(pool_uri + '/activate', '{}', 'POST')
req = None
@@ -319,44 +319,44 @@ class TemplateTests(unittest.TestCase):
req = json.dumps({'storagepool': pool_uri})
if req is not None:
- resp = self.request('/templates/test', req, 'PUT')
+ resp = self.request('/plugins/kimchi/templates/test', req,
'PUT')
self.assertEquals(200, resp.status)
def test_tmpl_integrity(self):
# Create a network and a pool for testing template integrity
net = {'name': u'nat-network', 'connection':
'nat'}
- self.request('/networks', json.dumps(net), 'POST')
+ self.request('/plugins/kimchi/networks', json.dumps(net),
'POST')
pool = {'type': 'dir', 'name': 'dir-pool',
'path': '/tmp/dir-pool'}
- self.request('/storagepools', json.dumps(pool), 'POST')
- pool_uri = '/storagepools/%s' %
pool['name'].encode('utf-8')
+ self.request('/plugins/kimchi/storagepools', json.dumps(pool),
'POST')
+ pool_uri = '/plugins/kimchi/storagepools/%s' %
pool['name'].encode('utf-8')
self.request(pool_uri + '/activate', '{}', 'POST')
# Create a template using the custom network and pool
t = {'name': 'test', 'cdrom': '/tmp/mock.iso',
'networks': ['nat-network'],
- 'storagepool': '/storagepools/dir-pool'}
+ 'storagepool': '/plugins/kimchi/storagepools/dir-pool'}
req = json.dumps(t)
- resp = self.request('/templates', req, 'POST')
+ resp = self.request('/plugins/kimchi/templates', req, 'POST')
self.assertEquals(201, resp.status)
# Try to delete network
# It should fail as it is associated to a template
- resp = self.request('/networks/nat-network', '{}',
'DELETE')
+ resp = self.request('/plugins/kimchi/networks/nat-network', '{}',
'DELETE')
self.assertIn("KCHNET0017E",
json.loads(resp.read())["reason"])
# Update template to release network and then delete it
params = {'networks': []}
req = json.dumps(params)
- self.request('/templates/test', req, 'PUT')
- resp = self.request('/networks/nat-network', '{}',
'DELETE')
+ self.request('/plugins/kimchi/templates/test', req, 'PUT')
+ resp = self.request('/plugins/kimchi/networks/nat-network', '{}',
'DELETE')
self.assertEquals(204, resp.status)
# Try to delete the storagepool
# It should fail as it is associated to a template
- resp = self.request('/storagepools/dir-pool', '{}',
'DELETE')
+ resp = self.request('/plugins/kimchi/storagepools/dir-pool',
'{}', 'DELETE')
self.assertEquals(400, resp.status)
# Verify the template
- res = json.loads(self.request('/templates/test').read())
+ res = json.loads(self.request('/plugins/kimchi/templates/test').read())
self.assertEquals(res['invalid']['cdrom'],
['/tmp/mock.iso'])
diff --git a/plugins/kimchi/ui/css/theme-default/guest-edit.css
b/plugins/kimchi/ui/css/theme-default/guest-edit.css
index 1cb5ff8..93e0201 100644
--- a/plugins/kimchi/ui/css/theme-default/guest-edit.css
+++ b/plugins/kimchi/ui/css/theme-default/guest-edit.css
@@ -128,7 +128,7 @@
}
.guest-edit-snapshot .icon {
- background: url('../../images/theme-default/kimchi-loading15x15.gif')
no-repeat;
+ background: url('../images/theme-default/kimchi-loading15x15.gif')
no-repeat;
display: block;
width: 16px;
height: 16px;
@@ -250,12 +250,12 @@
}
.guest-edit-permission .pam .body .item .user-icon {
- background: url('/images/theme-default/user.png') no-repeat scroll;
+ background: url('../images/theme-default/user.png') no-repeat scroll;
background-size: 15px 15px;
}
.guest-edit-permission .pam .body .item .group-icon {
- background: url('/images/theme-default/group.png') no-repeat scroll;
+ background: url('../images/theme-default/group.png') no-repeat scroll;
background-size: 15px 15px;
}
diff --git a/plugins/kimchi/ui/css/theme-default/host.css
b/plugins/kimchi/ui/css/theme-default/host.css
index 9e9cb01..a0cccb1 100644
--- a/plugins/kimchi/ui/css/theme-default/host.css
+++ b/plugins/kimchi/ui/css/theme-default/host.css
@@ -33,7 +33,7 @@
}
.host-panel .logo {
- background: url("../images/icon-vm.png") no-repeat left top;
+ background: url("plugins/kimchi/images/icon-vm.png") no-repeat left top;
height: 128px;
width: 128px;
}
@@ -220,7 +220,7 @@
}
#id-debug-img {
- background: url(../../images/theme-default/kimchi-loading15x15.gif) 12px
+ background: url(../images/theme-default/kimchi-loading15x15.gif) 12px
center no-repeat;
padding-left: 23px;
}
diff --git a/plugins/kimchi/ui/css/theme-default/list.css
b/plugins/kimchi/ui/css/theme-default/list.css
index 718c855..8c78623 100644
--- a/plugins/kimchi/ui/css/theme-default/list.css
+++ b/plugins/kimchi/ui/css/theme-default/list.css
@@ -312,7 +312,7 @@
}
.guest-pending .icon {
- background: url('../../images/theme-default/kimchi-loading15x15.gif')
no-repeat;
+ background: url('../images/theme-default/kimchi-loading15x15.gif')
no-repeat;
display: inline-block;
width: 20px;
height: 20px;
diff --git a/plugins/kimchi/ui/css/theme-default/network.css
b/plugins/kimchi/ui/css/theme-default/network.css
index 5d07468..30d310e 100644
--- a/plugins/kimchi/ui/css/theme-default/network.css
+++ b/plugins/kimchi/ui/css/theme-default/network.css
@@ -137,7 +137,7 @@
}
.network .list .nw-loading {
- background: #c0c0c0 url(../../images/theme-default/loading.gif)
+ background: #c0c0c0 url(../images/theme-default/loading.gif)
center no-repeat;
}
@@ -316,4 +316,4 @@
.ui-state-default a {
color: #212121;
-}
\ No newline at end of file
+}
diff --git a/plugins/kimchi/ui/css/theme-default/report-rename.css
b/plugins/kimchi/ui/css/theme-default/report-rename.css
index 1722005..3d70dab 100644
--- a/plugins/kimchi/ui/css/theme-default/report-rename.css
+++ b/plugins/kimchi/ui/css/theme-default/report-rename.css
@@ -32,7 +32,7 @@
}
#button-report-rename[disabled] {
- background: #c0c0c0 url(../../images/theme-default/loading.gif) 7px
+ background: #c0c0c0 url(../images/theme-default/loading.gif) 7px
center no-repeat;
color: #DDD;
prenameing-left: 26px;
diff --git a/plugins/kimchi/ui/css/theme-default/storage.css
b/plugins/kimchi/ui/css/theme-default/storage.css
index 0610278..519a28b 100644
--- a/plugins/kimchi/ui/css/theme-default/storage.css
+++ b/plugins/kimchi/ui/css/theme-default/storage.css
@@ -593,7 +593,7 @@
#pool-loading {
margin: 10px 15px;
- background: #C0C0C0 url(../../images/theme-default/loading.gif) 7px
+ background: #C0C0C0 url(../images/theme-default/loading.gif) 7px
center no-repeat;
padding: 0 20px 0 26px;
}
diff --git a/plugins/kimchi/ui/css/theme-default/template_add.css
b/plugins/kimchi/ui/css/theme-default/template_add.css
index a9bafa4..de5491f 100644
--- a/plugins/kimchi/ui/css/theme-default/template_add.css
+++ b/plugins/kimchi/ui/css/theme-default/template_add.css
@@ -171,7 +171,7 @@
margin: 0 5px 0 0;
border: 1px solid #CCCCCC;
border-radius: 8px;
- background: url(../../images/icon-vm.png) center center no-repeat;
+ background: url(../images/icon-vm.png) center center no-repeat;
background-size: 58px;
}
@@ -280,13 +280,13 @@
#iso-search-loading {
margin: 10px 15px;
- background: #C0C0C0 url(../../images/theme-default/loading.gif) 7px
+ background: #C0C0C0 url(../images/theme-default/loading.gif) 7px
center no-repeat;
padding: 0 20px 0 26px;
}
#iso-more-loading {
- background: #C0C0C0 url(../../images/theme-default/loading.gif) 7px
+ background: #C0C0C0 url(../images/theme-default/loading.gif) 7px
center no-repeat;
padding: 0 20px 0 26px;
}
diff --git a/plugins/kimchi/ui/js/src/kimchi.api.js
b/plugins/kimchi/ui/js/src/kimchi.api.js
index 81e44fd..d4d0c83 100644
--- a/plugins/kimchi/ui/js/src/kimchi.api.js
+++ b/plugins/kimchi/ui/js/src/kimchi.api.js
@@ -17,8 +17,6 @@
*/
var kimchi = {
- url : "../../../",
-
widget: {},
trackingTasks: [],
@@ -54,7 +52,7 @@ var kimchi = {
getCapabilities : function(suc, err, done) {
done = typeof done !== 'undefined' ? done: function(){};
wok.requestJSON({
- url : "config/capabilities",
+ url : "plugins/kimchi/config/capabilities",
type : "GET",
contentType : "application/json",
dataType : "json",
@@ -69,7 +67,7 @@ var kimchi = {
*/
getI18n: function(suc, err, url, sync) {
wok.requestJSON({
- url : url ? url : 'i18n.json',
+ url : url ? url : 'plugins/kimchi/i18n.json',
type : 'GET',
resend: true,
dataType : 'json',
@@ -84,7 +82,7 @@ var kimchi = {
*/
getHost: function(suc, err) {
wok.requestJSON({
- url : 'host',
+ url : 'plugins/kimchi/host',
type : 'GET',
resend: true,
contentType : 'application/json',
@@ -99,7 +97,7 @@ var kimchi = {
*/
getHostStats : function(suc, err) {
wok.requestJSON({
- url : 'host/stats',
+ url : 'plugins/kimchi/host/stats',
type : 'GET',
contentType : 'application/json',
headers: {'Wok-Robot': 'wok-robot'},
@@ -114,7 +112,7 @@ var kimchi = {
*/
getHostStatsHistory : function(suc, err) {
wok.requestJSON({
- url : 'host/stats/history',
+ url : 'plugins/kimchi/host/stats/history',
type : 'GET',
resend: true,
contentType : 'application/json',
@@ -138,7 +136,7 @@ var kimchi = {
*/
createVM : function(settings, suc, err) {
wok.requestJSON({
- url : "vms",
+ url : "plugins/kimchi/vms",
type : "POST",
contentType : "application/json",
data : JSON.stringify(settings),
@@ -154,7 +152,7 @@ var kimchi = {
*/
createTemplate : function(settings, suc, err) {
wok.requestJSON({
- url : "templates",
+ url : "plugins/kimchi/templates",
type : "POST",
contentType : "application/json",
data : JSON.stringify(settings),
@@ -166,7 +164,7 @@ var kimchi = {
deleteTemplate : function(tem, suc, err) {
wok.requestJSON({
- url : 'templates/' + encodeURIComponent(tem),
+ url : 'plugins/kimchi/templates/' + encodeURIComponent(tem),
type : 'DELETE',
contentType : 'application/json',
dataType : 'json',
@@ -177,7 +175,7 @@ var kimchi = {
cloneTemplate : function(tem, suc, err) {
wok.requestJSON({
- url : 'templates/' + encodeURIComponent(tem) + "/clone",
+ url : 'plugins/kimchi/templates/' + encodeURIComponent(tem) +
"/clone",
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -188,7 +186,7 @@ var kimchi = {
listTemplates : function(suc, err) {
wok.requestJSON({
- url : 'templates',
+ url : 'plugins/kimchi/templates',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -202,7 +200,7 @@ var kimchi = {
*/
retrieveTemplate : function(templateName, suc, err) {
wok.requestJSON({
- url : "templates/" + encodeURIComponent(templateName),
+ url : 'plugins/kimchi/templates/' +
encodeURIComponent(templateName),
type : 'GET',
contentType : 'application/json',
dataType : 'json'
@@ -216,7 +214,7 @@ var kimchi = {
*/
updateTemplate : function(name, settings, suc, err) {
$.ajax({
- url : "templates/" + encodeURIComponent(name),
+ url : 'plugins/kimchi/templates/' + encodeURIComponent(name),
type : 'PUT',
contentType : 'application/json',
data : JSON.stringify(settings),
@@ -232,7 +230,7 @@ var kimchi = {
*/
createStoragePool : function(settings, suc, err) {
wok.requestJSON({
- url : 'storagepools',
+ url : 'plugins/kimchi/storagepools',
type : 'POST',
contentType : 'application/json',
data : JSON.stringify(settings),
@@ -242,7 +240,7 @@ var kimchi = {
updateStoragePool : function(name, content, suc, err) {
$.ajax({
- url : "storagepools/" + encodeURIComponent(name),
+ url : "plugins/kimchi/storagepools/" + encodeURIComponent(name),
type : 'PUT',
contentType : 'application/json',
dataType : 'json',
@@ -254,7 +252,7 @@ var kimchi = {
startVM : function(vm, suc, err) {
wok.requestJSON({
- url : 'vms/' + encodeURIComponent(vm) + '/start',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/start',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -265,7 +263,7 @@ var kimchi = {
poweroffVM : function(vm, suc, err) {
wok.requestJSON({
- url : 'vms/' + encodeURIComponent(vm) + '/poweroff',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/poweroff',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -276,7 +274,7 @@ var kimchi = {
shutdownVM : function(vm, suc, err) {
wok.requestJSON({
- url : 'vms/' + encodeURIComponent(vm) + '/shutdown',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/shutdown',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -287,7 +285,7 @@ var kimchi = {
resetVM : function(vm, suc, err) {
wok.requestJSON({
- url : 'vms/' + encodeURIComponent(vm) + '/reset',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/reset',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -298,7 +296,7 @@ var kimchi = {
suspendVM : function(vm, suc, err) {
wok.requestJSON({
- url : 'vms/' + encodeURIComponent(vm) + '/suspend',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/suspend',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -309,7 +307,7 @@ var kimchi = {
resumeVM : function(vm, suc, err) {
wok.requestJSON({
- url : 'vms/' + encodeURIComponent(vm) + '/resume',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/resume',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -327,7 +325,7 @@ var kimchi = {
*/
retrieveVM : function(vm, suc, err) {
$.ajax({
- url : 'vms/' + encodeURIComponent(vm),
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm),
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -341,7 +339,7 @@ var kimchi = {
*/
updateVM : function(name, settings, suc, err) {
$.ajax({
- url : "vms/" + encodeURIComponent(name),
+ url : "plugins/kimchi/vms/" + encodeURIComponent(name),
type : 'PUT',
contentType : 'application/json',
data : JSON.stringify(settings),
@@ -353,7 +351,7 @@ var kimchi = {
deleteVM : function(vm, suc, err) {
wok.requestJSON({
- url : 'vms/' + encodeURIComponent(vm),
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm),
type : 'DELETE',
contentType : 'application/json',
dataType : 'json',
@@ -364,18 +362,19 @@ var kimchi = {
vncToVM : function(vm) {
wok.requestJSON({
- url : 'config',
+ url : 'plugins/kimchi/config',
type : 'GET',
dataType : 'json'
}).done(function(data, textStatus, xhr) {
proxy_port = data['display_proxy_port'];
wok.requestJSON({
- url : "vms/" + encodeURIComponent(vm) + "/connect",
+ url : "plugins/kimchi/vms/" + encodeURIComponent(vm) +
"/connect",
type : "POST",
dataType : "json"
}).done(function() {
url = 'https://' + location.hostname + ':' + proxy_port;
- url += "/console.html?url=" +
encodeURIComponent("novnc/vnc_auto.html");
+ url += "/console.html?url=";
+ url +=
encodeURIComponent("plugins/kimchi/novnc/vnc_auto.html");
url += "&port=" + proxy_port;
/*
* From python documentation base64.urlsafe_b64encode(s)
@@ -396,19 +395,19 @@ var kimchi = {
spiceToVM : function(vm) {
wok.requestJSON({
- url : 'config',
+ url : 'plugins/kimchi/config',
type : 'GET',
dataType : 'json'
}).done(function(data, textStatus, xhr) {
proxy_port = data['display_proxy_port'];
wok.requestJSON({
- url : "vms/" + encodeURIComponent(vm) + "/connect",
+ url : "plugins/kimchi/vms/" + encodeURIComponent(vm) +
"/connect",
type : "POST",
dataType : "json"
}).done(function(data, textStatus, xhr) {
url = 'https://' + location.hostname + ':' + proxy_port;
- url += "/console.html?url=spice_auto.html&port=" +
proxy_port;
- url += "&listen=" + location.hostname;
+ url += "/console.html?url=plugins/kimchi/spice_auto.html";
+ url += "&port=" + proxy_port + "&listen=" +
location.hostname;
/*
* From python documentation base64.urlsafe_b64encode(s)
* substitutes - instead of + and _ instead of / in the
@@ -428,7 +427,7 @@ var kimchi = {
listVMs : function(suc, err) {
wok.requestJSON({
- url : 'vms',
+ url : 'plugins/kimchi/vms',
type : 'GET',
contentType : 'application/json',
headers: {'Wok-Robot': 'wok-robot'},
@@ -441,7 +440,7 @@ var kimchi = {
listTemplates : function(suc, err) {
wok.requestJSON({
- url : 'templates',
+ url : 'plugins/kimchi/templates',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -453,7 +452,7 @@ var kimchi = {
listStoragePools : function(suc, err) {
wok.requestJSON({
- url : 'storagepools',
+ url : 'plugins/kimchi/storagepools',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -465,7 +464,7 @@ var kimchi = {
listStorageVolumes : function(poolName, suc, err) {
$.ajax({
- url : 'storagepools/' + encodeURIComponent(poolName) +
'/storagevolumes',
+ url : 'plugins/kimchi/storagepools/' + encodeURIComponent(poolName) +
'/storagevolumes',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -476,7 +475,7 @@ var kimchi = {
listIsos : function(suc, err) {
wok.requestJSON({
- url : 'storagepools/kimchi_isos/storagevolumes',
+ url : 'plugins/kimchi/storagepools/kimchi_isos/storagevolumes',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -487,7 +486,7 @@ var kimchi = {
listDistros : function(suc, err) {
wok.requestJSON({
- url : 'config/distros',
+ url : 'plugins/kimchi/config/distros',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -549,7 +548,7 @@ var kimchi = {
getTask : function(taskId, suc, err) {
wok.requestJSON({
- url : 'tasks/' + encodeURIComponent(taskId),
+ url : 'plugins/kimchi/tasks/' + encodeURIComponent(taskId),
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -560,7 +559,7 @@ var kimchi = {
getTasksByFilter : function(filter, suc, err, sync) {
wok.requestJSON({
- url : 'tasks?' + filter,
+ url : 'plugins/kimchi/tasks?' + filter,
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -591,7 +590,7 @@ var kimchi = {
deleteStoragePool : function(poolName, suc, err) {
$.ajax({
- url : 'storagepools/' + encodeURIComponent(poolName),
+ url : 'plugins/kimchi/storagepools/' + encodeURIComponent(poolName),
type : 'DELETE',
contentType : 'application/json',
dataType : 'json',
@@ -603,7 +602,7 @@ var kimchi = {
changePoolState : function(poolName, state, suc, err) {
if (state === 'activate' || state === 'deactivate')
$.ajax({
- url : 'storagepools/' + encodeURIComponent(poolName) +
'/' + state,
+ url : 'plugins/kimchi/storagepools/' +
encodeURIComponent(poolName) + '/' + state,
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -627,7 +626,7 @@ var kimchi = {
listNetworks : function(suc, err) {
wok.requestJSON({
- url : 'networks',
+ url : 'plugins/kimchi/networks',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -642,7 +641,7 @@ var kimchi = {
toggleNetwork : function(name, on, suc, err) {
var action = on ? "activate" : "deactivate";
wok.requestJSON({
- url : 'networks/' + encodeURIComponent(name) + '/' + action,
+ url : 'plugins/kimchi/networks/' + encodeURIComponent(name) +
'/' + action,
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -655,7 +654,7 @@ var kimchi = {
createNetwork : function(network, suc, err) {
wok.requestJSON({
- url : 'networks',
+ url : 'plugins/kimchi/networks',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -669,7 +668,7 @@ var kimchi = {
getInterfaces : function(suc, err) {
wok.requestJSON({
- url : 'interfaces',
+ url : 'plugins/kimchi/interfaces',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -683,7 +682,7 @@ var kimchi = {
deleteNetwork : function(name, suc, err) {
wok.requestJSON({
- url : 'networks/' + encodeURIComponent(name),
+ url : 'plugins/kimchi/networks/' + encodeURIComponent(name),
type : 'DELETE',
contentType : 'application/json',
dataType : 'json',
@@ -696,7 +695,7 @@ var kimchi = {
listReports : function(suc, err) {
wok.requestJSON({
- url : 'debugreports',
+ url : 'plugins/kimchi/debugreports',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -739,7 +738,7 @@ var kimchi = {
};
wok.requestJSON({
- url : 'debugreports',
+ url : 'plugins/kimchi/debugreports',
type : "POST",
contentType : "application/json",
data : JSON.stringify(settings),
@@ -751,7 +750,7 @@ var kimchi = {
renameReport : function(name, settings, suc, err) {
$.ajax({
- url : "debugreports/" + encodeURIComponent(name),
+ url : "plugins/kimchi/debugreports/" + encodeURIComponent(name),
type : 'PUT',
contentType : 'application/json',
data : JSON.stringify(settings),
@@ -764,7 +763,7 @@ var kimchi = {
deleteReport: function(settings, suc, err) {
var reportName = encodeURIComponent(settings['name']);
wok.requestJSON({
- url : 'debugreports/' + reportName,
+ url : 'plugins/kimchi/debugreports/' + reportName,
type : 'DELETE',
contentType : 'application/json',
dataType : 'json',
@@ -779,7 +778,7 @@ var kimchi = {
shutdown: function(settings, suc, err) {
var reboot = settings && settings['reboot'] === true;
- var url = 'host/' + (reboot ? 'reboot' : 'shutdown');
+ var url = 'plugins/kimchi/host/' + (reboot ? 'reboot' :
'shutdown');
wok.requestJSON({
url : url,
type : 'POST',
@@ -792,7 +791,7 @@ var kimchi = {
listHostPartitions : function(suc, err) {
wok.requestJSON({
- url : 'host/partitions',
+ url : 'plugins/kimchi/host/partitions',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -802,7 +801,7 @@ var kimchi = {
},
getStorageServers: function(type, suc, err) {
- var url = 'storageservers?_target_type=' + type;
+ var url = 'plugins/kimchi/storageservers?_target_type=' + type;
wok.requestJSON({
url : url,
type : 'GET',
@@ -816,7 +815,7 @@ var kimchi = {
},
getStorageTargets: function(server,type, suc, err) {
- var url = 'storageservers/' + server +
'/storagetargets?_target_type=' + type;
+ var url = 'plugins/kimchi/storageservers/' + server +
'/storagetargets?_target_type=' + type;
wok.requestJSON({
url : url,
type : 'GET',
@@ -829,7 +828,7 @@ var kimchi = {
},
getStoragePool: function(poolName, suc, err) {
- var url = kimchi.url + 'storagepools/' + encodeURIComponent(poolName);
+ var url = 'plugins/kimchi/storagepools/' + encodeURIComponent(poolName);
wok.requestJSON({
url : url,
type : 'GET',
@@ -842,7 +841,7 @@ var kimchi = {
},
getStoragePoolVolume: function(poolName, volumeName, suc, err) {
- var url = 'storagepools/' + encodeURIComponent(poolName) +
'/storagevolumes/' + encodeURIComponent(volumeName);
+ var url = 'plugins/kimchi/storagepools/' + encodeURIComponent(poolName) +
'/storagevolumes/' + encodeURIComponent(volumeName);
wok.requestJSON({
url : url,
type : 'GET',
@@ -858,7 +857,7 @@ var kimchi = {
var vm = encodeURIComponent(settings['vm']);
delete settings['vm'];
wok.requestJSON({
- url : 'vms/' + vm + '/storages',
+ url : 'plugins/kimchi/vms/' + vm + '/storages',
type : 'POST',
contentType : 'application/json',
data : JSON.stringify(settings),
@@ -872,7 +871,7 @@ var kimchi = {
var vm = encodeURIComponent(settings['vm']);
var dev = encodeURIComponent(settings['dev']);
wok.requestJSON({
- url : "vms/" + vm + '/storages/' + dev,
+ url : "plugins/kimchi/vms/" + vm + '/storages/' + dev,
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -885,7 +884,7 @@ var kimchi = {
var vm = encodeURIComponent(settings['vm']);
var dev = encodeURIComponent(settings['dev']);
wok.requestJSON({
- url : 'vms/' + vm + '/storages/' + dev,
+ url : 'plugins/kimchi/vms/' + vm + '/storages/' + dev,
type : 'PUT',
contentType : 'application/json',
data : JSON.stringify({
@@ -901,8 +900,8 @@ var kimchi = {
var vm = settings['vm'];
var dev = settings['dev'];
wok.requestJSON({
- url : 'vms/' + encodeURIComponent(vm) +
- '/storages/' + encodeURIComponent(dev),
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
+ '/storages/' + encodeURIComponent(dev),
type : 'DELETE',
contentType : 'application/json',
dataType : 'json',
@@ -914,7 +913,7 @@ var kimchi = {
listVMStorages : function(params, suc, err) {
var vm = encodeURIComponent(params['vm']);
var type = params['storageType'];
- var url = 'vms/' + vm + '/storages';
+ var url = 'plugins/kimchi/vms/' + vm + '/storages';
if(type) {
url += '?type=' + type;
}
@@ -930,7 +929,7 @@ var kimchi = {
listSoftwareUpdates : function(suc, err) {
wok.requestJSON({
- url : 'host/packagesupdate',
+ url : 'plugins/kimchi/host/packagesupdate',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -970,7 +969,7 @@ var kimchi = {
};
wok.requestJSON({
- url : 'host/swupdate',
+ url : 'plugins/kimchi/host/swupdate',
type : "POST",
contentType : "application/json",
dataType : "json",
@@ -981,7 +980,7 @@ var kimchi = {
createRepository : function(settings, suc, err) {
wok.requestJSON({
- url : "host/repositories",
+ url : "plugins/kimchi/host/repositories",
type : "POST",
contentType : "application/json",
data : JSON.stringify(settings),
@@ -994,7 +993,7 @@ var kimchi = {
retrieveRepository : function(repository, suc, err) {
var reposID = encodeURIComponent(repository);
wok.requestJSON({
- url : "host/repositories/" + reposID,
+ url : "plugins/kimchi/host/repositories/" + reposID,
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1006,7 +1005,7 @@ var kimchi = {
updateRepository : function(name, settings, suc, err) {
var reposID = encodeURIComponent(name);
$.ajax({
- url : "host/repositories/" + reposID,
+ url : "plugins/kimchi/host/repositories/" + reposID,
type : 'PUT',
contentType : 'application/json',
data : JSON.stringify(settings),
@@ -1019,8 +1018,8 @@ var kimchi = {
enableRepository : function(name, enable, suc, err) {
var reposID = encodeURIComponent(name);
$.ajax({
- url : "host/repositories/" + reposID +
- '/' + (enable === true ? 'enable' : 'disable'),
+ url : "plugins/kimchi/host/repositories/" + reposID +
+ '/' + (enable === true ? 'enable' :
'disable'),
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -1032,7 +1031,7 @@ var kimchi = {
deleteRepository : function(repository, suc, err) {
var reposID = encodeURIComponent(repository);
wok.requestJSON({
- url : 'host/repositories/' + reposID,
+ url : 'plugins/kimchi/host/repositories/' + reposID,
type : 'DELETE',
contentType : 'application/json',
dataType : 'json',
@@ -1043,7 +1042,7 @@ var kimchi = {
listRepositories : function(suc, err) {
wok.requestJSON({
- url : 'host/repositories',
+ url : 'plugins/kimchi/host/repositories',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1054,7 +1053,7 @@ var kimchi = {
},
getHostFCDevices: function(suc, err) {
- var url = 'host/devices?_cap=fc_host';
+ var url = 'plugins/kimchi/host/devices?_cap=fc_host';
wok.requestJSON({
url : url,
type : 'GET',
@@ -1068,7 +1067,7 @@ var kimchi = {
},
getGuestInterfaces: function(name, suc, err) {
- var url = 'vms/'+encodeURIComponent(name)+'/ifaces';
+ var url = 'plugins/kimchi/vms/' + encodeURIComponent(name) +
'/ifaces';
wok.requestJSON({
url : url,
type : 'GET',
@@ -1083,7 +1082,7 @@ var kimchi = {
createGuestInterface : function(name, interface, suc, err) {
wok.requestJSON({
- url : 'vms/'+encodeURIComponent(name)+'/ifaces',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(name) +
'/ifaces',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -1097,7 +1096,7 @@ var kimchi = {
deleteGuestInterface : function(vm, mac, suc, err) {
wok.requestJSON({
- url :
'vms/'+encodeURIComponent(vm)+'/ifaces/'+encodeURIComponent(mac),
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/ifaces/' + encodeURIComponent(mac),
type : 'DELETE',
contentType : 'application/json',
dataType : 'json',
@@ -1110,7 +1109,7 @@ var kimchi = {
updateGuestInterface : function(vm, mac, interface, suc, err) {
$.ajax({
- url :
'vms/'+encodeURIComponent(vm)+'/ifaces/'+encodeURIComponent(mac),
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/ifaces/' + encodeURIComponent(mac),
type : 'PUT',
contentType : 'application/json',
data : JSON.stringify(interface),
@@ -1124,7 +1123,7 @@ var kimchi = {
getUserById : function(data, suc, err) {
wok.requestJSON({
- url : 'users?_user_id=' + data.user_id,
+ url : 'plugins/kimchi/users?_user_id=' + data.user_id,
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1139,7 +1138,7 @@ var kimchi = {
getUsers : function(suc, err) {
wok.requestJSON({
- url : 'users',
+ url : 'plugins/kimchi/users',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1153,7 +1152,7 @@ var kimchi = {
getGroups : function(suc, err) {
wok.requestJSON({
- url : 'groups',
+ url : 'plugins/kimchi/groups',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1167,7 +1166,7 @@ var kimchi = {
getHostPCIDevices : function(suc, err) {
wok.requestJSON({
- url : 'host/devices?_passthrough=true&_cap=pci',
+ url : 'plugins/kimchi/host/devices?_passthrough=true&_cap=pci',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1181,7 +1180,7 @@ var kimchi = {
getPCIDeviceCompanions : function(pcidev, suc, err) {
wok.requestJSON({
- url : 'host/devices?_passthrough_affected_by=' + pcidev,
+ url : 'plugins/kimchi/host/devices?_passthrough_affected_by=' +
pcidev,
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1197,7 +1196,7 @@ var kimchi = {
server = encodeURIComponent(server);
port = port ? '&_server_port='+encodeURIComponent(port) :
'';
wok.requestJSON({
- url :
'storageservers/'+server+'/storagetargets?_target_type=iscsi'+port,
+ url : 'plugins/kimchi/storageservers/' + server +
'/storagetargets?_target_type=iscsi' + port,
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1211,7 +1210,7 @@ var kimchi = {
getPeers : function(suc, err) {
wok.requestJSON({
- url : 'peers',
+ url : 'plugins/kimchi/peers',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1225,7 +1224,7 @@ var kimchi = {
getVMPCIDevices : function(id, suc, err) {
wok.requestJSON({
- url : 'vms/'+encodeURIComponent(id)+'/hostdevs',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(id) +
'/hostdevs',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1239,7 +1238,7 @@ var kimchi = {
addVMPCIDevice : function(vm, device, suc, err) {
wok.requestJSON({
- url : 'vms/'+ encodeURIComponent(vm) +'/hostdevs',
+ url : 'plugins/kimchi/vms/'+ encodeURIComponent(vm)
+'/hostdevs',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -1253,7 +1252,7 @@ var kimchi = {
removeVMPCIDevice : function(vm, device, suc, err) {
wok.requestJSON({
- url : 'vms/'+ encodeURIComponent(vm) +'/hostdevs/' +
encodeURIComponent(device),
+ url : 'plugins/kimchi/vms/'+ encodeURIComponent(vm)
+'/hostdevs/' + encodeURIComponent(device),
type : 'DELETE',
contentType : 'application/json',
dataType : 'json',
@@ -1269,7 +1268,7 @@ var kimchi = {
*/
createVolumeWithCapacity: function(poolName, settings, suc, err) {
wok.requestJSON({
- url : 'storagepools/' + encodeURIComponent(poolName) +
'/storagevolumes',
+ url : 'plugins/kimchi/storagepools/' + encodeURIComponent(poolName) +
'/storagevolumes',
type : 'POST',
contentType : "application/json",
data : JSON.stringify(settings),
@@ -1283,7 +1282,7 @@ var kimchi = {
* Upload volume content
*/
uploadVolumeToSP: function(poolName, volumeName, settings, suc, err) {
- var url = 'storagepools/' + encodeURIComponent(poolName) +
'/storagevolumes/' + encodeURIComponent(volumeName);
+ var url = 'plugins/kimchi/storagepools/' + encodeURIComponent(poolName) +
'/storagevolumes/' + encodeURIComponent(volumeName);
var fd = settings['formData'];
wok.requestJSON({
url : url,
@@ -1304,7 +1303,7 @@ var kimchi = {
var sp = encodeURIComponent(settings['sp']);
delete settings['sp'];
wok.requestJSON({
- url : 'storagepools/' + sp + '/storagevolumes',
+ url : 'plugins/kimchi/storagepools/' + sp +
'/storagevolumes',
type : 'POST',
data : JSON.stringify(settings),
contentType : 'application/json',
@@ -1316,7 +1315,7 @@ var kimchi = {
cloneGuest: function(vm, suc, err) {
wok.requestJSON({
- url : 'vms/'+encodeURIComponent(vm)+"/clone",
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
"/clone",
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -1329,7 +1328,7 @@ var kimchi = {
listSnapshots : function(vm, suc, err) {
wok.requestJSON({
- url : 'vms/'+encodeURIComponent(vm)+'/snapshots',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/snapshots',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1343,7 +1342,7 @@ var kimchi = {
getCurrentSnapshot : function(vm, suc, err, sync) {
wok.requestJSON({
- url : 'vms/'+encodeURIComponent(vm)+'/snapshots/current',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/snapshots/current',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -1358,7 +1357,7 @@ var kimchi = {
revertSnapshot : function(vm, snapshot, suc, err) {
wok.requestJSON({
- url :
'vms/'+encodeURIComponent(vm)+'/snapshots/'+encodeURIComponent(snapshot)+'/revert',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/snapshots/' + encodeURIComponent(snapshot) + '/revert',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -1371,7 +1370,7 @@ var kimchi = {
createSnapshot : function(vm, suc, err) {
wok.requestJSON({
- url : 'vms/'+encodeURIComponent(vm)+'/snapshots',
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/snapshots',
type : 'POST',
contentType : 'application/json',
dataType : 'json',
@@ -1384,7 +1383,7 @@ var kimchi = {
deleteSnapshot : function(vm, snapshot, suc, err) {
wok.requestJSON({
- url :
'vms/'+encodeURIComponent(vm)+'/snapshots/'+encodeURIComponent(snapshot),
+ url : 'plugins/kimchi/vms/' + encodeURIComponent(vm) +
'/snapshots/' + encodeURIComponent(snapshot),
type : 'DELETE',
contentType : 'application/json',
dataType : 'json',
@@ -1397,7 +1396,7 @@ var kimchi = {
getCPUInfo : function(suc, err) {
wok.requestJSON({
- url : 'host/cpuinfo',
+ url : 'plugins/kimchi/host/cpuinfo',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
diff --git a/plugins/kimchi/ui/js/src/kimchi.guest_add_main.js
b/plugins/kimchi/ui/js/src/kimchi.guest_add_main.js
index 1008d85..6be6f9a 100644
--- a/plugins/kimchi/ui/js/src/kimchi.guest_add_main.js
+++ b/plugins/kimchi/ui/js/src/kimchi.guest_add_main.js
@@ -34,7 +34,7 @@ kimchi.guest_add_main = function() {
$('#btn-create-template').on('click', function(event) {
wok.topic('templateCreated').subscribe(showTemplates);
- wok.window.open('template-add.html');
+ wok.window.open('plugins/kimchi/template-add.html');
event.preventDefault();
});
diff --git a/plugins/kimchi/ui/js/src/kimchi.guest_edit_main.js
b/plugins/kimchi/ui/js/src/kimchi.guest_edit_main.js
index 28c2163..25e3703 100644
--- a/plugins/kimchi/ui/js/src/kimchi.guest_edit_main.js
+++ b/plugins/kimchi/ui/js/src/kimchi.guest_edit_main.js
@@ -604,7 +604,7 @@ kimchi.guest_edit_main = function() {
});
};
var listGeneratingSnapshots = function(){
-
kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/snapshots/*'),
function(tasks) {
+
kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/plugins/kimchi/snapshots/*'),
function(tasks) {
$(".task", "#form-guest-edit-snapshot").empty();
for(var i=0;i<tasks.length;i++){
addOngoingItem(tasks[i]);
@@ -639,7 +639,7 @@ kimchi.guest_edit_main = function() {
};
var initContent = function(guest) {
- guest['icon'] = guest['icon'] || 'images/icon-vm.png';
+ guest['icon'] = guest['icon'] ||
'plugins/kimchi/images/icon-vm.png';
$('#form-guest-edit-general').fillWithObject(guest);
kimchi.thisVMState = guest['state'];
refreshCDROMs();
@@ -650,7 +650,7 @@ kimchi.guest_edit_main = function() {
text: false
}).click(function(event) {
event.preventDefault();
- wok.window.open("guest-storage-add.html");
+ wok.window.open("plugins/kimchi/guest-storage-add.html");
});
if(kimchi.thisVMState === "running") {
$("#form-guest-edit-general input").prop("disabled",
true);
diff --git a/plugins/kimchi/ui/js/src/kimchi.guest_main.js
b/plugins/kimchi/ui/js/src/kimchi.guest_main.js
index a0f927b..7dd5d84 100644
--- a/plugins/kimchi/ui/js/src/kimchi.guest_main.js
+++ b/plugins/kimchi/ui/js/src/kimchi.guest_main.js
@@ -202,7 +202,7 @@ kimchi.vmedit = function(event) {
var vm_id=vm.attr("id");
kimchi.selectedGuest = vm_id;
wok.window.open({
- url: 'guest-edit.html',
+ url: 'plugins/kimchi/guest-edit.html',
close: function() {
kimchi.clearGuestEdit();
}
@@ -245,7 +245,7 @@ kimchi.listVmsAuto = function() {
}
var getCreatingGuests = function(){
var guests = [];
-
kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/vms/[^/]+$'),
function(tasks) {
+
kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/plugins/kimchi/vms/[^/]+$'),
function(tasks) {
for(var i=0;i<tasks.length;i++){
var guestUri = tasks[i].target_uri;
var guestName = guestUri.split('/')[2]
@@ -260,7 +260,7 @@ kimchi.listVmsAuto = function() {
};
var getCloningGuests = function(){
var guests = [];
-
kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/vms/.+/clone'),
function(tasks) {
+
kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/plugins/kimchi/vms/.+/clone'),
function(tasks) {
for(var i=0;i<tasks.length;i++){
var guestUri = tasks[i].target_uri;
var guestName = guestUri.split('/')[2]
@@ -325,7 +325,7 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu)
{
if (vmObject.screenshot) {
curImg = vmObject.screenshot.replace(/^\//,'');
}
- var load_src = curImg || 'images/icon-vm.png';
+ var load_src = curImg || 'plugins/kimchi/images/icon-vm.png';
var tile_src = prevScreenImage || vmObject['load-src'];
var liveTile=result.find('div[name=guest-tile] > .tile');
liveTile.addClass(vmObject.state);
@@ -352,7 +352,7 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu)
{
liveTile.off("click", kimchi.openVmConsole);
liveTile.on("click", kimchi.vmresume);
if(vmObject.state="paused") {
-
liveTile.find('.overlay').attr('src',"/images/theme-default/ac24_resume.png");
+
liveTile.find('.overlay').attr('src',"plugins/kimchi/images/theme-default/ac24_resume.png");
liveTile.find('.overlay').attr('alt',"Resume");
}
liveTile.hover(function(event){$(this).find('.overlay').show()},
function(event){$(this).find('.overlay').hide()});
@@ -492,7 +492,7 @@ kimchi.guest_main = function() {
if(wok.tabMode['guests'] === 'admin') {
$('.tools').attr('style','display');
$("#vm-add").on("click", function(event) {
- wok.window.open('guest-add.html');
+ wok.window.open('plugins/kimchi/guest-add.html');
});
}
kimchi.guestTemplate = $('#guest-tmpl').html();
diff --git a/plugins/kimchi/ui/js/src/kimchi.guest_media_main.js
b/plugins/kimchi/ui/js/src/kimchi.guest_media_main.js
index 2e4e7e8..b920527 100644
--- a/plugins/kimchi/ui/js/src/kimchi.guest_media_main.js
+++ b/plugins/kimchi/ui/js/src/kimchi.guest_media_main.js
@@ -35,7 +35,7 @@ kimchi.guest_media_main = function() {
var replaceCDROM = function(event) {
event.preventDefault();
kimchi.selectedGuestStorage = $(this).data('dev');
- wok.window.open("guest-cdrom-edit.html");
+ wok.window.open("plugins/kimchi/guest-cdrom-edit.html");
};
$('input[type="text"][name="cdrom"]',
container).on('click', replaceCDROM);
diff --git a/plugins/kimchi/ui/js/src/kimchi.host.js
b/plugins/kimchi/ui/js/src/kimchi.host.js
index 7834024..4218d97 100644
--- a/plugins/kimchi/ui/js/src/kimchi.host.js
+++ b/plugins/kimchi/ui/js/src/kimchi.host.js
@@ -86,7 +86,8 @@ kimchi.host_main = function() {
id: 'repositories-grid-add-button',
label: i18n['KCHREPO6012M'],
onClick: function(event) {
- wok.window.open({url:'repository-add.html', class:
repo_type});
+ wok.window.open({url:'plugins/kimchi/repository-add.html',
+ class: repo_type});
}
}, {
id: 'repositories-grid-enable-button',
@@ -114,7 +115,8 @@ kimchi.host_main = function() {
return;
}
kimchi.selectedRepository = repository['repo_id'];
- wok.window.open({url:'repository-edit.html', class:
repo_type});
+ wok.window.open({url:'plugins/kimchi/repository-edit.html',
+ class: repo_type});
}
}, {
id: 'repositories-grid-remove-button',
@@ -302,7 +304,7 @@ kimchi.host_main = function() {
id: reportGridID + '-generate-button',
label: i18n['KCHDR6006M'],
onClick: function(event) {
- wok.window.open('report-add.html');
+ wok.window.open('plugins/kimchi/report-add.html');
}
}, {
id: reportGridID + '-rename-button',
@@ -315,7 +317,7 @@ kimchi.host_main = function() {
}
kimchi.selectedReport = report['name'];
- wok.window.open('report-rename.html');
+ wok.window.open('plugins/kimchi/report-rename.html');
}
}, {
id: reportGridID + '-remove-button',
@@ -389,11 +391,11 @@ kimchi.host_main = function() {
var getPendingReports = function() {
var reports = []
- var filter = 'status=running&target_uri=' +
encodeURIComponent('^/debugreports/*')
+ var filter = 'status=running&target_uri=' +
encodeURIComponent('^/plugins/kimchi/debugreports/*')
kimchi.getTasksByFilter(filter, function(tasks) {
for(var i = 0; i < tasks.length; i++) {
- reportName = tasks[i].target_uri.replace(/^\/debugreports\//, '')
|| i18n['KCHDR6012M'];
+ reportName =
tasks[i].target_uri.replace(/^\/plugins\/kimchi\/debugreports\//, '') ||
i18n['KCHDR6012M'];
reports.push({'name': reportName, 'time':
i18n['KCHDR6007M']})
if(kimchi.trackingTasks.indexOf(tasks[i].id) >= 0) {
diff --git a/plugins/kimchi/ui/js/src/kimchi.storage_main.js
b/plugins/kimchi/ui/js/src/kimchi.storage_main.js
index 1238c5f..4b2e928 100644
--- a/plugins/kimchi/ui/js/src/kimchi.storage_main.js
+++ b/plugins/kimchi/ui/js/src/kimchi.storage_main.js
@@ -150,7 +150,7 @@ kimchi.storageBindClick = function() {
$('.pool-add-volume').on('click', function(event) {
var poolName = $(this).data('name');
kimchi.selectedSP = poolName;
- wok.window.open('storagepool-add-volume.html');
+ wok.window.open('plugins/kimchi/storagepool-add-volume.html');
});
$('.storage-action').on('click', function() {
@@ -202,7 +202,7 @@ kimchi.doListVolumes = function(poolObj) {
var getOngoingVolumes = function() {
var result = {}
- var filter = 'status=running&target_uri=' +
encodeURIComponent('^/storagepools/' + poolName + '/*')
+ var filter = 'status=running&target_uri=' +
encodeURIComponent('^/plugins/kimchi/storagepools/' + poolName + '/*')
kimchi.getTasksByFilter(filter, function(tasks) {
for(var i = 0; i < tasks.length; i++) {
var volumeName = tasks[i].target_uri.split('/').pop();
@@ -329,7 +329,7 @@ kimchi.storage_main = function() {
if(wok.tabMode['storage'] === 'admin') {
$('.tools').attr('style','display');
$('#storage-pool-add').on('click', function() {
- wok.window.open('storagepool-add.html');
+ wok.window.open('plugins/kimchi/storagepool-add.html');
});
$('.list-title .title-actions').attr('style','display');
}
diff --git a/plugins/kimchi/ui/js/src/kimchi.template_edit_main.js
b/plugins/kimchi/ui/js/src/kimchi.template_edit_main.js
index d336729..6df1328 100644
--- a/plugins/kimchi/ui/js/src/kimchi.template_edit_main.js
+++ b/plugins/kimchi/ui/js/src/kimchi.template_edit_main.js
@@ -283,7 +283,7 @@ kimchi.template_edit_main = function() {
if($('.template-storage-type', tmpItem).val() === 'iscsi' ||
$('.template-storage-type', tmpItem).val() == 'scsi') {
tempNameTail = tempName[tempName.length-1];
}
- tempName = '/storagepools/' + tempNameHead;
+ tempName = '/plugins/kimchi/storagepools/' + tempNameHead;
data['storagepool'] = tempName;
$.each(editableFields, function(i, field) {
/* Support only 1 disk at this moment */
diff --git a/plugins/kimchi/ui/js/src/kimchi.template_main.js
b/plugins/kimchi/ui/js/src/kimchi.template_main.js
index 5d474bd..b09fe12 100644
--- a/plugins/kimchi/ui/js/src/kimchi.template_main.js
+++ b/plugins/kimchi/ui/js/src/kimchi.template_main.js
@@ -34,9 +34,9 @@ kimchi.doListTemplates = function() {
}
}
if(isLocal){
- value.location = "images/theme-default/icon-local.png";
+ value.location =
"plugins/kimchi/images/theme-default/icon-local.png";
}else{
- value.location = "images/theme-default/icon-remote.png";
+ value.location =
"plugins/kimchi/images/theme-default/icon-remote.png";
}
listHtml += wok.substitute(templateHtml, value);
});
@@ -57,7 +57,7 @@ kimchi.templateBindClick = function() {
$('.template-edit').on('click', function(event) {
var templateName = $(this).data('template');
kimchi.selectedTemplate = templateName;
- wok.window.open("template-edit.html");
+ wok.window.open("plugins/kimchi/template-edit.html");
});
$('.template-clone').on('click', function(event) {
kimchi.selectedTemplate = $(this).data('template');
@@ -97,7 +97,7 @@ kimchi.template_main = function() {
$('.tools').attr('style','display');
$("#template-add").on("click", function(event) {
wok.window.open({
- url: 'template-add.html',
+ url: 'plugins/kimchi/template-add.html',
close: function() {
if (kimchi.deepScanHandler) {
kimchi.deepScanHandler.stop = true;
diff --git a/plugins/kimchi/ui/pages/error.html.tmpl
b/plugins/kimchi/ui/pages/error.html.tmpl
index 068f2a6..13af1e1 100644
--- a/plugins/kimchi/ui/pages/error.html.tmpl
+++ b/plugins/kimchi/ui/pages/error.html.tmpl
@@ -28,14 +28,14 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge,chrome=1">
<title>Kimchi</title>
- <link rel="stylesheet"
href="$href("/css/theme-default.min.css")">
+ <link rel="stylesheet"
href="$href("css/theme-default.min.css")">
</head>
<body>
<div class="error-background">
<h1 id="logo">
- <img src="/images/theme-default/logo-white.png"
alt="Kimchi">
+ <img src="plugins/kimchi/images/theme-default/logo-white.png"
alt="Kimchi">
</h1>
</div>
<div class="error-msg error-icon">
diff --git a/plugins/kimchi/ui/pages/guest-add.html.tmpl
b/plugins/kimchi/ui/pages/guest-add.html.tmpl
index 8466bae..340b131 100644
--- a/plugins/kimchi/ui/pages/guest-add.html.tmpl
+++ b/plugins/kimchi/ui/pages/guest-add.html.tmpl
@@ -59,7 +59,7 @@
<script type="html/text" id="tmpl-template"
class="tmpl-html">
<li>
<label>
- <input type="radio" name="template"
value="/templates/{name}">
+ <input type="radio" name="template"
value="/plugins/kimchi/templates/{name}">
<div class="info">
<div class="summary os-icon">
<img src="{icon}">
diff --git a/plugins/kimchi/ui/pages/guest.html.tmpl
b/plugins/kimchi/ui/pages/guest.html.tmpl
index a876f38..78e9161 100644
--- a/plugins/kimchi/ui/pages/guest.html.tmpl
+++ b/plugins/kimchi/ui/pages/guest.html.tmpl
@@ -45,7 +45,7 @@
<div class="tile ">
<img class="imgactive" alt=""
src="">
<img class="imgload" alt=""
src="">
- <img class="overlay shutoff-hidden"
alt="$_("Start")"
src="images/theme-default/icon-power-down.png" >
+ <img class="overlay shutoff-hidden"
alt="$_("Start")"
src="plugins/kimchi/images/theme-default/icon-power-down.png" >
</div>
</div>
<div class="sortable guest-actions"
name="guest-actions">
diff --git a/plugins/kimchi/ui/pages/storagepool-add.html.tmpl
b/plugins/kimchi/ui/pages/storagepool-add.html.tmpl
index a81207b..8ba4cfe 100644
--- a/plugins/kimchi/ui/pages/storagepool-add.html.tmpl
+++ b/plugins/kimchi/ui/pages/storagepool-add.html.tmpl
@@ -100,7 +100,7 @@
<div class="host-partition">
<p class="text-help">
$_("Looking for available partitions ...")
- <img src =
"images/theme-default/loading.gif" />
+ <img src =
"plugins/kimchi/images/theme-default/loading.gif" />
</p>
</div>
</section>
diff --git a/plugins/kimchi/ui/pages/tabs/storage.html.tmpl
b/plugins/kimchi/ui/pages/tabs/storage.html.tmpl
index c5171a7..c9ba895 100644
--- a/plugins/kimchi/ui/pages/tabs/storage.html.tmpl
+++ b/plugins/kimchi/ui/pages/tabs/storage.html.tmpl
@@ -46,7 +46,7 @@
</div>
<div id="logicalPoolExtend" title="$_("Device
path")">
<p id="loading-info" class="text-help">
- <img src = "images/theme-default/loading.gif" />
+ <img src = "plugins/kimchi/images/theme-default/loading.gif" />
$_("Looking for available partitions ...")
</p>
<div class="host-partition">
diff --git a/plugins/kimchi/ui/pages/template-add.html.tmpl
b/plugins/kimchi/ui/pages/template-add.html.tmpl
index fe63283..bac8e98 100644
--- a/plugins/kimchi/ui/pages/template-add.html.tmpl
+++ b/plugins/kimchi/ui/pages/template-add.html.tmpl
@@ -147,7 +147,7 @@
<div id="load-remote-iso">
<h3 class="step-subtitle">
<label>
- <img src = "images/theme-default/loading.gif"
/>
+ <img src =
"plugins/kimchi/images/theme-default/loading.gif" />
$_("Loading default remote ISOs ...")
</label>
</h3>
diff --git a/plugins/sample/ui/js/util.js b/plugins/sample/ui/js/util.js
index 1e6c4df..7689a81 100644
--- a/plugins/sample/ui/js/util.js
+++ b/plugins/sample/ui/js/util.js
@@ -20,7 +20,7 @@ sample = {};
sample.description = function(suc, err){
wok.requestJSON({
- url : kimchi.url + 'plugins/sample/description',
+ url : 'plugins/sample/description',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
diff --git a/ui/pages/error.html.tmpl b/ui/pages/error.html.tmpl
index dfe7ce3..eea1179 100644
--- a/ui/pages/error.html.tmpl
+++ b/ui/pages/error.html.tmpl
@@ -28,14 +28,14 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge,chrome=1">
<title>Wok</title>
- <link rel="stylesheet"
href="$href("/css/theme-default.min.css")">
+ <link rel="stylesheet"
href="$href("css/theme-default.min.css")">
</head>
<body>
<div class="error-background">
<h1 id="logo">
- <img src="/images/theme-default/logo-white.png"
alt="Wok">
+ <img src="images/theme-default/logo-white.png"
alt="Wok">
</h1>
</div>
<div class="error-msg error-icon">
--
1.7.1