CORD-1010 Fix sync steps in openstack synchronizer
Change-Id: I372e91b3c9603bb2c993c6a1b570cfc395e61b36
diff --git a/xos/synchronizer/model-deps b/xos/synchronizer/model-deps
new file mode 100644
index 0000000..59bbe25
--- /dev/null
+++ b/xos/synchronizer/model-deps
@@ -0,0 +1,117 @@
+{
+ "Slice": [
+ "Site",
+ "User"
+ ],
+ "ImageDeployments": [
+ "Image",
+ "Deployment"
+ ],
+ "ControllerImages": [
+ "Image"
+ ],
+ "ReservedResource": [
+ "Instance"
+ ],
+ "ControllerNetwork": [
+ "Network",
+ "Controller"
+ ],
+ "NetworkSlice": [
+ "Network",
+ "Slice"
+ ],
+ "Charge": [
+ "Account",
+ "Slice",
+ "Invoice"
+ ],
+ "ControllerSite": [
+ "Site",
+ "Controller"
+ ],
+ "Node": [
+ "Site"
+ ],
+ "ControllerSlice": [
+ "Controller",
+ "Slice"
+ ],
+ "ControllerSitePrivilege": [
+ "Controller"
+ ],
+ "ControllerUser": [
+ "User",
+ "Controller"
+ ],
+ "UserCredential": [
+ "User"
+ ],
+ "UserDashboardView": [
+ "User",
+ "DashboardView"
+ ],
+ "Controller": [
+ "Deployment"
+ ],
+ "User": [
+ "Site"
+ ],
+ "SliceTag": [
+ "Slice"
+ ],
+ "Reservation": [
+ "Slice"
+ ],
+ "Instance": [
+ "Image",
+ "User",
+ "Slice"
+ ],
+ "Payment": [
+ "Account"
+ ],
+ "Account": [
+ "Site"
+ ],
+ "ControllerSlicePrivilege": [
+ "Controller"
+ ],
+ "SiteDeployment": [
+ "Site",
+ "Deployment",
+ "Controller"
+ ],
+ "SlicePrivilege": [
+ "User",
+ "Slice",
+ "Role"
+ ],
+ "Port": [
+ "Network",
+ "Instance"
+ ],
+ "SitePrivilege": [
+ "User",
+ "Site",
+ "Role"
+ ],
+ "SiteCredential": [
+ "Site"
+ ],
+ "DeploymentPrivilege": [
+ "User",
+ "Deployment",
+ "Role"
+ ],
+ "ControllerDashboardView": [
+ "Controller",
+ "DashboardView"
+ ],
+ "Invoice": [
+ "Account"
+ ],
+ "SliceCredential": [
+ "Slice"
+ ]
+}
diff --git a/xos/synchronizer/openstack_from_api_config b/xos/synchronizer/openstack_from_api_config
index 066ca22..9c37359 100644
--- a/xos/synchronizer/openstack_from_api_config
+++ b/xos/synchronizer/openstack_from_api_config
@@ -7,7 +7,7 @@
# Sets options for the synchronizer
[observer]
name=openstack
-dependency_graph=/opt/xos/model-deps
+dependency_graph=/opt/xos/synchronizers/openstack/model-deps
steps_dir=/opt/xos/synchronizers/openstack/steps
sys_dir=/opt/xos/synchronizers/openstack/sys
model_policies_dir=/opt/xos/synchronizers/openstack/model_policies
diff --git a/xos/synchronizer/steps/sync_instances.py b/xos/synchronizer/steps/sync_instances.py
index 3682fd3..c43498f 100644
--- a/xos/synchronizer/steps/sync_instances.py
+++ b/xos/synchronizer/steps/sync_instances.py
@@ -2,13 +2,15 @@
import base64
import socket
from xos.config import Config
-from xos.settings import RESTAPI_HOSTNAME, RESTAPI_PORT
from synchronizers.openstack.openstacksyncstep import OpenStackSyncStep
from synchronizers.new_base.ansible_helper import *
from synchronizers.new_base.syncstep import *
from xos.logger import observer_logger as logger
from synchronizers.new_base.modelaccessor import *
+RESTAPI_HOSTNAME = getattr(Config(), "server_restapi_hostname", getattr(Config(), "server_hostname", socket.gethostname()))
+RESTAPI_PORT = int(getattr(Config(), "server_restapi_port", getattr(Config(), "server_port", "8000")))
+
def escape(s):
s = s.replace('\n',r'\n').replace('"',r'\"')
return s
diff --git a/xos/synchronizer/steps/sync_ports.py b/xos/synchronizer/steps/sync_ports.py
index d6f1303..cfd697f 100644
--- a/xos/synchronizer/steps/sync_ports.py
+++ b/xos/synchronizer/steps/sync_ports.py
@@ -216,7 +216,8 @@
def delete_ports(self):
logger.info("sync'ing Ports [delete=True]")
- for port in Port.deleted_objects.all():
+ ports = self.fetch_pending(deletion=True)
+ for port in ports:
self.delete_record(port)
def delete_record(self, port):