From 0b21a6d8dd7278dcf1d6a6d0ecd16e15fca3724b Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Sat, 3 Jan 2015 12:03:38 -0800 Subject: [PATCH] update to make use of renamed NetworkTemplate fields --- planetstack/core/admin.py | 6 ++-- planetstack/core/models/network.py | 28 +++++++++---------- .../xoslib/static/js/xoslib/xos-backbone.js | 5 ++-- .../xoslib/static/js/xoslib/xos-defaults.js | 2 +- .../xoslib/static/js/xoslib/xos-validators.js | 2 +- planetstack/openstack/manager.py | 14 +++++----- .../steps/sync_network_slivers.py | 2 +- .../openstack_observer/steps/sync_slivers.py | 4 +-- 8 files changed, 32 insertions(+), 31 deletions(-) diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py index 8580177..d027a2e 100644 --- a/planetstack/core/admin.py +++ b/planetstack/core/admin.py @@ -1532,12 +1532,12 @@ class NetworkAdmin(PlanetStackBaseAdmin): class NetworkTemplateAdmin(PlanetStackBaseAdmin): - list_display = ("backend_status_icon", "name", "guaranteedBandwidth", "visibility") + list_display = ("backend_status_icon", "name", "guaranteed_bandwidth", "visibility") list_display_links = ('backend_status_icon', 'name', ) - user_readonly_fields = ["name", "guaranteedBandwidth", "visibility"] + user_readonly_fields = ["name", "guaranteed_bandwidth", "visibility"] user_readonly_inlines = [] fieldsets = [ - (None, {'fields': ['name', 'description', 'guaranteedBandwidth', 'visibility', 'translation', 'sharedNetworkName', 'sharedNetworkId', 'topologyKind', 'controllerKind'], + (None, {'fields': ['name', 'description', 'guaranteed_bandwidth', 'visibility', 'translation', 'shared_network_name', 'shared_network_id', 'topology_kind', 'controller_kind'], 'classes':['suit-tab suit-tab-general']}),] suit_form_tabs = (('general','Network Template Details'), ) diff --git a/planetstack/core/models/network.py b/planetstack/core/models/network.py index e09cb9d..eeacc1a 100644 --- a/planetstack/core/models/network.py +++ b/planetstack/core/models/network.py @@ -70,28 +70,28 @@ class NetworkTemplate(PlCoreBase): name = models.CharField(max_length=32) description = models.CharField(max_length=1024, blank=True, null=True) - guaranteedBandwidth = models.IntegerField(default=0) + guaranteed_bandwidth = models.IntegerField(default=0) visibility = models.CharField(max_length=30, choices=VISIBILITY_CHOICES, default="private") translation = models.CharField(max_length=30, choices=TRANSLATION_CHOICES, default="none") - sharedNetworkName = models.CharField(max_length=30, blank=True, null=True) - sharedNetworkId = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum network") - topologyKind = models.CharField(null=False, blank=False, max_length=30, choices=TOPOLOGY_CHOICES, default="BigSwitch") - controllerKind = models.CharField(null=True, blank=True, max_length=30, choices=CONTROLLER_CHOICES, default=None) + shared_network_name = models.CharField(max_length=30, blank=True, null=True) + shared_network_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum network") + topology_kind = models.CharField(null=False, blank=False, max_length=30, choices=TOPOLOGY_CHOICES, default="BigSwitch") + controller_kind = models.CharField(null=True, blank=True, max_length=30, choices=CONTROLLER_CHOICES, default=None) def __init__(self, *args, **kwargs): super(NetworkTemplate, self).__init__(*args, **kwargs) # somehow these got set wrong inside of the live database. Remove this # code after all is well... - if (self.topologyKind=="BigSwitch"): - print "XXX warning: topologyKind invalid case" - self.topologyKind="bigswitch" - elif (self.topologyKind=="Physical"): - print "XXX warning: topologyKind invalid case" - self.topologyKind="physical" - elif (self.topologyKind=="Custom"): - print "XXX warning: topologyKind invalid case" - self.toplogyKind="custom" + if (self.topology_kind=="BigSwitch"): + print "XXX warning: topology_kind invalid case" + self.topology_kind="bigswitch" + elif (self.topology_kind=="Physical"): + print "XXX warning: topology_kind invalid case" + self.topology_kind="physical" + elif (self.topology_kind=="Custom"): + print "XXX warning: topology_kind invalid case" + self.toplogy_kind="custom" def __unicode__(self): return u'%s' % (self.name) diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js index d59d538..952dfb4 100644 --- a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js +++ b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js @@ -500,6 +500,7 @@ if (! window.XOSLIB_LOADED ) { }); define_model(this, {urlRoot: SITEDEPLOYMENT_API, + relatedCollections: {"controllerSiteDeployments": "site_deployment"}, foreignCollections: ["sites", "deployments", "controllers"], foreignFields: {"site": "sites", "deployment": "deployments", "controller": "controllers"}, modelName: "siteDeployment", @@ -535,8 +536,8 @@ if (! window.XOSLIB_LOADED ) { define_model(this, {urlRoot: NETWORKTEMPLATE_API, modelName: "networkTemplate", - listFields: ["backend_status", "id", "name", "visibility", "translation", "sharedNetworkName", "sharedNetworkId"], - detailFields: ["backend_status", "name", "description", "visibility", "translation", "sharedNetworkName", "sharedNetworkId"], + listFields: ["backend_status", "id", "name", "visibility", "translation", "shared_network_name", "shared_network_id"], + detailFields: ["backend_status", "name", "description", "visibility", "translation", "shared_network_name", "shared_network_id"], }); define_model(this, {urlRoot: NETWORK_API, diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-defaults.js b/planetstack/core/xoslib/static/js/xoslib/xos-defaults.js index 314d3be..b536eaf 100644 --- a/planetstack/core/xoslib/static/js/xoslib/xos-defaults.js +++ b/planetstack/core/xoslib/static/js/xoslib/xos-defaults.js @@ -15,7 +15,7 @@ function xos_get_defaults() { this.networkParameterType = {"updated": null, "description": "", "created": null, "deleted": false, "enacted": null, "backend_status": "Provisioning in progress", "name": ""}; this.networkSlice = {"updated": null, "slice": null, "network": null, "created": null, "deleted": false, "backend_status": "Provisioning in progress", "enacted": null}; this.networkSliver = {"updated": null, "network": null, "created": null, "deleted": false, "ip": null, "enacted": null, "backend_status": "Provisioning in progress", "port_id": null, "sliver": null}; - this.networkTemplate = {"enacted": null, "updated": null, "backend_status": "Provisioning in progress", "description": null, "created": null, "deleted": false, "sharedNetworkName": null, "guaranteedBandwidth": 0, "visibility": "private", "translation": "none", "sharedNetworkId": null, "name": ""}; + this.networkTemplate = {"enacted": null, "updated": null, "backend_status": "Provisioning in progress", "description": null, "created": null, "deleted": false, "shared_network_name": null, "guaranteed_bandwidth": 0, "visibility": "private", "translation": "none", "shared_network_id": null, "name": ""}; this.node = {"updated": null, "name": "", "created": null, "deleted": false, "site": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null}; this.payment = {"updated": null, "created": null, "deleted": false, "account": null, "amount": 0.0, "date": "2014-11-12T01:19:50.077Z", "backend_status": "Provisioning in progress", "enacted": null}; this.planetStack = {"updated": null, "description": "PlanetStack", "created": null, "deleted": false, "backend_status": "Provisioning in progress", "enacted": null}; diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-validators.js b/planetstack/core/xoslib/static/js/xoslib/xos-validators.js index 8865ce6..9af6ba7 100644 --- a/planetstack/core/xoslib/static/js/xoslib/xos-validators.js +++ b/planetstack/core/xoslib/static/js/xoslib/xos-validators.js @@ -15,7 +15,7 @@ function xos_get_validators() { this.networkParameterType = {"updated": [], "name": ["notBlank"], "created": [], "deleted": [], "description": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; this.networkSlice = {"updated": [], "slice": ["notBlank"], "network": ["notBlank"], "created": [], "deleted": [], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; this.networkSliver = {"updated": [], "network": ["notBlank"], "created": [], "deleted": [], "ip": [], "sliver": ["notBlank"], "backend_status": ["notBlank"], "port_id": [], "id": [], "enacted": ["notBlank"]}; - this.networkTemplate = {"controllerKind": [], "updated": [], "name": ["notBlank"], "created": [], "deleted": [], "description": [], "sharedNetworkName": [], "guaranteedBandwidth": ["notBlank"], "visibility": ["notBlank"], "topologyKind": ["notBlank"], "sharedNetworkId": [], "translation": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.networkTemplate = {"controller_kind": [], "updated": [], "name": ["notBlank"], "created": [], "deleted": [], "description": [], "shared_network_name": [], "guaranteed_bandwidth": ["notBlank"], "visibility": ["notBlank"], "topology_kind": ["notBlank"], "shared_network_id": [], "translation": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; this.node = {"updated": [], "name": ["notBlank"], "created": [], "deleted": [], "site": ["notBlank"], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; this.payment = {"updated": [], "created": [], "deleted": [], "account": ["notBlank"], "amount": ["notBlank"], "date": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; this.planetStack = {"updated": [], "description": ["notBlank"], "created": [], "deleted": [], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; diff --git a/planetstack/openstack/manager.py b/planetstack/openstack/manager.py index 9ede33f..c1647e8 100644 --- a/planetstack/openstack/manager.py +++ b/planetstack/openstack/manager.py @@ -423,8 +423,8 @@ class OpenStackManager: @require_enabled def save_network(self, network): if not network.network_id: - if network.template.sharedNetworkName: - network.network_id = network.template.sharedNetworkId + if network.template.shared_network_name: + network.network_id = network.template.shared_network_id (network.subnet_id, network.subnet) = self.driver.get_network_subnet(network.network_id) else: network_name = network.name @@ -471,10 +471,10 @@ class OpenStackManager: self.driver.delete_network(network.network_id) def save_network_template(self, template): - if (template.sharedNetworkName) and (not template.sharedNetworkId): - os_networks = self.driver.shell.quantum.list_networks(name=template.sharedNetworkName)['networks'] + if (template.shared_network_name) and (not template.shared_network_id): + os_networks = self.driver.shell.quantum.list_networks(name=template.shared_network_name)['networks'] if os_networks: - template.sharedNetworkId = os_networks[0]["id"] + template.shared_network_id = os_networks[0]["id"] template.save() template.enacted = datetime.now() @@ -505,8 +505,8 @@ class OpenStackManager: def refresh_network_templates(self): for template in NetworkTemplate.objects.all(): - if (template.sharedNetworkName) and (not template.sharedNetworkId): - # this will cause us to try to fill in the sharedNetworkId + if (template.shared_network_name) and (not template.shared_network_id): + # this will cause us to try to fill in the shared_network_id self.save_network_template(template) def refresh_networks(self): diff --git a/planetstack/openstack_observer/steps/sync_network_slivers.py b/planetstack/openstack_observer/steps/sync_network_slivers.py index 22cfa82..16bc5a2 100644 --- a/planetstack/openstack_observer/steps/sync_network_slivers.py +++ b/planetstack/openstack_observer/steps/sync_network_slivers.py @@ -85,7 +85,7 @@ class SyncNetworkSlivers(OpenStackSyncStep): continue - if network.template.sharedNetworkName: + if network.template.shared_network_name: # 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. diff --git a/planetstack/openstack_observer/steps/sync_slivers.py b/planetstack/openstack_observer/steps/sync_slivers.py index 6f61f53..6855785 100644 --- a/planetstack/openstack_observer/steps/sync_slivers.py +++ b/planetstack/openstack_observer/steps/sync_slivers.py @@ -55,8 +55,8 @@ class SyncSlivers(OpenStackSyncStep): nics.append(controller_network.net_id) # now include network template - network_templates = [network.template.sharedNetworkName for network in networks \ - if network.template.sharedNetworkName] + network_templates = [network.template.shared_network_name for network in networks \ + if network.template.shared_network_name] #driver = self.driver.client_driver(caller=sliver.creator, tenant=sliver.slice.name, controller=sliver.controllerNetwork) driver = self.driver.admin_driver(tenant='admin', controller=sliver.controllerNetwork) -- 2.43.0