rhn_satellite 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a42ab7be6ea1207a68ea1fe4e82f86bf2c830a34
4
- data.tar.gz: da447112d6d5fa2fc63c2cca06ab84c89d9899d2
3
+ metadata.gz: d906a912553c0eabe38d8f9accfb936aaddccdc2
4
+ data.tar.gz: 6a70fc49449cf3c5029537679f2907daa3f456bb
5
5
  SHA512:
6
- metadata.gz: d864e0de2eba9106561752ad6367fdf473ad9a436053e479eb25af00cc9949530dfc8831bfad4fd3c4053e26edaf5e06c096876147c87651775ad8e3df23721c
7
- data.tar.gz: a40b8d97e97cb32a6a863fcb3dfffdb288e32a2b6a30285e9b2a04045b8b0ba4bcee287fbb26db8848b51dfdf499d6175e8d7bcf1c5fb8626f6a4588208295de
6
+ metadata.gz: cb45552977efc27505d2e577837b825a2329c8cd9896d0d4105785232c103ec4232e10e84ec87f092413e3c2c3f9b937ece8281fbd9ad81f71049b4e30e2a447
7
+ data.tar.gz: 5f70407b3d6ab4c7dc1041dbfca5fb64d535d4b81db31f2cab4f4439068bcd1c4245ffda203cc1d35de95200ae0f170a3ef9fad3540cb30af58d31e8b71dd29d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -16,6 +16,7 @@ require 'rhn_satellite/schedule'
16
16
  require 'rhn_satellite/system'
17
17
  require 'rhn_satellite/systemgroup'
18
18
  require 'rhn_satellite/packages'
19
+ require 'rhn_satellite/kickstart'
19
20
 
20
21
  if File.exists?(file=File.expand_path('~/.satellite.yaml')) || File.exists?(file='/etc/satellite.yaml')
21
22
  require 'yaml'
@@ -25,4 +26,5 @@ if File.exists?(file=File.expand_path('~/.satellite.yaml')) || File.exists?(file
25
26
  RhnSatellite::Connection::Handler.default_password = global_options['password']
26
27
  RhnSatellite::Connection::Handler.default_timeout = global_options['timeout']
27
28
  RhnSatellite::Connection::Handler.default_https = global_options['https']
29
+ RhnSatellite::Connection::Handler.default_https_verify = global_options['https_verify']
28
30
  end
@@ -5,16 +5,17 @@ module RhnSatellite
5
5
  include RhnSatellite::Common::Debug
6
6
 
7
7
  class << self
8
- attr_accessor :default_hostname,:default_username, :default_password
8
+ attr_accessor :default_hostname,:default_username, :default_password, :default_https_verify
9
9
  attr_writer :default_timeout, :default_https
10
10
 
11
- def instance_for(identifier,hostname=nil,username=nil,password=nil,timeout=nil,https=nil)
11
+ def instance_for(identifier,hostname=nil,username=nil,password=nil,timeout=nil,https=nil,https_verify=nil)
12
12
  instances[identifier] ||= Handler.new(
13
13
  hostname||default_hostname,
14
14
  username||default_username,
15
15
  password||default_password,
16
16
  timeout || default_timeout,
17
- https.nil? ? default_https : https
17
+ https.nil? ? default_https : https,
18
+ https_verify.nil? ? default_https_verify : https_verify
18
19
  )
19
20
  end
20
21
 
@@ -26,6 +27,10 @@ module RhnSatellite
26
27
  @default_https.nil? ? (@default_https=true) : @default_https
27
28
  end
28
29
 
30
+ def default_https_verify
31
+ @default_https_verify.nil? ? (@default_https_verify=true) : @default_https_verify
32
+ end
33
+
29
34
  def reset_instance(identifier)
30
35
  instances.delete(identifier)
31
36
  end
@@ -44,12 +49,13 @@ module RhnSatellite
44
49
  end
45
50
  end
46
51
 
47
- def initialize(hostname,username=nil,password=nil,timeout=30,https=true)
52
+ def initialize(hostname,username=nil,password=nil,timeout=30,https=true,https_verify=true)
48
53
  @hostname = hostname
49
54
  @username = username
50
55
  @password = password
51
56
  @timeout = timeout
52
57
  @https = https
58
+ @https_verify = https_verify
53
59
  end
54
60
 
55
61
  def login(duration=nil)
@@ -93,6 +99,10 @@ module RhnSatellite
93
99
  def connect
94
100
  debug("Connecting to #{url}")
95
101
  @connection = XMLRPC::Client.new2(url,nil,@timeout)
102
+ if !@https_verify
103
+ @connection.instance_variable_get(:@http).instance_variable_set(:@verify_mode, OpenSSL::SSL::VERIFY_NONE)
104
+ end
105
+ @connection
96
106
  end
97
107
 
98
108
  def disconnect
@@ -0,0 +1,18 @@
1
+ module RhnSatellite
2
+ class Kickstart < RhnSatellite::Connection::Base
3
+ collection 'kickstart.listKickstarts'
4
+ class << self
5
+ def import_raw_file(profile_label, virtualization_type,
6
+ kickstartable_tree_label, kickstart_file_contents)
7
+
8
+ base.default_call('kickstart.importRawFile', profile_label,
9
+ virtualization_type, kickstartable_tree_label,
10
+ kickstart_file_contents)
11
+ end
12
+
13
+ def delete(ks_label)
14
+ base.default_call('kickstart.deleteProfile', ks_label)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: rhn_satellite 0.1.0 ruby lib
5
+ # stub: rhn_satellite 0.1.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "rhn_satellite"
9
- s.version = "0.1.1"
9
+ s.version = "0.1.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["duritong"]
14
- s.date = "2014-06-03"
14
+ s.date = "2015-08-28"
15
15
  s.description = "It provides an easy way to interact with a RedHat Satellite API."
16
16
  s.email = "peter.meier@immerda.ch"
17
17
  s.extra_rdoc_files = [
@@ -38,6 +38,7 @@ Gem::Specification.new do |s|
38
38
  "lib/rhn_satellite/common/misc.rb",
39
39
  "lib/rhn_satellite/connection/base.rb",
40
40
  "lib/rhn_satellite/connection/handler.rb",
41
+ "lib/rhn_satellite/kickstart.rb",
41
42
  "lib/rhn_satellite/packages.rb",
42
43
  "lib/rhn_satellite/schedule.rb",
43
44
  "lib/rhn_satellite/system.rb",
@@ -54,6 +55,7 @@ Gem::Specification.new do |s|
54
55
  "spec/unit/rhn_satellite/common/misc_spec.rb",
55
56
  "spec/unit/rhn_satellite/connection/base_spec.rb",
56
57
  "spec/unit/rhn_satellite/connection/handler_spec.rb",
58
+ "spec/unit/rhn_satellite/kickstart_spec.rb",
57
59
  "spec/unit/rhn_satellite/packages_spec.rb",
58
60
  "spec/unit/rhn_satellite/schedule_spec.rb",
59
61
  "spec/unit/rhn_satellite/system_spec.rb",
@@ -61,7 +63,7 @@ Gem::Specification.new do |s|
61
63
  ]
62
64
  s.homepage = "http://github.com/duritong/ruby-rhn_satellite"
63
65
  s.licenses = ["MIT"]
64
- s.rubygems_version = "2.2.1"
66
+ s.rubygems_version = "2.3.0"
65
67
  s.summary = "RhnSatellite is a ruby api to the RedHat Satellite"
66
68
 
67
69
  if s.respond_to? :specification_version then
@@ -25,6 +25,12 @@ describe RhnSatellite::Connection::Handler do
25
25
  RhnSatellite::Connection::Handler.default_https.should be_true
26
26
  end
27
27
  end
28
+
29
+ describe 'https_verify' do
30
+ it "should default to true" do
31
+ RhnSatellite::Connection::Handler.default_https_verify.should be_true
32
+ end
33
+ end
28
34
  end
29
35
 
30
36
  describe ".instance_for" do
@@ -78,6 +84,14 @@ describe RhnSatellite::Connection::Handler do
78
84
  it "takes passed https setting" do
79
85
  RhnSatellite::Connection::Handler.instance_for(:default_https2,'bla','user2','secret2',30,false).instance_variable_get('@https').should eql(false)
80
86
  end
87
+
88
+ it "defaults https_verify to true" do
89
+ RhnSatellite::Connection::Handler.instance_for(:default_https_verify,'bla','user','secret2').instance_variable_get('@https_verify').should eql(true)
90
+ end
91
+
92
+ it "takes passed https_verify setting" do
93
+ RhnSatellite::Connection::Handler.instance_for(:default_https_verify2,'bla','user2','secret2',30,false,false).instance_variable_get('@https_verify').should eql(false)
94
+ end
81
95
  end
82
96
 
83
97
  describe ".reset" do
@@ -111,6 +125,7 @@ describe RhnSatellite::Connection::Handler do
111
125
 
112
126
  context "connecting" do
113
127
  before :each do
128
+ RhnSatellite::Connection::Handler.reset_instance(:connect)
114
129
  RhnSatellite::Connection::Handler.default_hostname = 'connecttest'
115
130
  end
116
131
  describe "#connect" do
@@ -120,6 +135,21 @@ describe RhnSatellite::Connection::Handler do
120
135
  a = RhnSatellite::Connection::Handler.instance_for(:connect)
121
136
  a.connect
122
137
  end
138
+ context 'when ssl_verify is true' do
139
+ it "uses ssl verification" do
140
+ RhnSatellite::Connection::Handler.default_https_verify = true
141
+ a = RhnSatellite::Connection::Handler.instance_for(:connect)
142
+ a.connect.instance_variable_get(:@http).instance_variable_get(:@verify_mode).should_not eq OpenSSL::SSL::VERIFY_NONE
143
+ end
144
+ end
145
+
146
+ context 'when ssl_verify is false' do
147
+ it "disables ssl verification" do
148
+ RhnSatellite::Connection::Handler.default_https_verify = false
149
+ a = RhnSatellite::Connection::Handler.instance_for(:connect)
150
+ a.connect.instance_variable_get(:@http).instance_variable_get(:@verify_mode).should eq OpenSSL::SSL::VERIFY_NONE
151
+ end
152
+ end
123
153
  end
124
154
 
125
155
  describe "#disconnect" do
@@ -0,0 +1,93 @@
1
+ #! /usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../spec_helper'
3
+
4
+ describe RhnSatellite::Kickstart do
5
+ context "standard invocation" do
6
+ before(:each) do
7
+ #RhnSatellite::Systemgroup.reset
8
+ conn = Object.new
9
+ conn.stubs(:call)
10
+
11
+ XMLRPC::Client.stubs(:new2).returns(conn)
12
+
13
+ RhnSatellite::Kickstart.username = 'user'
14
+ RhnSatellite::Kickstart.password = 'pwd'
15
+ RhnSatellite::Connection::Handler.any_instance.stubs(:make_call).with("auth.login",'user','pwd').returns("token")
16
+ RhnSatellite::Connection::Handler.any_instance.stubs(:make_call).with("auth.logout",'token')
17
+ end
18
+
19
+ describe ".all" do
20
+ it "logins and returns a bunch of systems" do
21
+ RhnSatellite::Connection::Handler.any_instance.expects(:make_call).with('kickstart.listKickstarts',"token").returns(["123","234"])
22
+
23
+ RhnSatellite::Kickstart.all.should eql(["123","234"])
24
+ end
25
+
26
+ it "returns an empty array on an empty answer" do
27
+ RhnSatellite::Connection::Handler.any_instance.expects(:make_call).with('kickstart.listKickstarts',"token").returns(nil)
28
+
29
+ RhnSatellite::Kickstart.all.should eql([])
30
+ end
31
+
32
+ it "iterates the items over the block" do
33
+ RhnSatellite::Connection::Handler.any_instance.expects(:make_call).with('kickstart.listKickstarts',"token").returns(["123","234"])
34
+ RhnSatellite::Kickstart.all{|i| ["123","234"].include?(i).should be_true }.should eql(["123","234"])
35
+ end
36
+ end
37
+
38
+ describe ".get" do
39
+ context "with kickstarts" do
40
+ before :each do
41
+ RhnSatellite::Connection::Handler.any_instance.expects(:make_call).with('kickstart.listKickstarts',"token").returns([{'name' => "123"},{'name' => "234"}])
42
+ end
43
+ it "finds a kickstart in all kickstarts" do
44
+ RhnSatellite::Kickstart.get('123').should eql({'name' => '123'})
45
+ end
46
+
47
+ it "returns nil on an non-existant kickstart" do
48
+ RhnSatellite::Kickstart.get('12333').should eql(nil)
49
+ end
50
+ end
51
+ context "without any kickstarts" do
52
+ before :each do
53
+ RhnSatellite::Connection::Handler.any_instance.expects(:make_call).with('kickstart.listKickstarts',"token").returns([])
54
+ end
55
+ it "returns nil" do
56
+ RhnSatellite::Kickstart.get('12333').should eql(nil)
57
+ end
58
+ end
59
+ end
60
+
61
+ describe ".import_raw_file" do
62
+
63
+ it "imports kickstart file contents" do
64
+ RhnSatellite::Connection::Handler.any_instance.expects(:make_call).with(
65
+ "kickstart.importRawFile",
66
+ "token",
67
+ 'some_label',
68
+ 'none',
69
+ 'tree_label',
70
+ 'ks_content'
71
+ ).returns("1")
72
+
73
+ RhnSatellite::Kickstart.import_raw_file('some_label', 'none', 'tree_label', 'ks_content')
74
+ end
75
+ end
76
+
77
+ describe ".delete" do
78
+ it "logs in and should delete a kickstart label" do
79
+ RhnSatellite::Connection::Handler.any_instance.expects(:make_call).with('kickstart.deleteProfile','token', 'some_label').returns(1)
80
+
81
+ RhnSatellite::Kickstart.delete('some_label').should eql(1)
82
+ end
83
+
84
+ it "returns nothing on an inexistant kickstart label" do
85
+ RhnSatellite::Connection::Handler.any_instance.expects(:make_call).with('kickstart.deleteProfile','token', 'some_missing_label').returns(nil)
86
+
87
+ RhnSatellite::Kickstart.delete('some_missing_label').should eql(nil)
88
+ end
89
+ end
90
+
91
+
92
+ end
93
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhn_satellite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - duritong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-03 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -121,6 +121,7 @@ files:
121
121
  - lib/rhn_satellite/common/misc.rb
122
122
  - lib/rhn_satellite/connection/base.rb
123
123
  - lib/rhn_satellite/connection/handler.rb
124
+ - lib/rhn_satellite/kickstart.rb
124
125
  - lib/rhn_satellite/packages.rb
125
126
  - lib/rhn_satellite/schedule.rb
126
127
  - lib/rhn_satellite/system.rb
@@ -137,6 +138,7 @@ files:
137
138
  - spec/unit/rhn_satellite/common/misc_spec.rb
138
139
  - spec/unit/rhn_satellite/connection/base_spec.rb
139
140
  - spec/unit/rhn_satellite/connection/handler_spec.rb
141
+ - spec/unit/rhn_satellite/kickstart_spec.rb
140
142
  - spec/unit/rhn_satellite/packages_spec.rb
141
143
  - spec/unit/rhn_satellite/schedule_spec.rb
142
144
  - spec/unit/rhn_satellite/system_spec.rb
@@ -161,8 +163,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
163
  version: '0'
162
164
  requirements: []
163
165
  rubyforge_project:
164
- rubygems_version: 2.2.1
166
+ rubygems_version: 2.3.0
165
167
  signing_key:
166
168
  specification_version: 4
167
169
  summary: RhnSatellite is a ruby api to the RedHat Satellite
168
170
  test_files: []
171
+ has_rdoc: