Merge branch 'master' of github.com:open-cloud/xos
diff --git a/xos/core/models/plcorebase.py b/xos/core/models/plcorebase.py
index 76c2e54..6be949d 100644
--- a/xos/core/models/plcorebase.py
+++ b/xos/core/models/plcorebase.py
@@ -199,7 +199,7 @@
# default values for created and updated are only there to keep evolution
# from failing.
created = models.DateTimeField(auto_now_add=True)
- updated = models.DateTimeField(auto_now=True)
+ updated = models.DateTimeField(default=timezone.now)
enacted = models.DateTimeField(null=True, blank=True, default=None)
policed = models.DateTimeField(null=True, blank=True, default=None)
@@ -272,7 +272,7 @@
ignore_composite_key_check=False
if 'synchronizer' not in threading.current_thread().name:
- self.updated = datetime.datetime.now()
+ self.updated = timezone.now()
super(PlCoreBase, self).save(*args, **kwargs)
diff --git a/xos/openstack/manager.py b/xos/openstack/manager.py
index 45d49b4..ba163c7 100644
--- a/xos/openstack/manager.py
+++ b/xos/openstack/manager.py
@@ -4,6 +4,7 @@
import random
import hashlib
from datetime import datetime
+from django.utils import timezone
from netaddr import IPAddress, IPNetwork
from xos import settings
@@ -121,7 +122,7 @@
self.init_admin()
user.save()
- user.enacted = datetime.now()
+ user.enacted = timezone.now()
user.save(update_fields=['enacted'])
@require_enabled
@@ -147,7 +148,7 @@
# commit the updated record
site.save()
- site.enacted = datetime.now()
+ site.enacted = timezone.now()
site.save(update_fields=['enacted']) # enusre enacted > updated
@@ -162,7 +163,7 @@
self.driver.add_user_role(site_priv.user.kuser_id,
site_priv.site.tenant_id,
site_priv.role.role_type)
- site_priv.enacted = datetime.now()
+ site_priv.enacted = timezone.now()
site_priv.save(update_fields=['enacted'])
@@ -222,7 +223,7 @@
enabled=slice.enabled)
slice.save()
- slice.enacted = datetime.now()
+ slice.enacted = timezone.now()
slice.save(update_fields=['enacted'])
@require_enabled
@@ -253,7 +254,7 @@
self.driver.add_user_role(slice_memb.user.kuser_id,
slice_memb.slice.tenant_id,
slice_memb.role.role_type)
- slice_memb.enacted = datetime.now()
+ slice_memb.enacted = timezone.now()
slice_memb.save(update_fields=['enacted'])
@@ -348,7 +349,7 @@
self.driver.update_instance_metadata(instance.instance_id, metadata_update)
instance.save()
- instance.enacted = datetime.now()
+ instance.enacted = timezone.now()
instance.save(update_fields=['enacted'])
@require_enabled
@@ -457,7 +458,7 @@
self.driver.add_external_route(subnet)
network.save()
- network.enacted = datetime.now()
+ network.enacted = timezone.now()
network.save(update_fields=['enacted'])
def delete_network(self, network):
@@ -477,7 +478,7 @@
template.shared_network_id = os_networks[0]["id"]
template.save()
- template.enacted = datetime.now()
+ template.enacted = timezone.now()
template.save(update_fields=['enacted'])
def find_or_make_template_for_network(self, name):
diff --git a/xos/synchronizers/base/syncstep-portal.py b/xos/synchronizers/base/syncstep-portal.py
index dfb810e..07abb0b 100644
--- a/xos/synchronizers/base/syncstep-portal.py
+++ b/xos/synchronizers/base/syncstep-portal.py
@@ -5,6 +5,7 @@
from xos.logger import Logger, logging
from synchronizers.base.steps import *
from django.db.models import F, Q
+from django.utils import timezone
from core.models import *
from django.db import reset_queries
import json
@@ -141,7 +142,7 @@
o.delete(purge=True)
else:
self.sync_record(o)
- o.enacted = datetime.now() # Is this the same timezone? XXX
+ o.enacted = timezone.now() # Is this the same timezone? XXX
scratchpad = {'next_run':0, 'exponent':0}
o.backend_register = json.dumps(scratchpad)
o.backend_status = "1 - OK"
diff --git a/xos/synchronizers/model_policy.py b/xos/synchronizers/model_policy.py
index 8faae81..ef31d41 100644
--- a/xos/synchronizers/model_policy.py
+++ b/xos/synchronizers/model_policy.py
@@ -5,6 +5,7 @@
from synchronizers.openstack import model_policies
from xos.logger import logger
from datetime import datetime
+from django.utils import timezone
import time
from core.models import *
from django.db import reset_queries
@@ -87,7 +88,7 @@
logger.log_exc("Model Policy Error:")
try:
- instance.policed=datetime.now()
+ instance.policed=timezone.now()
instance.save(update_fields=['policed'])
except:
logging.error('Object %r is defective'%instance)