-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic resource allocation #975
Open
dswd
wants to merge
135
commits into
GLab:master
Choose a base branch
from
swuest:dynamic_resource_allocation
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
135 commits
Select commit
Hold shift + click to select a range
fecd304
Added new load balancing functionality to the host.py. Also added a m…
d157149
created a function to migrate an element from one host to another. Ad…
5cb20fe
Removed unnecessary import
1280744
bugfix
83387f0
bugfix
5bcead1
bugfix
c8521a5
bugfix
7d094cf
bugfix
86a577c
bugfix
ab95a63
bugfix
ea407d5
bugfix
5522995
bugfix
7cb90b9
bugfix
a8350dc
bugfix
c879bea
bugfix
eda9630
bugfix
2491f5b
bugfix
3a0fa1b
bugfix
fe3f37c
bugfix
4e02edc
bugfix
4f531df
bugfix
b3a471c
bugfix
b5899be
bugfix
f75875e
Added the migrate and checkMigrate function to every elementtyp.
d79b597
bugfix
f8f97a8
bugfix
7ad1730
bugfix
11395b6
bugfix
9c67dc2
bugfix
b953a0e
bugfix
5a6a5c9
bugfix
a0134e9
bugfix
f01b141
bugfix
53fbbcc
bugfix
9788101
bugfix
7e5491f
bugfix
baa3c3a
bugfix
c59ec40
Created a new allocation function as preparation for a new dynamic re…
55efd91
bugfix
79322af
bugfix
708af44
bugfix
94d3b4c
bugfix
cb09a64
bugfix
334e748
bugfix
486aa73
bugfix
8a00001
added reallokation api call for tests
ae150ed
bugfix
62d2eb2
bugfix
83537e2
bugfix
bb60e5a
bugfix
22b671c
bugfix
bf897c2
bugfix
e4fc7b3
bugfix
6736465
bugfix
98d66b0
bugfix
cb319a3
Bugfix
de90005
Bugfix
8a12e30
Bugfix
8bab4dd
Bugfix
ca8eb81
Bugfix
f85b7c5
Bugfix
3c46741
Bugfix
1d2e08e
Bugfix
ade9eb4
Bugfix
51e3a6a
Bugfix
e3d436a
Bugfix
7e5e389
Bugfix
1826573
Bugfix
1cb6749
Bugfix
34b7e23
Bugfix
e281527
Bugfix
a1f2b0e
Bugfix
27fd1fa
Bugfix
f8da4d8
Bugfix
dfb4670
Bugfix
6d9949a
Bugfix
ea92a51
Bugfix
63833e0
Bugfix
0073005
Bugfix
e7d0e05
Bugfix
064429b
Bugfix
1ec346a
bugfix
eecb929
bugfix
58348cb
bugfix
ae17b0c
bugfix
bbd14fe
bugfix
c1e30ec
bugfix
7d6c789
bugfix
124cce4
bugfix
dcf8ac2
bugfix
9217957
bugfix
4b2aaf6
bugfix
f1f1efc
bugfix
34d178b
Bugfix
44fb5be
bugfix
d3453fd
bugfix
6c9d017
bugfix
e409bad
bugfix
3b5eabe
bugfix
a15d2b6
bugfix
469e9f1
bugfix
7def20d
bugfix
040b680
bugfix
447947b
bugfix
a20a258
bugfix
0960c60
bugfix
c890b69
bugfix
af55b3b
bugfix
8d6ba7b
bugfix
0e9d4de
bugfix
70dc6f2
Added detachable flag for hosts
10787a2
Added detachable flag into hostmanager config
2cfc731
Modified the host value function and added weight for started element…
b9b05ab
Balancing
aaa0831
Balancing
21eaf05
Added a deactivated flag for each host. Also implemented an scheduled…
2a0ab8f
bugfix
1dc720b
bugfix
90a284b
bugfix
9696943
bugfix
130abe5
Merge branch 'master' of github.com:glab/ToMaTo into dynamic_ressourc…
f054cb4
bugfixes
0668934
Merge branch 'master' of github.com:glab/ToMaTo into dynamic_ressourc…
fd4741b
Stylefixes
3f8b79c
Added ErrorChecks and fixed some little Issues
e7fcaec
Bugfix
ec33b8f
Changed migration of connection elements and added some score for hos…
0ba9536
Fixed different issues:
93e9a64
Merge branch 'master' of github.com:glab/ToMaTo into dynamic_resource…
d0b00ab
Added the configuration of the upper and lower treshold for host allo…
2c45c3d
Bugfixes
065368b
Better sorting for the load influenecer. Bug fix
381ea07
Removed prints which have been added for bugfixes.
cc50e61
Bugfix
c315a4d
Bugfix
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,11 @@ | |
from .. import elements, resources, host | ||
from ..resources import network as r_network | ||
from ..lib.attributes import Attr #@UnresolvedImport | ||
from generic import ST_CREATED, ST_STARTED | ||
from generic import ST_CREATED, ST_STARTED, ST_PREPARED | ||
from .. import currentUser | ||
from ..auth import Flags | ||
from ..lib.error import UserError | ||
from tomato.config import MIGRATION_TRESHOLD | ||
|
||
class External_Network(elements.generic.ConnectingElement, elements.Element): | ||
name_attr = Attr("name", desc="Name") | ||
|
@@ -36,6 +37,7 @@ class External_Network(elements.generic.ConnectingElement, elements.Element): | |
CUSTOM_ACTIONS = { | ||
"start": [ST_CREATED], | ||
"stop": [ST_STARTED], | ||
"migrate": [ST_PREPARED], | ||
elements.REMOVE_ACTION: [ST_CREATED], | ||
} | ||
CUSTOM_ATTRS = { | ||
|
@@ -192,6 +194,42 @@ def action_stop(self): | |
self.element = None | ||
self.setState(ST_CREATED, True) | ||
|
||
def checkMigrate(self): | ||
#We only migrate if the external network is already started, otherwise we don't have to migrate | ||
return self.state in [ST_PREPARED] | ||
|
||
def try_migrate(self): | ||
|
||
UserError.check(self.element.checkMigrate(), code=UserError.UNSUPPORTED_ACTION, message="Element can't be migrated",data={"type": self.TYPE}) | ||
|
||
|
||
hPref, sPref = self.getLocationPrefs() | ||
|
||
bestHost,bestPref = host.getBestHost(site=self.site, elementTypes=[self.TYPE]+self.CAP_CHILDREN.keys(), hostPrefs=hPref, sitePrefs=sPref) | ||
UserError.check(bestHost, code=UserError.NO_RESOURCES, message="No matching host found for element", data={"type": self.TYPE}) | ||
|
||
|
||
hostScore = host.getHostScore(self.element.host,site=self.site, elementTypes=[self.TYPE]+self.CAP_CHILDREN.keys(), hostPrefs=hPref, sitePrefs=sPref) | ||
|
||
if bestPref > hostScore*MIGRATION_TRESHOLD: | ||
return | ||
|
||
|
||
|
||
kind = self.getParent().network.kind if self.parent and self.getParent().samenet else self.kind | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Below is all duplicated code, please create a method for this like |
||
|
||
if self.parent and self.getParent().samenet: | ||
self.network = r_network.getInstance(host, self.getParent().network.kind) | ||
else: | ||
self.network = r_network.getInstance(host, self.kind) | ||
attrs = {"network": self.network.network.kind} | ||
|
||
self.action_destroy() | ||
self.element = bestHost.createElement("external_network", parent=None, attrs=attrs, ownerElement=self) | ||
self.setState(ST_STARTED) | ||
self.triggerConnectionStart() | ||
|
||
|
||
def readyToConnect(self): | ||
return bool(self.element) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,14 +14,16 @@ | |
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/> | ||
|
||
from django.db import models | ||
from .. import elements, resources, host | ||
from ..resources import profile as r_profile, template as r_template | ||
from ..lib.attributes import Attr, attribute #@UnresolvedImport | ||
from ..lib import attributes #@UnresolvedImport | ||
from ..lib import attributes,rpc #@UnresolvedImport | ||
from ..lib.error import UserError, InternalError | ||
from ..lib.util import upload | ||
import time | ||
import urllib | ||
from tomato.config import MIGRATION_TRESHOLD | ||
|
||
ST_CREATED = "created" | ||
ST_PREPARED = "prepared" | ||
|
@@ -47,6 +49,7 @@ class VMElement(elements.Element): | |
"prepare": [ST_CREATED], | ||
"destroy": [ST_PREPARED], | ||
"change_template": [ST_CREATED, ST_PREPARED], | ||
"migrate": [ST_PREPARED], | ||
elements.REMOVE_ACTION: [ST_CREATED], | ||
} | ||
CUSTOM_ATTRS = { | ||
|
@@ -237,6 +240,47 @@ def after_start(self): | |
def after_upload_use(self): | ||
self.custom_template = True | ||
self.save() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
def try_migrate(self): | ||
|
||
|
||
if self.state in [ST_CREATED]: return | ||
|
||
hPref, sPref = self.getLocationPrefs() | ||
|
||
bestHost,bestPref = host.getBestHost(site=self.site, elementTypes=[self.TYPE]+self.CAP_CHILDREN.keys(), hostPrefs=hPref, sitePrefs=sPref) | ||
UserError.check(bestHost, code=UserError.NO_RESOURCES, message="No matching host found for element", data={"type": self.TYPE}) | ||
|
||
hostScore = host.getHostScore(self.element.host,site=self.site, elementTypes=[self.TYPE]+self.CAP_CHILDREN.keys(), hostPrefs=hPref, sitePrefs=sPref) | ||
|
||
if bestPref > hostScore*MIGRATION_TRESHOLD: | ||
return | ||
|
||
|
||
#Download template. Receive download_grant from template and save it to a tempfile? | ||
urllib.urlretrieve(self.element.host.grantUrl(self.element.action("download_grant"), "download"), self.name+"_tmp_image.tar.gz") | ||
|
||
attrs = self._remoteAttrs() | ||
#Create identical element on new host | ||
new_el = bestHost.createElement(self.TYPE, parent=None, attrs=attrs, ownerElement=self) | ||
|
||
#Kill old element on old host | ||
self.action_destroy() | ||
|
||
#Set new element and save it | ||
self.element = new_el | ||
self.save() | ||
|
||
for iface in self.getChildren(): | ||
iface.try_migrate() | ||
self.element.action("prepare") | ||
|
||
self.setState(ST_PREPARED, True) | ||
|
||
upload(bestHost.grantUrl(new_el.action("upload_grant"),"upload"),self.name+"_tmp_image.tar.gz") | ||
new_el.action("upload_use") | ||
|
||
|
||
|
||
def upcast(self): | ||
return self | ||
|
@@ -297,13 +341,31 @@ def _remove(self): | |
self.element = None | ||
self.save() | ||
|
||
def checkMigrate(self): | ||
return self.state in [ST_CREATED,ST_PREPARED] | ||
|
||
def try_migrate(self): | ||
|
||
if self.state in [ST_CREATED,ST_STARTED]: return | ||
|
||
|
||
|
||
parEl = self.getParent().element | ||
assert parEl | ||
attrs = self._remoteAttrs() | ||
element = parEl.createChild(self.TYPE, attrs=attrs, ownerElement=self) | ||
|
||
self.element.remove() | ||
self.element = element | ||
self.save() | ||
|
||
def readyToConnect(self): | ||
return self.state == ST_STARTED | ||
|
||
def upcast(self): | ||
return self | ||
|
||
|
||
class ConnectingElement: | ||
def getLocationData(self, maxDepth=3): | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be realized using host_modify