nutella_framework 0.6.21 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d8353ce5b98a9d01a65de966e1e019948878bed
4
- data.tar.gz: 7a139d76298eba6ba31c43f308af6cbdc4b98dc6
3
+ metadata.gz: 7750cdf08b41df1aa16fe91e81a7139a44673183
4
+ data.tar.gz: 123af08b4f4fb8c05044faee20a8e81680fc0742
5
5
  SHA512:
6
- metadata.gz: 1ce4c41c641d5ef024c59da00ed0c8adb5cecba87cf05d00721cb9f97148d75fabf3741feeea803e0878775e57dba2e6271a20a36b7e45414030845dddcf12f1
7
- data.tar.gz: 7d4fd5f9fe747787c11af1ba398353f645347c2fef1aff874c175055fe7ec72c7012306c114828acada2993ea4268c32ff05cf4507dee5c8812bb117a0a80a46
6
+ metadata.gz: a0a51409dfbc5339be31211186c36316c1e6ca0fc8577a8fcbd87b718aaa1f0a9c4c2d5e7d9017c2e6c9ff1dd5f9a94decfa33c323db470c432f3ecdf292987b
7
+ data.tar.gz: 2f045bde885636db2ae0f75a85f3bfd45ad02f37d177398a683573177748cc99aa5cba02ee40973e1e2a5f422665e24a39b6280f307c3e92afb1484a87ef145e
data/Gemfile CHANGED
@@ -10,7 +10,6 @@ gem 'nokogiri', '~>1.6'
10
10
  gem 'slop', '~>4.0'
11
11
  gem 'nutella_lib','~>0.4', '>=0.4.24'
12
12
  gem 'activesupport', '~>4.2'
13
- gem 'mandrill-api', '~>1.0', '>=1.0.53'
14
13
  gem 'bson', '~> 3.0'
15
14
 
16
15
  group :development do
data/README.md CHANGED
@@ -11,7 +11,7 @@ Nutella is written in ruby but it leverages a bunch of other technologies that n
11
11
  1. _ruby_ (version >= 2.1.0). Do yourself a favor and use [RVM](https://rvm.io/rvm/install) to install Ruby.
12
12
  1. _git_ (version >= 1.8.0). Do yourself a favor and use [Homebrew](http://brew.sh/) to install git, if you are on OSX.
13
13
  1. _tmux_ (version >= 1.8.0). Do yourself a favor and use [Homebrew](http://brew.sh/) to install tmux, if you are on OSX.
14
- 1. _node.js_ (version >= 0.10.0). Yes, really, you need to install node becaue we use it to run the broker that handles all communications between all the pieces of the framework. Do yourself a favor and use [nvm](https://github.com/creationix/nvm).
14
+ 1. _Docker_ (version >= 17.03.0). We use Docker to run the broker that handles all communications between all the pieces of the framework. Do yourself a favor and use [Docker for mac](https://store.docker.com/editions/community/docker-ce-desktop-mac), if you are on OSX.
15
15
  1. _mongoDB_ (optional). You'll need mongoDB if you want to use it with `nutella.persist`.
16
16
 
17
17
  Once you have all of these, to install nutella simply do:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.21
1
+ 0.7.0
@@ -3,27 +3,13 @@ require_relative '../../lib/config/config'
3
3
  require_relative '../../nutella_lib/framework_core'
4
4
  require_relative '../../lib/commands/util/components_list'
5
5
  require 'active_support/core_ext/object/deep_dup'
6
- require 'mandrill'
7
6
  require 'mongo'
8
7
  require 'bson'
9
8
 
10
- # Framework bots can access all the parameters they need directly
11
- # from the configuration file and the runlist,
12
- # to which they have full access to.
13
-
14
- # Access the config file like so:
15
- # Nutella.config['broker']
16
-
17
- # Access the runs list like so:
18
- # Nutella.runlist.all_runs
19
-
20
9
 
21
10
  # Initialize this bot as framework component
22
11
  nutella.f.init(Nutella.config['broker'], 'monitoring_bot')
23
12
 
24
- # Mandrill access key
25
- $m = Mandrill::API.new 'i4frQYcTBMyZ6bYyLkEVOQ'
26
-
27
13
  # Open the resources database
28
14
  $messages = nutella.f.persist.get_json_object_store('messages')
29
15
 
@@ -69,8 +55,6 @@ def send_subscription_mail(mail, application, instance = nil, component = nil)
69
55
  ],
70
56
  :from_email=>'nutellamonitoring@gmail.com'
71
57
  }
72
-
73
- sending = $m.messages.send_template template_name, template_content, message
74
58
  end
75
59
 
76
60
  def send_notification_mail(mail, application, instance = nil, component = nil)
@@ -105,10 +89,6 @@ def send_notification_mail(mail, application, instance = nil, component = nil)
105
89
  ],
106
90
  :from_email=>'nutellamonitoring@gmail.com'
107
91
  }
108
-
109
- sending = $m.messages.send_template template_name, template_content, message
110
- puts sending
111
-
112
92
  end
113
93
 
114
94
  # Add an alert on a specific application/instance/component
@@ -12,7 +12,7 @@ module Nutella
12
12
 
13
13
  # Check if we have a local broker installed
14
14
  # and install one if we don't
15
- if File.directory? Nutella.config['broker_dir']
15
+ if broker_exists
16
16
  console.info 'You have a local broker installed. Yay!'
17
17
  else
18
18
  console.warn 'You don\'t seem to have a local broker installed so we are going to go ahead and install one for you. This might take some time...'
@@ -33,29 +33,33 @@ module Nutella
33
33
  private
34
34
 
35
35
 
36
+ def broker_exists
37
+ # Check if Docker image for the broker was already pulled
38
+ if `docker images matteocollina/mosca:v2.3.0 --format "{{.ID}}"` != ""
39
+ # If so, check that a broker configuration exists and create one if it doesn't
40
+ Nutella.config['broker'] = '127.0.0.1' if Nutella.config['broker'].nil?
41
+ true
42
+ else
43
+ false
44
+ end
45
+ end
46
+
47
+
36
48
  def install_local_broker
37
- # Clone, cd and npm install
38
- broker_version = 'v0.28.1'
39
- out1 = system "git clone -b #{broker_version} --depth 1 git://github.com/mcollina/mosca.git #{Nutella.config['broker_dir']} > /dev/null 2>&1"
40
- Dir.chdir(Nutella.config['broker_dir'])
41
- out2 = system 'npm install > /dev/null 2>&1'
42
-
43
- # Add startup script and make it executable
44
- File.open('startup', 'w') { |file| file.write("#!/bin/sh\n\nBASEDIR=$(dirname $0)\n$BASEDIR/bin/mosca --disable-stats --http-port 1884 > /dev/null 2>&1 &\necho $! > $BASEDIR/bin/.pid\n") }
45
- File.chmod( 0755, 'startup' )
46
-
47
- # Write configuration into config.json
49
+ # Docker pull to install
50
+ system "docker pull matteocollina/mosca:v2.3.0 > /dev/null 2>&1"
51
+ # Write broker setting inside config.json
48
52
  Nutella.config['broker'] = '127.0.0.1'
49
- out1 && out2
50
53
  end
51
54
 
52
55
 
53
56
  def all_dependencies_installed?
54
- # Node version lambda
55
- node_semver = lambda do
56
- out = `node --version`
57
- out[0] = ''
58
- Semantic::Version.new out
57
+ # Docker version lambda
58
+ docker_semver = lambda do
59
+ out = `docker --version`
60
+ token = out.split(' ')
61
+ token[2].slice(0..1)
62
+ Semantic::Version.new token[2].slice(0..1).concat('.0.0')
59
63
  end
60
64
  # Git version lambda
61
65
  git_semver = lambda do
@@ -81,7 +85,7 @@ module Nutella
81
85
  Semantic::Version.new out[0..4]
82
86
  end
83
87
  # Check versions
84
- return true if check_version?('node', '0.10.0', node_semver) && check_version?('git', '1.8.0', git_semver) && check_version?('tmux', '1.8.0', tmux_semver) && check_version?('mongodb', '2.6.9', mongo_semver)
88
+ return true if check_version?('docker', '17.0.0', docker_semver) && check_version?('git', '1.8.0', git_semver) && check_version?('tmux', '1.8.0', tmux_semver) && check_version?('mongodb', '2.6.9', mongo_semver)
85
89
  # If even one of the checks fails, return false
86
90
  false
87
91
  end
data/lib/commands/stop.rb CHANGED
@@ -76,8 +76,8 @@ module Nutella
76
76
 
77
77
 
78
78
  def stop_internal_broker
79
- pid_file_path = "#{Nutella.config['broker_dir']}/bin/.pid"
80
- kill_process_with_pid pid_file_path
79
+ cid = `docker ps --filter ancestor=matteocollina/mosca:v2.3.0 --format "{{.ID}}"`
80
+ `docker kill #{cid}`
81
81
  end
82
82
 
83
83
 
@@ -7,16 +7,12 @@ class ComponentsStarter
7
7
  # Starts the internal broker if it's not started already
8
8
  # @return [boolean] true if the broker is correctly started, false otherwise
9
9
  def self.start_internal_broker
10
- pid_file_path = "#{Nutella.config['broker_dir']}bin/.pid"
11
- # Check if the process with pid indicated in the pidfile is alive
12
- return true if sanitize_pid_file pid_file_path
10
+ # Check if the broker has been started already, if it is, return
11
+ return true if broker_started?
13
12
  # Check that broker is not running 'unsupervised' (i.e. check port 1883), if it is, return
14
13
  return true unless broker_port_free?
15
- # Broker is not running and there is no pid file so we try to start
16
- # the internal broker and create a new pid file. Note that the pid file is created by
17
- # the `startup` script, not here.
18
- pid = fork
19
- exec("#{Nutella.config['broker_dir']}/startup") if pid.nil?
14
+ # Broker is not running so we try to start the internal broker
15
+ cid = `docker run -p 1883:1883 -p 1884:80 -d -v #{Nutella.config['broker_dir']}:/db matteocollina/mosca:v2.3.0`
20
16
  # Wait a bit to give the chance to the broker to actually start up
21
17
  sleep 1
22
18
  # All went well so we return true
@@ -134,6 +130,13 @@ class ComponentsStarter
134
130
  private_class_method :sanitize_pid_file
135
131
 
136
132
 
133
+ # Checks if the broker is running already
134
+ # @return [boolean] true if there is a container for the broker running already
135
+ def self.broker_started?
136
+ `docker ps --filter ancestor=matteocollina/mosca:v2.3.0 --format "{{.ID}}"` != ""
137
+ end
138
+ private_class_method :broker_started?
139
+
137
140
  # Checks if port 1883 (MQTT broker port) is free
138
141
  # or some other service is already listening on it
139
142
  # @return [boolean] true if there is no broker listening on port 1883, false otherwise
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: nutella_framework 0.6.21 ruby lib
5
+ # stub: nutella_framework 0.7.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "nutella_framework".freeze
9
- s.version = "0.6.21"
9
+ s.version = "0.7.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Alessandro Gnoli".freeze]
14
- s.date = "2017-04-09"
14
+ s.date = "2017-04-11"
15
15
  s.description = "utella is a framework to create and run RoomApps".freeze
16
16
  s.email = "tebemis@gmail.com".freeze
17
17
  s.executables = ["nutella".freeze]
@@ -655,7 +655,6 @@ Gem::Specification.new do |s|
655
655
  s.add_runtime_dependency(%q<slop>.freeze, ["~> 4.0"])
656
656
  s.add_runtime_dependency(%q<nutella_lib>.freeze, [">= 0.4.24", "~> 0.4"])
657
657
  s.add_runtime_dependency(%q<activesupport>.freeze, ["~> 4.2"])
658
- s.add_runtime_dependency(%q<mandrill-api>.freeze, [">= 1.0.53", "~> 1.0"])
659
658
  s.add_runtime_dependency(%q<bson>.freeze, ["~> 3.0"])
660
659
  s.add_development_dependency(%q<shoulda>.freeze, ["~> 3.0"])
661
660
  s.add_development_dependency(%q<yard>.freeze, ["~> 0.8"])
@@ -674,7 +673,6 @@ Gem::Specification.new do |s|
674
673
  s.add_dependency(%q<slop>.freeze, ["~> 4.0"])
675
674
  s.add_dependency(%q<nutella_lib>.freeze, [">= 0.4.24", "~> 0.4"])
676
675
  s.add_dependency(%q<activesupport>.freeze, ["~> 4.2"])
677
- s.add_dependency(%q<mandrill-api>.freeze, [">= 1.0.53", "~> 1.0"])
678
676
  s.add_dependency(%q<bson>.freeze, ["~> 3.0"])
679
677
  s.add_dependency(%q<shoulda>.freeze, ["~> 3.0"])
680
678
  s.add_dependency(%q<yard>.freeze, ["~> 0.8"])
@@ -694,7 +692,6 @@ Gem::Specification.new do |s|
694
692
  s.add_dependency(%q<slop>.freeze, ["~> 4.0"])
695
693
  s.add_dependency(%q<nutella_lib>.freeze, [">= 0.4.24", "~> 0.4"])
696
694
  s.add_dependency(%q<activesupport>.freeze, ["~> 4.2"])
697
- s.add_dependency(%q<mandrill-api>.freeze, [">= 1.0.53", "~> 1.0"])
698
695
  s.add_dependency(%q<bson>.freeze, ["~> 3.0"])
699
696
  s.add_dependency(%q<shoulda>.freeze, ["~> 3.0"])
700
697
  s.add_dependency(%q<yard>.freeze, ["~> 0.8"])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nutella_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.21
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Gnoli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-09 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic
@@ -156,26 +156,6 @@ dependencies:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
158
  version: '4.2'
159
- - !ruby/object:Gem::Dependency
160
- name: mandrill-api
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- version: 1.0.53
166
- - - "~>"
167
- - !ruby/object:Gem::Version
168
- version: '1.0'
169
- type: :runtime
170
- prerelease: false
171
- version_requirements: !ruby/object:Gem::Requirement
172
- requirements:
173
- - - ">="
174
- - !ruby/object:Gem::Version
175
- version: 1.0.53
176
- - - "~>"
177
- - !ruby/object:Gem::Version
178
- version: '1.0'
179
159
  - !ruby/object:Gem::Dependency
180
160
  name: bson
181
161
  requirement: !ruby/object:Gem::Requirement