From b6ce4f5918cc2627c398c264bc9ed5682e96921b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Sim=C3=B3n?= Date: Thu, 28 Nov 2024 10:36:12 +0100 Subject: [PATCH 1/5] ncm-opennebula: add cpu model section and remove it from raw xml --- .../src/main/pan/quattor/aii/opennebula/schema.pan | 4 ++++ ncm-opennebula/src/main/resources/raw_level1.tt | 3 +-- ncm-opennebula/src/main/resources/tests/profiles/vm.pan | 1 + .../src/main/resources/tests/regexps/aii_vmtemplate/simple | 2 +- .../resources/tests/regexps/aii_vmtemplate/vm_template | 3 +-- ncm-opennebula/src/main/resources/vmtemplate.tt | 5 +++++ ncm-opennebula/src/test/perl/rpcdata.pm | 7 +++++-- ncm-opennebula/src/test/resources/vm.pan | 2 ++ 8 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan b/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan index 97d2efdad1..2ebaa1e140 100644 --- a/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan +++ b/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan @@ -352,4 +352,8 @@ type opennebula_vmtemplate = { https://docs.opennebula.io/6.10/management_and_operations/capacity_planning/overcommitment.html } "cpuratio" : double(0..1) = 1.0 + @{The CPU model exposed to the guest. host-passthrough is the same model as the host. + Available modes are stored in the host information and obtained through monitor (onehost show ). + } + "cpu_model" : string = "host-passthrough" } = dict(); diff --git a/ncm-opennebula/src/main/resources/raw_level1.tt b/ncm-opennebula/src/main/resources/raw_level1.tt index 6da0af35de..f883a6bb2c 100644 --- a/ncm-opennebula/src/main/resources/raw_level1.tt +++ b/ncm-opennebula/src/main/resources/raw_level1.tt @@ -1,5 +1,4 @@ -DATA = "[% vcpus %] - +DATA = " [%- IF system.opennebula.memorybacking.defined %] [%- FOREACH item IN system.opennebula.memorybacking %] diff --git a/ncm-opennebula/src/main/resources/tests/profiles/vm.pan b/ncm-opennebula/src/main/resources/tests/profiles/vm.pan index c273b44531..f7f5224536 100644 --- a/ncm-opennebula/src/main/resources/tests/profiles/vm.pan +++ b/ncm-opennebula/src/main/resources/tests/profiles/vm.pan @@ -221,4 +221,5 @@ prefix "/system/opennebula"; )); "cpuratio" = 1.0; +"cpu_model" = "Broadwell-noTSX-IBRS"; diff --git a/ncm-opennebula/src/main/resources/tests/regexps/aii_vmtemplate/simple b/ncm-opennebula/src/main/resources/tests/regexps/aii_vmtemplate/simple index 36e594c1de..bd9ac5af4f 100644 --- a/ncm-opennebula/src/main/resources/tests/regexps/aii_vmtemplate/simple +++ b/ncm-opennebula/src/main/resources/tests/regexps/aii_vmtemplate/simple @@ -30,7 +30,7 @@ multiline ^OS\s?=\s?\[$ ^\s*BOOT\s?=\s*""\s*$ ^RAW\s?=\s?\[$ -^\s*DATA\s?=\s*".+$ +^\s*DATA\s?=\s*"$ ^\s*\<.+\>$ ^\s*\<.+\>",$ ^\s*TYPE\s?=\s*".+"\s*$ diff --git a/ncm-opennebula/src/main/resources/tests/regexps/aii_vmtemplate/vm_template b/ncm-opennebula/src/main/resources/tests/regexps/aii_vmtemplate/vm_template index 0f3e973c84..251bb4de03 100644 --- a/ncm-opennebula/src/main/resources/tests/regexps/aii_vmtemplate/vm_template +++ b/ncm-opennebula/src/main/resources/tests/regexps/aii_vmtemplate/vm_template @@ -58,8 +58,7 @@ multiline ^\s{4}BOOT\s?=\s?""$ ^\]$ ^RAW\s?=\s?\[$ -^\s{4}DATA\s?=\s?"\4\<\/vcpu\>\$ -^\s{4}\\<\/cpu\>$ +^\s{4}DATA\s?=\s?"$ ^\s{4}\$ ^\s{4}\$ ^\s{4}\$ diff --git a/ncm-opennebula/src/main/resources/vmtemplate.tt b/ncm-opennebula/src/main/resources/vmtemplate.tt index f46300bc7d..e6e38c34da 100644 --- a/ncm-opennebula/src/main/resources/vmtemplate.tt +++ b/ncm-opennebula/src/main/resources/vmtemplate.tt @@ -34,6 +34,11 @@ TOKEN = "YES" ] CPU = "[% vcpus * system.opennebula.cpuratio %]" VCPU = "[% vcpus %]" +CPU_MODEL = [ +[% FILTER indent -%] +MODEL = "[%- system.opennebula.cpu_model %]" +[%- END %] +] DESCRIPTION = "[% hardware.model %] [% fqdn %]" [%- FOR pair IN hardware.harddisks.pairs %] DISK = [ diff --git a/ncm-opennebula/src/test/perl/rpcdata.pm b/ncm-opennebula/src/test/perl/rpcdata.pm index d03391cac6..d8c7e50f47 100644 --- a/ncm-opennebula/src/test/perl/rpcdata.pm +++ b/ncm-opennebula/src/test/perl/rpcdata.pm @@ -881,6 +881,10 @@ CONTEXT = [ TOKEN = "YES" ] CPU = "4" +VCPU = "4" +CPU_MODEL = [ + MODEL = "Broadwell-noTSX-IBRS" +] DESCRIPTION = "KVM Virtual Machine node630.cubone.os" DISK = [ IMAGE = "node630.cubone.os_vda", @@ -906,8 +910,7 @@ OS = [ BOOT = "nic0,disk0" ] RAW = [ - DATA = "4 - + DATA = " diff --git a/ncm-opennebula/src/test/resources/vm.pan b/ncm-opennebula/src/test/resources/vm.pan index 0378ec5d6d..fb220567c3 100644 --- a/ncm-opennebula/src/test/resources/vm.pan +++ b/ncm-opennebula/src/test/resources/vm.pan @@ -185,3 +185,5 @@ prefix "/system/opennebula"; ); "cpuratio" = 1.0; +"cpu_model" = "Broadwell-noTSX-IBRS"; + From 09f060cda4af19bd2e8e8094e9c47f0789a32b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Sim=C3=B3n?= Date: Mon, 2 Dec 2024 10:05:11 +0100 Subject: [PATCH 2/5] ncm-opennebula: add cpu pinning support --- ncm-opennebula/src/main/perl/OpenNebula/Host.pm | 4 ++++ ncm-opennebula/src/main/resources/tests/profiles/vm.pan | 7 +++++++ ncm-opennebula/src/main/resources/topology_level1.tt | 4 ++++ ncm-opennebula/src/main/resources/vmtemplate.tt | 5 +++++ ncm-opennebula/src/test/resources/one.pan | 2 ++ 5 files changed, 22 insertions(+) create mode 100644 ncm-opennebula/src/main/resources/topology_level1.tt diff --git a/ncm-opennebula/src/main/perl/OpenNebula/Host.pm b/ncm-opennebula/src/main/perl/OpenNebula/Host.pm index a4cfb62414..f435a9f800 100644 --- a/ncm-opennebula/src/main/perl/OpenNebula/Host.pm +++ b/ncm-opennebula/src/main/perl/OpenNebula/Host.pm @@ -89,6 +89,10 @@ sub manage_hosts } # Update host template and set host cluster if defined $new = $self->update_something($one, "host", $host, "QUATTOR = 1"); + if (defined($hosts->{$host}->{pin_policy})) { + $new = $self->update_something($one, "host", $host, "PIN_POLICY = $hosts->{$host}->{pin_policy}"); + $self->verbose("HELLO pin defined: ", $hosts->{$host}->{pin_policy}); + }; if (defined($new) and defined($hosts->{$host}->{cluster})) { $self->verbose("Host $host cluster is set to: ", $hosts->{$host}->{cluster}); $self->set_service_clusters($one, "host", $new, $hosts->{$host}->{cluster}); diff --git a/ncm-opennebula/src/main/resources/tests/profiles/vm.pan b/ncm-opennebula/src/main/resources/tests/profiles/vm.pan index f7f5224536..5d69e4a492 100644 --- a/ncm-opennebula/src/main/resources/tests/profiles/vm.pan +++ b/ncm-opennebula/src/main/resources/tests/profiles/vm.pan @@ -223,3 +223,10 @@ prefix "/system/opennebula"; "cpuratio" = 1.0; "cpu_model" = "Broadwell-noTSX-IBRS"; +"topology" = dict( + "pin_policy", "NONE", + "sockets", 1, + "threads", 1, + "cores", 1, +); + diff --git a/ncm-opennebula/src/main/resources/topology_level1.tt b/ncm-opennebula/src/main/resources/topology_level1.tt new file mode 100644 index 0000000000..f2ebef1fa1 --- /dev/null +++ b/ncm-opennebula/src/main/resources/topology_level1.tt @@ -0,0 +1,4 @@ +[%- FOR pair IN data.pairs -%] +[% pair.key FILTER upper %] = "[% pair.value %]" +[%- data.pairs.last.key == pair.key ? "" : "," %] +[% END -%] diff --git a/ncm-opennebula/src/main/resources/vmtemplate.tt b/ncm-opennebula/src/main/resources/vmtemplate.tt index e6e38c34da..b7509ae43d 100644 --- a/ncm-opennebula/src/main/resources/vmtemplate.tt +++ b/ncm-opennebula/src/main/resources/vmtemplate.tt @@ -98,6 +98,11 @@ VMGROUP = [% INCLUDE 'opennebula/oned_level1.tt' data=item -%] [%- IF system.opennebula.labels.defined %] LABELS = "[% system.opennebula.labels.join(',') %]" [%- END %] +[%- IF system.opennebula.topology.pin_policy.defined %] +TOPOLOGY = [ +[% INCLUDE 'opennebula/topology_level1.tt' data=system.opennebula.topology FILTER indent -%] +] +[%- END %] [%- FOREACH sched IN system.opennebula.placements %] [% sched.key FILTER upper %] = "[% sched.value %]" [%- END %] diff --git a/ncm-opennebula/src/test/resources/one.pan b/ncm-opennebula/src/test/resources/one.pan index 31aa66d16e..875841ba5b 100644 --- a/ncm-opennebula/src/test/resources/one.pan +++ b/ncm-opennebula/src/test/resources/one.pan @@ -247,8 +247,10 @@ prefix "/software/components/opennebula"; 'hyp101', dict(), 'hyp102', dict(), # Add hyp103 in a different cluster + # and CPU pinning policy 'hyp103', dict( "cluster", "red.cluster", + "pin_policy", "PINNED", ), 'hyp104', dict(), ); From b0251e6629d46b85ddaf8fc21599e7f90e06ab1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Sim=C3=B3n?= Date: Mon, 2 Dec 2024 15:41:17 +0100 Subject: [PATCH 3/5] ncm-opennebula: update doc urls --- .../src/main/pan/components/opennebula/schema.pan | 7 ++----- .../src/main/pan/quattor/aii/opennebula/schema.pan | 4 +--- ncm-opennebula/src/main/perl/opennebula.pm | 4 +++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ncm-opennebula/src/main/pan/components/opennebula/schema.pan b/ncm-opennebula/src/main/pan/components/opennebula/schema.pan index 160223af46..598b9a6f55 100755 --- a/ncm-opennebula/src/main/pan/components/opennebula/schema.pan +++ b/ncm-opennebula/src/main/pan/components/opennebula/schema.pan @@ -1000,11 +1000,8 @@ type opennebula_oneflow = { "lcm_interval" : long = 30 @{default cooldown period after a scale operation, in seconds} "default_cooldown" : long = 300 - @{default shutdown action - terminate : OpenNebula >= 5.0.0 - shutdown : OpenNebula < 5.0.0 - } - "shutdown_action" : string = 'terminate' with match (SELF, '^(shutdown|shutdown-hard|terminate|terminate-hard)$') + @{default shutdown action} + "shutdown_action" : string = 'terminate' with match (SELF, '^(terminate|terminate-hard)$') @{default numner of virtual machines that will receive the given call in each interval defined by action_period, when an action is performed on a role} "action_number" : long(1..) = 1 diff --git a/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan b/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan index 2ebaa1e140..a8adc782d0 100644 --- a/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan +++ b/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan @@ -308,9 +308,7 @@ type opennebula_vmtemplate = { "pci" ? opennebula_vmtemplate_pci[] @{labels is a list of strings to group the VMs under a given name and filter them in the admin and cloud views. It is also possible to include in the list - sub-labels using a common slash: list("Name", "Name/SubName") - This feature is available since OpenNebula 5.x, below this version the change - does not take effect.} + sub-labels using a common slash: list("Name", "Name/SubName")} "labels" ? string[] "placements" ? opennebula_placements @{The optional memoryBacking element may contain several elements that influence diff --git a/ncm-opennebula/src/main/perl/opennebula.pm b/ncm-opennebula/src/main/perl/opennebula.pm index 1752199c6d..9679983652 100755 --- a/ncm-opennebula/src/main/perl/opennebula.pm +++ b/ncm-opennebula/src/main/perl/opennebula.pm @@ -54,7 +54,9 @@ Features that are implemented at this moment: =item * Updates KVM PCI passthrough filter config file -=item * Cloud resource labels (OpenNebula >= 5.x) +=item * Cloud resource labels + +=item * VMs CPU pinning =back From 51f3f91d7eef1d0c75d5270e44b4e4fa6422001a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Sim=C3=B3n?= Date: Mon, 2 Dec 2024 16:31:02 +0100 Subject: [PATCH 4/5] ncm-opennebula: more doc updates --- .../src/main/pan/quattor/aii/opennebula/schema.pan | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan b/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan index a8adc782d0..936f2f1ec3 100644 --- a/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan +++ b/ncm-opennebula/src/main/pan/quattor/aii/opennebula/schema.pan @@ -183,7 +183,7 @@ In this case to request this IB device we should set: class: 0x0c06 For more info: -http://docs.opennebula.org/5.0/deployment/open_cloud_host_setup/pci_passthrough.html +https://docs.opennebula.io/6.10/open_cluster_deployment/kvm_node/pci_passthrough.html } type opennebula_vmtemplate_pci = { @{first value from onehost TYPE section} @@ -215,7 +215,7 @@ Re-scheduling of VMs works as for any other VM, it will look for a different hos considering the placement constraints. For more info: -https://docs.opennebula.org/5.8/advanced_components/application_flow_and_auto-scaling/vmgroups.html +https://docs.opennebula.io/6.10/management_and_operations/capacity_planning/affinity.html } type opennebula_vmtemplate_vmgroup = { "vmgroup_name" : string @@ -224,7 +224,7 @@ type opennebula_vmtemplate_vmgroup = { @documentation{ Type that sets placement constraints and preferences for the VM, valid for all hosts -More info: http://docs.opennebula.org/5.0/operation/references/template.html#placement-section +More info: https://docs.opennebula.io/6.10/management_and_operations/capacity_planning/scheduling.html } type opennebula_placements = { @{Boolean expression that rules out provisioning hosts from list of machines @@ -289,12 +289,12 @@ type opennebula_vmtemplate = { '/system/opennebula/diskrdmpath/vdd/' = '/dev/sdf'; will passthrough the block device to the VM as vdd disk. Disk size is ignored in this case. It requires a RDM datastore. - See: https://docs.opennebula.org/5.8/deployment/open_cloud_storage_setup/dev_ds.html} + See: https://docs.opennebula.io/6.10/open_cluster_deployment/storage_setup/dev_ds.html} "diskrdmpath" ? opennebula_rdm_disk @{Set ignoremac tree to avoid to include MAC values within AR/VM templates} "ignoremac" ? opennebula_ignoremac @{Set how many queues will be used for the communication between CPUs and virtio drivers. - see: https://docs.opennebula.org/5.6/deployment/open_cloud_host_setup/kvm_driver.html} + see: https://docs.opennebula.io/6.10/open_cluster_deployment/kvm_node/kvm_driver.html} "virtio_queues" ? long(0..) @{Set graphics to export VM graphical display (VNC is used by default)} "graphics" : string = 'VNC' with match (SELF, '^(VNC|SDL|SPICE)$') From 2c215cad17dc77116e87ab2c87b83d57d5d556b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Sim=C3=B3n?= Date: Tue, 3 Dec 2024 11:10:02 +0100 Subject: [PATCH 5/5] ncm-opennebula: remove old legacy code --- .../src/main/pan/components/opennebula/schema.pan | 3 --- ncm-opennebula/src/main/perl/OpenNebula/AII.pm | 6 +----- ncm-opennebula/src/main/perl/OpenNebula/Host.pm | 1 - ncm-opennebula/src/main/perl/opennebula.pm | 13 +++++-------- ncm-opennebula/src/test/perl/aii_vmtemplate.t | 2 +- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/ncm-opennebula/src/main/pan/components/opennebula/schema.pan b/ncm-opennebula/src/main/pan/components/opennebula/schema.pan index 598b9a6f55..055e4cc785 100755 --- a/ncm-opennebula/src/main/pan/components/opennebula/schema.pan +++ b/ncm-opennebula/src/main/pan/components/opennebula/schema.pan @@ -324,9 +324,6 @@ Set OpenNebula hypervisor options and their virtual clusters (if any) type opennebula_host = { @{set OpenNebula hosts type.} 'host_hyp' : string = 'kvm' with match (SELF, '^(kvm|xen)$') - @{set the network driver in your hosts. - This option is not longer used by ONE >= 5.x versions.} - 'vnm_mad' ? string with match (SELF, '^(dummy|ovswitch|ovswitch_brcompat)$') @{Set the hypervisor cluster. Any new hypervisor is always included within "Default" cluster. Hosts can be in only one cluster at a time.} diff --git a/ncm-opennebula/src/main/perl/OpenNebula/AII.pm b/ncm-opennebula/src/main/perl/OpenNebula/AII.pm index 1723e2056b..4b1556fe4d 100644 --- a/ncm-opennebula/src/main/perl/OpenNebula/AII.pm +++ b/ncm-opennebula/src/main/perl/OpenNebula/AII.pm @@ -4,7 +4,7 @@ use NCM::Component::OpenNebula::Server qw($ONEADMIN_USER); use Readonly; use EDG::WP4::CCM::TextRender; -Readonly my $MINIMAL_ONE_VERSION => version->new("4.8.0"); +Readonly my $MINIMAL_ONE_VERSION => version->new("5.0.0"); Readonly my $AII_OPENNEBULA_CONFIG => "/etc/aii/opennebula.conf"; Readonly my $HOSTNAME => "/system/network/hostname"; Readonly my $DOMAINNAME => "/system/network/domainname"; @@ -12,7 +12,6 @@ Readonly my $MAXITER => 20; Readonly my $TIMEOUT => 30; Readonly my $ONE_DEFAULT_URL => 'http://localhost:2633/RPC2'; Readonly my $ONE_DEFAULT_PORT => 2633; -Readonly my $BOOT_V4 => [qw(network hd)]; Readonly my $BOOT_V5 => [qw(nic0 disk0)]; =head1 NAME @@ -79,9 +78,6 @@ sub process_template_aii if ((defined $oneversion) and ($oneversion >= version->new("5.0.0"))) { $tree->{system}->{opennebula}->{boot} = $BOOT_V5; $self->verbose("BOOT section set to support OpenNebula versions >= 5.0.0"); - } else { - $self->verbose("BOOT section set to support OpenNebula versions < 5.0.0"); - $tree->{system}->{opennebula}->{boot} = $BOOT_V4; }; my $tpl = EDG::WP4::CCM::TextRender->new( diff --git a/ncm-opennebula/src/main/perl/OpenNebula/Host.pm b/ncm-opennebula/src/main/perl/OpenNebula/Host.pm index f435a9f800..b369bafb5b 100644 --- a/ncm-opennebula/src/main/perl/OpenNebula/Host.pm +++ b/ncm-opennebula/src/main/perl/OpenNebula/Host.pm @@ -91,7 +91,6 @@ sub manage_hosts $new = $self->update_something($one, "host", $host, "QUATTOR = 1"); if (defined($hosts->{$host}->{pin_policy})) { $new = $self->update_something($one, "host", $host, "PIN_POLICY = $hosts->{$host}->{pin_policy}"); - $self->verbose("HELLO pin defined: ", $hosts->{$host}->{pin_policy}); }; if (defined($new) and defined($hosts->{$host}->{cluster})) { $self->verbose("Host $host cluster is set to: ", $hosts->{$host}->{cluster}); diff --git a/ncm-opennebula/src/main/perl/opennebula.pm b/ncm-opennebula/src/main/perl/opennebula.pm index 9679983652..d4cbf7d510 100755 --- a/ncm-opennebula/src/main/perl/opennebula.pm +++ b/ncm-opennebula/src/main/perl/opennebula.pm @@ -86,20 +86,17 @@ To set up the initial cluster, some steps should be taken: =over -=item 1. First install the required Ruby gems in your OpenNebula server (only for OpenNebula 5.10 or older). -You can use OpenNebula installgems addon : L. - -=item 2. The OpenNebula server(s) should have passwordless ssh access as oneadmin user to all the host hosts of the cluster. +=item 1. The OpenNebula server(s) should have passwordless ssh access as oneadmin user to all the host hosts of the cluster. e.g. by distributing the public key(s) of the OpenNebula host over the cluster. -=item 3. Start OpenNebula services: C<< # for i in '' -econe -gate -novnc -occi -sunstone; do service opennebula$i stop; done >> +=item 2. Start OpenNebula services: C<< # for i in '' -econe -gate -novnc -occi -sunstone; do service opennebula$i stop; done >> -=item 4. Run the component a first time. +=item 3. Run the component a first time. -=item 5. The new oneadmin password will be available from C<< /var/lib/one/.one/one_auth >> file. +=item 4. The new oneadmin password will be available from C<< /var/lib/one/.one/one_auth >> file. The old auth files are stored with .quattor.backup extension. -=item 6. It is also possible to change sunstone service password, just include +=item 5. It is also possible to change sunstone service password, just include 'serveradmin' user and passwd within opennebula/users tree. In that case the component also updates the C<< sunstone_auth >> file. diff --git a/ncm-opennebula/src/test/perl/aii_vmtemplate.t b/ncm-opennebula/src/test/perl/aii_vmtemplate.t index af5f08e160..345e1c9e4e 100644 --- a/ncm-opennebula/src/test/perl/aii_vmtemplate.t +++ b/ncm-opennebula/src/test/perl/aii_vmtemplate.t @@ -20,7 +20,7 @@ $opennebulaaii->mock('read_one_aii_conf', Net::OpenNebula->new(url => "http://l user => "oneadmin",)); my $aii = NCM::Component::opennebula->new(); -my $oneversion = version->new("5.0.0"); +my $oneversion = version->new("6.0.0"); my $ttout = $aii->process_template_aii($cfg, "vmtemplate", $oneversion);