Skip to content

Commit

Permalink
Merge pull request #1383 from alvarosimon/os_ceilometer
Browse files Browse the repository at this point in the history
ncm-openstack:  add ceilometer service
  • Loading branch information
jrha authored Dec 5, 2019
2 parents f307dcb + f28a214 commit bea92e7
Show file tree
Hide file tree
Showing 32 changed files with 519 additions and 52 deletions.
13 changes: 13 additions & 0 deletions ncm-openstack/src/main/pan/components/openstack/common.pan
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type openstack_neutron_service_plugins = choice('router', 'port_forwarding')[];

type openstack_neutron_agent_extensions = choice('port_forwarding')[];

type openstack_keystone_endpoint_type = choice('internalURL', 'publicURL');

@documentation{
OpenStack common domains section
}
Expand All @@ -49,6 +51,9 @@ type openstack_domains_common = {
'username' : string
@{OpenStack service user password}
'password' : string
@{Type of endpoint in Identity service catalog to use for communication with
OpenStack services}
'interface' ? openstack_keystone_endpoint_type = 'internalURL'
};

@documentation{
Expand Down Expand Up @@ -77,6 +82,14 @@ type openstack_oslo_concurrency = {
'lock_path' : absolute_file_path
};

@documentation{
The configuration options in 'oslo_messaging_notifications' Section.
}
type openstack_oslo_messaging_notifications = {
@{The drivers to handle sending notifications}
'driver' : choice('messaging', 'messagingv2', 'routing', 'log', 'test', 'noop') = 'messagingv2'
};

@documentation{
The configuration options in the DEFAULTS Section
}
Expand Down
21 changes: 21 additions & 0 deletions ncm-openstack/src/main/pan/components/openstack/compute/nova.pan
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,26 @@ type openstack_nova_DEFAULTS = {
NOTE: As of the 16.0.0 Pike release, this configuration option is ignored
for the ironic.IronicDriver compute driver and is hardcoded to 1.0}
"ram_allocation_ratio" ? double(0..)
@{This option enables periodic compute.instance.exists notifications. Each
compute node must be configured to generate system usage data. These
notifications are consumed by OpenStack Telemetry service}
"instance_usage_audit" ? boolean
@{Time period to generate instance usages for}
"instance_usage_audit_period" ? choice('hour', 'day', 'month', 'year')
@{If set, send compute.instance.update notifications on
instance state changes.
Please refer to:
https://docs.openstack.org/nova/latest/reference/notifications.html for
additional information on notifications.
* None - no notifications
* "vm_state" - notifications are sent with VM state transition information in
the ``old_state`` and ``state`` fields. The ``old_task_state`` and
``new_task_state`` fields will be set to the current task_state of the
instance.
* "vm_and_task_state" - notifications are sent with VM and task state
transition information}
"notify_on_state_change" ? choice('None', 'vm_state', 'vm_and_task_state')

};

@documentation{
Expand All @@ -288,6 +308,7 @@ type openstack_nova_common = {
'placement' : openstack_nova_placement
'cinder' ? openstack_nova_cinder
'neutron' ? openstack_nova_neutron
'oslo_messaging_notifications' ? openstack_oslo_messaging_notifications
};

type openstack_quattor_nova = openstack_quattor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ type openstack_horizon_config_identity_keystone = {
@{the endpoint type to use for the endpoints in the Keystone service catalog.
The default value for all services except for identity is "publicURL".
The default value for the identity service is "internalURL".}
'openstack_endpoint_type' ? choice('internalURL', 'publicURL')
'openstack_endpoint_type' ? openstack_keystone_endpoint_type
@{Configure the default role for users that you create via the dashboard}
'openstack_keystone_default_role' : string = 'user'
'openstack_keystone_backend' : openstack_horizon_keystone_backend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ function openstack_merge = {
Returns undef if nothing is found.}
function openstack_identity_gather_find_authtoken = {
data = ARGV[0];
name = ARGV[1];

foreach (k; v; data) {
res = undef;
if (k == 'keystone_authtoken') {
if (k == name) {
res = v;
} else if (is_dict(v)) {
res = openstack_identity_gather_find_authtoken(v);
res = openstack_identity_gather_find_authtoken(v, name);
};
if (is_defined(res)) {
return(res);
Expand Down Expand Up @@ -135,7 +136,8 @@ function openstack_identity_gather_service = {
# user/passwd data
# get user/password from a keystone_authtoken section
# section can be nested
authtoken = openstack_identity_gather_find_authtoken(srv);
auth_key = if (service == 'metric' && flavour == 'ceilometer') 'service_credentials' else 'keystone_authtoken';
authtoken = openstack_identity_gather_find_authtoken(srv, auth_key);
if (is_defined(authtoken)) {
if (!exists(authtoken['username']) || !exists(authtoken['password'])) {
error("%s: authtoken section has no user and/or password %s %s", FUNCTION, descr, msg);
Expand Down Expand Up @@ -216,7 +218,7 @@ function openstack_identity_gather = {

os_component = '/software/components/openstack';
os_services = list('identity', 'network', 'compute', 'image',
'volume', 'share', 'catalog', 'orchestration');
'volume', 'share', 'catalog', 'orchestration', 'metric');

hosts = list(list(OBJECT, ''));
if (ARGC > 1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
unique template components/openstack/identity/gather/metric/ceilometer;

@{openstack_quattor_ceilometer default value until we can use the schema defaults from value}
prefix "/software/components/openstack/metric/ceilometer/quattor";
'service/name' = 'gnocchi';
prefix "service/internal";
'proto' ?= 'https';
'host' ?= OBJECT;
'port' ?= 8041;
'suffix' ?= '';
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ type openstack_glance_service_config = {
'paste_deploy' : openstack_keystone_paste_deploy
'glance_store' ? openstack_glance_store
'cors' ? openstack_cors
'oslo_messaging_notifications' ? openstack_oslo_messaging_notifications
};

type openstack_quattor_glance = openstack_quattor;
Expand Down
14 changes: 14 additions & 0 deletions ncm-openstack/src/main/pan/components/openstack/metric.pan
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ${license-info}
# ${developer-info}
# ${author-info}

declaration template components/openstack/metric;

include 'components/openstack/metric/ceilometer';

@documentation{
Type to define OpenStack metric services
}
type openstack_metric_config = {
'ceilometer' ? openstack_ceilometer_config
} with openstack_oneof(SELF, 'ceilometer');
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# ${license-info}
# ${developer-info}
# ${author-info}


declaration template components/openstack/metric/ceilometer;

include 'components/openstack/identity';



@documentation{
list of Gnocchi api section
}
type openstack_ceilometer_gnocchi_api = {
'auth_mode' : string = 'keystone'
};


@documentation{
list of Gnocchi indexer section
}
type openstack_ceilometer_gnocchi_indexer = {
@{The SQLAlchemy connection string to use to connect to the database}
'url' : string
};

@documentation{
list of Gnocchi storage section
}
type openstack_ceilometer_gnocchi_storage = {
'file_basepath' ? absolute_file_path = '/var/lib/gnocchi'
'driver' : choice ('file', 'ceph') = 'file'
@{Ceph pool name to use}
'ceph_pool' ? string
@{Ceph username (ie: admin without "client." prefix)}
'ceph_username' ? string
@{Ceph keyring path}
'ceph_keyring' ? absolute_file_path
@{Ceph configuration file}
'ceph_conffile' ? absolute_file_path
} = dict();


@documentation{
list of Ceilometer Gnocchi service sections
}
type openstack_ceilometer_gnocchi_config = {
'api' : openstack_ceilometer_gnocchi_api
'indexer' : openstack_ceilometer_gnocchi_indexer
'storage' : openstack_ceilometer_gnocchi_storage
'keystone_authtoken' : openstack_domains_common
};

@documentation{
list of Ceilometer service configuration sections
}
type openstack_ceilometer_service_config = {
'DEFAULT' : openstack_DEFAULTS
'service_credentials' : openstack_domains_common
};

type openstack_quattor_ceilometer = openstack_quattor;

@documentation{
list of Ceilometer service configuration sections
}
type openstack_ceilometer_config = {
'service' ? openstack_ceilometer_service_config
'gnocchi' ? openstack_ceilometer_gnocchi_config
'quattor' : openstack_quattor_ceilometer = dict()
};
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ type openstack_neutron_service_config = {
'database' ? openstack_database
@{nova section has the same options than "keystone_authtoken" but with the nova user and passwod}
'nova' ? openstack_neutron_nova
'oslo_messaging_notifications' ? openstack_oslo_messaging_notifications
};

type openstack_quattor_neutron = openstack_quattor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type openstack_heat_clients_keystone = {
type openstack_heat_clients = {
@{Type of endpoint in Identity service catalog to use for communication with
the OpenStack service}
'endpoint_type' : choice('internalURL', 'publicURL') = 'internalURL'
'endpoint_type' : openstack_keystone_endpoint_type = 'internalURL'
} = dict();

type openstack_quattor_heat = openstack_quattor;
Expand All @@ -57,5 +57,6 @@ type openstack_heat_config = {
'trustee' : openstack_domains_common
'clients_keystone' : openstack_heat_clients_keystone
'clients' : openstack_heat_clients
'oslo_messaging_notifications' ? openstack_oslo_messaging_notifications
'quattor' : openstack_quattor_heat
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ unique template components/${project.artifactId}/rootwrap;

include 'components/sudo/config';

variable ROOTWRAP_SERVICES = list('nova', 'neutron', 'cinder', 'manila');
variable ROOTWRAP_SERVICES = list('nova', 'neutron', 'cinder', 'manila', 'ceilometer');

"/software/components/sudo/privilege_lines" = {

Expand Down
2 changes: 2 additions & 0 deletions ncm-openstack/src/main/pan/components/openstack/schema.pan
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ include 'components/openstack/dashboard';
include 'components/openstack/orchestration';
include 'components/openstack/catalog';
include 'components/openstack/messaging';
include 'components/openstack/metric';

@documentation{
Hypervisor configuration.
Expand Down Expand Up @@ -57,6 +58,7 @@ type openstack_component = {
'messaging' ? openstack_messaging_config
'orchestration' ? openstack_orchestration_config
'catalog' ? openstack_catalog_config
'metric' ? openstack_metric_config
'openrc' ? openstack_openrc_config
@{Hypervisor configuration. Host is a hypervisor when this attribute exists}
'hypervisor' ? openstack_hypervisor_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type openstack_cinder_config = {
'database' : openstack_database
'keystone_authtoken' : openstack_keystone_authtoken
'oslo_concurrency' : openstack_oslo_concurrency
'oslo_messaging_notifications' ? openstack_oslo_messaging_notifications
'lvm' ? openstack_cinder_lvm
'ceph' ? openstack_cinder_ceph
# default empty dict for pure hypervisor
Expand Down
80 changes: 80 additions & 0 deletions ncm-openstack/src/main/perl/OpenStack/Ceilometer.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#${PMpre} NCM::Component::OpenStack::Ceilometer${PMpost}

use parent qw(NCM::Component::OpenStack::Service);

use Readonly;
use Data::Dumper;

Readonly our $GNOCCHI_DB_MANAGE_COMMAND => "/usr/bin/gnocchi-upgrade";
Readonly our $CEILOMETER_DB_MANAGE_COMMAND => "/usr/bin/ceilometer-upgrade";

Readonly::Array my @CEILOMETER_DB_BOOTSTRAP => qw(--debug);
Readonly::Array my @CEILOMETER_DB_VERSION => qw(--version);

Readonly::Hash my %CONF_FILE => {
service => "/etc/ceilometer/ceilometer.conf",
gnocchi => "/etc/gnocchi/gnocchi.conf",
};

Readonly::Hash my %DAEMON => {
service => ['openstack-ceilometer-notification', 'openstack-ceilometer-central'],
gnocchi => ['openstack-gnocchi-metricd', 'httpd'],
};

Readonly::Hash my %DAEMON_HYPERVISOR => {
service => ['openstack-ceilometer-compute', 'openstack-ceilometer-ipmi'],
};


=head2 Methods
=over
=item _attrs
Override C<manage>, C<db> and C<filename> attribute (and set C<daemon_map>)
=cut

sub _attrs
{
my $self = shift;

$self->{manage} = $self->{hypervisor} ? undef : $CEILOMETER_DB_MANAGE_COMMAND;
#delete $self->{manage};
# Ceilometer has no database parameters
$self->{db_version} = [@CEILOMETER_DB_VERSION];
$self->{db_sync} = [@CEILOMETER_DB_BOOTSTRAP];
$self->{filename} = \%CONF_FILE;
$self->{fileownergroup}->{$CONF_FILE{gnocchi}} = {
user => 'gnocchi',
group => 'gnocchi',
};
$self->{daemon_map} = $self->{hypervisor} ? \%DAEMON_HYPERVISOR : \%DAEMON;
}

=item pre_populate_service_database
Initializes C<Gnocchi> database for C<Ceilometer> metric service.
This should be done before C<Ceilometer> database bootstrap.
=cut

sub pre_populate_service_database
{
my ($self) = @_;

my $cmd = [$GNOCCHI_DB_MANAGE_COMMAND];
$self->_do($cmd, "pre-populate Gnocchi database", sensitive => 0, user => 'gnocchi')
or return;

return 1;
}

=pod
=back
=cut

1;
Loading

0 comments on commit bea92e7

Please sign in to comment.