hammer_cli_foreman_bootdisk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0602d92eda12db552f671b531a7a0b59ebbbb0a4
4
+ data.tar.gz: c135ff0152ff4de4fe36b792d55cc81d18e743b9
5
+ SHA512:
6
+ metadata.gz: 8a332fb880b7a42c0f1d91d74fbef22626182184ebc725ded9eb26f154f6edacf51e59166e69a9039b4790b22b9e851b9fc4364f318eb1216bdca7c5a44f9511
7
+ data.tar.gz: 9d111df3681cf2f66d9cefc00ec10ea139ab0b2e4396c21640bbdc1a69d73e39814c24b65b2290df01106a483c30712961349613227738fce98b94a80a2cd20a
@@ -0,0 +1,60 @@
1
+ Foreman boot disk commands for Hammer CLI
2
+ =========================================
3
+
4
+ This [Hammer CLI](https://github.com/theforeman/hammer-cli) plugin contains
5
+ set of commands for [foreman_bootdisk](https://github.com/theforeman/foreman_bootdisk),
6
+ a plugin to [Foreman](http://theforeman.org/) for ISO/USB booting support
7
+
8
+ Documentation
9
+ -------------
10
+
11
+ Basic configuration of Hammer to communicate with Foreman is covered in the
12
+ hammer-cli-foreman documentation:
13
+
14
+ - [Hammer CLI Foreman configuration](https://github.com/theforeman/hammer-cli-foreman/blob/master/doc/configuration.md)
15
+
16
+ To download the generic disk (ISO/USB) image, run:
17
+
18
+ hammer bootdisk generic
19
+
20
+ Or to download a per-host disk, run:
21
+
22
+ hammer bootdisk host --host client.example.com
23
+
24
+ Files will be downloaded into the current directory unless `--file` is used to set the
25
+ destination:
26
+
27
+ hammer bootdisk generic --file /tmp/generic.iso
28
+
29
+ If a device is given to `--file`, you can write the image directly to it by adding the
30
+ `--force` option. Needless to say, but **double check** the device name is correct to
31
+ avoid overwriting the wrong disk.
32
+
33
+ hammer bootdisk generic --file /dev/sdb --force
34
+
35
+ When running hammer as an unprivileged user with no access to the device, add `--sudo`
36
+ to execute `sudo dd` for the copy. Password prompts may be shown if NOPASSWD is not
37
+ configured.
38
+
39
+ hammer bootdisk generic --file /dev/sdb --force --sudo
40
+
41
+
42
+ How to run
43
+ ----------
44
+
45
+ We build rpms, debs and gems. Alternatively you can install hammer from a git checkout.
46
+ See our [Hammer CLI installation and configuration instuctions](https://github.com/theforeman/hammer-cli/blob/master/doc/installation.md#installation).
47
+
48
+ Having issues?
49
+ --------------
50
+
51
+ If one of hammer commands doesn't work as you would expect, you can run `hammer -d ...` to get
52
+ full debug output from the loggers. It should give you an idea what went wrong.
53
+
54
+ If you have questions, don't hesitate to contact us on `foreman-users@googlegroups.com` or
55
+ `Freenode#theforeman` IRC channel.
56
+
57
+ License
58
+ -------
59
+
60
+ This project is licensed under the GPLv3+.
@@ -0,0 +1,20 @@
1
+ require 'pry'
2
+ require 'hammer_cli_foreman'
3
+
4
+ module HammerCLIForemanBootdisk
5
+ def self.exception_handler_class
6
+ HammerCLIForeman::ExceptionHandler
7
+ end
8
+
9
+ begin
10
+ require 'hammer_cli_foreman_bootdisk/commands'
11
+
12
+ HammerCLI::MainCommand.lazy_subcommand('bootdisk', _("Download boot disks"),
13
+ 'HammerCLIForemanBootdisk::Bootdisk', 'hammer_cli_foreman_bootdisk/bootdisk'
14
+ )
15
+ rescue => e
16
+ handler = HammerCLIForeman::ExceptionHandler.new(:context => {}, :adapter => :base)
17
+ handler.handle_exception(e)
18
+ raise HammerCLI::ModuleLoadingError.new(e)
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ module HammerCLIForemanBootdisk
2
+ class Bootdisk < HammerCLIForeman::Command
3
+ resource :disks
4
+
5
+ class GenericCommand < HammerCLIForemanBootdisk::DownloadCommand
6
+ action :generic
7
+
8
+ command_name 'generic'
9
+ success_message _('Successfully downloaded generic disk image to %s')
10
+ failure_message _('Failed to download generic disk image')
11
+
12
+ build_options
13
+ end
14
+
15
+ class HostCommand < HammerCLIForemanBootdisk::DownloadCommand
16
+ action :host
17
+
18
+ command_name 'host'
19
+ success_message _('Successfully downloaded host disk image to %s')
20
+ failure_message _('Failed to download host disk image')
21
+
22
+ build_options
23
+ end
24
+
25
+ autoload_subcommands
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ require 'tempfile'
2
+ require 'hammer_cli_foreman/commands'
3
+
4
+ module HammerCLIForemanBootdisk
5
+ class DownloadCommand < HammerCLIForeman::Command
6
+ option "--file", "PATH", _("File or device to write image to")
7
+ option "--force", :flag, _("Force writing to existing destination (device etc.)")
8
+ option "--sudo", :flag, _("Use sudo to write to device")
9
+
10
+ def print_data(record)
11
+ server_filename = $1 if record.headers[:content_disposition] =~ /filename=["']?([^\s,;"']+)/
12
+ file = options[HammerCLI.option_accessor_name('file')] || server_filename || 'bootdisk.iso'
13
+ if !options[HammerCLI.option_accessor_name('force')] && File.exist?(file) && !File.file?(file)
14
+ raise(HammerCLIForeman::OperationNotSupportedError, _("Destination %s already exists and isn't a regular file, use '--force' if you are sure you wish to write to it") % file)
15
+ end
16
+
17
+ if options[HammerCLI.option_accessor_name('sudo')]
18
+ temp_file = Tempfile.new('bootdisk')
19
+ begin
20
+ File.write(temp_file, record)
21
+ system('sudo', 'dd', "if=#{temp_file.path}", "of=#{file}", 'bs=1024')
22
+ ensure
23
+ temp_file.close
24
+ temp_file.unlink
25
+ end
26
+ else
27
+ File.write(file, record)
28
+ end
29
+ print_message (success_message % file) if success_message
30
+ end
31
+
32
+ def request_options
33
+ {:response => :raw}
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,24 @@
1
+ require 'hammer_cli/i18n'
2
+
3
+ module HammerCLIForemanBootdisk
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_bootdisk'
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+ HammerCLI::I18n.add_domain(HammerCLIForemanBootdisk::I18n::LocaleDomain.new)
@@ -0,0 +1,5 @@
1
+ module HammerCLIForemanBootdisk
2
+ def self.version
3
+ @version ||= Gem::Version.new '0.1.0'
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_bootdisk
10
+ VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load("../hammer_cli_foreman_bootdisk.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_bootdisk/). If so, do the following for each of the new languages:
5
+
6
+ ```
7
+ mkdir locale/<lang>
8
+ cp locale/hammer_cli_foreman_bootdisk.pot locale/<lang>/hammer_cli_foreman_bootdisk.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,57 @@
1
+ # Hammer CLI Foreman Bootdisk
2
+ # Copyright (C) 2014
3
+ # This file is distributed under the same license as the hammer_cli_foreman_bootdisk package.
4
+ # Dominic Cleal <dcleal@redhat.com>, 2014
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: hammer_cli_foreman_bootdisk 0.1.0\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2014-08-08 14:31+0100\n"
12
+ "PO-Revision-Date: 2014-08-08 14:24+0100\n"
13
+ "Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
14
+ "Language-Team: Foreman Team <foreman-dev@googlegroups.com>\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=2; plural=(n != 1);\n"
20
+
21
+ #: lib/hammer_cli_foreman_bootdisk/commands.rb:6
22
+ msgid "File or device to write image to"
23
+ msgstr ""
24
+
25
+ #: lib/hammer_cli_foreman_bootdisk/commands.rb:7
26
+ msgid "Force writing to existing destination (device etc.)"
27
+ msgstr ""
28
+
29
+ #: lib/hammer_cli_foreman_bootdisk/commands.rb:8
30
+ msgid "Use sudo to write to device"
31
+ msgstr ""
32
+
33
+ #: lib/hammer_cli_foreman_bootdisk/commands.rb:14
34
+ msgid ""
35
+ "Destination %s already exists and isn't a regular file, use '--force' if you "
36
+ "are sure you wish to write to it"
37
+ msgstr ""
38
+
39
+ #: lib/hammer_cli_foreman_bootdisk/bootdisk.rb:9
40
+ msgid "Successfully downloaded generic disk image to %s"
41
+ msgstr ""
42
+
43
+ #: lib/hammer_cli_foreman_bootdisk/bootdisk.rb:10
44
+ msgid "Failed to download generic disk image"
45
+ msgstr ""
46
+
47
+ #: lib/hammer_cli_foreman_bootdisk/bootdisk.rb:19
48
+ msgid "Successfully downloaded host disk image to %s"
49
+ msgstr ""
50
+
51
+ #: lib/hammer_cli_foreman_bootdisk/bootdisk.rb:20
52
+ msgid "Failed to download host disk image"
53
+ msgstr ""
54
+
55
+ #: lib/hammer_cli_foreman_bootdisk.rb:12
56
+ msgid "Download boot disks"
57
+ msgstr ""
@@ -0,0 +1,57 @@
1
+ # Hammer CLI Foreman Bootdisk
2
+ # Copyright (C) 2014
3
+ # This file is distributed under the same license as the hammer_cli_foreman_bootdisk package.
4
+ # Dominic Cleal <dcleal@redhat.com>, 2014
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: hammer_cli_foreman_bootdisk 0.1.0\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2014-08-08 14:31+0100\n"
12
+ "PO-Revision-Date: 2014-08-08 14:24+0100\n"
13
+ "Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
14
+ "Language-Team: Foreman Team <foreman-dev@googlegroups.com>\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=2; plural=(n != 1);\n"
20
+
21
+ #: lib/hammer_cli_foreman_bootdisk/commands.rb:6
22
+ msgid "File or device to write image to"
23
+ msgstr ""
24
+
25
+ #: lib/hammer_cli_foreman_bootdisk/commands.rb:7
26
+ msgid "Force writing to existing destination (device etc.)"
27
+ msgstr ""
28
+
29
+ #: lib/hammer_cli_foreman_bootdisk/commands.rb:8
30
+ msgid "Use sudo to write to device"
31
+ msgstr ""
32
+
33
+ #: lib/hammer_cli_foreman_bootdisk/commands.rb:14
34
+ msgid ""
35
+ "Destination %s already exists and isn't a regular file, use '--force' if you "
36
+ "are sure you wish to write to it"
37
+ msgstr ""
38
+
39
+ #: lib/hammer_cli_foreman_bootdisk/bootdisk.rb:9
40
+ msgid "Successfully downloaded generic disk image to %s"
41
+ msgstr ""
42
+
43
+ #: lib/hammer_cli_foreman_bootdisk/bootdisk.rb:10
44
+ msgid "Failed to download generic disk image"
45
+ msgstr ""
46
+
47
+ #: lib/hammer_cli_foreman_bootdisk/bootdisk.rb:19
48
+ msgid "Successfully downloaded host disk image to %s"
49
+ msgstr ""
50
+
51
+ #: lib/hammer_cli_foreman_bootdisk/bootdisk.rb:20
52
+ msgid "Failed to download host disk image"
53
+ msgstr ""
54
+
55
+ #: lib/hammer_cli_foreman_bootdisk.rb:12
56
+ msgid "Download boot disks"
57
+ msgstr ""
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hammer_cli_foreman_bootdisk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dominic Cleal
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hammer_cli_foreman
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.1
27
+ description: Foreman boot disk commands for Hammer CLI
28
+ email: dcleal@redhat.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files:
32
+ - README.md
33
+ files:
34
+ - lib/hammer_cli_foreman_bootdisk/version.rb
35
+ - lib/hammer_cli_foreman_bootdisk/i18n.rb
36
+ - lib/hammer_cli_foreman_bootdisk/commands.rb
37
+ - lib/hammer_cli_foreman_bootdisk/bootdisk.rb
38
+ - lib/hammer_cli_foreman_bootdisk.rb
39
+ - locale/README.md
40
+ - locale/Makefile
41
+ - locale/en/hammer_cli_foreman_bootdisk.po
42
+ - locale/en/LC_MESSAGES/hammer_cli_foreman_bootdisk.mo
43
+ - locale/hammer_cli_foreman_bootdisk.pot
44
+ - README.md
45
+ homepage: http://github.com/theforeman/hammer_cli_foreman_bootdisk
46
+ licenses:
47
+ - GPL v3+
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.0.6
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Foreman boot disk commands for Hammer
69
+ test_files: []