Integration of Ceilometer in Watcher
In current implementation is not easy to use ceilometer. Watcher must query metrics from the Telemetry v2 API to allow an easiest integration with OpenStack components (especially devstack). blueprint telemetry-integration Change-Id: Ide515472f1d160925d9f4aabf48c96dea4f6bc05
This commit is contained in:
@@ -17,7 +17,13 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
import abc
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class Applier(object):
|
||||
@abc.abstractmethod
|
||||
def execute(self, action_plan_uuid):
|
||||
raise NotImplementedError("Should have implemented this")
|
||||
raise NotImplementedError(
|
||||
"Should have implemented this") # pragma:no cover
|
||||
|
||||
@@ -17,7 +17,13 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
import abc
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class CommandMapper(object):
|
||||
@abc.abstractmethod
|
||||
def build_primitive_command(self, action):
|
||||
raise NotImplementedError("Should have implemented this")
|
||||
raise NotImplementedError(
|
||||
"Should have implemented this") # pragma:no cover
|
||||
|
||||
@@ -17,7 +17,13 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
import abc
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class ApplierCommand(object):
|
||||
@abc.abstractmethod
|
||||
def execute(self):
|
||||
raise NotImplementedError("Should have implemented this")
|
||||
raise NotImplementedError(
|
||||
"Should have implemented this") # pragma:no cover
|
||||
|
||||
@@ -16,14 +16,21 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
import abc
|
||||
import six
|
||||
from watcher.applier.api.promise import Promise
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class PrimitiveCommand(object):
|
||||
@Promise
|
||||
@abc.abstractmethod
|
||||
def execute(self):
|
||||
raise NotImplementedError("Should have implemented this")
|
||||
raise NotImplementedError(
|
||||
"Should have implemented this") # pragma:no cover
|
||||
|
||||
@Promise
|
||||
@abc.abstractmethod
|
||||
def undo(self):
|
||||
raise NotImplementedError("Should have implemented this")
|
||||
raise NotImplementedError(
|
||||
"Should have implemented this") # pragma:no cover
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
#
|
||||
|
||||
|
||||
from keystoneclient.auth.identity import v3
|
||||
from keystoneclient import session
|
||||
from oslo_config import cfg
|
||||
|
||||
from watcher.applier.api.primitive_command import PrimitiveCommand
|
||||
from watcher.applier.api.promise import Promise
|
||||
from watcher.applier.framework.command.wrapper.nova_wrapper import NovaWrapper
|
||||
from watcher.common.keystone import Client
|
||||
from watcher.decision_engine.framework.model.hypervisor_state import \
|
||||
HypervisorState
|
||||
|
||||
@@ -37,25 +36,9 @@ class HypervisorStateCommand(PrimitiveCommand):
|
||||
self.status = status
|
||||
|
||||
def nova_manage_service(self, status):
|
||||
creds = \
|
||||
{'auth_url': CONF.keystone_authtoken.auth_uri,
|
||||
'username': CONF.keystone_authtoken.admin_user,
|
||||
'password': CONF.keystone_authtoken.admin_password,
|
||||
'project_name': CONF.keystone_authtoken.admin_tenant_name,
|
||||
'user_domain_name': "default",
|
||||
'project_domain_name': "default"}
|
||||
|
||||
auth = v3.Password(auth_url=creds['auth_url'],
|
||||
username=creds['username'],
|
||||
password=creds['password'],
|
||||
project_name=creds['project_name'],
|
||||
user_domain_name=creds[
|
||||
'user_domain_name'],
|
||||
project_domain_name=creds[
|
||||
'project_domain_name'])
|
||||
sess = session.Session(auth=auth)
|
||||
# todo(jed) refactoring
|
||||
wrapper = NovaWrapper(creds, session=sess)
|
||||
keystone = Client()
|
||||
wrapper = NovaWrapper(keystone.get_credentials(),
|
||||
session=keystone.get_session())
|
||||
if status is True:
|
||||
return wrapper.enable_service_nova_compute(self.host)
|
||||
else:
|
||||
|
||||
@@ -24,6 +24,7 @@ from oslo_config import cfg
|
||||
from watcher.applier.api.primitive_command import PrimitiveCommand
|
||||
from watcher.applier.api.promise import Promise
|
||||
from watcher.applier.framework.command.wrapper.nova_wrapper import NovaWrapper
|
||||
from watcher.common.keystone import Client
|
||||
from watcher.decision_engine.framework.default_planner import Primitives
|
||||
|
||||
CONF = cfg.CONF
|
||||
@@ -40,25 +41,9 @@ class MigrateCommand(PrimitiveCommand):
|
||||
self.destination_hypervisor = destination_hypervisor
|
||||
|
||||
def migrate(self, destination):
|
||||
|
||||
creds = \
|
||||
{'auth_url': CONF.keystone_authtoken.auth_uri,
|
||||
'username': CONF.keystone_authtoken.admin_user,
|
||||
'password': CONF.keystone_authtoken.admin_password,
|
||||
'project_name': CONF.keystone_authtoken.admin_tenant_name,
|
||||
'user_domain_name': "default",
|
||||
'project_domain_name': "default"}
|
||||
auth = v3.Password(auth_url=creds['auth_url'],
|
||||
username=creds['username'],
|
||||
password=creds['password'],
|
||||
project_name=creds['project_name'],
|
||||
user_domain_name=creds[
|
||||
'user_domain_name'],
|
||||
project_domain_name=creds[
|
||||
'project_domain_name'])
|
||||
sess = session.Session(auth=auth)
|
||||
# todo(jed) add class
|
||||
wrapper = NovaWrapper(creds, session=sess)
|
||||
keystone = Client()
|
||||
wrapper = NovaWrapper(keystone.get_credentials(),
|
||||
session=keystone.get_session())
|
||||
instance = wrapper.find_instance(self.instance_uuid)
|
||||
if instance:
|
||||
project_id = getattr(instance, "tenant_id")
|
||||
|
||||
@@ -17,18 +17,25 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
from oslo_log import log
|
||||
|
||||
from watcher.applier.api.primitive_command import PrimitiveCommand
|
||||
from watcher.applier.api.promise import Promise
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class NopCommand(PrimitiveCommand):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@Promise
|
||||
def execute(self):
|
||||
LOG.debug("executing NOP command")
|
||||
return True
|
||||
|
||||
@Promise
|
||||
def undo(self):
|
||||
LOG.debug("undo NOP command")
|
||||
return True
|
||||
|
||||
@@ -355,10 +355,10 @@ class NovaWrapper(object):
|
||||
and retry:
|
||||
instance = self.nova.servers.get(instance.id)
|
||||
LOG.debug(
|
||||
"Waiting the migration of " + str(
|
||||
instance.human_id) + " to " +
|
||||
getattr(instance,
|
||||
'OS-EXT-SRV-ATTR:host'))
|
||||
'Waiting the migration of {0} to {1}'.format(
|
||||
instance,
|
||||
getattr(instance,
|
||||
'OS-EXT-SRV-ATTR:host')))
|
||||
time.sleep(1)
|
||||
retry -= 1
|
||||
|
||||
|
||||
@@ -66,9 +66,12 @@ class CommandExecutor(object):
|
||||
self.deploy.populate(primitive)
|
||||
self.notify(action, Status.SUCCESS)
|
||||
except Exception as e:
|
||||
LOG.error(
|
||||
"The applier module failed to execute the action" + str(
|
||||
action) + " with the exception : " + unicode(e))
|
||||
LOG.debug(
|
||||
'The applier module failed to execute the action{0} with '
|
||||
'the exception {1} '.format(
|
||||
action,
|
||||
unicode(e)))
|
||||
|
||||
LOG.error("Trigger a rollback")
|
||||
self.notify(action, Status.FAILED)
|
||||
self.deploy.rollback()
|
||||
|
||||
Reference in New Issue
Block a user