nitos_testbed_rc 1.0.0.pre.2 → 1.0.0.pre.4

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.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Nitos Testbed resource controllers
1
+ Nitos Testbed resource controllers (NTRC)
2
2
  =================
3
3
 
4
4
  Contains:
@@ -14,3 +14,166 @@ save and load images to nodes.
14
14
 
15
15
  These tools are under development. Unpredictable behaviour is to be expected untill
16
16
  a stable version is provided.
17
+
18
+ Installation
19
+ ------------
20
+
21
+ First you need to install the gem
22
+
23
+ % gem install nitos_testbed_rc --pre
24
+
25
+ Then you need to run the install_ntrc script to generate the configuration files.
26
+
27
+ % install_ntrc
28
+
29
+ Create certificates
30
+ -------------------
31
+
32
+ Use omf_cert.rb script to generate the following certificates and place them on directories '/root/.omf' and /root/.omf.
33
+
34
+ % mkdir /root/.omf
35
+ % mkdir /root/.omf/trusted_roots
36
+ % cd /root/.omf
37
+
38
+ Create a root certificate (change DOMAIN)
39
+
40
+ % ruby omf_cert.rb --email root@DOMAIN -o /root/.omf/trusted_roots/root.pem --duration 5000000 create_root
41
+
42
+ Create a certificate for user_proxy of NTRC (change DOMAIN, XMPP_DOMAIN and if you wish the output file names).
43
+
44
+ % ruby omf_cert.rb -o user_factory.pem --email user_factory@DOMAIN --resource-type user_factory --resource-id xmpp://user_factory@XMPP_DOMAIN --root /root/.omf/trusted_roots/root.pem --duration 50000000 create_resource
45
+
46
+ Create a certificate for cm_proxy of NTRC (change DOMAIN, XMPP_DOMAIN and if you wish the output file names).
47
+
48
+ % ruby omf_cert.rb -o cm_factory.pem --email cm_factory@DOMAIN --resource-type cm_factory --resource-id xmpp://cm_factory@XMPP_DOMAIN --root /root/.omf/trusted_roots/root.pem --duration 50000000 create_resource
49
+
50
+ Create a certificate for frisbee_proxy of NTRC (change DOMAIN, XMPP_DOMAIN and if you wish the output file names).
51
+
52
+ % ruby omf_cert.rb -o cm_factory.pem --email cm_factory@DOMAIN --resource-type cm_factory --resource-id xmpp://cm_factory@XMPP_DOMAIN --root /root/.omf/trusted_roots/root.pem --duration 50000000 create_resource
53
+
54
+ Create a certificate for the omf6 script, this certificate is inside the directory '~/.omf', every user of the testbed should have his own certificate in order to use omf6 script (change DOMAIN, USERNAME and if you wish the output file names).
55
+
56
+ % ./omf_cert.rb -o user_cert.pem --email root@DOMAIN --user root --root ~/.omf/trusted_roots/root.pem --duration 50000000 --geni_uri URI:urn:publicid:IDN+DOMAIN+user+USERNAME create_user
57
+
58
+ Configuration files
59
+ -------------------
60
+
61
+ Change configuration file '/etc/nitos_testbed/user_proxy_conf.yaml', which is related to user_proxy of NTRC. For example:
62
+
63
+ #xmpp details
64
+ :xmpp:
65
+ :username: user_proxy
66
+ :password: pw
67
+ :server: DOMAIN
68
+ #x509 certificates to be used by user_proxy
69
+ :auth:
70
+ :root_cert_dir: ~/.omf/trusted_roots
71
+ :entity_cert: ~/.omf/user_factory.pem
72
+ :entity_key: ~/.omf/user_factory.pkey
73
+ #operation mode for OmfCommon.init (development, production, etc)
74
+ :operationMode: development
75
+
76
+ Change configuration file '/etc/nitos_testbed/cm_proxy_conf.yaml', which is related to cm_proxy of NTRC. For example:
77
+
78
+ #details to be used for the connection to the xmpp server
79
+ :xmpp:
80
+ :username: cm_proxy
81
+ :password: pw
82
+ :server: DOMAIN
83
+ #x509 certificates to be used by cm_proxy
84
+ :auth:
85
+ :root_cert_dir: ~/.omf/trusted_roots
86
+ :entity_cert: ~/.omf/cm_factory.pem
87
+ :entity_key: ~/.omf/cm_factory.pkey
88
+
89
+ #time (in seconds) before timeout error occurs
90
+ :timeout: 80
91
+ #operation mode for OmfCommon.init (development, production, etc)
92
+ :operationMode: development
93
+ #testbed xmpp topic
94
+ :testbedTopic: am_controller
95
+
96
+ Change configuration file '/etc/nitos_testbed/frisbee_proxy_conf.yaml', which is related to frisbee_proxy of NTRC. For example:
97
+
98
+ #xmpp details
99
+ :xmpp:
100
+ :username: frisbee_proxy
101
+ :password: pw
102
+ :server: DOMAIN
103
+ #x509 certificates to be used by user_proxy
104
+ :auth:
105
+ :root_cert_dir: ~/.omf/trusted_roots
106
+ :entity_cert: ~/.omf/frisbee_factory.pem
107
+ :entity_key: ~/.omf/frisbee_factory.pkey
108
+
109
+ #operation Mode for OmfCommon.init (development, production, etc)
110
+ :operationMode: development
111
+
112
+ #testbed xmpp topic
113
+ :testbedTopic: am_controller
114
+
115
+ #frisbee and imagezip configuration
116
+ :frisbee:
117
+ # Directory images are stored
118
+ :imageDir: /var/lib/omf-images-6
119
+ #defaultImage: orbit-baseline
120
+ :defaultImage: baseline.ndz
121
+
122
+ # max bandwidth for frisbee server
123
+ :bandwidth: 50000000
124
+
125
+ # Multicast address to use for servicing images
126
+ #mcAddress: 224.0.0.2
127
+ :mcAddress: 224.0.0.1
128
+ # Using ports starting at ...
129
+ :startPort: 7000
130
+
131
+ # Time out frisbee server if nobody requested it within TIMEOUT sec
132
+ :timeout: 3600
133
+
134
+ # Directory to find frisbee daemons
135
+ :frisbeedBin: /usr/sbin/frisbeed
136
+ :frisbeeBin: /usr/sbin/frisbee
137
+ :imagezipClientBin: /usr/bin/imagezip
138
+ :imagezipServerBin: /bin/nc
139
+
140
+ # Local interface to bind to for frisbee traffic
141
+ #multicastIF: 192.168.204.1
142
+ :multicastIF: 10.0.1.200
143
+
144
+ Change configuration file '~/.omf/etc/user_proxy_conf.yaml', which is related to omf6 script of NTRC, every user of the testbed should have his own configuration file in order to use omf6 script. For example:
145
+
146
+ :xmpp:
147
+ :script_user: script_user
148
+ :password: pw
149
+ :server: DOMAIN
150
+ :auth:
151
+ :root_cert_dir: ~/.omf/trusted_roots
152
+ :entity_cert: ~/.omf/user_cert.pem
153
+ :entity_key: ~/.omf/user_cert.pkey
154
+ #operation mode for OmfCommon.init (development, production, etc)
155
+ :operationMode: development
156
+ #omf script configuration
157
+ :omf_script:
158
+ #default last action on load and save commands (reset or shutdown)
159
+ :last_action: reset
160
+
161
+ Run proxies
162
+ -----------
163
+
164
+ You can execute all proxies with one command:
165
+
166
+ % run_proxies
167
+
168
+ Or you run proxies seperatly
169
+
170
+ % user_proxy
171
+ % cm_proxy
172
+ % frisbee_proxy
173
+
174
+ Run omf6 commands
175
+ -----------------
176
+
177
+ Now you can use omf6 script to execute omf6 related commands
178
+
179
+ % omf6 --help
data/bin/cm_proxy CHANGED
@@ -77,10 +77,12 @@ class CmPDP
77
77
  leases = l_msg.read_property("leases")[:resources]
78
78
  leases.each do |l|
79
79
  if Time.parse(l[:resource][:valid_from]) <= Time.now && Time.parse(l[:resource][:valid_until]) >= Time.now
80
- l[:resource][:components].each do |c|
81
- if c[:component][:name] == node_name.to_s && l[:resource][:account][:name] == acc
82
- lease = l
83
- break #found the correct lease
80
+ unless l[:resource][:components].nil?
81
+ l[:resource][:components].each do |c|
82
+ if c[:component][:name] == node_name.to_s && l[:resource][:account][:name] == acc
83
+ lease = l
84
+ break #found the correct lease
85
+ end
84
86
  end
85
87
  end
86
88
  end
data/bin/install_ntrc CHANGED
@@ -4,6 +4,7 @@ require 'fileutils'
4
4
  spec = Gem::Specification.find_by_name("nitos_testbed_rc")
5
5
  gem_root = spec.gem_dir
6
6
  config_path = "/etc/nitos_testbed_rc"
7
+ log_path = "/var/log/ntrc"
7
8
 
8
9
  puts "Copying configuration files from '#{gem_root}'."
9
10
 
@@ -12,6 +13,11 @@ unless File.directory?(config_path)
12
13
  FileUtils.mkdir_p(config_path)
13
14
  end
14
15
 
16
+ unless File.directory?(log_path)
17
+ puts "Generating directory '#{log_path}'."
18
+ FileUtils.mkdir_p(log_path)
19
+ end
20
+
15
21
  conf_files = []
16
22
  conf_files << "cm_proxy_conf.yaml"
17
23
  conf_files << "frisbee_proxy_conf.yaml"
@@ -24,7 +30,7 @@ conf_files.each do |file|
24
30
  FileUtils.chmod 0644, "#{config_path}/#{file}"
25
31
  end
26
32
 
27
- config_path = "~/.omf/etc"
33
+ config_path = File.expand_path("~/.omf/etc")
28
34
  unless File.directory?(config_path)
29
35
  puts "Generating directory '#{config_path}'."
30
36
  FileUtils.mkdir_p(config_path)
@@ -32,4 +38,17 @@ end
32
38
 
33
39
  FileUtils.cp "#{gem_root}/etc/omf_script_conf.yaml", "#{config_path}/omf_script_conf.yaml"
34
40
  FileUtils.chmod 0644, "#{config_path}/omf_script_conf.yaml"
41
+
42
+ puts "Copying initialization script 'run_ntrc.sh'."
43
+ FileUtils.cp "#{gem_root}/init/run_ntrc.sh", "/usr/local/bin/run_ntrc.sh"
44
+
45
+ FileUtils.cp "#{gem_root}/init/ntrc.conf", "/etc/init/ntrc.conf"
46
+ FileUtils.cp "#{gem_root}/init/ntrc_user.conf", "/etc/init/ntrc_user.conf"
47
+ FileUtils.cp "#{gem_root}/init/ntrc_frisbee.conf", "/etc/init/ntrc_frisbee.conf"
48
+ FileUtils.cp "#{gem_root}/init/ntrc_cm.conf", "/etc/init/ntrc_cm.conf"
49
+ puts "Upstart scripts has been installed."
50
+ puts "Execute 'start ntrc' to run all the proxies."
51
+ puts "Execute 'start ntrc_frisbee' to run frisbee proxy."
52
+ puts "Execute 'start ntrc_user' to run user proxy."
53
+ puts "Execute 'start ntrc_cm' to run cm proxy."
35
54
  puts "done."
data/bin/omf6 CHANGED
@@ -3,8 +3,9 @@ require 'rubygems'
3
3
  require 'time'
4
4
  require 'omf_common'
5
5
  require 'optparse'
6
+ CONF_PATH = '~/.omf/etc/omf_script_conf.yaml'
6
7
 
7
- @config = YAML.load_file('~/.omf/etc/omf_script_conf.yaml')
8
+ @config = YAML.load_file(File.expand_path(CONF_PATH))
8
9
  # @config = YAML.load_file(File.join(File.dirname(File.expand_path(__FILE__)), '.../etc/omf_script_conf.yaml'))
9
10
  @auth = @config[:auth]
10
11
  @xmpp = @config[:xmpp]
@@ -5,9 +5,9 @@
5
5
  :server: testserver
6
6
  #x509 certificates to be used by cm_proxy
7
7
  :auth:
8
- :root_cert_dir: ~/.omf/trusted_roots
9
- :entity_cert: ~/.omf/cm_factory.pem
10
- :entity_key: ~/.omf/cm_factory.pkey
8
+ :root_cert_dir: /root/.omf/trusted_roots
9
+ :entity_cert: /root/.omf/cm_factory.pem
10
+ :entity_key: /root/.omf/cm_factory.pkey
11
11
 
12
12
  #time (in seconds) before timeout error occurs
13
13
  :timeout: 80
@@ -5,9 +5,9 @@
5
5
  :server: testserver
6
6
  #x509 certificates to be used by user_proxy
7
7
  :auth:
8
- :root_cert_dir: ~/.omf/trusted_roots
9
- :entity_cert: ~/.omf/frisbee_factory.pem
10
- :entity_key: ~/.omf/frisbee_factory.pkey
8
+ :root_cert_dir: /root/.omf/trusted_roots
9
+ :entity_cert: /root/.omf/frisbee_factory.pem
10
+ :entity_key: /root/.omf/frisbee_factory.pkey
11
11
 
12
12
  #operation Mode for OmfCommon.init (development, production, etc)
13
13
  :operationMode: development
@@ -5,8 +5,8 @@
5
5
  :server: testserver
6
6
  #x509 certificates to be used by user_proxy
7
7
  :auth:
8
- :root_cert_dir: ~/.omf/trusted_roots
9
- :entity_cert: ~/.omf/user_factory.pem
10
- :entity_key: ~/.omf/user_factory.pkey
8
+ :root_cert_dir: /root/.omf/trusted_roots
9
+ :entity_cert: /root/.omf/user_factory.pem
10
+ :entity_key: /root/.omf/user_factory.pkey
11
11
  #operation mode for OmfCommon.init (development, production, etc)
12
12
  :operationMode: development
data/init/ntrc.conf ADDED
@@ -0,0 +1,6 @@
1
+ description "NITOS Testbed Resource Controllers pack"
2
+ author "NITOS <nitlab@inf.uth.gr>"
3
+
4
+ start on (filesystem and net-device-up IFACE=lo)
5
+ stop on runlevel [!2345]
6
+
data/init/ntrc_cm.conf ADDED
@@ -0,0 +1,14 @@
1
+ description "NITOS proxy for cm controller of NITOS Testbed resource controllers pack"
2
+ author "NITOS <nitlab@inf.uth.gr>"
3
+
4
+ start on starting ntrc
5
+ stop on stopping ntrc
6
+
7
+ env DAEMON=/usr/local/bin/run_ntrc.sh
8
+
9
+ respawn
10
+
11
+ script
12
+ PATH=$PATH:/usr/bin:/usr/local/bin
13
+ exec $DAEMON 3 2>&1
14
+ end script
@@ -0,0 +1,14 @@
1
+ description "NITOS proxy for frisbee controller of NITOS Testbed resource controllers pack"
2
+ author "NITOS <nitlab@inf.uth.gr>"
3
+
4
+ start on starting ntrc
5
+ stop on stopping ntrc
6
+
7
+ env DAEMON=/usr/local/bin/run_ntrc.sh
8
+
9
+ respawn
10
+
11
+ script
12
+ PATH=$PATH:/usr/bin:/usr/local/bin
13
+ exec $DAEMON 2 2>&1
14
+ end script
@@ -0,0 +1,14 @@
1
+ description "NITOS proxy for user controller of NITOS Testbed resource controllers pack"
2
+ author "NITOS <nitlab@inf.uth.gr>"
3
+
4
+ start on starting ntrc
5
+ stop on stopping ntrc
6
+
7
+ env DAEMON=/usr/local/bin/run_ntrc.sh
8
+
9
+ respawn
10
+
11
+ script
12
+ PATH=$PATH:/usr/bin:/usr/local/bin
13
+ exec $DAEMON 1 2>&1
14
+ end script
data/init/run_ntrc.sh ADDED
@@ -0,0 +1,86 @@
1
+ #!/bin/bash
2
+
3
+ # Startup wrapper for the nitos_testbed_rc
4
+ # detects system-wide RVM installations & Ruby from distro packages
5
+
6
+ # system-wide RVM must be installed using
7
+ # '\curl -L https://get.rvm.io | sudo bash -s stable'
8
+
9
+ die() { echo "ERROR: $@" 1>&2 ; exit 1; }
10
+
11
+ RUBY_VER="ruby-1.9.3-p448"
12
+ RUBY_BIN_SUFFIX=""
13
+
14
+ if [ `id -u` != "0" ]; then
15
+ die "This script is intended to be run as 'root'"
16
+ fi
17
+
18
+ if [ -e /etc/profile.d/rvm.sh ]; then
19
+ # use RVM if installed
20
+ echo "System-wide RVM installation detected"
21
+ source /etc/profile.d/rvm.sh
22
+ if [[ $? != 0 ]] ; then
23
+ die "Failed to initialize RVM environment"
24
+ fi
25
+ # rvm use $RUBY_VER@omf > /dev/null
26
+ # if [[ $? != 0 ]] ; then
27
+ # die "$RUBY_VER with gemset 'omf' is not installed in your RVM"
28
+ # fi
29
+ ruby -v | grep 1.9.3 > /dev/null
30
+ if [[ $? != 0 ]] ; then
31
+ die "Could not run Ruby 1.9.3"
32
+ fi
33
+ gem list | grep nitos_testbed_rc > /dev/null
34
+ if [[ $? != 0 ]] ; then
35
+ die "The nitos_testbed_rc gem is not installed in the 'omf' gemset"
36
+ fi
37
+ else
38
+ # check for distro ruby when no RVM was found
39
+ echo "No system-wide RVM installation detected"
40
+ ruby -v | grep 1.9.3 > /dev/null
41
+ if [[ $? != 0 ]] ; then
42
+ ruby1.9.3 -v | grep 1.9.3 > /dev/null
43
+ if [[ $? != 0 ]] ; then
44
+ die "Could not run system Ruby 1.9.3. No useable Ruby installation found."
45
+ fi
46
+ RUBY_BIN_SUFFIX="1.9.3"
47
+ fi
48
+ echo "Ruby 1.9.3 found"
49
+ gem$RUBY_BIN_SUFFIX list | grep nitos_testbed_rc > /dev/null
50
+ if [[ $? != 0 ]] ; then
51
+ die "The nitos_testbed_rc gem is not installed"
52
+ fi
53
+ fi
54
+
55
+ EXEC=""
56
+
57
+ case "$1" in
58
+
59
+ 1) echo "Starting user_proxy"
60
+ EXEC=`which user_proxy`
61
+ if [[ $? != 0 ]] ; then
62
+ die "could not find user_proxy executable"
63
+ fi
64
+ ;;
65
+ 2) echo "Starting frisbee_proxy"
66
+ EXEC=`which frisbee_proxy`
67
+ if [[ $? != 0 ]] ; then
68
+ die "could not find frisbee_proxy executable"
69
+ fi
70
+ ;;
71
+ 3) echo "Starting cm_proxy"
72
+ EXEC=`which cm_proxy`
73
+ if [[ $? != 0 ]] ; then
74
+ die "could not find cm_proxy executable"
75
+ fi
76
+ ;;
77
+ *) echo "Starting run_proxy"
78
+ EXEC=`which run_proxy`
79
+ if [[ $? != 0 ]] ; then
80
+ die "could not find run_proxy executable"
81
+ fi
82
+ ;;
83
+ esac
84
+
85
+ echo "Running $EXEC"
86
+ exec /usr/bin/env ruby$RUBY_BIN_SUFFIX $EXEC
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module NITOS
2
2
  module TestbedRc
3
- VERSION = "1.0.0.pre.2"
3
+ VERSION = "1.0.0.pre.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nitos_testbed_rc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.2
4
+ version: 1.0.0.pre.4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-17 00:00:00.000000000 Z
12
+ date: 2014-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omf_common
@@ -101,6 +101,11 @@ files:
101
101
  - etc/frisbee_proxy_conf.yaml
102
102
  - etc/omf_script_conf.yaml
103
103
  - etc/user_proxy_conf.yaml
104
+ - init/ntrc.conf
105
+ - init/ntrc_cm.conf
106
+ - init/ntrc_frisbee.conf
107
+ - init/ntrc_user.conf
108
+ - init/run_ntrc.sh
104
109
  - lib/nitos_testbed_rc.rb
105
110
  - lib/nitos_testbed_rc/cm_factory.rb
106
111
  - lib/nitos_testbed_rc/frisbee.rb