Refactored the compute model and its elements

In this changeset, I refactored the whole Watcher codebase to
adopt a naming convention about the various elements of the
Compute model so that it reflects the same naming convention
adopted by Nova.

Change-Id: I28adba5e1f27175f025330417b072686134d5f51
Partially-Implements: blueprint cluster-model-objects-wrapper
This commit is contained in:
Vincent Françoise
2016-07-06 17:44:29 +02:00
parent dbde1afea0
commit 31c37342cd
53 changed files with 1865 additions and 1803 deletions

View File

@@ -23,7 +23,7 @@ from watcher._i18n import _
from watcher.applier.actions import base
from watcher.common import exception
from watcher.common import nova_helper
from watcher.decision_engine.model import hypervisor_state as hstate
from watcher.decision_engine.model import element
class ChangeNovaServiceState(base.BaseAction):
@@ -57,7 +57,7 @@ class ChangeNovaServiceState(base.BaseAction):
voluptuous.Length(min=1)),
voluptuous.Required(self.STATE):
voluptuous.Any(*[state.value
for state in list(hstate.HypervisorState)]),
for state in list(element.ServiceState)]),
})
@property
@@ -70,17 +70,17 @@ class ChangeNovaServiceState(base.BaseAction):
def execute(self):
target_state = None
if self.state == hstate.HypervisorState.DISABLED.value:
if self.state == element.ServiceState.DISABLED.value:
target_state = False
elif self.state == hstate.HypervisorState.ENABLED.value:
elif self.state == element.ServiceState.ENABLED.value:
target_state = True
return self._nova_manage_service(target_state)
def revert(self):
target_state = None
if self.state == hstate.HypervisorState.DISABLED.value:
if self.state == element.ServiceState.DISABLED.value:
target_state = True
elif self.state == hstate.HypervisorState.ENABLED.value:
elif self.state == element.ServiceState.ENABLED.value:
target_state = False
return self._nova_manage_service(target_state)

View File

@@ -44,12 +44,12 @@ class Migrate(base.BaseAction):
schema = Schema({
'resource_id': str, # should be a UUID
'migration_type': str, # choices -> "live", "cold"
'dst_hypervisor': str,
'src_hypervisor': str,
'destination_node': str,
'source_node': str,
})
The `resource_id` is the UUID of the server to migrate.
The `src_hypervisor` and `dst_hypervisor` parameters are respectively the
The `source_node` and `destination_node` parameters are respectively the
source and the destination compute hostname (list of available compute
hosts is returned by this command: ``nova service-list --binary
nova-compute``).
@@ -59,8 +59,8 @@ class Migrate(base.BaseAction):
MIGRATION_TYPE = 'migration_type'
LIVE_MIGRATION = 'live'
COLD_MIGRATION = 'cold'
DST_HYPERVISOR = 'dst_hypervisor'
SRC_HYPERVISOR = 'src_hypervisor'
DESTINATION_NODE = 'destination_node'
SOURCE_NODE = 'source_node'
def check_resource_id(self, value):
if (value is not None and
@@ -73,14 +73,14 @@ class Migrate(base.BaseAction):
def schema(self):
return voluptuous.Schema({
voluptuous.Required(self.RESOURCE_ID): self.check_resource_id,
voluptuous.Required(self.MIGRATION_TYPE,
default=self.LIVE_MIGRATION):
voluptuous.Any(*[self.LIVE_MIGRATION,
self.COLD_MIGRATION]),
voluptuous.Required(self.DST_HYPERVISOR):
voluptuous.Required(
self.MIGRATION_TYPE, default=self.LIVE_MIGRATION):
voluptuous.Any(
*[self.LIVE_MIGRATION, self.COLD_MIGRATION]),
voluptuous.Required(self.DESTINATION_NODE):
voluptuous.All(voluptuous.Any(*six.string_types),
voluptuous.Length(min=1)),
voluptuous.Required(self.SRC_HYPERVISOR):
voluptuous.Required(self.SOURCE_NODE):
voluptuous.All(voluptuous.Any(*six.string_types),
voluptuous.Length(min=1)),
})
@@ -94,12 +94,12 @@ class Migrate(base.BaseAction):
return self.input_parameters.get(self.MIGRATION_TYPE)
@property
def dst_hypervisor(self):
return self.input_parameters.get(self.DST_HYPERVISOR)
def destination_node(self):
return self.input_parameters.get(self.DESTINATION_NODE)
@property
def src_hypervisor(self):
return self.input_parameters.get(self.SRC_HYPERVISOR)
def source_node(self):
return self.input_parameters.get(self.SOURCE_NODE)
def _live_migrate_instance(self, nova, destination):
result = None
@@ -159,14 +159,14 @@ class Migrate(base.BaseAction):
raise exception.InstanceNotFound(name=self.instance_uuid)
def execute(self):
return self.migrate(destination=self.dst_hypervisor)
return self.migrate(destination=self.destination_node)
def revert(self):
return self.migrate(destination=self.src_hypervisor)
return self.migrate(destination=self.source_node)
def precondition(self):
# todo(jed) check if the instance exist/ check if the instance is on
# the src_hypervisor
# the source_node
pass
def postcondition(self):