Scott Baker | ed48af1 | 2016-04-25 09:21:08 -0700 | [diff] [blame] | 1 | # note: this module named xossite.py instead of site.py due to conflict with |
| 2 | # /usr/lib/python2.7/site.py |
| 3 | |
| 4 | import os |
| 5 | import pdb |
| 6 | import sys |
| 7 | import tempfile |
| 8 | sys.path.append("/opt/tosca") |
| 9 | from translator.toscalib.tosca_template import ToscaTemplate |
| 10 | |
| 11 | from core.models import User, Deployment, Flavor |
| 12 | |
| 13 | from xosresource import XOSResource |
| 14 | |
| 15 | class XOSFlavor(XOSResource): |
| 16 | provides = "tosca.nodes.Flavor" |
| 17 | xos_model = Flavor |
| 18 | copyin_props = ["flavor"] |
| 19 | |
| 20 | def get_xos_args(self): |
| 21 | args = super(XOSFlavor, self).get_xos_args() |
| 22 | |
| 23 | # Support the default where the OpenStack flavor is the same as the |
| 24 | # flavor name |
| 25 | if "flavor" not in args: |
| 26 | args["flavor"] = args["name"] |
| 27 | |
| 28 | return args |
| 29 | |
| 30 | def delete(self, obj): |
| 31 | if obj.instance_set.exists(): |
| 32 | self.info("Flavor %s has active instances; skipping delete" % obj.name) |
| 33 | return |
| 34 | super(XOSFlavor, self).delete(obj) |
| 35 | |
| 36 | |
| 37 | |