CCI-MOC / ORE

MOC OpenStack Research Environment
Apache License 2.0
2 stars 3 forks source link

Have to repeatedly source openrc #17

Closed lkatalin closed 6 years ago

lkatalin commented 6 years ago

I noticed that in order to be able to use openstack I have to run source /opt/stack/devstack/openrc admin admin every time I ssh to the instance I created with this devstack, and I wanted this to run automatically instead.

So I altered /opt/stack/devstack/openrc to have admin as default for both OS_USERNAME and OS_PROJECT_NAME and stuck a single line script into /etc/profile.d/ that runs source /opt/stack/devstack/openrc admin admin &> /dev/null on start-up of the shell.

Is there a way to make these changes part of the default configuration for the ORE, or do these types of changes reside in the image we launch from (rather than the config .yml files or patches) and therefore we can't really alter them?

Obviously this is pretty low priority.

HuzefaMandvi commented 6 years ago

This should be a quick one-line fix, np.

Little confused about this bit though:

So I altered /opt/stack/devstack/openrc to have admin as default for both OS_USERNAME and OS_PROJECT_NAME

Is the default not already admin? I have been running source openrc admin admin without changing anything in openrc

EmreAtes commented 6 years ago

I add . $HOME/devstack/openrc admin admin to $HOME/.bashrc, maybe something like that could be done?

Also, as far as I remember this breaks scp, so this would be a better fix:

if [[ $- == *i* ]]
then # interactive mode
    . $HOME/devstack/openrc admin admin
fi
lkatalin commented 6 years ago

@HuzefaMandvi When I looked in my openrc, I saw OS_USERNAME and OS_PROJECT_NAME default to demo, ex:

export OS_PROJECT_NAME=${OS_PROJECT_NAME:-demo}

... with this part of openrc checking for other arguments instead: if [[ -n "$1" ]]; then OS_USERNAME=$1 fi if [[ -n "$2" ]]; then OS_PROJECT_NAME=$2 fi

I think if that were not the case, it would be enough to source /opt/stack/devstack/openrc without the admin arguments. Does that seem right?

lkatalin commented 6 years ago

Ah, sorry, what I meant to say is that I put a script in /etc/profile.d/ that has source /opt/stack/devstack/openrc &> /dev/null; what I wrote at first is redundant.

@EmreAtes 's fix seems good too.

HuzefaMandvi commented 6 years ago

I see now. In the interest of keeping ORE as lightweight as possible, I think we will go ahead and keep the "admin admin" bit rather than modify openrc. As an aside, one of my goals for ORE is to modify devstack code as little as possible, and instead keep the changes in the yaml template and local.conf.

lkatalin commented 6 years ago

I think we will go ahead and keep the "admin admin" bit rather than modify openrc

That makes total sense, I just had the same thought. Agree strongly about keeping things modular & tidy.