From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci cluster/form-macros site/luci/Exten ...
Date: 31 Jan 2007 23:36:27 -0000 [thread overview]
Message-ID: <20070131233627.6284.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-01-31 23:36:26
Modified files:
luci/cluster : form-macros
luci/site/luci/Extensions: cluster_adapters.py
Log message:
fix vm service code
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.168&r2=1.169
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.221&r2=1.222
--- conga/luci/cluster/form-macros 2007/01/31 05:26:44 1.168
+++ conga/luci/cluster/form-macros 2007/01/31 23:36:26 1.169
@@ -3735,31 +3735,93 @@
</div>
<div metal:define-macro="xenvmadd-form">
- <span tal:define="global vmforminfo python: here.getXenVMInfo(modelb, request)"/>
- <form method="get" tal:attributes="action vmforminfo/formurl">
- <h4>Name for this VM: </h4><input type="text" name="xenvmname" value=""/>
- <h4>Path to configuration file: </h4><input type="text" name="xenvmpath" value=""/>
- <input type="submit" value="Create Xen VM"/>
- </form>
+<form method="post" action="">
+ <input type="hidden" name="clustername"
+ tal:attributes="value request/clustername | nothing" />
+
+ <input type="hidden" name="pagetype"
+ tal:attributes="value request/pagetype | nothing" />
+
+ <div class="service_comp_list">
+ <table class="systemsTable">
+ <thead class="systemsTable">
+ <tr class="systemsTable"><td class="systemsTable">
+ <p class="reshdr">Create a Virtual Machine Service</p>
+ </td></tr>
+ <tfoot class="systemsTable">
+ <tr class="systemsTable"><td colspan="2">
+ <div class="hbSubmit">
+ <input type="submit" value="Create Virtual Machine" />
+ </div>
+ </td></tr>
+ </tfoot>
+ <tbody class="systemsTable">
+ <tr class="systemsTable">
+ <td>Virtual machine name</td>
+ <td><input type="text" name="vmname" value="" /></td>
+ </tr>
+ <tr class="systemsTable">
+ <td>Path to VM configuration file</td>
+ <td><input type="text" name="vmpath" value="" /></td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+</form>
</div>
<div metal:define-macro="xenvmconfig-form">
- <h4>Properties for Xen VM <font color="green"><span tal:content="request/servicename"/></font></h4>
- <span tal:define="global xeninfo python:here.getXenVMInfo(modelb, request)">
- <form method="get" tal:attributes="action xeninfo/formurl">
- <h4>Name of VM: </h4><input type="text" name="xenvmname" value="" tal:attributes="value xeninfo/name"/>
- <h4>Path to configuration file: </h4><input type="text" name="xenvmpath" value="" tal:attributes="value xeninfo/path"/>
- <input type="button" value="Delete"/>
- <input type="submit" value="Update"/>
- </form>
- </span>
+<form method="post" action=""
+ tal:define="vminfo python:here.getXenVMInfo(modelb, request)">
+
+ <input type="hidden" name="clustername"
+ tal:attributes="value request/clustername | nothing" />
+
+ <input type="hidden" name="pagetype"
+ tal:attributes="value request/pagetype | nothing" />
+
+ <input type="hidden" name="oldname"
+ tal:attributes="value vminfo/name | nothing" />
+
+ <div class="service_comp_list">
+ <table class="systemsTable">
+ <thead class="systemsTable">
+ <tr class="systemsTable"><td class="systemsTable">
+ <p class="reshdr">Properties for <tal:block tal:replace="vminfo/name | string:virtual machine"/></p>
+ </td></tr>
+ <tfoot class="systemsTable">
+ <tr class="systemsTable"><td colspan="2">
+ <div class="hbSubmit">
+ <input name="submit" type="submit" value="Update Virtual Machine" />
+ <input name="delete" type="submit" value="Delete Virtual Machine" />
+ </div>
+ </td></tr>
+ </tfoot>
+ <tbody class="systemsTable">
+ <tr class="systemsTable">
+ <td>Virtual machine name</td>
+ <td>
+ <input type="text" name="vmname"
+ tal:attributes="value vminfo/name | nothing" />
+ </td>
+ </tr>
+ <tr class="systemsTable">
+ <td>Path to VM configuration file</td>
+ <td>
+ <input type="text" name="vmpath"
+ tal:attributes="value vminfo/path | nothing" />
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+</form>
</div>
<div metal:define-macro="xenvmprocess">
<span tal:define="retrn python:here.processXenVM(request)"/>
</div>
-
<div metal:define-macro="serviceadd-form">
<script type="text/javascript">
set_page_title('Luci ??? cluster ??? services ??? Add a new service');
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/01/31 19:28:08 1.221
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/01/31 23:36:26 1.222
@@ -1980,10 +1980,101 @@
response.redirect(request['URL'] + "?pagetype=" + NODE + "&clustername=" + clustername + '&nodename=' + nodename + '&busyfirst=true')
+def validateVM(self, request):
+ errors = list()
+
+ model = request.SESSION.get('model')
+
+ try:
+ vm_name = request.form['vmname'].strip()
+ if not vm_name:
+ raise Exception, 'blank'
+ except Exception, e:
+ luci_log.debug_verbose('validateVM0: no vm name: %s' % str(e))
+ errors.append('No virtual machine name was given.')
+
+ try:
+ vm_path = request.form['vmpath'].strip()
+ if not vm_path:
+ raise 'blank'
+ except Exception, e:
+ luci_log.debug_verbose('validateVM1: no vm path: %s' % str(e))
+ errors.append('No path to the virtual machine configuration file was given.')
+
+ if len(errors) > 0:
+ return (False, {'errors': errors })
+
+ isNew = False
+ try:
+ old_name = request.form['oldname'].strip()
+ if not old_name:
+ raise KeyError, 'oldname'
+ except KeyError, e:
+ isNew = True
+
+ if isNew is True:
+ xvm = Vm()
+ xvm.addAttribute('name', vm_name)
+ xvm.addAttribute('path', vm_path)
+ rmptr = model.getResourceManagerPtr()
+ rmptr.addChild(xvm)
+ else:
+ try:
+ xvm = model.retrieveXenVMsByName(old_name)
+ if not xvm:
+ raise Exception, 'not found'
+ except:
+ return (False, {'errors': ['No virtual machine named \"%s\" exists.' % old_name ]})
+ xvm.addAttribute('name', vm_name)
+ xvm.addAttribute('path', vm_path)
+
+ try:
+ model.setModified(True)
+ stringbuf = str(model.exportModelAsString())
+ if not stringbuf:
+ raise Exception, 'model is blank'
+ except Exception, e:
+ luci_log.debug_verbose('validateVM2: %s' % str(e))
+ errors.append('Unable to update the cluster model')
+
+ try:
+ clustername = model.getClusterName()
+ if not clustername:
+ raise Exception, 'cluster name from model.getClusterName() is blank'
+ except Exception, e:
+ luci_log.debug_verbose('validateVM3: %s' % str(e))
+ errors.append('Unable to determine the cluster name.')
+
+ if len(errors) > 0:
+ return (False, {'errors': errors })
+
+ rc = getRicciAgent(self, clustername)
+ if not rc:
+ luci_log.debug_verbose('validateVM4: no ricci for %s' % clustername)
+ return (False, {'errors': ['Unable to contact a ricci agent for this cluster.']})
+
+ batch_number, result = setClusterConf(rc, stringbuf)
+ if batch_number is None or result is None:
+ luci_log.debug_verbose('validateVM5: missing batch and/or result')
+ return (False, {'errors': [ 'Error creating virtual machine %s.' % vm_name ]})
+
+ try:
+ if isNew is True:
+ set_node_flag(self, clustername, rc.hostname(), str(batch_number), XENVM_ADD, "Creating virtual machine \'%s\'" % vm_name)
+ else:
+ set_node_flag(self, clustername, rc.hostname(), str(batch_number), XENVM_CONFIG, "Configuring virtual machine \'%s\'" % vm_name)
+ except Exception, e:
+ luci_log.debug_verbose('validateVM6: failed to set flags: %s' % str(e))
+
+ response = request.RESPONSE
+ response.redirect(request['URL'] + "?pagetype=" + SERVICES + "&clustername=" + clustername + '&busyfirst=true')
+
formValidators = {
6: validateCreateCluster,
7: validateConfigCluster,
15: validateAddClusterNode,
+ 18: validateVM,
+ 19: validateVM,
21: validateServiceAdd,
24: validateServiceAdd,
31: validateResourceAdd,
@@ -2959,7 +3050,10 @@
itemmap['cfgurl'] = baseurl + "?" + "clustername=" + cluname + "&servicename=" + item['name'] + "&pagetype=" + SERVICE
itemmap['delurl'] = baseurl + "?" + "clustername=" + cluname + "&servicename=" + item['name'] + "&pagetype=" + SERVICE_DELETE
- svc = model.retrieveServiceByName(item['name'])
+ try:
+ svc = model.retrieveServiceByName(item['name'])
+ except:
+ continue
dom = svc.getAttribute("domain")
if dom is not None:
itemmap['faildom'] = dom
@@ -4727,49 +4821,7 @@
return getNodeLogs(rc)
def processXenVM(self, req):
- model = req.SESSION.get('model')
- isNew = False
- try:
- xenvmname = req['servicename']
- except KeyError, e:
- isNew = True
-
- if isNew == True:
- xvm = Vm()
- xvm.addAttribute("name", req.form['xenvmname'])
- xvm.addAttribute("path", req.form['xenvmpath'])
- rmptr = model.getResourceManagerPtr()
- rmptr.addChild(xvm)
- else:
- xvm = model.retrieveXenVMsByName(self, xenvmname)
- xvm.addAttribute("name", req.form['xenvmname'])
- xvm.addAttribute("path", req.form['xenvmpath'])
-
- try:
- cp = model.getClusterPtr()
- cp.incrementConfigVersion()
- model.setModified(True)
- stringbuf = model.exportModelAsString()
- if not stringbuf:
- raise Exception, 'model is blank'
- except Exception, e:
- luci_log.debug_verbose('exportModelAsString error: %s' % str(e))
- return None
-
- try:
- clustername = model.getClusterName()
- if not clustername:
- raise Exception, 'cluster name from model.getClusterName() is blank'
- except Exception, e:
- luci_log.debug_verbose('error: getClusterName: %s' % str(e))
- return None
-
- rc = getRicciAgent(self, clustername)
- if not rc:
- luci_log.debug_verbose('Unable to find a ricci agent for the %s cluster' % clustername)
- return None
-
- setClusterConf(rc, stringbuf)
+ pass
def getXenVMInfo(self, model, request):
map = {}
next reply other threads:[~2007-01-31 23:36 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-31 23:36 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-09-21 3:11 [Cluster-devel] conga/luci cluster/form-macros site/luci/Exten rmccabe
2007-06-19 15:54 rmccabe
2007-05-03 20:16 rmccabe
2007-03-15 16:41 rmccabe
2007-03-14 22:38 rmccabe
2007-03-14 22:37 rmccabe
2007-03-05 16:50 rmccabe
2007-03-05 16:50 rmccabe
2007-03-05 16:49 rmccabe
2007-02-15 22:44 rmccabe
2007-02-08 3:46 rmccabe
2007-02-07 17:02 rmccabe
2007-02-07 16:55 rmccabe
2007-02-02 4:34 rmccabe
2007-02-02 0:11 rmccabe
2007-02-01 20:49 rmccabe
2007-01-31 5:26 rmccabe
2007-01-23 13:53 rmccabe
2007-01-15 18:21 rmccabe
2007-01-11 19:11 rmccabe
2007-01-10 21:40 rmccabe
2007-01-06 3:29 rmccabe
2006-12-14 23:14 rmccabe
2006-12-14 18:22 rmccabe
2006-12-11 22:42 rmccabe
2006-12-11 21:51 rmccabe
2006-12-06 22:11 rmccabe
2006-12-06 21:16 rmccabe
2006-11-13 21:40 rmccabe
2006-11-12 2:10 rmccabe
2006-11-09 20:32 rmccabe
2006-11-03 22:48 rmccabe
2006-10-25 1:53 rmccabe
2006-10-25 1:11 rmccabe
2006-10-13 21:25 rmccabe
2006-08-03 18:36 shuennek
2006-07-21 14:49 rmccabe
2006-07-20 16:59 rmccabe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070131233627.6284.qmail@sourceware.org \
--to=rmccabe@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).