puppet 5.5.6-universal-darwin → 5.5.7-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/Gemfile.lock +12 -12
- data/Rakefile +9 -0
- data/lib/puppet/application.rb +5 -0
- data/lib/puppet/application/apply.rb +1 -0
- data/lib/puppet/application/master.rb +9 -7
- data/lib/puppet/application/script.rb +1 -1
- data/lib/puppet/defaults.rb +51 -31
- data/lib/puppet/etc.rb +20 -0
- data/lib/puppet/file_serving/fileset.rb +1 -1
- data/lib/puppet/functions.rb +123 -0
- data/lib/puppet/functions/new.rb +37 -53
- data/lib/puppet/functions/warning.rb +1 -1
- data/lib/puppet/loaders.rb +1 -0
- data/lib/puppet/parser/functions.rb +3 -1
- data/lib/puppet/parser/functions/sprintf.rb +12 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +16 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +3 -4
- data/lib/puppet/pops/issues.rb +8 -0
- data/lib/puppet/pops/loader/loader.rb +2 -2
- data/lib/puppet/pops/loader/loader_paths.rb +3 -1
- data/lib/puppet/pops/loader/module_loaders.rb +1 -1
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +62 -0
- data/lib/puppet/pops/loaders.rb +5 -21
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/parser/lexer2.rb +1 -1
- data/lib/puppet/pops/validation/checker4_0.rb +31 -6
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
- data/lib/puppet/property/keyvalue.rb +70 -8
- data/lib/puppet/provider/aix_object.rb +483 -0
- data/lib/puppet/provider/exec.rb +54 -57
- data/lib/puppet/provider/group/aix.rb +40 -115
- data/lib/puppet/provider/group/pw.rb +4 -8
- data/lib/puppet/provider/group/windows_adsi.rb +7 -4
- data/lib/puppet/provider/nameservice.rb +1 -25
- data/lib/puppet/provider/nameservice/directoryservice.rb +5 -3
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/windows.rb +2 -2
- data/lib/puppet/provider/package/windows/exe_package.rb +3 -10
- data/lib/puppet/provider/package/zypper.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +19 -3
- data/lib/puppet/provider/service/windows.rb +49 -40
- data/lib/puppet/provider/user/aix.rb +180 -246
- data/lib/puppet/provider/user/windows_adsi.rb +9 -1
- data/lib/puppet/resource/catalog.rb +1 -5
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/exec.rb +16 -14
- data/lib/puppet/type/file.rb +2 -2
- data/lib/puppet/type/file/source.rb +9 -5
- data/lib/puppet/type/group.rb +65 -23
- data/lib/puppet/type/k5login.rb +2 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +3 -6
- data/lib/puppet/type/resources.rb +12 -2
- data/lib/puppet/type/schedule.rb +8 -1
- data/lib/puppet/type/selboolean.rb +2 -2
- data/lib/puppet/type/selmodule.rb +3 -4
- data/lib/puppet/type/service.rb +2 -5
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/user.rb +15 -20
- data/lib/puppet/type/yumrepo.rb +2 -2
- data/lib/puppet/type/zone.rb +2 -2
- data/lib/puppet/util.rb +7 -3
- data/lib/puppet/util/execution.rb +15 -1
- data/lib/puppet/util/posix.rb +15 -0
- data/lib/puppet/util/storage.rb +12 -0
- data/lib/puppet/util/windows.rb +4 -2
- data/lib/puppet/util/windows/adsi.rb +235 -205
- data/lib/puppet/util/windows/process.rb +23 -3
- data/lib/puppet/util/windows/security.rb +14 -0
- data/lib/puppet/util/windows/service.rb +977 -0
- data/lib/puppet/util/windows/user.rb +3 -5
- data/lib/puppet/version.rb +1 -1
- data/locales/ja/puppet.po +705 -374
- data/locales/puppet.pot +485 -261
- data/man/man5/puppet.conf.5 +36 -15
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-ca.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +1 -1
- data/man/man8/puppet-certificate_request.8 +1 -1
- data/man/man8/puppet-certificate_revocation_list.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-master.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_input.out +1 -0
- data/spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_output.out +1 -0
- data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +32 -0
- data/spec/integration/parser/collection_spec.rb +4 -8
- data/spec/integration/provider/service/windows_spec.rb +5 -5
- data/spec/integration/type/file_spec.rb +6 -6
- data/spec/integration/util/windows/adsi_spec.rb +6 -5
- data/spec/integration/util/windows/security_spec.rb +10 -7
- data/spec/integration/util/windows/user_spec.rb +37 -17
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/application/apply_spec.rb +41 -2
- data/spec/unit/application/master_spec.rb +7 -0
- data/spec/unit/application_spec.rb +21 -3
- data/spec/unit/defaults_spec.rb +20 -0
- data/spec/unit/etc_spec.rb +25 -0
- data/spec/unit/file_serving/fileset_spec.rb +11 -11
- data/spec/unit/gettext/config_spec.rb +1 -1
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +6 -6
- data/spec/unit/pops/loaders/loaders_spec.rb +40 -7
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
- data/spec/unit/pops/validator/validator_spec.rb +129 -10
- data/spec/unit/property/keyvalue_spec.rb +97 -6
- data/spec/unit/provider/aix_object_spec.rb +805 -0
- data/spec/unit/provider/group/aix_spec.rb +57 -0
- data/spec/unit/provider/group/pw_spec.rb +0 -6
- data/spec/unit/provider/group/windows_adsi_spec.rb +34 -35
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +2 -2
- data/spec/unit/provider/package/windows/exe_package_spec.rb +3 -3
- data/spec/unit/provider/package/windows_spec.rb +4 -4
- data/spec/unit/provider/service/launchd_spec.rb +19 -0
- data/spec/unit/provider/service/windows_spec.rb +71 -78
- data/spec/unit/provider/user/aix_spec.rb +162 -116
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/resource/catalog_spec.rb +2 -2
- data/spec/unit/ssl/certificate_authority_spec.rb +0 -1
- data/spec/unit/type/group_spec.rb +111 -13
- data/spec/unit/type/resources_spec.rb +18 -0
- data/spec/unit/util/execution_spec.rb +77 -0
- data/spec/unit/util/posix_spec.rb +28 -0
- data/spec/unit/util/storage_spec.rb +107 -0
- data/spec/unit/util/windows/adsi_spec.rb +108 -13
- data/spec/unit/util/windows/service_spec.rb +669 -0
- metadata +17 -5
- data/lib/puppet/provider/aixobject.rb +0 -392
- data/spec/unit/provider/aixobject_spec.rb +0 -101
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.5.
|
4
|
+
version: 5.5.7
|
5
5
|
platform: universal-darwin
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: facter
|
@@ -822,6 +822,7 @@ files:
|
|
822
822
|
- lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb
|
823
823
|
- lib/puppet/pops/loader/ruby_data_type_instantiator.rb
|
824
824
|
- lib/puppet/pops/loader/ruby_function_instantiator.rb
|
825
|
+
- lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb
|
825
826
|
- lib/puppet/pops/loader/runtime3_type_loader.rb
|
826
827
|
- lib/puppet/pops/loader/simple_environment_loader.rb
|
827
828
|
- lib/puppet/pops/loader/static_loader.rb
|
@@ -950,7 +951,7 @@ files:
|
|
950
951
|
- lib/puppet/property/list.rb
|
951
952
|
- lib/puppet/property/ordered_list.rb
|
952
953
|
- lib/puppet/provider.rb
|
953
|
-
- lib/puppet/provider/
|
954
|
+
- lib/puppet/provider/aix_object.rb
|
954
955
|
- lib/puppet/provider/augeas/augeas.rb
|
955
956
|
- lib/puppet/provider/cisco.rb
|
956
957
|
- lib/puppet/provider/command.rb
|
@@ -1325,6 +1326,7 @@ files:
|
|
1325
1326
|
- lib/puppet/util/windows/root_certs.rb
|
1326
1327
|
- lib/puppet/util/windows/security.rb
|
1327
1328
|
- lib/puppet/util/windows/security_descriptor.rb
|
1329
|
+
- lib/puppet/util/windows/service.rb
|
1328
1330
|
- lib/puppet/util/windows/sid.rb
|
1329
1331
|
- lib/puppet/util/windows/string.rb
|
1330
1332
|
- lib/puppet/util/windows/taskscheduler.rb
|
@@ -1703,6 +1705,8 @@ files:
|
|
1703
1705
|
- spec/fixtures/unit/pops/parser/lexer/tag.pp
|
1704
1706
|
- spec/fixtures/unit/pops/parser/lexer/tagged.pp
|
1705
1707
|
- spec/fixtures/unit/pops/parser/lexer/virtualresources.pp
|
1708
|
+
- spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_input.out
|
1709
|
+
- spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_output.out
|
1706
1710
|
- spec/fixtures/unit/provider/augeas/augeas/augeas/lenses/test.aug
|
1707
1711
|
- spec/fixtures/unit/provider/augeas/augeas/etc/fstab
|
1708
1712
|
- spec/fixtures/unit/provider/augeas/augeas/etc/hosts
|
@@ -1772,6 +1776,7 @@ files:
|
|
1772
1776
|
- spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys2
|
1773
1777
|
- spec/fixtures/unit/provider/sshkey/parsed/sample
|
1774
1778
|
- spec/fixtures/unit/provider/sshkey/parsed/sample_with_blank_lines
|
1779
|
+
- spec/fixtures/unit/provider/user/aix/aix_passwd_file.out
|
1775
1780
|
- spec/fixtures/unit/provider/zfs/zfs/zfs-list.out
|
1776
1781
|
- spec/fixtures/unit/provider/zpool/zpool/zpool-list.out
|
1777
1782
|
- spec/fixtures/unit/reports/tagmail/tagmail_email.conf
|
@@ -2376,7 +2381,7 @@ files:
|
|
2376
2381
|
- spec/unit/property/ordered_list_spec.rb
|
2377
2382
|
- spec/unit/property_spec.rb
|
2378
2383
|
- spec/unit/provider/README.markdown
|
2379
|
-
- spec/unit/provider/
|
2384
|
+
- spec/unit/provider/aix_object_spec.rb
|
2380
2385
|
- spec/unit/provider/augeas/augeas_spec.rb
|
2381
2386
|
- spec/unit/provider/cisco_spec.rb
|
2382
2387
|
- spec/unit/provider/command_spec.rb
|
@@ -2388,6 +2393,7 @@ files:
|
|
2388
2393
|
- spec/unit/provider/exec_spec.rb
|
2389
2394
|
- spec/unit/provider/file/posix_spec.rb
|
2390
2395
|
- spec/unit/provider/file/windows_spec.rb
|
2396
|
+
- spec/unit/provider/group/aix_spec.rb
|
2391
2397
|
- spec/unit/provider/group/directoryservice_spec.rb
|
2392
2398
|
- spec/unit/provider/group/groupadd_spec.rb
|
2393
2399
|
- spec/unit/provider/group/ldap_spec.rb
|
@@ -2666,6 +2672,7 @@ files:
|
|
2666
2672
|
- spec/unit/util/windows/file_spec.rb
|
2667
2673
|
- spec/unit/util/windows/root_certs_spec.rb
|
2668
2674
|
- spec/unit/util/windows/security_descriptor_spec.rb
|
2675
|
+
- spec/unit/util/windows/service_spec.rb
|
2669
2676
|
- spec/unit/util/windows/sid_spec.rb
|
2670
2677
|
- spec/unit/util/windows/string_spec.rb
|
2671
2678
|
- spec/unit/util/yaml_spec.rb
|
@@ -3007,6 +3014,8 @@ test_files:
|
|
3007
3014
|
- spec/fixtures/unit/pops/parser/lexer/tag.pp
|
3008
3015
|
- spec/fixtures/unit/pops/parser/lexer/tagged.pp
|
3009
3016
|
- spec/fixtures/unit/pops/parser/lexer/virtualresources.pp
|
3017
|
+
- spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_input.out
|
3018
|
+
- spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_output.out
|
3010
3019
|
- spec/fixtures/unit/provider/augeas/augeas/augeas/lenses/test.aug
|
3011
3020
|
- spec/fixtures/unit/provider/augeas/augeas/etc/fstab
|
3012
3021
|
- spec/fixtures/unit/provider/augeas/augeas/etc/hosts
|
@@ -3076,6 +3085,7 @@ test_files:
|
|
3076
3085
|
- spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys2
|
3077
3086
|
- spec/fixtures/unit/provider/sshkey/parsed/sample
|
3078
3087
|
- spec/fixtures/unit/provider/sshkey/parsed/sample_with_blank_lines
|
3088
|
+
- spec/fixtures/unit/provider/user/aix/aix_passwd_file.out
|
3079
3089
|
- spec/fixtures/unit/provider/zfs/zfs/zfs-list.out
|
3080
3090
|
- spec/fixtures/unit/provider/zpool/zpool/zpool-list.out
|
3081
3091
|
- spec/fixtures/unit/reports/tagmail/tagmail_email.conf
|
@@ -3680,7 +3690,7 @@ test_files:
|
|
3680
3690
|
- spec/unit/property/ordered_list_spec.rb
|
3681
3691
|
- spec/unit/property_spec.rb
|
3682
3692
|
- spec/unit/provider/README.markdown
|
3683
|
-
- spec/unit/provider/
|
3693
|
+
- spec/unit/provider/aix_object_spec.rb
|
3684
3694
|
- spec/unit/provider/augeas/augeas_spec.rb
|
3685
3695
|
- spec/unit/provider/cisco_spec.rb
|
3686
3696
|
- spec/unit/provider/command_spec.rb
|
@@ -3692,6 +3702,7 @@ test_files:
|
|
3692
3702
|
- spec/unit/provider/exec_spec.rb
|
3693
3703
|
- spec/unit/provider/file/posix_spec.rb
|
3694
3704
|
- spec/unit/provider/file/windows_spec.rb
|
3705
|
+
- spec/unit/provider/group/aix_spec.rb
|
3695
3706
|
- spec/unit/provider/group/directoryservice_spec.rb
|
3696
3707
|
- spec/unit/provider/group/groupadd_spec.rb
|
3697
3708
|
- spec/unit/provider/group/ldap_spec.rb
|
@@ -3970,6 +3981,7 @@ test_files:
|
|
3970
3981
|
- spec/unit/util/windows/file_spec.rb
|
3971
3982
|
- spec/unit/util/windows/root_certs_spec.rb
|
3972
3983
|
- spec/unit/util/windows/security_descriptor_spec.rb
|
3984
|
+
- spec/unit/util/windows/service_spec.rb
|
3973
3985
|
- spec/unit/util/windows/sid_spec.rb
|
3974
3986
|
- spec/unit/util/windows/string_spec.rb
|
3975
3987
|
- spec/unit/util/yaml_spec.rb
|
@@ -1,392 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Common code for AIX providers. This class implements basic structure for
|
3
|
-
# AIX resources.
|
4
|
-
# Author:: Hector Rivas Gandara <keymon@gmail.com>
|
5
|
-
#
|
6
|
-
class Puppet::Provider::AixObject < Puppet::Provider
|
7
|
-
desc "Generic AIX resource provider"
|
8
|
-
|
9
|
-
# The real provider must implement these functions.
|
10
|
-
def lscmd( _value = @resource[:name] )
|
11
|
-
raise Puppet::Error, "Method not defined #{@resource.class.name} #{@resource.name}: Base AixObject provider doesn't implement lscmd"
|
12
|
-
end
|
13
|
-
|
14
|
-
def addcmd( _extra_attrs = [] )
|
15
|
-
raise Puppet::Error, "Method not defined #{@resource.class.name} #{@resource.name}: Base AixObject provider doesn't implement addcmd"
|
16
|
-
end
|
17
|
-
|
18
|
-
def modifycmd( _attributes_hash = {} )
|
19
|
-
raise Puppet::Error, "Method not defined #{@resource.class.name} #{@resource.name}: Base AixObject provider doesn't implement modifycmd"
|
20
|
-
end
|
21
|
-
|
22
|
-
def deletecmd
|
23
|
-
raise Puppet::Error, "Method not defined #{@resource.class.name} #{@resource.name}: Base AixObject provider doesn't implement deletecmd"
|
24
|
-
end
|
25
|
-
|
26
|
-
# Valid attributes to be managed by this provider.
|
27
|
-
# It is a list of hashes
|
28
|
-
# :aix_attr AIX command attribute name
|
29
|
-
# :puppet_prop Puppet property name
|
30
|
-
# :to Optional. Method name that adapts puppet property to aix command value.
|
31
|
-
# :from Optional. Method to adapt aix command line value to puppet property. Optional
|
32
|
-
class << self
|
33
|
-
attr_accessor :attribute_mapping
|
34
|
-
end
|
35
|
-
|
36
|
-
# Mapping from Puppet property to AIX attribute.
|
37
|
-
def self.attribute_mapping_to
|
38
|
-
if ! @attribute_mapping_to
|
39
|
-
@attribute_mapping_to = {}
|
40
|
-
attribute_mapping.each { |elem|
|
41
|
-
attribute_mapping_to[elem[:puppet_prop]] = {
|
42
|
-
:key => elem[:aix_attr],
|
43
|
-
:method => elem[:to]
|
44
|
-
}
|
45
|
-
}
|
46
|
-
end
|
47
|
-
@attribute_mapping_to
|
48
|
-
end
|
49
|
-
|
50
|
-
# Mapping from AIX attribute to Puppet property.
|
51
|
-
def self.attribute_mapping_from
|
52
|
-
if ! @attribute_mapping_from
|
53
|
-
@attribute_mapping_from = {}
|
54
|
-
attribute_mapping.each { |elem|
|
55
|
-
attribute_mapping_from[elem[:aix_attr]] = {
|
56
|
-
:key => elem[:puppet_prop],
|
57
|
-
:method => elem[:from]
|
58
|
-
}
|
59
|
-
}
|
60
|
-
end
|
61
|
-
@attribute_mapping_from
|
62
|
-
end
|
63
|
-
|
64
|
-
# This functions translates a key and value using the given mapping.
|
65
|
-
# Mapping can be nil (no translation) or a hash with this format
|
66
|
-
# {:key => new_key, :method => translate_method}
|
67
|
-
# It returns a list with the pair [key, value]
|
68
|
-
def translate_attr(key, value, mapping)
|
69
|
-
return [key, value] unless mapping
|
70
|
-
return nil unless mapping[key]
|
71
|
-
|
72
|
-
if mapping[key][:method]
|
73
|
-
new_value = method(mapping[key][:method]).call(value)
|
74
|
-
else
|
75
|
-
new_value = value
|
76
|
-
end
|
77
|
-
[mapping[key][:key], new_value]
|
78
|
-
end
|
79
|
-
|
80
|
-
# Loads an AIX attribute (key=value) and stores it in the given hash with
|
81
|
-
# puppet semantics. It translates the pair using the given mapping.
|
82
|
-
#
|
83
|
-
# This operation works with each property one by one,
|
84
|
-
# subclasses must reimplement this if more complex operations are needed
|
85
|
-
def load_attribute(key, value, mapping, objectinfo)
|
86
|
-
if mapping.nil?
|
87
|
-
objectinfo[key] = value
|
88
|
-
elsif mapping[key].nil?
|
89
|
-
# is not present in mapping, ignore it.
|
90
|
-
true
|
91
|
-
elsif mapping[key][:method].nil?
|
92
|
-
objectinfo[mapping[key][:key]] = value
|
93
|
-
else
|
94
|
-
objectinfo[mapping[key][:key]] = method(mapping[key][:method]).call(value)
|
95
|
-
end
|
96
|
-
|
97
|
-
return objectinfo
|
98
|
-
end
|
99
|
-
|
100
|
-
# Gets the given command line argument for the given key and value,
|
101
|
-
# using the given mapping to translate key and value.
|
102
|
-
# All the objectinfo hash (@resource or @property_hash) is passed.
|
103
|
-
#
|
104
|
-
# This operation works with each property one by one,
|
105
|
-
# and default behaviour is return the arguments as key=value pairs.
|
106
|
-
# Subclasses must reimplement this if more complex operations/arguments
|
107
|
-
# are needed
|
108
|
-
#
|
109
|
-
def get_arguments(key, value, mapping, objectinfo)
|
110
|
-
if mapping.nil?
|
111
|
-
new_key = key
|
112
|
-
new_value = value
|
113
|
-
elsif mapping[key].nil?
|
114
|
-
# is not present in mapping, ignore it.
|
115
|
-
new_key = nil
|
116
|
-
new_value = nil
|
117
|
-
elsif mapping[key][:method].nil?
|
118
|
-
new_key = mapping[key][:key]
|
119
|
-
new_value = value
|
120
|
-
else
|
121
|
-
new_key = mapping[key][:key]
|
122
|
-
new_value = method(mapping[key][:method]).call(value)
|
123
|
-
end
|
124
|
-
|
125
|
-
# convert it to string
|
126
|
-
new_value = Array(new_value).join(',')
|
127
|
-
|
128
|
-
if new_key
|
129
|
-
return [ "#{new_key}=#{new_value}" ]
|
130
|
-
else
|
131
|
-
return []
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
# Convert the provider properties (hash) to AIX command arguments
|
136
|
-
# (list of strings)
|
137
|
-
# This function will translate each value/key and generate the argument using
|
138
|
-
# the get_arguments function.
|
139
|
-
def hash2args(hash, mapping=self.class.attribute_mapping_to)
|
140
|
-
return "" unless hash
|
141
|
-
arg_list = []
|
142
|
-
hash.each {|key, val|
|
143
|
-
arg_list += self.get_arguments(key, val, mapping, hash)
|
144
|
-
}
|
145
|
-
arg_list
|
146
|
-
end
|
147
|
-
|
148
|
-
# Parse AIX command attributes from the output of an AIX command, that
|
149
|
-
# which format is a list of space separated of key=value pairs:
|
150
|
-
# "uid=100 groups=a,b,c".
|
151
|
-
# It returns a hash.
|
152
|
-
#
|
153
|
-
# If a mapping is provided, the keys are translated as defined in the
|
154
|
-
# mapping hash. And only values included in mapping will be added
|
155
|
-
#
|
156
|
-
# NOTE: it will ignore the items not including '='
|
157
|
-
def parse_attr_list(str, mapping=self.class.attribute_mapping_from)
|
158
|
-
properties = {}
|
159
|
-
attrs = []
|
160
|
-
if str.nil? or (attrs = str.split()).empty?
|
161
|
-
return nil
|
162
|
-
end
|
163
|
-
|
164
|
-
attrs.each { |i|
|
165
|
-
if i.include? "=" # Ignore if it does not include '='
|
166
|
-
(key_str, val) = i.split('=')
|
167
|
-
# Check the key
|
168
|
-
if key_str.nil? or key_str.empty?
|
169
|
-
info _("Empty key in string 'i'?")
|
170
|
-
continue
|
171
|
-
end
|
172
|
-
key_str.strip!
|
173
|
-
key = key_str.to_sym
|
174
|
-
val.strip! if val
|
175
|
-
|
176
|
-
properties = self.load_attribute(key, val, mapping, properties)
|
177
|
-
end
|
178
|
-
}
|
179
|
-
properties.empty? ? nil : properties
|
180
|
-
end
|
181
|
-
|
182
|
-
# Parse AIX command output in a colon separated list of attributes,
|
183
|
-
# This function is useful to parse the output of commands like lsfs -c:
|
184
|
-
# #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
|
185
|
-
# /:/dev/hd4:jfs2::bootfs:557056:rw:yes:no
|
186
|
-
# /home:/dev/hd1:jfs2:::2129920:rw:yes:no
|
187
|
-
# /usr:/dev/hd2:jfs2::bootfs:9797632:rw:yes:no
|
188
|
-
#
|
189
|
-
# If a mapping is provided, the keys are translated as defined in the
|
190
|
-
# mapping hash. And only values included in mapping will be added
|
191
|
-
def parse_colon_list(str, key_list, mapping=self.class.attribute_mapping_from)
|
192
|
-
properties = {}
|
193
|
-
attrs = []
|
194
|
-
if str.nil? or (attrs = str.split(':')).empty?
|
195
|
-
return nil
|
196
|
-
end
|
197
|
-
|
198
|
-
attrs.each { |val|
|
199
|
-
key = key_list.shift.to_sym
|
200
|
-
properties = self.load_attribute(key, val, mapping, properties)
|
201
|
-
}
|
202
|
-
properties.empty? ? nil : properties
|
203
|
-
end
|
204
|
-
|
205
|
-
# Default parsing function for AIX commands.
|
206
|
-
# It will choose the method depending of the first line.
|
207
|
-
# For the colon separated list it will:
|
208
|
-
# 1. Get keys from first line.
|
209
|
-
# 2. Parse next line.
|
210
|
-
def parse_command_output(output, mapping=self.class.attribute_mapping_from)
|
211
|
-
lines = output.split("\n")
|
212
|
-
# if it begins with #something:... is a colon separated list.
|
213
|
-
if lines[0] =~ /^#.*:/
|
214
|
-
self.parse_colon_list(lines[1], lines[0][1..-1].split(':'), mapping)
|
215
|
-
else
|
216
|
-
self.parse_attr_list(lines[0], mapping)
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
# Retrieve all the information of an existing resource.
|
221
|
-
# It will execute 'lscmd' command and parse the output, using the mapping
|
222
|
-
# 'attribute_mapping_from' to translate the keys and values.
|
223
|
-
def getinfo(refresh = false)
|
224
|
-
if @objectinfo.nil? or refresh == true
|
225
|
-
# Execute lsuser, split all attributes and add them to a dict.
|
226
|
-
begin
|
227
|
-
output = execute(self.lscmd)
|
228
|
-
@objectinfo = self.parse_command_output(output)
|
229
|
-
# All attributes without translation
|
230
|
-
@objectosinfo = self.parse_command_output(output, nil)
|
231
|
-
rescue Puppet::ExecutionFailure => detail
|
232
|
-
# Print error if needed. FIXME: Do not check the user here.
|
233
|
-
Puppet.debug "aix.getinfo(): Could not find #{@resource.class.name} #{@resource.name}: #{detail}"
|
234
|
-
end
|
235
|
-
end
|
236
|
-
@objectinfo
|
237
|
-
end
|
238
|
-
|
239
|
-
# Like getinfo, but it will not use the mapping to translate the keys and values.
|
240
|
-
# It might be useful to retrieve some raw information.
|
241
|
-
def getosinfo(refresh = false)
|
242
|
-
if @objectosinfo.nil? or refresh == true
|
243
|
-
getinfo(refresh)
|
244
|
-
end
|
245
|
-
@objectosinfo || Hash.new
|
246
|
-
end
|
247
|
-
|
248
|
-
|
249
|
-
# List all elements of given type. It works for colon separated commands and
|
250
|
-
# list commands.
|
251
|
-
# It returns a list of names.
|
252
|
-
def self.list_all
|
253
|
-
names = []
|
254
|
-
begin
|
255
|
-
output = execute([self.command(:list), 'ALL'])
|
256
|
-
|
257
|
-
output = output.split("\n").select{ |line| line != /^#/ }
|
258
|
-
|
259
|
-
output.each do |line|
|
260
|
-
name = line.split(/[ :]/)[0]
|
261
|
-
names << name if not name.empty?
|
262
|
-
end
|
263
|
-
rescue Puppet::ExecutionFailure => detail
|
264
|
-
# Print error if needed
|
265
|
-
Puppet.debug "aix.list_all(): Could not get all resources of type #{@resource.class.name}: #{detail}"
|
266
|
-
end
|
267
|
-
names
|
268
|
-
end
|
269
|
-
|
270
|
-
|
271
|
-
#-------------
|
272
|
-
# Provider API
|
273
|
-
# ------------
|
274
|
-
|
275
|
-
# Clear out the cached values.
|
276
|
-
def flush
|
277
|
-
@property_hash.clear if @property_hash
|
278
|
-
@objectinfo.clear if @objectinfo
|
279
|
-
end
|
280
|
-
|
281
|
-
# Check that the user exists
|
282
|
-
def exists?
|
283
|
-
!!getinfo(true) # !! => converts to bool
|
284
|
-
end
|
285
|
-
|
286
|
-
# Return all existing instances
|
287
|
-
# The method for returning a list of provider instances. Note that it returns
|
288
|
-
# providers, preferably with values already filled in, not resources.
|
289
|
-
def self.instances
|
290
|
-
objects=[]
|
291
|
-
list_all.each { |entry|
|
292
|
-
objects << new(:name => entry, :ensure => :present)
|
293
|
-
}
|
294
|
-
objects
|
295
|
-
end
|
296
|
-
|
297
|
-
#- **ensure**
|
298
|
-
# The basic state that the object should be in. Valid values are
|
299
|
-
# `present`, `absent`, `role`.
|
300
|
-
# From ensurable: exists?, create, delete
|
301
|
-
def ensure
|
302
|
-
if exists?
|
303
|
-
:present
|
304
|
-
else
|
305
|
-
:absent
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
# Create a new instance of the resource
|
310
|
-
def create
|
311
|
-
if exists?
|
312
|
-
info _("already exists")
|
313
|
-
# The object already exists
|
314
|
-
return nil
|
315
|
-
end
|
316
|
-
|
317
|
-
begin
|
318
|
-
execute(self.addcmd)
|
319
|
-
rescue Puppet::ExecutionFailure => detail
|
320
|
-
raise Puppet::Error, _("Could not create %{resource} %{name}: %{detail}") % { resource: @resource.class.name, name: @resource.name, detail: detail }, detail.backtrace
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
# Delete this instance of the resource
|
325
|
-
def delete
|
326
|
-
unless exists?
|
327
|
-
info _("already absent")
|
328
|
-
# the object already doesn't exist
|
329
|
-
return nil
|
330
|
-
end
|
331
|
-
|
332
|
-
begin
|
333
|
-
execute(self.deletecmd)
|
334
|
-
rescue Puppet::ExecutionFailure => detail
|
335
|
-
raise Puppet::Error, _("Could not delete %{resource} %{name}: %{detail}") % { resource: @resource.class.name, name: @resource.name, detail: detail }, detail.backtrace
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
#--------------------------------
|
340
|
-
# Call this method when the object is initialized.
|
341
|
-
# It creates getter/setter methods for each property our resource type supports.
|
342
|
-
# If setter or getter already defined it will not be overwritten
|
343
|
-
def self.mk_resource_methods
|
344
|
-
[resource_type.validproperties, resource_type.parameters].flatten.each do |prop|
|
345
|
-
next if prop == :ensure
|
346
|
-
define_method(prop) { get(prop) || :absent} unless public_method_defined?(prop)
|
347
|
-
define_method(prop.to_s + "=") { |*vals| set(prop, *vals) } unless public_method_defined?(prop.to_s + "=")
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
# Define the needed getters and setters as soon as we know the resource type
|
352
|
-
def self.resource_type=(resource_type)
|
353
|
-
super
|
354
|
-
mk_resource_methods
|
355
|
-
end
|
356
|
-
|
357
|
-
# Retrieve a specific value by name.
|
358
|
-
def get(param)
|
359
|
-
(hash = getinfo(false)) ? hash[param] : nil
|
360
|
-
end
|
361
|
-
|
362
|
-
# Set a property.
|
363
|
-
def set(param, value)
|
364
|
-
@property_hash[param.intern] = value
|
365
|
-
|
366
|
-
if getinfo().nil?
|
367
|
-
# This is weird...
|
368
|
-
raise Puppet::Error, _("Trying to update parameter '%{param}' to '%{value}' for a resource that does not exists %{resource} %{name}: %{detail}") % { param: param, value: value, resource: @resource.class.name, name: @resource.name, detail: detail }
|
369
|
-
end
|
370
|
-
if value == getinfo()[param.to_sym]
|
371
|
-
return
|
372
|
-
end
|
373
|
-
|
374
|
-
#self.class.validate(param, value)
|
375
|
-
if cmd = modifycmd({param =>value})
|
376
|
-
begin
|
377
|
-
execute(cmd)
|
378
|
-
rescue Puppet::ExecutionFailure => detail
|
379
|
-
raise Puppet::Error, _("Could not set %{param} on %{resource}[%{name}]: %{detail}") % { param: param, resource: @resource.class.name, name: @resource.name, detail: detail }, detail.backtrace
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
# Refresh de info.
|
384
|
-
getinfo(true)
|
385
|
-
end
|
386
|
-
|
387
|
-
def initialize(resource)
|
388
|
-
super
|
389
|
-
@objectinfo = nil
|
390
|
-
@objectosinfo = nil
|
391
|
-
end
|
392
|
-
end
|