Merge "Enable ceilometer"
This commit is contained in:
commit
039d0ad335
|
@ -12,8 +12,6 @@
|
|||
description: ''
|
||||
- name: 'additional_service:murano'
|
||||
description: ''
|
||||
- name: 'additional_service:ceilometer'
|
||||
description: ''
|
||||
- name: 'additional_service:mongo'
|
||||
description: ''
|
||||
- name: 'additional_service:ironic'
|
||||
|
|
|
@ -405,6 +405,19 @@ def enable_linux_bridge(himn, username):
|
|||
ssh(himn, username, 'rm -f /etc/modprobe.d/blacklist-bridge*')
|
||||
|
||||
|
||||
def patch_ceilometer():
|
||||
"""
|
||||
Add patches which are not MOS with order:
|
||||
ceilometer-poll-cpu-util.patch
|
||||
"""
|
||||
patchset_dir = sys.path[0]
|
||||
patchfile_list = [
|
||||
'%s/patchset/ceilometer-poll-cpu-util.patch' % patchset_dir,
|
||||
]
|
||||
for patch_file in patchfile_list:
|
||||
execute('patch', '-d', DIST_PACKAGES_DIR, '-p1', '-i', patch_file)
|
||||
|
||||
|
||||
def patch_compute_xenapi():
|
||||
"""
|
||||
Add patches which are not merged to upstream with order:
|
||||
|
@ -440,6 +453,31 @@ def reconfig_multipath():
|
|||
execute('service', 'multipath-tools', 'restart')
|
||||
|
||||
|
||||
def check_and_setup_ceilometer(himn, username, password):
|
||||
"""Set xenapi configuration for ceilometer service"""
|
||||
filename = '/etc/ceilometer/ceilometer.conf'
|
||||
if not os.path.exists(filename):
|
||||
reportError("The file: %s doesn't exist" % filename)
|
||||
return
|
||||
|
||||
patch_ceilometer()
|
||||
|
||||
cf = ConfigParser.ConfigParser()
|
||||
try:
|
||||
cf.read(filename)
|
||||
cf.set('DEFAULT', 'hypervisor_inspector', 'xenapi')
|
||||
cf.set('xenapi', 'connection_url', 'http://%s' % himn)
|
||||
cf.set('xenapi', 'connection_username', username)
|
||||
cf.set('xenapi', 'connection_password', password)
|
||||
with open(filename, 'w') as configfile:
|
||||
cf.write(configfile)
|
||||
logging.info('Modify file %s successfully', filename)
|
||||
except Exception:
|
||||
reportError("Fail to modify file %s", filename)
|
||||
return
|
||||
restart_services('ceilometer-polling')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
install_xenapi_sdk()
|
||||
astute = get_astute(ASTUTE_PATH)
|
||||
|
@ -478,3 +516,12 @@ if __name__ == '__main__':
|
|||
restart_services('neutron-openvswitch-agent')
|
||||
|
||||
reconfig_multipath()
|
||||
|
||||
# Add xenapi specific setup for ceilometer if service is enabled.
|
||||
is_ceilometer_enabled = astute_get(astute,
|
||||
('ceilometer', 'enabled'))
|
||||
if is_ceilometer_enabled:
|
||||
check_and_setup_ceilometer(HIMN_IP, username, password)
|
||||
else:
|
||||
logging.info('Skip ceilomter setup as this service is '
|
||||
'disabled.')
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
diff --git a/ceilometer/compute/virt/xenapi/inspector.py b/ceilometer/compute/virt/xenapi/inspector.py
|
||||
index 19405dd..62960da 100644
|
||||
--- a/ceilometer/compute/virt/xenapi/inspector.py
|
||||
+++ b/ceilometer/compute/virt/xenapi/inspector.py
|
||||
@@ -120,18 +120,15 @@ class XenapiInspector(virt_inspector.Inspector):
|
||||
def inspect_cpu_util(self, instance, duration=None):
|
||||
instance_name = util.instance_name(instance)
|
||||
vm_ref = self._lookup_by_name(instance_name)
|
||||
- metrics_ref = self._call_xenapi("VM.get_metrics", vm_ref)
|
||||
- metrics_rec = self._call_xenapi("VM_metrics.get_record",
|
||||
- metrics_ref)
|
||||
- vcpus_number = metrics_rec['VCPUs_number']
|
||||
- vcpus_utils = metrics_rec['VCPUs_utilisation']
|
||||
- if len(vcpus_utils) == 0:
|
||||
- msg = _("Could not get VM %s CPU Utilization") % instance_name
|
||||
+ vcpus_number = int(self._call_xenapi("VM.get_VCPUs_max", vm_ref))
|
||||
+ if vcpus_number <= 0:
|
||||
+ msg = _("Could not get VM %s CPU number") % instance_name
|
||||
raise XenapiException(msg)
|
||||
-
|
||||
utils = 0.0
|
||||
- for num in range(int(vcpus_number)):
|
||||
- utils += vcpus_utils.get(str(num))
|
||||
+ for index in range(vcpus_number):
|
||||
+ utils += float(self._call_xenapi("VM.query_data_source",
|
||||
+ vm_ref,
|
||||
+ "cpu%d" % index))
|
||||
utils = utils / int(vcpus_number) * 100
|
||||
return virt_inspector.CPUUtilStats(util=utils)
|
||||
|
|
@ -6,7 +6,6 @@ attributes:
|
|||
- "settings:storage.ephemeral_ceph.value == true"
|
||||
- "settings:additional_components.sahara.value == true"
|
||||
- "settings:additional_components.murano.value == true"
|
||||
- "settings:additional_components.ceilometer.value == true"
|
||||
- "settings:additional_components.mongo.value == true"
|
||||
- "settings:additional_components.ironic.value == true"
|
||||
group: 'compute'
|
||||
|
@ -30,4 +29,4 @@ attributes:
|
|||
label: 'Install Nova Plugins'
|
||||
description: ''
|
||||
weight: 30
|
||||
type: "checkbox"
|
||||
type: "checkbox"
|
||||
|
|
Loading…
Reference in New Issue