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
a147cca7
Commit
a147cca7
authored
Mar 08, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented user configure ec2 API v0
parent
b5b2a867
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
170 additions
and
150 deletions
+170
-150
CloudConfigurationController0.java
...a/sne/drip/api/v0/rest/CloudConfigurationController0.java
+83
-0
PlannerController0.java
.../java/nl/uva/sne/drip/api/v0/rest/PlannerController0.java
+3
-22
UserController0.java
...ain/java/nl/uva/sne/drip/api/v0/rest/UserController0.java
+6
-13
Configure.java
...main/java/nl/uva/sne/drip/commons/v0/types/Configure.java
+37
-0
LoginKey0.java
...main/java/nl/uva/sne/drip/commons/v0/types/LoginKey0.java
+33
-0
Plan.java
.../src/main/java/nl/uva/sne/drip/commons/v0/types/Plan.java
+3
-44
Register.java
.../main/java/nl/uva/sne/drip/commons/v0/types/Register.java
+2
-34
Result.java
...rc/main/java/nl/uva/sne/drip/commons/v0/types/Result.java
+3
-37
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/v0/rest/CloudConfigurationController0.java
0 → 100644
View file @
a147cca7
/*
* Copyright 2017 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
.
api
.
v0
.
rest
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.annotation.security.RolesAllowed
;
import
nl.uva.sne.drip.commons.v1.types.CloudCredentials
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
nl.uva.sne.drip.api.dao.CloudCredentialsDao
;
import
nl.uva.sne.drip.api.exception.NullKeyException
;
import
nl.uva.sne.drip.api.exception.NullKeyIDException
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.commons.v0.types.Configure
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
*
* This controller is responsible for handling cloud credentials used by the
* provisoner to request for resources (VMs).
*
* @author S. Koulouzis
*/
@RestController
@RequestMapping
(
"/user/v0.0/switch/account/configure/"
)
@Component
public
class
CloudConfigurationController0
{
@Autowired
private
CloudCredentialsDao
cloudCredentialsDao
;
@RequestMapping
(
value
=
"/ec2"
,
method
=
RequestMethod
.
POST
,
consumes
=
MediaType
.
TEXT_XML_VALUE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
String
postConf
(
@RequestBody
Configure
configure
)
{
if
(
configure
.
key
==
null
)
{
throw
new
NullKeyException
();
}
if
(
configure
.
keyid
==
null
)
{
throw
new
NullKeyIDException
();
}
CloudCredentials
cloudCredentials
=
new
CloudCredentials
();
cloudCredentials
.
setKeyIdAlias
(
configure
.
keyid
);
cloudCredentials
.
setKey
(
configure
.
key
);
List
<
nl
.
uva
.
sne
.
drip
.
commons
.
v1
.
types
.
LoginKey
>
loginKeys
=
new
ArrayList
<>();
for
(
nl
.
uva
.
sne
.
drip
.
commons
.
v0
.
types
.
LoginKey0
key0
:
configure
.
loginKey
)
{
nl
.
uva
.
sne
.
drip
.
commons
.
v1
.
types
.
LoginKey
key1
=
new
nl
.
uva
.
sne
.
drip
.
commons
.
v1
.
types
.
LoginKey
();
key1
.
setKey
(
key0
.
content
);
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"domain_name"
,
key0
.
domain_name
);
key1
.
setAttributes
(
attributes
);
loginKeys
.
add
(
key1
);
}
cloudCredentials
.
setLogineKeys
(
loginKeys
);
cloudCredentials
.
setCloudProviderName
(
"ec2"
);
cloudCredentialsDao
.
save
(
cloudCredentials
);
return
"Success: "
+
cloudCredentials
.
getId
();
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/v0/rest/PlannerController0.java
View file @
a147cca7
...
...
@@ -63,14 +63,14 @@ public class PlannerController0 {
Result
plan
(
@RequestBody
Plan
plan0
)
{
try
{
String
yaml
=
plan0
.
getFile
()
;
String
yaml
=
plan0
.
file
;
yaml
=
yaml
.
replaceAll
(
"\\\\n"
,
"\n"
);
String
id
=
toscaService
.
save
(
yaml
,
null
);
nl
.
uva
.
sne
.
drip
.
commons
.
v1
.
types
.
Plan
plan1
=
plannerService
.
getPlan
(
id
);
Result
r
=
new
Result
();
r
.
setInfo
(
"INFO"
);
r
.
s
etStatus
(
Result
.
status
.
Success
);
r
.
info
=
(
"INFO"
);
r
.
s
tatus
=
(
"Success"
);
List
<
File
>
files
=
new
ArrayList
<>();
File
e
=
new
File
();
e
.
level
=
String
.
valueOf
(
plan1
.
getLevel
());
...
...
@@ -109,23 +109,4 @@ public class PlannerController0 {
}
return
null
;
}
@RequestMapping
(
value
=
"/get"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
TEXT_XML_VALUE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
Result
plan
()
{
Result
r
=
new
Result
();
r
.
setInfo
(
"INFO"
);
r
.
setStatus
(
Result
.
status
.
Success
);
List
<
File
>
files
=
new
ArrayList
<>();
File
e
=
new
File
();
e
.
level
=
"0"
;
e
.
name
=
"Planned_tosca_file_a.yaml"
;
e
.
content
=
"$Planned_tosca_file_a"
;
files
.
add
(
e
);
r
.
file
=
files
;
return
r
;
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/v0/rest/UserController0.java
View file @
a147cca7
...
...
@@ -15,20 +15,13 @@
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
v0
.
rest
;
import
nl.uva.sne.drip.api.v1.rest.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
javax.annotation.security.RolesAllowed
;
import
nl.uva.sne.drip.api.exception.PasswordNullException
;
import
nl.uva.sne.drip.api.exception.UserExistsException
;
import
nl.uva.sne.drip.api.exception.UserNotFoundException
;
import
nl.uva.sne.drip.api.exception.UserNullException
;
import
nl.uva.sne.drip.commons.v1.types.User
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
...
@@ -57,19 +50,19 @@ public class UserController0 {
@RolesAllowed
({
UserService
.
ADMIN
})
public
@ResponseBody
String
register
(
@RequestBody
Register
register
)
{
if
(
register
.
getUser
()
==
null
)
{
if
(
register
.
user
==
null
)
{
throw
new
UserNullException
();
}
if
(
register
.
getPwd
()
==
null
)
{
if
(
register
.
pwd
==
null
)
{
throw
new
PasswordNullException
();
}
UserDetails
registeredUser
=
service
.
loadUserByUsername
(
register
.
getUser
()
);
UserDetails
registeredUser
=
service
.
loadUserByUsername
(
register
.
user
);
if
(
registeredUser
!=
null
)
{
throw
new
UserExistsException
(
"Username "
+
register
.
getUser
()
+
" is used"
);
throw
new
UserExistsException
(
"Username "
+
register
.
user
+
" is used"
);
}
User
user
=
new
User
();
user
.
setUsername
(
register
.
getUser
()
);
user
.
setPassword
(
new
BCryptPasswordEncoder
().
encode
(
register
.
getPwd
()
));
user
.
setUsername
(
register
.
user
);
user
.
setPassword
(
new
BCryptPasswordEncoder
().
encode
(
register
.
pwd
));
service
.
getDao
().
save
(
user
);
return
"Success: "
+
user
.
getId
();
}
...
...
drip-api/src/main/java/nl/uva/sne/drip/commons/v0/types/Configure.java
0 → 100644
View file @
a147cca7
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* 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
.
commons
.
v0
.
types
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public
class
Configure
{
public
String
user
;
public
String
pwd
;
public
String
keyid
;
public
String
key
;
@XmlElement
(
name
=
"loginKey"
)
public
List
<
LoginKey0
>
loginKey
;
}
drip-api/src/main/java/nl/uva/sne/drip/commons/v0/types/LoginKey0.java
0 → 100644
View file @
a147cca7
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* 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
.
commons
.
v0
.
types
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlValue
;
/**
*
* @author S. Koulouzis
*/
public
class
LoginKey0
{
@XmlAttribute
(
name
=
"domain_name"
)
public
String
domain_name
;
@XmlValue
public
String
content
;
}
drip-api/src/main/java/nl/uva/sne/drip/commons/v0/types/Plan.java
View file @
a147cca7
...
...
@@ -28,64 +28,23 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public
class
Plan
implements
Serializable
{
private
String
user
;
private
String
pwd
;
private
String
file
;
/**
* Not used. It's only there for backwords compatibility
*
* @return the user
*/
@DocumentationExample
(
"user"
)
public
String
getUser
()
{
return
user
;
}
/**
* @param user the user to set
*/
public
void
setUser
(
String
user
)
{
this
.
user
=
user
;
}
public
String
user
;
/**
* Not used. It's only there for backwords compatibility
*
* @return the pwd
*/
@DocumentationExample
(
"123"
)
public
String
getPwd
()
{
return
pwd
;
}
/**
* The password
*
* @param pwd the pwd to set
*/
public
void
setPwd
(
String
pwd
)
{
this
.
pwd
=
pwd
;
}
public
String
pwd
;
/**
* The contents of the TOSCA description
*
* @return the file
*/
@DocumentationExample
(
"tosca_definitions_version: tosca_simple_yaml_1_0\\n\\n\\ndescription: example file for infrastructure planner\\n\\n\\nrepositories:\\n MOG_docker_hub: \\n description: MOG project’s code repository in GitHub\\n url: https://github.com/switch-project/mog\\n credential:\\n protocol: xauth\\n token_type: X-Auth-Token\\n # token encoded in Base64\\n token: 604bbe45ac7143a79e14f3158df67091\\n\\n\\nartifact_types:\\n tosca.artifacts.Deployment.Image.Container.Docker:\\n derived_from: tosca.artifacts.Deployment.Image\\n\\n\\ndata_types:\\n Switch.datatypes.QoS.AppComponent:\\n derived_from: tosca.datatypes.Root\\n properties:\\n response_time:\\n type: string\\n\\n Switch.datatypes.Application.Connection.EndPoint:\\n derived_from: tosca.datatypes.Root\\n properties:\\n address:\\n type: string\\n component_name:\\n type: string\\n netmask:\\n type: string\\n port_name:\\n type: string\\n\\n Switch.datatypes.Application.Connection.Multicast:\\n derived_from: tosca.datatypes.Root\\n properties:\\n multicastAddrIP:\\n type: string\\n multicastAddrPort:\\n type: integer\\n\\n Switch.datatypes.Network.EndPoint:\\n derived_from: tosca.datatypes.Root\\n properties:\\n address:\\n type: string\\n host_name:\\n type: string\\n netmask:\\n type: string\\n port_name:\\n type: string\\n\\n Switch.datatypes.Network.Multicast:\\n derived_from: tosca.datatypes.Root\\n properties:\\n multicastAddrIP:\\n type: string\\n multicastAddrPort:\\n type: integer\\n\\n\\nnode_types:\\n\\n Switch.nodes.Application.Container.Docker:\\n derived_from: tosca.nodes.Container.Application\\n properties:\\n QoS:\\n type: Switch.datatypes.QoS.AppComponent\\n artifacts:\\n docker_image:\\n type: tosca.artifacts.Deployment.Image.Container.Docker\\n interfaces:\\n Standard:\\n create:\\n inputs:\\n command:\\n type: string\\n exported_ports:\\n type: list\\n entry_schema:\\n type: string\\n port_bindings:\\n type: list\\n entry_schema:\\n type: string\\n\\n Switch.nodes.Application.Container.Docker.MOG.InputDistributor:\\n derived_from: Switch.nodes.Application.Container.Docker\\n artifacts:\\n docker_image:\\n type: tosca.artifacts.Deployment.Image.Container.Docker\\n file: \"mogswitch/InputDistributor:1.0\"\\n repository: MOG_docker_hub\\n properties:\\n inPort: \\n type: integer\\n waitingTime:\\n type: integer\\n multicastAddrIP:\\n type: string\\n multicastAddrPort:\\n type: integer\\n videoWidth:\\n type: integer\\n videoHeight:\\n type: integer\\n\\n Switch.nodes.Application.Container.Docker.MOG.ProxyTranscoder:\\n derived_from: Switch.nodes.Application.Container.Docker \\n artifacts:\\n docker_image:\\n type: tosca.artifacts.Deployment.Image.Container.Docker\\n file: \"mogswitch/ProxyTranscoder:1.0\"\\n repository: MOG_docker_hub\\n properties:\\n multicastAddrIP: \\n type: string\\n multicastAddrPort:\\n type: integer\\n videoWidth:\\n type: integer\\n videoHeight:\\n type: integer\\n\\n Switch.nodes.Application.Connection:\\n derived_from: tosca.nodes.Root \\n properties:\\n source:\\n type: Switch.datatypes.Application.Connection.EndPoint\\n target:\\n type: Switch.datatypes.Application.Connection.EndPoint\\n bandwidth:\\n type: string\\n latency: \\n type: string\\n jitter: \\n type: string\\n multicast:\\n type: Switch.datatypes.Application.Connection.Multicast\\n\\n Switch.nodes.Compute:\\n derived_from: tosca.nodes.Compute\\n properties:\\n OStype:\\n type: string\\n nodetype:\\n type: string\\n domain:\\n type: string\\n public_address:\\n type: string\\n \n"
+
" ethernet_port:\\n type: list\\n entry_schema:\\n type: tosca.datatypes.network.NetworkInfo\\n script:\\n type: string\\n installation:\\n type: string\\n ssh_credential:\\n type: tosca.datatypes.Credential\\n\\n Switch.nodes.Network:\\n derived_from: tosca.nodes.network.Network\\n properties:\\n bandwidth:\\n type: string\\n latency:\\n type: string\\n jitter:\\n type: string\\n source:\\n type: Switch.datatypes.Network.EndPoint\\n target:\\n type: Switch.datatypes.Network.EndPoint\\n multicast:\\n type: Switch.datatypes.Network.Multicast\\n\\n\\ntopology_template:\\n \\n node_templates:\\n 2d13d708e3a9441ab8336ce874e08dd1:\\n type: Switch.nodes.Application.Container.Docker.MOG.InputDistributor\\n artifacts:\\n docker_image:\\n file: \"mogswitch/InputDistributor:1.0\"\\n type: tosca.artifacts.Deployment.Image.Container.Docker\\n repository: MOG_docker_hub\\n properties:\\n QoS:\\n response_time: 30ms\\n inPort: 2000\\n waitingTime: 5\\n multicastAddrIP: 255.2.2.0\\n multicastAddrPort: 3000\\n videoWidth: 176\\n videoHeight: 100\\n interfaces:\\n Standard:\\n create:\\n implementation: docker_image\\n inputs:\\n command: InputDistributor\\n exported_ports:\\n - 2000\\n port_bindings:\\n - \"2000:2000\"\\n - \"3000:3000\"\\n\\n 8fcc1788d9ee462c826572c79fdb2a6a:\\n type: Switch.nodes.Application.Container.Docker.MOG.ProxyTranscoder\\n artifacts:\\n docker_image:\\n file: \"mogswitch/ProxyTranscoder:1.0\"\\n type: tosca.artifacts.Deployment.Image.Container.Docker\\n repository: MOG_docker_hub\\n properties:\\n QoS:\\n response_time: 30ms\\n multicastAddrIP: 255.2.2.0\\n multicastAddrPort: 3000\\n videoWidth: 176\\n videoHeight: 100\\n interfaces:\\n Standard:\\n create:\\n implementation: docker_image\\n inputs:\\n command: ProxyTranscoder\\n exported_ports:\\n - 80\\n port_bindings:\\n - \"8080:80\"\\n\\n 5e0add703c8a43938a39301f572e46c0:\\n type: Switch.nodes.Application.Connection\\n properties:\\n source:\\n address: 192.168.21.11\\n component_name: 2d13d708e3a9441ab8336ce874e08dd1\\n netmask: 255.255.255.0\\n port_name: \"inputDistributor_out\"\\n target:\\n address: 192.168.21.12\\n component_name: 8fcc1788d9ee462c826572c79fdb2a6a\\n netmask: 255.255.255.0\\n port_name: \"proxyTranscoder_in\"\\n latency: 30ms\\n bandwidth: 130MB/s\\n jitter: 500ms\\n multicast:\\n multicastAddrIP: 255.2.2.0\\n multicastAddrPort: 3000\\n"
)
public
String
getFile
()
{
return
file
;
}
/**
* @param file the file to set
*/
public
void
setFile
(
String
file
)
{
this
.
file
=
file
;
}
public
String
file
;
}
drip-api/src/main/java/nl/uva/sne/drip/commons/v0/types/Register.java
View file @
a147cca7
...
...
@@ -15,10 +15,6 @@
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
v0
.
types
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlRootElement
;
/**
...
...
@@ -28,35 +24,7 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public
class
Register
{
private
String
user
;
private
String
pwd
;
/**
* @return the user
*/
public
String
getUser
()
{
return
user
;
}
/**
* @param user the user to set
*/
public
void
setUser
(
String
user
)
{
this
.
user
=
user
;
}
/**
* @return the pwd
*/
public
String
getPwd
()
{
return
pwd
;
}
/**
* @param pwd the pwd to set
*/
public
void
setPwd
(
String
pwd
)
{
this
.
pwd
=
pwd
;
}
public
String
user
;
public
String
pwd
;
}
drip-api/src/main/java/nl/uva/sne/drip/commons/v0/types/Result.java
View file @
a147cca7
...
...
@@ -15,10 +15,7 @@
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
v0
.
types
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlRootElement
;
/**
...
...
@@ -28,40 +25,9 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public
class
Result
{
private
status
status
;
private
String
info
;
public
List
<
File
>
file
;
/**
* @return the type
*/
public
status
getStatus
()
{
return
status
;
}
public
void
setStatus
(
status
status
)
{
this
.
status
=
status
;
}
public
String
status
;
public
String
info
;
public
static
enum
status
{
Success
,
Fail
}
/**
* @return the info
*/
public
String
getInfo
()
{
return
info
;
}
/**
* @param info the info to set
*/
public
void
setInfo
(
String
info
)
{
this
.
info
=
info
;
}
public
List
<
File
>
file
;
}
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