Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
630f2716
Commit
630f2716
authored
5 years ago
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added exception types
parent
c0b42137
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
464 additions
and
70 deletions
+464
-70
ToscaHelper.java
.../main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
+7
-6
MissingCredentialsException.java
...ne/drip/model/Exceptions/MissingCredentialsException.java
+29
-0
TypeExeption.java
...n/java/nl/uva/sne/drip/model/Exceptions/TypeExeption.java
+28
-0
Message.java
commons/src/main/java/nl/uva/sne/drip/model/Message.java
+18
-14
admin_cluster_role_binding.yaml
deployer/k8s/admin_cluster_role_binding.yaml
+13
-0
admin_service_account.yaml
deployer/k8s/admin_service_account.yaml
+7
-0
dashboard.yaml
deployer/k8s/dashboard.yaml
+304
-0
template-deployment.yaml
deployer/k8s/template-deployment.yaml
+1
-1
template-service.yaml
deployer/k8s/template-service.yaml
+1
-1
k8s_service.py
deployer/service/k8s_service.py
+26
-6
ProvisionerApiController.java
...in/java/nl/uva/sne/drip/api/ProvisionerApiController.java
+5
-4
DRIPCaller.java
manager/src/main/java/nl/uva/sne/drip/rpc/DRIPCaller.java
+0
-2
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+23
-31
Consumer.java
...r/src/main/java/nl/uva/sne/drip/provisioner/Consumer.java
+1
-1
requirements.txt
sure_tosca-flask-server/requirements.txt
+1
-0
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+0
-4
No files found.
commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
View file @
630f2716
...
...
@@ -29,6 +29,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.model.NodeTemplate
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
import
nl.uva.sne.drip.model.tosca.Credential
;
...
...
@@ -167,25 +168,25 @@ public class ToscaHelper {
}
}
public
String
getTopologyDomain
(
NodeTemplateMap
nodeTemplateMap
)
throws
Exc
eption
{
public
String
getTopologyDomain
(
NodeTemplateMap
nodeTemplateMap
)
throws
TypeEx
eption
{
NodeTemplate
nodeTemplate
=
nodeTemplateMap
.
getNodeTemplate
();
if
(
nodeTemplate
.
getType
().
equals
(
VM_TOPOLOGY
))
{
return
(
String
)
nodeTemplate
.
getProperties
().
get
(
"domain"
);
}
else
{
throw
new
Exc
eption
(
"NodeTemplateMap is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
nodeTemplate
.
getType
());
throw
new
TypeEx
eption
(
"NodeTemplateMap is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
nodeTemplate
.
getType
());
}
}
public
String
getTopologyProvider
(
NodeTemplateMap
nodeTemplateMap
)
throws
Exc
eption
{
public
String
getTopologyProvider
(
NodeTemplateMap
nodeTemplateMap
)
throws
TypeEx
eption
{
NodeTemplate
nodeTemplate
=
nodeTemplateMap
.
getNodeTemplate
();
if
(
nodeTemplate
.
getType
().
equals
(
VM_TOPOLOGY
))
{
return
(
String
)
nodeTemplate
.
getProperties
().
get
(
"provider"
);
}
else
{
throw
new
Exc
eption
(
"NodeTemplate is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
nodeTemplate
.
getType
());
throw
new
TypeEx
eption
(
"NodeTemplate is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
nodeTemplate
.
getType
());
}
}
public
NodeTemplateMap
setCredentialsInVMTopology
(
NodeTemplateMap
vmTopologyMap
,
Credential
credential
)
throws
Exception
{
public
NodeTemplateMap
setCredentialsInVMTopology
(
NodeTemplateMap
vmTopologyMap
,
Credential
credential
)
throws
TypeExeption
{
NodeTemplate
vmTopology
=
vmTopologyMap
.
getNodeTemplate
();
if
(
vmTopology
.
getType
().
equals
(
VM_TOPOLOGY
))
{
Map
<
String
,
Object
>
att
=
vmTopology
.
getAttributes
();
...
...
@@ -197,7 +198,7 @@ public class ToscaHelper {
vmTopologyMap
.
setNodeTemplate
(
vmTopology
);
return
vmTopologyMap
;
}
else
{
throw
new
Exc
eption
(
"NodeTemplate is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
vmTopology
.
getType
());
throw
new
TypeEx
eption
(
"NodeTemplate is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
vmTopology
.
getType
());
}
}
...
...
This diff is collapsed.
Click to expand it.
commons/src/main/java/nl/uva/sne/drip/model/Exceptions/MissingCredentialsException.java
0 → 100644
View file @
630f2716
/*
* Copyright 2019 S. Koulouzis
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
model
.
Exceptions
;
/**
*
* @author S. Koulouzis
*/
public
class
MissingCredentialsException
extends
Exception
{
public
MissingCredentialsException
(
String
string
)
{
super
(
string
);
}
}
This diff is collapsed.
Click to expand it.
commons/src/main/java/nl/uva/sne/drip/model/Exceptions/TypeExeption.java
0 → 100644
View file @
630f2716
/*
* Copyright 2019 S. Koulouzis
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
model
.
Exceptions
;
/**
*
* @author S. Koulouzis
*/
public
class
TypeExeption
extends
Exception
{
public
TypeExeption
(
String
string
)
{
super
(
string
);
}
}
This diff is collapsed.
Click to expand it.
commons/src/main/java/nl/uva/sne/drip/model/Message.java
View file @
630f2716
...
...
@@ -30,27 +30,35 @@ import javax.validation.constraints.NotNull;
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
Message
implements
Serializable
{
/**
* @return the exception
*/
public
Exception
getException
()
{
return
exception
;
}
/**
* @param exception the exception to set
*/
public
void
setException
(
Exception
exception
)
{
this
.
exception
=
exception
;
}
@NotNull
private
String
owner
;
@NotNull
private
Long
creationDate
;
private
List
<
MessageParameter
>
parameters
;
// private List<MessageParameter> parameters;
private
ToscaTemplate
toscaTemplate
;
private
Exception
exception
;
public
Long
getCreationDate
()
{
return
this
.
creationDate
;
}
public
void
setParameters
(
List
<
MessageParameter
>
parameters
)
{
this
.
parameters
=
parameters
;
}
public
List
<
MessageParameter
>
getParameters
()
{
return
this
.
parameters
;
}
public
void
setCreationDate
(
Long
creationDate
)
{
this
.
creationDate
=
creationDate
;
}
...
...
@@ -83,8 +91,4 @@ public class Message implements Serializable {
this
.
toscaTemplate
=
toscaTemplate
;
}
public
void
setExeption
(
Exception
exception
)
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
//To change body of generated methods, choose Tools | Templates.
}
}
This diff is collapsed.
Click to expand it.
deployer/k8s/admin_cluster_role_binding.yaml
0 → 100644
View file @
630f2716
apiVersion
:
rbac.authorization.k8s.io/v1
kind
:
ClusterRoleBinding
metadata
:
name
:
admin-user
roleRef
:
apiGroup
:
rbac.authorization.k8s.io
kind
:
ClusterRole
name
:
cluster-admin
subjects
:
-
kind
:
ServiceAccount
name
:
admin-user
#namespace: kubernetes-dashboard
namespace
:
default
This diff is collapsed.
Click to expand it.
deployer/k8s/admin_service_account.yaml
0 → 100644
View file @
630f2716
apiVersion
:
v1
kind
:
ServiceAccount
metadata
:
name
:
admin-user
#namespace: kubernetes-dashboard
namespace
:
default
#kube-system
This diff is collapsed.
Click to expand it.
deployer/k8s/dashboard.yaml
0 → 100644
View file @
630f2716
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion
:
v1
kind
:
Namespace
metadata
:
name
:
kubernetes-dashboard
---
apiVersion
:
v1
kind
:
ServiceAccount
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
name
:
kubernetes-dashboard
namespace
:
kubernetes-dashboard
---
kind
:
Service
apiVersion
:
v1
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
name
:
kubernetes-dashboard
namespace
:
kubernetes-dashboard
spec
:
type
:
NodePort
ports
:
-
port
:
8443
nodePort
:
30443
selector
:
k8s-app
:
kubernetes-dashboard
---
apiVersion
:
v1
kind
:
Secret
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
name
:
kubernetes-dashboard-certs
namespace
:
kubernetes-dashboard
type
:
Opaque
---
apiVersion
:
v1
kind
:
Secret
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
name
:
kubernetes-dashboard-csrf
namespace
:
kubernetes-dashboard
type
:
Opaque
data
:
csrf
:
"
"
---
apiVersion
:
v1
kind
:
Secret
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
name
:
kubernetes-dashboard-key-holder
namespace
:
kubernetes-dashboard
type
:
Opaque
---
kind
:
ConfigMap
apiVersion
:
v1
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
name
:
kubernetes-dashboard-settings
namespace
:
kubernetes-dashboard
---
kind
:
Role
apiVersion
:
rbac.authorization.k8s.io/v1
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
name
:
kubernetes-dashboard
namespace
:
kubernetes-dashboard
rules
:
# Allow Dashboard to get, update and delete Dashboard exclusive secrets.
-
apiGroups
:
[
"
"
]
resources
:
[
"
secrets"
]
resourceNames
:
[
"
kubernetes-dashboard-key-holder"
,
"
kubernetes-dashboard-certs"
,
"
kubernetes-dashboard-csrf"
]
verbs
:
[
"
get"
,
"
update"
,
"
delete"
]
# Allow Dashboard to get and update 'kubernetes-dashboard-settings' config map.
-
apiGroups
:
[
"
"
]
resources
:
[
"
configmaps"
]
resourceNames
:
[
"
kubernetes-dashboard-settings"
]
verbs
:
[
"
get"
,
"
update"
]
# Allow Dashboard to get metrics.
-
apiGroups
:
[
"
"
]
resources
:
[
"
services"
]
resourceNames
:
[
"
heapster"
,
"
dashboard-metrics-scraper"
]
verbs
:
[
"
proxy"
]
-
apiGroups
:
[
"
"
]
resources
:
[
"
services/proxy"
]
resourceNames
:
[
"
heapster"
,
"
http:heapster:"
,
"
https:heapster:"
,
"
dashboard-metrics-scraper"
,
"
http:dashboard-metrics-scraper"
]
verbs
:
[
"
get"
]
---
kind
:
ClusterRole
apiVersion
:
rbac.authorization.k8s.io/v1
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
name
:
kubernetes-dashboard
rules
:
# Allow Metrics Scraper to get metrics from the Metrics server
-
apiGroups
:
[
"
metrics.k8s.io"
]
resources
:
[
"
pods"
,
"
nodes"
]
verbs
:
[
"
get"
,
"
list"
,
"
watch"
]
---
apiVersion
:
rbac.authorization.k8s.io/v1
kind
:
RoleBinding
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
name
:
kubernetes-dashboard
namespace
:
kubernetes-dashboard
roleRef
:
apiGroup
:
rbac.authorization.k8s.io
kind
:
Role
name
:
kubernetes-dashboard
subjects
:
-
kind
:
ServiceAccount
name
:
kubernetes-dashboard
namespace
:
kubernetes-dashboard
---
apiVersion
:
rbac.authorization.k8s.io/v1
kind
:
ClusterRoleBinding
metadata
:
name
:
kubernetes-dashboard
roleRef
:
apiGroup
:
rbac.authorization.k8s.io
kind
:
ClusterRole
name
:
kubernetes-dashboard
subjects
:
-
kind
:
ServiceAccount
name
:
kubernetes-dashboard
namespace
:
kubernetes-dashboard
---
kind
:
Deployment
apiVersion
:
apps/v1
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
name
:
kubernetes-dashboard
namespace
:
kubernetes-dashboard
spec
:
replicas
:
1
revisionHistoryLimit
:
10
selector
:
matchLabels
:
k8s-app
:
kubernetes-dashboard
template
:
metadata
:
labels
:
k8s-app
:
kubernetes-dashboard
spec
:
containers
:
-
name
:
kubernetes-dashboard
image
:
kubernetesui/dashboard:v2.0.0-rc3
imagePullPolicy
:
Always
ports
:
-
containerPort
:
8443
protocol
:
TCP
args
:
-
--auto-generate-certificates
-
--namespace=kubernetes-dashboard
# Uncomment the following line to manually specify Kubernetes API server Host
# If not specified, Dashboard will attempt to auto discover the API server and connect
# to it. Uncomment only if the default does not work.
# - --apiserver-host=http://my-address:port
volumeMounts
:
-
name
:
kubernetes-dashboard-certs
mountPath
:
/certs
# Create on-disk volume to store exec logs
-
mountPath
:
/tmp
name
:
tmp-volume
livenessProbe
:
httpGet
:
scheme
:
HTTPS
path
:
/
port
:
8443
initialDelaySeconds
:
30
timeoutSeconds
:
30
securityContext
:
allowPrivilegeEscalation
:
false
readOnlyRootFilesystem
:
true
runAsUser
:
1001
runAsGroup
:
2001
volumes
:
-
name
:
kubernetes-dashboard-certs
secret
:
secretName
:
kubernetes-dashboard-certs
-
name
:
tmp-volume
emptyDir
:
{}
serviceAccountName
:
kubernetes-dashboard
nodeSelector
:
"
beta.kubernetes.io/os"
:
linux
# Comment the following tolerations if Dashboard must not be deployed on master
tolerations
:
-
key
:
node-role.kubernetes.io/master
effect
:
NoSchedule
---
kind
:
Service
apiVersion
:
v1
metadata
:
labels
:
k8s-app
:
dashboard-metrics-scraper
name
:
dashboard-metrics-scraper
namespace
:
kubernetes-dashboard
spec
:
ports
:
-
port
:
8000
targetPort
:
8000
selector
:
k8s-app
:
dashboard-metrics-scraper
---
kind
:
Deployment
apiVersion
:
apps/v1
metadata
:
labels
:
k8s-app
:
dashboard-metrics-scraper
name
:
dashboard-metrics-scraper
namespace
:
kubernetes-dashboard
spec
:
replicas
:
1
revisionHistoryLimit
:
10
selector
:
matchLabels
:
k8s-app
:
dashboard-metrics-scraper
template
:
metadata
:
labels
:
k8s-app
:
dashboard-metrics-scraper
annotations
:
seccomp.security.alpha.kubernetes.io/pod
:
'
runtime/default'
spec
:
containers
:
-
name
:
dashboard-metrics-scraper
image
:
kubernetesui/metrics-scraper:v1.0.3
ports
:
-
containerPort
:
8000
protocol
:
TCP
livenessProbe
:
httpGet
:
scheme
:
HTTP
path
:
/
port
:
8000
initialDelaySeconds
:
30
timeoutSeconds
:
30
volumeMounts
:
-
mountPath
:
/tmp
name
:
tmp-volume
securityContext
:
allowPrivilegeEscalation
:
false
readOnlyRootFilesystem
:
true
runAsUser
:
1001
runAsGroup
:
2001
serviceAccountName
:
kubernetes-dashboard
nodeSelector
:
"
beta.kubernetes.io/os"
:
linux
# Comment the following tolerations if Dashboard must not be deployed on master
tolerations
:
-
key
:
node-role.kubernetes.io/master
effect
:
NoSchedule
volumes
:
-
name
:
tmp-volume
emptyDir
:
{}
This diff is collapsed.
Click to expand it.
deployer/k8s/template-deployment.yaml
View file @
630f2716
...
...
@@ -4,7 +4,7 @@ metadata:
labels
:
app
:
NAME
name
:
NAME
namespace
:
application
namespace
:
default
spec
:
selector
:
matchLabels
:
...
...
This diff is collapsed.
Click to expand it.
deployer/k8s/template-service.yaml
View file @
630f2716
...
...
@@ -4,7 +4,7 @@ metadata:
labels
:
app
:
NAME
name
:
NAME
namespace
:
application
namespace
:
default
spec
:
type
:
NodePort
ports
:
...
...
This diff is collapsed.
Click to expand it.
deployer/service/k8s_service.py
View file @
630f2716
...
...
@@ -33,8 +33,8 @@ def create_service_definition(docker_name, docker):
k8s_service
[
'metadata'
][
'labels'
][
'app'
]
=
docker_name
k8s_service
[
'metadata'
][
'name'
]
=
docker_name
docker_ports
=
docker
[
docker_name
][
'properties'
][
'ports'
][
0
]
.
split
(
':'
)
k8s_service
[
'spec'
][
'ports'
][
0
][
'port'
]
=
docker_ports
[
1
]
k8s_service
[
'spec'
][
'ports'
][
0
][
'nodePort'
]
=
docker_ports
[
0
]
k8s_service
[
'spec'
][
'ports'
][
0
][
'port'
]
=
int
(
docker_ports
[
1
])
k8s_service
[
'spec'
][
'ports'
][
0
][
'nodePort'
]
=
int
(
docker_ports
[
0
])
k8s_service
[
'spec'
][
'selector'
][
'app'
]
=
docker_name
# k8s_service = {'apiVersion': 'v1', 'kind': 'Service'}
...
...
@@ -61,7 +61,7 @@ def create_deployment_definition(docker_name, docker):
deployment
[
'spec'
][
'selector'
][
'matchLabels'
][
'app'
]
=
docker_name
deployment
[
'spec'
][
'template'
][
'metadata'
][
'labels'
][
'app'
]
=
docker_name
deployment
[
'spec'
][
'template'
][
'spec'
][
'containers'
][
0
][
'image'
]
=
docker
[
docker_name
][
'artifacts'
][
'image'
][
'file'
]
deployment
[
'spec'
][
'template'
][
'spec'
][
'containers'
][
0
][
'ports'
][
0
][
'containerPort'
]
=
docker_ports
[
1
]
deployment
[
'spec'
][
'template'
][
'spec'
][
'containers'
][
0
][
'ports'
][
0
][
'containerPort'
]
=
int
(
docker_ports
[
1
])
deployment
[
'spec'
][
'template'
][
'spec'
][
'containers'
][
0
][
'name'
]
=
docker_name
if
docker
[
docker_name
][
'properties'
]
and
'environment'
in
docker
[
docker_name
][
'properties'
]:
env_list
=
[]
...
...
@@ -114,7 +114,7 @@ def get_k8s_definitions(dockers):
def
create_pip_task
():
pip_task
=
{
'name'
:
'install
kubernet
es'
}
pip_task
=
{
'name'
:
'install
pip modul
es'
}
modules
=
[
'setuptools'
,
'kubernetes'
,
'openshift'
]
pip
=
{
'name'
:
modules
}
pip_task
[
'pip'
]
=
pip
...
...
@@ -142,6 +142,21 @@ def create_namespace_task():
return
task
def
create_dashboard_task
():
task
=
{
'name'
:
'create dashboard'
}
k8s
=
{
'src'
:
'/tmp/recommended.yaml'
,
'state'
:
'present'
}
task
[
'k8s'
]
=
k8s
return
task
def
create_download_dashboard_task
():
task
=
{
'name'
:
'Download dashboard'
}
get_url
=
{
'url'
:
'https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-rc3/aio/deploy/recommended.yaml'
,
'dest'
:
'/tmp/recommended.yaml'
}
task
[
'get_url'
]
=
get_url
return
task
def
write_ansible_k8s_files
(
tosca_template_json
,
tmp_path
):
dockers
=
get_dockers
(
tosca_template_json
)
k8s_definitions
=
get_k8s_definitions
(
dockers
)
...
...
@@ -152,9 +167,14 @@ def write_ansible_k8s_files(tosca_template_json, tmp_path):
pip_task
=
create_pip_task
()
tasks
.
append
(
pip_task
)
namespace_task
=
create_namespace_task
()
tasks
.
append
(
namespace_task
)
# namespace_task = create_namespace_task()
# tasks.append(namespace_task)
download_dashboard_task
=
create_download_dashboard_task
()
tasks
.
append
(
download_dashboard_task
)
dashboard_task
=
create_dashboard_task
()
tasks
.
append
(
dashboard_task
)
for
services_def
in
services
:
task
=
create_service_task
(
i
,
services_def
)
i
+=
1
...
...
This diff is collapsed.
Click to expand it.
manager/src/main/java/nl/uva/sne/drip/api/ProvisionerApiController.java
View file @
630f2716
...
...
@@ -2,6 +2,8 @@ package nl.uva.sne.drip.api;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
io.swagger.annotations.*
;
import
java.io.IOException
;
import
java.util.concurrent.TimeoutException
;
import
java.util.logging.Level
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -10,6 +12,8 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
javax.servlet.http.HttpServletRequest
;
import
nl.uva.sne.drip.model.Exceptions.MissingCredentialsException
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.service.DRIPService
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -48,10 +52,7 @@ public class ProvisionerApiController implements ProvisionerApi {
dripService
.
setRequestQeueName
(
queueName
);
String
planedYemplateId
=
dripService
.
provision
(
id
);
return
new
ResponseEntity
<>(
planedYemplateId
,
HttpStatus
.
OK
);
}
catch
(
ApiException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
ProvisionerApiController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
catch
(
Exception
ex
)
{
}
catch
(
ApiException
|
MissingCredentialsException
|
TypeExeption
|
IOException
|
TimeoutException
|
InterruptedException
|
NotFoundException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
ProvisionerApiController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
...
...
This diff is collapsed.
Click to expand it.
manager/src/main/java/nl/uva/sne/drip/rpc/DRIPCaller.java
View file @
630f2716
...
...
@@ -16,8 +16,6 @@ import java.util.concurrent.TimeoutException;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.model.Message
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
/*
...
...
This diff is collapsed.
Click to expand it.
manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
630f2716
...
...
@@ -15,6 +15,8 @@ import java.util.logging.Level;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.api.NotFoundException
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.model.Exceptions.MissingCredentialsException
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.model.Message
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
import
nl.uva.sne.drip.model.tosca.Credential
;
...
...
@@ -49,31 +51,21 @@ public class DRIPService {
ProvisionerService
provisionerService
;
private
static
final
String
OPERATION_PROVISION
=
"provision"
;
private
String
execute
(
ToscaTemplate
toscaTemplate
)
throws
JsonProcessingException
,
ApiException
,
Exception
{
try
{
caller
.
init
();
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
INFO
,
"toscaTemplate:\n{0}"
,
toscaTemplate
);
Message
message
=
new
Message
();
message
.
setOwner
(
"user"
);
message
.
setCreationDate
(
System
.
currentTimeMillis
());
message
.
setToscaTemplate
(
toscaTemplate
);
caller
.
setRequestQeueName
(
requestQeueName
);
Message
plannerResponse
=
caller
.
call
(
message
);
ToscaTemplate
plannedToscaTemplate
=
plannerResponse
.
getToscaTemplate
();
return
toscaTemplateService
.
save
(
plannedToscaTemplate
);
}
catch
(
IOException
|
TimeoutException
|
InterruptedException
ex
)
{
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
finally
{
try
{
caller
.
close
();
}
catch
(
IOException
|
TimeoutException
ex
)
{
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
return
null
;
private
String
execute
(
ToscaTemplate
toscaTemplate
)
throws
JsonProcessingException
,
ApiException
,
IOException
,
TimeoutException
,
InterruptedException
{
caller
.
init
();
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
INFO
,
"toscaTemplate:\n{0}"
,
toscaTemplate
);
Message
message
=
new
Message
();
message
.
setOwner
(
"user"
);
message
.
setCreationDate
(
System
.
currentTimeMillis
());
message
.
setToscaTemplate
(
toscaTemplate
);
caller
.
setRequestQeueName
(
requestQeueName
);
Message
plannerResponse
=
caller
.
call
(
message
);
ToscaTemplate
plannedToscaTemplate
=
plannerResponse
.
getToscaTemplate
();
caller
.
close
();
return
toscaTemplateService
.
save
(
plannedToscaTemplate
);
}
/**
...
...
@@ -94,7 +86,7 @@ public class DRIPService {
return
credentials
.
get
(
0
);
}
private
ToscaTemplate
addCredentials
(
ToscaTemplate
toscaTemplate
)
throws
IOException
,
JsonProcessingException
,
ApiException
,
Exc
eption
{
private
ToscaTemplate
addCredentials
(
ToscaTemplate
toscaTemplate
)
throws
MissingCredentialsException
,
ApiException
,
TypeEx
eption
{
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
List
<
Credential
>
credentials
=
null
;
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologies
)
{
...
...
@@ -102,7 +94,7 @@ public class DRIPService {
if
(
needsCredentials
(
provider
))
{
credentials
=
credentialService
.
findByProvider
(
provider
);
if
(
credentials
==
null
||
credentials
.
size
()
<=
0
)
{
throw
new
Exception
(
"Provider: "
+
provider
+
" needs credentials but non clould be found"
);
throw
new
MissingCredentials
Exception
(
"Provider: "
+
provider
+
" needs credentials but non clould be found"
);
}
else
{
Credential
credential
=
getBestCredential
(
credentials
);
vmTopologyMap
=
helper
.
setCredentialsInVMTopology
(
vmTopologyMap
,
credential
);
...
...
@@ -120,14 +112,14 @@ public class DRIPService {
return
execute
(
toscaTemplate
);
}
public
String
provision
(
String
id
)
throws
JsonProcessingException
,
NotFoundException
,
IOException
,
Exception
{
public
String
provision
(
String
id
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
IOException
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFound
Exception
{
ToscaTemplate
toscaTemplate
=
initExecution
(
id
);
toscaTemplate
=
addCredentials
(
toscaTemplate
);
toscaTemplate
=
setProvisionOperation
(
toscaTemplate
,
OPERATION_PROVISION
);
return
execute
(
toscaTemplate
);
}
private
ToscaTemplate
setProvisionOperation
(
ToscaTemplate
toscaTemplate
,
String
operation
)
throws
IOException
,
JsonProcessingException
,
ApiException
,
Exception
{
private
ToscaTemplate
setProvisionOperation
(
ToscaTemplate
toscaTemplate
,
String
operation
)
throws
IOException
,
JsonProcessingException
,
ApiException
{
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologies
)
{
Map
<
String
,
Object
>
provisionerInterface
=
helper
.
getProvisionerInterfaceFromVMTopology
(
vmTopologyMap
);
...
...
@@ -160,10 +152,10 @@ public class DRIPService {
private
ToscaTemplate
initExecution
(
String
id
)
throws
JsonProcessingException
,
NotFoundException
,
IOException
,
ApiException
{
String
ymlToscaTemplate
=
toscaTemplateService
.
findByID
(
id
);
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
FINE
,
"Found ToscaTemplate with id: "
+
id
);
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
FINE
,
"Found ToscaTemplate with id: {0}"
,
id
);
ToscaTemplate
toscaTemplate
=
toscaTemplateService
.
getYaml2ToscaTemplate
(
ymlToscaTemplate
);
helper
.
uploadToscaTemplate
(
toscaTemplate
);
return
toscaTemplate
;
}
...
...
This diff is collapsed.
Click to expand it.
provisioner/src/main/java/nl/uva/sne/drip/provisioner/Consumer.java
View file @
630f2716
...
...
@@ -100,7 +100,7 @@ public class Consumer extends DefaultConsumer {
private
Message
handleException
(
Exception
ex
)
{
Message
errorMessage
=
new
Message
();
errorMessage
.
setCreationDate
(
System
.
currentTimeMillis
());
errorMessage
.
setEx
eption
(
new
ApiException
(
ex
)
);
errorMessage
.
setEx
ception
(
ex
);
return
errorMessage
;
}
...
...
This diff is collapsed.
Click to expand it.
sure_tosca-flask-server/requirements.txt
View file @
630f2716
PyYAML
wheel==0.33.6
connexion == 2.4.0
python-dateutil == 2.8.0
...
...
This diff is collapsed.
Click to expand it.
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
630f2716
...
...
@@ -87,7 +87,6 @@ def get_tosca_template(tosca_template_dict):
def
get_tosca_template_dict_by_id
(
id
):
tosca_template_dict
=
tosca_templates_db
.
get
(
doc_id
=
int
(
id
))
return
tosca_template_dict
...
...
@@ -119,9 +118,6 @@ def save(file):
doc_id
=
tosca_templates_db
.
insert
(
dictionary
)
# tosca_templates_db.close()
logger
.
info
(
"Returning doc_id: "
+
str
(
doc_id
))
end
=
time
.
time
()
elapsed
=
end
-
start
logger
.
info
(
"Time elapsed: "
+
str
(
elapsed
))
return
doc_id
# except Exception as e:
# logger.error(str(e))
...
...
This diff is collapsed.
Click to expand it.
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