Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 1 | """ |
Tony Mack | d851547 | 2015-08-19 11:58:18 -0400 | [diff] [blame] | 2 | Basic Instance Test |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 3 | |
| 4 | 1) Create a slice1 |
Tony Mack | d851547 | 2015-08-19 11:58:18 -0400 | [diff] [blame] | 5 | 2) Create instance1 on slice1 |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 6 | """ |
| 7 | |
| 8 | import os |
| 9 | import json |
| 10 | import sys |
| 11 | import time |
| 12 | |
Scott Baker | eaeabad | 2015-02-09 11:18:46 -0800 | [diff] [blame] | 13 | sys.path.append("/opt/xos") |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 14 | |
Scott Baker | 86e132c | 2015-02-11 21:38:09 -0800 | [diff] [blame] | 15 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings") |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 16 | from openstack.manager import OpenStackManager |
Tony Mack | d851547 | 2015-08-19 11:58:18 -0400 | [diff] [blame] | 17 | from core.models import Slice, Instance, ServiceClass, Reservation, Tag, Network, User, Node, Image, Deployment, Site, NetworkTemplate, NetworkSlice |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 18 | |
| 19 | from planetstacktest import PlanetStackTest, fail_unless |
| 20 | |
Tony Mack | d851547 | 2015-08-19 11:58:18 -0400 | [diff] [blame] | 21 | class InstanceTest(PlanetStackTest): |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 22 | def __init__(self): |
| 23 | PlanetStackTest.__init__(self) |
| 24 | |
Tony Mack | d851547 | 2015-08-19 11:58:18 -0400 | [diff] [blame] | 25 | def run_instance1(self): |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 26 | slice1Name = self.make_slice_name() |
| 27 | slice1 = Slice(name = slice1Name, |
| 28 | omf_friendly=True, |
| 29 | site=self.testSite, |
| 30 | creator=self.testUser) |
| 31 | slice1=self.save_and_wait_for_enacted(slice1, nonempty_fields=["tenant_id"]) |
| 32 | |
Tony Mack | d851547 | 2015-08-19 11:58:18 -0400 | [diff] [blame] | 33 | instance1 = Instance(image = self.testImage, |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 34 | creator=self.testUser, |
| 35 | slice=slice1, |
| 36 | node=self.testNode, |
| 37 | deploymentNetwork=self.testDeployment) |
Tony Mack | d851547 | 2015-08-19 11:58:18 -0400 | [diff] [blame] | 38 | instance1=self.save_and_wait_for_enacted(instance1, nonempty_fields=["instance_id", "ip"]) |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 39 | |
| 40 | def run(self): |
| 41 | self.setup() |
| 42 | try: |
Tony Mack | d851547 | 2015-08-19 11:58:18 -0400 | [diff] [blame] | 43 | self.run_instance1() |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 44 | finally: |
| 45 | self.cleanup() |
| 46 | |
| 47 | def main(): |
Tony Mack | d851547 | 2015-08-19 11:58:18 -0400 | [diff] [blame] | 48 | InstanceTest().run() |
Scott Baker | ab23fa9 | 2013-08-25 16:53:49 -0700 | [diff] [blame] | 49 | |
| 50 | if __name__=="__main__": |
| 51 | main() |