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 +4 -4
- data/README.md +2 -2
- data/app/models/foreman_xen/xenserver.rb +0 -1
- data/app/views/compute_resources_vms/form/_templates.html.erb +12 -5
- data/app/views/compute_resources_vms/form/_xenstore.html.erb +31 -26
- data/lib/foreman_xen.rb +1 -0
- data/lib/foreman_xen/version.rb +1 -1
- data/lib/foreman_xen/vnc_tunnel.rb +77 -77
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c3b2a37c986005efe387f6931f768f5359ab6e9
|
4
|
+
data.tar.gz: bb8daba521e44ab73a7e84585202abee259f823b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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/
|
23
|
+
gem 'foreman_xen', :git => "https://github.com/theforeman/foreman-xen.git"
|
24
24
|
|
25
25
|
# Copyright
|
26
26
|
|
@@ -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="
|
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
|
-
<
|
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="
|
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="
|
41
|
-
|
42
|
-
|
43
|
-
|
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="
|
49
|
-
|
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="
|
57
|
-
<label class="control-label" for="xenstore-vm-data-nameserver1">vm-data/nameserver1</label>
|
58
|
-
|
59
|
-
|
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="
|
65
|
-
<label class="control-label" for="xenstore-vm-data-nameserver2">vm-data/nameserver2</label>
|
66
|
-
|
67
|
-
|
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="
|
73
|
-
<label class="control-label" for="xenstore-vm-data-environment">vm-data/environment</label>
|
74
|
-
|
75
|
-
|
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
data/lib/foreman_xen/version.rb
CHANGED
@@ -1,90 +1,90 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
36
|
-
|
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
|
-
|
36
|
+
def logger
|
37
|
+
Rails.logger
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
@client_socket = client_srv.accept
|
43
|
-
logger.debug 'VNCTunnel Client: client accepted'
|
40
|
+
private
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
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
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
87
|
-
|
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
|
-
|
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.
|
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-
|
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
|
-
-
|
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.
|
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
|