message_queue = Field(String, default=None)
message_created = Field(DateTime, default=None)
- penalty_level = Field(Int, default=0)
+ penalty_level = Field(Int, default=0)
+ penalty_applied = Field(Boolean, default=False)
@classmethod
def by_loginbase(cls, loginbase):
except Exception, exc:
logger.info("nodePOD: %s" % exc)
+'''
+Freeze all site slices.
+'''
+def suspendSiteSlices(loginbase):
+ api = xmlrpclib.Server(auth.server, verbose=False)
+ for slice in slices(loginbase):
+ logger.info("Suspending slice %s" % slice)
+ try:
+ if not debug:
+ api.AddSliceAttribute(auth.auth, slice, "enabled", "0")
+ except Exception, exc:
+ logger.info("suspendSlices: %s" % exc)
+
'''
Freeze all site slices.
'''
except Exception, exc:
logger.info("suspendSlices: %s" % exc)
+def enableSiteSlices(loginbase):
+ api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True)
+ for slice in slices(loginbase):
+ logger.info("Enabling slices %s" % slice)
+ try:
+ if not debug:
+ slice_list = api.GetSlices(auth.auth, {'name': slice}, None)
+ if len(slice_list) == 0:
+ return
+ slice_id = slice_list[0]['slice_id']
+ l_attr = api.GetSliceAttributes(auth.auth, {'slice_id': slice_id}, None)
+ for attr in l_attr:
+ if "enabled" == attr['name'] and attr['value'] == "0":
+ logger.info("Deleted enable=0 attribute from slice %s" % slice)
+ api.DeleteSliceAttribute(auth.auth, attr['slice_attribute_id'])
+ except Exception, exc:
+ logger.info("enableSiteSlices: %s" % exc)
+ print "exception: %s" % exc
+
def enableSlices(nodename):
api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True)
for slice in slices(siteId(nodename)):
# logger.info("Suspending slice %s" % slice)
# api.SliceAttributeAdd(auth.auth, slice, "plc_slice_state", {"state" : "suspended"})
#
+def enableSiteSliceCreation(loginbase):
+ api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True)
+ try:
+ logger.info("Enabling slice creation for site %s" % loginbase)
+ if not debug:
+ logger.info("\tcalling UpdateSite(%s, enabled=True)" % loginbase)
+ api.UpdateSite(auth.auth, loginbase, {'enabled': True})
+ except Exception, exc:
+ print "ERROR: enableSiteSliceCreation: %s" % exc
+ logger.info("ERROR: enableSiteSliceCreation: %s" % exc)
+
def enableSliceCreation(nodename):
api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True)
try:
print "ERROR: enableSliceCreation: %s" % exc
logger.info("ERROR: enableSliceCreation: %s" % exc)
+'''
+Removes site's ability to create slices. Returns previous max_slices
+'''
+def removeSiteSliceCreation(sitename):
+ print "removeSiteSliceCreation(%s)" % sitename
+ api = xmlrpclib.Server(auth.server, verbose=False)
+ try:
+ logger.info("Removing slice creation for site %s" % sitename)
+ if not debug:
+ api.UpdateSite(auth.auth, sitename, {'enabled': False})
+ except Exception, exc:
+ logger.info("removeSiteSliceCreation: %s" % exc)
+
'''
Removes ability to create slices. Returns previous max_slices
'''
sitequery=[]
pcuquery=[]
nodequery=[]
+ actions=[]
exceptions = None
for key in data:
exceptions = data['exceptions']
if loginbase:
+ actions = ActionRecord.query.filter_by(loginbase=loginbase).order_by(ActionRecord.date_created.desc())
+ actions = [ a for a in actions ]
sitequery = [HistorySiteRecord.by_loginbase(loginbase)]
pcus = {}
for plcnode in site_lb2hn[loginbase]:
prep_pcu_for_display(pcu)
pcuquery += [pcu]
- return dict(sitequery=sitequery, pcuquery=pcuquery, nodequery=nodequery, exceptions=exceptions)
+ return dict(sitequery=sitequery, pcuquery=pcuquery, nodequery=nodequery, actions=actions, exceptions=exceptions)
@expose(template="monitorweb.templates.pculist")
def pcu(self, filter='all'):
<th mochi:format="int"></th>
<th>Hostname</th>
<th>last_contact</th>
- <th>Last_checked</th>
+ <th>last_checked</th>
<th nowrap='true'>Port Status</th>
<th></th>
<th></th>
</div>
<div id="status_block" class="flash"
py:if="value_of('tg_flash', None)" py:content="tg_flash"></div>
- <h4 py:if="len(pcuquery) > 0">Convenience Calls</h4>
- <?python
- if len(pcuquery) == 0: pcu = None
- ?>
- <div py:if="pcu is not None" class="code">
+
+ <h4>Recent Actions</h4>
+ <p py:if="actions and len(actions) == 0">
+ There are no recent actions taken for this site.
+ </p>
+ <table py:if="actions and len(actions) > 0" id="sortable_table" class="datagrid" border="1" width="100%">
+ <thead>
+ <tr>
+ <th mochi:format="int"></th>
+ <th>Date</th>
+ <th>Action taken on</th>
+ <th>Action Type</th>
+ <th>Message ID</th>
+ <th>Errors</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr py:for="i,act in enumerate(actions)" class="${i%2 and 'odd' or 'even'}" >
+ <td></td>
+ <td py:content="act.date_created"></td>
+ <td py:if="act.hostname is not None" nowrap="true" >
+ <a class="ext-link" href="${plc_node_uri(act.hostname)}">
+ <span class="icon">${act.hostname}</span></a>
+ </td>
+ <td py:if="act.hostname is None" nowrap="true">
+ <a class="ext-link" href="${plc_site_uri(act.loginbase)}">
+ <span class="icon">${act.loginbase}</span></a>
+ </td>
+ <!--td py : content="diff_time(mktime(node.date_checked.timetuple()))"></td-->
+ <td py:content="act.action_type"></td>
+ <td py:content="act.message_id"></td>
+ <td py:content="act.error_string"></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <!-- TODO: figure out how to make this conditional by model rather than port;
+ it is convenient to have links to ilo, drac, amt, etc.
+ regardless of whether the last PCU scan was successful. -->
+ <h4 py:if="len(pcuquery) != 0">Convenience Calls</h4>
+ <div py:if="len(pcuquery) != 0" class="code"> <!-- pcu is not None" class="code"-->
<span py:for="port,state in pcu.ports">
<span class="code" py:if="port == 22 and state == 'open'">
ssh -o PasswordAuthentication=yes -o PubkeyAuthentication=no
from monitor import parser as parsermodule
parser = parsermodule.getParser(['cacheset'])
- parser.set_defaults( setupglobal=False, syncsite=True, site=None, setupids=False)
+ parser.set_defaults( setupglobal=False, syncsite=True, site=None, sitelist=None, setupids=False)
parser.add_option("", "--setupids", action="store_true", dest="setupids",
help="Setup global IDs.")
parser.add_option("", "--setupglobal", action="store_true", dest="setupglobal",
help="Do not sync sites.")
parser.add_option("", "--site", dest="site",
help="Sync only given site name.")
+ parser.add_option("", "--sitelist", dest="sitelist",
+ help="Sync only given site names in the list.")
opts = parsermodule.parse_args(parser)
os.system("""echo '' > /usr/share/monitor/nodelist.txt""")