SEBA-405 Cleanup synchronizer imports of model_accessor to globals;
Move mock modelaccessor to /tmp;
Easier mock modelaccessor configuration
Change-Id: I67a17b9a72ea69f61d92206f1b520a11c2f18d80
diff --git a/lib/xos-synchronizer/tests/steps/sync_container.py b/lib/xos-synchronizer/tests/steps/sync_container.py
index baf108f..8cbabcb 100644
--- a/lib/xos-synchronizer/tests/steps/sync_container.py
+++ b/lib/xos-synchronizer/tests/steps/sync_container.py
@@ -21,7 +21,6 @@
import time
from xossynchronizer.steps.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
from xossynchronizer.steps.syncstep import DeferredException
-from xossynchronizer.mock_modelaccessor import *
# hpclibrary will be in steps/..
parentdir = os.path.join(os.path.dirname(__file__), "..")
@@ -29,19 +28,18 @@
class SyncContainer(SyncInstanceUsingAnsible):
- provides = [Instance]
- observes = Instance
+ observes = "Instance"
template_name = "sync_container.yaml"
def __init__(self, *args, **kwargs):
super(SyncContainer, self).__init__(*args, **kwargs)
def fetch_pending(self, deletion=False):
- i = Instance()
+ i = self.model_accessor.Instance()
i.name = "Spectacular Sponge"
- j = Instance()
+ j = self.model_accessor.Instance()
j.name = "Spontaneous Tent"
- k = Instance()
+ k = self.model_accessor.Instance()
k.name = "Embarrassed Cat"
objs = [i, j, k]
diff --git a/lib/xos-synchronizer/tests/steps/sync_controller_images.py b/lib/xos-synchronizer/tests/steps/sync_controller_images.py
index 84a43b1..ef85983 100644
--- a/lib/xos-synchronizer/tests/steps/sync_controller_images.py
+++ b/lib/xos-synchronizer/tests/steps/sync_controller_images.py
@@ -16,17 +16,15 @@
import os
import base64
from xossynchronizer.steps.syncstep import SyncStep
-from xossynchronizer.mock_modelaccessor import *
class SyncControllerImages(SyncStep):
- provides = [ControllerImages]
- observes = ControllerImages
+ observes = "ControllerImages"
requested_interval = 0
playbook = "sync_controller_images.yaml"
def fetch_pending(self, deleted):
- ci = ControllerImages()
- i = Image()
+ ci = self.model_accessor.ControllerImages()
+ i = self.model_accessor.Image()
i.name = "Lush Loss"
ci.i = i
return [ci]
diff --git a/lib/xos-synchronizer/tests/steps/sync_controller_networks.py b/lib/xos-synchronizer/tests/steps/sync_controller_networks.py
index 1133545..55dfe4e 100644
--- a/lib/xos-synchronizer/tests/steps/sync_controller_networks.py
+++ b/lib/xos-synchronizer/tests/steps/sync_controller_networks.py
@@ -19,20 +19,18 @@
import socket
from netaddr import IPAddress, IPNetwork
from xossynchronizer.steps.syncstep import SyncStep
-from xossynchronizer.mock_modelaccessor import *
class SyncControllerNetworks(SyncStep):
requested_interval = 0
- provides = [Network]
- observes = ControllerNetwork
- external_dependencies = [User]
+ observes = "ControllerNetwork"
+ external_dependencies = ["User"]
playbook = "sync_controller_networks.yaml"
def fetch_pending(self, deleted):
- ci = ControllerNetwork()
- i = Network()
+ ci = self.model_accessor.ControllerNetwork()
+ i = self.model_accessor.Network()
i.name = "Lush Loss"
- s = Slice()
+ s = self.model_accessor.Slice()
s.name = "Ghastly Notebook"
i.owner = s
ci.i = i
diff --git a/lib/xos-synchronizer/tests/steps/sync_controller_site_privileges.py b/lib/xos-synchronizer/tests/steps/sync_controller_site_privileges.py
index 65d3985..e286ef8 100644
--- a/lib/xos-synchronizer/tests/steps/sync_controller_site_privileges.py
+++ b/lib/xos-synchronizer/tests/steps/sync_controller_site_privileges.py
@@ -17,12 +17,10 @@
import base64
import json
from xossynchronizer.steps.syncstep import SyncStep
-from xossynchronizer.mock_modelaccessor import *
class SyncControllerSitePrivileges(SyncStep):
- provides = [SitePrivilege]
requested_interval = 0
- observes = ControllerSitePrivilege
+ observes = "ControllerSitePrivilege"
playbook = "sync_controller_users.yaml"
def map_sync_inputs(self, controller_site_privilege):
diff --git a/lib/xos-synchronizer/tests/steps/sync_controller_sites.py b/lib/xos-synchronizer/tests/steps/sync_controller_sites.py
index 509a45c..24aa76f 100644
--- a/lib/xos-synchronizer/tests/steps/sync_controller_sites.py
+++ b/lib/xos-synchronizer/tests/steps/sync_controller_sites.py
@@ -17,12 +17,10 @@
import base64
import json
from xossynchronizer.steps.syncstep import SyncStep
-from xossynchronizer.mock_modelaccessor import *
class SyncControllerSites(SyncStep):
requested_interval = 0
- provides = [Site]
- observes = ControllerSite
+ observes = "ControllerSite"
playbook = "sync_controller_sites.yaml"
def fetch_pending(self, deleted=False):
diff --git a/lib/xos-synchronizer/tests/steps/sync_controller_slice_privileges.py b/lib/xos-synchronizer/tests/steps/sync_controller_slice_privileges.py
index ec0667c..09b63e6 100644
--- a/lib/xos-synchronizer/tests/steps/sync_controller_slice_privileges.py
+++ b/lib/xos-synchronizer/tests/steps/sync_controller_slice_privileges.py
@@ -17,12 +17,10 @@
import base64
import json
from xossynchronizer.steps.syncstep import SyncStep
-from xossynchronizer.mock_modelaccessor import *
class SyncControllerSlicePrivileges(SyncStep):
- provides = [SlicePrivilege]
requested_interval = 0
- observes = ControllerSlicePrivilege
+ observes = "ControllerSlicePrivilege"
playbook = "sync_controller_users.yaml"
def map_sync_inputs(self, controller_slice_privilege):
diff --git a/lib/xos-synchronizer/tests/steps/sync_controller_slices.py b/lib/xos-synchronizer/tests/steps/sync_controller_slices.py
index 0f43bad..31c62f1 100644
--- a/lib/xos-synchronizer/tests/steps/sync_controller_slices.py
+++ b/lib/xos-synchronizer/tests/steps/sync_controller_slices.py
@@ -15,13 +15,12 @@
import os
import base64
-from xossynchronizer.steps.syncstep import SyncStep, DeferredException
-from xossynchronizer.mock_modelaccessor import *
+from xossynchronizer.steps.syncstep import DeferredException
+from xossynchronizer.steps.ansiblesyncstep import AnsibleSyncStep
-class SyncControllerSlices(SyncStep):
- provides = [Slice]
+class SyncControllerSlices(AnsibleSyncStep):
requested_interval = 0
- observes = ControllerSlice
+ observes = "ControllerSlice"
playbook = "sync_controller_slices.yaml"
def map_sync_inputs(self, controller_slice):
diff --git a/lib/xos-synchronizer/tests/steps/sync_controller_users.py b/lib/xos-synchronizer/tests/steps/sync_controller_users.py
index 881e78a..a039257 100644
--- a/lib/xos-synchronizer/tests/steps/sync_controller_users.py
+++ b/lib/xos-synchronizer/tests/steps/sync_controller_users.py
@@ -16,13 +16,11 @@
import os
import base64
from xossynchronizer.steps.syncstep import SyncStep
-from xossynchronizer.mock_modelaccessor import *
class SyncControllerUsers(SyncStep):
- provides = [User]
requested_interval = 0
- observes = ControllerUser
+ observes = "ControllerUser"
playbook = "sync_controller_users.yaml"
def map_sync_inputs(self, controller_user):
diff --git a/lib/xos-synchronizer/tests/steps/sync_images.py b/lib/xos-synchronizer/tests/steps/sync_images.py
index 2284ed2..b3ed9bd 100644
--- a/lib/xos-synchronizer/tests/steps/sync_images.py
+++ b/lib/xos-synchronizer/tests/steps/sync_images.py
@@ -13,15 +13,11 @@
# limitations under the License.
-import os
-import base64
from xossynchronizer.steps.syncstep import SyncStep
-from xossynchronizer.mock_modelaccessor import *
class SyncImages(SyncStep):
- provides = [Image]
requested_interval = 0
- observes = [Image]
+ observes = ["Image"]
def sync_record(self, role):
# do nothing
diff --git a/lib/xos-synchronizer/tests/steps/sync_instances.py b/lib/xos-synchronizer/tests/steps/sync_instances.py
index 479b87d..1a70884 100644
--- a/lib/xos-synchronizer/tests/steps/sync_instances.py
+++ b/lib/xos-synchronizer/tests/steps/sync_instances.py
@@ -14,13 +14,7 @@
import os
-import base64
-import socket
-from xossynchronizer.steps import syncstep
-from xossynchronizer.mock_modelaccessor import *
-
-RESTAPI_HOSTNAME = socket.gethostname()
-RESTAPI_PORT = "8000"
+from xossynchronizer.steps import ansiblesyncstep
def escape(s):
@@ -28,10 +22,10 @@
return s
-class SyncInstances(syncstep.SyncStep):
- provides = [Instance]
+class SyncInstances(ansiblesyncstep.AnsibleSyncStep):
requested_interval = 0
- observes = Instance
+ # This observes is intentionally a list of one string, to test steps where observes is a list of strings.
+ observes = ["Instance"]
playbook = "sync_instances.yaml"
def fetch_pending(self, deletion=False):
diff --git a/lib/xos-synchronizer/tests/steps/sync_ports.py b/lib/xos-synchronizer/tests/steps/sync_ports.py
index 77209a5..a7eb7d1 100644
--- a/lib/xos-synchronizer/tests/steps/sync_ports.py
+++ b/lib/xos-synchronizer/tests/steps/sync_ports.py
@@ -16,13 +16,13 @@
import os
import base64
from xossynchronizer.steps.syncstep import SyncStep
-from xossynchronizer.mock_modelaccessor import *
class SyncPort(SyncStep):
- requested_interval = 0 # 3600
- provides = [Port]
- observes = Port
+ requested_interval = 0
+
+ # This observes is intentionally a string, to test steps where observes is a string
+ observes = "Port"
def call(self, failed=[], deletion=False):
if deletion:
diff --git a/lib/xos-synchronizer/tests/steps/sync_roles.py b/lib/xos-synchronizer/tests/steps/sync_roles.py
index e8b1364..7298a64 100644
--- a/lib/xos-synchronizer/tests/steps/sync_roles.py
+++ b/lib/xos-synchronizer/tests/steps/sync_roles.py
@@ -20,8 +20,9 @@
class SyncRoles(SyncStep):
- provides = [Role]
requested_interval = 0
+
+ # This observes is intentionally a list of three classes, to test steps where observes is a list of classes.
observes = [SiteRole, SliceRole, ControllerRole]
def sync_record(self, role):