rename planetstack module to xos
diff --git a/planetstack/openstack_observer/steps/sync_controller_images.py b/planetstack/openstack_observer/steps/sync_controller_images.py
index e076d81..fa4bd35 100644
--- a/planetstack/openstack_observer/steps/sync_controller_images.py
+++ b/planetstack/openstack_observer/steps/sync_controller_images.py
@@ -2,7 +2,7 @@
import base64
from collections import defaultdict
from django.db.models import F, Q
-from planetstack.config import Config
+from xos.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
from core.models import Controller
from core.models import Image, ControllerImages
diff --git a/planetstack/openstack_observer/steps/sync_controller_networks.py b/planetstack/openstack_observer/steps/sync_controller_networks.py
index 83cf8ea..242073d 100644
--- a/planetstack/openstack_observer/steps/sync_controller_networks.py
+++ b/planetstack/openstack_observer/steps/sync_controller_networks.py
@@ -3,7 +3,7 @@
from collections import defaultdict
from netaddr import IPAddress, IPNetwork
from django.db.models import F, Q
-from planetstack.config import Config
+from xos.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
from core.models.network import *
from core.models.slice import *
diff --git a/planetstack/openstack_observer/steps/sync_controller_site_privileges.py b/planetstack/openstack_observer/steps/sync_controller_site_privileges.py
index 0ea86e1..e58f9a1 100644
--- a/planetstack/openstack_observer/steps/sync_controller_site_privileges.py
+++ b/planetstack/openstack_observer/steps/sync_controller_site_privileges.py
@@ -2,7 +2,7 @@
import base64
from collections import defaultdict
from django.db.models import F, Q
-from planetstack.config import Config
+from xos.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
from core.models.site import Controller, SitePrivilege
from core.models.user import User
diff --git a/planetstack/openstack_observer/steps/sync_controller_sites.py b/planetstack/openstack_observer/steps/sync_controller_sites.py
index f7905c9..9aa6c5b 100644
--- a/planetstack/openstack_observer/steps/sync_controller_sites.py
+++ b/planetstack/openstack_observer/steps/sync_controller_sites.py
@@ -1,7 +1,7 @@
import os
import base64
from django.db.models import F, Q
-from planetstack.config import Config
+from xos.config import Config
from openstack_observer.openstacksyncstep import OpenStackSyncStep
from core.models.site import *
from observer.ansible import *
diff --git a/planetstack/openstack_observer/steps/sync_controller_slice_privileges.py b/planetstack/openstack_observer/steps/sync_controller_slice_privileges.py
index 99000ea..96156f7 100644
--- a/planetstack/openstack_observer/steps/sync_controller_slice_privileges.py
+++ b/planetstack/openstack_observer/steps/sync_controller_slice_privileges.py
@@ -2,7 +2,7 @@
import base64
from collections import defaultdict
from django.db.models import F, Q
-from planetstack.config import Config
+from xos.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
from core.models.slice import Controller, SlicePrivilege
from core.models.user import User
diff --git a/planetstack/openstack_observer/steps/sync_controller_slices.py b/planetstack/openstack_observer/steps/sync_controller_slices.py
index 0c24ae1..df44fa5 100644
--- a/planetstack/openstack_observer/steps/sync_controller_slices.py
+++ b/planetstack/openstack_observer/steps/sync_controller_slices.py
@@ -3,7 +3,7 @@
from collections import defaultdict
from netaddr import IPAddress, IPNetwork
from django.db.models import F, Q
-from planetstack.config import Config
+from xos.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
from core.models.slice import Slice, ControllerSlice
from core.models.controlleruser import ControllerUser
diff --git a/planetstack/openstack_observer/steps/sync_controller_users.py b/planetstack/openstack_observer/steps/sync_controller_users.py
index 08123fe..43053b7 100644
--- a/planetstack/openstack_observer/steps/sync_controller_users.py
+++ b/planetstack/openstack_observer/steps/sync_controller_users.py
@@ -2,7 +2,7 @@
import base64
from collections import defaultdict
from django.db.models import F, Q
-from planetstack.config import Config
+from xos.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
from core.models.site import Controller, SiteDeployment, SiteDeployment
from core.models.user import User
diff --git a/planetstack/openstack_observer/steps/sync_images.py b/planetstack/openstack_observer/steps/sync_images.py
new file mode 100644
index 0000000..f5764a1
--- /dev/null
+++ b/planetstack/openstack_observer/steps/sync_images.py
@@ -0,0 +1,43 @@
+import os
+import base64
+from django.db.models import F, Q
+from xos.config import Config
+from observer.openstacksyncstep import OpenStackSyncStep
+from core.models.image import Image
+
+class SyncImages(OpenStackSyncStep):
+ provides=[Image]
+ requested_interval=0
+ observes=Image
+
+ def fetch_pending(self, deleted):
+ # Images come from the back end
+ # You can't delete them
+ if (deleted):
+ return []
+
+ # get list of images on disk
+ images_path = Config().observer_images_directory
+ available_images = {}
+ for f in os.listdir(images_path):
+ if os.path.isfile(os.path.join(images_path ,f)):
+ available_images[f] = os.path.join(images_path ,f)
+
+ images = Image.objects.all()
+ image_names = [image.name for image in images]
+
+ for image_name in available_images:
+ #remove file extension
+ clean_name = ".".join(image_name.split('.')[:-1])
+ if clean_name not in image_names:
+ image = Image(name=clean_name,
+ disk_format='raw',
+ container_format='bare',
+ path = available_images[image_name])
+ image.save()
+
+
+ return Image.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
+
+ def sync_record(self, image):
+ image.save()
diff --git a/planetstack/openstack_observer/steps/sync_network_slivers.py b/planetstack/openstack_observer/steps/sync_network_slivers.py
index 7406fb2..535e7a4 100644
--- a/planetstack/openstack_observer/steps/sync_network_slivers.py
+++ b/planetstack/openstack_observer/steps/sync_network_slivers.py
@@ -1,7 +1,7 @@
import os
import base64
from django.db.models import F, Q
-from planetstack.config import Config
+from xos.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
from core.models import Controller
from core.models.network import *
diff --git a/planetstack/openstack_observer/steps/sync_roles.py b/planetstack/openstack_observer/steps/sync_roles.py
new file mode 100644
index 0000000..0bd26c6
--- /dev/null
+++ b/planetstack/openstack_observer/steps/sync_roles.py
@@ -0,0 +1,42 @@
+import os
+import base64
+from django.db.models import F, Q
+from xos.config import Config
+from observer.openstacksyncstep import OpenStackSyncStep
+from core.models.role import Role
+from core.models.site import SiteRole, Controller, ControllerRole
+from core.models.slice import SliceRole
+
+class SyncRoles(OpenStackSyncStep):
+ provides=[Role]
+ requested_interval=0
+ observes=Role
+
+ def fetch_pending(self, deleted):
+ # Deleting roles is not supported yet
+ if (deleted):
+ return []
+
+ site_roles = SiteRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
+ slice_roles = SliceRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
+ controller_roles = ControllerRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
+
+ roles = []
+ for site_role in site_roles:
+ roles.append(site_role)
+ for slice_role in slice_roles:
+ roles.append(slice_role)
+ for controller_role in controller_roles:
+ roles.append(controller_role)
+
+ return roles
+
+
+ def sync_record(self, role):
+ if not role.enacted:
+ controllers = Controller.objects.all()
+ for controller in controllers:
+ driver = self.driver.admin_driver(controller=controller)
+ driver.create_role(role.role)
+ role.save()
+
diff --git a/planetstack/openstack_observer/steps/sync_slivers.py b/planetstack/openstack_observer/steps/sync_slivers.py
index 9a25c19..00e1691 100644
--- a/planetstack/openstack_observer/steps/sync_slivers.py
+++ b/planetstack/openstack_observer/steps/sync_slivers.py
@@ -2,7 +2,7 @@
import base64
import socket
from django.db.models import F, Q
-from planetstack.config import Config
+from xos.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
from core.models.sliver import Sliver
from core.models.slice import Slice, SlicePrivilege, ControllerSlice