rename NetworkSliver-->Port in observers
diff --git a/xos/model-deps b/xos/model-deps
index 4866373..7f15774 100644
--- a/xos/model-deps
+++ b/xos/model-deps
@@ -99,7 +99,7 @@
"Slice",
"Role"
],
- "NetworkSliver": [
+ "Port": [
"Network",
"Sliver"
],
diff --git a/xos/observers/hpc/hpc_watcher.py b/xos/observers/hpc/hpc_watcher.py
index 0821e6c..d098257 100644
--- a/xos/observers/hpc/hpc_watcher.py
+++ b/xos/observers/hpc/hpc_watcher.py
@@ -366,7 +366,7 @@
if (network_name is None) or (network_name=="") or (network_name.lower()=="public"):
return sliver.get_public_ip()
- for ns in sliver.networkslivers.all():
+ for ns in sliver.ports.all():
if (ns.ip) and (ns.network.name==network_name):
return ns.ip
diff --git a/xos/observers/vcpe/steps/sync_vcpetenant.py b/xos/observers/vcpe/steps/sync_vcpetenant.py
index f803758..94f6d53 100644
--- a/xos/observers/vcpe/steps/sync_vcpetenant.py
+++ b/xos/observers/vcpe/steps/sync_vcpetenant.py
@@ -68,7 +68,7 @@
for slice in service.slices.all():
if "dnsdemux" in slice.name:
for sliver in slice.slivers.all():
- for ns in sliver.networkslivers.all():
+ for ns in sliver.ports.all():
if ns.ip and ns.network.labels and (vcpe_service.backend_network_label in ns.network.labels):
dnsdemux_ip = ns.ip
if not dnsdemux_ip:
@@ -100,7 +100,7 @@
if vcpe_service.bbs_slice:
if vcpe_service.backend_network_label:
for bbs_sliver in vcpe_service.bbs_slice.slivers.all():
- for ns in bbs_sliver.networkslivers.all():
+ for ns in bbs_sliver.ports.all():
if ns.ip and ns.network.labels and (vcpe_service.backend_network_label in ns.network.labels):
bbs_addrs.append(ns.ip)
else:
diff --git a/xos/openstack_observer/event_loop.py b/xos/openstack_observer/event_loop.py
index 003634b..b6eceb3 100644
--- a/xos/openstack_observer/event_loop.py
+++ b/xos/openstack_observer/event_loop.py
@@ -66,7 +66,6 @@
return ig
class XOSObserver:
- #sync_steps = [SyncNetworks,SyncNetworkSlivers,SyncSites,SyncSitePrivilege,SyncSlices,SyncSliceMemberships,SyncSlivers,SyncSliverIps,SyncExternalRoutes,SyncUsers,SyncRoles,SyncNodes,SyncImages,GarbageCollector]
sync_steps = []
@@ -196,7 +195,6 @@
#self.ordered_steps = ['SyncRoles', 'SyncControllerSites', 'SyncControllerSitePrivileges','SyncImages', 'SyncControllerImages','SyncControllerUsers','SyncControllerUserSitePrivileges','SyncControllerSlices', 'SyncControllerSlicePrivileges', 'SyncControllerUserSlicePrivileges', 'SyncControllerNetworks','SyncSlivers']
#self.ordered_steps = ['SyncControllerSites','SyncRoles','SyncControllerUsers','SyncControllerSlices','SyncControllerNetworks']
#self.ordered_steps = ['SyncControllerNetworks']
- #self.ordered_steps = ['SyncSlivers','SyncNetworkSlivers']
print "Order of steps=",self.ordered_steps
diff --git a/xos/openstack_observer/steps/sync_network_slivers.py b/xos/openstack_observer/steps/sync_ports.py
similarity index 76%
rename from xos/openstack_observer/steps/sync_network_slivers.py
rename to xos/openstack_observer/steps/sync_ports.py
index c46ca55..259245a 100644
--- a/xos/openstack_observer/steps/sync_network_slivers.py
+++ b/xos/openstack_observer/steps/sync_ports.py
@@ -7,10 +7,10 @@
from core.models.network import *
from util.logger import observer_logger as logger
-class SyncNetworkSlivers(OpenStackSyncStep):
+class SyncPorts(OpenStackSyncStep):
requested_interval = 0 # 3600
- provides=[NetworkSliver]
- observes=NetworkSliver
+ provides=[Port]
+ observes=Port
# The way it works is to enumerate the all of the ports that quantum
# has, and then work backward from each port's network-id to determine
@@ -19,12 +19,12 @@
def call(self, **args):
logger.info("sync'ing network slivers")
- 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
+ ports = Port.objects.all()
+ ports_by_id = {}
+ ports_by_neutron_port = {}
+ for port in ports:
+ ports_by_id[port.id] = port
+ ports_by_neutron_port[port.port_id] = port
networks = Network.objects.all()
networks_by_id = {}
@@ -74,7 +74,7 @@
for port in ports_by_id.values():
#logger.info("port %s" % str(port))
- if port["id"] in networkSlivers_by_port:
+ if port["id"] in ports_by_neutron_port:
# we already have it
#logger.info("already accounted for port %s" % port["id"])
continue
@@ -127,9 +127,9 @@
continue
ip=port["fixed_ips"][0]["ip_address"]
- logger.info("creating NetworkSliver (%s, %s, %s, %s)" % (str(network), str(sliver), ip, str(port["id"])))
+ logger.info("creating Port (%s, %s, %s, %s)" % (str(network), str(sliver), ip, str(port["id"])))
- ns = NetworkSliver(network=network,
+ ns = Port(network=network,
sliver=sliver,
ip=ip,
port_id=port["id"])
@@ -137,27 +137,27 @@
try:
ns.save()
except:
- logger.log_exc("failed to save networksliver %s" % str(ns))
+ logger.log_exc("failed to save port %s" % str(ns))
continue
- # For networkSlivers that were created by the user, find that ones
+ # For ports that were created by the user, find that ones
# that don't have neutron ports, and create them.
- for networkSliver in NetworkSliver.objects.filter(port_id__isnull=True, sliver__isnull=False):
- #logger.info("XXX working on networksliver %s" % networkSliver)
- controller = networkSliver.sliver.node.site_deployment.controller
+ for port in Port.objects.filter(port_id__isnull=True, sliver__isnull=False):
+ #logger.info("XXX working on port %s" % port)
+ controller = port.sliver.node.site_deployment.controller
if controller:
- cn=networkSliver.network.controllernetworks.filter(controller=controller)
+ cn=port.network.controllernetworks.filter(controller=controller)
if not cn:
- logger.log_exc("no controllernetwork for %s" % networkSliver)
+ logger.log_exc("no controllernetwork for %s" % port)
continue
cn=cn[0]
if cn.lazy_blocked:
cn.lazy_blocked=False
cn.save()
- logger.info("deferring networkSliver %s because controllerNetwork was lazy-blocked" % networkSliver)
+ logger.info("deferring port %s because controllerNetwork was lazy-blocked" % port)
continue
if not cn.net_id:
- logger.info("deferring networkSliver %s because controllerNetwork does not have a port-id yet" % networkSliver)
+ logger.info("deferring port %s because controllerNetwork does not have a port-id yet" % port)
continue
try:
# We need to use a client driver that specifies the tenant
@@ -169,38 +169,38 @@
# not being in working condition.
from openstack.client import OpenStackClient
from openstack.driver import OpenStackDriver
- caller = networkSliver.network.owner.creator
+ caller = port.network.owner.creator
auth = {'username': caller.email,
'password': caller.remote_password,
- 'tenant': networkSliver.sliver.slice.name} # networkSliver.network.owner.name}
+ 'tenant': port.sliver.slice.name} # port.network.owner.name}
client = OpenStackClient(controller=controller, **auth) # cacert=self.config.nova_ca_ssl_cert,
driver = OpenStackDriver(client=client)
port = driver.shell.quantum.create_port({"port": {"network_id": cn.net_id}})["port"]
- networkSliver.port_id = port["id"]
+ port.port_id = port["id"]
if port["fixed_ips"]:
- networkSliver.ip = port["fixed_ips"][0]["ip_address"]
+ port.ip = port["fixed_ips"][0]["ip_address"]
except:
- logger.log_exc("failed to create neutron port for %s" % networkSliver)
+ logger.log_exc("failed to create neutron port for %s" % port)
continue
- networkSliver.save()
+ port.save()
# Now, handle port forwarding
- # We get the list of NetworkSlivers again, since we might have just
+ # We get the list of Ports again, since we might have just
# added a few. Then, for each one of them we find it's quantum port and
# make sure quantum's nat:forward_ports argument is the same.
- for networkSliver in NetworkSliver.objects.all():
+ for port in Port.objects.all():
try:
- nat_list = networkSliver.network.nat_list
+ nat_list = port.network.nat_list
except (TypeError, ValueError), e:
logger.info("Failed to decode nat_list: %s" % str(e))
continue
- if not networkSliver.port_id:
+ if not port.port_id:
continue
- neutron_port = ports_by_id.get(networkSliver.port_id, None)
+ neutron_port = ports_by_id.get(port.port_id, None)
if not neutron_port:
continue
@@ -210,15 +210,15 @@
neutron_nat_list = []
if (neutron_nat_list != nat_list):
- logger.info("Setting nat:forward_ports for port %s network %s sliver %s to %s" % (str(networkSliver.port_id), str(networkSliver.network.id), str(networkSliver.sliver), str(nat_list)))
+ logger.info("Setting nat:forward_ports for port %s network %s sliver %s to %s" % (str(port.port_id), str(port.network.id), str(port.sliver), str(nat_list)))
try:
- driver = self.driver.admin_driver(controller=networkSliver.sliver.node.site_deployment.controller,tenant='admin')
- driver.shell.quantum.update_port(networkSliver.port_id, {"port": {"nat:forward_ports": nat_list}})
+ driver = self.driver.admin_driver(controller=port.sliver.node.site_deployment.controller,tenant='admin')
+ driver.shell.quantum.update_port(port.port_id, {"port": {"nat:forward_ports": nat_list}})
except:
logger.log_exc("failed to update port with nat_list %s" % str(nat_list))
continue
else:
- #logger.info("port %s network %s sliver %s nat %s is already set" % (str(networkSliver.port_id), str(networkSliver.network.id), str(networkSliver.sliver), str(nat_list)))
+ #logger.info("port %s network %s sliver %s nat %s is already set" % (str(port.port_id), str(port.network.id), str(port.sliver), str(nat_list)))
pass
def delete_record(self, network_sliver):
diff --git a/xos/openstack_observer/steps/sync_slivers.py b/xos/openstack_observer/steps/sync_slivers.py
index 4c29e3d..d98c2d2 100644
--- a/xos/openstack_observer/steps/sync_slivers.py
+++ b/xos/openstack_observer/steps/sync_slivers.py
@@ -62,7 +62,7 @@
ports = []
exclude_networks = set()
exclude_templates = set()
- for ns in sliver.networkslivers.all():
+ for ns in sliver.ports.all():
if not ns.port_id:
raise DeferredException("Port %s on sliver %s has no id; Try again later" % (str(ns), str(sliver)) )
ports.append(ns.port_id)