Description of problem: spacecmd ssm_intersect does not save to cache like ssm_add or ssm_clear does Version-Release number of selected component (if applicable): spacecmd-2.6.16-1.el6.noarch Note that the issue is not corrected in the github repo. How reproducible: Consistently reproducible. Steps to Reproduce from bash using spacecmd one off commands and sessions 1. Login to spacecmd spacecmd -s server -- login 2. Clear the ssm cache and ensure no systems are in the cache. spacecmd -s server -- ssm_clear spacecmd -s server -- ssm_list | wc -l 3. Add systems to the ssm cache and confirm they are cached between sessions: spacecmd -q -- ssm_add 'channel:some_channel_name' spacecmd -- ssm_list | wc -l 4. Intersect systems with the ssm_intersect command and notice that they intersection is not stored in the cache spacecmd -q -- ssm_intersect group:"sub_group_name" spacecmd -- ssm_list | wc -l Steps to Reproduce within Spacecmd shell: 1. Login to spacecmd spacecmd -s server -- 2. Run the same set of commands as above and notice that the ssm_intersect is applied properly: spacecmd {SSM:0}> ssm_clear spacecmd {SSM:0}> ssm_list [...] spacecmd {SSM:0}> ssm_add 'channel:some_channel_name' spacecmd {SSM:59}> ssm_intersect group:"sub_group_name" spacecmd {SSM:59}> ssm_list [...] spacecmd {SSM:7}> ssm_list [...] spacecmd {SSM:7}> exit 3. Exit then re-enter the spacecmd shell, notice that the ssm cache is loaded from the result of the ssh_add but not from the last known memory cache (59 systems instead of 7 in SSM) spacecmd -s server -- spacecmd {SSM:59}> ssm_list [...] Actual results: The cache contains the systems resulting from the ssh_add. Expected results: The cache should contain the systems resulting from the ssh_add and ssh_intersect, similarly to the Web UI features. Additional info: When using the spacecmd shell, one can operate on the memory cache properly with ssm_intersect but not among sessions.
The fix is to add the following code at line 137 (copied from line 93-94): https://github.com/spacewalkproject/spacewalk/blob/master/spacecmd/src/lib/ssm.py#L137 # save the SSM for use between sessions save_cache(self.ssm_cache_file, self.ssm)
To work around this issue, one can pass all the commands at once to spacecmd: This sequence of commands applies the system_setbasechannel to all systems matching 'channel:some_channel_name': $ spacecmd -s server -- ssm_clear $ spacecmd -s server -- ssm_add 'channel:some_channel_name' $ spacecmd -s server -- ssm_intersect group:"sub_group_name" $ spacecmd -s server -- system_setbasechannel ssm "new_base_channel" To apply the setbasechannel command to the result of ssm add+intersect, run them as follow (in effect bypassing the ssm session file cache): $ echo -e 'ssm_clear ssm_add "channel:some_channel_name" ssm_intersect group:"sub_group_name" system_setbasechannel ssm "new_base_channel" | spacecmd -s server --
I created the following pull request: https://github.com/spacewalkproject/spacewalk/pull/621 Thomas
spacewalk fb2acef1860be38b52aa27c4b3056db4757cad22
Spacewalk 2.8 has been released. https://github.com/spacewalkproject/spacewalk/wiki/ReleaseNotes28