runcible 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ group :test do
9
9
  gem 'webmock'
10
10
  gem 'minitest', '< 5'
11
11
  gem 'parseconfig'
12
+ gem 'mocha'
12
13
  end
13
14
 
14
15
  group :debug do
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Exposing Pulp's juiciest parts. http://www.pulpproject.org/
6
6
 
7
- Latest Live Tested Version: **pulp-server-2.2.0-0.22.beta.fc18.noarch**
7
+ Latest Live Tested Version: **pulp-server-2.2.0-0.22.beta.el6.noarch**
8
8
 
9
9
  Current stable Runcible: https://github.com/Katello/runcible/tree/0.3
10
10
 
@@ -30,23 +30,48 @@ module Runcible
30
30
  #
31
31
  # @param [String] id the consumer ID
32
32
  # @param [String] repo_id the repo ID to bind to
33
- # @param [Boolean] notify_agent sends consumer a notification
33
+ # @param [String] type_id the distributor type_id to bind to
34
+ # @param [Hash] options options to pass to the bindings
35
+ # @option options [Boolean] :notify_agent sends consumer a notification
36
+ # @option options [Hash] :binding_config sends consumer a notification
34
37
  # @return [RestClient::Response] set of tasks representing each bind operation
35
- def bind_all(id, repo_id, notify_agent=true)
38
+ def bind_all(id, repo_id, type_id, options={})
36
39
  repository_extension.retrieve_with_details(repo_id)['distributors'].collect do |d|
37
- bind(id, repo_id, d['id'], {:notify_agent=>notify_agent})
38
- end.flatten
40
+ bind(id, repo_id, d['id'], options) if d['distributor_type_id'] == type_id
41
+ end.reject{|f| f.nil?}.flatten
39
42
  end
40
43
 
41
44
  # Unbind a consumer to all repositories with a given ID
42
45
  #
43
46
  # @param [String] id the consumer ID
44
47
  # @param [String] repo_id the repo ID to unbind from
48
+ # @param [String] type_id the distributor type_id to unbind from
45
49
  # @return [RestClient::Response] set of tasks representing each unbind operation
46
- def unbind_all(id, repo_id)
50
+ def unbind_all(id, repo_id, type_id)
47
51
  repository_extension.retrieve_with_details(repo_id)['distributors'].collect do |d|
48
- unbind(id, repo_id, d['id'])
49
- end.flatten
52
+ unbind(id, repo_id, d['id']) if d['distributor_type_id'] == type_id
53
+ end.reject{|f| f.nil?}.flatten
54
+ end
55
+
56
+ # Activate a consumer as a pulp node
57
+ #
58
+ # @param [String] id the consumer ID
59
+ # @param [String] update_strategy update_strategy for the node (defaults to additive)
60
+ # @return [RestClient::Response] response from update call
61
+ def activate_node(id, update_strategy="additive")
62
+ delta = {:notes=>{'_child-node' => true,
63
+ '_node-update-strategy' => update_strategy}}
64
+ self.update(id, delta)
65
+ end
66
+
67
+ # Deactivate a consumer as a pulp node
68
+ #
69
+ # @param [String] id the consumer ID
70
+ # @return [RestClient::Response] response from update call
71
+ def deactivate_node(id)
72
+ delta = {:notes=>{'child-node' => nil,
73
+ 'update_strategy' => nil}}
74
+ self.update(id, :delta=>delta)
50
75
  end
51
76
 
52
77
  # Install content to a consumer
@@ -95,6 +120,8 @@ module Runcible
95
120
  unit_key = :name
96
121
  when 'erratum'
97
122
  unit_key = :id
123
+ when 'repository'
124
+ unit_key = :repo_id
98
125
  else
99
126
  unit_key = :id
100
127
  end
@@ -104,6 +131,8 @@ module Runcible
104
131
  content_unit[:type_id] = type_id
105
132
  content_unit[:unit_key] = {}
106
133
  content.push(content_unit)
134
+ elsif units.nil?
135
+ content = [{:unit_key=> nil, :type_id=>type_id}]
107
136
  else
108
137
  units.each do |unit|
109
138
  content_unit = {}
@@ -60,7 +60,7 @@ module Runcible
60
60
  optional[:importer_config] = importer
61
61
  end if importer
62
62
 
63
- repo_type = if importer.methods.include?(repo_type)
63
+ repo_type = if importer.methods.include?(:repo_type)
64
64
  importer.repo_type
65
65
  elsif importer.is_a?(Hash) && importer.has_key?(:repo_type)
66
66
  importer[:repo_type]
@@ -35,10 +35,6 @@ module Runcible
35
35
  params.each{|k,v| send("#{k.to_s}=",v)}
36
36
  end
37
37
 
38
- def type_id
39
- self.class.type_id
40
- end
41
-
42
38
  # Distributor Type id
43
39
  #
44
40
  # @return [string]
@@ -0,0 +1,57 @@
1
+ # Copyright (c) 2013 Red Hat Inc.
2
+ #
3
+ # MIT License
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ require 'active_support/json'
25
+ require 'securerandom'
26
+
27
+ module Runcible
28
+ module Models
29
+ class NodesHttpDistributor < Distributor
30
+
31
+ # Instantiates an nodes distributor
32
+ #
33
+ # @param [Hash] params Distributor options
34
+ # @return [Runcible::Extensions::NodesHttpDistributor]
35
+ def initialize(params)
36
+ super(params)
37
+ end
38
+
39
+ # Distributor Type id
40
+ #
41
+ # @return [string]
42
+ def self.type_id
43
+ 'nodes_http_distributor'
44
+ end
45
+
46
+ # generate the pulp config for the nodes distributor
47
+ #
48
+ # @return [Hash]
49
+ def config
50
+ to_ret = as_json
51
+ to_ret.delete('auto_publish')
52
+ to_ret.delete('id')
53
+ to_ret
54
+ end
55
+ end
56
+ end
57
+ end
@@ -36,7 +36,7 @@ module Runcible
36
36
  super(params)
37
37
  end
38
38
 
39
- def type_id
39
+ def self.type_id
40
40
  'puppet_distributor'
41
41
  end
42
42
 
@@ -1,3 +1,3 @@
1
1
  module Runcible
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runcible
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-12 00:00:00.000000000 Z
12
+ date: 2013-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -131,41 +131,42 @@ extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
133
  - lib/runcible.rb
134
- - lib/runcible/instance.rb
135
- - lib/runcible/version.rb
136
134
  - lib/runcible/models/puppet_distributor.rb
137
- - lib/runcible/models/puppet_importer.rb
138
- - lib/runcible/models/iso_distributor.rb
139
- - lib/runcible/models/importer.rb
140
135
  - lib/runcible/models/yum_clone_distributor.rb
141
136
  - lib/runcible/models/distributor.rb
142
137
  - lib/runcible/models/export_distributor.rb
143
- - lib/runcible/models/yum_distributor.rb
138
+ - lib/runcible/models/puppet_importer.rb
144
139
  - lib/runcible/models/iso_importer.rb
140
+ - lib/runcible/models/yum_distributor.rb
141
+ - lib/runcible/models/nodes_http_distributor.rb
142
+ - lib/runcible/models/iso_distributor.rb
145
143
  - lib/runcible/models/yum_importer.rb
146
- - lib/runcible/base.rb
144
+ - lib/runcible/models/importer.rb
145
+ - lib/runcible/extensions/package_category.rb
146
+ - lib/runcible/extensions/errata.rb
147
+ - lib/runcible/extensions/consumer_group.rb
148
+ - lib/runcible/extensions/puppet_module.rb
149
+ - lib/runcible/extensions/consumer.rb
147
150
  - lib/runcible/extensions/repository.rb
148
151
  - lib/runcible/extensions/rpm.rb
149
152
  - lib/runcible/extensions/unit.rb
150
- - lib/runcible/extensions/consumer_group.rb
151
- - lib/runcible/extensions/consumer.rb
152
- - lib/runcible/extensions/distribution.rb
153
153
  - lib/runcible/extensions/package_group.rb
154
- - lib/runcible/extensions/puppet_module.rb
155
- - lib/runcible/extensions/package_category.rb
156
- - lib/runcible/extensions/errata.rb
157
154
  - lib/runcible/extensions/yum_repo_metadata_file.rb
158
- - lib/runcible/resources/repository.rb
159
- - lib/runcible/resources/user.rb
160
- - lib/runcible/resources/unit.rb
161
- - lib/runcible/resources/consumer_group.rb
162
- - lib/runcible/resources/consumer.rb
155
+ - lib/runcible/extensions/distribution.rb
163
156
  - lib/runcible/resources/role.rb
157
+ - lib/runcible/resources/consumer_group.rb
164
158
  - lib/runcible/resources/content.rb
159
+ - lib/runcible/resources/consumer.rb
165
160
  - lib/runcible/resources/repository_schedule.rb
166
- - lib/runcible/resources/repository_group.rb
167
- - lib/runcible/resources/event_notifier.rb
168
161
  - lib/runcible/resources/task.rb
162
+ - lib/runcible/resources/event_notifier.rb
163
+ - lib/runcible/resources/repository.rb
164
+ - lib/runcible/resources/user.rb
165
+ - lib/runcible/resources/unit.rb
166
+ - lib/runcible/resources/repository_group.rb
167
+ - lib/runcible/version.rb
168
+ - lib/runcible/instance.rb
169
+ - lib/runcible/base.rb
169
170
  - LICENSE
170
171
  - Rakefile
171
172
  - Gemfile