Commit 5b0af9e4 authored by Alexander Pace's avatar Alexander Pace
Browse files

Reverting to old lvalert_admin, deleting diagostic tools

parent 61a13f38
......@@ -20,6 +20,7 @@ from __future__ import print_function
import os
import time
import logging
import libxml2
import getpass
import uuid
from optparse import *
......@@ -27,9 +28,15 @@ from M2Crypto.SSL import Context
# pubsub import must come first because it overloads part of the
# StanzaProcessor class
from ligo.lvalert import pubsub
from ligo.lvalert.utils import safe_netrc
from ligo.lvalert import sleeklvalert
from pyxmpp.all import JID,Iq,Presence,Message,StreamError,TLSSettings
from pyxmpp.jabber.all import Client
from pyxmpp.jabber.dataforms import Form,DATAFORM_NS
from pyxmpp.interface import implements
from pyxmpp.interfaces import *
from pyxmpp.exceptions import ClientError, FatalClientError
"""
A tool to administer the pubsub service of openfire
......@@ -241,57 +248,49 @@ if opts.debug:
else:
logging.basicConfig(level=logging.ERROR)
# debug the memore
libxml2.debugMemory(1)
# set up the stream
# append UUID to resource to guarantee that it is non-empty and unique
#myjid=JID(myusername+"@"+opts.server+"/"+opts.resource)
#s=MyClient(jid=myjid,password=mypassword)
myjid=JID(myusername+"@"+opts.server+"/"+opts.resource)
s=MyClient(jid=myjid,password=mypassword)
if opts.verbose:
print("connecting...")
s.connect()
client = sleeklvalert.LVAlertClient(username=myusername, \
password=mypassword, \
netrc=os.path.expanduser(opts.netrc), \
server=opts.server)
lvalert_connected = client.connect()
if opts.verbose and lvalert_connected:
print("connected...")
client.process(block=False)
#if opts.verbose:
# print("build pubsub stanza...")
#recpt=JID("pubsub."+opts.server)
#pspl=pubsub.PubSub(from_jid = myjid, to_jid = recpt, stream = s,\
#stanza_type="get")
if opts.verbose:
print("build pubsub stanza...")
recpt=JID("pubsub."+opts.server)
pspl=pubsub.PubSub(from_jid = myjid, to_jid = recpt, stream = s,\
stanza_type="get")
if opts.get_nodes:
print("Getting nodes")
client.get_nodes()
pspl.get_nodes()
elif opts.create:
print("Creating node " + opts.node)
pspl.create_node(opts.node)
elif opts.delete:
pspl.delete_node(opts.node)
elif opts.subscribe:
client.subscribe(opts.node)
pspl.subscribe(myjid,opts.node)
elif opts.unsubscribe:
client.unsubscribe(opts.node)
pspl.unsubscribe(myjid,opts.node,opts.unsubscribe_subid)
elif opts.subscriptions:
client.get_subscriptions()
#elif opts.affiliations:
#pspl.affiliations(myjid,opts.affiliations)
#elif opts.add_publisher:
#publisher_jid = opts.add_publisher.split('@')[0]
#publisher_jid=JID(publisher_jid+"@"+opts.server+"/Home")
#pspl.publisher(publisher_jid,opts.node,"publisher")
#elif opts.delete_publisher:
#publisher_jid = opts.delete_publisher.split('@')[0]
#publisher_jid=JID(publisher_jid+"@"+opts.server+"/Home")
#pspl.publisher(publisher_jid,opts.node,"none")
pspl.subscriptions(myjid)
elif opts.affiliations:
pspl.affiliations(myjid,opts.affiliations)
elif opts.add_publisher:
publisher_jid = opts.add_publisher.split('@')[0]
publisher_jid=JID(publisher_jid+"@"+opts.server+"/Home")
pspl.publisher(publisher_jid,opts.node,"publisher")
elif opts.delete_publisher:
publisher_jid = opts.delete_publisher.split('@')[0]
publisher_jid=JID(publisher_jid+"@"+opts.server+"/Home")
pspl.publisher(publisher_jid,opts.node,"none")
else:
client.get_nodes()
pspl.get_nodes()
if opts.verbose:
print("sending message...")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment