Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agant cannot connect to sysdb #25

Closed
athos0212 opened this issue May 17, 2017 · 18 comments
Closed

agant cannot connect to sysdb #25

athos0212 opened this issue May 17, 2017 · 18 comments
Assignees

Comments

@athos0212
Copy link

athos0212 commented May 17, 2017

veos-log.txt
in veos, example helloWorld can not connect to sysdb, catting log shows:
waiting for connection to Sysdb .............................................................

@ruferp
Copy link
Contributor

ruferp commented May 17, 2017

This most probably means there is no "mount profile" for the HelloWorld application in /usr/lib/SysdbMountProfiles.
Mount profiles are required since release 4.16.x.
A mount profile tells the system what to mount from Sysdb for that application.
Each manager that the application uses requires a corresponding line in the application's profile. The first line of the profile identifies the application the profile is for, the filename itself is irrelevant (just needs to be unique).
There is a brute-force profile that can be used as a guide at /usr/lib/SysdbMountProfiles/EosSdkAll. Its first line needs to be adapted according to the application's binary name: replace the "EosSdk" part of the first line with the basename of your binary. Then optionally remove the lines from the managers your application does not use (for performance reasons).

Here is a copy/paste way to produce that profile on the bash prompt of the EOS switch:
but first change the first line to match your application's executable (see "myApp" below)

bin=/usr/bin/myApp # <<<=== adapt this line
name=$(basename $bin)
dest=/usr/lib/SysdbMountProfiles/$name
source="/usr/lib/SysdbMountProfiles/EosSdkAll"
cat $source | sed "1s/agentName[ ]:./agentName:${name}-%sliceId/" > /tmp/tmp_$name
delta=$(cmp /tmp/tmp_$name $source)
if [ "$?" = "0" ]; then
echo "Error: something is wrong"
else
sudo mv /tmp/tmp_$name $dest
fi

The mount profile will be /usr/lib/SysdbMountProfiles/myApp

You will need to re-install that file to /usr/libSysdbMountProfiles after a reboot. This can be done via a "on-boot" script, or by packaging that profile into an RPM and configure EOS to boot with it (that's the best route if your application is already installed via an RPM).

The on-boot script route looks like this:

switch(config)# event-handler
switch(config-handler)# trigger on-boot
switch(config-handler)# action bash /mnt/flash/.sh

where /mnt/flash/.sh is a script that copies (installs) the profile from /mnt/flash to /usr/lib/SysdbMountProfiles.

The RPM route looks like this (after scp-ing the RPM to /tmp on the switch):

switch(config)# copy file:/tmp/myApp.i686.rpm extension:
switch(config)# extension myApp.i686.rpm
switch(config)# copy installed-extensions boot-extensions

The second line installs the RPM, the third one makes sure it will get re-installed after a reboot.

@athos0212
Copy link
Author

It works. Thank you for the quick response.

@ruferp
Copy link
Contributor

ruferp commented May 17, 2017

slight correction, the stars did not survive the copy/paste into this wiki, added them as STAR below:

cat $source | sed "1s/agentName[ ]STAR:.STAR/agentName:${name}-%sliceId/" > /tmp/tmp_$name

N.B. this would work too, but would not detect any errors in case the template file is not as expected:

cat $source | sed "1s/.STAR/agentName:${name}-%sliceId/" > /tmp/tmp_$name

@chency
Copy link

chency commented Oct 9, 2017

@ruferp It seems not work on my VM(vEOS-lab-4.18.1F.vmdk).Is there anything missing?
binary file:/mnt/flash/HelloWorld.py
(copy from EosSdk/examples/HelloWorld.py)

The mount profile:/mnt/flash/HelloWorld

bin=/mnt/flash/HelloWorld.py
name=$(basename $bin)
dest=/usr/lib/SysdbMountProfiles/$name
source="/usr/lib/SysdbMountProfiles/EosSdkAll"
cat $source | sed "1s/agentName[ ]*:.*/agentName:${name}-%sliceId/" > /tmp/tmp_$name
delta=$(cmp /tmp/tmp_$name $source)
if [ "$?" = "0" ]; then
  echo "Error: something is wrong"
else
  sudo mv /tmp/tmp_$name $dest
fi

The on-boot script:/mnt/flash/HelloWorld-install.sh

#!/bin/bash
echo "Start HelloWorld-install bash"
sudo cp /mnt/flash/HelloWorld /usr/lib/SysdbMountProfiles/HelloWorld.py

@ruferp
Copy link
Contributor

ruferp commented Oct 9, 2017

don't use extensions like .py, just call you binary HelloWorld.
The .py will mess up stuff at multiple levels in our code!

And the .py is quite irrelevant: binaries usually don't have extensions, although I do see a few in linux, but that's really an exception:

prufer@ubuntu:~/cross/gcc/gcc-4.9.2$ ls /usr/bin  | grep ".*\.[^0-9]" | sed 's/.*\.//' | sort | uniq -c | sort -n -r | head
      6 py
      4 pl
      2 sh
      2 gold
      2 bfd
      1 yacc
      1 x11
      1 wrapper
      1 ul
      1 tiny
prufer@ubuntu:~/cross/gcc/gcc-4.9.2$ ls /usr/bin/*.py
/usr/bin/miniterm.py    /usr/bin/pildriver.py  /usr/bin/pilfont.py
/usr/bin/pilconvert.py  /usr/bin/pilfile.py    /usr/bin/pilprint.py
prufer@ubuntu:~/cross/gcc/gcc-4.9.2$ 
prufer@ubuntu:~/cross/gcc/gcc-4.9.2$ ls /usr/bin | wc
   1496    1496   15691
prufer@ubuntu:~/cross/gcc/gcc-4.9.2$ 

@chency
Copy link

chency commented Oct 10, 2017

Ah~~~! It isn't a binary file. A python file copy from EosSdk/examples/HelloWorld.py!
Even if I change the file to HelloWorld,it still in waitting for connet sysdb.....
Only work for binary file?

@ruferp
Copy link
Contributor

ruferp commented Oct 10, 2017

binary or py makes no difference, as far as mount profile is concerned.
Have you re-generated the mount profile after the name change, or at least edited the old one to remove the .py in the first line?

@chency
Copy link

chency commented Oct 10, 2017

I have done it both,but it still no work.
default

@chency
Copy link

chency commented Oct 10, 2017

The log file:
HelloWorld-HelloWorldAgent-2858.zip

@ruferp
Copy link
Contributor

ruferp commented Oct 10, 2017

This:

bin=/mnt/flash/HelloWorld.py
name=$(basename $bin)
dest=/usr/lib/SysdbMountProfiles/$name
source="/usr/lib/SysdbMountProfiles/EosSdkAll"
cat $source | sed "1s/agentName[ ]*:.*/agentName:${name}-%sliceId/" > /tmp/tmp_$name
delta=$(cmp /tmp/tmp_$name $source)
if [ "$?" = "0" ]; then
  echo "Error: something is wrong"
else
  sudo mv /tmp/tmp_$name $dest
fi

is not supposed to be the mount profile itself, but how to create it!
Try:
bash
sudo su
source /usr/lib/libSysdbMountProfiles/HelloWord
exit
(I guess the bash script can overwrite itself since that's the last thing it does)

@chency
Copy link

chency commented Oct 10, 2017

Still not word, maybe the Sysdb not running!
After I reboot the vm(have added source cmd in my on-boot script), the HelloWorld mount file in /usr/lib/SysdbMountProfiles/ changed to

agentName:HelloWorld-%sliceId

Include: EosSdk_acl.include
Include: EosSdk_agent.include
Include: EosSdk_class_map.include
Include: EosSdk_decap_group.include
Include: EosSdk_directflow.include
Include: EosSdk_eth_intf.include
Include: EosSdk_eth_lag_intf.include
Include: EosSdk_eth_phy_intf.include
Include: EosSdk_fib.include
Include: EosSdk_hardware_table.include
Include: EosSdk_intf.include
Include: EosSdk_IntfMgrHelper.include
Include: EosSdk_ip_intf.include
Include: EosSdk_ip_route.include
Include: EosSdk_lldp.include
Include: EosSdk_mac_table.include
Include: EosSdk_mlag.include
Include: EosSdk_mpls_route.include
Include: EosSdk_neighbor_table.include
Include: EosSdk_nexthop_group.include
Include: EosSdk_policy_map.include
Include: EosSdk_subintf.include
Include: EosSdk_system.include
Include: EosSdk_vrf.include
Include: EosSdk_GOpenFlow.include
Include: EosSdk_bfd_session.include

Email: [email protected]

@ruferp
Copy link
Contributor

ruferp commented Oct 10, 2017

I did not see any EOS switch window there

@chency
Copy link

chency commented Oct 10, 2017

I tested it on the VMware Workstation named Fedora 4_18(baseed on vEOS-lab-4.18.1F.vmdk).
Only work on real EOS switch?

@ruferp
Copy link
Contributor

ruferp commented Oct 10, 2017

It looks like it is working now.

@chency
Copy link

chency commented Oct 10, 2017

@ruferp Thank you for the quick response and the remote assistance.

Run the HelloWorld.py on VM

  1. Copy python file (EosSdk/examples/HelloWorld.py) to /mnt/flash.
  2. Rename with HelloWorld(/mnt/flash/HelloWorld)
  3. Create mount file(/mnt/flash/HelloWorld.profile)
bin=/mnt/flash/HelloWorld
name=$(basename $bin)
dest=/usr/lib/SysdbMountProfiles/$name
source="/usr/lib/SysdbMountProfiles/EosSdkAll"
cat $source | sed "1s/agentName[ ]*:.*/agentName:${name}-%sliceId/" > /tmp/tmp_$name
delta=$(cmp /tmp/tmp_$name $source)
if [ "$?" = "0" ]; then
  echo "Error: something is wrong"
else
  sudo mv /tmp/tmp_$name $dest
fi

  1. Create on-boot script(/mnt/flash/HelloWorld-install.sh)
#!/bin/bash
echo "Start HelloWorld-install bash"
sudo /mnt/flash/HelloWorld.profile
  1. Persist your Agent
v-EOS#conf
v-EOS(config)#event-handler HelloWorld-install 
v-EOS(config-handler-HelloWorld-install)#trigger on-boot
v-EOS(config-handler-HelloWorld-install)#action bash /mnt/flash/HelloWorld-install.sh
v-EOS(config-handler-HelloWorld-install)#end
v-EOS#write
Copy completed successfully.
v-EOS#

A litter problem comes out after I reboot the VM.
It seems the HelloWorldAgent is started before the on-boot script has been excuted.
After the VM is successed reboot, the HelloWorldAgent auto-run...but waitting for connet Sysdb....
Then I shut it down, and restart it,it work again.

    v-EOS>en
    v-EOS#conf
    v-EOS(config)#daemon HelloWorldAgent 
    v-EOS(config-daemon-HelloWorldAgent)#show daemon 
    Process: HelloWorldAgent (running)
    No configuration options stored.

    No status data stored.

    v-EOS(config-daemon-HelloWorldAgent)#shutdown
    v-EOS(config-daemon-HelloWorldAgent)#exec /mnt/flash/HelloWorld
    v-EOS(config-daemon-HelloWorldAgent)#no shutdown
    This is an EosSdk application
    Full agent name is 'HelloWorld-HelloWorldAgent'
    v-EOS(config-daemon-HelloWorldAgent)#show daemon
    Agent: HelloWorldAgent (running)
    No configuration options stored.

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

@ruferp
Copy link
Contributor

ruferp commented Oct 10, 2017

Yes, that's a known problem with the on-boot triggers: indeed, your agent may get started before the on-boot script runs. After 10 minutes the agent will give up looking for sysdb and restart, at which point it will find a mount-profile and thus can talk to sysdb.
That's why it is better to create an 'extension' that contains your agent and its profiles (and other files it may need), because those get installed before any agent gets started (EventMgr is the agent that will react to the on-boot configuration, and if he does this after your agent has started, then you are toast). I think there is also an rc file that can be put into /mnt/flash that get executed right after the EOS.swi got extracted, but I'm not sure about that (and/or how it has to be named).

@ruferp
Copy link
Contributor

ruferp commented Oct 11, 2017

You can use an rc script that gets run after the EOS.swi image was extracted and before the agents run (instead of the on-boot script that runs too late to create a mount-profile for your agent that is configured in the startup-config).

Here is an example/illustration (where you see how to call the script, namely rc.eos):

$ ssh [email protected]
Password:
vEOS1>en
vEOS1#bash

Arista Networks EOS shell

[admin@vEOS1 ~]$ cat /mnt/flash/rc.eos
#!/bin/bash
outf=/tmp/rc.eos.out
whoami > $outf
ls /usr/bin/Aaa.sh >> $outf
ps -ef | grep Sysdb >> $outf
[admin@vEOS1 ~]$ cat /tmp/rc.eos.out
root
/usr/bin/Aaa.sh  <=== EOS.swi was extracted, but Sysdb is not yet running
[admin@vEOS1 ~]$

@ruferp
Copy link
Contributor

ruferp commented Oct 11, 2017

by the way, to set the root password (so you can ssh into the vm as root), don't use the "username secret " command, use this command instead:

aaa root secret 0 <password>

That will give you a bash shell inside the VM when you ssh; to get a Cli, just run "Cli -A" from bash.
Any user created through the username command will give you a Cli shell if you ssh in as them.
The username 'admin' is created without password, so if you want to be able to ssh in as admin without needed a password, then run this command first:

aaa authentication policy local allow-nopassword-remote-login

If somebody uses VMware fusion: this is how to have the vm get an ip address: dhclient ma1 (from bash), then use ifconfig to find the ip address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants