foreman_xen 0.0.1 → 0.0.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: 232755986ea6e3676d1b625ea28273782ae38b83
4
- data.tar.gz: 97ed7ce99f9bdd0acd45e03b00a1cdcb79db18da
3
+ metadata.gz: 0c3b2a37c986005efe387f6931f768f5359ab6e9
4
+ data.tar.gz: bb8daba521e44ab73a7e84585202abee259f823b
5
5
  SHA512:
6
- metadata.gz: 483a76adfad78351fb74bed7c3ab3d1b3ab411407b7a757c24880384d2124f6a47bb429517d2eff5348eca4db0c1ce6c0c992cccc046dac915d4cf6617993025
7
- data.tar.gz: dcadde1db7aa889fdebf2b46db975aa9519f9bfb1ed50bb22882f0b5430cad299db5c37991ee89aa6b19440c51ea27b5b10dd054deee8498bb55ba4cb00566bd
6
+ metadata.gz: f27f16653e04ceb293c3ac3f6fef2a3d727f27297a51fd89c3cf9a11424533e4cab75a4997baef790dd325f7518dae462a088f45063293b7abe6c74585b35fc9
7
+ data.tar.gz: fb4bc0be2fca1262513e4ad9ddd1f70197e709b9c58fc220a986b612372d0ce037a379befc6b95e10bc2058889fe0ff816989101263f955c0d1a3e9f7f167404
data/README.md CHANGED
@@ -14,13 +14,13 @@ The gem name is "foreman_xen".
14
14
 
15
15
  | Foreman Version | Plugin Version |
16
16
  | ---------------:| --------------:|
17
- | >= 1.5 | 0.0.1 |
17
+ | >= 1.5 | 0.0.2 |
18
18
 
19
19
  ## Latest code
20
20
 
21
21
  You can get the develop branch of the plugin by specifying your Gemfile in this way:
22
22
 
23
- gem 'foreman_xen', :git => "https://github.com/ohadlevy/foreman_xen.git"
23
+ gem 'foreman_xen', :git => "https://github.com/theforeman/foreman-xen.git"
24
24
 
25
25
  # Copyright
26
26
 
@@ -282,7 +282,6 @@ module ForemanXen
282
282
  end
283
283
  end
284
284
  out_hash
285
- @key = key
286
285
  end
287
286
  end
288
287
  end
@@ -9,21 +9,28 @@
9
9
  %>
10
10
 
11
11
  <div id='templates' class=''>
12
- <label class="control-label" for="host_compute_attributes_custom_template_name">Custom template</label>
13
12
 
13
+ <div class="form-group">
14
+ <label class="col-md-2 control-label" for="host_compute_attributes_custom_template_name">Custom template</label>
15
+ <div class="col-md-4">
14
16
  <div class="controls">
15
- <select class="input-xlarge" id="host_compute_attributes_custom_template_name" name="host[compute_attributes][custom_template_name]">
17
+ <select class="form-control span2" id="host_compute_attributes_custom_template_name" name="host[compute_attributes][custom_template_name]">
16
18
  <%= options_for_select([[_("No template"), ""]] + compute_resource.custom_templates.map { |t| [t.name, t.name] }, selected_item_c) %>
17
19
  </select>
18
20
  </div>
21
+ </div>
22
+ </div>
19
23
 
20
- <label class="control-label" for="host_compute_attributes_builtin_template_name">Built-in template</label>
21
-
24
+ <div class="form-group ">
25
+ <label class="col-md-2 control-label" for="host_compute_attributes_builtin_template_name">Built-in template</label>
26
+ <div class="col-md-4">
22
27
  <div class="controls">
23
- <select class="input-xlarge" id="host_compute_attributes_builtin_template_name" name="host[compute_attributes][builtin_template_name]">
28
+ <select class="form-control span2" id="host_compute_attributes_builtin_template_name" name="host[compute_attributes][builtin_template_name]">
24
29
  <%= options_for_select([[_("No template"), ""]] + compute_resource.builtin_templates.map { |t| [t.name, t.name] }, selected_item_b) %>
25
30
  </select>
26
31
  </div>
32
+ </div>
33
+ </div>
27
34
 
28
35
  </div>
29
36
 
@@ -30,53 +30,58 @@
30
30
  <div class="children_fields">
31
31
 
32
32
  <div class="fields"/>
33
- <div class="control-group "><label class="control-label" for="xenstore-vm-data-ifs-0-ip">vm-data/ifs/0/ip</label>
34
33
 
34
+ <div class="form-group">
35
+ <label class="col-md-2 control-label" for="xenstore-vm-data-ifs-0-ip">vm-data/ifs/0/ip</label>
36
+ <div class="col-md-4">
35
37
  <div class="controls">
36
- <input <%= disabled %> id="xenstore-vm-data-ifs-0-ip" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][ip]" class="input" value="<%= ip %>">
38
+ <input <%= disabled %> id="xenstore-vm-data-ifs-0-ip" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][ip]" class="form-control input-mini" value="<%= ip %>">
37
39
  </div>
38
40
  </div>
41
+ </div>
39
42
 
40
- <div class="control-group ">
41
- <label class="control-label" for="xenstore-vm-data-ifs-0-gateway">vm-data/ifs/0/gateway</label>
42
-
43
- <div class="controls">
44
- <input <%= disabled %> id="xenstore-vm-data-ifs-0-gateway" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][gateway]" class="input" value="<%= gateway %>">
43
+ <div class="form-group">
44
+ <label class="col-md-2 control-label" for="xenstore-vm-data-ifs-0-gateway">vm-data/ifs/0/gateway</label>
45
+ <div class="col-md-4">
46
+ <div class="controls">
47
+ <input <%= disabled %> id="xenstore-vm-data-ifs-0-gateway" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][gateway]" class="form-control input-mini" value="<%= gateway %>">
45
48
  </div>
46
49
  </div>
50
+ </div>
47
51
 
48
- <div class="control-group ">
49
- <label class="control-label" for="xenstore-vm-data-ifs-0-netmask">vm-data/ifs/0/netmask</label>
50
-
52
+ <div class="form-group">
53
+ <label class="col-md-2 control-label" for="xenstore-vm-data-ifs-0-netmask">vm-data/ifs/0/netmask</label>
54
+ <div class="col-md-4">
51
55
  <div class="controls">
52
- <input <%= disabled %> id="xenstore-vm-data-ifs-0-netmask" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][netmask]" class="input" value="<%= netmask %>">
56
+ <input <%= disabled %> id="xenstore-vm-data-ifs-0-netmask" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][netmask]" class="form-control input-mini" value="<%= netmask %>">
53
57
  </div>
54
58
  </div>
59
+ </div>
55
60
 
56
- <div class="control-group ">
57
- <label class="control-label" for="xenstore-vm-data-nameserver1">vm-data/nameserver1</label>
58
-
59
- <div class="controls">
60
- <input <%= disabled %> id="xenstore-vm-data-nameserver1" type="text" name="host[compute_attributes][xenstore][vm-data][nameserver1]" class="input" value="<%= nameserver1 %>">
61
+ <div class="form-group">
62
+ <label class="col-md-2 control-label" for="xenstore-vm-data-nameserver1">vm-data/nameserver1</label>
63
+ <div class="col-md-4">
64
+ <input <%= disabled %> id="xenstore-vm-data-nameserver1" type="text" name="host[compute_attributes][xenstore][vm-data][nameserver1]" class="form-control input-mini" value="<%= nameserver1 %>">
61
65
  </div>
62
66
  </div>
67
+ </div>
63
68
 
64
- <div class="control-group ">
65
- <label class="control-label" for="xenstore-vm-data-nameserver2">vm-data/nameserver2</label>
66
-
67
- <div class="controls">
68
- <input <%= disabled %> id="xenstore-vm-data-nameserver2" type="text" name="host[compute_attributes][xenstore][vm-data][nameserver2]" class="input" value="<%= nameserver2 %>">
69
+ <div class="form-group">
70
+ <label class="col-md-2 control-label" for="xenstore-vm-data-nameserver2">vm-data/nameserver2</label>
71
+ <div class="col-md-4">
72
+ <input <%= disabled %> id="xenstore-vm-data-nameserver2" type="text" name="host[compute_attributes][xenstore][vm-data][nameserver2]" class="form-control input-mini" value="<%= nameserver2 %>">
69
73
  </div>
70
74
  </div>
75
+ </div>
71
76
 
72
- <div class="control-group ">
73
- <label class="control-label" for="xenstore-vm-data-environment">vm-data/environment</label>
74
-
75
- <div class="controls">
76
- <input <%= disabled %> id="xenstore-vm-data-environment" type="text" name="host[compute_attributes][xenstore][vm-data][environment]" class="input" value="<%= environment %>">
77
+ <div class="form-group">
78
+ <label class="col-md-2 control-label" for="xenstore-vm-data-environment">vm-data/environment</label>
79
+ <div class="col-md-4">
80
+ <input <%= disabled %> id="xenstore-vm-data-environment" type="text" name="host[compute_attributes][xenstore][vm-data][environment]" class="form-control input-mini" value="<%= environment %>">
77
81
  </div>
78
82
  </div>
79
83
 
84
+ </div>
80
85
  </div>
81
86
 
82
87
 
data/lib/foreman_xen.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'foreman_xen/vnc_tunnel'
1
2
  require 'foreman_xen/engine'
2
3
  module ForemanXen
3
4
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanXen
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,90 +1,90 @@
1
- module ForemanXen
2
-
3
- class VNCTunnel
4
- attr_accessor :host, :port
5
-
6
- def initialize(fullURL)
7
- @uri = URI(fullURL)
8
- logger.info(fullURL)
9
- self.host = 'localhost'
10
- s = TCPServer.new('127.0.0.1', 0)
11
- self.port = s.addr[1]
12
- s.close
13
- @read_from_server = true
14
- end
15
-
16
- def start
17
- client_srv = TCPServer.new('127.0.0.1', self.port)
18
- Thread.new do
19
- req = "CONNECT #{@uri.path}?#{@uri.query} HTTP/1.1\r\n\r\n"
20
- @srv_socket = TCPSocket.open(@uri.host, 80)
21
- @srv_socket.print req
22
- header = @srv_socket.readline
23
- if header == "HTTP/1.1 200 OK\r\n"
24
- @srv_socket.each_line do |line|
25
- break if line == "\r\n"
26
- end
27
- listen client_srv
28
- else
29
- logger.error "Cannot connect to the console located at #{uri.to_s} reason: #{header}"
30
- raise "Cannot connect to the console located at #{uri.to_s} reason: #{header}"
31
- end
32
- end
33
- end
1
+ class VNCTunnel
2
+ attr_accessor :host, :port
3
+ @uri = nil
4
+ @srv_socket = nil
5
+ @client_socket = nil
6
+ @read_from_server = nil
7
+ def initialize(fullURL)
8
+ @uri = URI(fullURL)
9
+ logger.info(fullURL)
10
+ self.host = 'localhost'
11
+ s = TCPServer.new("127.0.0.1", 0)
12
+ self.port = s.addr[1]
13
+ s.close
14
+ @read_from_server = true
15
+ end
34
16
 
35
- def logger
36
- Rails.logger
17
+ def start
18
+ client_srv = TCPServer.new("127.0.0.1", self.port)
19
+ thr = Thread.new do
20
+ req = "CONNECT #{@uri.path}?#{@uri.query} HTTP/1.1\r\n\r\n"
21
+ @srv_socket = TCPSocket.open(@uri.host, 80)
22
+ @srv_socket.print req
23
+ header = @srv_socket.readline
24
+ if header == "HTTP/1.1 200 OK\r\n" then
25
+ @srv_socket.each_line do |line|
26
+ break if line == "\r\n"
27
+ end
28
+ listen client_srv
29
+ else
30
+ logger.error "Cannot connect to the conosle located at #{uri.to_s} reason: #{header}"
31
+ raise "Cannot connect to the console located at #{uri.to_s} reason: #{header}"
32
+ end
37
33
  end
34
+ end
38
35
 
39
- private
36
+ def logger
37
+ Rails.logger
38
+ end
40
39
 
41
- def listen(client_srv)
42
- @client_socket = client_srv.accept
43
- logger.debug 'VNCTunnel Client: client accepted'
40
+ private
44
41
 
45
- begin
46
- while true
47
- begin
48
- data = @client_socket.read_nonblock(1024)
49
- break if data == nil
50
- @srv_socket.write(data)
51
- rescue IO::WaitReadable => e
52
- IO.select([@client_socket])
53
- retry
54
- end
42
+ def listen client_srv
43
+ @client_socket = client_srv.accept
44
+ logger.debug "VNCTunnel Client: client accepted"
45
+ server_listen_thr = Thread.new do
46
+ listen_from_server
47
+ end
48
+ begin
49
+ while true
50
+ begin
51
+ data = @client_socket.read_nonblock(1024)
52
+ break if data == nil
53
+ @srv_socket.write(data)
54
+ rescue IO::WaitReadable => e
55
+ IO.select([@client_socket])
56
+ retry
55
57
  end
56
- rescue EOFError
57
- # ignored
58
- rescue Exception => e
59
- logger.error "VNCTunnel Client: unexpected exception #{e}"
60
- ensure
61
- @read_from_server = false
62
- @client_socket.close
63
- @srv_socket.close
64
58
  end
65
- logger.debug 'VNCTunnel Client is stopping'
59
+ rescue EOFError
60
+ rescue Exception => e
61
+ logger.error "VNCTunnel Client: unexpected exception #{e}"
62
+ ensure
63
+ @read_from_server = false
64
+ @client_socket.close
65
+ @srv_socket.close
66
66
  end
67
+ logger.debug "VNCTunnel Client is stopping"
68
+ end
67
69
 
68
- def listen_from_server
69
- logger.debug 'VNCTunnel Server is listening'
70
- begin
71
- while @read_from_server do
72
- begin
73
- data = @srv_socket.read_nonblock(1024)
74
- @client_socket.write(data)
75
- rescue IO::WaitReadable => e
76
- if IO.select([@srv_socket], nil, nil, 60) != nil
77
- retry
78
- end
70
+ def listen_from_server
71
+ logger.debug "VNCTunnel Server is listening"
72
+ begin
73
+ while @read_from_server do
74
+ begin
75
+ data = @srv_socket.read_nonblock(1024)
76
+ @client_socket.write(data)
77
+ rescue IO::WaitReadable => e
78
+ if IO.select([@srv_socket], nil, nil, 60) != nil then
79
+ retry
79
80
  end
80
81
  end
81
- rescue EOFError
82
- # ignored
83
- rescue Exception => e
84
- logger.error "VNCTunnel Server: unexpected exception #{e}"
85
82
  end
86
- logger.debug('VNCTunnel Server is stopping')
87
- end
88
-
83
+ rescue EOFError
84
+ rescue Exception => e
85
+ logger.error "VNCTunnel Server: unexpected exception #{e}"
86
+ end
87
+ logger.debug("VNCTunnel Server is stopping")
89
88
  end
90
- end
89
+
90
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_xen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
- - Michał Piotrowski
7
+ - Pavel Nemirovsky, Michał Piotrowski, Avi Israeli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-28 00:00:00.000000000 Z
11
+ date: 2014-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -40,7 +40,7 @@ dependencies:
40
40
  version: '0'
41
41
  description: Provision and manage XEN Server from Foreman.
42
42
  email:
43
- - michal.piotrowski@erlang-solutions.com
43
+ - operations@oovoo.com
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
@@ -87,10 +87,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.2.2
90
+ rubygems_version: 2.2.1
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Provision and manage XEN Server from Foreman
94
94
  test_files:
95
- - test/test_helper.rb
96
95
  - test/foreman_xen_test.rb
96
+ - test/test_helper.rb