Module: ImportTools::ContentView::Include
- Included in:
- HammerCLIImport::ImportCommand::ActivationKeyImportCommand, HammerCLIImport::ImportCommand::ContentHostImportCommand, HammerCLIImport::ImportCommand::LocalRepositoryImportCommand, HammerCLIImport::ImportCommand::RepositoryEnableCommand
- Defined in:
- lib/hammer_cli_import/importtools.rb
Instance Method Summary collapse
- #create_composite_content_view(entity_type, org_id, cv_label, cv_description, cvs) ⇒ Object
-
#delete_content_view(cv_id, entity_type = :content_views) ⇒ Object
use entity_type as parameter to be able to re-use the method for :content_views, :ak_content_views, :redhat_content_views, …
- #publish_content_view(id, entity_type = :content_views) ⇒ Object
Instance Method Details
#create_composite_content_view(entity_type, org_id, cv_label, cv_description, cvs) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/hammer_cli_import/importtools.rb', line 164 def create_composite_content_view(entity_type, org_id, cv_label, cv_description, cvs) if cvs.empty? return list_server_entities(:content_views, {:organization_id => org_id, :name => "Default Organization View"})[0]['id'] end if cvs.size == 1 return cvs.to_a[0] else # create composite content view cv_versions = [] cvs.each do |cv_id| cvvs = list_server_entities(:content_view_versions, {:content_view_id => cv_id}) cv_versions << cvvs.collect { |cv| cv['id'] }.max end cv = lookup_entity_in_cache(entity_type, 'label' => cv_label) if cv info " Content view #{cv_label} already created, reusing." else # create composite content view # for activation key purposes cv = create_entity( entity_type, { :organization_id => org_id, :name => cv_label, :label => cv_label, :composite => true, :description => cv_description, :component_ids => cv_versions }, cv_label) # publish the content view info " Publishing content view: #{cv['id']}" publish_content_view(cv['id'], entity_type) end return cv['id'] end end |
#delete_content_view(cv_id, entity_type = :content_views) ⇒ Object
use entity_type as parameter to be able to re-use the method for :content_views, :ak_content_views, :redhat_content_views, …
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/hammer_cli_import/importtools.rb', line 205 def delete_content_view(cv_id, entity_type = :content_views) raise "delete_content_view with #{entity_type}" unless map_target_entity[entity_type] == :content_views content_view = get_cache(entity_type)[cv_id] # first delete the content view from associated environments cves = content_view['environments'].collect { |e| e['id'] } cves.each do |cve| begin task = mapped_api_call( entity_type, :remove_from_environment, { :id => content_view['id'], :environment_id => cve }) rescue => e warn "Failed to remove content view [#{cv_id}] from environment #{cve} with #{e.class}: #{e.}" end wait_for_task(task['id'], 1, 0) end if content_view['versions'] && !content_view['versions'].empty? cv_version_ids = content_view['versions'].collect { |v| v['id'] } begin task = mapped_api_call( entity_type, :remove, { :id => content_view['id'], :content_view_version_ids => cv_version_ids }) wait_for_task(task['id'], 1, 0) rescue => e warn "Failed to remove versions of content view [#{cv_id}] with #{e.class}: #{e.}" end else debug "No versions found for #{to_singular(entity_type)} #{cv_id}" end delete_entity_by_import_id(entity_type, content_view['id']) end |
#publish_content_view(id, entity_type = :content_views) ⇒ Object
158 159 160 161 162 |
# File 'lib/hammer_cli_import/importtools.rb', line 158 def publish_content_view(id, entity_type = :content_views) mapped_api_call entity_type, :publish, {:id => id} rescue => e warn "Publishing of #{to_singular(entity_type)} [#{id}] failed with #{e.class}: #{e.}" end |