add network template to requested networks
diff --git a/planetstack/observer/steps/sync_slivers.py b/planetstack/observer/steps/sync_slivers.py
index a6ce1cd..299d079 100644
--- a/planetstack/observer/steps/sync_slivers.py
+++ b/planetstack/observer/steps/sync_slivers.py
@@ -5,7 +5,7 @@
from observer.openstacksyncstep import OpenStackSyncStep
from core.models.sliver import Sliver
from core.models.slice import SlicePrivilege, SliceDeployments
-from core.models.network import NetworkDeployments
+from core.models.network import Network, NetworkDeployments
from util.logger import Logger, logging
logger = Logger(level=logging.INFO)
@@ -17,13 +17,6 @@
def fetch_pending(self):
return Sliver.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- def get_requested_networks(self, slice, deployment):
- requested_networks = []
- networks = slice.networks.all()
- network_deployments = NetworkDeployments.objects.filter(network__in=networks, deployment=deployment)
- requested_networks = [{'net-id': nd.net_id} for nd in network_deployments]
- return requested_networks
-
def sync_record(self, sliver):
logger.info("sync'ing sliver:%s deployment:%s " % (sliver, sliver.node.deployment))
metadata_update = {}
@@ -35,13 +28,29 @@
metadata_update[tag.name] = tag.value
if not sliver.instance_id:
- nics = self.get_requested_networks(sliver.slice, sliver.node.deployment)
- file("/tmp/scott-manager","a").write("slice: %s\nreq: %s\n" % (str(sliver.slice.name), str(nics)))
+ driver = self.driver.client_driver(caller=sliver.creator, tenant=sliver.slice.name, deployment=sliver.deploymentNetwork.name)
+ # public keys
slice_memberships = SlicePrivilege.objects.filter(slice=sliver.slice)
pubkeys = [sm.user.public_key for sm in slice_memberships if sm.user.public_key]
if sliver.creator.public_key:
pubkeys.append(sliver.creator.public_key)
- driver = self.driver.client_driver(caller=sliver.creator, tenant=sliver.slice.name, deployment=sliver.deploymentNetwork.name)
+
+ # netowrks
+ #nics = self.get_requested_networks(sliver.slice, sliver.node.deployment)
+ nics = []
+ networks = Network.objects.filter(owner=sliver.slice)
+ network_deployments = NetworkDeployments.objects.filter(network__in=networks,
+ deployment=sliver.node.deployment)
+ network_templates = [network.template.sharedNetworkName for network in networks \
+ if network.template.sharedNetworkName]
+ nics = [{'net-id': nd.net_id} for nd in network_deployments]
+ # include network template
+ for net in driver.shell.quantum.list_networks()['networks']:
+ if net['name'] in network_templates:
+ nics.append({'net-id': net['id']})
+
+ file("/tmp/scott-manager","a").write("slice: %s\nreq: %s\n" % (str(sliver.slice.name), str(nics)))
+
# look up image id
deployment_driver = self.driver.admin_driver(deployment=sliver.deploymentNetwork.name)
image_id = None