Skip to content

Commit 8d1b3db

Browse files
authored
Merge pull request #123 from delphi-hub/develop
Release version 0.9.5
2 parents 53e577e + 651411c commit 8d1b3db

40 files changed

+1851
-441
lines changed

OpenAPISpecification.yaml

+98-27
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ paths:
3131
tags:
3232
- Meta
3333
summary: Retreives general configuration information
34-
description: Retrieves an object containing the most important configuration values of the registry. This contains the docker and traefik URIs.
34+
description: >-
35+
Retrieves an object containing the most important configuration values
36+
of the registry. This contains the docker and traefik URIs.
3537
operationId: configurationInfo
3638
responses:
3739
'200':
@@ -41,51 +43,52 @@ paths:
4143
properties:
4244
DockerHttpApi:
4345
type: string
44-
example: "172.0.2.1:9095"
46+
example: '172.0.2.1:9095'
4547
TraefikProxyUri:
4648
type: string
47-
example: "172.0.2.1:80"
49+
example: '172.0.2.1:80'
4850
/users/authenticate:
4951
post:
5052
tags:
5153
- User Management
5254
summary: Authenticates a user and returns a valid JWT
53-
description: >-
54-
This endpoints validates the username and password that must
55-
be supplied in the Authorization header (using HTTP Basic Authentication).
56-
If valid, a JSON Web Token will be generated and returned, that may be used
57-
to authenticate the user for subsequent requests.
55+
description: >-
56+
This endpoints validates the username and password that must be
57+
supplied in the Authorization header (using HTTP Basic Authentication).
58+
If valid, a JSON Web Token will be generated and returned, that may be
59+
used to authenticate the user for subsequent requests.
5860
operationId: authenticate
5961
parameters:
6062
- in: header
6163
name: Delphi-Authorization
62-
description: >-
63-
Valid JWT that autenticates the calling entity.
64+
description: Valid JWT that autenticates the calling entity.
6465
type: string
6566
required: true
6667
- in: header
6768
name: Authorization
68-
description: >-
69-
HTTP Basic Authentication following the schema 'Basic <User:Password>
70-
where the concatination of username and password is Base64-Encoded.
69+
description: >-
70+
HTTP Basic Authentication following the schema 'Basic
71+
<User:Password> where the concatination of username and password is
72+
Base64-Encoded.
7173
type: string
7274
required: true
7375
responses:
7476
'200':
75-
description: Supplied data is valid, a JWT is returned
77+
description: 'Supplied data is valid, a JWT is returned'
7678
schema:
7779
type: string
78-
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
80+
example: >-
81+
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
7982
'401':
80-
description: Unauthorized, invalid username / password supplied.
83+
description: 'Unauthorized, invalid username / password supplied.'
8184
/users/add:
8285
post:
8386
tags:
8487
- User Management
8588
summary: Adds a new users for the registry
8689
description: >-
87-
Adds a new user that is passed in the requests entity. The id of the user
88-
will be returned.
90+
Adds a new user that is passed in the requests entity. The id of the
91+
user will be returned.
8992
operationId: addUser
9093
parameters:
9194
- in: body
@@ -113,13 +116,70 @@ paths:
113116
- Component
114117
responses:
115118
'200':
116-
description: OK, user has been added, id is returned
119+
description: 'OK, user has been added, id is returned'
117120
schema:
118121
type: integer
119122
format: int64
120123
example: 42
121124
'400':
122-
description: Bad request, name already exists
125+
description: 'Bad request, name already exists'
126+
/users:
127+
get:
128+
tags:
129+
- User Management
130+
summary: Gets a list of all registered users
131+
description: >-
132+
Returns a list of all users registered at the registry. Requires caller to have admin privileges.
133+
operationId: allUsers
134+
responses:
135+
'200':
136+
description: "OK, list of users is being returned"
137+
schema:
138+
type: array
139+
items:
140+
$ref: '#/definitions/User'
141+
/users/{Id}:
142+
get:
143+
tags:
144+
- User Management
145+
summary: Gets the user with the specified id
146+
description: >-
147+
Returns the user with the specified id, if that id is present at the registry.
148+
operationId: retrieveUser
149+
parameters:
150+
- in: path
151+
name: Id
152+
required: true
153+
description: Id of the user to retrieve
154+
type: integer
155+
format: int64
156+
responses:
157+
'200':
158+
description: "OK, user is being returned"
159+
schema:
160+
$ref: '#/definitions/User'
161+
'404':
162+
description: "Id not found"
163+
/users/{Id}/remove:
164+
post:
165+
tags:
166+
- User Management
167+
summary: Removes the user with the specified id
168+
description: >-
169+
Removes the user with the specified id, if that id is present at the registry.
170+
operationId: removeUser
171+
parameters:
172+
- in: path
173+
name: Id
174+
required: true
175+
description: Id of the user to remove
176+
type: integer
177+
format: int64
178+
responses:
179+
'200':
180+
description: "OK, user has been removed"
181+
'404':
182+
description: "Id not found"
123183
/instances/register:
124184
post:
125185
tags:
@@ -657,13 +717,6 @@ paths:
657717
required: true
658718
type: integer
659719
format: int64
660-
- in: body
661-
name: ErrorLog
662-
description: An optional string explaining the failure
663-
required: false
664-
schema:
665-
type: string
666-
example: Something went wrong..
667720
responses:
668721
'200':
669722
description: Report successfully processed.
@@ -893,6 +946,24 @@ paths:
893946
'500':
894947
description: 'Internal server error, unknown operation result DESCRIPTION'
895948
definitions:
949+
User:
950+
type: object
951+
required:
952+
- userName
953+
- secret
954+
- userType
955+
properties:
956+
id:
957+
type: integer
958+
format: int64
959+
userName:
960+
type: string
961+
example: Ben
962+
userType:
963+
type: string
964+
enum:
965+
- User
966+
- Admin
896967
InstanceLink:
897968
type: object
898969
required:

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,35 @@ The Delphi registry is a server that provides access to all information and oper
1818
* Starting / Stopping / Pausing / Resuming / Deleting instances deployed on the docker host
1919
* Re-Assigning dependencies to instances (e.g. assigning a certain ElasticSearch instance to a Crawler)
2020

21+
## Quick Setup (Linux)
22+
Potentially there two different machines involved in the registry setup, the Docker host machine (*Docker Host*) and the machine the registry is hosted at (*Registry Host*). However, you can also use the same machine for hosting both applications.
23+
24+
On the *Docker Host*, execute the following steps:
25+
26+
1) Clone this repository to your machine
27+
2) Execute the setup script ```Setup/Delphi_install.sh```
28+
3) Deploy [ElasticSearch](https://www.elastic.co/de/products/elasticsearch) by executing ```docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.6.0```
29+
4) Expose your Docker HTTP api on port 9095
30+
* Execute ```sudo nano /lib/systemd/system/docker.service```
31+
* Change the line that starts with ```ExecStart``` to look like this: ```ExecStart=/usr/bin/dockerd -H fd:// -H=tcp://0.0.0.0:9095```
32+
* Save your changes and execute ```systemctl daemon-reload``` and ```sudo service docker restart```
33+
5) Note down the IP address of your machine in the LAN ( execute ```ifconfig``` )
34+
35+
36+
On the *Registry Host*, execute the following steps:
37+
38+
1) Clone this repository to your local machine
39+
2) Note down the IP address of your machine in the LAN ( execute ```ifconfig``` )
40+
3) Edit the configuration file located at ```src/main/scala/de/upb/cs/swt/delphi/instanceregistry/Configuration.scala```
41+
* Set ```traefikUri``` to ```http://<DOCKER-HOST-IP-HERE>:80```
42+
* Set ```defaultElasticSearchInstanceHost``` to ```http://<DOCKER-HOST-IP-HERE>```
43+
* Set ```uriInLocalNetwork``` to ```http://<REGISTRY-HOST-IP-HERE>:8087```
44+
* Set ```dockerUri``` to ```http://<DOCKER-HOST-IP-HERE>:9095```
45+
* Set ```jwtSecretKey``` to a secret password not known to anybody else
46+
4) Save your changes. Navigate to the root folder of the repository and execute the application by calling ```sbt run```
47+
48+
The setup of the registry is now complete. You should now be able to connect to the registry component at ```http://<REGISTRY-HOST-IP-HERE>:8087```. You can verify your setup by calling ```curl <REGISTRY-HOST-IP-HERE>:8087/configuration```, which should lead to a ```401 Unauthorized``` response. To find out more about how to authorize yourself, please have look at the **Authorization** section of this document.
49+
2150
## Requirements
2251
In order to compile or execute the instance registry, you must have the latest version of the *Scala Build Tool* (SBT) installed. You can get it [here](https://www.scala-sbt.org/).
2352

@@ -133,6 +162,8 @@ There are two ways of running the registry application. You can either run the a
133162
### Run the registry directly
134163
If you want to execute the registry directly on your local machine, simply go to the root folder of the repository and execute ```sbt run```. The application will stream all logging output to the terminal. You can terminate any time by pressing *RETURN*.
135164
### Run the registry in Docker
165+
Before creating an Docker image from the registry, make sure that all the network settings in the configuration file are set correctly in regards to the Docker networking infrastructure. Especially the settings ```dockerUri``` and ```uriInLocalNetwork``` are important. On Linux Docker Containers can connect to their host using the default Docker network gateway (```172.17.0.2```), on OSX the host has a defined DNS name (```host.docker.internal```).
166+
136167
For Windows users, to build a docker image containing the registry, go to the root folder of the repository and execute ```sbt docker:publishLocal```. This will build the application, create a docker image named ```delphi-registry:1.0.0-SNAPSHOT```, and register the image at your local docker registry.<br />
137168
For Linux users, the installation script mentioned in **Requirements** section will create docker image for registry named ```delphi-registry:1.0.0-SNAPSHOT```, and registers the image at your local docker registry.
138169

project/scalastyle-config.xml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<scalastyle>
2+
<name>Scalastyle standard configuration</name>
3+
<check level="warning" class="org.scalastyle.file.FileTabChecker" enabled="true"></check>
4+
<check level="warning" class="org.scalastyle.file.FileLengthChecker" enabled="true">
5+
<parameters>
6+
<parameter name="maxFileLength"><![CDATA[800]]></parameter>
7+
</parameters>
8+
</check>
9+
<check level="warning" class="org.scalastyle.file.HeaderMatchesChecker" enabled="true">
10+
<parameters>
11+
<parameter name="header"><![CDATA[// Copyright (C) 2018 The Delphi Team.
12+
// See the LICENCE file distributed with this work for additional
13+
// information regarding copyright ownership.
14+
//
15+
// Licensed under the Apache License, Version 2.0 (the "License");
16+
// you may not use this file except in compliance with the License.
17+
// You may obtain a copy of the License at
18+
//
19+
// http://www.apache.org/licenses/LICENSE-2.0
20+
//
21+
// Unless required by applicable law or agreed to in writing, software
22+
// distributed under the License is distributed on an "AS IS" BASIS,
23+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24+
// See the License for the specific language governing permissions and
25+
// limitations under the License.]]></parameter>
26+
</parameters>
27+
</check>
28+
<check level="warning" class="org.scalastyle.scalariform.SpacesAfterPlusChecker" enabled="true"></check>
29+
<check level="warning" class="org.scalastyle.file.WhitespaceEndOfLineChecker" enabled="true"></check>
30+
<check level="warning" class="org.scalastyle.scalariform.SpacesBeforePlusChecker" enabled="true"></check>
31+
<check level="warning" class="org.scalastyle.file.FileLineLengthChecker" enabled="true">
32+
<parameters>
33+
<parameter name="maxLineLength"><![CDATA[160]]></parameter>
34+
<parameter name="tabSize"><![CDATA[4]]></parameter>
35+
</parameters>
36+
</check>
37+
<check level="warning" class="org.scalastyle.scalariform.ClassNamesChecker" enabled="true">
38+
<parameters>
39+
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
40+
</parameters>
41+
</check>
42+
<check level="warning" class="org.scalastyle.scalariform.ObjectNamesChecker" enabled="true">
43+
<parameters>
44+
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
45+
</parameters>
46+
</check>
47+
<check level="warning" class="org.scalastyle.scalariform.PackageObjectNamesChecker" enabled="true">
48+
<parameters>
49+
<parameter name="regex"><![CDATA[^[a-z][A-Za-z]*$]]></parameter>
50+
</parameters>
51+
</check>
52+
<check level="warning" class="org.scalastyle.scalariform.EqualsHashCodeChecker" enabled="true"></check>
53+
<check level="warning" class="org.scalastyle.scalariform.IllegalImportsChecker" enabled="true">
54+
<parameters>
55+
<parameter name="illegalImports"><![CDATA[sun._,java.awt._]]></parameter>
56+
</parameters>
57+
</check>
58+
<check level="warning" class="org.scalastyle.scalariform.ParameterNumberChecker" enabled="true">
59+
<parameters>
60+
<parameter name="maxParameters"><![CDATA[8]]></parameter>
61+
</parameters>
62+
</check>
63+
<check level="warning" class="org.scalastyle.scalariform.MagicNumberChecker" enabled="false">
64+
<parameters>
65+
<parameter name="ignore"><![CDATA[-1,0,1,2,3]]></parameter>
66+
</parameters>
67+
</check>
68+
<check level="warning" class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker" enabled="true"></check>
69+
<check level="warning" class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker" enabled="true"></check>
70+
<check level="warning" class="org.scalastyle.scalariform.ReturnChecker" enabled="true"></check>
71+
<check level="warning" class="org.scalastyle.scalariform.NullChecker" enabled="true"></check>
72+
<check level="warning" class="org.scalastyle.scalariform.NoCloneChecker" enabled="true"></check>
73+
<check level="warning" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"></check>
74+
<check level="warning" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"></check>
75+
<check level="warning" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"></check>
76+
<check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
77+
<parameters>
78+
<parameter name="regex"><![CDATA[println]]></parameter>
79+
</parameters>
80+
</check>
81+
<check level="warning" class="org.scalastyle.scalariform.NumberOfTypesChecker" enabled="true">
82+
<parameters>
83+
<parameter name="maxTypes"><![CDATA[30]]></parameter>
84+
</parameters>
85+
</check>
86+
<check level="warning" class="org.scalastyle.scalariform.CyclomaticComplexityChecker" enabled="true">
87+
<parameters>
88+
<parameter name="maximum"><![CDATA[10]]></parameter>
89+
</parameters>
90+
</check>
91+
<check level="warning" class="org.scalastyle.scalariform.UppercaseLChecker" enabled="true"></check>
92+
<check level="warning" class="org.scalastyle.scalariform.SimplifyBooleanExpressionChecker" enabled="true"></check>
93+
<check level="warning" class="org.scalastyle.scalariform.IfBraceChecker" enabled="true">
94+
<parameters>
95+
<parameter name="singleLineAllowed"><![CDATA[true]]></parameter>
96+
<parameter name="doubleLineAllowed"><![CDATA[false]]></parameter>
97+
</parameters>
98+
</check>
99+
<check level="warning" class="org.scalastyle.scalariform.MethodLengthChecker" enabled="true">
100+
<parameters>
101+
<parameter name="maxLength"><![CDATA[50]]></parameter>
102+
</parameters>
103+
</check>
104+
<check level="warning" class="org.scalastyle.scalariform.MethodNamesChecker" enabled="true">
105+
<parameters>
106+
<parameter name="regex"><![CDATA[^[a-z][A-Za-z0-9]*$]]></parameter>
107+
</parameters>
108+
</check>
109+
<check level="warning" class="org.scalastyle.scalariform.NumberOfMethodsInTypeChecker" enabled="true">
110+
<parameters>
111+
<parameter name="maxMethods"><![CDATA[50]]></parameter>
112+
</parameters>
113+
</check>
114+
<check level="warning" class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker" enabled="true"></check>
115+
<check level="warning" class="org.scalastyle.file.NewLineAtEofChecker" enabled="true"></check>
116+
<check level="warning" class="org.scalastyle.file.NoNewLineAtEofChecker" enabled="false"></check>
117+
</scalastyle>
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1+
// Copyright (C) 2018 The Delphi Team.
2+
// See the LICENCE file distributed with this work for additional
3+
// information regarding copyright ownership.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
116
package de.upb.cs.swt.delphi.instanceregistry
217

318
import akka.actor.{ActorSystem, ExtendedActorSystem}
419
import akka.event.{BusLogging, LoggingAdapter}
520

621
trait AppLogging {
7-
def log(implicit system: ActorSystem): LoggingAdapter = new BusLogging(system.eventStream, this.getClass.getName, this.getClass, system.asInstanceOf[ExtendedActorSystem].logFilter)
22+
def log(implicit system: ActorSystem): LoggingAdapter = new BusLogging(
23+
system.eventStream,
24+
this.getClass.getName,
25+
this.getClass,
26+
system.asInstanceOf[ExtendedActorSystem].logFilter)
827
}

0 commit comments

Comments
 (0)