<commit_before>module ContainerGroupHelper::TextualSummary
  #
  # Groups
  #

  def textual_group_properties
    %i(name phase message reason creation_timestamp resource_version restart_policy dns_policy ip)
  end

  def textual_group_relationships
    # Order of items should be from parent to child
    %i(ems container_project container_replicator container_services containers container_node lives_on)
  end

  def textual_group_conditions
    labels = [_("Name"), _("Status")]
    h = {:labels => labels}
    h[:values] = @record.container_conditions.collect do |condition|
      [
        condition.name,
        condition.status,
      ]
    end
    h
  end

  def textual_group_smart_management
    items = %w(tags)
    items.collect { |m| send("textual_#{m}") }.flatten.compact
  end

  @@key_dictionary = [
    [:empty_dir_medium_type, _('Storage Medium Type')],
    [:gce_pd_name, _('GCE PD Resource')],
    [:git_repository, _('Git Repository')],
    [:git_revision, _('Git Revision')],
    [:nfs_server, _('NFS Server')],
    [:iscsi_target_portal, _('ISCSI Target Portal')],
    [:iscsi_iqn, _('ISCSI Target Qualified Name')],
    [:iscsi_lun, _('ISCSI Target Lun Number')],
    [:glusterfs_endpoint_name, _('Glusterfs Endpoint Name')],
    [:claim_name, _('Persistent Volume Claim Name')],
    [:rbd_ceph_monitors, _('Rados Ceph Monitors')],
    [:rbd_image, _('Rados Image Name')],
    [:rbd_pool, _('Rados Pool Name')],
    [:rbd_rados_user, _('Rados User Name')],
    [:rbd_keyring, _('Rados Keyring')],
    [:common_path, _('Volume Path')],
    [:common_fs_type, _('FS Type')],
    [:common_read_only, _('Read-Only')],
    [:common_volume_id, _('Volume ID')],
    [:common_partition, _('Partition')],
    [:common_secret, _('Secret Name')]
  ]

  def textual_group_volumes
    h = {:labels => [_("Name"), _("Property"), _("Value")], :values => []}
    @record.container_volumes.each do |volume|
      volume_values = @@key_dictionary.collect do |key, name|
        [nil, name, volume[key]] if volume[key].present?
      end.compact
      # Set the volume name only  for the first item in the list
      volume_values[0][0] = volume.name if volume_values.length > 0
      h[:values] += volume_values
    end
    h
  end

  #
  # Items
  #

  def textual_name
    @record.name
  end

  def textual_phase
    @record.phase
  end

  def textual_message
    @record.message
  end

  def textual_reason
    @record.reason
  end

  def textual_creation_timestamp
    format_timezone(@record.creation_timestamp)
  end

  def textual_resource_version
    @record.resource_version
  end

  def textual_restart_policy
    @record.restart_policy
  end

  def textual_dns_policy
    @record.dns_policy
  end

  def textual_ip
    {:label => "IP Address", :value => @record.ipaddress}
  end

  def textual_lives_on
    lives_on_ems = @record.container_node.try(:lives_on).try(:ext_management_system)
    return nil if lives_on_ems.nil?
    # TODO: handle the case where the node is a bare-metal
    lives_on_entity_name = lives_on_ems.kind_of?(EmsCloud) ? "Instance" : "Virtual Machine"
    {
      :label => "Underlying #{lives_on_entity_name}",
      :image => "vendor-#{lives_on_ems.image_name}",
      :value => "#{@record.container_node.lives_on.name}",
      :link  => url_for(
        :action     => 'show',
        :controller => 'vm_or_template',
        :id         => @record.container_node.lives_on.id
      )
    }
  end
end<commit_msg>Fix pod's dns policy field to be capitalized in UI (transferred from ManageIQ/manageiq@c710fc46f75f679e45fbb761fc4a92bdad0a08fb)<commit_after>module ContainerGroupHelper::TextualSummary
  #
  # Groups
  #

  def textual_group_properties
    %i(name phase message reason creation_timestamp resource_version restart_policy dns_policy ip)
  end

  def textual_group_relationships
    # Order of items should be from parent to child
    %i(ems container_project container_replicator container_services containers container_node lives_on)
  end

  def textual_group_conditions
    labels = [_("Name"), _("Status")]
    h = {:labels => labels}
    h[:values] = @record.container_conditions.collect do |condition|
      [
        condition.name,
        condition.status,
      ]
    end
    h
  end

  def textual_group_smart_management
    items = %w(tags)
    items.collect { |m| send("textual_#{m}") }.flatten.compact
  end

  @@key_dictionary = [
    [:empty_dir_medium_type, _('Storage Medium Type')],
    [:gce_pd_name, _('GCE PD Resource')],
    [:git_repository, _('Git Repository')],
    [:git_revision, _('Git Revision')],
    [:nfs_server, _('NFS Server')],
    [:iscsi_target_portal, _('ISCSI Target Portal')],
    [:iscsi_iqn, _('ISCSI Target Qualified Name')],
    [:iscsi_lun, _('ISCSI Target Lun Number')],
    [:glusterfs_endpoint_name, _('Glusterfs Endpoint Name')],
    [:claim_name, _('Persistent Volume Claim Name')],
    [:rbd_ceph_monitors, _('Rados Ceph Monitors')],
    [:rbd_image, _('Rados Image Name')],
    [:rbd_pool, _('Rados Pool Name')],
    [:rbd_rados_user, _('Rados User Name')],
    [:rbd_keyring, _('Rados Keyring')],
    [:common_path, _('Volume Path')],
    [:common_fs_type, _('FS Type')],
    [:common_read_only, _('Read-Only')],
    [:common_volume_id, _('Volume ID')],
    [:common_partition, _('Partition')],
    [:common_secret, _('Secret Name')]
  ]

  def textual_group_volumes
    h = {:labels => [_("Name"), _("Property"), _("Value")], :values => []}
    @record.container_volumes.each do |volume|
      volume_values = @@key_dictionary.collect do |key, name|
        [nil, name, volume[key]] if volume[key].present?
      end.compact
      # Set the volume name only  for the first item in the list
      volume_values[0][0] = volume.name if volume_values.length > 0
      h[:values] += volume_values
    end
    h
  end

  #
  # Items
  #

  def textual_name
    @record.name
  end

  def textual_phase
    @record.phase
  end

  def textual_message
    @record.message
  end

  def textual_reason
    @record.reason
  end

  def textual_creation_timestamp
    format_timezone(@record.creation_timestamp)
  end

  def textual_resource_version
    @record.resource_version
  end

  def textual_restart_policy
    @record.restart_policy
  end

  def textual_dns_policy
    {:label => "DNS Policy", :value => @record.dns_policy}
  end

  def textual_ip
    {:label => "IP Address", :value => @record.ipaddress}
  end

  def textual_lives_on
    lives_on_ems = @record.container_node.try(:lives_on).try(:ext_management_system)
    return nil if lives_on_ems.nil?
    # TODO: handle the case where the node is a bare-metal
    lives_on_entity_name = lives_on_ems.kind_of?(EmsCloud) ? "Instance" : "Virtual Machine"
    {
      :label => "Underlying #{lives_on_entity_name}",
      :image => "vendor-#{lives_on_ems.image_name}",
      :value => "#{@record.container_node.lives_on.name}",
      :link  => url_for(
        :action     => 'show',
        :controller => 'vm_or_template',
        :id         => @record.container_node.lives_on.id
      )
    }
  end
end
{'fraction_non_alphanumeric': 0.1283104376150687, 'fraction_numerical': 0.003823820988528537, 'mean_word_length': 3.532734274711168, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3829290', 'n_tokens_mistral': 2519, 'n_tokens_neox': 2355, 'n_words': 537}