Scott Baker | b2bddd8 | 2015-08-06 17:21:34 -0700 | [diff] [blame] | 1 | import os |
| 2 | import pdb |
| 3 | import sys |
| 4 | import tempfile |
| 5 | sys.path.append("/opt/tosca") |
| 6 | from translator.toscalib.tosca_template import ToscaTemplate |
| 7 | |
| 8 | from core.models import Slice,User,Network,NetworkTemplate |
| 9 | |
| 10 | from xosresource import XOSResource |
| 11 | |
| 12 | class XOSNetworkTemplate(XOSResource): |
| 13 | provides = "tosca.nodes.NetworkTemplate" |
| 14 | xos_model = NetworkTemplate |
Scott Baker | 354a108 | 2015-09-28 18:26:42 -0700 | [diff] [blame] | 15 | copyin_props = ["visibility", "translation", "shared_network_name", "shared_network_id", "toplogy_kind", "controller_kind"] |
Scott Baker | b2bddd8 | 2015-08-06 17:21:34 -0700 | [diff] [blame] | 16 | |
| 17 | def get_xos_args(self): |
Scott Baker | 354a108 | 2015-09-28 18:26:42 -0700 | [diff] [blame] | 18 | args = super(XOSNetworkTemplate, self).get_xos_args() |
Scott Baker | b2bddd8 | 2015-08-06 17:21:34 -0700 | [diff] [blame] | 19 | |
| 20 | return args |
| 21 | |
| 22 | def create(self): |
| 23 | nodetemplate = self.nodetemplate |
| 24 | |
| 25 | xos_args = self.get_xos_args() |
| 26 | |
| 27 | networkTemplate = NetworkTemplate(**xos_args) |
| 28 | networkTemplate.caller = self.user |
| 29 | networkTemplate.save() |
| 30 | |
| 31 | self.info("Created NetworkTemplate '%s' " % (str(networkTemplate), )) |
| 32 | |
| 33 | def delete(self, obj): |
| 34 | if obj.network_set.exists(): |
| 35 | return |
| 36 | |
| 37 | super(XOSNetworkTemplate, self).delete(obj) |
| 38 | |
| 39 | |
| 40 | |