Commit c354a862 authored by Spiros Koulouzis's avatar Spiros Koulouzis

fixed serialization error

parent a6e38c65
package nl.uva.sne.drip.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -10,29 +11,16 @@ import java.util.List;
import java.util.Map;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/**
* NodeTemplate
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-10T15:39:04.296Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-10T16:27:40.329Z")
public class NodeTemplate {
public String getId() {
return name;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.name = id;
}
@JsonIgnore
private String name;
@JsonProperty("derived_from")
private String derivedFrom = null;
......@@ -79,7 +67,7 @@ public class NodeTemplate {
* Get derivedFrom
*
* @return derivedFrom
*
*
*/
@ApiModelProperty(value = "")
......@@ -108,7 +96,7 @@ public class NodeTemplate {
* Get properties
*
* @return properties
*
*
*/
@ApiModelProperty(value = "")
......@@ -137,7 +125,7 @@ public class NodeTemplate {
* Get requirements
*
* @return requirements
*
*
*/
@ApiModelProperty(value = "")
......@@ -168,7 +156,7 @@ public class NodeTemplate {
* Get interfaces
*
* @return interfaces
*
*
*/
@ApiModelProperty(value = "")
......@@ -197,7 +185,7 @@ public class NodeTemplate {
* Get capabilities
*
* @return capabilities
*
*
*/
@ApiModelProperty(value = "")
......@@ -218,7 +206,7 @@ public class NodeTemplate {
* Get type
*
* @return type
*
*
*/
@ApiModelProperty(value = "")
......@@ -239,7 +227,7 @@ public class NodeTemplate {
* Get description
*
* @return description
*
*
*/
@ApiModelProperty(value = "")
......@@ -268,7 +256,7 @@ public class NodeTemplate {
* Get directives
*
* @return directives
*
*
*/
@ApiModelProperty(value = "")
......@@ -297,7 +285,7 @@ public class NodeTemplate {
* Get attributes
*
* @return attributes
*
*
*/
@ApiModelProperty(value = "")
......@@ -326,7 +314,7 @@ public class NodeTemplate {
* Get artifacts
*
* @return artifacts
*
*
*/
@ApiModelProperty(value = "")
......
......@@ -24,12 +24,17 @@ import java.io.FileInputStream;
import java.nio.file.Files;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.ToscaTemplate;
import org.junit.After;
......@@ -50,12 +55,14 @@ public class ToscaHelperTest {
private static final String testUpdatedApplicationExampleToscaFilePath = ".." + File.separator + "TOSCA" + File.separator + "application_example_2_topologies.yaml";
private static ToscaHelper instance;
private static ToscaTemplate toscaTemplate;
private static Boolean serviceUp;
public ToscaHelperTest() {
}
@BeforeClass
public static void setUpClass() throws UnsupportedEncodingException, JsonProcessingException, IOException, ApiException {
Properties prop = new Properties();
String resourceName = "src/test/resources/application.properties";
prop.load(new FileInputStream(resourceName));
......@@ -63,7 +70,11 @@ public class ToscaHelperTest {
String ymlStr = new String(bytes, "UTF-8");
objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
toscaTemplate = objectMapper.readValue(ymlStr, ToscaTemplate.class);
instance = new ToscaHelper(toscaTemplate, prop.getProperty("sure-tosca.base.path"));
String serviceBasePath = prop.getProperty("sure-tosca.base.path");
serviceUp = isServiceUp(serviceBasePath);
if (serviceUp) {
instance = new ToscaHelper(toscaTemplate, serviceBasePath);
}
}
......@@ -84,37 +95,59 @@ public class ToscaHelperTest {
*/
@Test
public void testGetId() {
System.out.println("getId");
Integer result = instance.getId();
assertNotNull(result);
if (serviceUp) {
System.out.println("getId");
Integer result = instance.getId();
assertNotNull(result);
}
}
/**
* Test of getProvisionInterfaceDefinitions method, of class ToscaHelper.
*
* @throws nl.uva.sne.drip.sure_tosca.client.ApiException
*/
@Test
public void testGetProvisionInterfaceDefinitions() throws Exception {
System.out.println("getProvisionInterfaceDefinitions");
List<String> toscaInterfaceTypes = new ArrayList<>();
String expected = "tosca.interfaces.ARTICONF.CloudsStorm";
toscaInterfaceTypes.add(expected);
List<Map<String, Object>> result = instance.getProvisionInterfaceDefinitions(toscaInterfaceTypes);
assertNotNull(result);
String key = result.get(0).keySet().iterator().next();
assertEquals(expected, key);
public void testGetProvisionInterfaceDefinitions() throws ApiException {
if (serviceUp) {
System.out.println("getProvisionInterfaceDefinitions");
List<String> toscaInterfaceTypes = new ArrayList<>();
String expected = "tosca.interfaces.ARTICONF.CloudsStorm";
toscaInterfaceTypes.add(expected);
List<Map<String, Object>> result = instance.getProvisionInterfaceDefinitions(toscaInterfaceTypes);
assertNotNull(result);
String key = result.get(0).keySet().iterator().next();
assertEquals(expected, key);
}
}
/**
* Test of getVMTopologyTemplates method, of class ToscaHelper.
*
* @throws nl.uva.sne.drip.sure_tosca.client.ApiException
*/
@Test
public void testGetVMTopologyTemplates() throws Exception {
System.out.println("getVMTopologyTemplates");
List<NodeTemplate> result = instance.getVMTopologyTemplates();
assertNotNull(result);
for (NodeTemplate nodeTemplate : result) {
assertEquals(nodeTemplate.getType(), "tosca.nodes.ARTICONF.VM.topology");
public void testGetVMTopologyTemplates() throws ApiException {
if (serviceUp) {
System.out.println("getVMTopologyTemplates");
List<NodeTemplate> result = instance.getVMTopologyTemplates();
assertNotNull(result);
for (NodeTemplate nodeTemplate : result) {
assertEquals(nodeTemplate.getType(), "tosca.nodes.ARTICONF.VM.topology");
}
}
}
public static Boolean isServiceUp(String serviceBasePath) {
try {
URL serviceUrl = new URL(serviceBasePath);
HttpURLConnection connection = (HttpURLConnection) serviceUrl.openConnection();
//Set request to header to reduce load as Subirkumarsao said.
connection.setRequestMethod("HEAD");
int code = connection.getResponseCode();
} catch (IOException ex) {
return false;
}
return true;
}
}
......@@ -15,15 +15,24 @@ import java.io.File;
import org.junit.Test;
import java.util.List;
import static nl.uva.sne.drip.commons.utils.ToscaHelperTest.isServiceUp;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
/**
* API tests for DefaultApi
*/
@Ignore
public class DefaultApiTest {
// private final DefaultApi api = new DefaultApi();
private String serviceBasePath;
private final Boolean serviceUp;
public DefaultApiTest() {
serviceUp = isServiceUp(serviceBasePath);
}
// private final DefaultApi api = new DefaultApi();
/**
*
*
......@@ -330,5 +339,4 @@ public class DefaultApiTest {
//
// // TODO: test validations
// }
}
---
swagger: "2.0"
info:
description: 'TOSCA Simple qUeRy sErvice (SURE). '
version: 1.0.0
title: tosca-sure
description: CONF allows application developers to seamlessly plan a customized virtual infrastructure based on application level constraints on QoS and resource budgets, provisioning the virtual infrastructure, deploy application components onto the virtual infrastructure, and start execution on demand using TOSCA.
version: 3.0.0
title: CONF
contact:
email: S.Koulouzis@uva.nl
email: z.zhao@uva.nl
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
basePath: /tosca-sure/1.0.0
basePath: /conf-api/3.0
schemes:
- https
- http
......@@ -17,7 +17,7 @@ paths:
/tosca_template:
post:
summary: upload a tosca template description file
description: upload and validate a tosca template description file
description: uploads and validates TOSCA template file
operationId: uploadToscaTemplate
consumes:
- multipart/form-data
......@@ -34,312 +34,187 @@ paths:
type: string
"405":
description: Invalid input
/tosca_template/{id}:
get:
description: ""
operationId: getToscaTemplate
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
responses:
"200":
description: successful operation
schema:
$ref: '#/definitions/ToscaTemplate'
"404":
description: Not found
"405":
description: Invalid input
/tosca_template/{id}/imports:
security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/tosca_template/ids:
get:
summary: ""
description: returns the interface types
operationId: getImports
summary: Get all topolog template IDs
description: Returns all IDs
operationId: getToscaTemplateIDs
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
parameters: []
responses:
"200":
description: successful operation
schema:
type: array
items:
type: object
additionalProperties:
type: object
properties: {}
type: string
"400":
description: Invalid ID supplied
"404":
description: Not found
description: ToscaTemplate not found
"405":
description: Invalid input
/tosca_template/{id}/dsl_definitions:
security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/tosca_template/{id}:
get:
summary: ""
description: returns the interface types
operationId: getDslDefinitions
summary: Find topolog template by ID
description: Returns a single topolog template
operationId: getToscaTemplateByID
produces:
- application/json
- text/plain
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
description: ID of topolog template to return
required: true
type: string
- name: anchors
in: query
description: the anchors the definition is for
required: false
type: array
items:
type: string
collectionFormat: multi
- name: derived_from
in: query
description: derived from
required: false
type: string
responses:
"200":
description: successful operation
schema:
type: array
items:
type: object
additionalProperties:
type: object
properties: {}
type: string
"400":
description: Invalid ID supplied
"404":
description: Not found
description: ToscaTemplate not found
"405":
description: Invalid input
/tosca_template/{id}/types:
get:
summary: ""
description: returns the interface types
operationId: getTypes
security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
put:
summary: Updates exisintg topolog template
description: ""
operationId: updateToscaTemplateByID
consumes:
- multipart/form-data
produces:
- application/json
- text/plain
parameters:
- name: file
in: formData
description: tosca Template description
required: false
type: file
- name: id
in: path
description: ID of topolog template uplodaed
description: ID of topolog template to return
required: true
type: string
- name: kind_of_type
in: query
description: the type we are looking for e.g. capability_types, artifact_types. etc.
required: false
type: string
enum:
- node_types
- relationship_types
- capability_types
- artifact_types
- data_types
- interface_types
- policy_types
- group_types
- name: has_interfaces
in: query
description: filter if has interfaces
required: false
type: boolean
- name: type_name
in: query
description: The type_name
required: false
type: string
- name: has_properties
in: query
description: filter if has properties
required: false
type: boolean
- name: has_attributes
in: query
description: filter if has attributes
required: false
type: boolean
- name: has_requirements
in: query
description: filter if has requirements
required: false
type: boolean
- name: has_capabilities
in: query
description: filter if has capabilities
required: false
type: boolean
- name: has_artifacts
in: query
description: filter if has artifacts
required: false
type: boolean
- name: derived_from
in: query
description: derived from
required: false
type: string
responses:
"200":
description: successful operation
schema:
type: array
items:
type: object
additionalProperties:
type: object
properties: {}
type: string
"400":
description: Invalid ID supplied
"404":
description: Not found
description: ToscaTemplate not found
"405":
description: Invalid input
/tosca_template/{id}/relationship_templates:
get:
summary: ""
description: returns the interface types
operationId: getRelationshipTemplates
produces:
- application/json
security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
delete:
summary: Deletes a tosca topology template
description: ""
operationId: deleteToscaTemplateByID
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
description: ID of topology template to return
required: true
type: string
- name: type_name
in: query
description: The relationship type
required: false
type: string
- name: derived_from
in: query
description: derived from
required: false
type: string
responses:
"200":
description: successful operation
schema:
type: array
items:
type: object
additionalProperties:
type: object
properties: {}
type: string
"400":
description: Invalid ID supplied
"404":
description: Not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template:
description: ToscaTemplate not found
security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/planner/plan/{id}:
get:
description: r
operationId: getTopologyTemplate
summary: plan tosca template
description: Returns the ID of the planed topolog template
operationId: planToscaTemplateByID
produces:
- application/json
- text/plain
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
description: ID of topolog template to plan
required: true
type: string
responses:
"200":
description: successful operation
schema:
$ref: '#/definitions/TopologyTemplate'
type: string
"400":
description: Invalid ID supplied
"404":
description: Not found
description: ToscaTemplate not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates:
security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/provisioner/provision/{id}:
get:
description: returns nodes templates in topology
operationId: getNodeTemplates
summary: provision tosca template
description: 'provosions the operationId: Plan Tosca Template Returns the provision ID'
operationId: provisionPlanToscaTemplateByID
produces:
- application/json
- text/plain
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
description: ID of topolog template to plan
required: true
type: string
- name: type_name
in: query
description: The type
required: false
type: string
- name: node_name
in: query
description: the name
required: false
type: string
- name: has_interfaces
in: query
description: filter if has interfaces
required: false
type: boolean
- name: has_properties
in: query
description: filter if has properties
required: false
type: boolean
- name: has_attributes
in: query
description: filter if has attributes
required: false
type: boolean
- name: has_requirements
in: query
description: filter if has requirements
required: false
type: boolean
- name: has_capabilities
in: query
description: filter if has capabilities
required: false
type: boolean
- name: has_artifacts
in: query
description: filter if has artifacts
required: false
type: boolean
responses:
"200":
description: successful operation
schema:
type: array
items:
$ref: '#/definitions/NodeTemplate'
type: string
"400":
description: Invalid ID supplied
"404":
description: Not found
description: ToscaTemplate not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/type_name:
security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/deployer/deploy/{id}:
get:
summary: ""
description: ""
operationId: getNodeTypeName
summary: deploy the software tosca template
description: Returns the deployment ID
operationId: deployProvisionToscaTemplateByID
produces:
- application/json
- text/plain
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
in: path
description: node_name
description: ID of topolog template to deploy
required: true
type: string
responses:
......@@ -347,358 +222,285 @@ paths:
description: successful operation
schema:
type: string
"400":
description: Invalid ID supplied
"404":
description: Not found
description: ToscaTemplate not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/requirements:
get:
description: 'Returns the requirements for an input node as described in the template not in the node''s definition '
operationId: getNodeRequirements
security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/credential:
post:
summary: Create credentials
description: Creates credentials
operationId: createCredentials
consumes:
- application/json
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
in: path
description: node_name
- in: body
name: body
description: Created user object
required: true
type: string
schema:
$ref: '#/definitions/Credentials'
responses:
"200":
description: successful operation
schema:
type: object
additionalProperties:
type: object
properties: {}
type: string
"400":
description: Invalid ID supplied
"404":
description: Not found
description: ToscaTemplate not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/derived_from:
security:
- auth:
- write:Credentials
- read:Credentials
/credential/ids:
get:
summary: ""
description: ""
operationId: getParentTypeName
summary: Get all credential IDs
description: 'Returns all IDss '
operationId: getCredentialIDs
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
in: path
description: node_name
required: true
type: string
parameters: []
responses:
"200":
description: successful operation
schema:
type: string
type: array
items:
type: string
"400":
description: Invalid ID supplied
"404":
description: Not found
description: ToscaTemplate not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_requirements:
get:
summary: ""
description: Recursively get all requirements all the way to the ROOT including the input node's
operationId: getAncestorsRequirements
security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/user:
post:
summary: Create user
description: This can only be done by admin.
operationId: createUser
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
in: path
description: node_name
- in: body
name: body
description: Created user object
required: true
type: string
schema:
$ref: '#/definitions/User'
responses:
"200":
description: successful operation
schema:
type: object
additionalProperties:
type: object
properties: {}
"404":
description: Not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_types:
type: string
"409":
description: already exists
security:
- auth:
- admin:User
/user/login:
get:
summary: ""
description: Recursively get all requirements all the way to the ROOT including the input node's
operationId: getAllAncestorTypes
tags:
- user
summary: Logs user into the system
description: ""
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
- name: username
in: query
description: The user name for login
required: true
type: string
- name: node_name
in: path
description: node_name
- name: password
in: query
description: The password for login in clear text
required: true
type: string
responses:
"200":
description: successful operation
schema:
type: array
items:
headers:
X-Rate-Limit:
type: integer
format: int32
description: calls per hour allowed by the user
X-Expires-After:
type: string
"404":
description: Not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_properties:
format: date-time
description: date in UTC when token expires
schema:
type: string
"400":
description: Invalid username/password supplied
/user/logout:
get:
summary: ""
description: Recursively get all requirements all the way to the ROOT including the input node's
operationId: getAllAncestorProperties
summary: Logs out current logged in user session
description: ""
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
in: path
description: node_name
required: true
type: string
parameters: []
responses:
"200":
default:
description: successful operation
schema:
type: array
items:
type: object
additionalProperties:
type: object
properties: {}
"404":
description: Not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/properties:
/user/{username}:
get:
summary: ""
description: s
operationId: getNodeProperties
summary: Get user by user name
description: ""
produces:
- application/json
parameters:
- name: id
- name: username
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
in: path
description: node_name
description: 'The name that needs to be fetched. Use user1 for testing. '
required: true
type: string
responses:
"200":
description: successful operation
schema:
type: object
additionalProperties:
type: object
properties: {}
$ref: '#/definitions/User'
"400":
description: Invalid username supplied
"404":
description: Not found
"405":
description: Invalid input
description: User not found
security:
- auth:
- admin:User
put:
summary: ""
description: s
operationId: setNodeProperties
tags:
- user
summary: Updated user
description: This can only be done by the logged in user.
produces:
- application/json
parameters:
- name: id
- name: username
in: path
description: ID of topolog template uplodaed
description: name that need to be updated
required: true
type: string
- in: body
name: properties
name: body
description: Updated user object
required: true
schema:
type: object
additionalProperties:
type: object
properties: {}
- name: node_name
in: path
description: node_name
required: true
type: string
responses:
"200":
description: successful operation
schema:
type: string
"404":
description: Not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/outputs:
get:
summary: ""
description: s
operationId: getNodeOutputs
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
in: path
description: node_name
required: true
type: string
$ref: '#/definitions/User'
responses:
"200":
description: successful operation
schema:
type: array
items:
type: object
additionalProperties:
type: object
properties: {}
"400":
description: Invalid user supplied
"404":
description: Not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/related:
get:
summary: ""
description: s
operationId: getRelatedNodes
description: User not found
security:
- auth:
- admin:User
delete:
summary: Delete user
description: This can only be done by the logged in user.
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
- name: username
in: path
description: node_name
description: The name that needs to be deleted
required: true
type: string
responses:
"200":
description: successful operation
schema:
type: array
items:
$ref: '#/definitions/NodeTemplate'
"400":
description: Invalid username supplied
"404":
description: Not found
"405":
description: Invalid input
description: User not found
security:
- auth:
- admin:User
securityDefinitions:
auth:
type: oauth2
authorizationUrl: http://localhost/oauth/dialog
flow: implicit
scopes:
write:ToscaTemplate: modify topolog template in your account
read:ToscaTemplate: read your topolog template
admin:User: Grants access to admin operations
write:Credentials: modify cloud credentials in your account
read:Credentials: read your cloud credentials
definitions:
ToscaTemplate:
User:
type: object
Credentials:
type: object
properties:
tosca_definitions_version:
protocol:
type: string
tosca_default_namespace:
token_type:
type: string
template_name:
token:
type: string
topology_template:
$ref: '#/definitions/TopologyTemplate'
template_author:
keys:
type: object
additionalProperties:
type: string
user:
type: string
template_version:
cloud_provider_name:
type: string
description:
NodeTemplate:
type: object
properties:
name:
type: string
imports:
derived_from:
type: string
properties:
type: object
additionalProperties:
type: object
properties: {}
requirements:
type: array
items:
type: object
additionalProperties:
type: object
properties: {}
dsl_definitions:
type: object
additionalProperties:
type: object
properties: {}
node_types:
type: object
additionalProperties:
type: object
properties: {}
relationship_types:
type: object
additionalProperties:
type: object
properties: {}
relationship_templates:
type: object
additionalProperties:
type: object
properties: {}
capability_types:
type: object
additionalProperties:
type: object
properties: {}
artifact_types:
type: object
additionalProperties:
type: object
properties: {}
data_types:
type: object
additionalProperties:
type: object
properties: {}
interface_types:
interfaces:
type: object
additionalProperties:
type: object
properties: {}
policy_types:
capabilities:
type: object
additionalProperties:
type: object
properties: {}
group_types:
type:
type: string
description:
type: string
directives:
type: array
items:
type: string
attributes:
type: object
additionalProperties:
type: object
properties: {}
repositories:
artifacts:
type: object
additionalProperties:
type: object
......@@ -743,48 +545,128 @@ definitions:
additionalProperties:
type: object
properties: {}
NodeTemplate:
ToscaTemplate:
type: object
properties:
derived_from:
tosca_definitions_version:
type: string
properties:
type: object
additionalProperties:
type: object
properties: {}
requirements:
tosca_default_namespace:
type: string
template_name:
type: string
topology_template:
$ref: '#/definitions/TopologyTemplate'
template_author:
type: string
template_version:
type: string
description:
type: string
imports:
type: array
items:
type: object
additionalProperties:
type: object
properties: {}
interfaces:
dsl_definitions:
type: object
additionalProperties:
type: object
properties: {}
capabilities:
node_types:
type: object
additionalProperties:
type: object
properties: {}
type:
type: string
description:
type: string
directives:
type: array
items:
type: string
attributes:
relationship_types:
type: object
additionalProperties:
type: object
properties: {}
artifacts:
relationship_templates:
type: object
additionalProperties:
type: object
properties: {}
capability_types:
type: object
additionalProperties:
type: object
properties: {}
artifact_types:
type: object
additionalProperties:
type: object
properties: {}
data_types:
type: object
additionalProperties:
type: object
properties: {}
interface_types:
type: object
additionalProperties:
type: object
properties: {}
policy_types:
type: object
additionalProperties:
type: object
properties: {}
group_types:
type: object
additionalProperties:
type: object
properties: {}
repositories:
type: object
additionalProperties:
type: object
properties: {}
CloudsStormTopTopology:
type: object
properties:
userName:
type: string
publicKeyPath:
type: string
topologies:
type: array
items:
$ref: '#/definitions/CloudsStormSubTopology'
subnets:
type: array
items:
$ref: '#/definitions/CloudsStormSubnets'
CloudsStormSubTopology:
type: object
properties:
topology:
type: string
cloudProvider:
type: string
domain:
type: string
status:
type: string
CloudsStormSubnets:
type: object
properties:
name:
type: string
subnet:
type: string
netmask:
type: string
members:
type: array
items:
$ref: '#/definitions/CloudsStormSubMembers'
CloudsStormSubMembers:
type: object
properties:
vmName:
type: string
address:
type: string
......@@ -746,6 +746,8 @@ definitions:
NodeTemplate:
type: object
properties:
name:
type: string
derived_from:
type: string
properties:
......
NodeTemplate:
type: "object"
properties:
name:
type: "string"
derived_from:
type: "string"
properties:
......
......@@ -64,12 +64,3 @@ class Model(object):
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other
# def __hash__(self):
# return hash(self.__dict__.keys())
def __key(self):
return tuple(sorted(self.to_dict()))
def __hash__(self):
return hash(self.__key())
\ No newline at end of file
......@@ -15,8 +15,7 @@ class NodeTemplateModel(Model):
Do not edit the class manually.
"""
def __init__(self, derived_from=None, properties=None, requirements=None, interfaces=None, capabilities=None,
type=None, description=None, directives=None, attributes=None, artifacts=None): # noqa: E501
def __init__(self, derived_from=None, properties=None, requirements=None, interfaces=None, capabilities=None, type=None, description=None, directives=None, attributes=None, artifacts=None): # noqa: E501
"""NodeTemplate - a model defined in Swagger
:param derived_from: The derived_from of this NodeTemplate. # noqa: E501
......@@ -84,10 +83,12 @@ class NodeTemplateModel(Model):
:param dikt: A dict.
:type: dict
:return: The NodeTemplate of this NodeTemplate. # noqa: E501
:rtype: NodeTemplateModel
:rtype: NodeTemplate
"""
return util.deserialize_model(dikt, cls)
@property
def derived_from(self):
"""Gets the derived_from of this NodeTemplate.
......
......@@ -5,9 +5,9 @@ from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from sure_tosca.models import NodeTemplateModel
from sure_tosca.models.base_model_ import Model
from sure_tosca import util
from sure_tosca.models.node_template import NodeTemplateModel
class TopologyTemplateModel(Model):
......@@ -22,9 +22,9 @@ class TopologyTemplateModel(Model):
:param description: The description of this TopologyTemplate. # noqa: E501
:type description: str
:param inputs: The inputs of this TopologyTemplate. # noqa: E501
:type inputs: List[Dict[str, object]]
:type inputs: Dict[str, str]
:param node_templates: The node_templates of this TopologyTemplate. # noqa: E501
:type node_templates: Dict[str, NodeTemplateModel]
:type node_templates: Dict[str, NodeTemplate]
:param relationship_templates: The relationship_templates of this TopologyTemplate. # noqa: E501
:type relationship_templates: Dict[str, object]
:param outputs: The outputs of this TopologyTemplate. # noqa: E501
......@@ -38,7 +38,7 @@ class TopologyTemplateModel(Model):
"""
self.swagger_types = {
'description': str,
'inputs': List[Dict[str, object]],
'inputs': Dict[str, str],
'node_templates': Dict[str, NodeTemplateModel],
'relationship_templates': Dict[str, object],
'outputs': Dict[str, object],
......@@ -74,7 +74,7 @@ class TopologyTemplateModel(Model):
:param dikt: A dict.
:type: dict
:return: The TopologyTemplate of this TopologyTemplate. # noqa: E501
:rtype: TopologyTemplateModel
:rtype: TopologyTemplate
"""
return util.deserialize_model(dikt, cls)
......@@ -105,7 +105,7 @@ class TopologyTemplateModel(Model):
:return: The inputs of this TopologyTemplate.
:rtype: List[Dict[str, object]]
:rtype: Dict[str, str]
"""
return self._inputs
......@@ -115,7 +115,7 @@ class TopologyTemplateModel(Model):
:param inputs: The inputs of this TopologyTemplate.
:type inputs: List[Dict[str, object]]
:type inputs: Dict[str, str]
"""
self._inputs = inputs
......@@ -126,7 +126,7 @@ class TopologyTemplateModel(Model):
:return: The node_templates of this TopologyTemplate.
:rtype: Dict[str, NodeTemplateModel]
:rtype: Dict[str, NodeTemplate]
"""
return self._node_templates
......@@ -136,7 +136,7 @@ class TopologyTemplateModel(Model):
:param node_templates: The node_templates of this TopologyTemplate.
:type node_templates: Dict[str, NodeTemplateModel]
:type node_templates: Dict[str, NodeTemplate]
"""
self._node_templates = node_templates
......@@ -168,7 +168,7 @@ class TopologyTemplateModel(Model):
:return: The outputs of this TopologyTemplate.
:rtype: str
:rtype: Dict[str, object]
"""
return self._outputs
......@@ -178,7 +178,7 @@ class TopologyTemplateModel(Model):
:param outputs: The outputs of this TopologyTemplate.
:type outputs: str
:type outputs: Dict[str, object]
"""
self._outputs = outputs
......@@ -245,8 +245,3 @@ class TopologyTemplateModel(Model):
"""
self._policies = policies
def __eq__(self, other):
if isinstance(other, TopologyTemplateModel):
return self.__key() == other.__key()
return NotImplemented
\ No newline at end of file
......@@ -5,9 +5,9 @@ from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from sure_tosca.models import TopologyTemplateModel
from sure_tosca.models.base_model_ import Model
from sure_tosca import util
from sure_tosca.models.topology_template import TopologyTemplateModel
class ToscaTemplateModel(Model):
......@@ -16,11 +16,7 @@ class ToscaTemplateModel(Model):
Do not edit the class manually.
"""
def __init__(self, tosca_definitions_version=None, tosca_default_namespace=None, template_name=None,
topology_template=None, template_author=None, template_version=None, description=None, imports=None,
dsl_definitions=None, node_types=None, relationship_types=None, relationship_templates=None,
capability_types=None, artifact_types=None, data_types=None, interface_types=None, policy_types=None,
group_types=None, repositories=None): # noqa: E501
def __init__(self, tosca_definitions_version=None, tosca_default_namespace=None, template_name=None, topology_template=None, template_author=None, template_version=None, description=None, imports=None, dsl_definitions=None, node_types=None, relationship_types=None, relationship_templates=None, capability_types=None, artifact_types=None, data_types=None, interface_types=None, policy_types=None, group_types=None, repositories=None): # noqa: E501
"""ToscaTemplate - a model defined in Swagger
:param tosca_definitions_version: The tosca_definitions_version of this ToscaTemplate. # noqa: E501
......@@ -30,7 +26,7 @@ class ToscaTemplateModel(Model):
:param template_name: The template_name of this ToscaTemplate. # noqa: E501
:type template_name: str
:param topology_template: The topology_template of this ToscaTemplate. # noqa: E501
:type topology_template: TopologyTemplateModel
:type topology_template: TopologyTemplate
:param template_author: The template_author of this ToscaTemplate. # noqa: E501
:type template_author: str
:param template_version: The template_version of this ToscaTemplate. # noqa: E501
......@@ -56,7 +52,7 @@ class ToscaTemplateModel(Model):
:param interface_types: The interface_types of this ToscaTemplate. # noqa: E501
:type interface_types: Dict[str, object]
:param policy_types: The policy_types of this ToscaTemplate. # noqa: E501
:type policy_types: Dict[str, str]
:type policy_types: Dict[str, object]
:param group_types: The group_types of this ToscaTemplate. # noqa: E501
:type group_types: Dict[str, object]
:param repositories: The repositories of this ToscaTemplate. # noqa: E501
......@@ -79,7 +75,7 @@ class ToscaTemplateModel(Model):
'artifact_types': Dict[str, object],
'data_types': Dict[str, object],
'interface_types': Dict[str, object],
'policy_types': Dict[str, str],
'policy_types': Dict[str, object],
'group_types': Dict[str, object],
'repositories': Dict[str, object]
}
......@@ -133,7 +129,7 @@ class ToscaTemplateModel(Model):
:param dikt: A dict.
:type: dict
:return: The ToscaTemplate of this ToscaTemplate. # noqa: E501
:rtype: ToscaTemplateModel
:rtype: ToscaTemplate
"""
return util.deserialize_model(dikt, cls)
......@@ -206,7 +202,7 @@ class ToscaTemplateModel(Model):
:return: The topology_template of this ToscaTemplate.
:rtype: TopologyTemplateModel
:rtype: TopologyTemplate
"""
return self._topology_template
......@@ -216,7 +212,7 @@ class ToscaTemplateModel(Model):
:param topology_template: The topology_template of this ToscaTemplate.
:type topology_template: TopologyTemplateModel
:type topology_template: TopologyTemplate
"""
self._topology_template = topology_template
......@@ -479,7 +475,7 @@ class ToscaTemplateModel(Model):
:return: The policy_types of this ToscaTemplate.
:rtype: Dict[str, str]
:rtype: Dict[str, object]
"""
return self._policy_types
......@@ -489,7 +485,7 @@ class ToscaTemplateModel(Model):
:param policy_types: The policy_types of this ToscaTemplate.
:type policy_types: Dict[str, str]
:type policy_types: Dict[str, object]
"""
self._policy_types = policy_types
......@@ -535,8 +531,3 @@ class ToscaTemplateModel(Model):
"""
self._repositories = repositories
def __eq__(self, other):
if isinstance(other, ToscaTemplateModel):
return self.__key() == other.__key()
return NotImplemented
......@@ -3,6 +3,7 @@ import logging
import os
import tempfile
import uuid
from builtins import print
from functools import reduce
import copy
......@@ -115,6 +116,17 @@ def get_interface_types(id, interface_type=None):
return query_db(queries, db=interface_types_db)
def change_to_nodeTemplateModel(query_results):
res = []
for node_template in query_results:
# copy.deepcopy()
name = next(iter(node_template))
node_template = node_template[name]
node_template['name'] = name
res.append(NodeTemplateModel.from_dict(node_template))
return res
def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None, has_properties=None,
has_attributes=None,
has_requirements=None, has_capabilities=None, has_artifacts=None):
......@@ -173,7 +185,8 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
queries.append(query.artifacts != prop)
query_results = query_db(queries, db=node_template_db)
return query_results
return change_to_nodeTemplateModel(query_results)
def get_tosca_template_get_dsl_definitions(id, anchors, derived_from):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment