networkmanager-dbus 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/Guardfile +5 -1
  2. data/README.md +20 -2
  3. data/Rakefile +13 -1
  4. data/TODO.md +3 -3
  5. data/examples/change_ip.rb +17 -0
  6. data/examples/connectivity.rb +1 -1
  7. data/lib/dbus_interface.rb +14 -5
  8. data/lib/dbus_interface/class.rb +28 -4
  9. data/lib/dbus_interface/connection.rb +58 -0
  10. data/lib/dbus_interface/object.rb +15 -7
  11. data/lib/network_manager.rb +3 -2
  12. data/lib/network_manager/dbus.rb +2 -0
  13. data/lib/network_manager/dbus/device.rb +9 -7
  14. data/lib/network_manager/dbus/root.rb +8 -4
  15. data/lib/network_manager/dbus/settings.rb +18 -5
  16. data/lib/network_manager/dbus/settings_connection.rb +86 -0
  17. data/lib/network_manager/ip4_config.rb +33 -0
  18. data/lib/network_manager/version.rb +1 -1
  19. data/lib/networkmanager-dbus.rb +1 -1
  20. data/networkmanager-dbus.gemspec +4 -0
  21. data/script/console +7 -0
  22. data/script/spec_server +1 -0
  23. data/spec/fixtures/active_connections.yml +10 -0
  24. data/spec/fixtures/devices.yml +18 -37
  25. data/spec/fixtures/dhcp4_configs.yml +17 -0
  26. data/spec/fixtures/ip4_configs.yml +7 -0
  27. data/spec/fixtures/settings.yml +4 -14
  28. data/spec/fixtures/settings_connections.yml +10 -0
  29. data/spec/lib/dbus_interface/class_spec.rb +31 -0
  30. data/spec/lib/dbus_interface/object_spec.rb +32 -0
  31. data/spec/{network_manager → lib/network_manager}/dbus/active_connection_spec.rb +6 -6
  32. data/spec/lib/network_manager/dbus/device_spec.rb +58 -0
  33. data/spec/lib/network_manager/dbus/dhcp4_config_spec.rb +19 -0
  34. data/spec/lib/network_manager/dbus/ethernet_device_spec.rb +14 -0
  35. data/spec/lib/network_manager/dbus/ip4_config_spec.rb +19 -0
  36. data/spec/lib/network_manager/dbus/root_spec.rb +38 -0
  37. data/spec/lib/network_manager/dbus/settings_connection_spec.rb +69 -0
  38. data/spec/lib/network_manager/dbus/settings_spec.rb +53 -0
  39. data/spec/lib/network_manager/ip4_config_spec.rb +27 -0
  40. data/spec/{network_manager_spec.rb → lib/network_manager_spec.rb} +2 -0
  41. data/spec/mocks/dbus/ethernet_device_mock.rb +5 -0
  42. data/spec/mocks/dbus/root_mock.rb +14 -0
  43. data/spec/mocks/dbus/settings_connection_mock.rb +21 -0
  44. data/spec/mocks/dbus/settings_mock.rb +9 -0
  45. data/spec/mocks/dbus_mock.rb +33 -0
  46. data/spec/mocks/init.rb +18 -0
  47. data/spec/mocks/system_bus_mock.rb +5 -0
  48. data/spec/mocks/system_bus_service_mock.rb +9 -0
  49. data/spec/spec_helper.rb +22 -3
  50. data/spec/support/fixture_helper.rb +21 -4
  51. metadata +96 -28
  52. data/lib/network_manager/ip4_helper.rb +0 -14
  53. data/spec/network_manager/dbus/device_spec.rb +0 -36
  54. data/spec/network_manager/dbus/dhcp4_config_spec.rb +0 -14
  55. data/spec/network_manager/dbus/ethernet_device_spec.rb +0 -21
  56. data/spec/network_manager/dbus/ip4_config_spec.rb +0 -14
  57. data/spec/network_manager/dbus/root_spec.rb +0 -22
  58. data/spec/network_manager/dbus/settings_connection_spec.rb +0 -13
  59. data/spec/network_manager/dbus/settings_spec.rb +0 -30
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: networkmanager-dbus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-01 00:00:00.000000000Z
12
+ date: 2011-11-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70103547674940 !ruby/object:Gem::Requirement
16
+ requirement: &70163607162400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,32 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70103547674940
24
+ version_requirements: *70163607162400
25
+ - !ruby/object:Gem::Dependency
26
+ name: pry
27
+ requirement: &70163607161840 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70163607161840
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: rspec
27
- requirement: &70103547663160 !ruby/object:Gem::Requirement
38
+ requirement: &70163607161160 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70163607161160
47
+ - !ruby/object:Gem::Dependency
48
+ name: rr
49
+ requirement: &70163607160480 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ! '>='
@@ -32,10 +54,10 @@ dependencies:
32
54
  version: '0'
33
55
  type: :development
34
56
  prerelease: false
35
- version_requirements: *70103547663160
57
+ version_requirements: *70163607160480
36
58
  - !ruby/object:Gem::Dependency
37
59
  name: guard
38
- requirement: &70103547662100 !ruby/object:Gem::Requirement
60
+ requirement: &70163607159920 !ruby/object:Gem::Requirement
39
61
  none: false
40
62
  requirements:
41
63
  - - ! '>='
@@ -43,10 +65,10 @@ dependencies:
43
65
  version: '0'
44
66
  type: :development
45
67
  prerelease: false
46
- version_requirements: *70103547662100
68
+ version_requirements: *70163607159920
47
69
  - !ruby/object:Gem::Dependency
48
70
  name: guard-shell
49
- requirement: &70103547660880 !ruby/object:Gem::Requirement
71
+ requirement: &70163607159320 !ruby/object:Gem::Requirement
50
72
  none: false
51
73
  requirements:
52
74
  - - ! '>='
@@ -54,10 +76,21 @@ dependencies:
54
76
  version: '0'
55
77
  type: :development
56
78
  prerelease: false
57
- version_requirements: *70103547660880
79
+ version_requirements: *70163607159320
80
+ - !ruby/object:Gem::Dependency
81
+ name: growl-rspec
82
+ requirement: &70163607158700 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70163607158700
58
91
  - !ruby/object:Gem::Dependency
59
92
  name: growl
60
- requirement: &70103547659060 !ruby/object:Gem::Requirement
93
+ requirement: &70163607158120 !ruby/object:Gem::Requirement
61
94
  none: false
62
95
  requirements:
63
96
  - - ! '>='
@@ -65,10 +98,10 @@ dependencies:
65
98
  version: '0'
66
99
  type: :development
67
100
  prerelease: false
68
- version_requirements: *70103547659060
101
+ version_requirements: *70163607158120
69
102
  - !ruby/object:Gem::Dependency
70
103
  name: json
71
- requirement: &70103547657180 !ruby/object:Gem::Requirement
104
+ requirement: &70163607157340 !ruby/object:Gem::Requirement
72
105
  none: false
73
106
  requirements:
74
107
  - - ! '>='
@@ -76,10 +109,10 @@ dependencies:
76
109
  version: '0'
77
110
  type: :development
78
111
  prerelease: false
79
- version_requirements: *70103547657180
112
+ version_requirements: *70163607157340
80
113
  - !ruby/object:Gem::Dependency
81
114
  name: marilyn-rpc
82
- requirement: &70103547656600 !ruby/object:Gem::Requirement
115
+ requirement: &70163607156680 !ruby/object:Gem::Requirement
83
116
  none: false
84
117
  requirements:
85
118
  - - ! '>='
@@ -87,10 +120,21 @@ dependencies:
87
120
  version: '0'
88
121
  type: :development
89
122
  prerelease: false
90
- version_requirements: *70103547656600
123
+ version_requirements: *70163607156680
124
+ - !ruby/object:Gem::Dependency
125
+ name: ipaddress
126
+ requirement: &70163607156120 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: *70163607156120
91
135
  - !ruby/object:Gem::Dependency
92
136
  name: ruby-dbus
93
- requirement: &70103547656060 !ruby/object:Gem::Requirement
137
+ requirement: &70163607155460 !ruby/object:Gem::Requirement
94
138
  none: false
95
139
  requirements:
96
140
  - - ! '>='
@@ -98,7 +142,7 @@ dependencies:
98
142
  version: '0'
99
143
  type: :runtime
100
144
  prerelease: false
101
- version_requirements: *70103547656060
145
+ version_requirements: *70163607155460
102
146
  description: Utilizing the official NetworkManager DBus API
103
147
  email:
104
148
  - whiterabbit.init@gmail.com
@@ -114,10 +158,12 @@ files:
114
158
  - README.md
115
159
  - Rakefile
116
160
  - TODO.md
161
+ - examples/change_ip.rb
117
162
  - examples/connectivity.rb
118
163
  - examples/list_ips.rb
119
164
  - lib/dbus_interface.rb
120
165
  - lib/dbus_interface/class.rb
166
+ - lib/dbus_interface/connection.rb
121
167
  - lib/dbus_interface/object.rb
122
168
  - lib/network_manager.rb
123
169
  - lib/network_manager/dbus.rb
@@ -129,23 +175,39 @@ files:
129
175
  - lib/network_manager/dbus/root.rb
130
176
  - lib/network_manager/dbus/settings.rb
131
177
  - lib/network_manager/dbus/settings_connection.rb
132
- - lib/network_manager/ip4_helper.rb
178
+ - lib/network_manager/ip4_config.rb
133
179
  - lib/network_manager/version.rb
134
180
  - lib/networkmanager-dbus.rb
135
181
  - networkmanager-dbus.gemspec
182
+ - script/console
136
183
  - script/spec_client
137
184
  - script/spec_server
185
+ - spec/fixtures/active_connections.yml
138
186
  - spec/fixtures/devices.yml
187
+ - spec/fixtures/dhcp4_configs.yml
188
+ - spec/fixtures/ip4_configs.yml
139
189
  - spec/fixtures/settings.yml
140
- - spec/network_manager/dbus/active_connection_spec.rb
141
- - spec/network_manager/dbus/device_spec.rb
142
- - spec/network_manager/dbus/dhcp4_config_spec.rb
143
- - spec/network_manager/dbus/ethernet_device_spec.rb
144
- - spec/network_manager/dbus/ip4_config_spec.rb
145
- - spec/network_manager/dbus/root_spec.rb
146
- - spec/network_manager/dbus/settings_connection_spec.rb
147
- - spec/network_manager/dbus/settings_spec.rb
148
- - spec/network_manager_spec.rb
190
+ - spec/fixtures/settings_connections.yml
191
+ - spec/lib/dbus_interface/class_spec.rb
192
+ - spec/lib/dbus_interface/object_spec.rb
193
+ - spec/lib/network_manager/dbus/active_connection_spec.rb
194
+ - spec/lib/network_manager/dbus/device_spec.rb
195
+ - spec/lib/network_manager/dbus/dhcp4_config_spec.rb
196
+ - spec/lib/network_manager/dbus/ethernet_device_spec.rb
197
+ - spec/lib/network_manager/dbus/ip4_config_spec.rb
198
+ - spec/lib/network_manager/dbus/root_spec.rb
199
+ - spec/lib/network_manager/dbus/settings_connection_spec.rb
200
+ - spec/lib/network_manager/dbus/settings_spec.rb
201
+ - spec/lib/network_manager/ip4_config_spec.rb
202
+ - spec/lib/network_manager_spec.rb
203
+ - spec/mocks/dbus/ethernet_device_mock.rb
204
+ - spec/mocks/dbus/root_mock.rb
205
+ - spec/mocks/dbus/settings_connection_mock.rb
206
+ - spec/mocks/dbus/settings_mock.rb
207
+ - spec/mocks/dbus_mock.rb
208
+ - spec/mocks/init.rb
209
+ - spec/mocks/system_bus_mock.rb
210
+ - spec/mocks/system_bus_service_mock.rb
149
211
  - spec/spec_helper.rb
150
212
  - spec/support/fixture_helper.rb
151
213
  homepage: ''
@@ -160,12 +222,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
222
  - - ! '>='
161
223
  - !ruby/object:Gem::Version
162
224
  version: '0'
225
+ segments:
226
+ - 0
227
+ hash: 2644458213369562415
163
228
  required_rubygems_version: !ruby/object:Gem::Requirement
164
229
  none: false
165
230
  requirements:
166
231
  - - ! '>='
167
232
  - !ruby/object:Gem::Version
168
233
  version: '0'
234
+ segments:
235
+ - 0
236
+ hash: 2644458213369562415
169
237
  requirements: []
170
238
  rubyforge_project: networkmanager-dbus
171
239
  rubygems_version: 1.8.10
@@ -1,14 +0,0 @@
1
- module NetworkManager::Ip4Helper
2
- def self.ip4_integer_to_dot_decimal(ip4_integer)
3
- integer = ip4_integer
4
- result = []
5
- 4.times.map do
6
- # bitwise AND 255 bits
7
- result.push integer & 255
8
-
9
- # bitwise SHIFT RIGHT 8 bits
10
- integer = integer >> 8
11
- end
12
- result.join '.'
13
- end
14
- end
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "NetworkManager::DBus::Device" do
4
- before :each do
5
- @devices = fixture('devices.yml')
6
- @list = NetworkManager::DBus::Root.devices
7
- end
8
-
9
- it "should list poperties" do
10
- # simple test
11
- @list.first.properties['Interface'].should ==
12
- @devices[0]['properties']['Interface']
13
-
14
- # total comparison
15
- @list.first.properties.should ==
16
- @devices[0]['properties']
17
- end
18
-
19
- describe "NM_DEVICE_TYPE" do
20
- it "should detect ethernet devices" do
21
- @list.first.ethernet?.should == true
22
- @list.first.ethernet.class.should ==
23
- NetworkManager::DBus::EthernetDevice
24
- end
25
- end
26
-
27
- it 'should provide ip4_config' do
28
- @list.first.ip4_config.class.should ==
29
- NetworkManager::DBus::Ip4Config
30
- end
31
-
32
- it 'should provide active_connection' do
33
- @list.first.active_connection.class.should ==
34
- NetworkManager::DBus::ActiveConnection
35
- end
36
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "NetworkManager::DBus::Dhcp4Config" do
4
- before :each do
5
- @devices = fixture('devices.yml')
6
- @device = @devices[0]
7
- @config = @device['dhcp4_config']
8
- end
9
-
10
- it 'shoud list properties' do
11
- config = NetworkManager::DBus::Dhcp4Config.new @device['properties']['Dhcp4Config']
12
- config.properties.should == @config['properties']
13
- end
14
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "NetworkManager::DBus::EthernetDevice" do
4
- before :each do
5
- @devices = fixture('devices.yml')
6
- @device = @devices[0]
7
- @ethernet_device = @device['ethernet']
8
- end
9
-
10
- it "should list poperties" do
11
- object_path = NetworkManager::DBus::Root.devices.first.object_path
12
- ethernet_device = NetworkManager::DBus::EthernetDevice.new object_path
13
-
14
- # simple test
15
- ethernet_device.properties['HwAddress'].should ==
16
- @ethernet_device['properties']['HwAddress']
17
-
18
- # total comparison
19
- ethernet_device.properties.should == @ethernet_device['properties']
20
- end
21
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "NetworkManager::DBus::Ip4Config" do
4
- before :each do
5
- @devices = fixture('devices.yml')
6
- @device = @devices[0]
7
- @config = @device['ip4_config'][0]
8
- end
9
-
10
- it 'shoud list properties' do
11
- config = NetworkManager::DBus::Ip4Config.new @device['properties']['Ip4Config']
12
- config.properties.should == @config['properties']
13
- end
14
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "NetworkManager::DBus::Root" do
4
- before :each do
5
- @devices = fixture('devices.yml')
6
- end
7
-
8
- it "should list devices" do
9
- list = NetworkManager::DBus::Root.devices
10
- list.size.should > 0
11
- list.first.class.should == NetworkManager::DBus::Device
12
- end
13
-
14
- it "should return device_by_interface" do
15
- dev = NetworkManager::DBus::Root.device_by_interface 'eth0'
16
- dev.properties.should == @devices[0]['properties']
17
- end
18
-
19
- it 'should tell about internet_connection?' do
20
- NetworkManager::DBus::Root.internet_connection?.should be_true
21
- end
22
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "NetworkManager::DBus::SettingsConnection" do
4
- before :each do
5
- @settings = fixture('settings.yml')
6
- @connection = @settings['connections'][0]
7
- end
8
-
9
- it "should get settings" do
10
- NetworkManager::DBus::Settings.connections.first.object.GetSettings.first['connection']['id'].should ==
11
- @connection['settings']['connection']['id']
12
- end
13
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "NetworkManager::DBus::Settings" do
4
- before :each do
5
- @settings = fixture('settings.yml')
6
- end
7
-
8
- it "should provide properties" do
9
- NetworkManager::DBus::Settings.instance.properties.should == @settings['properties']
10
- end
11
-
12
- it "should list connections" do
13
- NetworkManager::DBus::Settings.connections.size.should == 3
14
- end
15
-
16
- describe 'hostname' do
17
- after :each do
18
- NetworkManager::DBus::Settings.instance.hostname = @settings['properties']['Hostname']
19
- end
20
-
21
- it 'should get hostname' do
22
- NetworkManager::DBus::Settings.instance.hostname.should == @settings['properties']['Hostname']
23
- end
24
-
25
- it 'should set hostname' do
26
- NetworkManager::DBus::Settings.instance.hostname = 'a-host-name'
27
- NetworkManager::DBus::Settings.instance.hostname.should == 'a-host-name'
28
- end
29
- end
30
- end