{"action":"created","issue":{"url":"https://api.github.com/repos/puppetlabs/beaker/issues/1081","repository_url":"https://api.github.com/repos/puppetlabs/beaker","labels_url":"https://api.github.com/repos/puppetlabs/beaker/issues/1081/labels{/name}","comments_url":"https://api.github.com/repos/puppetlabs/beaker/issues/1081/comments","events_url":"https://api.github.com/repos/puppetlabs/beaker/issues/1081/events","html_url":"https://github.com/puppetlabs/beaker/pull/1081","id":141095018,"number":1081,"title":"(BKR-722) Don't clobber user_pc in prepend_commands for cisco host","user":{"login":"glennmatthews","id":5603551,"avatar_url":"https://avatars.githubusercontent.com/u/5603551?v=3","gravatar_id":"","url":"https://api.github.com/users/glennmatthews","html_url":"https://github.com/glennmatthews","followers_url":"https://api.github.com/users/glennmatthews/followers","following_url":"https://api.github.com/users/glennmatthews/following{/other_user}","gists_url":"https://api.github.com/users/glennmatthews/gists{/gist_id}","starred_url":"https://api.github.com/users/glennmatthews/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glennmatthews/subscriptions","organizations_url":"https://api.github.com/users/glennmatthews/orgs","repos_url":"https://api.github.com/users/glennmatthews/repos","events_url":"https://api.github.com/users/glennmatthews/events{/privacy}","received_events_url":"https://api.github.com/users/glennmatthews/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-03-15T20:54:21Z","updated_at":"2016-03-21T16:25:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/puppetlabs/beaker/pulls/1081","html_url":"https://github.com/puppetlabs/beaker/pull/1081","diff_url":"https://github.com/puppetlabs/beaker/pull/1081.diff","patch_url":"https://github.com/puppetlabs/beaker/pull/1081.patch"},"body":"The implementation of `#prepend_commands` for cisco hosts returns `'source /etc/profile;'` and optionally `\"sudo ip netns exec #{vrf}\"` but does not retain any user-specified prepends. Additionally, it supplies `'sudo'` always when the vrf is specified (regardless of whether the user is root) and never supplies `'sudo'` when the vrf is not specified.\r\n(edit) Additionally, because 'sudo' is inserted in `prepend_commands`, any values from `environment_string` are lost when switching users\r\n\r\nFix 1: preserve user_pc.\r\nFix 2: prepend 'sudo' depending on whether user is root, independent of whether vrf is present.\r\n(edit) Fix 3: Add `'source /etc/profile/; [sudo]'` in `environment_string` rather than in `prepend_commands`.\r\n\r\n```\r\n$ rspec spec/beaker/host/cisco_spec.rb \r\n\r\nCisco::Host\r\n  #prepend_commands\r\n    for cisco_nexus-7\r\n      ends with the :vrf host parameter\r\n      guards against \"vsh\" usage (only scenario we dont want prefixing)\r\n      retains user-specified prepend commands when adding vrf\r\n    for cisco_ios_xr-6\r\n      does use the :vrf host parameter if provided\r\n      retains user-specified prepend commands when adding vrf\r\n  #environment_string\r\n    starts with sourcing the /etc/profile script\r\n    uses `sudo` if not root\r\n    for cisco_nexus-7\r\n      uses `sudo` if not root\r\n      uses `export` if root\r\n      ends with a semi-colon\r\n      turns env maps into paired strings correctly\r\n    for cisco_ios_xr-6\r\n      uses `sudo` if not root\r\n      uses `env` if root\r\n      does not end with a semi-colon\r\n      turns env maps into paired strings correctly\r\n  #package_config_dir\r\n    returns correctly for cisco platforms\r\n  #repo_type\r\n    returns correctly for cisco platforms\r\n  #validate_setup\r\n    on the cisco_nexus-7 platform\r\n      errors when no :vrf value is provided\r\n      errors when no :user value is provided\r\n      does nothing if the host is setup correctly\r\n    on the cisco_ios_xr-6 platform\r\n      does nothing if no :vrf value is provided\r\n      errors when no user is provided\r\n      does nothing if the host is setup correctly\r\n\r\nFinished in 0.09871 seconds (files took 1.13 seconds to load)\r\n23 examples, 0 failures\r\n```"},"comment":{"url":"https://api.github.com/repos/puppetlabs/beaker/issues/comments/199365681","html_url":"https://github.com/puppetlabs/beaker/pull/1081#issuecomment-199365681","issue_url":"https://api.github.com/repos/puppetlabs/beaker/issues/1081","id":199365681,"user":{"login":"tvpartytonight","id":5789610,"avatar_url":"https://avatars.githubusercontent.com/u/5789610?v=3","gravatar_id":"","url":"https://api.github.com/users/tvpartytonight","html_url":"https://github.com/tvpartytonight","followers_url":"https://api.github.com/users/tvpartytonight/followers","following_url":"https://api.github.com/users/tvpartytonight/following{/other_user}","gists_url":"https://api.github.com/users/tvpartytonight/gists{/gist_id}","starred_url":"https://api.github.com/users/tvpartytonight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tvpartytonight/subscriptions","organizations_url":"https://api.github.com/users/tvpartytonight/orgs","repos_url":"https://api.github.com/users/tvpartytonight/repos","events_url":"https://api.github.com/users/tvpartytonight/events{/privacy}","received_events_url":"https://api.github.com/users/tvpartytonight/received_events","type":"User","site_admin":false},"created_at":"2016-03-21T16:25:50Z","updated_at":"2016-03-21T16:25:50Z","body":":+1: "}}