Last active
October 20, 2015 21:16
-
-
Save palmertime/8755d046f70d717fcc1f to your computer and use it in GitHub Desktop.
Fix for validation error when creating a CV version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.current = User.first | |
Katello::ContentViewPuppetEnvironment.where(:puppet_environment_id => nil).where("environment_id is not null").each do |cvpe| | |
env = Environment.where(:name => cvpe.generate_puppet_env_name).first | |
if env.nil? | |
env = Environment.create(:name => 'foo', :locations => [Location.default_location], :organizations => [cvpe.content_view.organization]) | |
end | |
env.organizations << cvpe.content_view.organization unless env.organizations.include?(cvpe.content_view.organization) | |
env.locations << Location.default_location unless env.locations.include?(Location.default_location) | |
cvpe.puppet_environment = env | |
cvpe.save! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment