tabs
diff --git a/planetstack/observer/steps/sync_network_slivers.py b/planetstack/observer/steps/sync_network_slivers.py
index 4466174..a803053 100644
--- a/planetstack/observer/steps/sync_network_slivers.py
+++ b/planetstack/observer/steps/sync_network_slivers.py
@@ -5,71 +5,71 @@
from core.models.network import *
class SyncNetworkSlivers(OpenStackSyncStep):
- requested_interval = 3600
- provides=[NetworkSliver]
+ requested_interval = 3600
+ provides=[NetworkSliver]
- def call(self):
- networkSlivers = NetworkSliver.objects.all()
- networkSlivers_by_id = {}
- networkSlivers_by_port = {}
- for networkSliver in networkSlivers:
- networkSlivers_by_id[networkSliver.id] = networkSliver
- networkSlivers_by_port[networkSliver.port_id] = networkSliver
+ def call(self):
+ networkSlivers = NetworkSliver.objects.all()
+ networkSlivers_by_id = {}
+ networkSlivers_by_port = {}
+ for networkSliver in networkSlivers:
+ networkSlivers_by_id[networkSliver.id] = networkSliver
+ networkSlivers_by_port[networkSliver.port_id] = networkSliver
- networks = Network.objects.all()
- networks_by_id = {}
- for network in networks:
- networks_by_id[network.network_id] = network
+ networks = Network.objects.all()
+ networks_by_id = {}
+ for network in networks:
+ networks_by_id[network.network_id] = network
- slivers = Sliver.objects.all()
- slivers_by_instance_id = {}
- for sliver in slivers:
- slivers_by_instance_id[sliver.instance_id] = sliver
+ slivers = Sliver.objects.all()
+ slivers_by_instance_id = {}
+ for sliver in slivers:
+ slivers_by_instance_id[sliver.instance_id] = sliver
- ports = self.driver.shell.quantum.list_ports()["ports"]
- for port in ports:
- if port["id"] in networkSlivers_by_port:
- # we already have it
- print "already accounted for port", port["id"]
- continue
+ ports = self.driver.shell.quantum.list_ports()["ports"]
+ for port in ports:
+ if port["id"] in networkSlivers_by_port:
+ # we already have it
+ print "already accounted for port", port["id"]
+ continue
- if port["device_owner"] != "compute:nova":
- # we only want the ports that connect to instances
- continue
+ if port["device_owner"] != "compute:nova":
+ # we only want the ports that connect to instances
+ continue
- network = networks_by_id.get(port['network_id'], None)
- if not network:
- #print "no network for port", port["id"], "network", port["network_id"]
- continue
+ network = networks_by_id.get(port['network_id'], None)
+ if not network:
+ #print "no network for port", port["id"], "network", port["network_id"]
+ continue
- sliver = slivers_by_instance_id.get(port['device_id'], None)
- if not sliver:
- print "no sliver for port", port["id"], "device_id", port['device_id']
- continue
+ sliver = slivers_by_instance_id.get(port['device_id'], None)
+ if not sliver:
+ print "no sliver for port", port["id"], "device_id", port['device_id']
+ continue
- if network.template.sharedNetworkId is not None:
- # If it's a shared network template, then more than one network
- # object maps to the quantum network. We have to do a whole bunch
- # of extra work to find the right one.
- networks = network.template.network_set.all()
- network = None
- for candidate_network in networks:
- if (candidate_network.owner == sliver.slice):
- print "found network", candidate_network
- network = candidate_network
+ if network.template.sharedNetworkId is not None:
+ # If it's a shared network template, then more than one network
+ # object maps to the quantum network. We have to do a whole bunch
+ # of extra work to find the right one.
+ networks = network.template.network_set.all()
+ network = None
+ for candidate_network in networks:
+ if (candidate_network.owner == sliver.slice):
+ print "found network", candidate_network
+ network = candidate_network
- if not network:
- print "failed to find the correct network for a shared template for port", port["id"], "network", port["network_id"]
- continue
+ if not network:
+ print "failed to find the correct network for a shared template for port", port["id"], "network", port["network_id"]
+ continue
- if not port["fixed_ips"]:
- print "port", port["id"], "has no fixed_ips"
- continue
+ if not port["fixed_ips"]:
+ print "port", port["id"], "has no fixed_ips"
+ continue
-# print "XXX", port
+# print "XXX", port
- ns = NetworkSliver(network=network,
- sliver=sliver,
- ip=port["fixed_ips"][0]["ip_address"],
- port_id=port["id"])
- ns.save()
+ ns = NetworkSliver(network=network,
+ sliver=sliver,
+ ip=port["fixed_ips"][0]["ip_address"],
+ port_id=port["id"])
+ ns.save()
diff --git a/planetstack/observer/steps/sync_site_privileges.py b/planetstack/observer/steps/sync_site_privileges.py
index e02dde7..6ec917c 100644
--- a/planetstack/observer/steps/sync_site_privileges.py
+++ b/planetstack/observer/steps/sync_site_privileges.py
@@ -5,14 +5,14 @@
from core.models.site import *
class SyncSitePrivileges(OpenStackSyncStep):
- requested_interval=0
- provides=[SitePrivilege]
+ requested_interval=0
+ provides=[SitePrivilege]
def fetch_pending(self):
return Network.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- def sync_record(self, user):
- if site_priv.user.kuser_id and site_priv.site.tenant_id:
- self.driver.add_user_role(site_priv.user.kuser_id,
- site_priv.site.tenant_id,
- site_priv.role.role_type)
+ def sync_record(self, user):
+ if site_priv.user.kuser_id and site_priv.site.tenant_id:
+ self.driver.add_user_role(site_priv.user.kuser_id,
+ site_priv.site.tenant_id,
+ site_priv.role.role_type)
diff --git a/planetstack/observer/steps/sync_sites.py b/planetstack/observer/steps/sync_sites.py
index ece34af..d7a0ab7 100644
--- a/planetstack/observer/steps/sync_sites.py
+++ b/planetstack/observer/steps/sync_sites.py
@@ -5,29 +5,29 @@
from core.models.site import Site
class SyncSites(OpenStackSyncStep):
- provides=[Site]
- requested_interval=0
+ provides=[Site]
+ requested_interval=0
def fetch_pending(self):
return Site.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- def sync_record(self, site):
- save_site = False
- if not site.tenant_id:
- tenant = self.driver.create_tenant(tenant_name=site.login_base,
- description=site.name,
- enabled=site.enabled)
- site.tenant_id = tenant.id
- save_site = True
- # XXX - What's caller?
- # self.driver.add_user_role(self.caller.kuser_id, tenant.id, 'admin')
+ def sync_record(self, site):
+ save_site = False
+ if not site.tenant_id:
+ tenant = self.driver.create_tenant(tenant_name=site.login_base,
+ description=site.name,
+ enabled=site.enabled)
+ site.tenant_id = tenant.id
+ save_site = True
+ # XXX - What's caller?
+ # self.driver.add_user_role(self.caller.kuser_id, tenant.id, 'admin')
- # update the record
- if site.id and site.tenant_id:
- self.driver.update_tenant(site.tenant_id,
- description=site.name,
- enabled=site.enabled)
+ # update the record
+ if site.id and site.tenant_id:
+ self.driver.update_tenant(site.tenant_id,
+ description=site.name,
+ enabled=site.enabled)
- if (save_site):
- site.save() #
+ if (save_site):
+ site.save() #
diff --git a/planetstack/observer/steps/sync_slices.py b/planetstack/observer/steps/sync_slices.py
index 4f10a14..d5ed266 100644
--- a/planetstack/observer/steps/sync_slices.py
+++ b/planetstack/observer/steps/sync_slices.py
@@ -5,58 +5,58 @@
from core.models.slice import Slice
class SyncSlices(OpenStackSyncStep):
- provides=[Slice]
- requested_interval=0
+ provides=[Slice]
+ requested_interval=0
def fetch_pending(self):
return Slice.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- def sync_record(self, slice):
- if not slice.tenant_id:
- nova_fields = {'tenant_name': slice.name,
- 'description': slice.description,
- 'enabled': slice.enabled}
- tenant = self.driver.create_tenant(**nova_fields)
- slice.tenant_id = tenant.id
+ def sync_record(self, slice):
+ if not slice.tenant_id:
+ nova_fields = {'tenant_name': slice.name,
+ 'description': slice.description,
+ 'enabled': slice.enabled}
+ tenant = self.driver.create_tenant(**nova_fields)
+ slice.tenant_id = tenant.id
- # XXX give caller an admin role at the tenant they've created
- self.driver.add_user_role(self.caller.kuser_id, tenant.id, 'admin')
+ # XXX give caller an admin role at the tenant they've created
+ self.driver.add_user_role(self.caller.kuser_id, tenant.id, 'admin')
- # refresh credentials using this tenant
- self.driver.shell.connect(username=self.driver.shell.keystone.username,
- password=self.driver.shell.keystone.password,
- tenant=tenant.name)
+ # refresh credentials using this tenant
+ self.driver.shell.connect(username=self.driver.shell.keystone.username,
+ password=self.driver.shell.keystone.password,
+ tenant=tenant.name)
- # create network
- network = self.driver.create_network(slice.name)
- slice.network_id = network['id']
+ # create network
+ network = self.driver.create_network(slice.name)
+ slice.network_id = network['id']
- # create router
- router = self.driver.create_router(slice.name)
- slice.router_id = router['id']
+ # create router
+ router = self.driver.create_router(slice.name)
+ slice.router_id = router['id']
- # create subnet
- next_subnet = self.get_next_subnet()
- cidr = str(next_subnet.cidr)
- ip_version = next_subnet.version
- start = str(next_subnet[2])
- end = str(next_subnet[-2])
- subnet = self.driver.create_subnet(name=slice.name,
- network_id = network['id'],
- cidr_ip = cidr,
- ip_version = ip_version,
- start = start,
- end = end)
- slice.subnet_id = subnet['id']
- # add subnet as interface to slice's router
- self.driver.add_router_interface(router['id'], subnet['id'])
- # add external route
- self.driver.add_external_route(subnet)
+ # create subnet
+ next_subnet = self.get_next_subnet()
+ cidr = str(next_subnet.cidr)
+ ip_version = next_subnet.version
+ start = str(next_subnet[2])
+ end = str(next_subnet[-2])
+ subnet = self.driver.create_subnet(name=slice.name,
+ network_id = network['id'],
+ cidr_ip = cidr,
+ ip_version = ip_version,
+ start = start,
+ end = end)
+ slice.subnet_id = subnet['id']
+ # add subnet as interface to slice's router
+ self.driver.add_router_interface(router['id'], subnet['id'])
+ # add external route
+ self.driver.add_external_route(subnet)
- if slice.id and slice.tenant_id:
- self.driver.update_tenant(slice.tenant_id,
- description=slice.description,
- enabled=slice.enabled)
+ if slice.id and slice.tenant_id:
+ self.driver.update_tenant(slice.tenant_id,
+ description=slice.description,
+ enabled=slice.enabled)
- slice.save()
+ slice.save()
diff --git a/planetstack/observer/steps/sync_slivers.py b/planetstack/observer/steps/sync_slivers.py
index e119b0e..74a1b50 100644
--- a/planetstack/observer/steps/sync_slivers.py
+++ b/planetstack/observer/steps/sync_slivers.py
@@ -5,14 +5,14 @@
from core.models.sliver import Sliver
class SyncSlivers(OpenStackSyncStep):
- provides=[Sliver]
- requested_interval=0
+ provides=[Sliver]
+ requested_interval=0
def fetch_pending(self):
return Sliver.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- def sync_record(self, slice):
- if not sliver.instance_id:
+ def sync_record(self, slice):
+ if not sliver.instance_id:
nics = self.get_requested_networks(sliver.slice)
file("/tmp/scott-manager","a").write("slice: %s\nreq: %s\n" % (str(sliver.slice.name), str(nics)))
slice_memberships = SliceMembership.objects.filter(slice=sliver.slice)
@@ -27,7 +27,7 @@
sliver.instance_id = instance.id
sliver.instance_name = getattr(instance, 'OS-EXT-SRV-ATTR:instance_name')
- if sliver.instance_id and ("numberCores" in sliver.changed_fields):
- self.driver.update_instance_metadata(sliver.instance_id, {"cpu_cores": str(sliver.numberCores)})
+ if sliver.instance_id and ("numberCores" in sliver.changed_fields):
+ self.driver.update_instance_metadata(sliver.instance_id, {"cpu_cores": str(sliver.numberCores)})
- sliver.save()
+ sliver.save()