hammer_cli_foreman 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of hammer_cli_foreman might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/config/foreman.yml +16 -0
- data/doc/host_create.md +102 -54
- data/doc/release_notes.md +20 -0
- data/lib/hammer_cli_foreman.rb +8 -0
- data/lib/hammer_cli_foreman/commands.rb +33 -9
- data/lib/hammer_cli_foreman/compute_resource.rb +13 -2
- data/lib/hammer_cli_foreman/domain.rb +24 -1
- data/lib/hammer_cli_foreman/environment.rb +1 -2
- data/lib/hammer_cli_foreman/host.rb +131 -73
- data/lib/hammer_cli_foreman/hostgroup.rb +18 -8
- data/lib/hammer_cli_foreman/i18n.rb +2 -6
- data/lib/hammer_cli_foreman/id_resolver.rb +41 -6
- data/lib/hammer_cli_foreman/interface.rb +165 -0
- data/lib/hammer_cli_foreman/output/fields.rb +7 -0
- data/lib/hammer_cli_foreman/output/formatters.rb +3 -5
- data/lib/hammer_cli_foreman/puppet_class.rb +16 -2
- data/lib/hammer_cli_foreman/settings.rb +37 -0
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +75 -11
- data/lib/hammer_cli_foreman/smart_variable.rb +146 -0
- data/lib/hammer_cli_foreman/user.rb +9 -3
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/locale/Makefile +9 -17
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/hammer-cli-foreman.edit.po +2403 -0
- data/locale/de/hammer-cli-foreman.po +302 -355
- data/locale/de/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/hammer-cli-foreman.edit.po +2260 -0
- data/locale/en/hammer-cli-foreman.po +946 -823
- data/locale/en/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/hammer-cli-foreman.edit.po +2267 -0
- data/locale/en_GB/hammer-cli-foreman.po +297 -351
- data/locale/en_GB/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/hammer-cli-foreman.edit.po +2427 -0
- data/locale/es/hammer-cli-foreman.po +301 -354
- data/locale/es/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/hammer-cli-foreman.edit.po +2427 -0
- data/locale/fr/hammer-cli-foreman.po +299 -353
- data/locale/fr/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/hammer-cli-foreman.pot +1413 -1112
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/hammer-cli-foreman.edit.po +2402 -0
- data/locale/it/hammer-cli-foreman.po +299 -353
- data/locale/it/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/hammer-cli-foreman.edit.po +2401 -0
- data/locale/ja/hammer-cli-foreman.po +338 -391
- data/locale/ja/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/hammer-cli-foreman.edit.po +2401 -0
- data/locale/ko/hammer-cli-foreman.po +299 -353
- data/locale/ko/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/hammer-cli-foreman.edit.po +2417 -0
- data/locale/pt_BR/hammer-cli-foreman.po +312 -365
- data/locale/pt_BR/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/hammer-cli-foreman.edit.po +2401 -0
- data/locale/ru/hammer-cli-foreman.po +300 -354
- data/locale/ru/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/hammer-cli-foreman.edit.po +2400 -0
- data/locale/zh_CN/hammer-cli-foreman.po +299 -353
- data/locale/zh_CN/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/hammer-cli-foreman.edit.po +2400 -0
- data/locale/zh_TW/hammer-cli-foreman.po +299 -353
- data/locale/zh_TW/hammer-cli-foreman.po.time_stamp +0 -0
- data/test/unit/apipie_resource_mock.rb +7 -0
- data/test/unit/commands_test.rb +42 -0
- data/test/unit/data/1.7/foreman_api.json +1 -0
- data/test/unit/dependency_resolver_test.rb +4 -2
- data/test/unit/environment_test.rb +2 -2
- data/test/unit/host_test.rb +50 -27
- data/test/unit/hostgroup_test.rb +19 -3
- data/test/unit/media_test.rb +2 -2
- data/test/unit/puppet_class_test.rb +17 -2
- data/test/unit/smart_class_parameter_test.rb +26 -2
- data/test/unit/smart_variable_test.rb +134 -0
- data/test/unit/test_helper.rb +1 -1
- metadata +36 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b196146a134afe8482c703b560288d0e8cb2206
|
4
|
+
data.tar.gz: 15eab89eccbcd3cd909194ddba493797dce136eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beb620540ca30ef2cf3b17c9ca29b6e1ae781a3dd7bc1d173de3e9d6854cc4426872cf494fc5f65437b8aa81a59a67569b51081637005785b0549c93f072988c
|
7
|
+
data.tar.gz: 2225626548fe1c23627620b3a7d82806d32637ecec5fee683ab3726a8be613074027f243866c6cdc708a1e764013006da648dcab105e7a051318d985edf494a4
|
data/config/foreman.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
:foreman:
|
2
|
+
# Enable/disable foreman commands
|
3
|
+
:enable_module: true
|
4
|
+
|
5
|
+
# Your foreman server address
|
6
|
+
:host: 'https://localhost/'
|
7
|
+
|
8
|
+
# Credentials. You'll be asked for them interactively if you leave them blank here
|
9
|
+
:username: 'admin'
|
10
|
+
#:password: 'example'
|
11
|
+
|
12
|
+
# Check API documentation cache status on each request
|
13
|
+
#:refresh_cache: false
|
14
|
+
|
15
|
+
# API request timeout. Set to -1 for no timeout
|
16
|
+
#:request_timeout: 120 #seconds
|
data/doc/host_create.md
CHANGED
@@ -10,43 +10,72 @@ Usage:
|
|
10
10
|
hammer host create [OPTIONS]
|
11
11
|
|
12
12
|
Options:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
13
|
+
--architecture ARCHITECTURE_NAME Architecture name
|
14
|
+
--architecture-id ARCHITECTURE_ID
|
15
|
+
--ask-root-password ASK_ROOT_PW One of true/false, yes/no, 1/0.
|
16
|
+
--build BUILD One of true/false, yes/no, 1/0.
|
17
|
+
Default: "true"
|
18
|
+
--comment COMMENT Additional information about this host
|
19
|
+
--compute-attributes COMPUTE_ATTRS Compute resource attributes.
|
20
|
+
Comma-separated list of key=value.
|
21
|
+
--compute-profile COMPUTE_PROFILE_NAME Name to search by
|
22
|
+
--compute-profile-id COMPUTE_PROFILE_ID
|
23
|
+
--compute-resource COMPUTE_RESOURCE_NAME Compute resource name
|
24
|
+
--compute-resource-id COMPUTE_RESOURCE_ID
|
25
|
+
--domain DOMAIN_NAME Domain name
|
26
|
+
--domain-id DOMAIN_ID Numerical ID or domain name
|
27
|
+
--enabled ENABLED One of true/false, yes/no, 1/0.
|
28
|
+
Default: "true"
|
29
|
+
--environment ENVIRONMENT_NAME Environment name
|
30
|
+
--environment-id ENVIRONMENT_ID
|
31
|
+
--hostgroup HOSTGROUP_NAME Hostgroup name
|
32
|
+
--hostgroup-id HOSTGROUP_ID
|
33
|
+
--hostgroup-title HOSTGROUP_TITLE Hostgroup title
|
34
|
+
--image IMAGE_NAME Name to search by
|
35
|
+
--image-id IMAGE_ID
|
36
|
+
--interface INTERFACE Interface parameters.
|
37
|
+
Comma-separated list of key=value.
|
38
|
+
Can be specified multiple times.
|
39
|
+
--ip IP not required if using a subnet with DHCP proxy
|
40
|
+
--location LOCATION_NAME Location name
|
41
|
+
--location-id LOCATION_ID
|
42
|
+
--mac MAC required for managed host that is bare metal, not required if it’s a virtual machine
|
43
|
+
--managed MANAGED One of true/false, yes/no, 1/0.
|
44
|
+
Default: "true"
|
45
|
+
--medium MEDIUM_NAME Medium name
|
46
|
+
--medium-id MEDIUM_ID
|
47
|
+
--model MODEL_NAME Model name
|
48
|
+
--model-id MODEL_ID
|
49
|
+
--name NAME
|
50
|
+
--operatingsystem OPERATINGSYSTEM_TITLE Operating system title
|
51
|
+
--operatingsystem-id OPERATINGSYSTEM_ID
|
52
|
+
--organization ORGANIZATION_NAME Organization name
|
53
|
+
--organization-id ORGANIZATION_ID
|
54
|
+
--owner OWNER_LOGIN Login of the owner
|
55
|
+
--owner-id OWNER_ID ID of the owner
|
56
|
+
--owner-type OWNER_TYPE Host’s owner type
|
57
|
+
--parameters PARAMS Host parameters.
|
58
|
+
Comma-separated list of key=value.
|
59
|
+
--partition-table PARTITION_TABLE_NAME Partition table name
|
60
|
+
--partition-table-id PARTITION_TABLE_ID
|
61
|
+
--progress-report-id PROGRESS_REPORT_ID UUID to track orchestration tasks status, GET /api/orchestration/:UUID/tasks
|
62
|
+
--provision-method METHOD One of 'build', 'image'
|
63
|
+
--puppet-ca-proxy PUPPET_CA_PROXY_NAME
|
64
|
+
--puppet-ca-proxy-id PUPPET_CA_PROXY_ID
|
65
|
+
--puppet-class-ids PUPPET_CLASS_IDS Comma separated list of values.
|
66
|
+
--puppet-classes PUPPET_CLASS_NAMES Comma separated list of values.
|
67
|
+
--puppet-proxy PUPPET_PROXY_NAME
|
68
|
+
--puppet-proxy-id PUPPET_PROXY_ID
|
69
|
+
--realm REALM_NAME Name to search by
|
70
|
+
--realm-id REALM_ID Numerical ID or realm name
|
71
|
+
--root-pass ROOT_PASS required if host is managed and value is not inherited from host group or default password in settings
|
72
|
+
--root-password ROOT_PW
|
73
|
+
--subnet SUBNET_NAME Subnet name
|
74
|
+
--subnet-id SUBNET_ID
|
75
|
+
--volume VOLUME Volume parameters
|
76
|
+
Comma-separated list of key=value.
|
77
|
+
Can be specified multiple times.
|
78
|
+
-h, --help print help
|
50
79
|
```
|
51
80
|
|
52
81
|
Example
|
@@ -56,36 +85,55 @@ An example command for creating a host with 2 volumes (5GB raw + 10 GB qcow2) us
|
|
56
85
|
a default network interface on a libvirt provider can look like this:
|
57
86
|
```bash
|
58
87
|
hammer host create
|
59
|
-
--hostgroup
|
60
|
-
--compute-resource
|
88
|
+
--hostgroup=my_hostgroup # most of the settings is done in the hostgroup
|
89
|
+
--compute-resource=libvirt # set the libvirt provider
|
61
90
|
--compute-attributes="cpus=2" # specify the provider specific options, see the list below
|
62
|
-
--interface="
|
91
|
+
--interface="primary=true,compute_type=network,compute_network=default" # add a network interface, can be passed multiple times
|
63
92
|
--volume="capacity=5G" # add a volume, can be passed multiple times
|
64
93
|
--volume="capacity=10G,format_type=qcow2" # add another volume with different size and type
|
65
94
|
--name="test-host"
|
66
|
-
--ip="1.2.3.4"
|
67
95
|
```
|
68
96
|
|
69
97
|
See the list of all possible option keys below.
|
70
98
|
|
71
99
|
|
72
|
-
|
100
|
+
Common interface settings
|
73
101
|
=========================
|
74
102
|
|
75
|
-
|
103
|
+
Please note that managed hosts need to have one primary interface. Always set `primary=true` for one of your interfaces.
|
104
|
+
|
76
105
|
Available keys for `--interface`:
|
77
106
|
```
|
78
|
-
type # one of Nic::Managed, Nic::BMC
|
79
107
|
mac
|
108
|
+
ip
|
109
|
+
type # One of interface, bmc, bond
|
80
110
|
name
|
81
|
-
domain_id
|
82
111
|
subnet_id
|
83
|
-
|
112
|
+
domain_id
|
113
|
+
identifier
|
114
|
+
managed # true/false
|
115
|
+
primary # true/false, each managed hosts needs to have one primary interface.
|
116
|
+
provision # true/false
|
117
|
+
virtual # true/false
|
118
|
+
|
119
|
+
# for virtual interfaces:
|
120
|
+
tag # VLAN tag, this attribute has precedence over the subnet VLAN ID. Only for virtual interfaces.
|
121
|
+
attached_to # Identifier of the interface to which this interface belongs, e.g. eth1.
|
122
|
+
|
123
|
+
# for bonds:
|
124
|
+
mode # One of balance-rr, active-backup, balance-xor, broadcast, 802.3ad, balance-tlb, balance-alb
|
125
|
+
attached_devices # Identifiers of slave interfaces, e.g. [eth1,eth2].
|
126
|
+
bond_options
|
127
|
+
|
128
|
+
# for BMCs:
|
84
129
|
provider # always IPMI
|
85
|
-
username
|
86
|
-
password
|
130
|
+
username
|
131
|
+
password
|
87
132
|
```
|
88
133
|
|
134
|
+
Provider specific options
|
135
|
+
=========================
|
136
|
+
|
89
137
|
## EC2
|
90
138
|
Available keys for `--compute-attributes`:
|
91
139
|
```
|
@@ -115,9 +163,9 @@ start # boolean, whether to start the machine or not
|
|
115
163
|
|
116
164
|
Available keys for `--interface`:
|
117
165
|
```
|
118
|
-
|
119
|
-
|
120
|
-
|
166
|
+
compute_type # one of [:bridge, :network]
|
167
|
+
compute_network / compute_bridge # name of interface according to type
|
168
|
+
compute_model # one of [virtio, rtl8139, ne2k_pci, pcnet, e1000]
|
121
169
|
```
|
122
170
|
|
123
171
|
Available keys for `--volume`:
|
@@ -149,8 +197,8 @@ start # boolean, whether to start the machine or not
|
|
149
197
|
|
150
198
|
Available keys for `--interface`:
|
151
199
|
```
|
152
|
-
|
153
|
-
|
200
|
+
compute_name # eg. eth0
|
201
|
+
compute_network # select one of available networks for a cluster
|
154
202
|
```
|
155
203
|
|
156
204
|
Available keys for `--volume`:
|
@@ -178,7 +226,7 @@ path
|
|
178
226
|
|
179
227
|
Available keys for `--interface`:
|
180
228
|
```
|
181
|
-
|
229
|
+
compute_network
|
182
230
|
```
|
183
231
|
|
184
232
|
Available keys for `--volume`:
|
data/doc/release_notes.md
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
3
|
|
4
|
+
### 0.2.0 (2015-04-23)
|
5
|
+
* Adding default org and loc to user info ([#10251](http://projects.theforeman.org/issues/10251))
|
6
|
+
* Host update resets some attributes ([#10215](http://projects.theforeman.org/issues/10215))
|
7
|
+
* Improve handling of id search errors ([#9971](http://projects.theforeman.org/issues/9971))
|
8
|
+
* Commands for managing host's interfaces ([#3849](http://projects.theforeman.org/issues/3849))
|
9
|
+
* Support for smart variables and override values ([#2928](http://projects.theforeman.org/issues/2928))
|
10
|
+
* Can't convert nil into Array in compute resouce info ([#7699](http://projects.theforeman.org/issues/7699))
|
11
|
+
* Use correct domain for system locales, only load one domain ([#9648](http://projects.theforeman.org/issues/9648))
|
12
|
+
* Allow disablement of record_to_common_format ([#8227](http://projects.theforeman.org/issues/8227))
|
13
|
+
* Puppet-classes in host and hostgroup returns without an error ([#7473](http://projects.theforeman.org/issues/7473))
|
14
|
+
* Does not resolve a nested host group to id when updating a host ([#9318](http://projects.theforeman.org/issues/9318))
|
15
|
+
* User info doesn't display timezone and locale ([#9114](http://projects.theforeman.org/issues/9114))
|
16
|
+
* Update to gettext 3.x ([#8980](http://projects.theforeman.org/issues/8980))
|
17
|
+
* Commands for settings ([#2918](http://projects.theforeman.org/issues/2918))
|
18
|
+
* Adds dns name association to domain cli ([#3630](http://projects.theforeman.org/issues/3630))
|
19
|
+
* List of host facts is shown correctly ([#7187](http://projects.theforeman.org/issues/7187))
|
20
|
+
* Add config directory to gemspec ([#8829](http://projects.theforeman.org/issues/8829))
|
21
|
+
* List commands should not be interactive for csv output ([#3898](http://projects.theforeman.org/issues/3898))
|
22
|
+
|
23
|
+
|
4
24
|
### 0.1.4 (2014-12-11)
|
5
25
|
* sending puppet class ids ([#8651](http://projects.theforeman.org/issues/8651))
|
6
26
|
* setting --puppet-class-ids on host create/update throws api exception ([#8642](http://projects.theforeman.org/issues/8642))
|
data/lib/hammer_cli_foreman.rb
CHANGED
@@ -107,10 +107,18 @@ module HammerCLIForeman
|
|
107
107
|
'HammerCLIForeman::SmartClassParameter', 'hammer_cli_foreman/smart_class_parameter'
|
108
108
|
)
|
109
109
|
|
110
|
+
HammerCLI::MainCommand.lazy_subcommand('smart-variable', _("Manipulate smart variables."),
|
111
|
+
'HammerCLIForeman::SmartVariable', 'hammer_cli_foreman/smart_variable'
|
112
|
+
)
|
113
|
+
|
110
114
|
HammerCLI::MainCommand.lazy_subcommand('proxy', _("Manipulate smart proxies."),
|
111
115
|
'HammerCLIForeman::SmartProxy', 'hammer_cli_foreman/smart_proxy'
|
112
116
|
)
|
113
117
|
|
118
|
+
HammerCLI::MainCommand.lazy_subcommand('settings', _("Change server settings."),
|
119
|
+
'HammerCLIForeman::Settings', 'hammer_cli_foreman/settings'
|
120
|
+
)
|
121
|
+
|
114
122
|
HammerCLI::MainCommand.lazy_subcommand('subnet', _("Manipulate subnets."),
|
115
123
|
'HammerCLIForeman::Subnet', 'hammer_cli_foreman/subnet'
|
116
124
|
)
|
@@ -148,7 +148,10 @@ module HammerCLIForeman
|
|
148
148
|
begin
|
149
149
|
resolver.send("#{resource.singular_name}_id", opts)
|
150
150
|
rescue HammerCLIForeman::MissingSeachOptions => e
|
151
|
-
|
151
|
+
if (options[:required] == true || resource_search_requested(resource, opts))
|
152
|
+
logger.info "Error occured while searching for #{resource.singular_name}"
|
153
|
+
raise e
|
154
|
+
end
|
152
155
|
end
|
153
156
|
end
|
154
157
|
|
@@ -157,7 +160,10 @@ module HammerCLIForeman
|
|
157
160
|
begin
|
158
161
|
resolver.send("#{resource.singular_name}_ids", opts)
|
159
162
|
rescue HammerCLIForeman::MissingSeachOptions => e
|
160
|
-
|
163
|
+
if (options[:required] == true || resource_search_requested(resource, opts, true))
|
164
|
+
logger.info "Error occured while searching for #{resource.name}"
|
165
|
+
raise e
|
166
|
+
end
|
161
167
|
end
|
162
168
|
end
|
163
169
|
|
@@ -176,7 +182,7 @@ module HammerCLIForeman
|
|
176
182
|
end
|
177
183
|
|
178
184
|
def send_request
|
179
|
-
|
185
|
+
transform_format(super)
|
180
186
|
rescue HammerCLIForeman::MissingSeachOptions => e
|
181
187
|
|
182
188
|
switches = self.class.find_options(:referenced_resource => e.resource.singular_name).map(&:long_switch)
|
@@ -198,6 +204,10 @@ module HammerCLIForeman
|
|
198
204
|
)
|
199
205
|
end
|
200
206
|
|
207
|
+
def transform_format(data)
|
208
|
+
HammerCLIForeman.record_to_common_format(data)
|
209
|
+
end
|
210
|
+
|
201
211
|
def customized_options
|
202
212
|
params = options
|
203
213
|
# resolve all '<resource_name>_id' parameters if they are defined as options
|
@@ -235,6 +245,18 @@ module HammerCLIForeman
|
|
235
245
|
params_pruned['id'] = params[id_option_name] if params[id_option_name]
|
236
246
|
params_pruned
|
237
247
|
end
|
248
|
+
|
249
|
+
private
|
250
|
+
|
251
|
+
def resource_search_requested(resource, options, plural=false)
|
252
|
+
# check if any searchable for given resource is set
|
253
|
+
filed_options = Hash[options.select { |opt, value| !value.nil? }].keys
|
254
|
+
searchable_options = searchables.for(resource).map do |o|
|
255
|
+
HammerCLI.option_accessor_name(plural ? o.plural_name : o.name)
|
256
|
+
end
|
257
|
+
!(filed_options & searchable_options).empty?
|
258
|
+
end
|
259
|
+
|
238
260
|
end
|
239
261
|
|
240
262
|
|
@@ -245,16 +267,19 @@ module HammerCLIForeman
|
|
245
267
|
DEFAULT_PER_PAGE = 20
|
246
268
|
|
247
269
|
def adapter
|
248
|
-
:table
|
270
|
+
@context[:adapter] || :table
|
249
271
|
end
|
250
272
|
|
251
273
|
def send_request
|
252
|
-
|
253
|
-
set = HammerCLIForeman.collection_to_common_format(data)
|
274
|
+
set = super
|
254
275
|
set.map! { |r| extend_data(r) }
|
255
276
|
set
|
256
277
|
end
|
257
278
|
|
279
|
+
def transform_format(data)
|
280
|
+
HammerCLIForeman.collection_to_common_format(data)
|
281
|
+
end
|
282
|
+
|
258
283
|
def extend_data(record)
|
259
284
|
record
|
260
285
|
end
|
@@ -284,7 +309,7 @@ module HammerCLIForeman
|
|
284
309
|
while list_next do
|
285
310
|
d = retrieve_and_print
|
286
311
|
|
287
|
-
if (d.size >= self.option_per_page.to_i) && interactive?
|
312
|
+
if (d.size >= self.option_per_page.to_i) && interactive? && adapter != :csv
|
288
313
|
answer = ask(_("List next page? (%s): ") % 'Y/n').downcase
|
289
314
|
list_next = (answer == 'y' || answer == '')
|
290
315
|
self.option_page += 1
|
@@ -347,8 +372,7 @@ module HammerCLIForeman
|
|
347
372
|
end
|
348
373
|
|
349
374
|
def send_request
|
350
|
-
|
351
|
-
record = HammerCLIForeman.record_to_common_format(data)
|
375
|
+
record = super
|
352
376
|
extend_data(record)
|
353
377
|
end
|
354
378
|
|
@@ -5,12 +5,21 @@ module HammerCLIForeman
|
|
5
5
|
class ComputeResource < HammerCLIForeman::Command
|
6
6
|
resource :compute_resources
|
7
7
|
|
8
|
+
module ProviderNameLegacy
|
9
|
+
def extend_data(data)
|
10
|
+
# api used to return provider_friendly_name as a provider
|
11
|
+
data['provider_friendly_name'] ||= data['provider']
|
12
|
+
data
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
class ListCommand < HammerCLIForeman::ListCommand
|
17
|
+
include ProviderNameLegacy
|
9
18
|
|
10
19
|
output do
|
11
20
|
field :id, _("Id")
|
12
21
|
field :name, _("Name")
|
13
|
-
field :
|
22
|
+
field :provider_friendly_name, _("Provider")
|
14
23
|
end
|
15
24
|
|
16
25
|
build_options
|
@@ -18,6 +27,8 @@ module HammerCLIForeman
|
|
18
27
|
|
19
28
|
|
20
29
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
30
|
+
include ProviderNameLegacy
|
31
|
+
|
21
32
|
PROVIDER_SPECIFIC_FIELDS = {
|
22
33
|
'ovirt' => [
|
23
34
|
Fields::Field.new(:label => _('UUID'), :path => ["compute_resource", "uuid"])
|
@@ -49,7 +60,7 @@ module HammerCLIForeman
|
|
49
60
|
|
50
61
|
def print_data(data)
|
51
62
|
provider = data["provider"].downcase
|
52
|
-
output_definition.fields.concat
|
63
|
+
output_definition.fields.concat(PROVIDER_SPECIFIC_FIELDS[provider] || [])
|
53
64
|
super(data)
|
54
65
|
end
|
55
66
|
|
@@ -1,5 +1,26 @@
|
|
1
1
|
module HammerCLIForeman
|
2
2
|
|
3
|
+
module DomainUpdateCreateCommons
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.option "--dns-id", "DNS_ID", _("ID of DNS proxy to use within this domain")
|
7
|
+
base.option "--dns", "DNS_NAME", _("Name of DNS proxy to use within this domain")
|
8
|
+
end
|
9
|
+
|
10
|
+
def request_params
|
11
|
+
params = super
|
12
|
+
params['domain']["dns_id"] = option_dns_id || dns_id(option_dns)
|
13
|
+
params
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def dns_id(name)
|
19
|
+
resolver.smart_proxy_id('option_name' => name) if name
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
3
24
|
class Domain < HammerCLIForeman::Command
|
4
25
|
|
5
26
|
resource :domains
|
@@ -31,16 +52,18 @@ module HammerCLIForeman
|
|
31
52
|
|
32
53
|
|
33
54
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
55
|
+
include DomainUpdateCreateCommons
|
34
56
|
|
35
57
|
success_message _("Domain [%{name}] created")
|
36
58
|
failure_message _("Could not create the domain")
|
37
59
|
|
38
60
|
option "--description", "DESC", _("Full name describing the domain"), :attribute_name => :option_fullname
|
39
|
-
build_options :without => [:domain_parameters_attributes, :fullname]
|
61
|
+
build_options :without => [:domain_parameters_attributes, :fullname, :dns_id]
|
40
62
|
end
|
41
63
|
|
42
64
|
|
43
65
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
66
|
+
include DomainUpdateCreateCommons
|
44
67
|
|
45
68
|
success_message _("Domain [%{name}] updated")
|
46
69
|
failure_message _("Could not update the domain")
|