[RFC]: help, how to get the mac after create a VM interface.
by Sheldon
when I create a interface, There is no mac attribute in the xml.
After create successfully, libvirt will allocate a mac.
The problem is that, How can I get the mac.
Should the CREATE method always needs to return an interface info?
Here is some of create code.
def vmifaces_create(self, vm, params):
dom = self._get_vm(vm)
xml = """
<interface type='network'>
<source network='default'/>
</interface>
"""
dom.attachDeviceFlags(xml,
libvirt.VIR_DOMAIN_AFFECT_CURRENT)
# here I need to return the mac
return ????
The libvirt will create a xml like the follow? The problem is that the a
vm may have several interfaces.
xml = """
<interface type='network'>
<mac address='52:54:00:2a:53:8f'/>
<source network='default'/>
<model type='rtl8139'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
"""
--
Thanks and best regards!
Sheldon Feng(冯少合)<shaohef(a)linux.vnet.ibm.com>
IBM Linux Technology Center
10 years, 10 months
[PATCH] add gettext to package require list
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
gettext translates a natural language message into the user's language.
kimchi needs it.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
contrib/DEBIAN/control.in | 1 +
contrib/kimchi.spec.fedora.in | 1 +
contrib/kimchi.spec.suse.in | 1 +
3 files changed, 3 insertions(+)
diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in
index 1ddc5ba..762b3a0 100644
--- a/contrib/DEBIAN/control.in
+++ b/contrib/DEBIAN/control.in
@@ -8,6 +8,7 @@ Depends: python-cherrypy3 (>= 3.2.0),
python-imaging,
python-jsonschema (>= 1.3.0),
python-libvirt,
+ gettext,
libvirt-bin,
nfs-common,
python-m2crypto,
diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 77c64e9..4505d9d 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -11,6 +11,7 @@ Group: System Environment/Base
License: LGPL/ASL2
Source0: %{name}-%{version}.tar.gz
Requires: qemu-kvm
+Requires: gettext-devel
Requires: libvirt
Requires: libvirt-python
Requires: python-cherrypy >= 3.2.0
diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in
index 889b704..a178442 100644
--- a/contrib/kimchi.spec.suse.in
+++ b/contrib/kimchi.spec.suse.in
@@ -7,6 +7,7 @@ Group: System Environment/Base
License: LGPL/ASL2
Source0: %{name}-%{version}.tar.gz
Requires: kvm
+Requires: gettext-tools
Requires: libvirt
Requires: libvirt-python
Requires: python-CherryPy >= 3.2.0
--
1.8.4.2
10 years, 10 months
[PATCH] bug fix: test case can not find plugin, fix it
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
$ sudo ./run_tests.sh test_rest
Failed to import plugin plugins.sample.Drawings
That's because plugin is not in src/
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
tests/run_tests.sh.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/run_tests.sh.in b/tests/run_tests.sh.in
index 2baf66d..038e8fa 100644
--- a/tests/run_tests.sh.in
+++ b/tests/run_tests.sh.in
@@ -31,7 +31,7 @@ else
fi
if [ "$HAVE_UNITTEST" != "yes" -o "$PYTHON_VER" == "2.6" ]; then
- PYTHONPATH=../src:./ unit2 $ARGS
+ PYTHONPATH=../src:./:../ unit2 $ARGS
else
- PYTHONPATH=../src python -m unittest $ARGS
+ PYTHONPATH=../src:../ python -m unittest $ARGS
fi
--
1.8.4.2
10 years, 10 months
[PATCH] Modify bug in spice UI
by zhoumeina
Last spice patch push hard code in spice UI, this patch is working
for fix this issue.
Signed-off-by: zhoumeina <zhoumein(a)linux.vnet.ibm.com>
---
ui/pages/spice.html.tmpl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/ui/pages/spice.html.tmpl b/ui/pages/spice.html.tmpl
index 7fd0db5..3e43306 100644
--- a/ui/pages/spice.html.tmpl
+++ b/ui/pages/spice.html.tmpl
@@ -74,7 +74,7 @@
sc.stop();
}
- uri = scheme + host + ":" + port + "/?token=rrr";
+ uri = scheme + host + ":" + port + "/?token=" + token;
try {
sc = new SpiceMainConn({
uri : uri,
--
1.7.1
10 years, 10 months
[PATCHv9 00/10] Support storage targets and servers
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
v9>v10, work around ubuntu libvirt problem.
v8>v9, split two types of filter params, fix nits
v7>v8, address model break, change xml construction to libxml
v6>v7, adopt lxml to parse xml, move parse params to get() to avoid duplicate code,
fix bugs when one server support multiple target type.
v5>v6, change GET param support to cover more scenario of filter collected results.
v4>v5, remove storage server list reload function,
merge storage server and targets
v3>v4, fix inconsistency between doc and json schema
v1>v3, fix racing problem, fix style.
Royce Lv (10):
Support params for GET method
Add testcase for GET param
Storage server: Update API.md
storage server: update controller.py
storage server: Update model and mockmodel
storage target: Update API.md
storage target: Update controller and json schema
storage target: Add model support
Add showmount function and feature test for libvirt target probe
Fix libvirt nfs target probe problem
docs/API.md | 37 ++++++++++++++++
src/kimchi/API.json | 22 ++++++++++
src/kimchi/control/base.py | 31 +++++++++++---
src/kimchi/control/storagepools.py | 4 +-
src/kimchi/control/storageservers.py | 55 ++++++++++++++++++++++++
src/kimchi/control/storagevolumes.py | 2 +-
src/kimchi/featuretests.py | 22 ++++++++++
src/kimchi/mockmodel.py | 30 +++++++++++++
src/kimchi/model.py | 82 +++++++++++++++++++++++++++++++++++-
src/kimchi/root.py | 2 +
src/kimchi/utils.py | 20 ++++++++-
tests/test_rest.py | 23 ++++++++++
12 files changed, 317 insertions(+), 13 deletions(-)
create mode 100644 src/kimchi/control/storageservers.py
--
1.8.1.2
10 years, 10 months
[PATCH V2]Avoid useless libvirt error log produced by featuret
by apporc
v2-v1:
1. Just hide the portocol type error, leave other error messages as it is.(Thanks Cristian)
2. Unregister the error handler when necessary.(Thanks Cristian)
3. Keep back kimchi log "*** Running feature tests ***", etc.(Thanks Cristian)
4. Move libvirt error handler function inside of Featuretest.(Thanks Aline)
v1:
Avoid useless libvirt error log produced by featuret
apporc (1):
Avoid useless libvirt error log produced by featuretests
src/kimchi/featuretests.py | 14 ++++++++++++--
src/kimchi/model.py | 2 --
2 files changed, 12 insertions(+), 4 deletions(-)
--
1.7.9.5
10 years, 10 months
[PATCH] Break the 'sample' plugin's monolithic model into several smaller ones
by Zhou Zheng Sheng
In kimchi the model is always a monolithic class. This is not good from
the point of modulization, and it is not necessary to put everything
into one big model. Unfortunately the problem will not get solved
unless we conduct enormous refactor against the whole controller-model
architecture.
This patch tries to mitigate the problem by firstly splitting the model
class into some smaller ones, than automatically mapping all sub-model
instance methods to a RootModel instance. As a demonstration, this patch
splits the 'sample' plugin's model.
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
plugins/__init__.py | 47 +++++++++++++++++++++
plugins/sample/model.py | 109 ++++++++++++++++++++++++++++++------------------
2 files changed, 115 insertions(+), 41 deletions(-)
diff --git a/plugins/__init__.py b/plugins/__init__.py
index e69de29..f0b800c 100644
--- a/plugins/__init__.py
+++ b/plugins/__init__.py
@@ -0,0 +1,47 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2014
+#
+# Authors:
+# Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+class RootModel(object):
+ '''
+ This model squashes all sub-model's public callable methods to itself.
+
+ Model methods are not limited to get_list, create, lookup, update, delete.
+ Controller can call generate_action_handler to generate new actions, which
+ call the related model methods. So all public callable methods of a
+ sub-model should be mapped to this model.
+ '''
+ def __init__(self, model_instances):
+ for model_instance in model_instances:
+ cls_name = model_instance.__class__.__name__
+ if cls_name.endswith('Model'):
+ method_prefix = cls_name[:-len('Model')].lower()
+ else:
+ method_prefix = cls_name.lower()
+
+ callables = [m for m in dir(model_instance)
+ if not m.startswith('_') and
+ callable(getattr(model_instance, m))]
+
+ for member_name in callables:
+ m = getattr(model_instance, member_name, None)
+ setattr(self, '%s_%s' % (method_prefix, member_name), m)
diff --git a/plugins/sample/model.py b/plugins/sample/model.py
index 9a2f22f..d194e67 100644
--- a/plugins/sample/model.py
+++ b/plugins/sample/model.py
@@ -21,79 +21,106 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from kimchi.exception import InvalidOperation, NotFoundError
+from kimchi.plugins import RootModel
-class Model(object):
+class CirclesModel(object):
+ def __init__(self):
+ self._circles = {}
+
+ def create(self, params):
+ name = params['name']
+ if name in self._circles:
+ raise InvalidOperation("Circle %s already exists" % name)
+ self._circles[name] = Circle(params['radius'])
+ return name
+ def get_list(self):
+ return sorted(self._circles)
+
+
+class CircleModel(object):
+ def __init__(self, parent_model):
+ # Circel and Circles models are friends, it's OK to share _circles.
+ self._circles = parent_model._circles
+
+ def lookup(self, name):
+ try:
+ circle = self._circles[name]
+ except KeyError:
+ raise NotFoundError("Circle %s not found" % name)
+ return {'radius': circle.radius}
+
+ def update(self, name, params):
+ if name not in self._circles:
+ raise NotFoundError("Circle %s not found" % name)
+ self._circles[name].radius = params['radius']
+ return name
+
+ def delete(self, name):
+ try:
+ del self._circles[name]
+ except KeyError:
+ pass
+
+
+class RectanglesModel(object):
def __init__(self):
- self.rectangles = {}
- self.circles = {}
+ self._rectangles = {}
- def rectangles_create(self, params):
+ def create(self, params):
name = params['name']
- if name in self.rectangles:
+ if name in self._rectangles:
raise InvalidOperation("Rectangle %s already exists" % name)
- self.rectangles[name] = Rectangle(params['length'], params['width'])
+ self._rectangles[name] = Rectangle(params['length'], params['width'])
return name
- def rectangles_get_list(self):
- return sorted(self.rectangles)
+ def get_list(self):
+ return sorted(self._rectangles)
+
- def rectangle_lookup(self, name):
+class RectangleModel(object):
+ def __init__(self, parent_model):
+ self._rectangles = parent_model._rectangles
+
+ def lookup(self, name):
try:
- rectangle = self.rectangles[name]
+ rectangle = self._rectangles[name]
except KeyError:
raise NotFoundError("Rectangle %s not found" % name)
return {'length': rectangle.length, 'width': rectangle.width}
- def rectangle_update(self, name, params):
- if name not in self.rectangles:
+ def update(self, name, params):
+ if name not in self._rectangles:
raise NotFoundError("Rectangle %s not found" % name)
try:
- self.rectangles[name].length = params['length']
+ self._rectangles[name].length = params['length']
except KeyError:
pass
try:
- self.rectangles[name].width = params['width']
+ self._rectangles[name].width = params['width']
except KeyError:
pass
return name
- def rectangle_delete(self, name):
+ def delete(self, name):
try:
- del self.rectangles[name]
+ del self._rectangles[name]
except KeyError:
pass
- def circles_create(self, params):
- name = params['name']
- if name in self.circles:
- raise InvalidOperation("Circle %s already exists" % name)
- self.circles[name] = Circle(params['radius'])
- return name
- def circles_get_list(self):
- return sorted(self.circles)
-
- def circle_lookup(self, name):
- try:
- circle = self.circles[name]
- except KeyError:
- raise NotFoundError("Circle %s not found" % name)
- return {'radius': circle.radius}
+class Model(RootModel):
+ def __init__(self):
+ circles = CirclesModel()
+ circle = CircleModel(circles)
- def circle_update(self, name, params):
- if name not in self.circles:
- raise NotFoundError("Circle %s not found" % name)
- self.circles[name].radius = params['radius']
- return name
+ rectangles = RectanglesModel()
+ rectangle = RectangleModel(rectangles)
- def circle_delete(self, name):
- try:
- del self.circles[name]
- except KeyError:
- pass
+ return super(Model, self).__init__(
+ [circle, circles, rectangle, rectangles])
class Rectangle(object):
--
1.7.11.7
10 years, 10 months
Re: [Kimchi-devel] [kimchi] The auto logout leaves action menu on page (#294)
by Yu Xin Huo
Sorry, it is not host tab, but guest tab.
On 1/23/2014 5:44 AM, Adam King wrote:
> Yu Xin,
>
> I was checking out some of the outstanding issues. I can't recreate this
> as there isn't a host action menu, at least not the way I am reading
> your issue description.
> Can you elaborate, and/or include a picture?
>
> Thanks,
> Adam
> On 12/30/2013 3:29 AM, Yu Xin Huo wrote:
> >
> > Happened to see an issue.
> >
> > 1. bring up action menu of host and leave it there
> > 2. when session timeout, the login dialog popup behind the menu
> >
> > This looks quite bad although it is not an functional issue.
> >
> > —
> > Reply to this email directly or view it on GitHub
> > <https://github.com/kimchi-project/kimchi/issues/294>.
> >
>
> --
> Adam King <rak(a)linux.vnet.ibm.com>
> IBM CSI
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/kimchi-project/kimchi/issues/294#issuecomment-33071839>.
>
10 years, 10 months
Apply code guidelines
by Crístian Viana
Hi!
I am sending this patchset as an attempt to make the Kimchi code more
consistent. Some of the changes are specified by the PEP8 Style Guide, some of
them are not. This is only *one attempt*; these rules do not need necessarily to
be commited. If you do not agree or have any question regarding the patches,
feel free to discuss them here.
Currently, there is no standard for the Kimchi code and I think we should have
an official code guideline, that is why I am trying to apply these patches. It
does not need to be exactly these rules but adopting some kind of style instead
of the subjectivity of each developer will be a nice addition to the project.
As soon as we define our guidelines, we should have a wiki page or some file
describing them all.
10 years, 10 months
[PATCH V2 0/4] support create/delete VMIface
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
This patch depends on "[PATCH V2 0/6] VM supports interfaces"
V1 -> V2
do not support hot plugging attach/detach interface
we will support this feature after we implement events.
1. get all vms:
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type: application/json' http://localhost:8000/vms
2. get all networks:
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type: application/json' http://localhost:8000/networks
3. get all ifaces of a vm
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type: application/json' http://localhost:8000/vms/test-vm-0/ifaces/
[
{
"mac":"52:54:00:00:00:01",
"model":"virtio",
"type":"network",
"network":"default"
}
]
4. attach a new iface to vm
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type: application/json' http://localhost:8000/vms/test-vm-8/ifaces -X POST -d '
{
"type":"network",
"network":"test-network-0"
}
'
{
"mac":"52:54:00:00:00:0d",
"model":"virtio",
"type":"network",
"network":"test-network-0"
}
5. detach a iface from vm
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type: application/json' http://localhost:8000/vms/test-vm-8/ifaces/52:54:00:00:00:0d -X DELETE
ShaoHe Feng (4):
support create/delete VMIface: update model
support create/delete VMIface: update mockmodel
support create/delete VMIface: update API.json
support create/delete VMIface: update testcase
src/kimchi/API.json | 21 ++++++++++++++++++
src/kimchi/mockmodel.py | 21 ++++++++++++++++++
src/kimchi/model.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++-
tests/test_model.py | 22 +++++++++++++++++++
tests/test_rest.py | 27 +++++++++++++++++++++++
5 files changed, 147 insertions(+), 1 deletion(-)
--
1.8.4.2
10 years, 10 months