Project

General

Profile

Download (2.49 KB) Statistics
| Branch: | Tag: | Revision:

hammer-cli-import / README.md @ master

1
# hammer-cli-import
2

    
3
Tool for importing data from an existing Spacewalk/Satellite system.
4

    
5
THIS TOOL IS WORK IN PROGRESS.
6

    
7
## Setup info
8

    
9
To enable modules do the following:
10

    
11
~~~~ { .bash }
12
mkdir -p ~/.hammer
13
cat >> ~/.hammer/cli_config.yml << EOF
14
:modules:
15
  - hammer_cli_import
16
EOF
17
~~~~
18

    
19
And running with
20

    
21
~~~ { .bash }
22
env RUBYOPT=-Ilib hammer import
23
~~~
24

    
25
To build/install as a gem:
26

    
27
~~~ { .bash }
28
gem build hammer_cli_import.gemspec
29
gem install hammer_cli_import-0.0.1.gem
30
hammer import
31
~~~
32

    
33
## RuboCop
34

    
35
[RuboCop][rubocop] requires at least Ruby 1.9.2. That is available in SCL.
36

    
37
~~~ { .bash }
38
yum install -y ruby193-ruby-devel
39
scl enable ruby193 "gem install rubocop"
40
~~~
41

    
42
It needs to be run with newer Ruby too (it will pick up its configuration
43
automatically when run from the root of repository).
44

    
45
~~~ { .bash }
46
scl enable ruby193 "/opt/rh/ruby193/root/usr/local/share/gems/gems/*/bin/rubocop"
47
~~~
48

    
49
## Development
50

    
51
You can add to your `~/.irbrc`:
52

    
53
~~~ { .ruby }
54
class Object
55
  def imethods
56
    methods - Object.instance_methods
57
  end
58

    
59
  def methods_re(re)
60
    methods.select do |m|
61
      re.match m.to_s
62
    end
63
  end
64
end
65
~~~
66

    
67
### Reproducers
68

    
69
You can play with apipie-bindings on command line. For that you need bundler. Example session:
70

    
71
~~~
72
[hammer-cli-import]$ gem install bundler
73
[hammer-cli-import]$ bundle exec irb
74

    
75
require 'apipie-bindings'
76
api = ApipieBindings::API.new({:uri => 'http://localhost/', :username => 'admin', :password => :changeme, :api_version => '2', :aggressive_cache_checking => true})
77
user_hash = {
78
:login => "newuser",
79
:firstname => "user",
80
:lastname => "new",
81
:mail => "root@localhost",
82
:auth_source_id => 1,
83
:password => "password",
84
:organization_ids => [13],
85
:default_organization_id => 13,
86
:location_ids => [],
87
:role_ids => [],
88
}
89
api.resource(:users).call(:create, user_hash)
90
~~~
91

    
92
or create `reproducer.rb` and then run it via `bundle exec ruby reproducer.rb`.
93

    
94
~~~ { .ruby }
95
require 'apipie-bindings'
96

    
97
api = ApipieBindings::API.new({:uri => 'http://localhost/', :username => 'admin',
98
                               :password => 'changeme', :api_version => '2',
99
                               :aggressive_cache_checking => true})
100
user_hash = {
101
  :login => 'newuser',
102
  :firstname => 'user',
103
  :lastname => 'new',
104
  :mail => 'root@localhost',
105
  :auth_source_id => 1,
106
  :password => 'password',
107
  :organization_ids => [13],
108
  :default_organization_id => 13,
109
  :location_ids => [],
110
  :role_ids => []
111
}
112
api.resource(:users).call(:create, user_hash)
113
~~~
114

    
115
[rubocop]: http://batsov.com/rubocop/ "Ruby code analyzer"