From 5b094157601de9897092f2372f7a15542495136d Mon Sep 17 00:00:00 2001 From: Ken Raffenetti Date: Tue, 14 Nov 2006 17:31:52 +0000 Subject: adding Hostbase push tool git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2496 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Hostbase/hostbase/views.py | 31 ++++++++++++++++++++++++++----- tools/hostbase.py | 2 +- tools/hostbasepush.py | 16 ++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100755 tools/hostbasepush.py diff --git a/src/lib/Server/Hostbase/hostbase/views.py b/src/lib/Server/Hostbase/hostbase/views.py index 0d15fe106..6b228a805 100644 --- a/src/lib/Server/Hostbase/hostbase/views.py +++ b/src/lib/Server/Hostbase/hostbase/views.py @@ -682,6 +682,20 @@ def validate(request, new=False, host_id=None): and regex.host.match(request.POST['hostname'])): failures.append('hostname') + if not regex.printq.match(request.POST['printq']) and request.POST['printq']: + failures.append('printq') + + if not regex.user.match(request.POST['primary_user']): + failures.append('primary_user') + + if (not regex.user.match(request.POST['administrator']) + and request.POST['administrator']): + failures.append('administrator') + + if not (request.POST['location'] + and regex.location.match(request.POST['location'])): + failures.append('location') + if new: if (not regex.macaddr.match(request.POST['mac_addr_new']) and request.POST['mac_addr_new']): @@ -861,15 +875,22 @@ def zonenew(request): ## login required stuff ## uncomment the views below that you would like to restrict access to -## search = login_required(search) -## look = login_required(look) -## dns = login_required(dns) +## uncomment the lines below this point to restrict access to pages that modify the database +## anonymous users can still view data in Hostbase + ## edit = login_required(edit) ## confirm = login_required(confirm) ## dnsedit = login_required(dnsedit) ## new = login_required(new) ## remove = login_required(remove) -## zones = login_required(zones) -## zoneview = login_required(zoneview) ## zoneedit = login_required(zoneedit) ## zonenew = login_required(zonenew) + +## uncomment the lines below this point to restrict access to all of hostbase + +## search = login_required(search) +## look = login_required(look) +## dns = login_required(dns) +## zones = login_required(zones) +## zoneview = login_required(zoneview) + diff --git a/tools/hostbase.py b/tools/hostbase.py index c25be3370..974577e69 100755 --- a/tools/hostbase.py +++ b/tools/hostbase.py @@ -62,4 +62,4 @@ if opts[0][0] == '-c': fd.close() os.system('vi + /tmp/hostbase.%s.tmp' % host.id) os.system('batchadd.py /tmp/hostbase.%s.tmp' % host.id) - + os.system('rm /tmp/hostbase.%s.tmp' % host.id) diff --git a/tools/hostbasepush.py b/tools/hostbasepush.py new file mode 100755 index 000000000..61f2e046b --- /dev/null +++ b/tools/hostbasepush.py @@ -0,0 +1,16 @@ +#!/usr/bin/python + +__revision__ = "$Revision: $" + +import Bcfg2.Client.Proxy, os + +if not os.getuid() == 0: + print 'this command must be run as root' + raise SystemExit + +proxy = Bcfg2.Client.Proxy.bcfg2() +print 'building files...' +proxy.run_method('Hostbase.rebuildState', ()) +print 'running bcfg...' +os.system('bcfg2 -q -d -v') + -- cgit v1.2.3-1-g7c22