blob: 557964e8cde0f351d380bf8d0eb71b0f8a7a9e36 [file] [log] [blame]
Scott Bakerb2bddd82015-08-06 17:21:34 -07001import os
2import pdb
3import sys
4import tempfile
5sys.path.append("/opt/tosca")
6from translator.toscalib.tosca_template import ToscaTemplate
7
8from core.models import Slice,User,Network,NetworkTemplate
9
10from xosresource import XOSResource
11
12class XOSNetworkTemplate(XOSResource):
13 provides = "tosca.nodes.NetworkTemplate"
14 xos_model = NetworkTemplate
Scott Baker354a1082015-09-28 18:26:42 -070015 copyin_props = ["visibility", "translation", "shared_network_name", "shared_network_id", "toplogy_kind", "controller_kind"]
Scott Bakerb2bddd82015-08-06 17:21:34 -070016
17 def get_xos_args(self):
Scott Baker354a1082015-09-28 18:26:42 -070018 args = super(XOSNetworkTemplate, self).get_xos_args()
Scott Bakerb2bddd82015-08-06 17:21:34 -070019
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