<commit_before>module Aeolus
  module Image
    class ListCommand < BaseCommand
      def initialize(opts={}, logger=nil)
        super(opts, logger)
      end

      def images
        images = [["UUID", "NAME", "OS", "OS VERSION", "ARCH", "DESCRIPTION"]]
        doc = Nokogiri::XML iwhd['/target_images'].get
        doc.xpath("/objects/object/key").each do |targetimage|
          begin
            build = iwhd["/target_images/" + targetimage + "/build"].get
            image = iwhd["/builds/" + build + "/image"].get
            template_xml = Nokogiri::XML iwhd["/templates/" + iwhd["/target_images/" + targetimage + "/template"].get].get
            images << [image,
                       template_xml.xpath("/template/name").text,
                       template_xml.xpath("/template/os/name").text,
                       template_xml.xpath("/template/os/version").text,
                       template_xml.xpath("/template/os/arch").text,
                       template_xml.xpath("/template/description").text]
          rescue RestClient::ResourceNotFound, RestClient::InternalServerError
          end
        end
        format_print(images)
        quit(0)
      end

      def builds
        doc = Nokogiri::XML iwhd['/builds'].get
        doc.xpath("/objects/object/key").each do |build|
          if iwhd['/builds/' + build.text + "/image"].get == @options[:id]
            puts build.text
          end
        end
        quit(0)
      end

      def targetimages
        doc = Nokogiri::XML iwhd['/target_images'].get
        doc.xpath("/objects/object/key").each do |target_image|
          begin
            if iwhd['/target_images/' + target_image.text + "/build"].get == @options[:id]
              puts target_image.text
            end
          rescue RestClient::ResourceNotFound
          end
        end
        quit(0)
      end

      def targets
        targets = [["NAME", "TARGET CODE"]]
        targets << ["Mock", "mock"]
        targets << ["Amazon EC2", "ec2"]
        targets << ["RHEV-M", "rhevm"]
        targets << ["VMWare VSphere", "vsphere"]
        targets << ["Condor Cloud", "condor_cloud"]
        format_print(targets)
        quit(0)
      end

      def providers
        print_values = [["NAME", "TYPE", "URL"]]

        doc = Nokogiri::XML conductor['/providers'].get
        doc.xpath("/providers/provider").each do |provider|
          print_values << [provider.xpath("name").text, provider.xpath("provider_type").text, provider.xpath("url").text]
        end

        format_print(print_values)
        quit(0)
      end

      def accounts
        print_values = [["NAME", "PROVIDER", "PROVIDER TYPE"]]
        doc = Nokogiri::XML conductor['/provider_accounts/'].get
        doc.xpath("/provider_accounts/provider_account").each do |account|
          print_values << [account.xpath("name").text, account.xpath("provider").text, account.xpath("provider_type").text]
        end

        format_print(print_values)
        quit(0)
      end<commit_msg>Fix user visible typos in provider type names.<commit_after>module Aeolus
  module Image
    class ListCommand < BaseCommand
      def initialize(opts={}, logger=nil)
        super(opts, logger)
      end

      def images
        images = [["UUID", "NAME", "OS", "OS VERSION", "ARCH", "DESCRIPTION"]]
        doc = Nokogiri::XML iwhd['/target_images'].get
        doc.xpath("/objects/object/key").each do |targetimage|
          begin
            build = iwhd["/target_images/" + targetimage + "/build"].get
            image = iwhd["/builds/" + build + "/image"].get
            template_xml = Nokogiri::XML iwhd["/templates/" + iwhd["/target_images/" + targetimage + "/template"].get].get
            images << [image,
                       template_xml.xpath("/template/name").text,
                       template_xml.xpath("/template/os/name").text,
                       template_xml.xpath("/template/os/version").text,
                       template_xml.xpath("/template/os/arch").text,
                       template_xml.xpath("/template/description").text]
          rescue RestClient::ResourceNotFound, RestClient::InternalServerError
          end
        end
        format_print(images)
        quit(0)
      end

      def builds
        doc = Nokogiri::XML iwhd['/builds'].get
        doc.xpath("/objects/object/key").each do |build|
          if iwhd['/builds/' + build.text + "/image"].get == @options[:id]
            puts build.text
          end
        end
        quit(0)
      end

      def targetimages
        doc = Nokogiri::XML iwhd['/target_images'].get
        doc.xpath("/objects/object/key").each do |target_image|
          begin
            if iwhd['/target_images/' + target_image.text + "/build"].get == @options[:id]
              puts target_image.text
            end
          rescue RestClient::ResourceNotFound
          end
        end
        quit(0)
      end

      def targets
        targets = [["NAME", "TARGET CODE"]]
        targets << ["Mock", "mock"]
        targets << ["Amazon EC2", "ec2"]
        targets << ["RHEV-M", "rhevm"]
        targets << ["VMware vSphere", "vsphere"]
        targets << ["Condor Cloud", "condor_cloud"]
        format_print(targets)
        quit(0)
      end

      def providers
        print_values = [["NAME", "TYPE", "URL"]]

        doc = Nokogiri::XML conductor['/providers'].get
        doc.xpath("/providers/provider").each do |provider|
          print_values << [provider.xpath("name").text, provider.xpath("provider_type").text, provider.xpath("url").text]
        end

        format_print(print_values)
        quit(0)
      end

      def accounts
        print_values = [["NAME", "PROVIDER", "PROVIDER TYPE"]]
        doc = Nokogiri::XML conductor['/provider_accounts/'].get
        doc.xpath("/provider_accounts/provider_account").each do |account|
          print_values << [account.xpath("name").text, account.xpath("provider").text, account.xpath("provider_type").text]
        end

        format_print(print_values)
        quit(0)
      end
{'fraction_non_alphanumeric': 0.14295136026380875, 'fraction_numerical': 0.0026380873866446827, 'mean_word_length': 2.0467101958814666, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '467597', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1753, 'n_words': 344}