Skip to content

Instantly share code, notes, and snippets.

@mathershifter
Last active November 13, 2020 23:48
Show Gist options
  • Save mathershifter/75e02683f6b8e6813802cc0962aeb159 to your computer and use it in GitHub Desktop.
Save mathershifter/75e02683f6b8e6813802cc0962aeb159 to your computer and use it in GitHub Desktop.
EOSSDK HelloWorld configuration

EOSSDK Agent Install Example

copy the agent

host# chmod +x HelloWorld.py
host# scp HelloWorld.py admin@<switch>:/mnt/flash/HelloWorld

create the mount profile script

switch# bash
[admin@switch]$ cd /mnt/flash
[admin@switch flash]$ cat >mountprofile.sh <<EOF
#!/bin/sh

if [ -z $1 ]; then
        echo "Please specify an agent name"
        exit 1
fi

AGENT=$1
DEST=/usr/lib/SysdbMountProfiles/$AGENT
SOURCE="/usr/lib/SysdbMountProfiles/EosSdkAll"
TMP=/tmp/tmp_$AGENT
cat $SOURCE | sed "1s/agentName[ ]*:.*/agentName:${AGENT}-%sliceId/" > $TMP
delta=$(cmp /tmp/tmp_$AGENT $SOURCE)
if [ "$?" = "0" ]
then
  echo "Error: something is wrong"
  exit 1
else
  sudo mv $TMP $DEST
fi
EOF

Run the mount profile script

[admin@switch flash]$
[admin@switch flash]$ sh mountprofile.sh HelloWorld

configure the daemon/agent on the switch

host# ssh -l admin <switch>
switch# configure
switch (configure)# daemon HelloWorld
switch (config-daemon-HelloWorld)# exec /mnt/flash/HelloWorld
switch (config-daemon-HelloWorld)# no shutdown
switch (config-daemon-HelloWorld)# show daemon HelloWorld
Agent: HelloWorld (running with PID 15711)
Uptime: 0:00:02 (Start time: Fri Nov 13 22:03:55 2020)
No configuration options stored.

Status:
Data           Value
-------------- ---------------------------
greeting       Welcome! What is your name?

switch (config-daemon-HelloWorld)# option name set Rupesh
switch (config-daemon-HelloWorld)# show daemon HelloWorld
Agent: HelloWorld (running with PID 15255)
Uptime: 0:04:32 (Start time: Fri Nov 13 21:58:29 2020)
Configuration:
Option       Value
------------ ------
name         Rupesh

Status:
Data           Value
-------------- -------------
greeting       Hello Rupesh!

switch (config-daemon-HelloWorld)# no option name
switch (config-daemon-HelloWorld)# show daemon HelloWorld
Agent: HelloWorld (running with PID 15255)
Uptime: 0:04:54 (Start time: Fri Nov 13 21:58:29 2020)
No configuration options stored.

Status:
Data           Value
-------------- --------
greeting       Goodbye!

switch (config-daemon-HelloWorld)# shutdown
switch (config-daemon-HelloWorld)# show daemon HelloWorld
Agent: HelloWorld (shutdown with PID 15255)
No configuration options stored.

Status:
Data           Value
-------------- ------
greeting       Adios!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment