blob: 5854d5720150ef6f6518da79be44be6641f77550 [file] [log] [blame]
donNewtonAlphab8f30752018-10-04 11:57:41 -04001/*
2 Copyright 2017 the original author or authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16package tosca
17
18import (
19 "fmt"
20
21 yaml "gopkg.in/yaml.v2"
22)
23
24// type: tosca.nodes.ONUDevice
25var ontDeleteTemplate = `tosca_definitions_version: tosca_simple_yaml_1_0
26imports:
27 - custom_types/onudevice.yaml
28description: Delete an ont
29topology_template:
30 node_templates:
31 device#onu:
32 type: tosca.nodes.ONUDevice
33 properties:
34 serial_number:`
35
36/*var ontDeleteTemplate = `tosca_definitions_version: tosca_simple_yaml_1_0
37imports:
38 - custom_types/onudevice.yaml
39description: Create a simulated OLT Device in VOLTHA
40topology_template:
41 node_templates:
42 device#onu:
43 type: something
44 properties:
45 serial_number:`*/
46
47type OntDelete struct {
48 ToscaDefinitionsVersion string `yaml:"tosca_definitions_version"`
49 Imports []string `yaml:"imports"`
50 Description string `yaml:"description"`
51 TopologyTemplate struct {
52 NodeTemplates struct {
53 DeviceOnt struct {
54 DeviceType string `yaml:"type"`
55 Properties struct {
56 SerialNumber string `yaml:"serial_number"`
57 } `yaml:"properties"`
58 } `yaml:"device#onu"`
59 } `yaml:"node_templates"`
60 } `yaml:"topology_template"`
61}
62
63func NewOntDelete(serialNumber string) OntDelete {
64 o := OntDelete{}
65 err := yaml.Unmarshal([]byte(ontDeleteTemplate), &o)
66 if err != nil {
67 fmt.Println(err)
68 }
69 props := &o.TopologyTemplate.NodeTemplates.DeviceOnt.Properties
70 props.SerialNumber = serialNumber
71 return o
72
73}
74func (ont *OntDelete) ToYaml() (string, error) {
75 b, err := yaml.Marshal(ont)
76 ret := string(b)
77 return ret, err
78}