amorenoz / ovs-dbg

Scripts to help debug OVS and OVN
Apache License 2.0
23 stars 8 forks source link

ovs-offline: add a bash environment script #58

Closed SalDaniele closed 3 years ago

SalDaniele commented 3 years ago

Starting ovs-offline will now generate a script that can be sourced to run ovs/ovn commands without needing to specify sock/ctl/mgmt.

The script also generates a restore script to return environment variables to their previous state.

fixes #48

Signed-off-by: Salvatore Daniele sdaniele@redhat.com

SalDaniele commented 3 years ago

@amorenoz question. Do you think it is necessary to generate the additional script to restore previous env variables / remove aliases?

Say the user wants to run ovs-appctl on a local live ovs set up in the same shell after? Or had a previously configured env variable for ovs/ovn? Or would this be to niche of a situation to warrant all the extra code? If so, I can clean this up a good deal before review.

Thanks,

Sal

amorenoz commented 3 years ago

@amorenoz question. Do you think it is necessary to generate the additional script to restore previous env variables / remove aliases?

I think it's desirable, yes. We can do that as a new enhancement afterwards but we can see this as the way pipenv / venv works in python.

$ source ./venv/bin/activate
$ (venv) python -m pip install ... (installs in the virtual environment)
$ (venv) python ...
$ (venv) deactivate
$ echo "back to my old terminal"
SalDaniele commented 3 years ago

The commit has now been updated to better emulate the behavior of virtualenv (custom bash prompt, deactivate command)

amorenoz commented 3 years ago

Also, if we are going to set env vars, I think we are going to have to fix #45

SalDaniele commented 3 years ago

Commit is updated.

Also, if we are going to set env vars, I think we are going to have to fix #45

I'll take a look at this next.

amorenoz commented 3 years ago

ovs-vsctl does not work with this PR

ovs-vsctl show
ovs-vsctl: unix:/tmp/ovs-offline/var-run/ovs/db.sock: database connection failed (No such file or directory)
SalDaniele commented 3 years ago

ovs-vsctl does not work with this PR

ovs-vsctl show
ovs-vsctl: unix:/tmp/ovs-offline/var-run/ovs/db.sock: database connection failed (No such file or directory)

Strange, it works on my test with both collect-k8s and collect-sos-ovs. The other commands work fine? What about ovs-ofctl?

If you have a moment, would you mind sending me the contents of /tmp/ovs-offline/var-run/ovs/ and the value on the env variable OVS_RUNDIR after you run source /tmp/ovs-offline/bin/activate?

amorenoz commented 3 years ago

Thanks @SalDaniele