hammer_cli_foreman_discovery 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +15 -0
  2. data/README.md +4 -0
  3. data/lib/hammer_cli_foreman_discovery.rb +3 -0
  4. data/lib/hammer_cli_foreman_discovery/discovery.rb +152 -0
  5. data/lib/hammer_cli_foreman_discovery/i18n.rb +24 -0
  6. data/lib/hammer_cli_foreman_discovery/version.rb +5 -0
  7. data/locale/Makefile +65 -0
  8. data/locale/README.md +18 -0
  9. data/locale/de/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  10. data/locale/de/hammer_cli_foreman_discovery.po +98 -0
  11. data/locale/en/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  12. data/locale/en/hammer_cli_foreman_discovery.po +99 -0
  13. data/locale/en_GB/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  14. data/locale/en_GB/hammer_cli_foreman_discovery.po +99 -0
  15. data/locale/es/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  16. data/locale/es/hammer_cli_foreman_discovery.po +98 -0
  17. data/locale/fr/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  18. data/locale/fr/hammer_cli_foreman_discovery.po +99 -0
  19. data/locale/hammer_cli_foreman_discovery.pot +107 -0
  20. data/locale/it/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  21. data/locale/it/hammer_cli_foreman_discovery.po +98 -0
  22. data/locale/ja/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  23. data/locale/ja/hammer_cli_foreman_discovery.po +98 -0
  24. data/locale/ko/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  25. data/locale/ko/hammer_cli_foreman_discovery.po +98 -0
  26. data/locale/pt_BR/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  27. data/locale/pt_BR/hammer_cli_foreman_discovery.po +98 -0
  28. data/locale/ru/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  29. data/locale/ru/hammer_cli_foreman_discovery.po +98 -0
  30. data/locale/zh_CN/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  31. data/locale/zh_CN/hammer_cli_foreman_discovery.po +98 -0
  32. data/locale/zh_TW/LC_MESSAGES/hammer_cli_foreman_discovery.mo +0 -0
  33. data/locale/zh_TW/hammer_cli_foreman_discovery.po +98 -0
  34. metadata +109 -0
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmQ3ZmVlNGFiNWI4NmE1OTI4NDk2NjdmYzk0NzNmMzA0NmQyNzk4NQ==
5
+ data.tar.gz: !binary |-
6
+ NWRkMDI2NTQ1ZjAxMTk2NjBmNThiNTIyNjRjMDgxMmIyMTNkNmFiYg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NTgyMDU0MGNiNjhjMmEzM2Y1NjJkODQxYjBkNmVjYmQxOTBkOGZhNDNiZmRm
10
+ MTVjOWQ3ZmVhNzExYzM5MTEyODZmYWU0MmJhMWU5ODI1ZWVmNzcyMGMxYjA0
11
+ ZTg4ODFjMWRjMmVmYTNhMWI2ZTJjOTYyZThlMTY2MTAxZjY2OTU=
12
+ data.tar.gz: !binary |-
13
+ NjA0NWQ3NjAxOTgyOTRmZjA4NzhiMzg5MjFmZjBkY2U3Y2M4NTAzZjliMmMw
14
+ NmMyNzY1NjllYjNjZjVmODI4YWUyYjYzOTFmODlkYjU4YzU3MjA3OWRmODJl
15
+ ZTFhOTg2MTNmYzgzYzc5ZmUxMzM0ZmUzMGI2MTNkNjM5MGYwY2M=
@@ -0,0 +1,4 @@
1
+ Hammer CLI Foreman Discovery
2
+ ========================
3
+
4
+ Managing Foreman Host discovery (results and progress) in the Hammer CLI.
@@ -0,0 +1,3 @@
1
+ module HammerCLIForemanDiscovery
2
+ require 'hammer_cli_foreman_discovery/discovery'
3
+ end
@@ -0,0 +1,152 @@
1
+ require 'hammer_cli'
2
+ require 'hammer_cli_foreman'
3
+
4
+ module HammerCLIForemanDiscovery
5
+
6
+ class DiscoveredHost < HammerCLIForeman::Command
7
+
8
+ resource :discovered_hosts
9
+
10
+ class ListCommand < HammerCLIForeman::ListCommand
11
+ output do
12
+ field :id, _("ID")
13
+ field :name, _("Name")
14
+ field :mac, _("MAC")
15
+ field :last_report, _('Last report'), Fields::Date
16
+ field :cpus, _('CPUs')
17
+ field :memory, _('Memory')
18
+ field :disk_count, _('Disk count')
19
+ field :disks_size, _('Disks size')
20
+ field nil, _("Subnet"), Fields::SingleReference, :key => :subnet
21
+ field :last_report, _('Last Report'), Fields::Date
22
+ end
23
+
24
+ build_options
25
+ end
26
+
27
+ class InfoCommand < HammerCLIForeman::InfoCommand
28
+ output ListCommand.output_definition do
29
+ field :ip, _('IP')
30
+ field :model, _('Model')
31
+ field nil, _("Organization"), Fields::SingleReference, :key => :organization
32
+ field nil, _("Location"), Fields::SingleReference, :key => :location
33
+ end
34
+
35
+ build_options
36
+ end
37
+
38
+ class FactsCommand < HammerCLIForeman::InfoCommand
39
+ command_name "facts"
40
+
41
+ output do
42
+ field :fact, _("Fact")
43
+ field :value, _("Value")
44
+ end
45
+
46
+ def extend_data(facts_collection)
47
+ facts_collection['facts_hash'].collect do |fact, value|
48
+ { :fact => fact, :value => value }
49
+ end
50
+ end
51
+
52
+ def adapter
53
+ :table
54
+ end
55
+
56
+ build_options
57
+ end
58
+
59
+ class DeleteCommand < HammerCLIForeman::DeleteCommand
60
+ success_message _("Host deleted")
61
+ failure_message _("Could not delete the host")
62
+
63
+ build_options
64
+ end
65
+
66
+ class ProvisionCommand < HammerCLIForeman::UpdateCommand
67
+ command_name "provision"
68
+
69
+ success_message _("Host created")
70
+ failure_message _("Could not create the host")
71
+
72
+ def self.build_options
73
+ option "--partition-table-id", "PARTITION_TABLE_ID", " "
74
+ option "--root-password", "ROOT_PW", " "
75
+ option "--ask-root-password", "ASK_ROOT_PW", " ",
76
+ :format => HammerCLI::Options::Normalizers::Bool.new
77
+ option "--puppetclass-ids", "PUPPETCLASS_IDS", " ",
78
+ :format => HammerCLI::Options::Normalizers::List.new
79
+
80
+ bool_format = {}
81
+ bool_format[:format] = HammerCLI::Options::Normalizers::Bool.new
82
+ option "--managed", "MANAGED", " ", bool_format
83
+ bool_format[:format] = HammerCLI::Options::Normalizers::Bool.new
84
+ option "--build", "BUILD", " ", bool_format
85
+ bool_format[:format] = HammerCLI::Options::Normalizers::Bool.new
86
+ option "--enabled", "ENABLED", " ", bool_format
87
+
88
+ option "--parameters", "PARAMS", _("Host parameters"),
89
+ :format => HammerCLI::Options::Normalizers::KeyValueList.new
90
+ option "--interface", "INTERFACE", _("Interface parameters"), :multivalued => true,
91
+ :format => HammerCLI::Options::Normalizers::KeyValueList.new
92
+ option "--provision-method", "METHOD", " ",
93
+ :format => HammerCLI::Options::Normalizers::Enum.new(['build', 'image'])
94
+
95
+ super :without => [:root_pass, :ptable_id, :puppet_class_ids]
96
+ end
97
+
98
+ def ask_password
99
+ prompt = _("Enter the root password for the host:") + '_'
100
+ ask(prompt) { |q| q.echo = false }
101
+ end
102
+
103
+ def request_params
104
+ params = super
105
+
106
+ params['discovered_host']['ptable_id'] = option_partition_table_id unless option_partition_table_id.nil?
107
+ params['discovered_host']['root_pass'] = option_root_password unless option_root_password.nil?
108
+
109
+ if option_ask_root_password
110
+ params['discovered_host']['root_pass'] = ask_password
111
+ end
112
+
113
+ params
114
+ end
115
+
116
+ build_options
117
+ end
118
+
119
+ class AutoProvisionCommand < HammerCLIForeman::SingleResourceCommand
120
+ action :auto_provision
121
+ command_name "auto-provision"
122
+ desc _("Auto provision a host")
123
+ success_message _("Host created")
124
+ failure_message _("Could not create the host")
125
+
126
+ build_options
127
+ end
128
+
129
+ class RebootCommand < HammerCLIForeman::SingleResourceCommand
130
+ action :reboot
131
+ command_name "reboot"
132
+ desc _("Reboot a host")
133
+ success_message _("Host reboot started")
134
+ failure_message _("Could not reboot the host")
135
+
136
+ build_options
137
+ end
138
+
139
+ class RefreshFactsCommand < HammerCLIForeman::SingleResourceCommand
140
+ action :refresh_facts
141
+ command_name "refresh-facts"
142
+ desc _("Refresh the facts of a host")
143
+ success_message _("Host facts refreshed")
144
+ failure_message _("Could not refresh the facts of the host")
145
+
146
+ build_options
147
+ end
148
+ autoload_subcommands
149
+ end
150
+
151
+ HammerCLI::MainCommand.subcommand 'discovery', _("Discovery related actions."), DiscoveredHost
152
+ end
@@ -0,0 +1,24 @@
1
+ require 'hammer_cli/i18n'
2
+
3
+ module HammerCLIForemanDiscovery
4
+ module I18n
5
+
6
+ class LocaleDomain < HammerCLI::I18n::LocaleDomain
7
+
8
+ def translated_files
9
+ Dir.glob(File.join(File.dirname(__FILE__), '../**/*.rb'))
10
+ end
11
+
12
+ def locale_dir
13
+ File.join(File.dirname(__FILE__), '../../locale')
14
+ end
15
+
16
+ def domain_name
17
+ 'hammer_cli_foreman_discovery'
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+ HammerCLI::I18n.add_domain(HammerCLIForemanDiscovery::I18n::LocaleDomain.new)
@@ -0,0 +1,5 @@
1
+ module HammerCLIForemanDiscovery
2
+ def self.version
3
+ @version ||= Gem::Version.new('0.0.1')
4
+ end
5
+ end
@@ -0,0 +1,65 @@
1
+ #
2
+ # Makefile for PO merging and MO generation. More info in the README.
3
+ #
4
+ # make all-mo (default) - generate MO files
5
+ # make check - check translations using translate-tool
6
+ # make tx-update - download and merge translations from Transifex
7
+ # make clean - clean everything
8
+ #
9
+ DOMAIN = hammer_cli_foreman_discovery
10
+ VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load("../hammer_cli_foreman_discovery.gemspec");puts spec.version')
11
+ POTFILE = $(DOMAIN).pot
12
+ MOFILE = $(DOMAIN).mo
13
+ POFILES = $(shell find . -name '*.po')
14
+ MOFILES = $(patsubst %.po,%.mo,$(POFILES))
15
+ POXFILES = $(patsubst %.po,%.pox,$(POFILES))
16
+
17
+ %.mo: %.po
18
+ mkdir -p $(shell dirname $@)/LC_MESSAGES
19
+ msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $<
20
+
21
+ # Generate MO files from PO files
22
+ all-mo: $(MOFILES)
23
+
24
+ # Check for malformed strings
25
+ %.pox: %.po
26
+ msgfmt -c $<
27
+ pofilter --nofuzzy -t variables -t blank -t urls -t emails -t long -t newlines \
28
+ -t endwhitespace -t endpunc -t puncspacing -t options -t printf -t validchars --gnome $< > $@
29
+ cat $@
30
+ ! grep -q msgid $@
31
+
32
+ check: $(POXFILES)
33
+ msgfmt -c ${POTFILE}
34
+
35
+ # Merge PO files
36
+ update-po:
37
+ for f in $(shell find ./ -name "*.po") ; do \
38
+ msgmerge -N --backup=none -U $$f ${POTFILE} ; \
39
+ done
40
+
41
+ # Unify duplicate translations
42
+ uniq-po:
43
+ for f in $(shell find ./ -name "*.po") ; do \
44
+ msguniq $$f -o $$f ; \
45
+ done
46
+
47
+ tx-pull:
48
+ tx pull -f
49
+ for f in $(POFILES) ; do \
50
+ sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
51
+ done
52
+ -git commit -a -m "i18n - extracting new, pulling from tx"
53
+
54
+ extract-strings:
55
+ bundle exec rake gettext:find
56
+
57
+ reset-po:
58
+ # merging po files is unnecessary when using transifex.com
59
+ git checkout -- ../locale/*/*po
60
+
61
+ tx-update: tx-pull extract-strings reset-po $(MOFILES)
62
+ # amend mo files
63
+ git add ../locale/*/LC_MESSAGES
64
+ git commit -a --amend -m "i18n - extracting new, pulling from tx"
65
+ -echo Changes commited!
@@ -0,0 +1,18 @@
1
+ Updating the translations
2
+ -------------------------
3
+
4
+ 1. Check if there are any new languages with progress more than 50% on [transifex](https://www.transifex.com/projects/p/foreman/resource/hammer-cli-foreman_discovery/). If so, do the following for each of the new languages:
5
+
6
+ ```
7
+ mkdir locale/<lang>
8
+ cp locale/hammer_cli_foreman_discovery.pot locale/<lang>/hammer_cli_foreman_discovery.po
9
+ ```
10
+ 2. Make sure you have `transifex-client` installed
11
+
12
+ 3. Update the translations. From GIT repo root directory run:
13
+
14
+ ```
15
+ make -C locale tx-update
16
+ ```
17
+
18
+ It will download translations from transifex, generates `mo` files, updates strings in `pot` file and wraps all the changes in a new commit. Transifex automatically updates its strings when the commit is pushed to Github.
@@ -0,0 +1,98 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ #
5
+ # Translators:
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: hammer_cli_foreman_discovery 0.0.1\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2015-01-21 12:11+0200\n"
11
+ "PO-Revision-Date: 2015-01-21 10:30+0000\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: German (http://www.transifex.com/projects/p/foreman/language/de/)\n"
14
+ "MIME-Version: 1.0\n"
15
+ "Content-Type: text/plain; charset=UTF-8\n"
16
+ "Content-Transfer-Encoding: 8bit\n"
17
+ "Language: de\n"
18
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
+
20
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:11
21
+ msgid "Id"
22
+ msgstr "Kennung"
23
+
24
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:12
25
+ msgid "Name"
26
+ msgstr "Name"
27
+
28
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:13
29
+ msgid "Mac"
30
+ msgstr ""
31
+
32
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:14
33
+ msgid "Last Report"
34
+ msgstr ""
35
+
36
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:15
37
+ msgid "Subnet"
38
+ msgstr "Subnetz"
39
+
40
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:16
41
+ msgid "Organization"
42
+ msgstr "Organisation"
43
+
44
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:17
45
+ msgid "Location"
46
+ msgstr "Ort"
47
+
48
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:25
49
+ msgid "Ip"
50
+ msgstr ""
51
+
52
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:26
53
+ msgid "Model"
54
+ msgstr "Modell"
55
+
56
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:27
57
+ msgid "Facts"
58
+ msgstr "Fakten"
59
+
60
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:36
61
+ msgid "Host created"
62
+ msgstr "Host erstellt"
63
+
64
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:37
65
+ msgid "Could not create the host"
66
+ msgstr "Host konnte nicht erstellt werden"
67
+
68
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:55
69
+ msgid "Host parameters."
70
+ msgstr "Hostparameter."
71
+
72
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:57
73
+ msgid "Interface parameters."
74
+ msgstr "Schnittstellenparameter."
75
+
76
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:89
77
+ msgid "Reboot a host"
78
+ msgstr "Host neustarten"
79
+
80
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:90
81
+ msgid "Host reboot started."
82
+ msgstr "Host wird neu gestartet."
83
+
84
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:91
85
+ msgid "Could not reboot the host"
86
+ msgstr ""
87
+
88
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:99
89
+ msgid "Refresh the facts of a host"
90
+ msgstr ""
91
+
92
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:100
93
+ msgid "Host facts refreshed"
94
+ msgstr ""
95
+
96
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:101
97
+ msgid "Could not refresh the facts of the host"
98
+ msgstr ""
@@ -0,0 +1,99 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the hammer_cli_foreman_discovery package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: hammer_cli_foreman_discovery 0.0.1\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2015-01-21 14:11+0200\n"
12
+ "PO-Revision-Date: 2015-01-21 12:06+0200\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
20
+
21
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:11
22
+ msgid "Id"
23
+ msgstr ""
24
+
25
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:12
26
+ msgid "Name"
27
+ msgstr ""
28
+
29
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:13
30
+ msgid "Mac"
31
+ msgstr ""
32
+
33
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:14
34
+ msgid "Last Report"
35
+ msgstr ""
36
+
37
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:15
38
+ msgid "Subnet"
39
+ msgstr ""
40
+
41
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:16
42
+ msgid "Organization"
43
+ msgstr ""
44
+
45
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:17
46
+ msgid "Location"
47
+ msgstr ""
48
+
49
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:25
50
+ msgid "Ip"
51
+ msgstr ""
52
+
53
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:26
54
+ msgid "Model"
55
+ msgstr ""
56
+
57
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:27
58
+ msgid "Facts"
59
+ msgstr ""
60
+
61
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:36
62
+ msgid "Host created"
63
+ msgstr ""
64
+
65
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:37
66
+ msgid "Could not create the host"
67
+ msgstr ""
68
+
69
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:55
70
+ msgid "Host parameters."
71
+ msgstr ""
72
+
73
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:57
74
+ msgid "Interface parameters."
75
+ msgstr ""
76
+
77
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:89
78
+ msgid "Reboot a host"
79
+ msgstr ""
80
+
81
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:90
82
+ msgid "Host reboot started."
83
+ msgstr ""
84
+
85
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:91
86
+ msgid "Could not reboot the host"
87
+ msgstr ""
88
+
89
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:99
90
+ msgid "Refresh the facts of a host"
91
+ msgstr ""
92
+
93
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:100
94
+ msgid "Host facts refreshed"
95
+ msgstr ""
96
+
97
+ #: lib/hammer_cli_foreman_discovery/discovery.rb:101
98
+ msgid "Could not refresh the facts of the host"
99
+ msgstr ""