Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Eric Zheng
slapos
Commits
d4aa42f7
Commit
d4aa42f7
authored
Sep 28, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rina: demo of a SR deploying an application using RINA as a network stack
parent
8158e481
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
230 additions
and
0 deletions
+230
-0
software/hellorina/instance-root.cfg.in
software/hellorina/instance-root.cfg.in
+59
-0
software/hellorina/instance-server.cfg.in
software/hellorina/instance-server.cfg.in
+14
-0
software/hellorina/instance.cfg.in
software/hellorina/instance.cfg.in
+45
-0
software/hellorina/proxy
software/hellorina/proxy
+70
-0
software/hellorina/software.cfg
software/hellorina/software.cfg
+42
-0
No files found.
software/hellorina/instance-root.cfg.in
0 → 100644
View file @
d4aa42f7
{% set sla_dict = {} -%}
{% for sla, ref_list in slapparameter_dict.get('sla-dict', {}).iteritems() -%}
{% do sla_dict.update(dict.fromkeys(ref_list, sla)) -%}
{% endfor -%}
{% macro sla(name, required=False) -%}
{% if required or name in sla_dict -%}
{% for k, (v,) in urlparse.parse_qs(sla_dict.pop(name), strict_parsing=1).iteritems() -%}
sla-{{ k }} = {{ v }}
{% endfor -%}
{% else -%}
sla-computer_guid = ${slap-connection:computer-id}
{% endif -%}
{% endmacro -%}
[directory]
recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory}
etc = ${:home}/etc
var = ${:home}/var
# Executables put here will be started but not monitored (for startup scripts)
script = ${:etc}/run
# Executables put here will be started and monitored (for daemons)
service = ${:etc}/service
[server]
<= request-common-base
software-type = server
name = server
{{ sla('server') }}
return =
[proxy]
recipe = slapos.cookbook:wrapper
command-line = {{ python_location }}/bin/python2.7 {{ rina_proxy }} ${server:instance-guid} ${:ipv6} ${:port}
wrapper-path = ${directory:service}/proxy
environment =
PATH={{ rina_tools_location }}/bin:%(PATH)s
ipv6 = {{ipv6}}
port = 8080
[publish]
recipe = slapos.cookbook:publish.serialised
url.proxy = http://[${proxy:ipv6}]:${proxy:port}
[request-common-base]
recipe = slapos.cookbook:request.serialised
software-url = ${slap-connection:software-release-url}
server-url = ${slap-connection:server-url}
key-file = ${slap-connection:key-file}
cert-file = ${slap-connection:cert-file}
computer-id = ${slap-connection:computer-id}
partition-id = ${slap-connection:partition-id}
[buildout]
parts =
publish
{{- assert(not sla_dict, sla_dict) }}
software/hellorina/instance-server.cfg.in
0 → 100644
View file @
d4aa42f7
[directory]
recipe = slapos.cookbook:mkdirectory
service = ${buildout:directory}/etc/service
[server]
recipe = slapos.cookbook:wrapper
command-line = {{rina_tools_location}}/bin/rina-echo-time -l --server-api {{instance_guid}}
wrapper-path = ${directory:service}/server
[publish]
recipe = slapos.cookbook:publish.serialised
[buildout]
parts = publish server
software/hellorina/instance.cfg.in
0 → 100644
View file @
d4aa42f7
[buildout]
parts = switch-softwaretype
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
[slap-configuration]
recipe = slapos.cookbook:slapconfiguration.serialised
computer = ${slap-connection:computer-id}
partition = ${slap-connection:partition-id}
url = ${slap-connection:server-url}
key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file}
[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
filename = ${:_buildout_section_name_}.cfg
rendered = ${buildout:parts-directory}/${:_buildout_section_name_}/${:filename}
extensions = jinja2.ext.do
extra-context =
context =
key slapparameter_dict slap-configuration:configuration
raw rina_tools_location {{ rina_tools_location }}
${:extra-context}
[root]
<= jinja2-template-base
template = {{ instance_root }}
extra-context =
key ipv6 slap-configuration:ipv6-random
raw python_location {{ python_location }}
raw rina_proxy {{ rina_proxy }}
[server]
<= jinja2-template-base
template = {{ instance_server }}
extra-context =
key instance_guid slap-configuration:instance-guid
[switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype
override = {{ dumps(override_switch_softwaretype |default) }}
default = root:rendered
# BBB
RootSoftwareInstance = ${:default}
server = server:rendered
software/hellorina/proxy
0 → 100755
View file @
d4aa42f7
#!/usr/bin/python
import
httplib
,
socket
,
subprocess
,
sys
,
threading
,
urlparse
import
BaseHTTPServer
,
SocketServer
class
Popen
(
subprocess
.
Popen
):
def
stop
(
self
):
if
self
.
pid
and
self
.
returncode
is
None
:
self
.
terminate
()
t
=
threading
.
Timer
(
5
,
self
.
kill
)
t
.
start
()
# PY3: use waitid(WNOWAIT) and call self.poll() after t.cancel()
r
=
self
.
wait
()
t
.
cancel
()
return
r
class
Handler
(
BaseHTTPServer
.
BaseHTTPRequestHandler
):
def
do_GET
(
self
):
try
:
path
,
query
=
self
.
path
.
split
(
'?'
,
1
)
except
ValueError
:
path
=
self
.
path
query
=
{}
else
:
query
=
dict
(
urlparse
.
parse_qsl
(
query
,
keep_blank_values
=
1
,
strict_parsing
=
1
))
_
,
path
=
path
.
split
(
'/'
)
if
not
_
:
try
:
return
getattr
(
self
,
'_GET_'
+
path
,
None
)(
**
query
)
except
(
AttributeError
,
TypeError
):
pass
self
.
send_error
(
httplib
.
BAD_REQUEST
)
def
_GET_
(
self
):
self
.
send_response
(
httplib
.
FOUND
)
self
.
send_header
(
'Location'
,
'ping?count=4'
)
self
.
end_headers
()
def
_GET_ping
(
self
,
count
=
4
):
count
=
int
(
count
)
args
=
"rina-echo-time"
,
"--server-api"
,
server_api
,
"-c"
,
str
(
count
)
try
:
p
=
Popen
(
args
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
except
Exception
,
e
:
self
.
send_error
(
httplib
.
INTERNAL_SERVER_ERROR
)
raise
try
:
self
.
send_response
(
httplib
.
OK
)
self
.
send_header
(
'Content-type'
,
'text/plain; charset=utf-8'
)
self
.
end_headers
()
self
.
wfile
.
write
(
'# count=%s
\
n
'
%
count
)
while
1
:
line
=
p
.
stdout
.
readline
()
if
not
line
:
break
self
.
wfile
.
write
(
line
)
finally
:
p
.
stop
()
class
Server
(
SocketServer
.
ThreadingTCPServer
):
allow_reuse_address
=
True
daemon_threads
=
True
address_family
=
socket
.
AF_INET6
if
__name__
==
"__main__"
:
server_api
=
sys
.
argv
[
1
]
Server
((
sys
.
argv
[
2
],
int
(
sys
.
argv
[
3
])),
Handler
).
serve_forever
()
software/hellorina/software.cfg
0 → 100644
View file @
d4aa42f7
[buildout]
extends =
../../stack/slapos.cfg
../../component/rina-tools/buildout.cfg
parts =
slapos-cookbook
template
[template]
recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/instance.cfg.in
md5sum = d2fd3ed7df0e3082608b9caf72e4f700
# XXX: "template.cfg" is hardcoded in instanciation recipe
rendered = ${buildout:directory}/template.cfg
context =
key develop_eggs_directory buildout:develop-eggs-directory
key eggs_directory buildout:eggs-directory
key python_location python2.7:location
key rina_tools_location rina-tools:location
key instance_root instance-root:target
key instance_server instance-server:target
key rina_proxy proxy:target
[download-base]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_buildout_section_name_}.cfg.in
# XXX: following mode should be the default
mode = 644
[instance-root]
<= download-base
md5sum = 8ba6905c430e69a14db1be386f932c0f
[instance-server]
<= download-base
md5sum = 88a451b0f7f8def12713b92b91659b98
[proxy]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_buildout_section_name_}
mode = 755
md5sum = 78b77a6bda9958f547f7d89b747731e3
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment