donNewtonAlpha | b8f3075 | 2018-10-04 11:57:41 -0400 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package tosca |
| 17 | |
| 18 | import ( |
| 19 | "fmt" |
| 20 | |
| 21 | yaml "gopkg.in/yaml.v2" |
| 22 | ) |
| 23 | |
| 24 | // type: tosca.nodes.ONUDevice |
| 25 | var ontDeleteTemplate = `tosca_definitions_version: tosca_simple_yaml_1_0 |
| 26 | imports: |
| 27 | - custom_types/onudevice.yaml |
| 28 | description: Delete an ont |
| 29 | topology_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 |
| 37 | imports: |
| 38 | - custom_types/onudevice.yaml |
| 39 | description: Create a simulated OLT Device in VOLTHA |
| 40 | topology_template: |
| 41 | node_templates: |
| 42 | device#onu: |
| 43 | type: something |
| 44 | properties: |
| 45 | serial_number:`*/ |
| 46 | |
| 47 | type 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 | |
| 63 | func 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 | } |
| 74 | func (ont *OntDelete) ToYaml() (string, error) { |
| 75 | b, err := yaml.Marshal(ont) |
| 76 | ret := string(b) |
| 77 | return ret, err |
| 78 | } |