def do_host_apply_memprofile(cc, args): """Apply a memory profile to a host.""" # Assemble patch profile = iprofile_utils._find_iprofile(cc, args.profilenameoruuid) patch = _prepare_profile_patch(profile.uuid) # Send patch host = ihost_utils._find_ihost(cc, args.hostnameorid) try: host = cc.ihost.update(host.id, patch) except exc.HTTPNotFound: raise exc.CommandError('host not found: %s' % args.hostnameorid) # Echo list of new host memory imemory = cc.imemory.list(host.uuid) field_labels = [ 'uuid', 'vm_hugepages_1G', 'vm_hugepages_2M', 'vm_hugepages_2M_pending', 'vm_hugepages_1G_pending', 'vswitch_hugepages_nr', 'vswitch_hugepages_size_reqd', 'vswitch_hugepages_size_mib' ] fields = [ 'uuid', 'vm_hugepages_nr_1G', 'vm_hugepages_nr_2M', 'vm_hugepages_nr_2M_pending', 'vm_hugepages_nr_1G_pending', 'vswitch_hugepages_nr', 'vswitch_hugepages_reqd', 'vswitch_hugepages_size_mib' ] utils.print_list(imemory, fields, field_labels, sortby=0)
def do_host_apply_cpuprofile(cc, args): """Apply a cpu profile to a host.""" # Assemble patch profile = iprofile_utils._find_iprofile(cc, args.profilenameoruuid) patch = _prepare_profile_patch(profile.uuid) # Send patch host = ihost_utils._find_ihost(cc, args.hostnameorid) try: host = cc.ihost.update(host.id, patch) except exc.HTTPNotFound: raise exc.CommandError('host not found: %s' % args.hostnameorid) # Echo list of new host cpus icpus = cc.icpu.list(host.uuid) field_labels = [ 'uuid', 'log_core', 'processor', 'phy_core', 'thread', 'processor_model', 'assigned_function' ] fields = [ 'uuid', 'cpu', 'numa_node', 'core', 'thread', 'cpu_model', 'allocated_function' ] utils.print_list(icpus, fields, field_labels, sortby=1, formatters={ 'allocated_function': icpu_utils._cpu_function_tuple_formatter })
def do_cpuprofile_show(cc, args): """Show cpu profile attributes.""" iprofile = iprofile_utils._find_iprofile(cc, args.cpuprofilenameoruuid) get_cpuprofile_data(cc, iprofile) if not iprofile.cpus: # not a 'cpu' profile raise exc.CommandError('CPU Profile not found: %s' % args.cpuprofilenameoruuid) _print_cpuprofile_show(iprofile)
def do_host_apply_ifprofile(cc, args): """Apply an interface profile to a host.""" # Assemble patch profile = iprofile_utils._find_iprofile(cc, args.profilenameoruuid) patch = _prepare_profile_patch(profile.uuid) # Send patch host = ihost_utils._find_ihost(cc, args.hostnameorid) try: host = cc.ihost.update(host.id, patch) except exc.HTTPNotFound: raise exc.CommandError('host not found: %s' % args.hostnameorid) # Echo list of new host interfaces iinterfaces = cc.iinterface.list(host.uuid) for i in iinterfaces: iinterface_utils._get_ports(cc, host, i) field_labels = [ 'uuid', 'name', 'network type', 'type', 'vlan id', 'ports', 'uses', 'used by', 'mtu', 'provider networks' ] fields = [ 'uuid', 'ifname', 'networktype', 'iftype', 'vlan_id', 'ports', 'uses', 'used_by', 'imtu', 'providernetworks' ] utils.print_list(iinterfaces, fields, field_labels, sortby=0)
def do_memprofile_delete(cc, args): """Delete a memory profile.""" for n in args.iprofilenameoruuid: iprofile = iprofile_utils._find_iprofile(cc, n) try: cc.iprofile.delete(iprofile.uuid) except exc.HTTPNotFound: raise exc.CommandError('Memory profile delete failed: %s' % n) print('Deleted memory profile %s' % n)
def do_memprofile_show(cc, args): """Show memory profile attributes.""" iprofile = iprofile_utils._find_iprofile(cc, args.iprofilenameoruuid) get_memprofile_data(cc, iprofile) if not iprofile.memory: # not a memory profile raise exc.CommandError('Memory Profile not found: %s' % args.ifprofilenameoruuid) _print_memprofile_show(iprofile)
def do_ifprofile_show(cc, args): """Show interface profile attributes.""" iprofile = iprofile_utils._find_iprofile(cc, args.ifprofilenameoruuid) get_ifprofile_data(cc, iprofile) if not iprofile.ports: # not an 'interface' profile raise exc.CommandError('If Profile not found: %s' % args.ifprofilenameoruuid) _print_ifprofile_show(iprofile)
def do_host_apply_storprofile(cc, args): """Apply a storage profile to a host.""" # Assemble patch profile = iprofile_utils._find_iprofile(cc, args.profilenameoruuid) patch = _prepare_profile_patch(profile.uuid) host = ihost_utils._find_ihost(cc, args.hostnameorid) try: host = cc.ihost.update(host.id, patch) except exc.HTTPNotFound: raise exc.CommandError('Host not found: %s' % args.hostnameorid) _list_storage(cc, host)
def do_storprofile_show(cc, args): """Show storage profile attributes.""" iprofile = iprofile_utils._find_iprofile(cc, args.iprofilenameoruuid) get_storprofile_data(cc, iprofile) if not iprofile.disks: # not a stor profile raise exc.CommandError('Stor Profile not found: %s' % args.ifprofilenameoruuid) profile_disk_invalid = get_storprofile_data(cc, iprofile, detailed=True) if profile_disk_invalid: print("WARNING: This storage profile, from a previous release, is " "missing the persistent disk name in the disk config field. " "This profile needs to be deleted and recreated.") _print_storprofile_show(iprofile)
def do_host_apply_profile(cc, args): """Apply a profile to a host.""" # Assemble patch profile = iprofile_utils._find_iprofile(cc, args.profilenameoruuid) patch = _prepare_profile_patch(profile.uuid) # Send patch host = ihost_utils._find_ihost(cc, args.hostnameorid) try: host = cc.ihost.update(host.id, patch) except exc.HTTPNotFound: raise exc.CommandError('host not found: %s' % args.hostnameorid) # Echo list of new host interfaces iinterfaces = cc.iinterface.list(host.uuid) for i in iinterfaces: iinterface_utils._get_ports(cc, host, i) field_labels = ['uuid', 'name', 'network type', 'type', 'vlan id', 'ports', 'uses', 'used by', 'mtu', 'provider networks'] fields = ['uuid', 'ifname', 'networktype', 'iftype', 'vlan_id', 'ports', 'uses', 'used_by', 'imtu', 'providernetworks'] utils.print_list(iinterfaces, fields, field_labels, sortby=0) # Echo list of new host cpus icpus = cc.icpu.list(host.uuid) field_labels = ['uuid', 'log_core', 'processor', 'phy_core', 'thread', 'processor_model', 'assigned_function'] fields = ['uuid', 'cpu', 'numa_node', 'core', 'thread', 'cpu_model', 'allocated_function'] utils.print_list(icpus, fields, field_labels, sortby=1, formatters={'allocated_function': icpu_utils._cpu_function_tuple_formatter}) _list_storage(cc, host) # Echo list of new memory imemory = cc.imemory.list(host.uuid) field_labels = ['uuid', 'application_hugepages_1G', 'application_hugepages_2M', 'application_hugepages_2M_pending', 'application_hugepages_1G_pending'] fields = ['uuid', 'vm_hugepages_nr_1G', 'vm_hugepages_nr_2M', 'vm_hugepages_nr_2M_pending', 'vm_hugepages_nr_1G_pending'] utils.print_list(imemory, fields, field_labels, sortby=0)