git://git.onelab.eu
/
plstackapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
85743c1
)
recreate all slivers when image or flavor is changed
author
Scott Baker
<smbaker@gmail.com>
Mon, 19 Jan 2015 00:07:58 +0000
(16:07 -0800)
committer
Scott Baker
<smbaker@gmail.com>
Mon, 19 Jan 2015 00:07:58 +0000
(16:07 -0800)
planetstack/core/xoslib/objects/sliceplus.py
patch
|
blob
|
history
diff --git
a/planetstack/core/xoslib/objects/sliceplus.py
b/planetstack/core/xoslib/objects/sliceplus.py
index
9a70e25
..
cd86fce
100644
(file)
--- a/
planetstack/core/xoslib/objects/sliceplus.py
+++ b/
planetstack/core/xoslib/objects/sliceplus.py
@@
-8,9
+8,11
@@
class SlicePlus(Slice, PlusObjectMixin):
def __init__(self, *args, **kwargs):
super(SlicePlus, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs):
super(SlicePlus, self).__init__(*args, **kwargs)
- self._update_site_allocation = None
self._update_users = None
self._sliceInfo = None
self._update_users = None
self._sliceInfo = None
+ self.getSliceInfo()
+ self._site_allocation = self._sliceInfo["sitesUsed"]
+ self._initial_site_allocation = self._site_allocation
def getSliceInfo(self, user=None):
if not self._sliceInfo:
def getSliceInfo(self, user=None):
if not self._sliceInfo:
@@
-46,12
+48,11
@@
class SlicePlus(Slice, PlusObjectMixin):
@property
def site_allocation(self):
@property
def site_allocation(self):
- return self.
getSliceInfo()["sitesUsed"]
+ return self.
_site_allocation
@site_allocation.setter
def site_allocation(self, value):
@site_allocation.setter
def site_allocation(self, value):
- self._update_site_allocation = value
- #print "XXX set sitesUsed to", value
+ self._site_allocation = value
@property
def user_names(self):
@property
def user_names(self):
@@
-109,26
+110,30
@@
class SlicePlus(Slice, PlusObjectMixin):
return nodeList
def save(self, *args, **kwargs):
return nodeList
def save(self, *args, **kwargs):
+ updated_image = self.has_field_changed("default_image")
+ updated_flavor = self.has_field_changed("default_flavor")
+
super(SlicePlus, self).save(*args, **kwargs)
super(SlicePlus, self).save(*args, **kwargs)
- if self._update_site_allocation:
- self.save_site_allocation(noAct=True)
+ updated_sites = (self._site_allocation != self._initial_site_allocation) or updated_image or updated_flavor
+ if updated_sites:
+ self.save_site_allocation(noAct=True, reset=(updated_image or updated_flavor))
if self._update_users:
self.save_users(noAct=True)
if self._update_users:
self.save_users(noAct=True)
- if
self._update_site_allocation
:
- self.save_site_allocation()
+ if
updated_sites
:
+ self.save_site_allocation(
reset=(updated_image or updated_flavor)
)
if self._update_users:
self.save_users()
if self._update_users:
self.save_users()
- def save_site_allocation(self, noAct = False):
- new_site_allocation = self._update_site_allocation
+ def save_site_allocation(self, noAct = False
, reset=False
):
+ print "save_site_allocation, reset=",reset
all_slice_slivers = self.slivers.all()
all_slice_slivers = self.slivers.all()
- for site_name in
new
_site_allocation.keys():
- desired_allocation =
new
_site_allocation[site_name]
+ for site_name in
self.
_site_allocation.keys():
+ desired_allocation =
self.
_site_allocation[site_name]
# make a list of the slivers for this site
slivers = []
# make a list of the slivers for this site
slivers = []
@@
-137,11
+142,13
@@
class SlicePlus(Slice, PlusObjectMixin):
slivers.append(sliver)
# delete extra slivers
slivers.append(sliver)
# delete extra slivers
- while (len(slivers) > desired_allocation):
+ while (
reset and len(slivers)>0) or (
len(slivers) > desired_allocation):
sliver = slivers.pop()
sliver = slivers.pop()
- print "deleting sliver", sliver
if (not noAct):
if (not noAct):
+ print "deleting sliver", sliver
sliver.delete()
sliver.delete()
+ else:
+ print "would delete sliver", sliver
# add more slivers
if (len(slivers) < desired_allocation):
# add more slivers
if (len(slivers) < desired_allocation):
@@
-165,9
+172,10
@@
class SlicePlus(Slice, PlusObjectMixin):
deployment = node.site_deployment.deployment)
slivers.append(sliver)
if (not noAct):
deployment = node.site_deployment.deployment)
slivers.append(sliver)
if (not noAct):
+ print "added sliver", sliver
sliver.save()
sliver.save()
-
-
print "adde
d sliver", sliver
+ else:
+
print "would ad
d sliver", sliver
node.sliverCount = node.sliverCount + 1
node.sliverCount = node.sliverCount + 1