|
|
|
|
|
|
|
|
|
|
xen-changelog
[Xen-changelog] [xen-unstable] Add domain name check and UUID check to '
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1185296704 -3600
# Node ID 207582c8d88b532783da5c6f5839336187556f0a
# Parent d9836851a2a4cf6e506f6a8e162a4c90c9f87d82
Add domain name check and UUID check to 'xm new' command.
Add a domain name check and a UUID check to xm new command. The check
logic is as follows:
- If the UUID is not specified
- If a VM with same name exists
=> Update the config for that existing VM
- Else no vm with same name exists
=> Define a brand new VM with auto-generated UUID
- Else UUID is specified
- If a VM with same UUID exists
- If name is different
=> Error
- Else if name is same
=> Update the config for that existing VM
- Else no VM with same UUID exists
- If name is different
=> Define a branch new VM with that name
- Else if name is same
=> Error
Signed-off-by: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
---
tools/python/xen/xend/XendDomain.py | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+)
diff -r d9836851a2a4 -r 207582c8d88b tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py Tue Jul 24 15:47:36 2007 +0100
+++ b/tools/python/xen/xend/XendDomain.py Tue Jul 24 18:05:04 2007 +0100
@@ -51,6 +51,7 @@ from xen.xend.xenstore.xswatch import xs
from xen.xend.xenstore.xswatch import xswatch
from xen.util import mkdir
from xen.xend import uuid
+from xen.xend import sxp
xc = xen.lowlevel.xc.xc()
xoptions = XendOptions.instance()
@@ -968,6 +969,31 @@ class XendDomain:
try:
try:
domconfig = XendConfig.XendConfig(sxp_obj = config)
+
+ domains = self.list('all')
+ domains = map(lambda dom: dom.sxpr(), domains)
+ for dom in domains:
+ if sxp.child_value(config, 'uuid', None):
+ if domconfig['uuid'] == sxp.child_value(dom, 'uuid'):
+ if domconfig['name_label'] != sxp.child_value(dom,
'name'):
+ raise XendError("Domain UUID '%s' is already
used." % \
+ domconfig['uuid'])
+ else:
+ # Update the config for that existing domain
+ # because it is same name and same UUID.
+ break
+ else:
+ if domconfig['name_label'] == sxp.child_value(dom,
'name'):
+ raise XendError("Domain name '%s' is already
used." % \
+ domconfig['name_label'])
+ else:
+ if domconfig['name_label'] == sxp.child_value(dom,
'name'):
+ # Overwrite the auto-generated UUID by the UUID
+ # of the existing domain. And update the config
+ # for that existing domain.
+ domconfig['uuid'] = sxp.child_value(dom, 'uuid')
+ break
+
dominfo = XendDomainInfo.createDormant(domconfig)
log.debug("Creating new managed domain: %s" %
dominfo.getName())
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-changelog] [xen-unstable] Add domain name check and UUID check to 'xm new' command.,
Xen patchbot-unstable <=
|
|
|
|
|