config/sysinv/sysinv/sysinv/sysinv/objects/memory.py
Andrew Troake 766de0c034 Hugepage percent allocation.
Users have the option to allocate hugepage memory by # of
pages or percent of memory available.
Percent allocation is allocated on boot.

Story: 2006755
Task: 37245

CLI:
Allocating by percentage:
system host-memory-modify -2M 50% controller-0 0
Allocating by # of pages
system host-memory-modify -2M 50 controller-0 0

Testcases:
Allocating hugepage memory by percentage
Allocating hugepage memory by number of pages
Correct percentage is allocated if available memory
    changes
100% of hugepage memory allocates correctly
Check error is raised if user attempts to allocate
    percentage not in range of 0%-100%
Confirm that Horizon GUI can set as both percent and
    integer
Confirm that hugepage changes are made before unlock
    and after unlock

Change-Id: I6f1165c22e409e261c0b065f7d6cf5407647b56e
Signed-off-by: Andrew Troake <andrew.troake@windriver.com>
2019-12-16 15:16:56 -05:00

71 lines
2.3 KiB
Python

#
# Copyright (c) 2013-2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# coding=utf-8
#
#
from sysinv.db import api as db_api
from sysinv.objects import base
from sysinv.objects import utils
class Memory(base.SysinvObject):
dbapi = db_api.get_instance()
fields = {
'id': int,
'uuid': utils.str_or_none,
'forinodeid': utils.int_or_none,
'inode_uuid': utils.str_or_none,
'forihostid': int,
'ihost_uuid': utils.str_or_none,
'numa_node': utils.int_or_none,
'memtotal_mib': utils.int_or_none,
'memavail_mib': utils.int_or_none,
'platform_reserved_mib': utils.int_or_none,
'node_memtotal_mib': utils.int_or_none,
'hugepages_configured': utils.str_or_none,
'vswitch_hugepages_size_mib': utils.int_or_none,
'vswitch_hugepages_reqd': utils.int_or_none,
'vswitch_hugepages_nr': utils.int_or_none,
'vswitch_hugepages_avail': utils.int_or_none,
'vm_pending_as_percentage': utils.str_or_none,
'vm_hugepages_nr_2M_pending': utils.int_or_none,
'vm_hugepages_nr_1G_pending': utils.int_or_none,
'vm_hugepages_nr_2M': utils.int_or_none,
'vm_hugepages_avail_2M': utils.int_or_none,
'vm_hugepages_nr_1G': utils.int_or_none,
'vm_hugepages_avail_1G': utils.int_or_none,
'vm_hugepages_2M_percentage': utils.int_or_none,
'vm_hugepages_1G_percentage': utils.int_or_none,
'vm_hugepages_nr_4K': utils.int_or_none,
'vm_hugepages_use_1G': utils.str_or_none,
'vm_hugepages_possible_2M': utils.int_or_none,
'vm_hugepages_possible_1G': utils.int_or_none,
'capabilities': utils.dict_or_none,
}
_foreign_fields = {'ihost_uuid': 'host:uuid',
'inode_uuid': 'node:uuid',
'numa_node': 'node:numa_node'}
@base.remotable_classmethod
def get_by_uuid(cls, context, uuid):
return cls.dbapi.imemory_get(uuid)
def save_changes(self, context, updates):
self.dbapi.imemory_update(self.uuid, # pylint: disable=no-member
updates)