From e178fd6ee0caeff1e42243fe86bae10680d69462 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Mon, 1 Jun 2009 19:00:19 +0000 Subject: [PATCH] changes for 3.0 --- bootman.py | 18 ++++++++++-------- bwlimit.py | 4 ++-- emailTxt.py | 2 +- findbad.py | 6 +++--- getsshkeys.py | 12 ++++++------ grouprins.py | 8 ++++---- nodeaction.py | 2 +- nodecommon.py | 3 ++- nodeconfig.py | 2 +- nodegroups.py | 2 +- nodenetwork.py | 16 ++++++++-------- plc.py | 4 ++-- policy.py | 4 ++-- showlatlon.py | 4 ++-- syncplcdb.py | 6 +++--- testapi.py | 2 +- 16 files changed, 49 insertions(+), 46 deletions(-) diff --git a/bootman.py b/bootman.py index 6dc7ac8..5e8b908 100755 --- a/bootman.py +++ b/bootman.py @@ -386,7 +386,7 @@ def reboot(hostname, config=None, forced_action=None): return False if forced_action == "reboot": - conn.restart_node('rins') + conn.restart_node('reinstall') return True boot_state = conn.get_boot_state() @@ -593,7 +593,7 @@ def reboot(hostname, config=None, forced_action=None): ]: sequences.update({n : "restart_bootmanager_boot"}) - # conn.restart_bootmanager('rins') + # conn.restart_bootmanager('reinstall') for n in [ "bminit-cfg-auth-getplc-installinit-validate-exception-modulefail-update-debug-done", "bminit-cfg-auth-getplc-update-installinit-validate-exception-modulefail-update-debug-done", "bminit-cfg-auth-getplc-installinit-validate-bmexceptmount-exception-noinstall-update-debug-done", @@ -615,13 +615,15 @@ def reboot(hostname, config=None, forced_action=None): "bminit-cfg-auth-getplc-update-installinit-validate-rebuildinitrd-netcfg-disk-update4-update3-update3-implementerror-update-debug-done", "bminit-cfg-auth-getplc-installinit-validate-exception-bmexceptmount-exception-noinstall-update-debug-done", "bminit-cfg-auth-getplc-update-installinit-validate-exception-bmexceptmount-exception-noinstall-update-debug-done", + "bminit-cfg-auth-getplc-update-installinit-validate-bmexceptvgscan-exception-noinstall-update-debug-validate-bmexceptvgscan-done", + "bminit-cfg-auth-getplc-update-installinit-validate-exception-noinstall-update-debug-validate-done", ]: sequences.update({n : "restart_bootmanager_rins"}) # repair_node_keys sequences.update({"bminit-cfg-auth-bootcheckfail-authfail-exception-update-bootupdatefail-authfail-debug-done": "repair_node_keys"}) - # conn.restart_node('rins') + # conn.restart_node('reinstall') for n in ["bminit-cfg-auth-getplc-update-installinit-validate-rebuildinitrd-exception-chrootfail-update-debug-done", "bminit-cfg-auth-getplc-update-installinit-validate-rebuildinitrd-netcfg-update3-disk-update4-exception-chrootfail-update-debug-done", "bminit-cfg-auth-getplc-hardware-installinit-installdisk-installbootfs-installcfg-exception-chrootfail-update-debug-done", @@ -715,16 +717,16 @@ def reboot(hostname, config=None, forced_action=None): conn.restart_bootmanager('boot') elif sequences[s] == "restart_bootmanager_rins": if config and not config.quiet: print "...Restarting BootManager.py on %s "% node - conn.restart_bootmanager('rins') + conn.restart_bootmanager('reinstall') elif sequences[s] == "restart_node_rins": - conn.restart_node('rins') + conn.restart_node('reinstall') elif sequences[s] == "restart_node_boot": conn.restart_node('boot') elif sequences[s] == "repair_node_keys": if conn.compare_and_repair_nodekeys(): # the keys either are in sync or were forced in sync. # so try to reboot the node again. - conn.restart_bootmanager('rins') + conn.restart_bootmanager('reinstall') pass else: # there was some failure to synchronize the keys. @@ -819,7 +821,7 @@ def reboot(hostname, config=None, forced_action=None): args = {} try: node = api.GetNodes(hostname)[0] - net = api.GetNodeNetworks(node['nodenetwork_ids'])[0] + net = api.GetInterfaces(node['interface_ids'])[0] except: from nodecommon import email_exception email_exception() @@ -831,7 +833,7 @@ def reboot(hostname, config=None, forced_action=None): args['hostname'] = hostname args['network_config'] = nodenet_str - args['nodenetwork_id'] = net['nodenetwork_id'] + args['interface_id'] = net['interface_id'] m = PersistMessage(hostname, mailtxt.baddns[0] % args, mailtxt.baddns[1] % args, True, db='baddns_persistmessages') diff --git a/bwlimit.py b/bwlimit.py index 6b93156..850ad53 100755 --- a/bwlimit.py +++ b/bwlimit.py @@ -19,8 +19,8 @@ def main(): for h in d_nodes: host = d_nodes[h] - for nw_id in host['nodenetwork_ids']: - l_nw = plc.getNodeNetworks({'nodenetwork_id': host['nodenetwork_ids']}) + for nw_id in host['interface_ids']: + l_nw = plc.getNodeNetworks({'interface_id': host['interface_ids']}) bwlimit[h] = [] for nw in l_nw: if nw['bwlimit'] != None and nw['bwlimit'] < 500000: diff --git a/emailTxt.py b/emailTxt.py index d1bccaa..c6e33f1 100644 --- a/emailTxt.py +++ b/emailTxt.py @@ -550,7 +550,7 @@ To help us return this machine to running order, please verify that the register You may update the node's network information at the link below: - https://www.planet-lab.org/db/nodes/node_networks.php?id=%(nodenetwork_id)s + https://www.planet-lab.org/db/nodes/node_networks.php?id=%(interface_id)s If you have any questions, please feel free to contact us at PlanetLab Support (support@planet-lab.org). diff --git a/findbad.py b/findbad.py index 630f1c5..6420f99 100755 --- a/findbad.py +++ b/findbad.py @@ -56,7 +56,7 @@ def collectPingAndSSH(nodename, cohash): echo ' "bmlog":"'`ls /tmp/bm.log`'",' echo ' "bootcd":"'`cat /mnt/cdrom/bootme/ID`'",' echo ' "nm":"'`ps ax | grep nm.py | grep -v grep`'",' - echo ' "readonlyfs":"'`touch /var/log/monitor 2>&1`'",' + echo ' "readonlyfs":"'`touch /var/log/monitor 2>&1 ; touch /vservers/monitor.log 2>&1`'",' echo ' "dns":"'`host boot.planet-lab.org 2>&1`'",' echo ' "princeton_comon":"'`ls -d /vservers/princeton_comon`'",' @@ -220,7 +220,7 @@ EOF """) values['pcu'] = "NOPCU" site_id = d_node[0]['site_id'] last_contact = d_node[0]['last_contact'] - nodegroups = [ i['name'] for i in api.GetNodeGroups(d_node[0]['nodegroup_ids']) ] + nodegroups = [ i['groupname'] for i in api.GetNodeGroups(d_node[0]['nodegroup_ids']) ] values['plcnode'] = {'status' : 'SUCCESS', 'pcu_ids': pcu, 'boot_state' : d_node[0]['boot_state'], @@ -361,7 +361,7 @@ def main(): f_nodes = [config.node] l_nodes = filter(lambda x: x['hostname'] in f_nodes, l_nodes) elif config.nodegroup: - ng = api.GetNodeGroups({'name' : config.nodegroup}) + ng = api.GetNodeGroups({'groupname' : config.nodegroup}) l_nodes = api.GetNodes(ng[0]['node_ids']) elif config.site: site = api.GetSites(config.site) diff --git a/getsshkeys.py b/getsshkeys.py index b24b855..eae5883 100755 --- a/getsshkeys.py +++ b/getsshkeys.py @@ -135,27 +135,27 @@ class SSHKnownHosts: if type(host) == type(""): host = [host] # get the node(s) info - nodes = self.api.GetNodes(self.auth,host,["hostname","ssh_rsa_key","nodenetwork_ids"]) + nodes = self.api.GetNodes(self.auth,host,["hostname","ssh_rsa_key","interface_ids"]) # for each node's node network, update the self.nodenetworks cache nodenetworks = [] for node in nodes: - for net in node["nodenetwork_ids"]: + for net in node["interface_ids"]: nodenetworks.append(net) - plcnodenetworks = self.api.GetNodeNetworks(self.auth,nodenetworks,["nodenetwork_id","ip"]) + plcnodenetworks = self.api.GetInterfaces(self.auth,nodenetworks,["interface_id","ip"]) for n in plcnodenetworks: - self.nodenetworks[n["nodenetwork_id"]]=n + self.nodenetworks[n["interface_id"]]=n return nodes def _record_from_node(self, node, nokey_list=None): host = node['hostname'] key = node['ssh_rsa_key'] - nodenetworks = node['nodenetwork_ids'] + nodenetworks = node['interface_ids'] if len(nodenetworks)==0: return (host, None, None, None) - # the [0] subscript to node['nodenetwork_ids'] means + # the [0] subscript to node['interface_ids'] means # that this function wont work with multihomed nodes l_nw = self.nodenetworks.get(nodenetworks[0],None) if l_nw is None: return (host, None, None, None) diff --git a/grouprins.py b/grouprins.py index abb6fa1..b85bbad 100755 --- a/grouprins.py +++ b/grouprins.py @@ -107,7 +107,7 @@ class Reboot(object): # set node to 'rins' boot state. print "CALLING REBOOT +++ RINS" - plc.nodeBootState(host, 'rins') + plc.nodeBootState(host, 'reinstall') ret = reboot.reboot(host) pflags.setRecentFlag('pcu_rins_tried') @@ -189,11 +189,11 @@ def set_node_to_rins(host, fb): node = api.GetNodes(host, ['boot_state', 'last_contact', 'last_updated', 'date_created']) record = {'observation' : node[0], 'model' : 'USER_REQUEST', - 'action' : 'api.UpdateNode(%s, {"boot_state" : "rins"})' % host, + 'action' : 'api.UpdateNode(%s, {"boot_state" : "reinstall"})' % host, 'time' : time.time()} l = Log(host, record) - ret = api.UpdateNode(host, {'boot_state' : 'rins'}) + ret = api.UpdateNode(host, {'boot_state' : 'reinstall'}) if ret: # it's nice to see the current status rather than the previous status on the console node = api.GetNodes(host)[0] @@ -247,7 +247,7 @@ config = parsermodule.parse_args(parser) # COLLECT nodegroups, nodes and node lists if config.nodegroup: - ng = api.GetNodeGroups({'name' : config.nodegroup}) + ng = api.GetNodeGroups({'groupname' : config.nodegroup}) nodelist = api.GetNodes(ng[0]['node_ids']) hostnames = [ n['hostname'] for n in nodelist ] diff --git a/nodeaction.py b/nodeaction.py index cff7f6a..b130396 100755 --- a/nodeaction.py +++ b/nodeaction.py @@ -30,7 +30,7 @@ for node in config.args: if config.rins: print "Setting %s to rins" % node - api.UpdateNode(node, {'boot_state' : 'rins'}) + api.UpdateNode(node, {'boot_state' : 'reinstall'}) if config.backoff: print "Enabling Slices & Slice Creation for %s" % node diff --git a/nodecommon.py b/nodecommon.py index 4882420..2250492 100644 --- a/nodecommon.py +++ b/nodecommon.py @@ -75,6 +75,7 @@ def color_boot_state(l): elif l == "down": return red(l) elif l == "boot": return green(l) elif l == "rins": return blue(l) + elif l == "reinstall": return blue(l) else: return l @@ -182,7 +183,7 @@ def get_nodeset(config): f_nodes = [config.node] l_nodes = filter(lambda x: x['hostname'] in f_nodes, l_nodes) elif config.nodegroup: - ng = api.GetNodeGroups({'name' : config.nodegroup}) + ng = api.GetNodeGroups({'groupname' : config.nodegroup}) l_nodes = api.GetNodes(ng[0]['node_ids'], ['hostname']) elif config.site: site = api.GetSites(config.site) diff --git a/nodeconfig.py b/nodeconfig.py index ce644e6..ac84ec3 100755 --- a/nodeconfig.py +++ b/nodeconfig.py @@ -41,7 +41,7 @@ def main(): try: n = api.GetNodes(node)[0] #print n - net = api.GetNodeNetworks(n['nodenetwork_ids'])[0] + net = api.GetInterfaces(n['interface_ids'])[0] #print net node_keys = ['boot_state', 'key', 'last_updated', 'last_contact'] diff --git a/nodegroups.py b/nodegroups.py index 3f4b980..f5d46ba 100755 --- a/nodegroups.py +++ b/nodegroups.py @@ -81,7 +81,7 @@ def main(): group_str = "selection" else: - ng = api.GetNodeGroups({'name' : config.nodegroup}) + ng = api.GetNodeGroups({'grouname' : config.nodegroup}) nodelist = api.GetNodes(ng[0]['node_ids']) group_str = config.nodegroup diff --git a/nodenetwork.py b/nodenetwork.py index 5c1a439..baa64cd 100755 --- a/nodenetwork.py +++ b/nodenetwork.py @@ -8,32 +8,32 @@ import util.file if len(sys.argv[1:]) > 0: for host in sys.argv[1:]: n = api.GetNodes(host)[0] - nn = api.GetNodeNetworks(n['nodenetwork_ids']) + nn = api.GetInterfaces(n['interface_ids']) for nodenet in nn: - nnet2 = api.GetNodeNetworks({'ip': nodenet['ip']}) + nnet2 = api.GetInterfaces({'ip': nodenet['ip']}) print "len of nn entries with ip: %s == %s " % ( nodenet['ip'], len(nnet2) ) for nn2 in nnet2: n2 = api.GetNodes(nn2['node_id']) - print "\t%d node is attached to nodenetwork %s" % ( len(n2), nn2['nodenetwork_id'] ) + print "\t%d node is attached to nodenetwork %s" % ( len(n2), nn2['interface_id'] ) if len(n2) != 0 : n2 = n2[0] print #print "host %s : %s" % (n2['hostname'], n2['node_id']) else: pass - #print nn2['nodenetwork_id'] - #api.DeleteNodeNetwork(nn2['nodenetwork_id']) + #print nn2['interface_id'] + #api.DeleteNodeNetwork(nn2['interface_id']) else: nnids = util.file.getListFromFile('nnids.txt') nnids = [ int(i) for i in nnids] for id in nnids: - nnet2 = api.GetNodeNetworks(id) + nnet2 = api.GetInterfaces(id) for nn2 in nnet2: n2 = api.GetNodes(nn2['node_id']) if len(n2) == 0 : - print "\t%d node is attached to nodenetwork %s %s" % ( len(n2), nn2['nodenetwork_id'] , nn2['ip']), + print "\t%d node is attached to nodenetwork %s %s" % ( len(n2), nn2['interface_id'] , nn2['ip']), - netlist = api.GetNodeNetworks({'ip' : nn2['ip']}) + netlist = api.GetInterfaces({'ip' : nn2['ip']}) if len(netlist) != 1: node_len = len([ n['node_id'] for n in netlist]) print "\t but, ip %s is used by %s nodenetwork entries" % (nn2['ip'], node_len) diff --git a/plc.py b/plc.py index 6ca4695..5be15c8 100644 --- a/plc.py +++ b/plc.py @@ -232,14 +232,14 @@ def getSiteNodes2(loginbase): def getNodeNetworks(filter=None): api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True) - nodenetworks = api.GetNodeNetworks(auth.auth, filter, None) + nodenetworks = api.GetInterfaces(auth.auth, filter, None) return nodenetworks def getNodes(filter=None, fields=None): api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True) nodes = api.GetNodes(auth.auth, filter, fields) #['boot_state', 'hostname', - #'site_id', 'date_created', 'node_id', 'version', 'nodenetwork_ids', + #'site_id', 'date_created', 'node_id', 'version', 'interface_ids', #'last_updated', 'peer_node_id', 'ssh_rsa_key' ]) return nodes diff --git a/policy.py b/policy.py index a782a9d..7823237 100644 --- a/policy.py +++ b/policy.py @@ -943,7 +943,7 @@ class Action(Thread): self.actions['suspendslices'] = lambda args: plc.suspendSlices(args['hostname']) self.actions['nocreate'] = lambda args: plc.removeSliceCreation(args['hostname']) self.actions['close_rt'] = lambda args: close_rt_backoff(args) - self.actions['rins'] = lambda args: plc.nodeBootState(args['hostname'], "rins") + self.actions['rins'] = lambda args: plc.nodeBootState(args['hostname'], "reinstall") self.actions['noop'] = lambda args: args self.actions['reboot_node'] = lambda args: reboot_node(args) self.actions['reset_nodemanager'] = lambda args: args # reset_nodemanager(args) @@ -1248,7 +1248,7 @@ class Action(Thread): print "%s" % act_record['log'], print "%15s" % (['reboot_node'],) # Set node to re-install - plc.nodeBootState(act_record['nodename'], "rins") + plc.nodeBootState(act_record['nodename'], "reinstall") try: ret = reboot_node({'hostname': act_record['nodename']}) except Exception, exc: diff --git a/showlatlon.py b/showlatlon.py index aa09416..ea0891c 100755 --- a/showlatlon.py +++ b/showlatlon.py @@ -32,7 +32,7 @@ def gethardwarequality(nodename, fb): return "BAD" # "cpu_slow", if cstat['memsize'] != "null" and float(cstat['memsize']) < 2.8: return "BAD" # "mem_small", - if cstat['disksize'] != "null" and float(cstat['disksize']) < 300.0: + if cstat['disksize'] != "null" and float(cstat['disksize']) < 250.0: return "BAD" # "disk_small", if cstat['disksize'] == "null" and \ @@ -43,7 +43,7 @@ def gethardwarequality(nodename, fb): try: if float(cstat['cpuspeed']) >= 2.2 and \ float(cstat['memsize']) >= 2.8 and \ - (cstat['disksize'] == "null" or float(cstat['disksize']) >= 300.0): + (cstat['disksize'] == "null" or float(cstat['disksize']) >= 250.0): return "A-OK" except: print cstat diff --git a/syncplcdb.py b/syncplcdb.py index de6a474..6d28e34 100755 --- a/syncplcdb.py +++ b/syncplcdb.py @@ -51,10 +51,10 @@ def dsn_from_dsln(d_sites, id2lb, l_nodes): def create_netid2ip(l_nodes, l_nodenetworks): netid2ip = {} for node in l_nodes: - for netid in node['nodenetwork_ids']: + for netid in node['interface_ids']: found = False for nn in l_nodenetworks: - if nn['nodenetwork_id'] == netid: + if nn['interface_id'] == netid: found = True netid2ip[netid] = nn['ip'] if not found: @@ -73,7 +73,7 @@ def create_plcdb(): # get nodes at each site, and l_nodes = plc.getNodes({'peer_id':None}, ['hostname', 'node_id', 'ports', 'site_id', 'version', - 'last_updated', 'date_created', 'last_contact', 'pcu_ids', 'nodenetwork_ids']) + 'last_updated', 'date_created', 'last_contact', 'pcu_ids', 'interface_ids']) l_nodenetworks = plc.getNodeNetworks() (plcdb, hn2lb, lb2hn) = dsn_from_dsln(d_sites, id2lb, l_nodes) diff --git a/testapi.py b/testapi.py index ca62990..bab1647 100755 --- a/testapi.py +++ b/testapi.py @@ -12,7 +12,7 @@ try: site_nodes = api.GetNodes(site['node_ids']) site_people = api.GetPersons(site['person_ids']) for node in site_nodes: - network = api.GetNodeNetworks(node['nodenetwork_ids']) + network = api.GetInterfaces(node['interface_ids']) print "ok" except: sys.stderr.write(traceback.format_exc()) -- 2.43.0