tabs, bugfixes
diff --git a/planetstack/observer/steps/sync_networks.py b/planetstack/observer/steps/sync_networks.py
index f87d241..656ae68 100644
--- a/planetstack/observer/steps/sync_networks.py
+++ b/planetstack/observer/steps/sync_networks.py
@@ -5,54 +5,54 @@
from core.models.network import *
class SyncNetworks(OpenStackSyncStep):
- provides=[Network]
- requested_interval = 0
+ provides=[Network]
+ requested_interval = 0
- def save_network(self, network):
- if not network.network_id:
- if network.template.sharedNetworkName:
- network.network_id = network.template.sharedNetworkId
- (network.subnet_id, network.subnet) = self.driver.get_network_subnet(network.network_id)
- else:
- network_name = network.name
+ def save_network(self, network):
+ if not network.network_id:
+ if network.template.sharedNetworkName:
+ network.network_id = network.template.sharedNetworkId
+ (network.subnet_id, network.subnet) = self.driver.get_network_subnet(network.network_id)
+ else:
+ network_name = network.name
- # create network
- os_network = self.driver.create_network(network_name, shared=True)
- network.network_id = os_network['id']
+ # create network
+ os_network = self.driver.create_network(network_name, shared=True)
+ network.network_id = os_network['id']
- # create router
- router = self.driver.create_router(network_name)
- network.router_id = router['id']
+ # create router
+ router = self.driver.create_router(network_name)
+ network.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=network_name,
- network_id = network.network_id,
- cidr_ip = cidr,
- ip_version = ip_version,
- start = start,
- end = end)
- network.subnet = cidr
- network.subnet_id = subnet['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=network_name,
+ network_id = network.network_id,
+ cidr_ip = cidr,
+ ip_version = ip_version,
+ start = start,
+ end = end)
+ network.subnet = cidr
+ network.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)
- def sync_record(self, site):
- if network.owner and network.owner.creator:
- try:
- # update manager context
+ def sync_record(self, site):
+ if network.owner and network.owner.creator:
+ try:
+ # update manager context
real_driver = self.driver
self.driver = self.driver.client_driver(network.owner.creator, network.owner.name)
- self.save_network(network)
+ self.save_network(network)
self.driver = real_driver
- logger.info("saved network: %s" % (network))
- except Exception,e:
- logger.log_exc("save network failed: %s" % network)
- raise e
+ logger.info("saved network: %s" % (network))
+ except Exception,e:
+ logger.log_exc("save network failed: %s" % network)
+ raise e
diff --git a/planetstack/observer/steps/sync_slice_memberships.py b/planetstack/observer/steps/sync_slice_memberships.py
index 66953f1..1ec3a96 100644
--- a/planetstack/observer/steps/sync_slice_memberships.py
+++ b/planetstack/observer/steps/sync_slice_memberships.py
@@ -5,10 +5,10 @@
from core.models.slice import *
class SyncSliceMemberships(OpenStackSyncStep):
- requested_interval=0
- provides=[SliceMembership]
- def sync_record(self, user):
- if slice_memb.user.kuser_id and slice_memb.slice.tenant_id:
- self.driver.add_user_role(slice_memb.user.kuser_id,
- slice_memb.slice.tenant_id,
- slice_memb.role.role_type)
+ requested_interval=0
+ provides=[SliceRole]
+ def sync_record(self, user):
+ if slice_memb.user.kuser_id and slice_memb.slice.tenant_id:
+ self.driver.add_user_role(slice_memb.user.kuser_id,
+ slice_memb.slice.tenant_id,
+ slice_memb.role.role_type)
diff --git a/planetstack/observer/steps/sync_sliver_ips.py b/planetstack/observer/steps/sync_sliver_ips.py
index d231d13..50ec6ad 100644
--- a/planetstack/observer/steps/sync_sliver_ips.py
+++ b/planetstack/observer/steps/sync_sliver_ips.py
@@ -5,21 +5,21 @@
from core.models.sliver import Sliver
class SyncSliverIps(OpenStackSyncStep):
- provides=[Sliver]
- requested_interval=0
- def fetch_pending(self):
- slivers = Sliver.objects.filter(ip=None)
- return slivers
+ provides=[Sliver]
+ requested_interval=0
+ def fetch_pending(self):
+ slivers = Sliver.objects.filter(ip=None)
+ return slivers
- def sync_record(self, sliver):
+ def sync_record(self, sliver):
driver = self.driver.client_driver(tenant=sliver.slice.name)
- servers = driver.shell.nova.servers.findall(id=sliver.instance_id)
- if not servers:
- return
- server = servers[0]
- ips = server.addresses.get(sliver.slice.name, [])
- if not ips:
- return
- sliver.ip = ips[0]['addr']
- sliver.save()
- logger.info("saved sliver ip: %s %s" % (sliver, ips[0]))
+ servers = driver.shell.nova.servers.findall(id=sliver.instance_id)
+ if not servers:
+ return
+ server = servers[0]
+ ips = server.addresses.get(sliver.slice.name, [])
+ if not ips:
+ return
+ sliver.ip = ips[0]['addr']
+ sliver.save()
+ logger.info("saved sliver ip: %s %s" % (sliver, ips[0]))
diff --git a/planetstack/observer/steps/sync_users.py b/planetstack/observer/steps/sync_users.py
index aa665be..dde8a24 100644
--- a/planetstack/observer/steps/sync_users.py
+++ b/planetstack/observer/steps/sync_users.py
@@ -5,32 +5,32 @@
from core.models.user import User
class SyncUsers(OpenStackSyncStep):
- provides=[User]
- requested_interval=0
- def sync_record(self, user):
- name = user.email[:user.email.find('@')]
- user_fields = {'name': name,
- 'email': user.email,
- 'password': hashlib.md5(user.password).hexdigest()[:6],
- 'enabled': True}
- if not user.kuser_id:
- keystone_user = self.driver.create_user(**user_fields)
- user.kuser_id = keystone_user.id
- else:
- self.driver.update_user(user.kuser_id, user_fields)
+ provides=[User]
+ requested_interval=0
+ def sync_record(self, user):
+ name = user.email[:user.email.find('@')]
+ user_fields = {'name': name,
+ 'email': user.email,
+ 'password': hashlib.md5(user.password).hexdigest()[:6],
+ 'enabled': True}
+ if not user.kuser_id:
+ keystone_user = self.driver.create_user(**user_fields)
+ user.kuser_id = keystone_user.id
+ else:
+ self.driver.update_user(user.kuser_id, user_fields)
- if user.site:
- self.driver.add_user_role(user.kuser_id, user.site.tenant_id, 'user')
- if user.is_admin:
- self.driver.add_user_role(user.kuser_id, user.site.tenant_id, 'admin')
- else:
- # may have admin role so attempt to remove it
- self.driver.delete_user_role(user.kuser_id, user.site.tenant_id, 'admin')
+ if user.site:
+ self.driver.add_user_role(user.kuser_id, user.site.tenant_id, 'user')
+ if user.is_admin:
+ self.driver.add_user_role(user.kuser_id, user.site.tenant_id, 'admin')
+ else:
+ # may have admin role so attempt to remove it
+ self.driver.delete_user_role(user.kuser_id, user.site.tenant_id, 'admin')
- if user.public_key:
+ if user.public_key:
driver = self.driver.client_driver(caller=user, tenant=user.site.login_base)
key_fields = {'name': user.keyname,
'public_key': user.public_key}
driver.create_keypair(**key_fields)
- user.save()
+ user.save()