blob: 2813521d46f4c07d3537204cc233d77b30773f27 [file] [log] [blame]
Scott Bakerab23fa92013-08-25 16:53:49 -07001"""
Tony Mackd8515472015-08-19 11:58:18 -04002 Basic Instance Test
Scott Bakerab23fa92013-08-25 16:53:49 -07003
4 1) Create a slice1
Tony Mackd8515472015-08-19 11:58:18 -04005 2) Create instance1 on slice1
Scott Bakerab23fa92013-08-25 16:53:49 -07006"""
7
8import os
9import json
10import sys
11import time
12
Scott Bakereaeabad2015-02-09 11:18:46 -080013sys.path.append("/opt/xos")
Scott Bakerab23fa92013-08-25 16:53:49 -070014
Scott Baker86e132c2015-02-11 21:38:09 -080015os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
Scott Bakerab23fa92013-08-25 16:53:49 -070016from openstack.manager import OpenStackManager
Tony Mackd8515472015-08-19 11:58:18 -040017from core.models import Slice, Instance, ServiceClass, Reservation, Tag, Network, User, Node, Image, Deployment, Site, NetworkTemplate, NetworkSlice
Scott Bakerab23fa92013-08-25 16:53:49 -070018
19from planetstacktest import PlanetStackTest, fail_unless
20
Tony Mackd8515472015-08-19 11:58:18 -040021class InstanceTest(PlanetStackTest):
Scott Bakerab23fa92013-08-25 16:53:49 -070022 def __init__(self):
23 PlanetStackTest.__init__(self)
24
Tony Mackd8515472015-08-19 11:58:18 -040025 def run_instance1(self):
Scott Bakerab23fa92013-08-25 16:53:49 -070026 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 Mackd8515472015-08-19 11:58:18 -040033 instance1 = Instance(image = self.testImage,
Scott Bakerab23fa92013-08-25 16:53:49 -070034 creator=self.testUser,
35 slice=slice1,
36 node=self.testNode,
37 deploymentNetwork=self.testDeployment)
Tony Mackd8515472015-08-19 11:58:18 -040038 instance1=self.save_and_wait_for_enacted(instance1, nonempty_fields=["instance_id", "ip"])
Scott Bakerab23fa92013-08-25 16:53:49 -070039
40 def run(self):
41 self.setup()
42 try:
Tony Mackd8515472015-08-19 11:58:18 -040043 self.run_instance1()
Scott Bakerab23fa92013-08-25 16:53:49 -070044 finally:
45 self.cleanup()
46
47def main():
Tony Mackd8515472015-08-19 11:58:18 -040048 InstanceTest().run()
Scott Bakerab23fa92013-08-25 16:53:49 -070049
50if __name__=="__main__":
51 main()