wildcloud-keeper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,40 @@
1
+ lxc.utsname = app<%= @id %>
2
+
3
+ lxc.tty = 4
4
+ lxc.pts = 1024
5
+ lxc.rootfs = <%= @target_path %>
6
+ lxc.mount = <%= @fstab_file %>
7
+ lxc.arch = amd64
8
+
9
+ <% if options[:memory] %>lxc.cgroup.memory.limit_in_bytes = <%= options[:memory] %><% end %>
10
+ <% if options[:swap] %>lxc.cgroup.memory.memsw.limit_in_bytes = <%= options[:swap] %><% end %>
11
+ <% if options[:cpu] %>lxc.cgroup.cpuset.cpus = <%= options[:cpus] %><% end %>
12
+ <% if options[:cpu_share] %>lxc.cgroup.cpu.shares = <%= options[:cpu_share] %><% end %>
13
+
14
+ lxc.cgroup.devices.deny = a
15
+
16
+ # /dev/null and zero
17
+ lxc.cgroup.devices.allow = c 1:3 rwm
18
+ lxc.cgroup.devices.allow = c 1:5 rwm
19
+
20
+ # consoles
21
+ lxc.cgroup.devices.allow = c 5:1 rwm
22
+ lxc.cgroup.devices.allow = c 5:0 rwm
23
+ #lxc.cgroup.devices.allow = c 4:0 rwm
24
+ #lxc.cgroup.devices.allow = c 4:1 rwm
25
+
26
+ # /dev/{,u}random
27
+ lxc.cgroup.devices.allow = c 1:9 rwm
28
+ lxc.cgroup.devices.allow = c 1:8 rwm
29
+ lxc.cgroup.devices.allow = c 136:* rwm
30
+ lxc.cgroup.devices.allow = c 5:2 rwm
31
+
32
+ # rtc
33
+ lxc.cgroup.devices.allow = c 254:0 rwm
34
+
35
+ #fuse
36
+ lxc.cgroup.devices.allow = c 10:229 rwm
37
+
38
+ lxc.network.type=veth
39
+ lxc.network.link=br0
40
+ lxc.network.flags=up
@@ -0,0 +1,2 @@
1
+ proc <%= @target_path %>/proc proc nodev,noexec,nosuid 0 0
2
+ sysfs <%= @target_path %>/sys sysfs defaults 0 0
@@ -0,0 +1,8 @@
1
+ auto lo
2
+ iface lo inet loopback
3
+
4
+ auto eth0
5
+ iface eth0 inet static
6
+ address <%= options[:ip_address] %>
7
+ netmask 255.255.255.0
8
+ gateway 10.0.0.1
@@ -0,0 +1,70 @@
1
+ # Copyright 2011 Marek Jelen
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ require 'amqp'
17
+ require 'json'
18
+
19
+ require 'wildcloud/keeper/logger'
20
+ require 'wildcloud/keeper/configuration'
21
+
22
+ module Wildcloud
23
+ module Keeper
24
+ module Transport
25
+
26
+ class Amqp
27
+
28
+ def initialize
29
+ Keeper.logger.debug('AMQP') { 'Connecting to broker' }
30
+
31
+ @connection = AMQP.connect(Keeper.configuration['amqp'])
32
+ Keeper.add_amqp_logger(@connection)
33
+
34
+ @channel = AMQP::Channel.new(@connection)
35
+ @channel.prefetch(Keeper.configuration['node']['workers'])
36
+
37
+ @exchange = @channel.topic('wildcloud.keeper')
38
+ @queue = @channel.queue("wildcloud.keeper.node.#{Keeper.configuration['node']['name']}")
39
+ @queue.bind(@exchange, :routing_key => 'nodes')
40
+ @queue.bind(@exchange, :routing_key => "node.#{Keeper.configuration['node']['name']}")
41
+
42
+ if Keeper.configuration['node']['builder']
43
+ @builders = @channel.queue("wildcloud.keeper.build")
44
+ @builders.bind(@exchange, :routing_key => 'build')
45
+ end
46
+ end
47
+
48
+ def start(&block)
49
+ Keeper.logger.info('AMQP') { 'Starting to receive messages' }
50
+ @subscription = @queue.subscribe do |metadata, payload|
51
+ process_message(block, payload)
52
+ end
53
+ @building = @builders.subscribe do |metadata, payload|
54
+ process_message(block, payload)
55
+ end if @builders
56
+ end
57
+
58
+ def process_message(block, payload)
59
+ block.call(JSON.parse(payload))
60
+ end
61
+
62
+ def send(message, key)
63
+ Keeper.logger.debug('AMQP') { "Publishing message (key: #{key}) #{message.inspect}" }
64
+ @exchange.publish(JSON.dump(message), :routing_key => key.to_s)
65
+ end
66
+
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright 2011 Marek Jelen
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Wildcloud
16
+ module Keeper
17
+ VERSION = '0.0.1' unless const_defined?(:VERSION)
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wildcloud-keeper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marek Jelen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: amqp
16
+ requirement: &2153296580 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - =
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2153296580
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &2153296100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
32
+ version: 1.6.4
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2153296100
36
+ - !ruby/object:Gem::Dependency
37
+ name: wildcloud-logger
38
+ requirement: &2153295620 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
43
+ version: 0.0.1
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2153295620
47
+ description: Keeper deploys instances, starts and stops virtual machines
48
+ email:
49
+ - marek@jelen.biz
50
+ executables:
51
+ - wildcloud-keeper
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - bin/wildcloud-keeper
56
+ - lib/wildcloud/keeper/configuration.rb
57
+ - lib/wildcloud/keeper/deployers/aufs.rb
58
+ - lib/wildcloud/keeper/isolators/lxc.rb
59
+ - lib/wildcloud/keeper/logger.rb
60
+ - lib/wildcloud/keeper/runtime.rb
61
+ - lib/wildcloud/keeper/templates/app.config
62
+ - lib/wildcloud/keeper/templates/app.fstab
63
+ - lib/wildcloud/keeper/templates/interfaces
64
+ - lib/wildcloud/keeper/transport/amqp.rb
65
+ - lib/wildcloud/keeper/version.rb
66
+ - lib/wildcloud/keeper.rb
67
+ - LICENSE
68
+ - README.md
69
+ - CHANGELOG.md
70
+ homepage: http://github.com/wildcloud
71
+ licenses:
72
+ - Apache2
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: 1.3.6
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 1.8.10
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Keeper is responsible for managing applications on nodes.
95
+ test_files: []