-
- def create_multinode_generic_booking(self):
- topology = {}
-
- compute_hostnames = ["cmp01", "cmp02", "cmp03"]
-
- host_type = HostProfile.objects.first()
-
- universal_networks = [
- {"name": "public", "tagged": False, "public": True},
- {"name": "admin", "tagged": True, "public": False}]
- just_compute_networks = [{"name": "private", "tagged": True, "public": False}]
- just_jumphost_networks = [{"name": "external", "tagged": True, "public": True}]
-
- # generate a bunch of extra networks
- for i in range(10):
- net = {"tagged": False, "public": False}
- net["name"] = "u_net" + str(i)
- universal_networks.append(net)
-
- jhost_info = {}
- jhost_info["type"] = host_type
- jhost_info["role"] = OPNFVRole.objects.get(name="Jumphost")
- jhost_info["nets"] = self.make_networks(host_type, list(just_jumphost_networks + universal_networks))
- jhost_info["image"] = self.image
- topology["jump"] = jhost_info
-
- for hostname in compute_hostnames:
- host_info = {}
- host_info["type"] = host_type
- host_info["role"] = OPNFVRole.objects.get(name="Compute")
- host_info["nets"] = self.make_networks(host_type, list(just_compute_networks + universal_networks))
- host_info["image"] = self.image
- topology[hostname] = host_info
-
- booking = instantiate_booking(self.loginuser,
- timezone.now(),
- timezone.now() + timedelta(days=1),
- "demobooking",
- self.lab,
- topology=topology,
- installer=self.installer,
- scenario=self.scenario)
-
- if not booking.resource:
- raise Exception("Booking does not have a resource when trying to pass to makeCompleteJob")
- JobFactory.makeCompleteJob(booking)
-
- return booking, compute_hostnames, "jump"
-
- """
- evenly distributes networks given across a given profile's interfaces
- """
- def make_networks(self, hostprofile, nets):
- network_struct = []
- count = hostprofile.interfaceprofile.all().count()
- for i in range(count):
- network_struct.append([])
- while(nets):
- index = len(nets) % count
- network_struct[index].append(nets.pop())
-
- return network_struct