sfcc 0.1.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,17 +4,11 @@
4
4
 
5
5
  #include <assert.h>
6
6
 
7
- /*
8
7
  #include <cimc/cimc.h>
9
8
  #include <cimc/cimcdt.h>
10
9
  #include <cimc/cimcft.h>
11
- */
12
- #include <CimClientLib/cmci.h>
13
- #include <CimClientLib/cmcidt.h>
14
- #include <CimClientLib/cmcift.h>
15
- #include <CimClientLib/native.h>
16
10
  #include <CimClientLib/cmcimacs.h>
17
-
11
+
18
12
  #include "ruby.h"
19
13
 
20
14
  #include <ruby.h>
@@ -27,34 +21,10 @@
27
21
  #include <unistd.h>
28
22
  #include <stdlib.h>
29
23
 
24
+ extern const char *to_charptr(VALUE v);
30
25
  extern VALUE mSfcc;
31
26
  extern VALUE mSfccCim;
32
-
33
- /*
34
- #define SFCC_DEC_REFCOUNT(x) \
35
- do { \
36
- int refc = ((CIMCObject*)x)->refCount; \
37
- printf("dec X: %d rf: %d\n", (int)x, refc); \
38
- --((CIMCObject*)x)->refCount; \
39
- if (refc <= 0) \
40
- x->ft->release(x); \
41
- free(x); \
42
- } while (0);
43
- */
44
-
45
- #define SFCC_DEC_REFCOUNT(x) \
46
- x->ft->release(x);
47
-
48
- /*
49
- #define SFCC_INC_REFCOUNT(x) \
50
- do { \
51
- int refc = ((CIMCObject*)x)->refCount; \
52
- printf("inc X: %d rf: %d\n", (int) x, refc); \
53
- ++((CIMCObject*)x)->refCount; \
54
- } while (0);
55
- */
56
-
57
- #define SFCC_INC_REFCOUNT(x) (void)(0);
27
+ extern CIMCEnv *cimcEnv;
58
28
 
59
29
  #define CIMSTR_2_RUBYSTR(x) (x ? (x->ft->getCharPtr(x, NULL) ? rb_str_new2(x->ft->getCharPtr(x, NULL)) : Qnil) : Qnil)
60
30
 
@@ -62,7 +32,7 @@ extern VALUE mSfccCim;
62
32
  * raises a ruby exception if the status is an error
63
33
  * whenever possible, adds the custom message if not null
64
34
  */
65
- void sfcc_rb_raise_if_error(CMPIStatus status, const char *msg, ...);
35
+ void sfcc_rb_raise_if_error(CIMCStatus status, const char *msg, ...);
66
36
 
67
37
  /**
68
38
  * allocates a string array where each string points to the
@@ -73,24 +43,29 @@ void sfcc_rb_raise_if_error(CMPIStatus status, const char *msg, ...);
73
43
  */
74
44
  inline char ** sfcc_value_array_to_string_array(VALUE array);
75
45
 
46
+ /**
47
+ * converts a CIMCArray to rbArray
48
+ */
49
+ inline VALUE sfcc_cimcarray_to_rubyarray(CIMCArray *array);
50
+
76
51
  /**
77
52
  * converts a ruby hash to a CIM args object
78
53
  */
79
- inline CMPIArgs* sfcc_hash_to_cimargs(VALUE hash);
54
+ inline CIMCArgs* sfcc_hash_to_cimargs(VALUE hash);
80
55
 
81
56
  /**
82
57
  * converts a CIM args object to a hash
83
58
  */
84
- inline VALUE sfcc_cimargs_to_hash(CMPIArgs *args);
59
+ inline VALUE sfcc_cimargs_to_hash(CIMCArgs *args);
85
60
 
86
61
  /**
87
- * converts CMPIData to ruby VALUE
62
+ * converts CIMCData to ruby VALUE
88
63
  */
89
- inline VALUE sfcc_cimdata_to_value(CMPIData data);
64
+ inline VALUE sfcc_cimdata_to_value(CIMCData data);
90
65
 
91
66
  /**
92
- * convert ruby VALUE to CMPIData
67
+ * convert ruby VALUE to CIMCData
93
68
  */
94
- inline CMPIData sfcc_value_to_cimdata(VALUE value);
69
+ inline CIMCData sfcc_value_to_cimdata(VALUE value);
95
70
 
96
71
  #endif
@@ -57,19 +57,43 @@ module Sfcc
57
57
  class ErrorRcError < RuntimeError; end
58
58
 
59
59
  class Client
60
+ private
61
+ def self.uri_to_params(uri, params)
62
+ params[:host] ||= uri.host
63
+ params[:scheme] ||= uri.scheme
64
+ params[:port] ||= uri.port
65
+ params[:user] ||= uri.user
66
+ params[:password] ||= uri.password
67
+ end
68
+ public
60
69
  # Client.connect(:host => "localhost",
61
70
  # :scheme => "http",
62
71
  # :port => 5988,
63
72
  # :user => "root",
64
- # :password => "foo") do |client|
73
+ # :password => "foo"
74
+ # :verify => true,
75
+ # :trust_store => "/path/to/trust/store",
76
+ # :cert_file => "/path/to/cert_file",
77
+ # :key_file => "/path/to/key_file") do |client|
65
78
  # # do something with client
66
79
  # end
67
80
  #
68
- # client is both returned and passed to the given block.
81
+ # client is both returned and passed to a given block.
82
+ #
83
+ # :verify, :trust_store, :cert_file, and :key_file are only evaluated
84
+ # if :scheme is 'https' and verify != false
85
+ #
86
+ # If :verify=>false, :trust_store, :cert_file and :key_file are unused
87
+ # If :verify is ommitted, it defaults to true
69
88
  #
70
89
  # Alternatively you can pass a uri:
71
90
  #
72
- # client = Client.connect(uri)
91
+ # client = Client.connect(uri)
92
+ #
93
+ # or a mix like
94
+ #
95
+ # client = Client.connect(:uri => uri, :verify => false)
96
+ # Explicit parameters (like :user) always override :uri data
73
97
  #
74
98
  def self.connect(args={})
75
99
  params = {}
@@ -77,21 +101,46 @@ module Sfcc
77
101
  case args
78
102
  when Hash
79
103
  params.merge!(args)
80
- when String
81
- uri = URI.parse(arg)
104
+ uri = params[:uri]
105
+ case uri
106
+ when URI
107
+ self.uri_to_params(uri, params)
108
+ else
109
+ self.uri_to_params(URI.parse(uri.to_s), params)
110
+ end
111
+ when ::String
112
+ uri = URI.parse(args)
113
+ return Client.connect uri
82
114
  when URI
83
- params[:host] = uri.host
84
- params[:scheme] = uri.scheme
85
- params[:port] = uri.port
86
- params[:user] = uri.user
87
- params[:password] = uri.password
115
+ self.uri_to_params(args, params)
116
+ else
117
+ raise "Bad argument #{args.inspect}:#{args.class}"
118
+ end
119
+
120
+ verify = params[:verify]
121
+ trust_store = params[:trust_store]
122
+ cert_file = params[:cert_file]
123
+ key_file = params[:key_file]
124
+
125
+ case params[:scheme]
126
+ when "http"
127
+ when "https"
128
+ unless verify == false
129
+ raise "Must either specify :verify=>false or :cert_file for https URLs."
130
+ end
131
+ else
132
+ raise "Unsupported connection scheme #{scheme.inspect}"
88
133
  end
89
134
 
90
135
  native_connect(params[:host],
91
136
  params[:scheme],
92
- params[:port],
137
+ params[:port].to_s,
93
138
  params[:user],
94
- params[:password]);
139
+ params[:password],
140
+ verify,
141
+ trust_store,
142
+ cert_file,
143
+ key_file)
95
144
  end
96
145
  end
97
146
 
@@ -126,6 +175,10 @@ module Sfcc
126
175
  end
127
176
 
128
177
  class Instance
178
+ def classname
179
+ self.object_path.classname
180
+ end
181
+
129
182
  # properties => Hash
130
183
  #
131
184
  # return a hash with all properties
@@ -158,9 +211,19 @@ module Sfcc
158
211
  def to_s
159
212
  object_path.to_s
160
213
  end
214
+
215
+ def method_missing name, *args
216
+ self.property name
217
+ end
161
218
  end
162
219
 
163
220
  class ObjectPath
221
+ def [] name
222
+ self.key(name)
223
+ end
224
+ def method_missing name, *args
225
+ self[name]
226
+ end
164
227
  end
165
228
 
166
229
  class Enumeration
@@ -1,3 +1,3 @@
1
1
  module Sfcc
2
- VERSION = "0.1.2"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,140 +1,113 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sfcc
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 2
9
- version: 0.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Duncan Mac-Vicar
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-08-19 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-05-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rake-compiler
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &8018900 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
31
22
  type: :development
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: mocha
35
23
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *8018900
25
+ - !ruby/object:Gem::Dependency
26
+ name: mocha
27
+ requirement: &8018380 !ruby/object:Gem::Requirement
37
28
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- - 9
44
- version: "0.9"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
45
33
  type: :development
46
- version_requirements: *id002
47
- - !ruby/object:Gem::Dependency
48
- name: yard
49
34
  prerelease: false
50
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *8018380
36
+ - !ruby/object:Gem::Dependency
37
+ name: yard
38
+ requirement: &8017880 !ruby/object:Gem::Requirement
51
39
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- - 5
58
- version: "0.5"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0.5'
59
44
  type: :development
60
- version_requirements: *id003
61
- - !ruby/object:Gem::Dependency
62
- name: shoulda
63
45
  prerelease: false
64
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *8017880
47
+ - !ruby/object:Gem::Dependency
48
+ name: shoulda
49
+ requirement: &8017380 !ruby/object:Gem::Requirement
65
50
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
72
55
  type: :development
73
- version_requirements: *id004
74
- description: ruby-sfcc allows to access a CIMOM either with the WBEM protocol or by using the SfcbLocal interface provided by the sblim-sfcb CIMOM implementation from the sblim project.
75
- email:
56
+ prerelease: false
57
+ version_requirements: *8017380
58
+ description: ruby-sfcc allows to access a CIMOM either with the WBEM protocol or by
59
+ using the SfcbLocal interface provided by the sblim-sfcb CIMOM implementation from
60
+ the sblim project.
61
+ email:
76
62
  - dmacvicar@suse.de
77
63
  executables: []
78
-
79
- extensions: []
80
-
64
+ extensions:
65
+ - ext/sfcc/extconf.rb
81
66
  extra_rdoc_files: []
82
-
83
- files:
84
- - lib/sfcc.rb
67
+ files:
85
68
  - lib/sfcc/version.rb
69
+ - lib/sfcc.rb
86
70
  - ext/sfcc/extconf.rb
87
- - ext/sfcc/cim_client.h
88
- - ext/sfcc/cim_object_path.h
89
- - ext/sfcc/cim_instance.h
90
71
  - ext/sfcc/cim_enumeration.h
72
+ - ext/sfcc/cim_string.h
91
73
  - ext/sfcc/sfcc.h
74
+ - ext/sfcc/cim_object_path.h
92
75
  - ext/sfcc/cim_class.h
93
- - ext/sfcc/cim_string.h
94
- - ext/sfcc/cim_enumeration.c
76
+ - ext/sfcc/cim_client.h
77
+ - ext/sfcc/cim_instance.h
95
78
  - ext/sfcc/cim_client.c
79
+ - ext/sfcc/sfcc.c
80
+ - ext/sfcc/cim_enumeration.c
96
81
  - ext/sfcc/cim_object_path.c
82
+ - ext/sfcc/cim_class.c
97
83
  - ext/sfcc/cim_string.c
98
84
  - ext/sfcc/cim_instance.c
99
- - ext/sfcc/sfcc.c
100
- - ext/sfcc/cim_class.c
101
85
  - CHANGELOG.rdoc
102
86
  - README.rdoc
103
- has_rdoc: true
104
87
  homepage: http://www.github.com/dmacvicar/ruby-sfcc
105
88
  licenses: []
106
-
107
- post_install_message: " ____\n\
108
- /@ ~-.\n\
109
- / __ .- | remember to have fun! \n // // @ \n\n"
89
+ post_install_message: ! " ____\n/@ ~-.\n/ __ .- | remember to have fun! \n //
90
+ // @ \n\n"
110
91
  rdoc_options: []
111
-
112
- require_paths:
92
+ require_paths:
113
93
  - lib
114
- required_ruby_version: !ruby/object:Gem::Requirement
94
+ required_ruby_version: !ruby/object:Gem::Requirement
115
95
  none: false
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- segments:
120
- - 0
121
- version: "0"
122
- required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
101
  none: false
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- segments:
128
- - 1
129
- - 3
130
- - 6
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
131
105
  version: 1.3.6
132
106
  requirements: []
133
-
134
107
  rubyforge_project:
135
- rubygems_version: 1.3.7
108
+ rubygems_version: 1.8.11
136
109
  signing_key:
137
110
  specification_version: 3
138
111
  summary: WBEM client for ruby based on the sblim-sfcc library
139
112
  test_files: []
140
-
113
+ has_rdoc: