Converting compute-hyperv to py3
Initial conversion with 2to3 tool Added support for Python3 Replaces / with // for Py3 compatibility Adds Py2.7 compatibility Fix IOUtils Py3 compatibility issue. The method retrieving buffer data was raising a TypeError on Py3. Co-Authored-By: Alessandro Pilotti <apilotti@cloudbasesolutions.com> Co-Authored-By: Claudiu Belu <cbelu@cloudbasesolutions.com> Co-Authored-By: Lucian Petrut <lpetrut@cloudbasesolutions.com> Change-Id: I99212227105d5fd442a7bd88eb8832586a187e2f
This commit is contained in:
committed by
Lucian Petrut
parent
61b87f8094
commit
cca46626a9
@@ -19,6 +19,7 @@ Management class for host operations.
|
||||
import datetime
|
||||
import os
|
||||
import platform
|
||||
import six
|
||||
import time
|
||||
|
||||
|
||||
@@ -81,12 +82,12 @@ class HostOps(object):
|
||||
topology = dict()
|
||||
topology['sockets'] = len(processors)
|
||||
topology['cores'] = processors[0]['NumberOfCores']
|
||||
topology['threads'] = (processors[0]['NumberOfLogicalProcessors'] /
|
||||
topology['threads'] = (processors[0]['NumberOfLogicalProcessors'] //
|
||||
processors[0]['NumberOfCores'])
|
||||
cpu_info['topology'] = topology
|
||||
|
||||
features = list()
|
||||
for fkey, fname in constants.PROCESSOR_FEATURE.items():
|
||||
for fkey, fname in six.iteritems(constants.PROCESSOR_FEATURE):
|
||||
if self._hostutils.is_cpu_feature_present(fkey):
|
||||
features.append(fname)
|
||||
cpu_info['features'] = features
|
||||
@@ -95,16 +96,16 @@ class HostOps(object):
|
||||
|
||||
def _get_memory_info(self):
|
||||
(total_mem_kb, free_mem_kb) = self._hostutils.get_memory_info()
|
||||
total_mem_mb = total_mem_kb / 1024
|
||||
free_mem_mb = free_mem_kb / 1024
|
||||
total_mem_mb = total_mem_kb // 1024
|
||||
free_mem_mb = free_mem_kb // 1024
|
||||
return (total_mem_mb, free_mem_mb, total_mem_mb - free_mem_mb)
|
||||
|
||||
def _get_local_hdd_info_gb(self):
|
||||
drive = os.path.splitdrive(self._pathutils.get_instances_dir())[0]
|
||||
(size, free_space) = self._hostutils.get_volume_info(drive)
|
||||
|
||||
total_gb = size / units.Gi
|
||||
free_gb = free_space / units.Gi
|
||||
total_gb = size // units.Gi
|
||||
free_gb = free_space // units.Gi
|
||||
used_gb = total_gb - free_gb
|
||||
return (total_gb, free_gb, used_gb)
|
||||
|
||||
@@ -222,7 +223,7 @@ class HostOps(object):
|
||||
# value is same as in libvirt
|
||||
return "%s up %s, 0 users, load average: 0, 0, 0" % (
|
||||
str(time.strftime("%H:%M:%S")),
|
||||
str(datetime.timedelta(milliseconds=long(tick_count64))))
|
||||
str(datetime.timedelta(milliseconds=int(tick_count64))))
|
||||
|
||||
def host_maintenance_mode(self, host, mode):
|
||||
"""Starts/Stops host maintenance. On start, it triggers
|
||||
|
||||
Reference in New Issue
Block a user