Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Docker Image CI

on: [push]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Build the Docker image
run: docker build . --file Dockerfile --tag fctninc/snmp-unity-agent:$(date +%s)

- name: Publish to Docker Hub
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: fctninc/snmp-unity-agent
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.7-alpine3.10

RUN apk add --quiet --no-cache \
gcc g++ make libffi-dev openssl-dev

COPY . /app

WORKDIR /app

RUN python setup.py install

RUN snmpagent-unity create-community --name public

ENTRYPOINT [ "snmpagent-unity" ]

CMD ["run", "--conf_file", "/app/unity.ini"]
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ Restart a SNMP agent. An error will occur if not running daemon found.

snmpagent-unity stop

Docker & Foreground service
^^^^^^^^^^^^^^^^^^^^^^^^^^^

When running in docker, it has to be run in foreground, cli allows this

.. code-block:: console

snmpagent-unity run --conf_file <file_path>

Start a SNMP agent in the foreground with the specified configuration
file ``<file_path>``.

.. code-block:: console

docker run -v /path/to/config.conf:/app/config.conf -p 11161:11161/udp fctninc/snmp-unity-agent:latest run --conf_file /app/config.conf

SNMP user management
^^^^^^^^^^^^^^^^^^^^
- Create a SNMP v2 community
Expand Down
1 change: 1 addition & 0 deletions snmpagent_unity/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
start Start a SNMP agent daemon
stop Stop the SNMP agent daemon
restart Restart the SNMP agent daemon
run Run the agent in foreground (for docker)

examples:
snmpagent-unity --help
Expand Down
2 changes: 1 addition & 1 deletion snmpagent_unity/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
CMD = [user.AddUser, user.UpdateUser, user.DeleteUser, user.ListUsers,
community.CreateCommunity, community.DeleteCommunity,
crypto.Encrypt, crypto.Decrypt,
service.Start, service.Stop, service.Restart]
service.Start, service.Stop, service.Restart, service.Run]

CMD_DICT = {cmd.name: cmd for cmd in CMD}
25 changes: 25 additions & 0 deletions snmpagent_unity/commands/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def _stop():
return agentd.agent_daemon.stop()


def _run(conf_file):
return agentd.main(conf_file)


def _get_running_conf():
return agentd.agent_daemon.get_running_conf()

Expand Down Expand Up @@ -56,6 +60,27 @@ def do(self):
return _stop()


class Run(base.BaseCommand):
"""
Dell-EMC SNMP agent: run the SNMP agent.

usage:
snmpagent-unity run --conf_file /tmp/agent.conf

options:
--conf_file <conf_file> Agent configuration file path

examples:
snmpagent-unity run --conf_file /tmp/agent.conf
"""
name = 'run'
log_to_stdout = True

@utils.log_command_exception
def do(self):
return _run(self.args['--conf_file'])


class Restart(base.BaseCommand):
"""
Dell-EMC SNMP agent: Restart the running SNMP agent.
Expand Down