Created
January 9, 2015 01:25
-
-
Save glyph/0cacb238e5461543a582 to your computer and use it in GitHub Desktop.
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
# on the injector API | |
@route("/v1.0/creation", ["POST"]) | |
def inject_create_error(self, request): | |
""" | |
""" | |
params = loads(request.content) | |
nova_tenant = self.session.data_for_api(self._nova_api) | |
criteria = params['criteria'] | |
installed_behavior_id = nova_tenant.set_behavior_for_new_servers( | |
criteria, | |
load_behavior(params['behavior'])) | |
return {"id": installed_behavior_id} | |
# tenant (i.e. S_Cache) | |
def set_behavior_for_new_servers(self, criteria, behavior): | |
""" | |
""" | |
b_id = self.generate_behavior_id() | |
self.creation_behaviors.append((b_id, criteria, behavior)) | |
return b_id | |
def select_creation_behavior(self, creation_params): | |
""" | |
""" | |
for b_id, criteria, behavior in self.creation_behaviors: | |
if Criteria.from_json_structure(criteria).matches(creation_params): | |
return behavior | |
else: | |
return default_server_creation_behavior | |
def default_server_creation_behavior(nova_tenant, creation_params): | |
""" | |
successfully create a nova server | |
*actually* a global function | |
""" | |
server_object = Server.from_creation_params(creation_params) | |
nova_tenant.add_server(server_object) | |
return server_object.creation_info() | |
def create_server(self, request): | |
""" | |
""" | |
creation_params = parse_nova_creation_parameters(request) | |
behavior = self.select_creation_behavior(creation_params) | |
return behavior(self, creation_params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment