Package: oglhslack
This project provides a ready to go implementation of theLighthouse
API Clientas a Slack Bot.It has also aDocker
imagefor launching
the slack bot in minutes.AuthenticationTheLighthouse API Clientexpects to find the following environment
variables:(required)OGLH_API_USERa valid Lighthouse user(required)OGLH_API_PASSa valid Lighthouse user’s password(required)OGLH_API_URLthe Lighthouse API url without/api/v1Lighthouse Slack BotIt expects to find the following environment variables:(required)SLACK_BOT_TOKENwhich is provided by Slack at the
moment ofcreating a bot.(required)SLACK_BOT_NAMEis the name given to the Slack bot.(required)SLACK_BOT_DEFAULT_CHANNELa default Slack channel
name used for warnings.(optional)SLACK_BOT_DEFAULT_LOG_CHANNELa Slack channel name
for logs, if it is not provided, logs will be printed to a file only,
but logs classified as high priority like warnings and errors will be
printed to theSLACK_BOT_DEFAULT_CHANNELwhenSLACK_BOT_DEFAULT_LOG_CHANNELis not set.(optional)SLACK_BOT_ADMIN_CHANNELis the name for the
administrator channel, if no name is informed, it is assumed to beoglhadmin.TheLighhouseSlack bot can be triggered as simple as:>>>fromoglhslackimportOgLhSlackBot>>>slack_bot=OgLhSlackBot()>>>slack_bot.listen()Or, straight from the terminal:$pythonoglhslack.pyCommandsIt is possible to interact with the Slack Bot in private messages (PM),
private or public channels. When commands are not performed in private
messages, they must be prefixed by@mybot, wheremybotis the
bot’s name.Built in commandsThere is a small set of commands which can be found the bot’s help, they
are pretty straight in what they do. It is possible this list of
commands through:@mybot helpSome commands have(admin only)on theirs descriptions, indicating
that they can be performed in theoglhadminchannel.API client commandsThis commands follow theLighthouse API
Clientconventions.For listing objects likenodesit is possible to perform:@mybot list nodesFor listing tags belonging to a node with idmy-node-name:@mybot list tags from node my-node-nameFor listing smartgroups:@mybot list smartgroups from nodesFor getting information regarding to a specific node:@mybot find node my-node-nameFor getting systems’s information:@mybot get hostname from systemIt works basically as:Listing objects of a given type, likenodes,ports, and so on. >listobjectsListing objects of a given type, belonging to a parent object, likesystem. >listobjectsfromparent-objectListing objects of a given type, belonging to a parent object specified
by its id. >listobjectsfromparent-objectparent-nameFind specific objects by their ids. >findobjectobject-nameFind specific objects by their ids, when belonging to parent objects. >findobjectobject-namefromparent-objectfindobjectobject-namefromparent-objectparent-nameGet objects whenlistandfinddo not apply >getobjectfromparent-objectChannels conventionsAdministration channelCommands that make changes in Lighthouse are not allowed in normal
channels or in private messages.In order to execute such commands, it is required that the Slack
administrator creates a channel namedoglhadmin, or with the name
specified in theSLACK_BOT_ADMIN_CHANNELenvironment variable. This
channel is supposed to be open for authorized members only.Docker imageThe Opengear Lighthouse docker image is available athttps://hub.docker.com/r/opengeardev/oglhslack/.It requires a file containing the environment variables as specifiedhere.It is supposed to be like:SLACK_BOT_TOKEN=xoxb-************-************************
SLACK_BOT_NAME=mybotname
SLACK_BOT_DEFAULT_CHANNEL=myDefaultChannel
SLACK_BOT_DEFAULT_LOG_CHANNEL=myDefaultLogChannel
SLACK_BOT_ADMIN_CHANNEL=oglhadmin
OGLH_API_USER=myOgLhUser
OGLH_API_PASS=myOgLhPassword
OGLH_API_URL=https://oglh-octo.opengear.comFor launching the Slack bot just run:$sudodockerrun--env-file/path/to/my/env.listopengeardev/oglhslack