From jboggs at redhat.com Thu Apr 1 02:20:19 2010 From: jboggs at redhat.com (Joey Boggs) Date: Wed, 31 Mar 2010 22:20:19 -0400 Subject: [Ovirt-devel] [PATCH node 1/3] Enables ability to have a common shared root Message-ID: <1270088421-19909-1-git-send-email-jboggs@redhat.com> --- scripts/ovirt-config-boot | 13 +++++++- scripts/ovirt-config-storage | 73 +++++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 30 deletions(-) diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot index d545878..8cc127b 100755 --- a/scripts/ovirt-config-boot +++ b/scripts/ovirt-config-boot @@ -29,6 +29,12 @@ ovirt_boot_setup() { local disk2 local partN=-1 log "installing the image." + + if [ "$OVIRT_ROOT_INSTALL" == "n" ]; then + log "done." + return + fi + local found_boot=false if findfs LABEL=Boot 2>&1 >/dev/null ; then found_boot=true @@ -212,7 +218,12 @@ if [ -z "$doreboot" ]; then fi start_log -ovirt_boot_setup "$live" "$bootparams" +if [ "$OVIRT_ROOT_INSTALL" =="n" ]; then + log "done." + return +else + ovirt_boot_setup "$live" "$bootparams" +fi rc=$? if [ $rc -eq 0 -a "$doreboot" = "yes" ]; then disable_firstboot diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index 8d59a6b..aec3447 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -357,6 +357,22 @@ do_configure() printf "\n\nPlease select the disk to use for the Root.\n\n" ROOTDRIVE=$(get_dev_name) || return 0 get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE + if ask_yes_or_no "Will Root be shared with other nodes ([Y]es/[N]o)?"; then + OVIRT_SHARED_ROOT="y" + if ask_yes_or_no "Partition and install Root?"; then + OVIRT_ROOT_INSTALL="y" + else + OVIRT_ROOT_INSTALL="n" + fi + else + OVIRT_SHARED_ROOT="n" + OVIRT_ROOT_INSTALL="y" + fi + + augtool < References: <1270088421-19909-1-git-send-email-jboggs@redhat.com> Message-ID: <1270088421-19909-2-git-send-email-jboggs@redhat.com> A previous patch removed the manual initrd rebuild as dracut now builds it correctly. With that being removed the initrd0.img file was not being copied over to the system preventing boot --- scripts/ovirt-config-boot | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot index 8cc127b..5f2450e 100755 --- a/scripts/ovirt-config-boot +++ b/scripts/ovirt-config-boot @@ -132,6 +132,7 @@ ovirt_boot_setup() { mkdir -p $grub_dir cp -p $live/$syslinux/vmlinuz0 $initrd_dest + cp -p $live/$syslinux/initrd0.img $initrd_dest rc=$? if [ $rc -ne 0 ]; then log "kernel image copy failed." -- 1.6.6.1 From jboggs at redhat.com Thu Apr 1 02:20:21 2010 From: jboggs at redhat.com (Joey Boggs) Date: Wed, 31 Mar 2010 22:20:21 -0400 Subject: [Ovirt-devel] [PATCH node 3/3] correct reboot function in ovirt-functions. Machines installed w/o ovirt_iscsi_enabled="y" would not have the "ROOT" partition file system renamed on install/reboot In-Reply-To: <1270088421-19909-2-git-send-email-jboggs@redhat.com> References: <1270088421-19909-1-git-send-email-jboggs@redhat.com> <1270088421-19909-2-git-send-email-jboggs@redhat.com> Message-ID: <1270088421-19909-3-git-send-email-jboggs@redhat.com> --- scripts/ovirt-functions | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index d8aa008..e79fcd8 100644 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -716,7 +716,7 @@ lvremove() { # cleanup before reboot reboot() { cd / - if [ "$OVIRT_ISCSI_ENABLED" = "yes" ]; then + if [ "$OVIRT_ISCSI_ENABLED" != "y" ]; then # setup new Root if update is prepared if findfs LABEL=RootUpdate 2>&1 >/dev/null; then root_update_dev=$(findfs LABEL=RootUpdate 2>/dev/null) -- 1.6.6.1 From mburns at redhat.com Thu Apr 1 02:51:33 2010 From: mburns at redhat.com (Mike Burns) Date: Wed, 31 Mar 2010 22:51:33 -0400 Subject: [Ovirt-devel] [PATCH node 3/3] correct reboot function in ovirt-functions. Machines installed w/o ovirt_iscsi_enabled="y" would not have the "ROOT" partition file system renamed on install/reboot In-Reply-To: <1270088421-19909-3-git-send-email-jboggs@redhat.com> References: <1270088421-19909-1-git-send-email-jboggs@redhat.com> <1270088421-19909-2-git-send-email-jboggs@redhat.com> <1270088421-19909-3-git-send-email-jboggs@redhat.com> Message-ID: <1270090293.3291.1089.camel@localhost.localdomain> On Wed, 2010-03-31 at 22:20 -0400, Joey Boggs wrote: > --- > scripts/ovirt-functions | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions > index d8aa008..e79fcd8 100644 > --- a/scripts/ovirt-functions > +++ b/scripts/ovirt-functions > @@ -716,7 +716,7 @@ lvremove() { > # cleanup before reboot > reboot() { > cd / > - if [ "$OVIRT_ISCSI_ENABLED" = "yes" ]; then > + if [ "$OVIRT_ISCSI_ENABLED" != "y" ]; then > # setup new Root if update is prepared > if findfs LABEL=RootUpdate 2>&1 >/dev/null; then > root_update_dev=$(findfs LABEL=RootUpdate 2>/dev/null) ACK - thought this was fixed already From mburns at redhat.com Thu Apr 1 02:58:50 2010 From: mburns at redhat.com (Mike Burns) Date: Wed, 31 Mar 2010 22:58:50 -0400 Subject: [Ovirt-devel] [PATCH node 1/3] Enables ability to have a common shared root In-Reply-To: <1270088421-19909-1-git-send-email-jboggs@redhat.com> References: <1270088421-19909-1-git-send-email-jboggs@redhat.com> Message-ID: <1270090730.3291.1097.camel@localhost.localdomain> On Wed, 2010-03-31 at 22:20 -0400, Joey Boggs wrote: > --- > scripts/ovirt-config-boot | 13 +++++++- > scripts/ovirt-config-storage | 73 +++++++++++++++++++++++++---------------- > 2 files changed, 56 insertions(+), 30 deletions(-) > > diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot > index d545878..8cc127b 100755 > --- a/scripts/ovirt-config-boot > +++ b/scripts/ovirt-config-boot > @@ -29,6 +29,12 @@ ovirt_boot_setup() { > local disk2 > local partN=-1 > log "installing the image." > + > + if [ "$OVIRT_ROOT_INSTALL" == "n" ]; then > + log "done." > + return > + fi > + > local found_boot=false > if findfs LABEL=Boot 2>&1 >/dev/null ; then > found_boot=true > @@ -212,7 +218,12 @@ if [ -z "$doreboot" ]; then > fi > > start_log > -ovirt_boot_setup "$live" "$bootparams" > +if [ "$OVIRT_ROOT_INSTALL" =="n" ]; then > + log "done." > + return > +else > + ovirt_boot_setup "$live" "$bootparams" > +fi > rc=$? > if [ $rc -eq 0 -a "$doreboot" = "yes" ]; then > disable_firstboot > diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage > index 8d59a6b..aec3447 100755 > --- a/scripts/ovirt-config-storage > +++ b/scripts/ovirt-config-storage > @@ -357,6 +357,22 @@ do_configure() > printf "\n\nPlease select the disk to use for the Root.\n\n" > ROOTDRIVE=$(get_dev_name) || return 0 > get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE > + if ask_yes_or_no "Will Root be shared with other nodes ([Y]es/[N]o)?"; then > + OVIRT_SHARED_ROOT="y" > + if ask_yes_or_no "Partition and install Root?"; then > + OVIRT_ROOT_INSTALL="y" > + else > + OVIRT_ROOT_INSTALL="n" > + fi > + else > + OVIRT_SHARED_ROOT="n" > + OVIRT_ROOT_INSTALL="y" > + fi > + > + augtool < + set /files$OVIRT_DEFAULTS/OVIRT_SHARED_ROOT $OVIRT_SHARED_ROOT > + set /files$OVIRT_DEFAULTS/OVIRT_ROOT_INSTALL $OVIRT_ROOT_INSTALL > +EOF > > printf "\n\nPlease select the disk to use for the HostVG.\n\n" > HOSTVGDRIVE=$(get_dev_name) || return 0 > @@ -402,6 +418,8 @@ do_configure() > if [ "$OVIRT_ISCSI_ENABLED" == "y" ]; then > partlist="boot" # swap root config logging data" > local space_left=$BOOTDRIVESPACE > + elif [ "$OVIRT_ROOT_INSTALL" == "n" ]; then > + partlist="swap config logging data" > else > partlist="swap root config logging data" > fi > @@ -635,37 +653,32 @@ perform_partitioning() > return > fi > > - log "Starting partitioning of $ROOTDRIVE" > - log "Partitioning drive: $ROOTDRIVE" > - # FIXME: save a backup copy, just in case? > - log "Wiping old boot sector" > - dd if=/dev/zero of=$ROOTDRIVE bs=1024K count=1 > - reread_partitions $ROOTDRIVE > - partprobe -s $ROOTDRIVE > - log "Labeling Drive: $ROOTDRIVE" > - parted $ROOTDRIVE -s "mklabel ${LABEL_TYPE}" > + if [ "$OVIRT_ROOT_INSTALL" == "y" ]; then > + log "Starting partitioning of $ROOTDRIVE" > + log "Partitioning drive: $ROOTDRIVE" > + # FIXME: save a backup copy, just in case? > + log "Wiping old boot sector" > + dd if=/dev/zero of=$ROOTDRIVE bs=1024K count=1 > + blockdev --rereadpt $ROOTDRIVE ^^ This should be a call to reread_partitions > + partprobe -s $ROOTDRIVE > + log "Labeling Drive: $ROOTDRIVE" > + parted $ROOTDRIVE -s "mklabel ${LABEL_TYPE}" > + log "Creating Root and RootBackup Partitions" > + let RootBackup_end=${ROOT_SIZE}*2 > + parted $ROOTDRIVE -s "mkpart primary ext2 0M ${ROOT_SIZE}M" > + parted $ROOTDRIVE -s "mkpart primary ext2 ${ROOT_SIZE}M ${RootBackup_end}M" > + # sleep to ensure filesystems are created before continuing > + sleep 10 > + mke2fs ${ROOTDRIVE}1 -L Root > + mke2fs ${ROOTDRIVE}2 -L RootBackup > + tune2fs -c 0 -i 0 ${ROOTDRIVE}1 > + tune2fs -c 0 -i 0 ${ROOTDRIVE}2 I think we need to check whether the partitions are ${ROOTDRIVE}1 or ${ROOTDRIVE}p1 here. See code around partroot and partrootbackup below > + fi > > if [ $ROOTDRIVE != $HOSTVGDRIVE ]; then > log "Labeling Drive: $HOSTVGDRIVE" > parted $HOSTVGDRIVE -s "mklabel ${LABEL_TYPE}" > fi > - log "Creating Root and RootBackup Partitions" > - let RootBackup_end=${ROOT_SIZE}*2 > - parted $ROOTDRIVE -s "mkpart primary ext2 0M ${ROOT_SIZE}M" > - parted $ROOTDRIVE -s "mkpart primary ext2 ${ROOT_SIZE}M ${RootBackup_end}M" > - reread_partitions $ROOTDRIVE > - partroot=${ROOTDRIVE}1 > - partrootbackup=${ROOTDRIVE}2 > - if [ ! -e $partroot ]; then > - partroot=${ROOTDRIVE}p1 > - partrootbackup=${ROOTDRIVE}p2 > - fi > - # sleep to ensure filesystems are created before continuing > - sleep 10 > - mke2fs ${partroot} -L Root > - mke2fs ${partrootbackup} -L RootBackup > - tune2fs -c 0 -i 0 ${partroot} > - tune2fs -c 0 -i 0 ${partrootbackup} > log "Creating LVM partition" > > if [ $ROOTDRIVE == $HOSTVGDRIVE ]; then > @@ -682,9 +695,11 @@ perform_partitioning() > reread_partitions $HOSTVGDRIVE > > # sync GPT to the legacy MBR partitions > - if [ "gpt" == "$LABEL_TYPE" ]; then > - log "Running gptsync to create legacy mbr" > - gptsync $ROOTDRIVE > + if [ "$OVIRT_ROOT_INSTALL" == "y" ]; then > + if [ "gpt" == "$LABEL_TYPE" ]; then > + log "Running gptsync to create legacy mbr" > + gptsync $ROOTDRIVE > + fi > fi > > partpv=${HOSTVGDRIVE}${hostvgpart} This doesn't apply to current next. Also, we need to ensure that we quote all variables that contain the path to a drive like HOSTVGDRIVE and ROOTDRIVE. This is because some older disks and disks on vm result in wwids that contain spaces. Some/Many of these might be fixed by the rebase since most of those were fixed in the latest patch on next. Mike From mburns at redhat.com Thu Apr 1 03:11:24 2010 From: mburns at redhat.com (Mike Burns) Date: Wed, 31 Mar 2010 23:11:24 -0400 Subject: [Ovirt-devel] [PATCH node 3/3] correct reboot function in ovirt-functions. Machines installed w/o ovirt_iscsi_enabled="y" would not have the "ROOT" partition file system renamed on install/reboot In-Reply-To: <1270090293.3291.1089.camel@localhost.localdomain> References: <1270088421-19909-1-git-send-email-jboggs@redhat.com> <1270088421-19909-2-git-send-email-jboggs@redhat.com> <1270088421-19909-3-git-send-email-jboggs@redhat.com> <1270090293.3291.1089.camel@localhost.localdomain> Message-ID: <1270091484.3291.1098.camel@localhost.localdomain> On Wed, 2010-03-31 at 22:51 -0400, Mike Burns wrote: > On Wed, 2010-03-31 at 22:20 -0400, Joey Boggs wrote: > > --- > > scripts/ovirt-functions | 2 +- > > 1 files changed, 1 insertions(+), 1 deletions(-) > > > > diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions > > index d8aa008..e79fcd8 100644 > > --- a/scripts/ovirt-functions > > +++ b/scripts/ovirt-functions > > @@ -716,7 +716,7 @@ lvremove() { > > # cleanup before reboot > > reboot() { > > cd / > > - if [ "$OVIRT_ISCSI_ENABLED" = "yes" ]; then > > + if [ "$OVIRT_ISCSI_ENABLED" != "y" ]; then > > # setup new Root if update is prepared > > if findfs LABEL=RootUpdate 2>&1 >/dev/null; then > > root_update_dev=$(findfs LABEL=RootUpdate 2>/dev/null) > > > ACK - thought this was fixed already > Well...needs to be rebased, but still ACK. Missing "" on last line root_update_dev="$(findfs LABEL=RootUpdate 2>/dev/null)" > _______________________________________________ > Ovirt-devel mailing list > Ovirt-devel at redhat.com > https://www.redhat.com/mailman/listinfo/ovirt-devel From mloiseleur at linagora.com Thu Apr 1 08:21:18 2010 From: mloiseleur at linagora.com (Michel Loiseleur) Date: Thu, 01 Apr 2010 10:21:18 +0200 Subject: [Ovirt-devel] [PATCH] Enhance vms display In-Reply-To: <1267100939-8689-1-git-send-email-mloiseleur@linagora.com> References: <1267100939-8689-1-git-send-email-mloiseleur@linagora.com> Message-ID: <4BB4577E.4020907@linagora.com> Hi, Any comments on this one ? Regards, Le 25/02/2010 13:28, Loiseleur Michel a ?crit : > It can be quite hard to manage a pool of 40-50 VMs without informations about the OS running, the contact (which is the only one to know when the vm can really be destroyed) or an End Of Life date. This patch add those fields, and rework a little the VM list view, in order to show gracefully those new fields. It has been made at the expense of UUID, Total Run Time& Load fields. Since those fields are often better displayed from a monitoring software, I have though it was acceptable. > > Signed-off-by: Loiseleur Michel > --- > src/app/controllers/pool_controller.rb | 6 ++-- > src/app/views/vm/_form.rhtml | 10 ++++++-- > src/app/views/vm/_grid.rhtml | 9 ++++--- > src/db/migrate/044_add_vm_fields.rb | 34 ++++++++++++++++++++++++++++++++ > 4 files changed, 49 insertions(+), 10 deletions(-) > create mode 100644 src/db/migrate/044_add_vm_fields.rb > > diff --git a/src/app/controllers/pool_controller.rb b/src/app/controllers/pool_controller.rb > index e86b064..e6c341d 100644 > --- a/src/app/controllers/pool_controller.rb > +++ b/src/app/controllers/pool_controller.rb > @@ -94,11 +94,11 @@ class PoolController< ApplicationController > end > > def vms_json(args) > - attr_list = [:id, :description, :uuid, > + attr_list = [:id, :description, > :num_vcpus_allocated, :memory_allocated_in_mb, > - :state, :calc_uptime, :id] > + :state, :contact, :os, :eol, :comment ] > if (@pool.is_a? VmResourcePool) and @pool.get_hardware_pool.can_view(@user) > - attr_list.insert(3, [:host, :hostname]) > + attr_list.insert(2, [:host, :hostname]) > end > json_list(args[:full_items], attr_list, [:all], args[:find_opts]) > end > diff --git a/src/app/views/vm/_form.rhtml b/src/app/views/vm/_form.rhtml > index adb75d2..13e73db 100644 > --- a/src/app/views/vm/_form.rhtml > +++ b/src/app/views/vm/_form.rhtml > @@ -8,10 +8,14 @@ > >
General
>
> -<%= text_field_with_label "Name:", "vm", "description", {:style=>"width:250px;"} %> > -<%= text_field_with_label "UUID:", "vm", "uuid", {:style=>"width:250px;"} %> > -<%= select_with_label "Operating System:", 'vm', 'provisioning_and_boot_settings', @provisioning_options, :style=>"width:250px;" %> > +<%= text_field_with_label "Name:", "vm", "description" %> > +<%= text_field_with_label "UUID:", "vm", "uuid" %> > +<%= select_with_label "Provisioning:", 'vm', 'provisioning_and_boot_settings', @provisioning_options %> > <% if controller.action_name == "edit" %>*Warning* Editing provision could overwrite vm<% end %> > +<%= text_field_with_label "Contact:", "vm", "contact" %> > +<%= text_field_with_label "Operating System:", "vm", "os" %> > +<%= text_field_with_label "End Of Life:", "vm", "eol" %> > +<%= text_field_with_label "Comment:", "vm", "comment" %> > >
>
> diff --git a/src/app/views/vm/_grid.rhtml b/src/app/views/vm/_grid.rhtml > index e3fa0e0..fe821e1 100644 > --- a/src/app/views/vm/_grid.rhtml > +++ b/src/app/views/vm/_grid.rhtml > @@ -27,16 +27,17 @@ > <% end %> > colModel : [ > {display: '', name : 'id', width : 20, sortable : false, align: 'left', process:<%= table_id %>checkbox}, > - {display: 'Description', name : 'description', width : 180, sortable : true, align: 'left'}, > - {display: 'UUID', name : 'uuid', width : 180, sortable : true, align: 'left'}, > + {display: 'Name', name : 'description', width : 180, sortable : true, align: 'left'}, > <% if (pool.is_a? VmResourcePool) and pool.get_hardware_pool.can_view(@user) %> > {display: 'Host', name : 'host', width: 180, sortable : true, align: 'left' }, > <% end %> > {display: 'CPUs', name : 'num_vcpus_allocated', width : 40, sortable : true, align: 'left'}, > {display: 'Memory (MB)', name : 'memory_allocated', width : 60, sortable : true, align: 'right'}, > {display: 'State', name : 'state', width : 50, sortable : true, align: 'right'}, > - {display: 'Total Run Time', name : 'calc_uptime', width : 50, align: 'right'}, > - {display: 'Load', name : 'load', width: 180, sortable : false, align: 'left', process:<%= table_id %>_load_widget } > + {display: 'Contact', name : 'contact', width : 100, align: 'left'}, > + {display: 'OS', name : 'os', width : 60, sortable : true, align: 'left'}, > + {display: 'EOL', name : 'eol', width : 60, sortable : true, align: 'right'}, > + {display: 'Comment', name : 'comment', width : 100, sortable : true, align: 'right'} > ], > sortname: "description", > sortorder: "asc", > diff --git a/src/db/migrate/044_add_vm_fields.rb b/src/db/migrate/044_add_vm_fields.rb > new file mode 100644 > index 0000000..834f0ec > --- /dev/null > +++ b/src/db/migrate/044_add_vm_fields.rb > @@ -0,0 +1,34 @@ > +# Copyright (C) 2010 Linagora. > +# Written by Michel Loiseleur > +# > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; version 2 of the License. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program; if not, write to the Free Software > +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, > +# MA 02110-1301, USA. A copy of the GNU General Public License is > +# also available at http://www.gnu.org/copyleft/gpl.html. > + > +# introduce information fields for VMs > +class AddVmFields< ActiveRecord::Migration > + def self.up > + add_column :vms, :contact, :string, :null => false, :default => '' > + add_column :vms, :comment, :string, :null => false, :default => '' > + add_column :vms, :eol, :date, :null => false, :default => Date.new(1970,01,01).to_s > + add_column :vms, :os, :string, :null => false, :default => '' > + end > + > + def self.down > + remove_column :vms, :contact > + remove_column :vms, :comment > + remove_column :vms, :eol > + remove_column :vms, :os > + end > +end > -- Loiseleur Michel Directeur de l'OSSA Linagora / 80, rue Roque de Fillol / 92800 PUTEAUX Tel/Fax : +33 1 46 96 63 63 / +33 1 46 96 63 64 http://www.08000linux.com/ | http://www.tosca-project.net "Ce n'est pas le logiciel qui est libre, c'est vous" From jboggs at redhat.com Mon Apr 5 16:15:57 2010 From: jboggs at redhat.com (Joey Boggs) Date: Mon, 5 Apr 2010 12:15:57 -0400 Subject: [Ovirt-devel] RESEND: [PATCH node 1/3] enables ability for a common shared root Message-ID: <1270484157-5624-1-git-send-email-jboggs@redhat.com> --- scripts/ovirt-config-boot | 13 +++++- scripts/ovirt-config-storage | 111 ++++++++++++++++++++++++------------------ 2 files changed, 75 insertions(+), 49 deletions(-) diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot index d545878..8cc127b 100755 --- a/scripts/ovirt-config-boot +++ b/scripts/ovirt-config-boot @@ -29,6 +29,12 @@ ovirt_boot_setup() { local disk2 local partN=-1 log "installing the image." + + if [ "$OVIRT_ROOT_INSTALL" == "n" ]; then + log "done." + return + fi + local found_boot=false if findfs LABEL=Boot 2>&1 >/dev/null ; then found_boot=true @@ -212,7 +218,12 @@ if [ -z "$doreboot" ]; then fi start_log -ovirt_boot_setup "$live" "$bootparams" +if [ "$OVIRT_ROOT_INSTALL" =="n" ]; then + log "done." + return +else + ovirt_boot_setup "$live" "$bootparams" +fi rc=$? if [ $rc -eq 0 -a "$doreboot" = "yes" ]; then disable_firstboot diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index 8d59a6b..c91b0ea 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -172,7 +172,7 @@ check_partition_sizes() HOSTVG_NEED_SIZE=$(echo "scale=0;" \ "$SWAP_SIZE + $CONFIG_SIZE + $LOGGING_SIZE + $min_data_size" | bc -l) - if [ $ROOTDRIVE == $HOSTVGDRIVE ]; then + if [ "$ROOTDRIVE" == "$HOSTVGDRIVE" ]; then drive_list="ROOT" ROOT_NEED_SIZE=$(echo "scale=0; $ROOT_SIZE * 2 + $HOSTVG_NEED_SIZE"| bc -l) else @@ -204,7 +204,7 @@ check_partition_sizes() # check if an existing HostVG exists on a device other than the target if [ "$OVIRT_ISCSI_ENABLED" != "y" ]; then devices="$(pvs -o pv_name,vg_name --noheadings | \ - grep "HostVG"|grep -v $HOSTVGDRIVE|awk '{ print $1 }')" + grep "HostVG"|grep -v "$HOSTVGDRIVE"|awk '{ print $1 }')" rc=0 if [ -n "$devices" ]; then printf "\n" @@ -357,11 +357,27 @@ do_configure() printf "\n\nPlease select the disk to use for the Root.\n\n" ROOTDRIVE=$(get_dev_name) || return 0 get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE + if ask_yes_or_no "Will Root be shared with other nodes ([Y]es/[N]o)?"; then + OVIRT_SHARED_ROOT="y" + if ask_yes_or_no "Partition and install Root?"; then + OVIRT_ROOT_INSTALL="y" + else + OVIRT_ROOT_INSTALL="n" + fi + else + OVIRT_SHARED_ROOT="n" + OVIRT_ROOT_INSTALL="y" + fi + + augtool < /dev/null || udevsettle - reread_partitions $HOSTVGDRIVE + reread_partitions "$HOSTVGDRIVE" # sync GPT to the legacy MBR partitions - if [ "gpt" == "$LABEL_TYPE" ]; then - log "Running gptsync to create legacy mbr" - gptsync $ROOTDRIVE + if [ "$OVIRT_ROOT_INSTALL" == "y" ]; then + if [ "gpt" == "$LABEL_TYPE" ]; then + log "Running gptsync to create legacy mbr" + gptsync "$ROOTDRIVE" + fi fi - partpv=${HOSTVGDRIVE}${hostvgpart} + partpv="${HOSTVGDRIVE}"${hostvgpart} if [ ! -e "$partpv" ]; then # e.g. /dev/cciss/c0d0p2 - partpv=${HOSTVGDRIVE}p${hostvgpart} + partpv="${HOSTVGDRIVE}"p${hostvgpart} fi log "Creating physical volume" if [ ! -e "$partpv" ]; then -- 1.6.6.1 From jboggs at redhat.com Mon Apr 5 19:52:01 2010 From: jboggs at redhat.com (Joey Boggs) Date: Mon, 05 Apr 2010 15:52:01 -0400 Subject: [Ovirt-devel] [PATCH node 3/3] correct reboot function in ovirt-functions. Machines installed w/o ovirt_iscsi_enabled="y" would not have the "ROOT" partition file system renamed on install/reboot In-Reply-To: <1270091484.3291.1098.camel@localhost.localdomain> References: <1270088421-19909-1-git-send-email-jboggs@redhat.com> <1270088421-19909-2-git-send-email-jboggs@redhat.com> <1270088421-19909-3-git-send-email-jboggs@redhat.com> <1270090293.3291.1089.camel@localhost.localdomain> <1270091484.3291.1098.camel@localhost.localdomain> Message-ID: <4BBA3F61.7060106@redhat.com> On 03/31/2010 11:11 PM, Mike Burns wrote: > On Wed, 2010-03-31 at 22:51 -0400, Mike Burns wrote: > >> On Wed, 2010-03-31 at 22:20 -0400, Joey Boggs wrote: >> >>> --- >>> scripts/ovirt-functions | 2 +- >>> 1 files changed, 1 insertions(+), 1 deletions(-) >>> >>> diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions >>> index d8aa008..e79fcd8 100644 >>> --- a/scripts/ovirt-functions >>> +++ b/scripts/ovirt-functions >>> @@ -716,7 +716,7 @@ lvremove() { >>> # cleanup before reboot >>> reboot() { >>> cd / >>> - if [ "$OVIRT_ISCSI_ENABLED" = "yes" ]; then >>> + if [ "$OVIRT_ISCSI_ENABLED" != "y" ]; then >>> # setup new Root if update is prepared >>> if findfs LABEL=RootUpdate 2>&1>/dev/null; then >>> root_update_dev=$(findfs LABEL=RootUpdate 2>/dev/null) >>> >> >> ACK - thought this was fixed already >> >> > Well...needs to be rebased, but still ACK. Missing "" on last line > > root_update_dev="$(findfs LABEL=RootUpdate 2>/dev/null)" > > >> _______________________________________________ >> Ovirt-devel mailing list >> Ovirt-devel at redhat.com >> https://www.redhat.com/mailman/listinfo/ovirt-devel >> > > pushed From jboggs at redhat.com Mon Apr 5 20:22:31 2010 From: jboggs at redhat.com (Joey Boggs) Date: Mon, 05 Apr 2010 16:22:31 -0400 Subject: [Ovirt-devel] [PATCH node 2/3] copy initrd0.img to root partition In-Reply-To: <1270088421-19909-2-git-send-email-jboggs@redhat.com> References: <1270088421-19909-1-git-send-email-jboggs@redhat.com> <1270088421-19909-2-git-send-email-jboggs@redhat.com> Message-ID: <4BBA4687.2000307@redhat.com> On 03/31/2010 10:20 PM, Joey Boggs wrote: > A previous patch removed the manual initrd rebuild as dracut now builds it correctly. With that being removed the initrd0.img file was not being copied over to the system preventing boot > --- > scripts/ovirt-config-boot | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot > index 8cc127b..5f2450e 100755 > --- a/scripts/ovirt-config-boot > +++ b/scripts/ovirt-config-boot > @@ -132,6 +132,7 @@ ovirt_boot_setup() { > mkdir -p $grub_dir > > cp -p $live/$syslinux/vmlinuz0 $initrd_dest > + cp -p $live/$syslinux/initrd0.img $initrd_dest > rc=$? > if [ $rc -ne 0 ]; then > log "kernel image copy failed." > pushed, was blocking successful install From dpierce at redhat.com Mon Apr 5 20:25:15 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Mon, 5 Apr 2010 16:25:15 -0400 Subject: [Ovirt-devel] [PATCH] Upgrading the server to work with Rails 2.3.4. In-Reply-To: <1270064445-16147-1-git-send-email-dpierce@redhat.com> References: <1270064445-16147-1-git-send-email-dpierce@redhat.com> Message-ID: <20100405202515.GC5858@mcpierce-desktop.usersys.redhat.com> On Wed, Mar 31, 2010 at 03:40:45PM -0400, Darryl L. Pierce wrote: > > Signed-off-by: Darryl L. Pierce > --- > src/app/controllers/application_controller.rb | 2 +- > src/config/environment.rb | 2 +- > src/config/initializers/new_rails_defaults.rb | 6 +++++- > 3 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/src/app/controllers/application_controller.rb b/src/app/controllers/application_controller.rb > index 7e2041f..4c4666e 100644 > --- a/src/app/controllers/application_controller.rb > +++ b/src/app/controllers/application_controller.rb > @@ -25,7 +25,7 @@ class ApplicationController < ActionController::Base > # FIXME: once all controller classes include this, remove here > include ApplicationService > > - init_gettext "ovirt" > +# init_gettext "ovirt" > layout :choose_layout > > before_filter :is_logged_in, :get_help_section > diff --git a/src/config/environment.rb b/src/config/environment.rb > index 913b9f9..9c1a9fa 100644 > --- a/src/config/environment.rb > +++ b/src/config/environment.rb > @@ -20,7 +20,7 @@ > # Be sure to restart your web server when you modify this file. > > # Specifies gem version of Rails to use when vendor/rails is not present > -RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION > +RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION > > # Bootstrap the Rails environment, frameworks, and default configuration > require File.join(File.dirname(__FILE__), 'boot') > diff --git a/src/config/initializers/new_rails_defaults.rb b/src/config/initializers/new_rails_defaults.rb > index 8ec3186..acfb93e 100644 > --- a/src/config/initializers/new_rails_defaults.rb > +++ b/src/config/initializers/new_rails_defaults.rb > @@ -16,4 +16,8 @@ ActiveSupport.use_standard_json_time_format = true > > # Don't escape HTML entities in JSON, leave that for the #json_escape helper. > # if you're including raw json in an HTML page. > -ActiveSupport.escape_html_entities_in_json = false > \ No newline at end of file > +ActiveSupport.escape_html_entities_in_json = false > + > +def PGconn.quote_ident(name) > + %("#{name}") > +end > -- > 1.6.6.1 > If nobody has any objections, I'll push this patch tomorrow. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From dpierce at redhat.com Tue Apr 6 18:16:08 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Tue, 6 Apr 2010 14:16:08 -0400 Subject: [Ovirt-devel] [PATCH] Upgrading the server to work with Rails 2.3.4. In-Reply-To: <20100405202515.GC5858@mcpierce-desktop.usersys.redhat.com> References: <20100405202515.GC5858@mcpierce-desktop.usersys.redhat.com> Message-ID: <20100406181608.GI5858@mcpierce-desktop.usersys.redhat.com> On Mon, Apr 05, 2010 at 04:25:15PM -0400, Darryl L. Pierce wrote: I've pushed this and am building an updated RPM now. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From mburns at redhat.com Wed Apr 7 14:15:07 2010 From: mburns at redhat.com (Mike Burns) Date: Wed, 07 Apr 2010 10:15:07 -0400 Subject: [Ovirt-devel] RESEND: [PATCH node 1/3] enables ability for a common shared root In-Reply-To: <1270484157-5624-1-git-send-email-jboggs@redhat.com> References: <1270484157-5624-1-git-send-email-jboggs@redhat.com> Message-ID: <1270649707.2257.6.camel@mburns-laptop.bos.redhat.com> On Mon, 2010-04-05 at 12:15 -0400, Joey Boggs wrote: > --- > scripts/ovirt-config-boot | 13 +++++- > scripts/ovirt-config-storage | 111 ++++++++++++++++++++++++------------------ > 2 files changed, 75 insertions(+), 49 deletions(-) > > diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot > index d545878..8cc127b 100755 > --- a/scripts/ovirt-config-boot > +++ b/scripts/ovirt-config-boot > @@ -29,6 +29,12 @@ ovirt_boot_setup() { > local disk2 > local partN=-1 > log "installing the image." > + > + if [ "$OVIRT_ROOT_INSTALL" == "n" ]; then > + log "done." > + return > + fi > + > local found_boot=false > if findfs LABEL=Boot 2>&1 >/dev/null ; then > found_boot=true > @@ -212,7 +218,12 @@ if [ -z "$doreboot" ]; then > fi > > start_log > -ovirt_boot_setup "$live" "$bootparams" > +if [ "$OVIRT_ROOT_INSTALL" =="n" ]; then > + log "done." > + return > +else > + ovirt_boot_setup "$live" "$bootparams" > +fi > rc=$? > if [ $rc -eq 0 -a "$doreboot" = "yes" ]; then > disable_firstboot > diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage > index 8d59a6b..c91b0ea 100755 > --- a/scripts/ovirt-config-storage > +++ b/scripts/ovirt-config-storage > @@ -172,7 +172,7 @@ check_partition_sizes() > HOSTVG_NEED_SIZE=$(echo "scale=0;" \ > "$SWAP_SIZE + $CONFIG_SIZE + $LOGGING_SIZE + $min_data_size" | bc -l) > > - if [ $ROOTDRIVE == $HOSTVGDRIVE ]; then > + if [ "$ROOTDRIVE" == "$HOSTVGDRIVE" ]; then > drive_list="ROOT" > ROOT_NEED_SIZE=$(echo "scale=0; $ROOT_SIZE * 2 + $HOSTVG_NEED_SIZE"| bc -l) > else > @@ -204,7 +204,7 @@ check_partition_sizes() > # check if an existing HostVG exists on a device other than the target > if [ "$OVIRT_ISCSI_ENABLED" != "y" ]; then > devices="$(pvs -o pv_name,vg_name --noheadings | \ > - grep "HostVG"|grep -v $HOSTVGDRIVE|awk '{ print $1 }')" > + grep "HostVG"|grep -v "$HOSTVGDRIVE"|awk '{ print $1 }')" > rc=0 > if [ -n "$devices" ]; then > printf "\n" > @@ -357,11 +357,27 @@ do_configure() > printf "\n\nPlease select the disk to use for the Root.\n\n" > ROOTDRIVE=$(get_dev_name) || return 0 > get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE > + if ask_yes_or_no "Will Root be shared with other nodes ([Y]es/[N]o)?"; then > + OVIRT_SHARED_ROOT="y" > + if ask_yes_or_no "Partition and install Root?"; then > + OVIRT_ROOT_INSTALL="y" > + else > + OVIRT_ROOT_INSTALL="n" > + fi > + else > + OVIRT_SHARED_ROOT="n" > + OVIRT_ROOT_INSTALL="y" > + fi > + > + augtool < + set /files$OVIRT_DEFAULTS/OVIRT_SHARED_ROOT $OVIRT_SHARED_ROOT > + set /files$OVIRT_DEFAULTS/OVIRT_ROOT_INSTALL $OVIRT_ROOT_INSTALL > +EOF > > printf "\n\nPlease select the disk to use for the HostVG.\n\n" > HOSTVGDRIVE=$(get_dev_name) || return 0 > local skipped=false > - if check_existing_hostvg $HOSTVGDRIVE devs; then > + if check_existing_hostvg "$HOSTVGDRIVE" devs; then > for dev in $devs > do > printf "Removing HostVG on $dev will erase the drive and cannot be undone\n" > @@ -402,6 +418,8 @@ do_configure() > if [ "$OVIRT_ISCSI_ENABLED" == "y" ]; then > partlist="boot" # swap root config logging data" > local space_left=$BOOTDRIVESPACE > + elif [ "$OVIRT_ROOT_INSTALL" == "n" ]; then > + partlist="swap config logging data" > else > partlist="swap root config logging data" > fi > @@ -459,7 +477,7 @@ set /files$OVIRT_DEFAULTS/OVIRT_VOL_LOGGING_SIZE $LOGGING_SIZE > set /files$OVIRT_DEFAULTS/OVIRT_VOL_DATA_SIZE $DATA_SIZE > EOF > > - if [ -n $BOOTDRIVE ]; then > + if [ -n "$BOOTDRIVE" ]; then > augtool < set /files$OVIRT_DEFAULTS/OVIRT_BOOT_INIT $BOOTDRIVE > EOF > @@ -478,7 +496,7 @@ do_review() > local data_size_display="$DATA_SIZE MB" > if [ "$DATA_SIZE" = -1 ]; then > > - if [ $ROOTDRIVE == $HOSTVGDRIVE ]; then > + if [ "$ROOTDRIVE" == "$HOSTVGDRIVE" ]; then > local remaining_mb=$(( $ROOTDRIVESPACE - $SWAP_SIZE \ > - $ROOT_SIZE * 2 - $CONFIG_SIZE - $LOGGING_SIZE )) > test $remaining_mb -lt 0 && is_negative=1 > @@ -557,7 +575,7 @@ check_existing_hostvg() > # - remove LVM volumes and groups > wipe_lvm_on_disk() > { > - local dev=${1-$HOSTVGDRIVE} > + local dev=${1-"$HOSTVGDRIVE"} > unmount_logging > local part_delim="p" > if [[ "$dev" =~ "/dev/sd" ]]; then > @@ -604,8 +622,8 @@ perform_partitioning() > unmount_config /etc/default/ovirt > > log "Removing old LVM partitions" > - wipe_lvm_on_disk $HOSTVGDRIVE > - wipe_lvm_on_disk $ROOTDRIVE > + wipe_lvm_on_disk "$HOSTVGDRIVE" > + wipe_lvm_on_disk "$ROOTDRIVE" > > # begin critical section > set -e > @@ -635,62 +653,59 @@ perform_partitioning() > return > fi > > - log "Starting partitioning of $ROOTDRIVE" > - log "Partitioning drive: $ROOTDRIVE" > - # FIXME: save a backup copy, just in case? > - log "Wiping old boot sector" > - dd if=/dev/zero of=$ROOTDRIVE bs=1024K count=1 > - reread_partitions $ROOTDRIVE > - partprobe -s $ROOTDRIVE > - log "Labeling Drive: $ROOTDRIVE" > - parted $ROOTDRIVE -s "mklabel ${LABEL_TYPE}" > + if [ "$OVIRT_ROOT_INSTALL" == "y" ]; then > + log "Starting partitioning of $ROOTDRIVE" > + log "Partitioning drive: $ROOTDRIVE" > + # FIXME: save a backup copy, just in case? > + log "Wiping old boot sector" > + dd if=/dev/zero of=$ROOTDRIVE bs=1024K count=1 > + blockdev --rereadpt $ROOTDRIVE > + partprobe -s $ROOTDRIVE > + log "Labeling Drive: $ROOTDRIVE" > + parted $ROOTDRIVE -s "mklabel ${LABEL_TYPE}" > + log "Creating Root and RootBackup Partitions" > + let RootBackup_end=${ROOT_SIZE}*2 > + parted $ROOTDRIVE -s "mkpart primary ext2 0M ${ROOT_SIZE}M" > + parted $ROOTDRIVE -s "mkpart primary ext2 ${ROOT_SIZE}M ${RootBackup_end}M" > + # sleep to ensure filesystems are created before continuing > + sleep 10 > + mke2fs ${ROOTDRIVE}1 -L Root > + mke2fs ${ROOTDRIVE}2 -L RootBackup > + tune2fs -c 0 -i 0 ${ROOTDRIVE}1 > + tune2fs -c 0 -i 0 ${ROOTDRIVE}2 > + fi > > - if [ $ROOTDRIVE != $HOSTVGDRIVE ]; then > + if [ "$ROOTDRIVE" != "$HOSTVGDRIVE" ]; then > log "Labeling Drive: $HOSTVGDRIVE" > - parted $HOSTVGDRIVE -s "mklabel ${LABEL_TYPE}" > - fi > - log "Creating Root and RootBackup Partitions" > - let RootBackup_end=${ROOT_SIZE}*2 > - parted $ROOTDRIVE -s "mkpart primary ext2 0M ${ROOT_SIZE}M" > - parted $ROOTDRIVE -s "mkpart primary ext2 ${ROOT_SIZE}M ${RootBackup_end}M" > - reread_partitions $ROOTDRIVE > - partroot=${ROOTDRIVE}1 > - partrootbackup=${ROOTDRIVE}2 > - if [ ! -e $partroot ]; then > - partroot=${ROOTDRIVE}p1 > - partrootbackup=${ROOTDRIVE}p2 > - fi > - # sleep to ensure filesystems are created before continuing > - sleep 10 > - mke2fs ${partroot} -L Root > - mke2fs ${partrootbackup} -L RootBackup > - tune2fs -c 0 -i 0 ${partroot} > - tune2fs -c 0 -i 0 ${partrootbackup} > + parted "$HOSTVGDRIVE" -s "mklabel ${LABEL_TYPE}" > + fi > log "Creating LVM partition" > > - if [ $ROOTDRIVE == $HOSTVGDRIVE ]; then > - parted $HOSTVGDRIVE -s "mkpart primary ext2 ${RootBackup_end}M -1" > + if [ "$ROOTDRIVE" == "$HOSTVGDRIVE" ]; then > + parted "$HOSTVGDRIVE" -s "mkpart primary ext2 ${RootBackup_end}M -1" > hostvgpart="3" > else > - parted $HOSTVGDRIVE -s "mkpart primary ext2 0M -1" > + parted "$HOSTVGDRIVE" -s "mkpart primary ext2 0M -1" > hostvgpart="1" > fi > log "Toggling LVM on" > - parted $HOSTVGDRIVE -s "set $hostvgpart lvm on" > - parted $ROOTDRIVE -s "print" > + parted "$HOSTVGDRIVE" -s "set $hostvgpart lvm on" > + parted "$ROOTDRIVE" -s "print" > udevadm settle 2> /dev/null || udevsettle > - reread_partitions $HOSTVGDRIVE > + reread_partitions "$HOSTVGDRIVE" > > # sync GPT to the legacy MBR partitions > - if [ "gpt" == "$LABEL_TYPE" ]; then > - log "Running gptsync to create legacy mbr" > - gptsync $ROOTDRIVE > + if [ "$OVIRT_ROOT_INSTALL" == "y" ]; then > + if [ "gpt" == "$LABEL_TYPE" ]; then > + log "Running gptsync to create legacy mbr" > + gptsync "$ROOTDRIVE" > + fi > fi > > - partpv=${HOSTVGDRIVE}${hostvgpart} > + partpv="${HOSTVGDRIVE}"${hostvgpart} > if [ ! -e "$partpv" ]; then > # e.g. /dev/cciss/c0d0p2 > - partpv=${HOSTVGDRIVE}p${hostvgpart} > + partpv="${HOSTVGDRIVE}"p${hostvgpart} > fi > log "Creating physical volume" > if [ ! -e "$partpv" ]; then Still having issues applying this patch directly. I've rebased it manually and will post updated patch here shortly. Mike From mburns at redhat.com Wed Apr 7 14:15:25 2010 From: mburns at redhat.com (Mike Burns) Date: Wed, 7 Apr 2010 10:15:25 -0400 Subject: [Ovirt-devel] [PATCH node] RESEND: [PATCH node 1/3] enables ability for a common shared root Message-ID: <1270649725-5312-1-git-send-email-mburns@redhat.com> From: Joey Boggs --- scripts/ovirt-config-boot | 13 ++++++- scripts/ovirt-config-storage | 80 +++++++++++++++++++++++++----------------- 2 files changed, 60 insertions(+), 33 deletions(-) diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot index 72bcd9b..9593905 100755 --- a/scripts/ovirt-config-boot +++ b/scripts/ovirt-config-boot @@ -29,6 +29,12 @@ ovirt_boot_setup() { local disk2 local partN=-1 log "installing the image." + + if [ "$OVIRT_ROOT_INSTALL" == "n" ]; then + log "done." + return + fi + local found_boot=false if findfs LABEL=Boot 2>&1 >/dev/null ; then found_boot=true @@ -213,7 +219,12 @@ if [ -z "$doreboot" ]; then fi start_log -ovirt_boot_setup "$live" "$bootparams" +if [ "$OVIRT_ROOT_INSTALL" =="n" ]; then + log "done." + return +else + ovirt_boot_setup "$live" "$bootparams" +fi rc=$? if [ $rc -eq 0 -a "$doreboot" = "yes" ]; then disable_firstboot diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index ce9707c..35cb340 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -358,6 +358,22 @@ do_configure() printf "\n\nPlease select the disk to use for the Root.\n\n" ROOTDRIVE=$(get_dev_name) || return 0 get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE + if ask_yes_or_no "Will Root be shared with other nodes ([Y]es/[N]o)?"; then + OVIRT_SHARED_ROOT="y" + if ask_yes_or_no "Partition and install Root?"; then + OVIRT_ROOT_INSTALL="y" + else + OVIRT_ROOT_INSTALL="n" + fi + else + OVIRT_SHARED_ROOT="n" + OVIRT_ROOT_INSTALL="y" + fi + + augtool < References: <1270649725-5312-1-git-send-email-mburns@redhat.com> Message-ID: <1270650510.2257.15.camel@mburns-laptop.bos.redhat.com> On Wed, 2010-04-07 at 10:15 -0400, Mike Burns wrote: > From: Joey Boggs > > --- > scripts/ovirt-config-boot | 13 ++++++- > scripts/ovirt-config-storage | 80 +++++++++++++++++++++++++----------------- > 2 files changed, 60 insertions(+), 33 deletions(-) > > diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot > index 72bcd9b..9593905 100755 > --- a/scripts/ovirt-config-boot > +++ b/scripts/ovirt-config-boot > @@ -29,6 +29,12 @@ ovirt_boot_setup() { > local disk2 > local partN=-1 > log "installing the image." > + > + if [ "$OVIRT_ROOT_INSTALL" == "n" ]; then > + log "done." > + return > + fi > + > local found_boot=false > if findfs LABEL=Boot 2>&1 >/dev/null ; then > found_boot=true > @@ -213,7 +219,12 @@ if [ -z "$doreboot" ]; then > fi > > start_log > -ovirt_boot_setup "$live" "$bootparams" > +if [ "$OVIRT_ROOT_INSTALL" =="n" ]; then > + log "done." > + return > +else > + ovirt_boot_setup "$live" "$bootparams" > +fi > rc=$? > if [ $rc -eq 0 -a "$doreboot" = "yes" ]; then > disable_firstboot > diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage > index ce9707c..35cb340 100755 > --- a/scripts/ovirt-config-storage > +++ b/scripts/ovirt-config-storage > @@ -358,6 +358,22 @@ do_configure() > printf "\n\nPlease select the disk to use for the Root.\n\n" > ROOTDRIVE=$(get_dev_name) || return 0 > get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE > + if ask_yes_or_no "Will Root be shared with other nodes ([Y]es/[N]o)?"; then > + OVIRT_SHARED_ROOT="y" > + if ask_yes_or_no "Partition and install Root?"; then > + OVIRT_ROOT_INSTALL="y" > + else > + OVIRT_ROOT_INSTALL="n" > + fi > + else > + OVIRT_SHARED_ROOT="n" > + OVIRT_ROOT_INSTALL="y" > + fi > + > + augtool < + set /files$OVIRT_DEFAULTS/OVIRT_SHARED_ROOT $OVIRT_SHARED_ROOT > + set /files$OVIRT_DEFAULTS/OVIRT_ROOT_INSTALL $OVIRT_ROOT_INSTALL > +EOF > > printf "\n\nPlease select the disk to use for the HostVG.\n\n" > HOSTVGDRIVE=$(get_dev_name) || return 0 > @@ -403,6 +419,8 @@ do_configure() > if [ "$OVIRT_ISCSI_ENABLED" == "y" ]; then > partlist="boot" # swap root config logging data" > local space_left=$BOOTDRIVESPACE > + elif [ "$OVIRT_ROOT_INSTALL" == "n" ]; then > + partlist="swap config logging data" > else > partlist="swap root config logging data" > fi > @@ -558,7 +576,7 @@ check_existing_hostvg() > # - remove LVM volumes and groups > wipe_lvm_on_disk() > { > - local dev=${1-$HOSTVGDRIVE} > + local dev=${1-"$HOSTVGDRIVE"} > unmount_logging > local part_delim="p" > if [[ "$dev" =~ "/dev/sd" ]]; then > @@ -605,8 +623,8 @@ perform_partitioning() > unmount_config /etc/default/ovirt > > log "Removing old LVM partitions" > - wipe_lvm_on_disk $HOSTVGDRIVE > - wipe_lvm_on_disk $ROOTDRIVE > + wipe_lvm_on_disk "$HOSTVGDRIVE" > + wipe_lvm_on_disk "$ROOTDRIVE" > > # begin critical section > set -e > @@ -636,37 +654,33 @@ perform_partitioning() > return > fi > > - log "Starting partitioning of $ROOTDRIVE" > - log "Partitioning drive: $ROOTDRIVE" > - # FIXME: save a backup copy, just in case? > - log "Wiping old boot sector" > - dd if=/dev/zero of="$ROOTDRIVE" bs=1024K count=1 > - reread_partitions "$ROOTDRIVE" > - partprobe -s "$ROOTDRIVE" > - log "Labeling Drive: $ROOTDRIVE" > - parted "$ROOTDRIVE" -s "mklabel ${LABEL_TYPE}" > + if [ "OVIRT_ROOT_INSTALL" == "y" ]; then > + log "Starting partitioning of $ROOTDRIVE" > + log "Partitioning drive: $ROOTDRIVE" > + # FIXME: save a backup copy, just in case? > + log "Wiping old boot sector" > + dd if=/dev/zero of="$ROOTDRIVE" bs=1024K count=1 > + reread_partitions "$ROOTDRIVE" > + partprobe -s "$ROOTDRIVE" > + log "Labeling Drive: $ROOTDRIVE" > + parted "$ROOTDRIVE" -s "mklabel ${LABEL_TYPE}" > + > + log "Creating Root and RootBackup Partitions" > + let RootBackup_end=${ROOT_SIZE}*2 > + parted $ROOTDRIVE -s "mkpart primary ext2 0M ${ROOT_SIZE}M" > + parted $ROOTDRIVE -s "mkpart primary ext2 ${ROOT_SIZE}M ${RootBackup_end}M" > + # sleep to ensure filesystems are created before continuing > + sleep 10 > + mke2fs ${ROOTDRIVE}1 -L Root > + mke2fs ${ROOTDRIVE}2 -L RootBackup > + tune2fs -c 0 -i 0 ${ROOTDRIVE}1 > + tune2fs -c 0 -i 0 ${ROOTDRIVE}2 These 4 lines need to be changed. For multipath and cciss devices, the partitions are like ${ROOTDRIVE}p1. - mke2fs ${ROOTDRIVE}1 -L Root - mke2fs ${ROOTDRIVE}2 -L RootBackup - tune2fs -c 0 -i 0 ${ROOTDRIVE}1 - tune2fs -c 0 -i 0 ${ROOTDRIVE}2 + reread_partitions "$ROOTDRIVE" + partroot="${ROOTDRIVE}1" + partrootbackup="${ROOTDRIVE}2" + if [ ! -e "$partroot" ]; then + partroot="${ROOTDRIVE}p1" + partrootbackup="${ROOTDRIVE}p2" + fi + mke2fs "$partroot}" -L Root + mke2fs "${partrootbackup}" -L RootBackup + tune2fs -c 0 -i 0 "${partroot}" + tune2fs -c 0 -i 0 "${partrootbackup}" > + fi > > if [ "$ROOTDRIVE" != "$HOSTVGDRIVE" ]; then > log "Labeling Drive: $HOSTVGDRIVE" > parted "$HOSTVGDRIVE" -s "mklabel ${LABEL_TYPE}" > fi > - log "Creating Root and RootBackup Partitions" > - let RootBackup_end=${ROOT_SIZE}*2 > - parted $ROOTDRIVE -s "mkpart primary ext2 0M ${ROOT_SIZE}M" > - parted $ROOTDRIVE -s "mkpart primary ext2 ${ROOT_SIZE}M ${RootBackup_end}M" > - reread_partitions $ROOTDRIVE > - partroot="${ROOTDRIVE}1" > - partrootbackup="${ROOTDRIVE}2" > - if [ ! -e "$partroot" ]; then > - partroot="${ROOTDRIVE}p1" > - partrootbackup="${ROOTDRIVE}p2" > - fi > - # sleep to ensure filesystems are created before continuing > - sleep 10 > - mke2fs "${partroot}" -L Root > - mke2fs "${partrootbackup}" -L RootBackup > - tune2fs -c 0 -i 0 "${partroot}" > - tune2fs -c 0 -i 0 "${partrootbackup}" > log "Creating LVM partition" > > if [ "$ROOTDRIVE" == "$HOSTVGDRIVE" ]; then > @@ -683,9 +697,11 @@ perform_partitioning() > reread_partitions "$HOSTVGDRIVE" > > # sync GPT to the legacy MBR partitions > - if [ "gpt" == "$LABEL_TYPE" ]; then > - log "Running gptsync to create legacy mbr" > - gptsync "$ROOTDRIVE" > + if [ "${OVIRT_INSTALL_ROOT}" == "y" ]; then > + if [ "gpt" == "$LABEL_TYPE" ]; then > + log "Running gptsync to create legacy mbr" > + gptsync "$ROOTDRIVE" > + fi > fi > > partpv="${HOSTVGDRIVE}${hostvgpart}" From mburns at redhat.com Wed Apr 7 14:44:35 2010 From: mburns at redhat.com (Mike Burns) Date: Wed, 7 Apr 2010 10:44:35 -0400 Subject: [Ovirt-devel] [PATCH node] Fix defaulting of OVIRT_CACHE_DIR in recipe makefile Message-ID: <1270651475-7416-1-git-send-email-mburns@redhat.com> Due to a typo, the defaulting of OVIRT_CACHE_DIR in the recipe Makefile.am was broken. Signed-off-by: Mike Burns --- recipe/Makefile.am | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/recipe/Makefile.am b/recipe/Makefile.am index fb34437..d09905a 100644 --- a/recipe/Makefile.am +++ b/recipe/Makefile.am @@ -27,7 +27,7 @@ ARCH = $(shell rpm --eval '%{_arch}') OVIRT_NODE_RECIPE = ovirt-node-recipe.ks PKG_FMT = iso PACKAGE = ovirt-node-image -OVIRT_CACHE_DIR ? =$(HOME)/ovirt-cache +OVIRT_CACHE_DIR ?= $(HOME)/ovirt-cache NODE_TMP = $(OVIRT_CACHE_DIR)/$(PACKAGE)-$(ARCH)-tmp OVIRT_LOCAL_REPO ?= file://$(OVIRT_CACHE_DIR)/ovirt NODE_KS = $(NODE_TMP)/node.ks -- 1.6.6.1 From dpierce at redhat.com Wed Apr 7 14:57:03 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Wed, 7 Apr 2010 10:57:03 -0400 Subject: [Ovirt-devel] [PATCH node] Fix defaulting of OVIRT_CACHE_DIR in recipe makefile In-Reply-To: <1270651475-7416-1-git-send-email-mburns@redhat.com> References: <1270651475-7416-1-git-send-email-mburns@redhat.com> Message-ID: <20100407145703.GM5858@mcpierce-desktop.usersys.redhat.com> On Wed, Apr 07, 2010 at 10:44:35AM -0400, Mike Burns wrote: > Due to a typo, the defaulting of OVIRT_CACHE_DIR in the recipe > Makefile.am was broken. > > Signed-off-by: Mike Burns > --- > recipe/Makefile.am | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/recipe/Makefile.am b/recipe/Makefile.am > index fb34437..d09905a 100644 > --- a/recipe/Makefile.am > +++ b/recipe/Makefile.am > @@ -27,7 +27,7 @@ ARCH = $(shell rpm --eval '%{_arch}') > OVIRT_NODE_RECIPE = ovirt-node-recipe.ks > PKG_FMT = iso > PACKAGE = ovirt-node-image > -OVIRT_CACHE_DIR ? =$(HOME)/ovirt-cache > +OVIRT_CACHE_DIR ?= $(HOME)/ovirt-cache > NODE_TMP = $(OVIRT_CACHE_DIR)/$(PACKAGE)-$(ARCH)-tmp > OVIRT_LOCAL_REPO ?= file://$(OVIRT_CACHE_DIR)/ovirt > NODE_KS = $(NODE_TMP)/node.ks > -- > 1.6.6.1 > > _______________________________________________ > Ovirt-devel mailing list > Ovirt-devel at redhat.com > https://www.redhat.com/mailman/listinfo/ovirt-devel ACK and pushed. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From dpierce at redhat.com Thu Apr 8 18:21:32 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Thu, 8 Apr 2010 14:21:32 -0400 Subject: [Ovirt-devel] [PATCH matahari] Fixes the parent reference for a Processors agent. Message-ID: <1270750892-7394-1-git-send-email-dpierce@redhat.com> Signed-off-by: Darryl L. Pierce --- src/host.cpp | 2 +- src/processors.cpp | 4 ++-- src/processors.h | 2 +- src/schema.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/host.cpp b/src/host.cpp index 44c7717..ac04f47 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -82,7 +82,7 @@ void HostWrapper::setupQMFObjects(ManagementAgent *agent) agent->addObject(mgmt_object); syncQMFHostObject(); - processors.setup(agent); + processors.setup(agent, this); // Iterate over list and set up CPU objects for (vector::iterator iter = cpus.begin(); diff --git a/src/processors.cpp b/src/processors.cpp index 3edc417..4317b1f 100644 --- a/src/processors.cpp +++ b/src/processors.cpp @@ -37,10 +37,10 @@ namespace _qmf = qmf::com::redhat::matahari; extern DBusError dbus_error; void -ProcessorsAgent::setup(ManagementAgent* agent) +ProcessorsAgent::setup(ManagementAgent* agent, Manageable* parent) { // setup the management object - management_object = new _qmf::Processors(agent, this); + management_object = new _qmf::Processors(agent, this, parent); agent->addObject(management_object); LibHalContext* context = get_hal_ctx(); diff --git a/src/processors.h b/src/processors.h index 008ce11..3e46b16 100644 --- a/src/processors.h +++ b/src/processors.h @@ -40,7 +40,7 @@ class ProcessorsAgent : public Manageable ManagementObject* GetManagementObject(void) const { return management_object; } - void setup(ManagementAgent* agent); + void setup(ManagementAgent* agent, Manageable* parent); // agent methods void update_load_averages(void) const; diff --git a/src/schema.xml b/src/schema.xml index 48e9576..f9c6f6b 100644 --- a/src/schema.xml +++ b/src/schema.xml @@ -16,7 +16,7 @@ - + -- 1.6.6.1 From jboggs at redhat.com Fri Apr 9 14:26:35 2010 From: jboggs at redhat.com (Joey Boggs) Date: Fri, 9 Apr 2010 10:26:35 -0400 Subject: [Ovirt-devel] [PATCH node] fix iscsi installation problems In-Reply-To: References: Message-ID: <1270823195-5084-1-git-send-email-jboggs@redhat.com> This patch fixes a few problems encountered with installing to an iscsi backed root partition as well as a normal local disk install. --- scripts/ovirt-config-boot | 10 ++++++---- scripts/ovirt-config-networking | 8 +++++--- scripts/ovirt-config-storage | 17 ++++++++++++++++- scripts/ovirt-functions | 27 ++++++++++++++++++--------- 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot index 72bcd9b..fc6649f 100755 --- a/scripts/ovirt-config-boot +++ b/scripts/ovirt-config-boot @@ -34,7 +34,7 @@ ovirt_boot_setup() { found_boot=true grub_dev_label=Boot elif findfs LABEL=Root 2>&1 >/dev/null ; then - found_boot=true + found_boot=false grub_dev_label=Root fi if $found_boot; then @@ -56,8 +56,8 @@ ovirt_boot_setup() { grub_dev_label="RootBackup" fi - # check that /boot mounted ok and find partition number for GRUB - get_part_info $(readlink -f $(findfs LABEL=$grub_dev_label 2>/dev/null)) disk partN + # check that /boot mounted ok and find partition number for GRUB, $4 is to allow 0 as a partition number for grub + get_part_info $(readlink -f $(findfs LABEL=$grub_dev_label 2>/dev/null)) disk partN y rc=$? if [ $rc -ne 0 -o $partN -lt 0 ]; then log "unable to determine Root partition" @@ -217,7 +217,9 @@ ovirt_boot_setup "$live" "$bootparams" rc=$? if [ $rc -eq 0 -a "$doreboot" = "yes" ]; then disable_firstboot - ovirt_store_firstboot_config + if [ "$OVIRT_ISCSI_ENABLED" != "y" ]; then + ovirt_store_firstboot_config + fi stop_log reboot diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index 4d412ac..810d0e0 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -24,10 +24,12 @@ CONFIGURED_NIC="" VLAN_ID="" VL_ROOT="" +if [[ -z "$ROOTDRIVE" && "$OVIRT_ISCSI_ENABLED" != "y" ]]; then # if local storage is not configured, then exit the script -if ! is_local_storage_configured; then - printf "Local storage must be configured prior to configuring the management interface.\n\n" - exit 99 + if [[ ! is_local_storage_configured && "$OVIRT_ISCSI_NETWORKING" != "y" ]] ; then + printf "Local storage must be configured prior to configuring the management interface.\n\n" + exit 99 + fi fi # $1 - the variable name to set diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index ce9707c..c94c79d 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -624,7 +624,7 @@ perform_partitioning() parted "$BOOTDRIVE" -s "mklabel ${LABEL_TYPE}" parted "$BOOTDRIVE" -s "mkpartfs primary ext2 0M ${boot_size_si}M" reread_partitions "$BOOTDRIVE" - partboot="$BOOTDRIVE1" + partboot="${BOOTDRIVE}1" if [ ! -e "$partboot" ]; then partboot="${BOOTDRIVE}p1" fi @@ -794,11 +794,26 @@ do_confirm() else return fi + # store networking config since it was created before storage was established for iscsi targets + if [ "$OVIRT_ISCSI_NETWORKING" == "y" ]; then + ovirt_store_config \ + /etc/sysconfig/network-scripts/ifcfg* \ + /etc/ntp.conf + fi done } do_iscsi_target() { +if ! network_up ; then + printf "Networking must be configured prior to configuring an iscsi target.\n\n" + # allow network config without setting up storage first + augtool < Hi, My setup is 1 management server and 1 server for virtual guests. The management server is an old dual core 32bit machine, the virtual guests server will be a dual quad core Dell server (until someone needs it back for production stuff :) ) This install is for the 32bit management server. First did a basic install of F12 without any X stuff in it Made sure /etc/selinux/config is in permissive or disabled mode Edited my network interfaces, one for management and one for guests network. After putting the proxy in place (eg. yum.conf, wgetrc, and putting http_proxy and ftp_proxy in roots .bash_profile) I updated the basic install to the latest versions en did a reboot afterwards. Made sure that in /etc/hosts my hostname entry was correct. should be [x.x.x.x.x name.domain name] and in no other way, found out the hard way. Downloaded ovirt-release-LATEST.noarch.rpm from http://www.ovirt.org/repos/ovirt/ and installed it Made sure the repo was enabled by editting /etc/yum.repos.d/ovirt.repo Did a "yum install ovirt-server ovirt-server-installer ovirt-node-image ovirt-node-image-pxe" But the ovirt nodes are not available for the 32bit environment so only the ovirt-server packages were installed. After that I did a "yum --enablerepo=updates-testing update rubygem-activeldap" Then I ran "ovirt-installer" and after that "ace -d -l ace-install-ovirt.log install ovirt" That last command does not put all the output in the log file only a few lines, the bulk of the messages are shown on the screen. The 0.100 installer did a better job at that. After that I could find the web interface at http://ipadress/ovirt and log in with admin and the password I entered at ovirt-installer time. Next thing to find out is how I get the virtual server (the dual quadcore) booted and configured via pxe, but that's for next week. Thnx to all the people on IRC that helped me this week. Cheers, Michel --------------------------------------------------------------------------------------------------------------- Deze e-mail en eventuele bijlagen vallen onder de op onze website gepubliceerde disclaimer: http://vluchtelingenwerk.nl/emaildisclaimer.html Denk aan het milieu, print dit bericht niet onnodig uit. From matinata at br.ibm.com Mon Apr 12 13:18:20 2010 From: matinata at br.ibm.com (Ricardo Marin Matinata) Date: Mon, 12 Apr 2010 10:18:20 -0300 Subject: [Ovirt-devel] RFC: Advanced Storage Configuration Message-ID: <1271078300.3715.31.camel@localhost> Hello, I'd like to put forward the following proposal for your appreciation, in order to add flexibility to the node configuration, so one can choose to store guest's images in a different device than the core OS/config/log/data today. In essence, proposal involves the following: - Addition of a new top level install menu called "Advanced Storage Configuration" where one can select a storage device to which should the guest's images be stored. - Next to the device selection, creates a new volume group - HostVG-Images - to be mounted at /images - Perform adjustments do /var/lib/libvirt/images "mount binds" against /images Comments ? Regards, -- Ricardo Marin Matinata Linux Technology Center IBM Brazil | Hortolandia | SP matinata br ibm com From apevec at redhat.com Tue Apr 13 12:26:50 2010 From: apevec at redhat.com (Alan Pevec) Date: Tue, 13 Apr 2010 14:26:50 +0200 Subject: [Ovirt-devel] [PATCH node] refactor node image recipe Message-ID: <1271161610-19653-1-git-send-email-apevec@redhat.com> top-level kickstart file contains only includes, example custom-template.ks is provided with documented customization points. Signed-off-by: Alan Pevec --- recipe/common-manifest-post.ks | 31 +++++++++++ recipe/common-manifest-pre.ks | 11 ++++ recipe/common-post-chroot.ks | 46 ++++++++++++++++ recipe/common-post.ks | 24 +++++++++ recipe/custom-template.ks | 33 ++++++++++++ recipe/ovirt-node-image.ks | 111 ++-------------------------------------- 6 files changed, 150 insertions(+), 106 deletions(-) create mode 100644 recipe/common-manifest-post.ks create mode 100644 recipe/common-manifest-pre.ks create mode 100644 recipe/common-post-chroot.ks create mode 100644 recipe/custom-template.ks diff --git a/recipe/common-manifest-post.ks b/recipe/common-manifest-post.ks new file mode 100644 index 0000000..020f3a0 --- /dev/null +++ b/recipe/common-manifest-post.ks @@ -0,0 +1,31 @@ +%post +# Create post-image processing manifests +manifests=/tmp/manifests +mkdir -p $manifests +rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \ + > $manifests/rpm-manifest-post.txt +rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest-post.txt +du -akx --exclude=/var/cache/yum / > $manifests/file-manifest-post.txt +du -x --exclude=/var/cache/yum / > $manifests/dir-manifest-post.txt + +ver=$(rpm -q --qf '%{version}' ovirt-node) +rel=$(rpm -q --qf '%{release}' ovirt-node) +arch=$(rpm -q --qf '%{arch}' ovirt-node) +echo "oVirt Node release $ver-$rel-$arch" > $manifests/ovirt-release +tar -cvf ovirt-node-image-manifests-$ver-$rel.$arch.tar -C /tmp manifests +ln -nf ovirt-node-image-manifests-$ver-$rel.$arch.tar ovirt-node-image-manifests.tar +rm -Rf $manifests +%end + +%post --nochroot +# Move manifest tar to build directory +mv $INSTALL_ROOT/ovirt-node-image-manifests*.tar . + +# only works on x86, x86_64 +if [ "$(uname -i)" = "i386" -o "$(uname -i)" = "x86_64" ]; then + if [ ! -d $LIVE_ROOT/LiveOS ]; then mkdir -p $LIVE_ROOT/LiveOS ; fi + cp /usr/bin/livecd-iso-to-disk $LIVE_ROOT/LiveOS + cp /usr/bin/livecd-iso-to-pxeboot $LIVE_ROOT/LiveOS +fi +%end + diff --git a/recipe/common-manifest-pre.ks b/recipe/common-manifest-pre.ks new file mode 100644 index 0000000..c88f0cc --- /dev/null +++ b/recipe/common-manifest-pre.ks @@ -0,0 +1,11 @@ +%post +# Create initial manifests +manifests=/tmp/manifests +mkdir -p $manifests +rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \ + > $manifests/rpm-manifest.txt +rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest.txt +du -akx --exclude=/var/cache/yum / > $manifests/file-manifest.txt +du -x --exclude=/var/cache/yum / > $manifests/dir-manifest.txt +%end + diff --git a/recipe/common-post-chroot.ks b/recipe/common-post-chroot.ks new file mode 100644 index 0000000..a3f5071 --- /dev/null +++ b/recipe/common-post-chroot.ks @@ -0,0 +1,46 @@ +if [ -f "ovirt-authorized_keys" ]; then + echo "Adding authorized_keys to Image" + mkdir -p $INSTALL_ROOT/root/.ssh + cp -v ovirt-authorized_keys $INSTALL_ROOT/root/.ssh/authorized_keys + chown -R root:root $INSTALL_ROOT/root/.ssh + chmod 755 $INSTALL_ROOT/root/.ssh + chmod 644 $INSTALL_ROOT/root/.ssh/authorized_keys +fi + +echo "Fixing boot menu" +# remove quiet from Node bootparams, added by livecd-creator +sed -i -e 's/ quiet//' $LIVE_ROOT/isolinux/isolinux.cfg + +# add stand-alone boot entry +awk ' +BEGIN { + # append additional default boot parameters + add_boot_params="check" +} +/^label linux0/ { linux0=1 } +linux0==1 && $1=="append" { + $0=$0 " " add_boot_params + append0=$0 +} +linux0==1 && $1=="label" && $2!="linux0" { + linux0=2 + print "label stand-alone" + print " menu label Boot in stand-alone mode" + print " kernel vmlinuz0" + gsub("console=tty0", "", append0) + print append0" ovirt_standalone console=tty0" +} +{ print } +' $LIVE_ROOT/isolinux/isolinux.cfg > $LIVE_ROOT/isolinux/isolinux.cfg.standalone +mv $LIVE_ROOT/isolinux/isolinux.cfg.standalone $LIVE_ROOT/isolinux/isolinux.cfg + +cp $INSTALL_ROOT/usr/share/ovirt-node/syslinux-vesa-splash.jpg $LIVE_ROOT/isolinux/splash.jpg + +# overwrite user visible banners with the image versioning info +PACKAGE=ovirt +ln -snf $PACKAGE-release $INSTALL_ROOT/etc/redhat-release +ln -snf $PACKAGE-release $INSTALL_ROOT/etc/system-release +cp $INSTALL_ROOT/etc/$PACKAGE-release $INSTALL_ROOT/etc/issue +echo "Kernel \r on an \m (\l)" >> $INSTALL_ROOT/etc/issue +cp $INSTALL_ROOT/etc/issue $INSTALL_ROOT/etc/issue.net + diff --git a/recipe/common-post.ks b/recipe/common-post.ks index 411e565..fed5b6b 100644 --- a/recipe/common-post.ks +++ b/recipe/common-post.ks @@ -3,6 +3,9 @@ echo "Starting Kickstart Post" PATH=/sbin:/usr/sbin:/bin:/usr/bin export PATH +# cleanup rpmdb to allow non-matching host and chroot RPM versions +rm -f /var/lib/rpm/__db* + # Import SELinux Modules echo "Enabling selinux modules" SEMODULES="base automount avahi consolekit cyrus dhcp dnsmasq guest hal ipsec \ @@ -196,3 +199,24 @@ EOF # Need this for F12 findfs calls # Otherwise, findfs returns /dev/sdX instead of /dev/mapper/ echo "EVALUATE=scan" > /etc/blkid.conf + +touch /.autorelabel + +# prepare for STATE_MOUNT in rc.sysinit +augtool <<\EOF +set /files/etc/sysconfig/readonly-root/TEMPORARY_STATE NOT_OVIRT_FIRSTBOOT +set /files/etc/sysconfig/readonly-root/STATE_LABEL CONFIG +set /files/etc/sysconfig/readonly-root/STATE_MOUNT /config +set /files/etc/sysconfig/readonly-root/READONLY yes +save +EOF +# use persistent state unless firstboot is forced +# XXX auges shellvars lens does not accept this value +sed -i 's at NOT_OVIRT_FIRSTBOOT@$(if cat /proc/cmdline|grep -qv ovirt_firstboot; then printf "yes"; else printf "no"; fi)@' /etc/sysconfig/readonly-root +# prepare mount points for local storage +mkdir -p /boot +mkdir -p /config +mkdir -p /data +mkdir -p /liveos +echo "/dev/HostVG/Config /config ext3 defaults,noauto,noatime 0 0" >> /etc/fstab + diff --git a/recipe/custom-template.ks b/recipe/custom-template.ks new file mode 100644 index 0000000..70d084b --- /dev/null +++ b/recipe/custom-template.ks @@ -0,0 +1,33 @@ +# oVirt Node image recipe +# This an example TEMPLATE for customizations. + +%include common-install.ks +# add custom installation directives here + +%include repos.ks +# add custom repos here + +%packages --excludedocs --nobase +%include common-pkgs.ks +# add custom package list here + +%end + +%post +%include common-post.ks +# add custom post-scripts here + +%end + +%include common-manifest-pre.ks + +%include common-blacklist.ks + +%post --nochroot +%include common-post-nochroot.ks +# add custom post-scripts running outside image chroot here + +%end + +%include common-manifest-post.ks + diff --git a/recipe/ovirt-node-image.ks b/recipe/ovirt-node-image.ks index 7c9361c..6fad5cd 100644 --- a/recipe/ovirt-node-image.ks +++ b/recipe/ovirt-node-image.ks @@ -1,3 +1,5 @@ +# oVirt Node image recipe + %include common-install.ks %include repos.ks @@ -8,121 +10,18 @@ %end %post -# cleanup rpmdb to allow non-matching host and chroot RPM versions -rm -f /var/lib/rpm/__db* %include common-post.ks -touch /.autorelabel - -# prepare for STATE_MOUNT in rc.sysinit -augtool <<\EOF -set /files/etc/sysconfig/readonly-root/TEMPORARY_STATE NOT_OVIRT_FIRSTBOOT -set /files/etc/sysconfig/readonly-root/STATE_LABEL CONFIG -set /files/etc/sysconfig/readonly-root/STATE_MOUNT /config -set /files/etc/sysconfig/readonly-root/READONLY yes -save -EOF -# use persistent state unless firstboot is forced -# XXX auges shellvars lens does not accept this value -sed -i 's at NOT_OVIRT_FIRSTBOOT@$(if cat /proc/cmdline|grep -qv ovirt_firstboot; then printf "yes"; else printf "no"; fi)@' /etc/sysconfig/readonly-root -# prepare mount points for local storage -mkdir -p /boot -mkdir -p /config -mkdir -p /data -mkdir -p /liveos -echo "/dev/HostVG/Config /config ext3 defaults,noauto,noatime 0 0" >> /etc/fstab %end -%post -# Create initial manifests -manifests=/tmp/manifests -mkdir -p $manifests -rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \ - > $manifests/rpm-manifest.txt -rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest.txt -du -akx --exclude=/var/cache/yum / > $manifests/file-manifest.txt -du -x --exclude=/var/cache/yum / > $manifests/dir-manifest.txt -%end +%include common-manifest-pre.ks %include common-blacklist.ks %post --nochroot -if [ -f "ovirt-authorized_keys" ]; then - echo "Adding authorized_keys to Image" - mkdir -p $INSTALL_ROOT/root/.ssh - cp -v ovirt-authorized_keys $INSTALL_ROOT/root/.ssh/authorized_keys - chown -R root:root $INSTALL_ROOT/root/.ssh - chmod 755 $INSTALL_ROOT/root/.ssh - chmod 644 $INSTALL_ROOT/root/.ssh/authorized_keys -fi - -echo "Fixing boot menu" -# remove quiet from Node bootparams, added by livecd-creator -sed -i -e 's/ quiet//' $LIVE_ROOT/isolinux/isolinux.cfg - -# add stand-alone boot entry -awk ' -BEGIN { - # append additional default boot parameters - add_boot_params="check" -} -/^label linux0/ { linux0=1 } -linux0==1 && $1=="append" { - $0=$0 " " add_boot_params - append0=$0 -} -linux0==1 && $1=="label" && $2!="linux0" { - linux0=2 - print "label stand-alone" - print " menu label Boot in stand-alone mode" - print " kernel vmlinuz0" - gsub("console=tty0", "", append0) - print append0" ovirt_standalone console=tty0" -} -{ print } -' $LIVE_ROOT/isolinux/isolinux.cfg > $LIVE_ROOT/isolinux/isolinux.cfg.standalone -mv $LIVE_ROOT/isolinux/isolinux.cfg.standalone $LIVE_ROOT/isolinux/isolinux.cfg - -cp $INSTALL_ROOT/usr/share/ovirt-node/syslinux-vesa-splash.jpg $LIVE_ROOT/isolinux/splash.jpg - -# overwrite user visible banners with the image versioning info -PACKAGE=ovirt -ln -snf $PACKAGE-release $INSTALL_ROOT/etc/redhat-release -ln -snf $PACKAGE-release $INSTALL_ROOT/etc/system-release -cp $INSTALL_ROOT/etc/$PACKAGE-release $INSTALL_ROOT/etc/issue -echo "Kernel \r on an \m (\l)" >> $INSTALL_ROOT/etc/issue -cp $INSTALL_ROOT/etc/issue $INSTALL_ROOT/etc/issue.net +%include common-post-nochroot.ks %end -%post -# Create post-image processing manifests -manifests=/tmp/manifests -mkdir -p $manifests -rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \ - > $manifests/rpm-manifest-post.txt -rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest-post.txt -du -akx --exclude=/var/cache/yum / > $manifests/file-manifest-post.txt -du -x --exclude=/var/cache/yum / > $manifests/dir-manifest-post.txt - -ver=$(rpm -q --qf '%{version}' ovirt-node) -rel=$(rpm -q --qf '%{release}' ovirt-node) -arch=$(rpm -q --qf '%{arch}' ovirt-node) -echo "oVirt Node release $ver-$rel-$arch" > $manifests/ovirt-release -tar -cvf ovirt-node-image-manifests-$ver-$rel.$arch.tar -C /tmp manifests -ln -nf ovirt-node-image-manifests-$ver-$rel.$arch.tar ovirt-node-image-manifests.tar -rm -Rf $manifests -%end - -%post --nochroot -# Move manifest tar to build directory -mv $INSTALL_ROOT/ovirt-node-image-manifests*.tar . - -# only works on x86, x86_64 -if [ "$(uname -i)" = "i386" -o "$(uname -i)" = "x86_64" ]; then - if [ ! -d $LIVE_ROOT/LiveOS ]; then mkdir -p $LIVE_ROOT/LiveOS ; fi - cp /usr/bin/livecd-iso-to-disk $LIVE_ROOT/LiveOS - cp /usr/bin/livecd-iso-to-pxeboot $LIVE_ROOT/LiveOS -fi -%end +%include common-manifest-post.ks -- 1.6.0.6 From dpierce at redhat.com Tue Apr 13 13:30:25 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Tue, 13 Apr 2010 09:30:25 -0400 Subject: [Ovirt-devel] Refactored with feedback... Message-ID: <1271165426-3625-1-git-send-email-dpierce@redhat.com> This version adds an additional call to cleanup_after_testing after each test to ensure things are cleaned up. From dpierce at redhat.com Tue Apr 13 13:30:26 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Tue, 13 Apr 2010 09:30:26 -0400 Subject: [Ovirt-devel] [PATCH] Ensures that cleanup specifies the network interface to be destroyed. In-Reply-To: <1271165426-3625-1-git-send-email-dpierce@redhat.com> References: <1271165426-3625-1-git-send-email-dpierce@redhat.com> Message-ID: <1271165426-3625-2-git-send-email-dpierce@redhat.com> Signed-off-by: Darryl L. Pierce --- autotest.sh | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/autotest.sh b/autotest.sh index 3431ed4..2f21079 100755 --- a/autotest.sh +++ b/autotest.sh @@ -691,7 +691,7 @@ cleanup_after_testing () { test -n "$vm_list" && for vm in $vm_list; do destroy_node $vm done - stop_networking + stop_networking "${IFACE_NAME}" true # do not delete the work directory if preserve was specified if $preserve_vm; then return; fi @@ -752,6 +752,8 @@ log "Logging results to file: ${RESULTS}" execute_test $test result=$? + cleanup_after_testing + if [ $result != 0 ]; then echo "${result}" > $result_file break -- 1.6.6.1 From dpierce at redhat.com Tue Apr 13 14:44:38 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Tue, 13 Apr 2010 10:44:38 -0400 Subject: [Ovirt-devel] [PATCH node] refactor node image recipe In-Reply-To: <1271161610-19653-1-git-send-email-apevec@redhat.com> References: <1271161610-19653-1-git-send-email-apevec@redhat.com> Message-ID: <20100413144438.GA7266@mcpierce-desktop.usersys.redhat.com> On Tue, Apr 13, 2010 at 02:26:50PM +0200, Alan Pevec wrote: > top-level kickstart file contains only includes, > example custom-template.ks is provided with documented customization > points. > > Signed-off-by: Alan Pevec > --- The patch works but after a few fixes were made locally. * need to add common-manifest-post.ks to recipes/Makefile.am * need to add common-manifest-pre.ks to recipes/Makefile.am * need to add common-post-chroot.ks to recipes/Makefile.am [1] * need to fix recipe/ovirt-node-image.ks to use common-post-chroot.ks [1] - I went on the assumptiong that common-post-chroot.ks and common-post-nochroot.ks are the same file. NAK until an update with the above changes is sent. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From apevec at redhat.com Wed Apr 14 02:05:29 2010 From: apevec at redhat.com (Alan Pevec) Date: Wed, 14 Apr 2010 04:05:29 +0200 Subject: [Ovirt-devel] [PATCH node] refactor node image recipe In-Reply-To: <20100413144438.GA7266@mcpierce-desktop.usersys.redhat.com> References: <20100413144438.GA7266@mcpierce-desktop.usersys.redhat.com> Message-ID: <1271210729-31477-1-git-send-email-apevec@redhat.com> top-level kickstart file contains only includes, example custom-template.ks is provided with documented customization points. Signed-off-by: Alan Pevec --- recipe/Makefile.am | 29 +++++++---- recipe/common-manifest-post.ks | 31 +++++++++++ recipe/common-manifest-pre.ks | 11 ++++ recipe/common-post-nochroot.ks | 46 ++++++++++++++++ recipe/common-post.ks | 24 +++++++++ recipe/custom-template.ks | 33 ++++++++++++ recipe/ovirt-node-image.ks | 111 ++-------------------------------------- 7 files changed, 168 insertions(+), 117 deletions(-) create mode 100644 recipe/common-manifest-post.ks create mode 100644 recipe/common-manifest-pre.ks create mode 100644 recipe/common-post-nochroot.ks create mode 100644 recipe/custom-template.ks diff --git a/recipe/Makefile.am b/recipe/Makefile.am index d09905a..fe116f6 100644 --- a/recipe/Makefile.am +++ b/recipe/Makefile.am @@ -36,21 +36,28 @@ SUM ?= sha1sum AUTH_KEYS ?= $(HOME)/.ssh/authorized_keys OVIRT_NODE_TOOLSdir = $(datadir)/ovirt-node-tools -OVIRT_NODE_TOOLS_DATA = \ - repos.ks \ +OVIRT_NODE_TOOLS_DATA = \ + repos.ks \ + common-manifest-pre.ks \ common-blacklist.ks \ + common-manifest-post.ks \ common-install.ks \ - common-pkgs.ks \ - common-post.ks \ - ovirt-node-image.ks \ + common-pkgs.ks \ + common-post.ks \ + common-post-nochroot.ks \ + ovirt-node-image.ks \ ovirt-node-recipe.ks -EXTRA_DIST= \ - common-blacklist.ks \ - common-install.ks \ - common-pkgs.ks \ - common-post.ks \ - ovirt-node-image.ks + +EXTRA_DIST = \ + common-manifest-pre.ks \ + common-blacklist.ks \ + common-manifest-post.ks \ + common-install.ks \ + common-pkgs.ks \ + common-post.ks \ + common-post-nochroot.ks \ + ovirt-node-image.ks repos.ks: ( \ diff --git a/recipe/common-manifest-post.ks b/recipe/common-manifest-post.ks new file mode 100644 index 0000000..020f3a0 --- /dev/null +++ b/recipe/common-manifest-post.ks @@ -0,0 +1,31 @@ +%post +# Create post-image processing manifests +manifests=/tmp/manifests +mkdir -p $manifests +rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \ + > $manifests/rpm-manifest-post.txt +rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest-post.txt +du -akx --exclude=/var/cache/yum / > $manifests/file-manifest-post.txt +du -x --exclude=/var/cache/yum / > $manifests/dir-manifest-post.txt + +ver=$(rpm -q --qf '%{version}' ovirt-node) +rel=$(rpm -q --qf '%{release}' ovirt-node) +arch=$(rpm -q --qf '%{arch}' ovirt-node) +echo "oVirt Node release $ver-$rel-$arch" > $manifests/ovirt-release +tar -cvf ovirt-node-image-manifests-$ver-$rel.$arch.tar -C /tmp manifests +ln -nf ovirt-node-image-manifests-$ver-$rel.$arch.tar ovirt-node-image-manifests.tar +rm -Rf $manifests +%end + +%post --nochroot +# Move manifest tar to build directory +mv $INSTALL_ROOT/ovirt-node-image-manifests*.tar . + +# only works on x86, x86_64 +if [ "$(uname -i)" = "i386" -o "$(uname -i)" = "x86_64" ]; then + if [ ! -d $LIVE_ROOT/LiveOS ]; then mkdir -p $LIVE_ROOT/LiveOS ; fi + cp /usr/bin/livecd-iso-to-disk $LIVE_ROOT/LiveOS + cp /usr/bin/livecd-iso-to-pxeboot $LIVE_ROOT/LiveOS +fi +%end + diff --git a/recipe/common-manifest-pre.ks b/recipe/common-manifest-pre.ks new file mode 100644 index 0000000..c88f0cc --- /dev/null +++ b/recipe/common-manifest-pre.ks @@ -0,0 +1,11 @@ +%post +# Create initial manifests +manifests=/tmp/manifests +mkdir -p $manifests +rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \ + > $manifests/rpm-manifest.txt +rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest.txt +du -akx --exclude=/var/cache/yum / > $manifests/file-manifest.txt +du -x --exclude=/var/cache/yum / > $manifests/dir-manifest.txt +%end + diff --git a/recipe/common-post-nochroot.ks b/recipe/common-post-nochroot.ks new file mode 100644 index 0000000..a3f5071 --- /dev/null +++ b/recipe/common-post-nochroot.ks @@ -0,0 +1,46 @@ +if [ -f "ovirt-authorized_keys" ]; then + echo "Adding authorized_keys to Image" + mkdir -p $INSTALL_ROOT/root/.ssh + cp -v ovirt-authorized_keys $INSTALL_ROOT/root/.ssh/authorized_keys + chown -R root:root $INSTALL_ROOT/root/.ssh + chmod 755 $INSTALL_ROOT/root/.ssh + chmod 644 $INSTALL_ROOT/root/.ssh/authorized_keys +fi + +echo "Fixing boot menu" +# remove quiet from Node bootparams, added by livecd-creator +sed -i -e 's/ quiet//' $LIVE_ROOT/isolinux/isolinux.cfg + +# add stand-alone boot entry +awk ' +BEGIN { + # append additional default boot parameters + add_boot_params="check" +} +/^label linux0/ { linux0=1 } +linux0==1 && $1=="append" { + $0=$0 " " add_boot_params + append0=$0 +} +linux0==1 && $1=="label" && $2!="linux0" { + linux0=2 + print "label stand-alone" + print " menu label Boot in stand-alone mode" + print " kernel vmlinuz0" + gsub("console=tty0", "", append0) + print append0" ovirt_standalone console=tty0" +} +{ print } +' $LIVE_ROOT/isolinux/isolinux.cfg > $LIVE_ROOT/isolinux/isolinux.cfg.standalone +mv $LIVE_ROOT/isolinux/isolinux.cfg.standalone $LIVE_ROOT/isolinux/isolinux.cfg + +cp $INSTALL_ROOT/usr/share/ovirt-node/syslinux-vesa-splash.jpg $LIVE_ROOT/isolinux/splash.jpg + +# overwrite user visible banners with the image versioning info +PACKAGE=ovirt +ln -snf $PACKAGE-release $INSTALL_ROOT/etc/redhat-release +ln -snf $PACKAGE-release $INSTALL_ROOT/etc/system-release +cp $INSTALL_ROOT/etc/$PACKAGE-release $INSTALL_ROOT/etc/issue +echo "Kernel \r on an \m (\l)" >> $INSTALL_ROOT/etc/issue +cp $INSTALL_ROOT/etc/issue $INSTALL_ROOT/etc/issue.net + diff --git a/recipe/common-post.ks b/recipe/common-post.ks index 411e565..fed5b6b 100644 --- a/recipe/common-post.ks +++ b/recipe/common-post.ks @@ -3,6 +3,9 @@ echo "Starting Kickstart Post" PATH=/sbin:/usr/sbin:/bin:/usr/bin export PATH +# cleanup rpmdb to allow non-matching host and chroot RPM versions +rm -f /var/lib/rpm/__db* + # Import SELinux Modules echo "Enabling selinux modules" SEMODULES="base automount avahi consolekit cyrus dhcp dnsmasq guest hal ipsec \ @@ -196,3 +199,24 @@ EOF # Need this for F12 findfs calls # Otherwise, findfs returns /dev/sdX instead of /dev/mapper/ echo "EVALUATE=scan" > /etc/blkid.conf + +touch /.autorelabel + +# prepare for STATE_MOUNT in rc.sysinit +augtool <<\EOF +set /files/etc/sysconfig/readonly-root/TEMPORARY_STATE NOT_OVIRT_FIRSTBOOT +set /files/etc/sysconfig/readonly-root/STATE_LABEL CONFIG +set /files/etc/sysconfig/readonly-root/STATE_MOUNT /config +set /files/etc/sysconfig/readonly-root/READONLY yes +save +EOF +# use persistent state unless firstboot is forced +# XXX auges shellvars lens does not accept this value +sed -i 's at NOT_OVIRT_FIRSTBOOT@$(if cat /proc/cmdline|grep -qv ovirt_firstboot; then printf "yes"; else printf "no"; fi)@' /etc/sysconfig/readonly-root +# prepare mount points for local storage +mkdir -p /boot +mkdir -p /config +mkdir -p /data +mkdir -p /liveos +echo "/dev/HostVG/Config /config ext3 defaults,noauto,noatime 0 0" >> /etc/fstab + diff --git a/recipe/custom-template.ks b/recipe/custom-template.ks new file mode 100644 index 0000000..70d084b --- /dev/null +++ b/recipe/custom-template.ks @@ -0,0 +1,33 @@ +# oVirt Node image recipe +# This an example TEMPLATE for customizations. + +%include common-install.ks +# add custom installation directives here + +%include repos.ks +# add custom repos here + +%packages --excludedocs --nobase +%include common-pkgs.ks +# add custom package list here + +%end + +%post +%include common-post.ks +# add custom post-scripts here + +%end + +%include common-manifest-pre.ks + +%include common-blacklist.ks + +%post --nochroot +%include common-post-nochroot.ks +# add custom post-scripts running outside image chroot here + +%end + +%include common-manifest-post.ks + diff --git a/recipe/ovirt-node-image.ks b/recipe/ovirt-node-image.ks index 7c9361c..6fad5cd 100644 --- a/recipe/ovirt-node-image.ks +++ b/recipe/ovirt-node-image.ks @@ -1,3 +1,5 @@ +# oVirt Node image recipe + %include common-install.ks %include repos.ks @@ -8,121 +10,18 @@ %end %post -# cleanup rpmdb to allow non-matching host and chroot RPM versions -rm -f /var/lib/rpm/__db* %include common-post.ks -touch /.autorelabel - -# prepare for STATE_MOUNT in rc.sysinit -augtool <<\EOF -set /files/etc/sysconfig/readonly-root/TEMPORARY_STATE NOT_OVIRT_FIRSTBOOT -set /files/etc/sysconfig/readonly-root/STATE_LABEL CONFIG -set /files/etc/sysconfig/readonly-root/STATE_MOUNT /config -set /files/etc/sysconfig/readonly-root/READONLY yes -save -EOF -# use persistent state unless firstboot is forced -# XXX auges shellvars lens does not accept this value -sed -i 's at NOT_OVIRT_FIRSTBOOT@$(if cat /proc/cmdline|grep -qv ovirt_firstboot; then printf "yes"; else printf "no"; fi)@' /etc/sysconfig/readonly-root -# prepare mount points for local storage -mkdir -p /boot -mkdir -p /config -mkdir -p /data -mkdir -p /liveos -echo "/dev/HostVG/Config /config ext3 defaults,noauto,noatime 0 0" >> /etc/fstab %end -%post -# Create initial manifests -manifests=/tmp/manifests -mkdir -p $manifests -rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \ - > $manifests/rpm-manifest.txt -rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest.txt -du -akx --exclude=/var/cache/yum / > $manifests/file-manifest.txt -du -x --exclude=/var/cache/yum / > $manifests/dir-manifest.txt -%end +%include common-manifest-pre.ks %include common-blacklist.ks %post --nochroot -if [ -f "ovirt-authorized_keys" ]; then - echo "Adding authorized_keys to Image" - mkdir -p $INSTALL_ROOT/root/.ssh - cp -v ovirt-authorized_keys $INSTALL_ROOT/root/.ssh/authorized_keys - chown -R root:root $INSTALL_ROOT/root/.ssh - chmod 755 $INSTALL_ROOT/root/.ssh - chmod 644 $INSTALL_ROOT/root/.ssh/authorized_keys -fi - -echo "Fixing boot menu" -# remove quiet from Node bootparams, added by livecd-creator -sed -i -e 's/ quiet//' $LIVE_ROOT/isolinux/isolinux.cfg - -# add stand-alone boot entry -awk ' -BEGIN { - # append additional default boot parameters - add_boot_params="check" -} -/^label linux0/ { linux0=1 } -linux0==1 && $1=="append" { - $0=$0 " " add_boot_params - append0=$0 -} -linux0==1 && $1=="label" && $2!="linux0" { - linux0=2 - print "label stand-alone" - print " menu label Boot in stand-alone mode" - print " kernel vmlinuz0" - gsub("console=tty0", "", append0) - print append0" ovirt_standalone console=tty0" -} -{ print } -' $LIVE_ROOT/isolinux/isolinux.cfg > $LIVE_ROOT/isolinux/isolinux.cfg.standalone -mv $LIVE_ROOT/isolinux/isolinux.cfg.standalone $LIVE_ROOT/isolinux/isolinux.cfg - -cp $INSTALL_ROOT/usr/share/ovirt-node/syslinux-vesa-splash.jpg $LIVE_ROOT/isolinux/splash.jpg - -# overwrite user visible banners with the image versioning info -PACKAGE=ovirt -ln -snf $PACKAGE-release $INSTALL_ROOT/etc/redhat-release -ln -snf $PACKAGE-release $INSTALL_ROOT/etc/system-release -cp $INSTALL_ROOT/etc/$PACKAGE-release $INSTALL_ROOT/etc/issue -echo "Kernel \r on an \m (\l)" >> $INSTALL_ROOT/etc/issue -cp $INSTALL_ROOT/etc/issue $INSTALL_ROOT/etc/issue.net +%include common-post-nochroot.ks %end -%post -# Create post-image processing manifests -manifests=/tmp/manifests -mkdir -p $manifests -rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \ - > $manifests/rpm-manifest-post.txt -rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest-post.txt -du -akx --exclude=/var/cache/yum / > $manifests/file-manifest-post.txt -du -x --exclude=/var/cache/yum / > $manifests/dir-manifest-post.txt - -ver=$(rpm -q --qf '%{version}' ovirt-node) -rel=$(rpm -q --qf '%{release}' ovirt-node) -arch=$(rpm -q --qf '%{arch}' ovirt-node) -echo "oVirt Node release $ver-$rel-$arch" > $manifests/ovirt-release -tar -cvf ovirt-node-image-manifests-$ver-$rel.$arch.tar -C /tmp manifests -ln -nf ovirt-node-image-manifests-$ver-$rel.$arch.tar ovirt-node-image-manifests.tar -rm -Rf $manifests -%end - -%post --nochroot -# Move manifest tar to build directory -mv $INSTALL_ROOT/ovirt-node-image-manifests*.tar . - -# only works on x86, x86_64 -if [ "$(uname -i)" = "i386" -o "$(uname -i)" = "x86_64" ]; then - if [ ! -d $LIVE_ROOT/LiveOS ]; then mkdir -p $LIVE_ROOT/LiveOS ; fi - cp /usr/bin/livecd-iso-to-disk $LIVE_ROOT/LiveOS - cp /usr/bin/livecd-iso-to-pxeboot $LIVE_ROOT/LiveOS -fi -%end +%include common-manifest-post.ks -- 1.6.0.6 From dpierce at redhat.com Thu Apr 15 15:19:31 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Thu, 15 Apr 2010 11:19:31 -0400 Subject: [Ovirt-devel] [PATCH matahari] Refactored the Host agent. Message-ID: <1271344771-8405-1-git-send-email-dpierce@redhat.com> Replaced the previous HostWrapper class with the new HostAgent class, which more closely resembles the style of the ProcessorsAgent class. Deleted the HostWrapper class entirely. Refactored the daemon entry point to reduce the number of methods invoked in order to start or stop the HostAgent instance. Moved the NICWrapper's setupQMFObject method from private to public so that it can be invoked by the HostAgent. This is a temporary measure since the NICWrapper will be replaced by a future patch. Signed-off-by: Darryl L. Pierce --- src/host.cpp | 263 +++++++++++++--------------------------------------- src/host.h | 75 ++++----------- src/main.cpp | 57 ++++-------- src/nic.h | 2 +- src/processors.cpp | 6 + src/processors.h | 3 + 6 files changed, 111 insertions(+), 295 deletions(-) diff --git a/src/host.cpp b/src/host.cpp index ac04f47..885068b 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -37,213 +37,80 @@ using namespace std; using qpid::management::Manageable; namespace _qmf = qmf::com::redhat::matahari; -ostream& operator<<(ostream &output, const HostWrapper& host) +void +HostAgent::setup(ManagementAgent* agent) { - output << "Node" << endl << endl; - output << "UUID: " << host.uuid << endl; - output << "Hostname: " << host.hostname << endl; - output << "Memory: " << host.memory << endl; - output << "Hypervisor: " << host.hypervisor << endl; - output << "Arch: " << host.arch << endl << endl; - - vector cpus = host.cpus; - vector nics = host.nics; - - for (vector::iterator iter = cpus.begin(); - iter!= cpus.end(); - iter++) { - output << **iter << endl; - } - for (vector::iterator iter = nics.begin(); - iter!= nics.end(); - iter++) { - output << **iter << endl; + management_object = new _qmf::Host(agent, this); + agent->addObject(management_object); + + // discover the aspects of the host + processors.setup(agent, this); + + LibHalContext *hal_ctx; + int ret; + + // Get our HAL Context or die trying + hal_ctx = get_hal_ctx(); + if (!hal_ctx) + throw runtime_error("Unable to get HAL Context Structure."); + + try { + NICWrapper::fillNICInfo(this->nics, agent, hal_ctx); + + // Host UUID + char *uuid_c = get_uuid(hal_ctx); + string uuid(uuid_c); + management_object->set_uuid(uuid); + + // Hostname + char hostname_c[HOST_NAME_MAX]; + ret = gethostname(hostname_c, sizeof(hostname_c)); + if (ret != 0) + throw runtime_error("Unable to get hostname"); + string hostname(hostname_c); + management_object->set_hostname(hostname); + + // Hypervisor, arch, memory + management_object->set_memory(0); + management_object->set_hypervisor("unknown"); + management_object->set_arch("unknown"); + + virConnectPtr connection; + virNodeInfo info; + connection = virConnectOpenReadOnly(NULL); + if (connection) { + const char *hv = virConnectGetType(connection); + if (hv != NULL) + management_object->set_hypervisor(hv); + ret = virNodeGetInfo(connection, &info); + if (ret == 0) { + management_object->set_arch(info.model); + management_object->set_memory(info.memory); + } } + virConnectClose(connection); - output << "End Node" << endl; - return output; -} + management_object->set_beeping(false); -void HostWrapper::doLoop(void) -{ - // Someday we might update statistics too! - while(1) + // setup the nic objects + for(vector::iterator iter = nics.begin(); + iter != nics.end(); + iter++) { - // update all statistics - processors.update_load_averages(); - sleep(5); - } -} - -void HostWrapper::setupQMFObjects(ManagementAgent *agent) -{ - // Set up Host object - mgmt_object = new _qmf::Host(agent, this); - agent->addObject(mgmt_object); - syncQMFHostObject(); - - processors.setup(agent, this); - - // Iterate over list and set up CPU objects - for (vector::iterator iter = cpus.begin(); - iter!= cpus.end(); - iter++) { - (*iter)->setupQMFObject(agent, this); - } - // Iterate over list and set up NIC objects - for (vector::iterator iter = nics.begin(); - iter!= nics.end(); - iter++) { (*iter)->setupQMFObject(agent, this); - } -} - -void HostWrapper::syncQMFHostObject(void) -{ - mgmt_object->set_uuid(uuid); - mgmt_object->set_hostname(hostname); - mgmt_object->set_memory(memory); - mgmt_object->set_hypervisor(hypervisor); - mgmt_object->set_arch(arch); - mgmt_object->set_beeping(beeping); -} - -void HostWrapper::cleanupQMFObjects(void) -{ - // Clean up Host object - mgmt_object->resourceDestroy(); - - // Iterate over list and clean up CPU objects - for (vector::iterator iter = cpus.begin(); - iter!= cpus.end(); - iter++) { - (*iter)->cleanupQMFObject(); - } - // Iterate over list and clean up NIC objects - for (vector::iterator iter = nics.begin(); - iter!= nics.end(); - iter++) { - (*iter)->cleanupQMFObject(); - } -} - -void HostWrapper::cleanupMemberObjects(void) -{ - // Get rid of the CPUWrapper objects for this host - for (vector::iterator iter = cpus.begin(); iter != cpus.end();) { - delete (*iter); - iter = cpus.erase(iter); - } - // Get rid of the NICWrapper objects for this host - for (vector::iterator iter = nics.begin(); iter != nics.end();) { - delete (*iter); - iter = nics.erase(iter); - } -} - -void HostWrapper::disposeHostWrapper() -{ - if (hostSingleton == NULL) - return; - - hostSingleton->cleanupQMFObjects(); - hostSingleton->cleanupMemberObjects(); - - delete hostSingleton; - hostSingleton = NULL; -} - -HostWrapper* HostWrapper::setupHostWrapper(ManagementAgent *agent) -{ - if (hostSingleton != NULL) - return hostSingleton; - - LibHalContext *hal_ctx; - int ret; - - // Get our HAL Context or die trying - hal_ctx = get_hal_ctx(); - if (!hal_ctx) - throw runtime_error("Unable to get HAL Context Structure."); - - HostWrapper *host = new HostWrapper(); - - try { - CPUWrapper::fillCPUInfo(host->cpus, agent); - NICWrapper::fillNICInfo(host->nics, agent, hal_ctx); - - // Host UUID - char *uuid_c = get_uuid(hal_ctx); - string uuid(uuid_c); - host->uuid = uuid; - - // Hostname - char hostname_c[HOST_NAME_MAX]; - ret = gethostname(hostname_c, sizeof(hostname_c)); - if (ret != 0) - throw runtime_error("Unable to get hostname"); - string hostname(hostname_c); - host->hostname = hostname; - - // Hypervisor, arch, memory - host->memory = 0; - host->hypervisor = "unknown"; - host->arch = "unknown"; - - virConnectPtr connection; - virNodeInfo info; - connection = virConnectOpenReadOnly(NULL); - if (connection) { - const char *hv = virConnectGetType(connection); - if (hv != NULL) - host->hypervisor = hv; - ret = virNodeGetInfo(connection, &info); - if (ret == 0) { - host->arch = info.model; - host->memory = info.memory; - } - } - virConnectClose(connection); - - host->beeping = false; - } - catch (...) { - host->cleanupMemberObjects(); - put_hal_ctx(hal_ctx); - delete host; - throw; - } - - // Close the Hal Context + } + } + catch (...) { put_hal_ctx(hal_ctx); + throw; + } - host->setupQMFObjects(agent); - - // Setup singleton reference and return - hostSingleton = host; - return hostSingleton; + // Close the Hal Context + put_hal_ctx(hal_ctx); } -void HostWrapper::reboot() +void +HostAgent::update(void) { - system("shutdown -r now"); -} - -void HostWrapper::shutdown() -{ - system("shutdown -h now"); -} - -Manageable::status_t -HostWrapper::ManagementMethod(uint32_t methodId, Args& args, string& text) -{ - switch(methodId) { - case _qmf::Host::METHOD_SHUTDOWN: - shutdown(); - return Manageable::STATUS_OK; - case _qmf::Host::METHOD_REBOOT: - reboot(); - return Manageable::STATUS_OK; - } - return Manageable::STATUS_NOT_IMPLEMENTED; + processors.update(); } diff --git a/src/host.h b/src/host.h index 148c91f..c19da3e 100644 --- a/src/host.h +++ b/src/host.h @@ -1,3 +1,6 @@ +#ifndef __HOST_H +#define __HOST_H + /* host.h - Copyright (C) 2009 Red Hat, Inc. * Written by Arjun Roy * @@ -32,67 +35,25 @@ using namespace std; using qpid::management::Manageable; -class HostWrapper : public Manageable +class HostAgent : public Manageable { - static HostWrapper *hostSingleton; - - friend ostream& operator<<(ostream &output, const HostWrapper& host); - - // Host Parameters - string uuid; - string hostname; - string hypervisor; - string arch; - bool beeping; - int memory; - - // Aggregated components - vector cpus; - vector nics; - - ProcessorsAgent processors; - - // QMF related fields - ManagementAgent *agent; - qmf::com::redhat::matahari::Host *mgmt_object; - - // Methods to put up / take down QMF objects - void setupQMFObjects(ManagementAgent *agent); - void cleanupQMFObjects(void); - - // Housekeeping methods - void syncQMFHostObject(void); - void cleanupMemberObjects(void); - - // Host functionality - void reboot(); - void shutdown(); - - // Constructors and Destructor are private - HostWrapper() {} - HostWrapper(const HostWrapper &) {} - ~HostWrapper() {} + private: + qmf::com::redhat::matahari::Host* management_object; + ProcessorsAgent processors; + vector nics; public: - // Factory methods to create/dispose of the singleton - static HostWrapper *setupHostWrapper(ManagementAgent *agent); - static void disposeHostWrapper(void); - - // QMF Methods - ManagementObject* GetManagementObject(void) const { return mgmt_object; } - status_t ManagementMethod(uint32_t methodId, Args& args, string& text); + HostAgent() {} + virtual ~HostAgent() {} - // Field Accessors - const string &getUUID(void) { return uuid; } - const string &getHostname(void) { return hostname; } - const string &getHypervisor(void) { return hypervisor; } - const string &getArch(void) { return arch; } - bool isBeeping(void) { return beeping; } - int getMemory(void) { return memory; } + ManagementObject* GetManagementObject(void) const { return management_object; } - const vector &getCPUList(void) { return cpus; } - const vector &getNICList(void) { return nics; } + void setup(ManagementAgent* agent); + void update(void); - // Main Loop - void doLoop(void); + // agent methods + void shutdown(void); + void reboot(void); }; + +#endif // __HOST_H diff --git a/src/main.cpp b/src/main.cpp index 002a02e..8493864 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,18 +42,11 @@ namespace _qmf = qmf::com::redhat::matahari; // Global Variables ManagementAgent::Singleton* singleton; -HostWrapper* HostWrapper::hostSingleton = NULL; -void cleanup(void) +void +shutdown(int /*signal*/) { - HostWrapper::disposeHostWrapper(); - delete singleton; -} - -void shutdown(int) -{ - cleanup(); - exit(0); + exit(0); } static void @@ -69,21 +62,22 @@ print_usage() printf("\t-p | --port specify broker port.\n"); } -int do_main(int argc, char **argv) +int +main(int argc, char **argv) { int arg; int idx = 0; bool daemonize = false; bool gssapi = false; bool verbose = false; - char *host = NULL; + char *servername = NULL; char *username = NULL; char *service = NULL; - int port = 5672; + int serverport = 5672; ConnectionSettings settings; ManagementAgent *agent; - HostWrapper *hostWrapper; + HostAgent host; struct option opt[] = { {"help", no_argument, NULL, 'h'}, @@ -131,7 +125,7 @@ int do_main(int argc, char **argv) break; case 'p': if (optarg) { - port = atoi(optarg); + serverport = atoi(optarg); } else { print_usage(); exit(1); @@ -139,7 +133,7 @@ int do_main(int argc, char **argv) break; case 'b': if (optarg) { - host = strdup(optarg); + servername = strdup(optarg); } else { print_usage(); exit(1); @@ -169,8 +163,8 @@ int do_main(int argc, char **argv) signal(SIGINT, shutdown); // Connect to the broker - settings.host = host ? host : "127.0.0.1"; - settings.port = port; + settings.host = servername ? servername : "127.0.0.1"; + settings.port = serverport; if (username != NULL) { settings.username = username; @@ -185,28 +179,13 @@ int do_main(int argc, char **argv) agent->init(settings, 5, false, ".magentdata"); // Get the info and post it to the broker - try { - hostWrapper = HostWrapper::setupHostWrapper(agent); - } - catch (...) { - cleanup(); - throw; - } + host.setup(agent); - // Main loop - hostWrapper->doLoop(); + while(1) + { + host.update(); + sleep(5); + } - // And we are done - cleanup(); return 0; } - -int main(int argc, char** argv) -{ - try { - return do_main(argc, argv); - } - catch(std::exception& e) { - cout << "Top Level Exception: " << e.what() << endl; - } -} diff --git a/src/nic.h b/src/nic.h index 15f31fb..c79ecf9 100644 --- a/src/nic.h +++ b/src/nic.h @@ -47,7 +47,6 @@ class NICWrapper : public Manageable qmf::com::redhat::matahari::NIC *mgmt_object; // Methods to put up / take down QMF Objects - void setupQMFObject(ManagementAgent *agent, Manageable *parent); void cleanupQMFObject(void); void syncQMFObject(void); @@ -77,6 +76,7 @@ class NICWrapper : public Manageable int identifyNIC(int seconds); public: + void setupQMFObject(ManagementAgent *agent, Manageable *parent); // Factory like method static void fillNICInfo(vector &nics, ManagementAgent *agent, diff --git a/src/processors.cpp b/src/processors.cpp index 4317b1f..cff66d9 100644 --- a/src/processors.cpp +++ b/src/processors.cpp @@ -57,6 +57,12 @@ ProcessorsAgent::setup(ManagementAgent* agent, Manageable* parent) } void +ProcessorsAgent::update(void) const +{ + update_load_averages(); +} + +void ProcessorsAgent::update_load_averages(void) const { double load_average; diff --git a/src/processors.h b/src/processors.h index 3e46b16..17a6a6a 100644 --- a/src/processors.h +++ b/src/processors.h @@ -42,6 +42,9 @@ class ProcessorsAgent : public Manageable void setup(ManagementAgent* agent, Manageable* parent); + void update(void) const; + + private: // agent methods void update_load_averages(void) const; }; -- 1.6.6.1 From jboggs at redhat.com Thu Apr 15 20:09:54 2010 From: jboggs at redhat.com (Joey Boggs) Date: Thu, 15 Apr 2010 16:09:54 -0400 Subject: [Ovirt-devel] [PATCH node] RESEND: prevent hostvg and sharedroot from accepting same drive input Message-ID: <1271362194-23955-1-git-send-email-jboggs@redhat.com> resending after rebase --- scripts/ovirt-config-storage | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index df36752..10c33fa 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -376,7 +376,19 @@ do_configure() EOF printf "\n\nPlease select the disk to use for the HostVG.\n\n" - HOSTVGDRIVE=$(get_dev_name) || return 0 + while true; do + HOSTVGDRIVE=$(get_dev_name) || return 0 + if [ "$OVIRT_SHARED_ROOT" == "y" ]; then + if [ "$ROOTDRIVE" == "$HOSTVGDRIVE" ]; then + printf "\n\nRoot Drive and HostVG drive must be different when shared\n\n" + return 1 + else + break; + fi + fi + break; + done + local skipped=false if check_existing_hostvg "$HOSTVGDRIVE" devs; then for dev in $devs -- 1.6.6.1 From apevec at gmail.com Fri Apr 16 17:51:00 2010 From: apevec at gmail.com (Alan Pevec) Date: Fri, 16 Apr 2010 19:51:00 +0200 Subject: [Ovirt-devel] RFC: Advanced Storage Configuration In-Reply-To: <1271078300.3715.31.camel@localhost> References: <1271078300.3715.31.camel@localhost> Message-ID: On Mon, Apr 12, 2010 at 3:18 PM, Ricardo Marin Matinata wrote: > - Addition of a new top level install menu called "Advanced Storage > Configuration" where one can select a storage device to which should the > guest's images be stored. > - Next to the device selection, creates a new volume group - > HostVG-Images - to be mounted at /images > - Perform adjustments do /var/lib/libvirt/images "mount binds" > against /images This sound good, I would just like to extend this and allow also separation of swap LV into separate VG. It also makes sense to organize all of these option as a sub-menu under storage configuration. One more aspect is to extend the syntax of "storage_vol" boot parameter to support autoinstalls with advanced storage configurations: storage_vol=,,,:... instead of current format: storage_vol=BOOT_MB:SWAP_MB:ROOT_MB:CONFIG_MB:LOGGING_MB:DATA_MB Any other ideas what else should we have in the storage configuration sub-menu? Alan From pmyers at redhat.com Fri Apr 16 18:24:58 2010 From: pmyers at redhat.com (Perry Myers) Date: Fri, 16 Apr 2010 14:24:58 -0400 Subject: [Ovirt-devel] RFC: Advanced Storage Configuration In-Reply-To: References: <1271078300.3715.31.camel@localhost> Message-ID: <4BC8AB7A.8070304@redhat.com> On 04/16/2010 01:51 PM, Alan Pevec wrote: > On Mon, Apr 12, 2010 at 3:18 PM, Ricardo Marin Matinata > wrote: >> - Addition of a new top level install menu called "Advanced Storage >> Configuration" where one can select a storage device to which should the >> guest's images be stored. >> - Next to the device selection, creates a new volume group - >> HostVG-Images - to be mounted at /images >> - Perform adjustments do /var/lib/libvirt/images "mount binds" >> against /images > > This sound good, I would just like to extend this and allow also > separation of swap LV into separate VG. > It also makes sense to organize all of these option as a sub-menu > under storage configuration. > One more aspect is to extend the syntax of "storage_vol" boot > parameter to support autoinstalls with advanced storage > configurations: > > storage_vol=,,,:... > > instead of current format: > storage_vol=BOOT_MB:SWAP_MB:ROOT_MB:CONFIG_MB:LOGGING_MB:DATA_MB > > Any other ideas what else should we have in the storage configuration sub-menu? This all sounds good. Only thing we also discussed was swap encryption Perry From dpierce at redhat.com Mon Apr 19 18:42:31 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Mon, 19 Apr 2010 14:42:31 -0400 Subject: [Ovirt-devel] [PATCH matahari] Replaces the existing HAL code for ProcessorAgent with udev. Message-ID: <1271702551-29548-1-git-send-email-dpierce@redhat.com> Stripped out the HAL support code and replaced with calls to udev. The remainder of the code to extract CPU details parses through the /proc/cpuinfo file since udev/sysfs will not return such information. Signed-off-by: Darryl L. Pierce --- configure.ac | 3 +- src/Makefile.am | 4 +- src/processors.cpp | 94 +++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 79 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index 9102c66..c51c23e 100644 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,7 @@ AM_INIT_AUTOMAKE AC_PROG_CXX AC_PROG_CC AC_PROG_CPP -AC_CHECK_HEADERS([arpa/inet.h netinet/in.h sys/ioctl.h sys/socket.h unistd.h]) +AC_CHECK_HEADERS([arpa/inet.h netinet/in.h sys/ioctl.h sys/socket.h unistd.h libudev.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL @@ -19,6 +19,7 @@ PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.2.12) PKG_CHECK_MODULES(HAL, hal >= 0.5.12) PKG_CHECK_MODULES(LIBVIRT, libvirt >= 0.6.2) PKG_CHECK_MODULES(PCRE, libpcre >= 7.8) +PKG_CHECK_MODULES(UDEV, libudev >= 145) # Checks for library functions. AC_CHECK_FUNCS([gethostname inet_ntoa socket]) diff --git a/src/Makefile.am b/src/Makefile.am index ee30443..b4668b9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -INCLUDES = -I$(top_srcdir)/src/qmf/com/redhat/matahari $(HAL_CFLAGS) $(LIBVIRT_CFLAGS) $(PCRE_CFLAGS) +INCLUDES = -I$(top_srcdir)/src/qmf/com/redhat/matahari $(HAL_CFLAGS) $(LIBVIRT_CFLAGS) $(PCRE_CFLAGS) $(UDEV_CFLAGS) sbin_PROGRAMS = matahari @@ -41,6 +41,6 @@ CLEANFILES = $(generated_file_list) $(first) matahari_CPPFLAGS = -fno-strict-aliasing matahari_LDFLAGS = -L/usr/local/lib -matahari_LDADD = -lqmf $(HAL_LIBS) $(LIBVIRT_LIBS) $(PCRE_LIBS) +matahari_LDADD = -lqmf $(HAL_LIBS) $(LIBVIRT_LIBS) $(PCRE_LIBS) $(UDEV_LIBS) dist_pkgdata_DATA = schema.xml diff --git a/src/processors.cpp b/src/processors.cpp index 4317b1f..30a2837 100644 --- a/src/processors.cpp +++ b/src/processors.cpp @@ -17,25 +17,19 @@ * also available at http://www.gnu.org/copyleft/gpl.html. */ -#include +#include "processors.h" #include -#include -#include -#include -#include - -#include - +#include #include -#include "hal.h" -#include "processors.h" +// TODO remove this wrapper once rhbz#583747 is fixed +extern "C" { +#include +} using namespace std; namespace _qmf = qmf::com::redhat::matahari; -extern DBusError dbus_error; - void ProcessorsAgent::setup(ManagementAgent* agent, Manageable* parent) { @@ -43,17 +37,79 @@ ProcessorsAgent::setup(ManagementAgent* agent, Manageable* parent) management_object = new _qmf::Processors(agent, this, parent); agent->addObject(management_object); - LibHalContext* context = get_hal_ctx(); + int core_count = 0; + string model = "unknown"; + + struct udev* udev = udev_new(); + struct udev_enumerate* enumerator = udev_enumerate_new(udev); + + udev_enumerate_add_match_property(enumerator, "DRIVER", "processor"); + if(!udev_enumerate_scan_devices(enumerator)) + { + struct udev_list_entry* entries = udev_enumerate_get_list_entry(enumerator); + struct udev_list_entry* entry; + + udev_list_entry_foreach(entry, entries) + { + core_count++; + } + } + + udev_enumerate_unref(enumerator); + udev_unref(udev); + + ifstream input("/proc/cpuinfo"); + if(input.is_open()) + { + string regexstr = "(.*\\S)\\s*:\\s*(\\S.*)"; + int expected = 3; + int found[expected * 3]; + const char* pcre_error; + int pcre_error_offset; + pcre* regex; + bool done = false; + bool started = false; + + regex = pcre_compile(regexstr.c_str(), 0, &pcre_error, &pcre_error_offset, NULL); + if(!regex) { throw runtime_error("Unable to compile regular expression."); } + + while(!input.eof() && !done) + { + string line; + + getline(input, line); + int match = pcre_exec(regex, NULL, line.c_str(), line.length(), + 0, PCRE_NOTEMPTY,found, expected * 3); - int num_results; - char** processors = libhal_find_device_by_capability(context,"processor", &num_results, &dbus_error); + if(match == expected) + { + string name = line.substr(found[2], found[3] - found[2]); + string value = line.substr(found[4], found[5] - found[4]); - if (!processors) - throw runtime_error("Error: could not query processors via HAL."); + // if we're at a second processor and we've already started, then we're done + if (name == "processor") + { + if (started) + { + done = true; + } + else + { + started = true; + } + } + else + { + if(name == "model name") model = value; + } + } + } + input.close(); + } // populate the managed object's values - management_object->set_model(libhal_device_get_property_string(context, processors[0], "info.product", &dbus_error)); - management_object->set_cores(num_results); + management_object->set_model(model); + management_object->set_cores(core_count); } void -- 1.6.6.1 From jboggs at redhat.com Mon Apr 19 18:55:02 2010 From: jboggs at redhat.com (Joey Boggs) Date: Mon, 19 Apr 2010 14:55:02 -0400 Subject: [Ovirt-devel] [PATCH] enable iscsi hostvg setup and move all hostvg operations under create_hostvg() Message-ID: <1271703302-17740-1-git-send-email-jboggs@redhat.com> --- scripts/ovirt-config-storage | 190 +++++++++++++++++++++++------------------ 1 files changed, 107 insertions(+), 83 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index df36752..9ff42d9 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -354,6 +354,12 @@ do_configure() BOOTDRIVE=$(get_dev_name) || return 0 get_drive_size "$BOOTDRIVE" BOOTDRIVESPACE echo "$BOOTDRIVE" + if ask_yes_or_no "Enable HostVG Storage (y/n)?"; then + OVIRT_ISCSI_HOSTVG="y" + HOSTVGDRIVE=$(get_dev_name) || return 0 + get_drive_size "$HOSTVGDRIVE" + echo "$HOSTVGDRIVE" + fi else printf "\n\nPlease select the disk to use for the Root.\n\n" ROOTDRIVE=$(get_dev_name) || return 0 @@ -416,8 +422,11 @@ EOF fi local space_left=$HOSTVGDRIVESPACE - if [ "$OVIRT_ISCSI_ENABLED" == "y" ]; then - partlist="boot" # swap root config logging data" + if [[ "$OVIRT_ISCSI_ENABLED" == "y" && "$OVIRT_ISCSI_HOSTVG" != "y" ]]; then + partlist="boot" + local space_left=$BOOTDRIVESPACE + elif [[ "$OVIRT_ISCSI_ENABLED" == "y" && "$OVIRT_ISCSI_HOSTVG" == "y" ]]; then + partlist="boot swap config logging data" local space_left=$BOOTDRIVESPACE elif [ "$OVIRT_ROOT_INSTALL" == "n" ]; then partlist="swap config logging data" @@ -469,7 +478,6 @@ EOF # save input variables augtool < This class has been replaced by the ProcessorsAgent. Signed-off-by: Darryl L. Pierce --- src/Makefile.am | 4 - src/cpu.cpp | 216 ------------------------------------------------------- src/cpu.h | 111 ---------------------------- src/host.cpp | 24 ------ src/host.h | 3 - src/schema.xml | 16 ---- 6 files changed, 0 insertions(+), 374 deletions(-) delete mode 100644 src/cpu.cpp delete mode 100644 src/cpu.h diff --git a/src/Makefile.am b/src/Makefile.am index b4668b9..7606e20 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,8 +6,6 @@ first = qmf/com/redhat/matahari/Host.cpp generated_file_list = \ qmf/com/redhat/matahari/ArgsNICIdentify_nic.h \ - qmf/com/redhat/matahari/CPU.cpp \ - qmf/com/redhat/matahari/CPU.h \ qmf/com/redhat/matahari/Host.h \ qmf/com/redhat/matahari/NIC.cpp \ qmf/com/redhat/matahari/NIC.h \ @@ -19,8 +17,6 @@ generated_file_list = \ nodist_matahari_SOURCES = $(generated_file_list) $(first) matahari_SOURCES = \ - cpu.cpp \ - cpu.h \ hal.cpp \ hal.h \ host.cpp \ diff --git a/src/cpu.cpp b/src/cpu.cpp deleted file mode 100644 index 453c571..0000000 --- a/src/cpu.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* cpu.cpp - Copyright (C) 2009 Red Hat, Inc. - * Written by Arjun Roy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. A copy of the GNU General Public License is - * also available at http://www.gnu.org/copyleft/gpl.html. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "cpu.h" -#include "qmf/com/redhat/matahari/CPU.h" - -using namespace std; -namespace _qmf = qmf::com::redhat::matahari; - -template targetType convert(const std::string& str) -{ - istringstream i(str); - targetType t; - if (!(i >> t)) - throw invalid_argument("Conversion failure for " + str); - return t; -} - -ostream& operator<<(ostream& output, const CPUWrapper& cpu) -{ - output << "Processor" << endl; - output << "CPU #: " << cpu.cpunum << endl; - output << "Core #: " << cpu.corenum << endl; - output << "Num. Cores: " << cpu.numcores << endl; - output << "Model: " << cpu.model << endl; - output << "Family: " << cpu.family << endl; - output << "CPU ID Level: " << cpu.cpuid_lvl << endl; - output << "Speed (Mhz): " << cpu.speed << endl; - output << "Cache (kB): " << cpu.cache << endl; - output << "Vendor: " << cpu.vendor << endl; - output << "Flags: " << cpu.flags << endl; - return output; -} - -void CPUWrapper::setupQMFObject(ManagementAgent *agent, Manageable *parent) -{ - mgmt_object = new _qmf::CPU(agent, this, parent); - agent->addObject(mgmt_object); - syncQMFObject(); -} - -void CPUWrapper::cleanupQMFObject(void) -{ - mgmt_object->resourceDestroy(); -} - -void CPUWrapper::syncQMFObject(void) -{ - mgmt_object->set_cpunum(cpunum); - mgmt_object->set_corenum(corenum); - mgmt_object->set_numcores(numcores); - mgmt_object->set_model(model); - mgmt_object->set_family(family); - mgmt_object->set_cpuid_lvl(cpuid_lvl); - mgmt_object->set_speed(speed); - mgmt_object->set_cache(cache); - mgmt_object->set_vendor(vendor); - mgmt_object->set_flags(flags); -} - -/** - * void fillCPUInfo(vector &cpus, ManagementAgent *agent) - * - * Takes in a vector of CPUWrapper object pointers and populates it with - * CPUs found by querying /proc/cpuinfo. NOTE: This method is very sensitive - * to the output format of /proc/cpuinfo. - * - * Throws a runtime error if file io is unsuccessful. - */ -void CPUWrapper::fillCPUInfo(vector &cpus, ManagementAgent *agent) -{ - string line; - string regexstr = "(.*\\S)\\s*:\\s*(\\S.*)"; - int desiredmatches = 3; // Match string and two captured substrings - int matchArraySize = desiredmatches * 3; - int results[matchArraySize]; // pcre requires this much - const char *pcre_err; - int pcre_err_offset; - pcre *regex; - - regex = pcre_compile(regexstr.c_str(), // input - 0, // no options - &pcre_err, // where to place static error str - &pcre_err_offset, // index in regex string of error - NULL // use the default charset - ); - if (!regex) { - ostringstream err; - err << "Error: Bad regex: " << regexstr << endl; - err << "Error was: " << pcre_err << " at " << pcre_err_offset << endl; - throw runtime_error(err.str()); - } - - ifstream cpuinfo("/proc/cpuinfo", ios::in); - if (!cpuinfo.is_open() || cpuinfo.fail()) - throw runtime_error("Unable to open /proc/cpuinfo"); - - // Each line is a key:value pair. New processor - // delimiter is the "processor" key. - while (!cpuinfo.eof()) { - getline(cpuinfo, line); - int match = pcre_exec(regex, // Regex - NULL, // No extra optimizations - line.c_str(), // Input - line.length(), // Input length - 0, // Start offset - PCRE_NOTEMPTY, // options bitvector - results, // Results vector - matchArraySize // Vector size - ); - - if (match == desiredmatches) { - if (line.substr(results[2], results[3] - results[2]) == "processor") { - // Start pulling data for a new processor - int cpunum = -1; - int coreid = -1; - int cpucores = -1; - int model = -1; - int family = -1; - int cpuid_lvl = -1; - double speed = -1; - int cache = -1; - string vendor = "unknown"; - string flags = "unknown"; - - // Get the cpu # from this line - cpunum = convert(line.substr(results[4], - results[5] - results[4])); - // And now grab the rest - do { - getline(cpuinfo, line); - match = pcre_exec(regex, // Regex - NULL, // No extra optimizations - line.c_str(), // Input - line.length(), // Input length - 0, // Start offset - PCRE_NOTEMPTY, // options bitvector - results, // Results vector - matchArraySize // Vector size - ); - - if (match == desiredmatches) { - string key = line.substr(results[2], - results[3] - results[2]); - - string value = line.substr(results[4], - results[5] - results[4]); - - if (key == "core id") { - coreid = convert(value); - } else if (key == "cpu cores") { - cpucores = convert(value); - } else if (key == "model") { - model = convert(value); - } else if (key == "cpu family") { - family = convert(value); - } else if (key == "cpuid level") { - cpuid_lvl = convert(value); - } else if (key == "cpu MHz") { - speed = convert(value); - } else if (key == "cache size") { - int space = value.find(' '); - cache = convert(value.substr(0, space)); - } else if (key == "vendor_id") { - vendor = value; - } else if (key == "flags") { - flags = value; - } - } - } - while (line != ""); - - // Got all the data. Add the CPU to our list - CPUWrapper *cpu = new CPUWrapper(cpunum, - coreid, - cpucores, - model, - family, - cpuid_lvl, - speed, - cache, - vendor, - flags); - cpus.push_back(cpu); - } - } - else - continue; - } - cpuinfo.close(); -} diff --git a/src/cpu.h b/src/cpu.h deleted file mode 100644 index bb3a9b3..0000000 --- a/src/cpu.h +++ /dev/null @@ -1,111 +0,0 @@ -/* cpu.h - Copyright (C) 2009 Red Hat, Inc. - * Written by Arjun Roy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. A copy of the GNU General Public License is - * also available at http://www.gnu.org/copyleft/gpl.html. - */ - -#include -#include -#include - -#include "qmf/com/redhat/matahari/CPU.h" - -using namespace qpid::management; -using namespace std; - -using qpid::management::Manageable; - -class CPUWrapper : public Manageable -{ - friend ostream& operator<<(ostream &output, const CPUWrapper& cpu); - friend class HostWrapper; - - // CPU Parameters - int cpunum; - int corenum; - int numcores; - - int model; - int family; - int cpuid_lvl; - double speed; - int cache; - - string vendor; - string flags; - - // QMF related fields - ManagementAgent *agent; - qmf::com::redhat::matahari::CPU *mgmt_object; - - // Methods to put up / take down QMF Objects - void setupQMFObject(ManagementAgent *agent, Manageable *parent); - void cleanupQMFObject(void); - void syncQMFObject(void); - - // Constructors and Destructor are private - CPUWrapper() {} - CPUWrapper(const CPUWrapper&) {} - ~CPUWrapper() {} - - CPUWrapper(int cpunum__, - int corenum__, - int numcores__, - int model__, - int family__, - int cpuid_lvl__, - double speed__, - int cache__, - const string &vendor__, - const string &flags__) { - cpunum = cpunum__; - corenum = corenum__; - numcores = numcores__; - model = model__; - family = family__; - cpuid_lvl = cpuid_lvl__; - speed = speed__; - cache = cache__; - vendor = vendor__; - flags = flags__; - } - -public: - - // Factory like method - static void fillCPUInfo(vector &cpus, ManagementAgent *agent); - - // QMF Methods - ManagementObject* GetManagementObject(void) const { return mgmt_object; } - - status_t ManagementMethod(uint32_t methodId, Args& args, string& text) { - return STATUS_NOT_IMPLEMENTED; - } - - // Field Accessors - int getCpunum(void) { return cpunum; } - int getCorenum(void) { return corenum; } - int getNumcores(void) { return numcores; } - - int getModel(void) { return model; } - int getFamily(void) { return family; } - int getCpuid_Lvl(void) { return cpuid_lvl; } - double getSpeed(void) { return speed; } - int getCache(void) { return cache; } - - const string &getVendor(void) { return vendor; } - const string &getFlags(void) { return flags; } -}; diff --git a/src/host.cpp b/src/host.cpp index ac04f47..b3ed51f 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -46,14 +46,8 @@ ostream& operator<<(ostream &output, const HostWrapper& host) output << "Hypervisor: " << host.hypervisor << endl; output << "Arch: " << host.arch << endl << endl; - vector cpus = host.cpus; vector nics = host.nics; - for (vector::iterator iter = cpus.begin(); - iter!= cpus.end(); - iter++) { - output << **iter << endl; - } for (vector::iterator iter = nics.begin(); iter!= nics.end(); iter++) { @@ -84,12 +78,6 @@ void HostWrapper::setupQMFObjects(ManagementAgent *agent) processors.setup(agent, this); - // Iterate over list and set up CPU objects - for (vector::iterator iter = cpus.begin(); - iter!= cpus.end(); - iter++) { - (*iter)->setupQMFObject(agent, this); - } // Iterate over list and set up NIC objects for (vector::iterator iter = nics.begin(); iter!= nics.end(); @@ -113,12 +101,6 @@ void HostWrapper::cleanupQMFObjects(void) // Clean up Host object mgmt_object->resourceDestroy(); - // Iterate over list and clean up CPU objects - for (vector::iterator iter = cpus.begin(); - iter!= cpus.end(); - iter++) { - (*iter)->cleanupQMFObject(); - } // Iterate over list and clean up NIC objects for (vector::iterator iter = nics.begin(); iter!= nics.end(); @@ -129,11 +111,6 @@ void HostWrapper::cleanupQMFObjects(void) void HostWrapper::cleanupMemberObjects(void) { - // Get rid of the CPUWrapper objects for this host - for (vector::iterator iter = cpus.begin(); iter != cpus.end();) { - delete (*iter); - iter = cpus.erase(iter); - } // Get rid of the NICWrapper objects for this host for (vector::iterator iter = nics.begin(); iter != nics.end();) { delete (*iter); @@ -169,7 +146,6 @@ HostWrapper* HostWrapper::setupHostWrapper(ManagementAgent *agent) HostWrapper *host = new HostWrapper(); try { - CPUWrapper::fillCPUInfo(host->cpus, agent); NICWrapper::fillNICInfo(host->nics, agent, hal_ctx); // Host UUID diff --git a/src/host.h b/src/host.h index 148c91f..bdf43fa 100644 --- a/src/host.h +++ b/src/host.h @@ -23,7 +23,6 @@ #include "qmf/com/redhat/matahari/Host.h" -#include "cpu.h" #include "nic.h" #include "processors.h" @@ -47,7 +46,6 @@ class HostWrapper : public Manageable int memory; // Aggregated components - vector cpus; vector nics; ProcessorsAgent processors; @@ -90,7 +88,6 @@ class HostWrapper : public Manageable bool isBeeping(void) { return beeping; } int getMemory(void) { return memory; } - const vector &getCPUList(void) { return cpus; } const vector &getNICList(void) { return nics; } // Main Loop diff --git a/src/schema.xml b/src/schema.xml index f9c6f6b..e6b54db 100644 --- a/src/schema.xml +++ b/src/schema.xml @@ -23,22 +23,6 @@ - - - - - - - - - - - - - - - - -- 1.6.6.1 From dpierce at redhat.com Mon Apr 19 20:42:52 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Mon, 19 Apr 2010 16:42:52 -0400 Subject: [Ovirt-devel] Representing networks on the node... Message-ID: <20100419204252.GO3410@mcpierce-desktop.usersys.redhat.com> I meant to send this out a while back, but don't see that I ever actually sent it. I'm currently reworking the matahari agents to clean up the code, refactor elements and also enhance the agents. And the one that has me stumped is the NIC agent. The main problem is that, if we're going to represent network interfaces, we shouldn't limit it to only physical devices. Instead, I feel that it should represent all network devices, including virtual interfaces, bridges, etc. So what I was thinking about was to have an agent to represent the physical device, and then agents under it to represent the network(s) to which it is associated. So the physical device would represented by a NetworkDevice agent with the following properties/methods: * mac_address - address for device * vendor - the NIC manufacturer * model - the NIC model * interface - the system iface name * create() - creates a network definition * destroy() - deletes the network definition * blink() - causes the device to blink, so it can be identified The properties are, hopefully, pretty clear. The methods will likely need a little more clarification. create() - Takes arguments that configure the network to which the device is to be connected; i.e., the address, netmask, gateway, DNS entries, whether to use DHCP, etc. This can become a very heavy method so might logically be broken up into related methods. destroy() - The reverse of connect(), it would take down an active network. An option argument would indicate to also delete the configuration file(s) for the network. The Network agent would represent the networks to which a NetworkDevice is connected. It has a parent reference to the NetworkDevice parent, and has the following properties/methods: * active - reports whether the interface is up or down * address - the assigned network address [1] * netmask * gateway * DNS * bridge - reports whether the interface is a bridge * virtual - reports whether the interface is virtual * up() - brings the interface up * down() - stops the interface Granted, this is not a complete list: here is where I really would like to kick around some ideas of how we ought to implement things if we go in this direction. In addition to being directed by the management server, the status of Network agents would be affected by local messaging (dbus?) to keep its status as real-time as possible. Ideas? Questions? [1] - duplication is needed to support IPv6 -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From imain at redhat.com Tue Apr 20 16:21:45 2010 From: imain at redhat.com (Ian Main) Date: Tue, 20 Apr 2010 09:21:45 -0700 Subject: [Ovirt-devel] [PATCH matahari] Refactored the Host agent. In-Reply-To: <1271344771-8405-1-git-send-email-dpierce@redhat.com> References: <1271344771-8405-1-git-send-email-dpierce@redhat.com> Message-ID: <1271780505.5621.26.camel@localhost.localdomain> On Thu, 2010-04-15 at 11:19 -0400, Darryl L. Pierce wrote: > Replaced the previous HostWrapper class with the new HostAgent class, > which more closely resembles the style of the ProcessorsAgent class. > > Deleted the HostWrapper class entirely. > > Refactored the daemon entry point to reduce the number of methods > invoked in order to start or stop the HostAgent instance. Moved the > NICWrapper's setupQMFObject method from private to public so that it can > be invoked by the HostAgent. This is a temporary measure since the > NICWrapper will be replaced by a future patch. ACK Ian > Signed-off-by: Darryl L. Pierce > --- > src/host.cpp | 263 +++++++++++++--------------------------------------- > src/host.h | 75 ++++----------- > src/main.cpp | 57 ++++-------- > src/nic.h | 2 +- > src/processors.cpp | 6 + > src/processors.h | 3 + > 6 files changed, 111 insertions(+), 295 deletions(-) > > diff --git a/src/host.cpp b/src/host.cpp > index ac04f47..885068b 100644 > --- a/src/host.cpp > +++ b/src/host.cpp > @@ -37,213 +37,80 @@ using namespace std; > using qpid::management::Manageable; > namespace _qmf = qmf::com::redhat::matahari; > > -ostream& operator<<(ostream &output, const HostWrapper& host) > +void > +HostAgent::setup(ManagementAgent* agent) > { > - output << "Node" << endl << endl; > - output << "UUID: " << host.uuid << endl; > - output << "Hostname: " << host.hostname << endl; > - output << "Memory: " << host.memory << endl; > - output << "Hypervisor: " << host.hypervisor << endl; > - output << "Arch: " << host.arch << endl << endl; > - > - vector cpus = host.cpus; > - vector nics = host.nics; > - > - for (vector::iterator iter = cpus.begin(); > - iter!= cpus.end(); > - iter++) { > - output << **iter << endl; > - } > - for (vector::iterator iter = nics.begin(); > - iter!= nics.end(); > - iter++) { > - output << **iter << endl; > + management_object = new _qmf::Host(agent, this); > + agent->addObject(management_object); > + > + // discover the aspects of the host > + processors.setup(agent, this); > + > + LibHalContext *hal_ctx; > + int ret; > + > + // Get our HAL Context or die trying > + hal_ctx = get_hal_ctx(); > + if (!hal_ctx) > + throw runtime_error("Unable to get HAL Context Structure."); > + > + try { > + NICWrapper::fillNICInfo(this->nics, agent, hal_ctx); > + > + // Host UUID > + char *uuid_c = get_uuid(hal_ctx); > + string uuid(uuid_c); > + management_object->set_uuid(uuid); > + > + // Hostname > + char hostname_c[HOST_NAME_MAX]; > + ret = gethostname(hostname_c, sizeof(hostname_c)); > + if (ret != 0) > + throw runtime_error("Unable to get hostname"); > + string hostname(hostname_c); > + management_object->set_hostname(hostname); > + > + // Hypervisor, arch, memory > + management_object->set_memory(0); > + management_object->set_hypervisor("unknown"); > + management_object->set_arch("unknown"); > + > + virConnectPtr connection; > + virNodeInfo info; > + connection = virConnectOpenReadOnly(NULL); > + if (connection) { > + const char *hv = virConnectGetType(connection); > + if (hv != NULL) > + management_object->set_hypervisor(hv); > + ret = virNodeGetInfo(connection, &info); > + if (ret == 0) { > + management_object->set_arch(info.model); > + management_object->set_memory(info.memory); > + } > } > + virConnectClose(connection); > > - output << "End Node" << endl; > - return output; > -} > + management_object->set_beeping(false); > > -void HostWrapper::doLoop(void) > -{ > - // Someday we might update statistics too! > - while(1) > + // setup the nic objects > + for(vector::iterator iter = nics.begin(); > + iter != nics.end(); > + iter++) > { > - // update all statistics > - processors.update_load_averages(); > - sleep(5); > - } > -} > - > -void HostWrapper::setupQMFObjects(ManagementAgent *agent) > -{ > - // Set up Host object > - mgmt_object = new _qmf::Host(agent, this); > - agent->addObject(mgmt_object); > - syncQMFHostObject(); > - > - processors.setup(agent, this); > - > - // Iterate over list and set up CPU objects > - for (vector::iterator iter = cpus.begin(); > - iter!= cpus.end(); > - iter++) { > - (*iter)->setupQMFObject(agent, this); > - } > - // Iterate over list and set up NIC objects > - for (vector::iterator iter = nics.begin(); > - iter!= nics.end(); > - iter++) { > (*iter)->setupQMFObject(agent, this); > - } > -} > - > -void HostWrapper::syncQMFHostObject(void) > -{ > - mgmt_object->set_uuid(uuid); > - mgmt_object->set_hostname(hostname); > - mgmt_object->set_memory(memory); > - mgmt_object->set_hypervisor(hypervisor); > - mgmt_object->set_arch(arch); > - mgmt_object->set_beeping(beeping); > -} > - > -void HostWrapper::cleanupQMFObjects(void) > -{ > - // Clean up Host object > - mgmt_object->resourceDestroy(); > - > - // Iterate over list and clean up CPU objects > - for (vector::iterator iter = cpus.begin(); > - iter!= cpus.end(); > - iter++) { > - (*iter)->cleanupQMFObject(); > - } > - // Iterate over list and clean up NIC objects > - for (vector::iterator iter = nics.begin(); > - iter!= nics.end(); > - iter++) { > - (*iter)->cleanupQMFObject(); > - } > -} > - > -void HostWrapper::cleanupMemberObjects(void) > -{ > - // Get rid of the CPUWrapper objects for this host > - for (vector::iterator iter = cpus.begin(); iter != cpus.end();) { > - delete (*iter); > - iter = cpus.erase(iter); > - } > - // Get rid of the NICWrapper objects for this host > - for (vector::iterator iter = nics.begin(); iter != nics.end();) { > - delete (*iter); > - iter = nics.erase(iter); > - } > -} > - > -void HostWrapper::disposeHostWrapper() > -{ > - if (hostSingleton == NULL) > - return; > - > - hostSingleton->cleanupQMFObjects(); > - hostSingleton->cleanupMemberObjects(); > - > - delete hostSingleton; > - hostSingleton = NULL; > -} > - > -HostWrapper* HostWrapper::setupHostWrapper(ManagementAgent *agent) > -{ > - if (hostSingleton != NULL) > - return hostSingleton; > - > - LibHalContext *hal_ctx; > - int ret; > - > - // Get our HAL Context or die trying > - hal_ctx = get_hal_ctx(); > - if (!hal_ctx) > - throw runtime_error("Unable to get HAL Context Structure."); > - > - HostWrapper *host = new HostWrapper(); > - > - try { > - CPUWrapper::fillCPUInfo(host->cpus, agent); > - NICWrapper::fillNICInfo(host->nics, agent, hal_ctx); > - > - // Host UUID > - char *uuid_c = get_uuid(hal_ctx); > - string uuid(uuid_c); > - host->uuid = uuid; > - > - // Hostname > - char hostname_c[HOST_NAME_MAX]; > - ret = gethostname(hostname_c, sizeof(hostname_c)); > - if (ret != 0) > - throw runtime_error("Unable to get hostname"); > - string hostname(hostname_c); > - host->hostname = hostname; > - > - // Hypervisor, arch, memory > - host->memory = 0; > - host->hypervisor = "unknown"; > - host->arch = "unknown"; > - > - virConnectPtr connection; > - virNodeInfo info; > - connection = virConnectOpenReadOnly(NULL); > - if (connection) { > - const char *hv = virConnectGetType(connection); > - if (hv != NULL) > - host->hypervisor = hv; > - ret = virNodeGetInfo(connection, &info); > - if (ret == 0) { > - host->arch = info.model; > - host->memory = info.memory; > - } > - } > - virConnectClose(connection); > - > - host->beeping = false; > - } > - catch (...) { > - host->cleanupMemberObjects(); > - put_hal_ctx(hal_ctx); > - delete host; > - throw; > - } > - > - // Close the Hal Context > + } > + } > + catch (...) { > put_hal_ctx(hal_ctx); > + throw; > + } > > - host->setupQMFObjects(agent); > - > - // Setup singleton reference and return > - hostSingleton = host; > - return hostSingleton; > + // Close the Hal Context > + put_hal_ctx(hal_ctx); > } > > -void HostWrapper::reboot() > +void > +HostAgent::update(void) > { > - system("shutdown -r now"); > -} > - > -void HostWrapper::shutdown() > -{ > - system("shutdown -h now"); > -} > - > -Manageable::status_t > -HostWrapper::ManagementMethod(uint32_t methodId, Args& args, string& text) > -{ > - switch(methodId) { > - case _qmf::Host::METHOD_SHUTDOWN: > - shutdown(); > - return Manageable::STATUS_OK; > - case _qmf::Host::METHOD_REBOOT: > - reboot(); > - return Manageable::STATUS_OK; > - } > - return Manageable::STATUS_NOT_IMPLEMENTED; > + processors.update(); > } > diff --git a/src/host.h b/src/host.h > index 148c91f..c19da3e 100644 > --- a/src/host.h > +++ b/src/host.h > @@ -1,3 +1,6 @@ > +#ifndef __HOST_H > +#define __HOST_H > + > /* host.h - Copyright (C) 2009 Red Hat, Inc. > * Written by Arjun Roy > * > @@ -32,67 +35,25 @@ using namespace std; > > using qpid::management::Manageable; > > -class HostWrapper : public Manageable > +class HostAgent : public Manageable > { > - static HostWrapper *hostSingleton; > - > - friend ostream& operator<<(ostream &output, const HostWrapper& host); > - > - // Host Parameters > - string uuid; > - string hostname; > - string hypervisor; > - string arch; > - bool beeping; > - int memory; > - > - // Aggregated components > - vector cpus; > - vector nics; > - > - ProcessorsAgent processors; > - > - // QMF related fields > - ManagementAgent *agent; > - qmf::com::redhat::matahari::Host *mgmt_object; > - > - // Methods to put up / take down QMF objects > - void setupQMFObjects(ManagementAgent *agent); > - void cleanupQMFObjects(void); > - > - // Housekeeping methods > - void syncQMFHostObject(void); > - void cleanupMemberObjects(void); > - > - // Host functionality > - void reboot(); > - void shutdown(); > - > - // Constructors and Destructor are private > - HostWrapper() {} > - HostWrapper(const HostWrapper &) {} > - ~HostWrapper() {} > + private: > + qmf::com::redhat::matahari::Host* management_object; > + ProcessorsAgent processors; > + vector nics; > > public: > - // Factory methods to create/dispose of the singleton > - static HostWrapper *setupHostWrapper(ManagementAgent *agent); > - static void disposeHostWrapper(void); > - > - // QMF Methods > - ManagementObject* GetManagementObject(void) const { return mgmt_object; } > - status_t ManagementMethod(uint32_t methodId, Args& args, string& text); > + HostAgent() {} > + virtual ~HostAgent() {} > > - // Field Accessors > - const string &getUUID(void) { return uuid; } > - const string &getHostname(void) { return hostname; } > - const string &getHypervisor(void) { return hypervisor; } > - const string &getArch(void) { return arch; } > - bool isBeeping(void) { return beeping; } > - int getMemory(void) { return memory; } > + ManagementObject* GetManagementObject(void) const { return management_object; } > > - const vector &getCPUList(void) { return cpus; } > - const vector &getNICList(void) { return nics; } > + void setup(ManagementAgent* agent); > + void update(void); > > - // Main Loop > - void doLoop(void); > + // agent methods > + void shutdown(void); > + void reboot(void); > }; > + > +#endif // __HOST_H > diff --git a/src/main.cpp b/src/main.cpp > index 002a02e..8493864 100644 > --- a/src/main.cpp > +++ b/src/main.cpp > @@ -42,18 +42,11 @@ namespace _qmf = qmf::com::redhat::matahari; > > // Global Variables > ManagementAgent::Singleton* singleton; > -HostWrapper* HostWrapper::hostSingleton = NULL; > > -void cleanup(void) > +void > +shutdown(int /*signal*/) > { > - HostWrapper::disposeHostWrapper(); > - delete singleton; > -} > - > -void shutdown(int) > -{ > - cleanup(); > - exit(0); > + exit(0); > } > > static void > @@ -69,21 +62,22 @@ print_usage() > printf("\t-p | --port specify broker port.\n"); > } > > -int do_main(int argc, char **argv) > +int > +main(int argc, char **argv) > { > int arg; > int idx = 0; > bool daemonize = false; > bool gssapi = false; > bool verbose = false; > - char *host = NULL; > + char *servername = NULL; > char *username = NULL; > char *service = NULL; > - int port = 5672; > + int serverport = 5672; > > ConnectionSettings settings; > ManagementAgent *agent; > - HostWrapper *hostWrapper; > + HostAgent host; > > struct option opt[] = { > {"help", no_argument, NULL, 'h'}, > @@ -131,7 +125,7 @@ int do_main(int argc, char **argv) > break; > case 'p': > if (optarg) { > - port = atoi(optarg); > + serverport = atoi(optarg); > } else { > print_usage(); > exit(1); > @@ -139,7 +133,7 @@ int do_main(int argc, char **argv) > break; > case 'b': > if (optarg) { > - host = strdup(optarg); > + servername = strdup(optarg); > } else { > print_usage(); > exit(1); > @@ -169,8 +163,8 @@ int do_main(int argc, char **argv) > signal(SIGINT, shutdown); > > // Connect to the broker > - settings.host = host ? host : "127.0.0.1"; > - settings.port = port; > + settings.host = servername ? servername : "127.0.0.1"; > + settings.port = serverport; > > if (username != NULL) { > settings.username = username; > @@ -185,28 +179,13 @@ int do_main(int argc, char **argv) > agent->init(settings, 5, false, ".magentdata"); > > // Get the info and post it to the broker > - try { > - hostWrapper = HostWrapper::setupHostWrapper(agent); > - } > - catch (...) { > - cleanup(); > - throw; > - } > + host.setup(agent); > > - // Main loop > - hostWrapper->doLoop(); > + while(1) > + { > + host.update(); > + sleep(5); > + } > > - // And we are done > - cleanup(); > return 0; > } > - > -int main(int argc, char** argv) > -{ > - try { > - return do_main(argc, argv); > - } > - catch(std::exception& e) { > - cout << "Top Level Exception: " << e.what() << endl; > - } > -} > diff --git a/src/nic.h b/src/nic.h > index 15f31fb..c79ecf9 100644 > --- a/src/nic.h > +++ b/src/nic.h > @@ -47,7 +47,6 @@ class NICWrapper : public Manageable > qmf::com::redhat::matahari::NIC *mgmt_object; > > // Methods to put up / take down QMF Objects > - void setupQMFObject(ManagementAgent *agent, Manageable *parent); > void cleanupQMFObject(void); > void syncQMFObject(void); > > @@ -77,6 +76,7 @@ class NICWrapper : public Manageable > int identifyNIC(int seconds); > public: > > + void setupQMFObject(ManagementAgent *agent, Manageable *parent); > // Factory like method > static void fillNICInfo(vector &nics, > ManagementAgent *agent, > diff --git a/src/processors.cpp b/src/processors.cpp > index 4317b1f..cff66d9 100644 > --- a/src/processors.cpp > +++ b/src/processors.cpp > @@ -57,6 +57,12 @@ ProcessorsAgent::setup(ManagementAgent* agent, Manageable* parent) > } > > void > +ProcessorsAgent::update(void) const > +{ > + update_load_averages(); > +} > + > +void > ProcessorsAgent::update_load_averages(void) const > { > double load_average; > diff --git a/src/processors.h b/src/processors.h > index 3e46b16..17a6a6a 100644 > --- a/src/processors.h > +++ b/src/processors.h > @@ -42,6 +42,9 @@ class ProcessorsAgent : public Manageable > > void setup(ManagementAgent* agent, Manageable* parent); > > + void update(void) const; > + > + private: > // agent methods > void update_load_averages(void) const; > }; From imain at redhat.com Tue Apr 20 16:23:57 2010 From: imain at redhat.com (Ian Main) Date: Tue, 20 Apr 2010 09:23:57 -0700 Subject: [Ovirt-devel] [Matahari] [PATCH matahari] Replaces the existing HAL code for ProcessorAgent with udev. In-Reply-To: <1271702551-29548-1-git-send-email-dpierce@redhat.com> References: <1271702551-29548-1-git-send-email-dpierce@redhat.com> Message-ID: <1271780637.5621.27.camel@localhost.localdomain> On Mon, 2010-04-19 at 14:42 -0400, Darryl L. Pierce wrote: > Stripped out the HAL support code and replaced with calls to udev. The > remainder of the code to extract CPU details parses through the > /proc/cpuinfo file since udev/sysfs will not return such information. Your formatting is different from the rest of the codebase.. it's getting all mixed up in there.. Otherwise ACK. :) Ian > Signed-off-by: Darryl L. Pierce > --- > configure.ac | 3 +- > src/Makefile.am | 4 +- > src/processors.cpp | 94 +++++++++++++++++++++++++++++++++++++++++---------- > 3 files changed, 79 insertions(+), 22 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 9102c66..c51c23e 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -8,7 +8,7 @@ AM_INIT_AUTOMAKE > AC_PROG_CXX > AC_PROG_CC > AC_PROG_CPP > -AC_CHECK_HEADERS([arpa/inet.h netinet/in.h sys/ioctl.h sys/socket.h unistd.h]) > +AC_CHECK_HEADERS([arpa/inet.h netinet/in.h sys/ioctl.h sys/socket.h unistd.h libudev.h]) > > # Checks for typedefs, structures, and compiler characteristics. > AC_HEADER_STDBOOL > @@ -19,6 +19,7 @@ PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.2.12) > PKG_CHECK_MODULES(HAL, hal >= 0.5.12) > PKG_CHECK_MODULES(LIBVIRT, libvirt >= 0.6.2) > PKG_CHECK_MODULES(PCRE, libpcre >= 7.8) > +PKG_CHECK_MODULES(UDEV, libudev >= 145) > > # Checks for library functions. > AC_CHECK_FUNCS([gethostname inet_ntoa socket]) > diff --git a/src/Makefile.am b/src/Makefile.am > index ee30443..b4668b9 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -1,4 +1,4 @@ > -INCLUDES = -I$(top_srcdir)/src/qmf/com/redhat/matahari $(HAL_CFLAGS) $(LIBVIRT_CFLAGS) $(PCRE_CFLAGS) > +INCLUDES = -I$(top_srcdir)/src/qmf/com/redhat/matahari $(HAL_CFLAGS) $(LIBVIRT_CFLAGS) $(PCRE_CFLAGS) $(UDEV_CFLAGS) > > sbin_PROGRAMS = matahari > > @@ -41,6 +41,6 @@ CLEANFILES = $(generated_file_list) $(first) > > matahari_CPPFLAGS = -fno-strict-aliasing > matahari_LDFLAGS = -L/usr/local/lib > -matahari_LDADD = -lqmf $(HAL_LIBS) $(LIBVIRT_LIBS) $(PCRE_LIBS) > +matahari_LDADD = -lqmf $(HAL_LIBS) $(LIBVIRT_LIBS) $(PCRE_LIBS) $(UDEV_LIBS) > > dist_pkgdata_DATA = schema.xml > diff --git a/src/processors.cpp b/src/processors.cpp > index 4317b1f..30a2837 100644 > --- a/src/processors.cpp > +++ b/src/processors.cpp > @@ -17,25 +17,19 @@ > * also available at http://www.gnu.org/copyleft/gpl.html. > */ > > -#include > +#include "processors.h" > #include > -#include > -#include > -#include > -#include > - > -#include > - > +#include > #include > > -#include "hal.h" > -#include "processors.h" > +// TODO remove this wrapper once rhbz#583747 is fixed > +extern "C" { > +#include > +} > > using namespace std; > namespace _qmf = qmf::com::redhat::matahari; > > -extern DBusError dbus_error; > - > void > ProcessorsAgent::setup(ManagementAgent* agent, Manageable* parent) > { > @@ -43,17 +37,79 @@ ProcessorsAgent::setup(ManagementAgent* agent, Manageable* parent) > management_object = new _qmf::Processors(agent, this, parent); > agent->addObject(management_object); > > - LibHalContext* context = get_hal_ctx(); > + int core_count = 0; > + string model = "unknown"; > + > + struct udev* udev = udev_new(); > + struct udev_enumerate* enumerator = udev_enumerate_new(udev); > + > + udev_enumerate_add_match_property(enumerator, "DRIVER", "processor"); > + if(!udev_enumerate_scan_devices(enumerator)) > + { > + struct udev_list_entry* entries = udev_enumerate_get_list_entry(enumerator); > + struct udev_list_entry* entry; > + > + udev_list_entry_foreach(entry, entries) > + { > + core_count++; > + } > + } > + > + udev_enumerate_unref(enumerator); > + udev_unref(udev); > + > + ifstream input("/proc/cpuinfo"); > + if(input.is_open()) > + { > + string regexstr = "(.*\\S)\\s*:\\s*(\\S.*)"; > + int expected = 3; > + int found[expected * 3]; > + const char* pcre_error; > + int pcre_error_offset; > + pcre* regex; > + bool done = false; > + bool started = false; > + > + regex = pcre_compile(regexstr.c_str(), 0, &pcre_error, &pcre_error_offset, NULL); > + if(!regex) { throw runtime_error("Unable to compile regular expression."); } > + > + while(!input.eof() && !done) > + { > + string line; > + > + getline(input, line); > + int match = pcre_exec(regex, NULL, line.c_str(), line.length(), > + 0, PCRE_NOTEMPTY,found, expected * 3); > > - int num_results; > - char** processors = libhal_find_device_by_capability(context,"processor", &num_results, &dbus_error); > + if(match == expected) > + { > + string name = line.substr(found[2], found[3] - found[2]); > + string value = line.substr(found[4], found[5] - found[4]); > > - if (!processors) > - throw runtime_error("Error: could not query processors via HAL."); > + // if we're at a second processor and we've already started, then we're done > + if (name == "processor") > + { > + if (started) > + { > + done = true; > + } > + else > + { > + started = true; > + } > + } > + else > + { > + if(name == "model name") model = value; > + } > + } > + } > + input.close(); > + } > > // populate the managed object's values > - management_object->set_model(libhal_device_get_property_string(context, processors[0], "info.product", &dbus_error)); > - management_object->set_cores(num_results); > + management_object->set_model(model); > + management_object->set_cores(core_count); > } > > void From imain at redhat.com Tue Apr 20 17:00:52 2010 From: imain at redhat.com (Ian Main) Date: Tue, 20 Apr 2010 10:00:52 -0700 Subject: [Ovirt-devel] [Matahari] [PATCH matahari] Removes all code for the previous CPUWrapper class. In-Reply-To: <1271703795-1645-1-git-send-email-dpierce@redhat.com> References: <1271703795-1645-1-git-send-email-dpierce@redhat.com> Message-ID: <1271782852.5621.30.camel@localhost.localdomain> On Mon, 2010-04-19 at 15:03 -0400, Darryl L. Pierce wrote: > This class has been replaced by the ProcessorsAgent. ACK Ian > Signed-off-by: Darryl L. Pierce > --- > src/Makefile.am | 4 - > src/cpu.cpp | 216 ------------------------------------------------------- > src/cpu.h | 111 ---------------------------- > src/host.cpp | 24 ------ > src/host.h | 3 - > src/schema.xml | 16 ---- > 6 files changed, 0 insertions(+), 374 deletions(-) > delete mode 100644 src/cpu.cpp > delete mode 100644 src/cpu.h > > diff --git a/src/Makefile.am b/src/Makefile.am > index b4668b9..7606e20 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -6,8 +6,6 @@ first = qmf/com/redhat/matahari/Host.cpp > > generated_file_list = \ > qmf/com/redhat/matahari/ArgsNICIdentify_nic.h \ > - qmf/com/redhat/matahari/CPU.cpp \ > - qmf/com/redhat/matahari/CPU.h \ > qmf/com/redhat/matahari/Host.h \ > qmf/com/redhat/matahari/NIC.cpp \ > qmf/com/redhat/matahari/NIC.h \ > @@ -19,8 +17,6 @@ generated_file_list = \ > nodist_matahari_SOURCES = $(generated_file_list) $(first) > > matahari_SOURCES = \ > - cpu.cpp \ > - cpu.h \ > hal.cpp \ > hal.h \ > host.cpp \ > diff --git a/src/cpu.cpp b/src/cpu.cpp > deleted file mode 100644 > index 453c571..0000000 > --- a/src/cpu.cpp > +++ /dev/null > @@ -1,216 +0,0 @@ > -/* cpu.cpp - Copyright (C) 2009 Red Hat, Inc. > - * Written by Arjun Roy > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; version 2 of the License. > - * > - * This program is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > - * GNU General Public License for more details. > - * > - * You should have received a copy of the GNU General Public License > - * along with this program; if not, write to the Free Software > - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, > - * MA 02110-1301, USA. A copy of the GNU General Public License is > - * also available at http://www.gnu.org/copyleft/gpl.html. > - */ > - > -#include > -#include > -#include > -#include > -#include > -#include > - > -#include > - > -#include "cpu.h" > -#include "qmf/com/redhat/matahari/CPU.h" > - > -using namespace std; > -namespace _qmf = qmf::com::redhat::matahari; > - > -template targetType convert(const std::string& str) > -{ > - istringstream i(str); > - targetType t; > - if (!(i >> t)) > - throw invalid_argument("Conversion failure for " + str); > - return t; > -} > - > -ostream& operator<<(ostream& output, const CPUWrapper& cpu) > -{ > - output << "Processor" << endl; > - output << "CPU #: " << cpu.cpunum << endl; > - output << "Core #: " << cpu.corenum << endl; > - output << "Num. Cores: " << cpu.numcores << endl; > - output << "Model: " << cpu.model << endl; > - output << "Family: " << cpu.family << endl; > - output << "CPU ID Level: " << cpu.cpuid_lvl << endl; > - output << "Speed (Mhz): " << cpu.speed << endl; > - output << "Cache (kB): " << cpu.cache << endl; > - output << "Vendor: " << cpu.vendor << endl; > - output << "Flags: " << cpu.flags << endl; > - return output; > -} > - > -void CPUWrapper::setupQMFObject(ManagementAgent *agent, Manageable *parent) > -{ > - mgmt_object = new _qmf::CPU(agent, this, parent); > - agent->addObject(mgmt_object); > - syncQMFObject(); > -} > - > -void CPUWrapper::cleanupQMFObject(void) > -{ > - mgmt_object->resourceDestroy(); > -} > - > -void CPUWrapper::syncQMFObject(void) > -{ > - mgmt_object->set_cpunum(cpunum); > - mgmt_object->set_corenum(corenum); > - mgmt_object->set_numcores(numcores); > - mgmt_object->set_model(model); > - mgmt_object->set_family(family); > - mgmt_object->set_cpuid_lvl(cpuid_lvl); > - mgmt_object->set_speed(speed); > - mgmt_object->set_cache(cache); > - mgmt_object->set_vendor(vendor); > - mgmt_object->set_flags(flags); > -} > - > -/** > - * void fillCPUInfo(vector &cpus, ManagementAgent *agent) > - * > - * Takes in a vector of CPUWrapper object pointers and populates it with > - * CPUs found by querying /proc/cpuinfo. NOTE: This method is very sensitive > - * to the output format of /proc/cpuinfo. > - * > - * Throws a runtime error if file io is unsuccessful. > - */ > -void CPUWrapper::fillCPUInfo(vector &cpus, ManagementAgent *agent) > -{ > - string line; > - string regexstr = "(.*\\S)\\s*:\\s*(\\S.*)"; > - int desiredmatches = 3; // Match string and two captured substrings > - int matchArraySize = desiredmatches * 3; > - int results[matchArraySize]; // pcre requires this much > - const char *pcre_err; > - int pcre_err_offset; > - pcre *regex; > - > - regex = pcre_compile(regexstr.c_str(), // input > - 0, // no options > - &pcre_err, // where to place static error str > - &pcre_err_offset, // index in regex string of error > - NULL // use the default charset > - ); > - if (!regex) { > - ostringstream err; > - err << "Error: Bad regex: " << regexstr << endl; > - err << "Error was: " << pcre_err << " at " << pcre_err_offset << endl; > - throw runtime_error(err.str()); > - } > - > - ifstream cpuinfo("/proc/cpuinfo", ios::in); > - if (!cpuinfo.is_open() || cpuinfo.fail()) > - throw runtime_error("Unable to open /proc/cpuinfo"); > - > - // Each line is a key:value pair. New processor > - // delimiter is the "processor" key. > - while (!cpuinfo.eof()) { > - getline(cpuinfo, line); > - int match = pcre_exec(regex, // Regex > - NULL, // No extra optimizations > - line.c_str(), // Input > - line.length(), // Input length > - 0, // Start offset > - PCRE_NOTEMPTY, // options bitvector > - results, // Results vector > - matchArraySize // Vector size > - ); > - > - if (match == desiredmatches) { > - if (line.substr(results[2], results[3] - results[2]) == "processor") { > - // Start pulling data for a new processor > - int cpunum = -1; > - int coreid = -1; > - int cpucores = -1; > - int model = -1; > - int family = -1; > - int cpuid_lvl = -1; > - double speed = -1; > - int cache = -1; > - string vendor = "unknown"; > - string flags = "unknown"; > - > - // Get the cpu # from this line > - cpunum = convert(line.substr(results[4], > - results[5] - results[4])); > - // And now grab the rest > - do { > - getline(cpuinfo, line); > - match = pcre_exec(regex, // Regex > - NULL, // No extra optimizations > - line.c_str(), // Input > - line.length(), // Input length > - 0, // Start offset > - PCRE_NOTEMPTY, // options bitvector > - results, // Results vector > - matchArraySize // Vector size > - ); > - > - if (match == desiredmatches) { > - string key = line.substr(results[2], > - results[3] - results[2]); > - > - string value = line.substr(results[4], > - results[5] - results[4]); > - > - if (key == "core id") { > - coreid = convert(value); > - } else if (key == "cpu cores") { > - cpucores = convert(value); > - } else if (key == "model") { > - model = convert(value); > - } else if (key == "cpu family") { > - family = convert(value); > - } else if (key == "cpuid level") { > - cpuid_lvl = convert(value); > - } else if (key == "cpu MHz") { > - speed = convert(value); > - } else if (key == "cache size") { > - int space = value.find(' '); > - cache = convert(value.substr(0, space)); > - } else if (key == "vendor_id") { > - vendor = value; > - } else if (key == "flags") { > - flags = value; > - } > - } > - } > - while (line != ""); > - > - // Got all the data. Add the CPU to our list > - CPUWrapper *cpu = new CPUWrapper(cpunum, > - coreid, > - cpucores, > - model, > - family, > - cpuid_lvl, > - speed, > - cache, > - vendor, > - flags); > - cpus.push_back(cpu); > - } > - } > - else > - continue; > - } > - cpuinfo.close(); > -} > diff --git a/src/cpu.h b/src/cpu.h > deleted file mode 100644 > index bb3a9b3..0000000 > --- a/src/cpu.h > +++ /dev/null > @@ -1,111 +0,0 @@ > -/* cpu.h - Copyright (C) 2009 Red Hat, Inc. > - * Written by Arjun Roy > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; version 2 of the License. > - * > - * This program is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > - * GNU General Public License for more details. > - * > - * You should have received a copy of the GNU General Public License > - * along with this program; if not, write to the Free Software > - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, > - * MA 02110-1301, USA. A copy of the GNU General Public License is > - * also available at http://www.gnu.org/copyleft/gpl.html. > - */ > - > -#include > -#include > -#include > - > -#include "qmf/com/redhat/matahari/CPU.h" > - > -using namespace qpid::management; > -using namespace std; > - > -using qpid::management::Manageable; > - > -class CPUWrapper : public Manageable > -{ > - friend ostream& operator<<(ostream &output, const CPUWrapper& cpu); > - friend class HostWrapper; > - > - // CPU Parameters > - int cpunum; > - int corenum; > - int numcores; > - > - int model; > - int family; > - int cpuid_lvl; > - double speed; > - int cache; > - > - string vendor; > - string flags; > - > - // QMF related fields > - ManagementAgent *agent; > - qmf::com::redhat::matahari::CPU *mgmt_object; > - > - // Methods to put up / take down QMF Objects > - void setupQMFObject(ManagementAgent *agent, Manageable *parent); > - void cleanupQMFObject(void); > - void syncQMFObject(void); > - > - // Constructors and Destructor are private > - CPUWrapper() {} > - CPUWrapper(const CPUWrapper&) {} > - ~CPUWrapper() {} > - > - CPUWrapper(int cpunum__, > - int corenum__, > - int numcores__, > - int model__, > - int family__, > - int cpuid_lvl__, > - double speed__, > - int cache__, > - const string &vendor__, > - const string &flags__) { > - cpunum = cpunum__; > - corenum = corenum__; > - numcores = numcores__; > - model = model__; > - family = family__; > - cpuid_lvl = cpuid_lvl__; > - speed = speed__; > - cache = cache__; > - vendor = vendor__; > - flags = flags__; > - } > - > -public: > - > - // Factory like method > - static void fillCPUInfo(vector &cpus, ManagementAgent *agent); > - > - // QMF Methods > - ManagementObject* GetManagementObject(void) const { return mgmt_object; } > - > - status_t ManagementMethod(uint32_t methodId, Args& args, string& text) { > - return STATUS_NOT_IMPLEMENTED; > - } > - > - // Field Accessors > - int getCpunum(void) { return cpunum; } > - int getCorenum(void) { return corenum; } > - int getNumcores(void) { return numcores; } > - > - int getModel(void) { return model; } > - int getFamily(void) { return family; } > - int getCpuid_Lvl(void) { return cpuid_lvl; } > - double getSpeed(void) { return speed; } > - int getCache(void) { return cache; } > - > - const string &getVendor(void) { return vendor; } > - const string &getFlags(void) { return flags; } > -}; > diff --git a/src/host.cpp b/src/host.cpp > index ac04f47..b3ed51f 100644 > --- a/src/host.cpp > +++ b/src/host.cpp > @@ -46,14 +46,8 @@ ostream& operator<<(ostream &output, const HostWrapper& host) > output << "Hypervisor: " << host.hypervisor << endl; > output << "Arch: " << host.arch << endl << endl; > > - vector cpus = host.cpus; > vector nics = host.nics; > > - for (vector::iterator iter = cpus.begin(); > - iter!= cpus.end(); > - iter++) { > - output << **iter << endl; > - } > for (vector::iterator iter = nics.begin(); > iter!= nics.end(); > iter++) { > @@ -84,12 +78,6 @@ void HostWrapper::setupQMFObjects(ManagementAgent *agent) > > processors.setup(agent, this); > > - // Iterate over list and set up CPU objects > - for (vector::iterator iter = cpus.begin(); > - iter!= cpus.end(); > - iter++) { > - (*iter)->setupQMFObject(agent, this); > - } > // Iterate over list and set up NIC objects > for (vector::iterator iter = nics.begin(); > iter!= nics.end(); > @@ -113,12 +101,6 @@ void HostWrapper::cleanupQMFObjects(void) > // Clean up Host object > mgmt_object->resourceDestroy(); > > - // Iterate over list and clean up CPU objects > - for (vector::iterator iter = cpus.begin(); > - iter!= cpus.end(); > - iter++) { > - (*iter)->cleanupQMFObject(); > - } > // Iterate over list and clean up NIC objects > for (vector::iterator iter = nics.begin(); > iter!= nics.end(); > @@ -129,11 +111,6 @@ void HostWrapper::cleanupQMFObjects(void) > > void HostWrapper::cleanupMemberObjects(void) > { > - // Get rid of the CPUWrapper objects for this host > - for (vector::iterator iter = cpus.begin(); iter != cpus.end();) { > - delete (*iter); > - iter = cpus.erase(iter); > - } > // Get rid of the NICWrapper objects for this host > for (vector::iterator iter = nics.begin(); iter != nics.end();) { > delete (*iter); > @@ -169,7 +146,6 @@ HostWrapper* HostWrapper::setupHostWrapper(ManagementAgent *agent) > HostWrapper *host = new HostWrapper(); > > try { > - CPUWrapper::fillCPUInfo(host->cpus, agent); > NICWrapper::fillNICInfo(host->nics, agent, hal_ctx); > > // Host UUID > diff --git a/src/host.h b/src/host.h > index 148c91f..bdf43fa 100644 > --- a/src/host.h > +++ b/src/host.h > @@ -23,7 +23,6 @@ > > #include "qmf/com/redhat/matahari/Host.h" > > -#include "cpu.h" > #include "nic.h" > #include "processors.h" > > @@ -47,7 +46,6 @@ class HostWrapper : public Manageable > int memory; > > // Aggregated components > - vector cpus; > vector nics; > > ProcessorsAgent processors; > @@ -90,7 +88,6 @@ class HostWrapper : public Manageable > bool isBeeping(void) { return beeping; } > int getMemory(void) { return memory; } > > - const vector &getCPUList(void) { return cpus; } > const vector &getNICList(void) { return nics; } > > // Main Loop > diff --git a/src/schema.xml b/src/schema.xml > index f9c6f6b..e6b54db 100644 > --- a/src/schema.xml > +++ b/src/schema.xml > @@ -23,22 +23,6 @@ > > > > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > > > From dpierce at redhat.com Tue Apr 20 17:10:45 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Tue, 20 Apr 2010 13:10:45 -0400 Subject: [Ovirt-devel] [PATCH matahari] Refactored the Host agent. In-Reply-To: <1271780505.5621.26.camel@localhost.localdomain> References: <1271344771-8405-1-git-send-email-dpierce@redhat.com> <1271780505.5621.26.camel@localhost.localdomain> Message-ID: <20100420171045.GR3410@mcpierce-desktop.usersys.redhat.com> On Tue, Apr 20, 2010 at 09:21:45AM -0700, Ian Main wrote: > On Thu, 2010-04-15 at 11:19 -0400, Darryl L. Pierce wrote: > > Replaced the previous HostWrapper class with the new HostAgent class, > > which more closely resembles the style of the ProcessorsAgent class. > > > > Deleted the HostWrapper class entirely. > > > > Refactored the daemon entry point to reduce the number of methods > > invoked in order to start or stop the HostAgent instance. Moved the > > NICWrapper's setupQMFObject method from private to public so that it can > > be invoked by the HostAgent. This is a temporary measure since the > > NICWrapper will be replaced by a future patch. > > ACK Thank you. This is pushed. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From dpierce at redhat.com Tue Apr 20 17:25:24 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Tue, 20 Apr 2010 13:25:24 -0400 Subject: [Ovirt-devel] [Matahari] [PATCH matahari] Replaces the existing HAL code for ProcessorAgent with udev. In-Reply-To: <1271780637.5621.27.camel@localhost.localdomain> References: <1271702551-29548-1-git-send-email-dpierce@redhat.com> <1271780637.5621.27.camel@localhost.localdomain> Message-ID: <20100420172524.GS3410@mcpierce-desktop.usersys.redhat.com> On Tue, Apr 20, 2010 at 09:23:57AM -0700, Ian Main wrote: > On Mon, 2010-04-19 at 14:42 -0400, Darryl L. Pierce wrote: > > Stripped out the HAL support code and replaced with calls to udev. The > > remainder of the code to extract CPU details parses through the > > /proc/cpuinfo file since udev/sysfs will not return such information. > > Your formatting is different from the rest of the codebase.. it's > getting all mixed up in there.. > > Otherwise ACK. :) I'm being consistent in all of the new code, though. :) Thank you. This is pushed. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From dpierce at redhat.com Tue Apr 20 17:43:22 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Tue, 20 Apr 2010 13:43:22 -0400 Subject: [Ovirt-devel] [Matahari] [PATCH matahari] Removes all code for the previous CPUWrapper class. In-Reply-To: <1271782852.5621.30.camel@localhost.localdomain> References: <1271703795-1645-1-git-send-email-dpierce@redhat.com> <1271782852.5621.30.camel@localhost.localdomain> Message-ID: <20100420174322.GT3410@mcpierce-desktop.usersys.redhat.com> On Tue, Apr 20, 2010 at 10:00:52AM -0700, Ian Main wrote: > On Mon, 2010-04-19 at 15:03 -0400, Darryl L. Pierce wrote: > > This class has been replaced by the ProcessorsAgent. > > ACK Thank you. This is now pushed. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From nicolas.ochem at alcatel-lucent.com Wed Apr 21 13:06:37 2010 From: nicolas.ochem at alcatel-lucent.com (Nicolas Ochem) Date: Wed, 21 Apr 2010 15:06:37 +0200 Subject: [Ovirt-devel] representing networks on the node : about VLANs Message-ID: <4BCEF85D.7050404@alcatel-lucent.com> I would like to add a few points to the new network model proposed. - a Physical Network can be attached to real NIC cards and virtual machines - a VLAN network belongs to a Physical Network. For each NIC attached to a physical network containing VLANS, we should create VLAN interfaces on the node, and bridges attached to these interfaces. A VLAN Network can be attached to virtual machines just like a Physical Network. Typical use case scenario : a user create a Physical Network designed to contain VLAN traffic. Then he builds many VLAN Networks belonging to that physical network, and connects his Virtual Machines to some of these VLAN networks. The work required is : - on the server : refactor the networking model (today a VLAN Network has the same properties than a Physical Network) - on the node : create VLAN interfaces and bridges. I was able to do that previously by passing interface parameters to the node containing ...|VLAN=true|... From dpierce at redhat.com Wed Apr 21 17:38:54 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Wed, 21 Apr 2010 13:38:54 -0400 Subject: [Ovirt-devel] [PATCH matahari] Removes HAL code from the HostAgent codebase. Message-ID: <1271871534-21115-1-git-send-email-dpierce@redhat.com> Now all aspects of the host environment are details by other means. The fully qualified hostname and architecture are taken from uname(). Memory is taken from sysinfo(). The machine UUID is taken from DBus rather than udev since udev reports hardware UUID which is not guaranteed to be unique, while DBus is designed to be just that. Refactored, for now, the NICWrapper class to get its own HAL context rather than it being supplied by the HostAgent class. This way the HostAgent is completely HAL free. Signed-off-by: Darryl L. Pierce --- src/host.cpp | 131 +++++++++++++++++++++++++++---------------------------- src/nic.cpp | 4 +- src/nic.h | 3 +- src/schema.xml | 2 +- 4 files changed, 68 insertions(+), 72 deletions(-) diff --git a/src/host.cpp b/src/host.cpp index 885068b..11c5a8f 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -17,16 +17,12 @@ * also available at http://www.gnu.org/copyleft/gpl.html. */ -#include - -#include #include -#include - -#include -#include #include +#include +#include +#include #include "host.h" #include "qmf/com/redhat/matahari/Host.h" @@ -46,67 +42,68 @@ HostAgent::setup(ManagementAgent* agent) // discover the aspects of the host processors.setup(agent, this); - LibHalContext *hal_ctx; - int ret; - - // Get our HAL Context or die trying - hal_ctx = get_hal_ctx(); - if (!hal_ctx) - throw runtime_error("Unable to get HAL Context Structure."); - - try { - NICWrapper::fillNICInfo(this->nics, agent, hal_ctx); - - // Host UUID - char *uuid_c = get_uuid(hal_ctx); - string uuid(uuid_c); - management_object->set_uuid(uuid); - - // Hostname - char hostname_c[HOST_NAME_MAX]; - ret = gethostname(hostname_c, sizeof(hostname_c)); - if (ret != 0) - throw runtime_error("Unable to get hostname"); - string hostname(hostname_c); - management_object->set_hostname(hostname); - - // Hypervisor, arch, memory - management_object->set_memory(0); - management_object->set_hypervisor("unknown"); - management_object->set_arch("unknown"); - - virConnectPtr connection; - virNodeInfo info; - connection = virConnectOpenReadOnly(NULL); - if (connection) { - const char *hv = virConnectGetType(connection); - if (hv != NULL) - management_object->set_hypervisor(hv); - ret = virNodeGetInfo(connection, &info); - if (ret == 0) { - management_object->set_arch(info.model); - management_object->set_memory(info.memory); - } + struct utsname details; + string uuid = "Unknown"; + string hostname = "Unknown"; + string hypervisor = "Unknown"; + string architecture = "None"; + unsigned long memory = 0; + bool beeping = false; + + ifstream input("/var/lib/dbus/machine-id"); + + if(input.is_open()) + { + getline(input, uuid); + input.close(); + } + + if(!uname(&details)) + { + hostname = string(details.nodename); + architecture = string(details.machine); + } + else + { + throw runtime_error("Unable to retrieve system details"); + } + + virConnectPtr lvconn = virConnectOpenReadOnly(NULL); + + if(lvconn) + { + hypervisor = string(virConnectGetType(lvconn)); + virConnectClose(lvconn); + } + + struct sysinfo sysinf; + if(!sysinfo(&sysinf)) + { + memory = sysinf.totalram / 1024L; + } + else + { + throw runtime_error("Unable to retrieve system memory details."); + } + + cout << "memory: " << memory << endl; + + management_object->set_uuid(uuid); + management_object->set_hostname(hostname); + management_object->set_hypervisor(hypervisor); + management_object->set_arch(architecture); + management_object->set_memory(memory); + management_object->set_beeping(beeping); + + NICWrapper::fillNICInfo(this->nics, agent); + + // setup the nic objects + for(vector::iterator iter = nics.begin(); + iter != nics.end(); + iter++) + { + (*iter)->setupQMFObject(agent, this); } - virConnectClose(connection); - - management_object->set_beeping(false); - - // setup the nic objects - for(vector::iterator iter = nics.begin(); - iter != nics.end(); - iter++) - { - (*iter)->setupQMFObject(agent, this); - } - } - catch (...) { - put_hal_ctx(hal_ctx); - throw; - } - - // Close the Hal Context - put_hal_ctx(hal_ctx); } void diff --git a/src/nic.cpp b/src/nic.cpp index 197f5c7..040ca67 100644 --- a/src/nic.cpp +++ b/src/nic.cpp @@ -227,9 +227,9 @@ NICWrapper *NICWrapper::getNIC(ManagementAgent *agent, * calls. */ void NICWrapper::fillNICInfo(vector &nics, - ManagementAgent *agent, - LibHalContext *hal_ctx) + ManagementAgent *agent) { + LibHalContext* hal_ctx = get_hal_ctx(); char **net_devices; int num_results, i; net_devices = libhal_find_device_by_capability(hal_ctx, diff --git a/src/nic.h b/src/nic.h index c79ecf9..e0e5874 100644 --- a/src/nic.h +++ b/src/nic.h @@ -79,8 +79,7 @@ public: void setupQMFObject(ManagementAgent *agent, Manageable *parent); // Factory like method static void fillNICInfo(vector &nics, - ManagementAgent *agent, - LibHalContext *ctx); + ManagementAgent *agent); // QMF Methods ManagementObject *GetManagementObject(void) const { return mgmt_object; } diff --git a/src/schema.xml b/src/schema.xml index e6b54db..890e4ed 100644 --- a/src/schema.xml +++ b/src/schema.xml @@ -4,7 +4,7 @@ - + -- 1.6.6.1 From dpierce at redhat.com Wed Apr 21 20:10:08 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Wed, 21 Apr 2010 16:10:08 -0400 Subject: [Ovirt-devel] [PATCH matahari] Created a new platform-abstraction layer named Platform. Message-ID: <1271880608-10745-1-git-send-email-dpierce@redhat.com> It provides an initial implementation, LinuxPlatform, which is by default included in the build. Later code will refactor the build process to include the appropriate implementation depending on the target platform. Signed-off-by: Darryl L. Pierce --- src/Makefile.am | 4 ++ src/linux_platform.cpp | 117 ++++++++++++++++++++++++++++++++++++++++++++++++ src/linux_platform.h | 35 ++++++++++++++ src/platform.cpp | 35 ++++++++++++++ src/platform.h | 62 +++++++++++++++++++++++++ src/processors.cpp | 93 ++------------------------------------ 6 files changed, 258 insertions(+), 88 deletions(-) create mode 100644 src/linux_platform.cpp create mode 100644 src/linux_platform.h create mode 100644 src/platform.cpp create mode 100644 src/platform.h diff --git a/src/Makefile.am b/src/Makefile.am index 7606e20..e4f394d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,9 +21,13 @@ matahari_SOURCES = \ hal.h \ host.cpp \ host.h \ + linux_platform.cpp \ + linux_platform.h \ main.cpp \ nic.cpp \ nic.h \ + platform.cpp \ + platform.h \ processors.cpp \ processors.h diff --git a/src/linux_platform.cpp b/src/linux_platform.cpp new file mode 100644 index 0000000..26418f5 --- /dev/null +++ b/src/linux_platform.cpp @@ -0,0 +1,117 @@ +/* linux_platform.cpp - Copyright (C) 2010 Red Hat, Inc. + * Written by Darryl L. Pierce + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. A copy of the GNU General Public License is + * also available at http://www.gnu.org/copyleft/gpl.html. + */ + +#include +#include +#include +#include + +// TODO remove this wrapper once rhbz#583747 is fixed +extern "C" { +#include +} + +#include "linux_platform.h" + +LinuxPlatform::LinuxPlatform() +{ + int core_count = 0; + string model = "unknown"; + + struct udev* udev = udev_new(); + struct udev_enumerate* enumerator = udev_enumerate_new(udev); + + udev_enumerate_add_match_property(enumerator, "DRIVER", "processor"); + if(!udev_enumerate_scan_devices(enumerator)) + { + struct udev_list_entry* entries = udev_enumerate_get_list_entry(enumerator); + struct udev_list_entry* entry; + + udev_list_entry_foreach(entry, entries) + { + core_count++; + } + set_number_of_cores(core_count); + } + + udev_enumerate_unref(enumerator); + udev_unref(udev); + + ifstream input("/proc/cpuinfo"); + if(input.is_open()) + { + string regexstr = "(.*\\S)\\s*:\\s*(\\S.*)"; + int expected = 3; + int found[expected * 3]; + const char* pcre_error; + int pcre_error_offset; + pcre* regex; + bool done = false; + bool started = false; + + regex = pcre_compile(regexstr.c_str(), 0, &pcre_error, &pcre_error_offset, NULL); + if(!regex) { throw runtime_error("Unable to compile regular expression."); } + + while(!input.eof() && !done) + { + string line; + + getline(input, line); + int match = pcre_exec(regex, NULL, line.c_str(), line.length(), + 0, PCRE_NOTEMPTY,found, expected * 3); + + if(match == expected) + { + string name = line.substr(found[2], found[3] - found[2]); + string value = line.substr(found[4], found[5] - found[4]); + + // if we're at a second processor and we've already started, then we're done + if (name == "processor") + { + if (started) + { + done = true; + } + else + { + started = true; + } + } + else + { + if(name == "model name") set_processor_model(value); + } + } + } + input.close(); + } +} + +double +LinuxPlatform::get_load_average() const +{ + double load_average; + ifstream input; + + input.open("/proc/loadavg", ios::in); + input >> load_average; + input.close(); + + return load_average; +} diff --git a/src/linux_platform.h b/src/linux_platform.h new file mode 100644 index 0000000..13116df --- /dev/null +++ b/src/linux_platform.h @@ -0,0 +1,35 @@ +#ifndef __LINUX_PLATFORM_H +#define __LINUX_PLATFORM_H + +/* linux_platform.h - Copyright (C) 2010 Red Hat, Inc. + * Written by Darryl L. Pierce + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. A copy of the GNU General Public License is + * also available at http://www.gnu.org/copyleft/gpl.html. + */ + +#include +#include "platform.h" + +class LinuxPlatform : public Platform +{ + public: + LinuxPlatform(); + virtual ~LinuxPlatform() {} + + virtual double get_load_average() const; +}; + +#endif diff --git a/src/platform.cpp b/src/platform.cpp new file mode 100644 index 0000000..69f528b --- /dev/null +++ b/src/platform.cpp @@ -0,0 +1,35 @@ +/* platform.cpp - Copyright (C) 2010 Red Hat, Inc. + * Written by Darryl L. Pierce + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. A copy of the GNU General Public License is + * also available at http://www.gnu.org/copyleft/gpl.html. + */ + +#include "platform.h" +#include "linux_platform.h" + +Platform* Platform::_instance = 0; + +Platform* +Platform::instance() +{ + // TODO this is where we decide which implementation to use + if(!_instance) + { + _instance = new LinuxPlatform; + } + + return _instance; +} diff --git a/src/platform.h b/src/platform.h new file mode 100644 index 0000000..514ad20 --- /dev/null +++ b/src/platform.h @@ -0,0 +1,62 @@ +#ifndef __PLATFORM_H +#define __PLATFORM_H + +/* platform.h - Copyright (C) 2010 Red Hat, Inc. + * Written by Darryl L. Pierce + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. A copy of the GNU General Public License is + * also available at http://www.gnu.org/copyleft/gpl.html. + */ + +#include + +using namespace std; + +/* + * Platform defines a type that provides platform-specific details. + * + * Implementations provide the specific details needed by the + * various agents at runtime. + */ +class Platform +{ + private: + static Platform* _instance; + + string processor_model; + unsigned int number_of_cores; + + protected: + Platform() {} + virtual~ Platform() {} + + void set_processor_model(const string model) { processor_model = model; } + void set_number_of_cores(const int number) { number_of_cores = number; } + + public: + // the singleton instance + static Platform* instance(); + + // returns text describing the processor model. + string get_processor_model() const { return processor_model; } + + // returns the number of cores in the processor. + int get_number_of_cores() const { return number_of_cores; } + + // returns the load average for the platform + virtual double get_load_average() const = 0; +}; + +#endif diff --git a/src/processors.cpp b/src/processors.cpp index cbc2979..13c492d 100644 --- a/src/processors.cpp +++ b/src/processors.cpp @@ -18,14 +18,7 @@ */ #include "processors.h" -#include -#include -#include - -// TODO remove this wrapper once rhbz#583747 is fixed -extern "C" { -#include -} +#include "platform.h" using namespace std; namespace _qmf = qmf::com::redhat::matahari; @@ -37,79 +30,10 @@ ProcessorsAgent::setup(ManagementAgent* agent, Manageable* parent) management_object = new _qmf::Processors(agent, this, parent); agent->addObject(management_object); - int core_count = 0; - string model = "unknown"; - - struct udev* udev = udev_new(); - struct udev_enumerate* enumerator = udev_enumerate_new(udev); - - udev_enumerate_add_match_property(enumerator, "DRIVER", "processor"); - if(!udev_enumerate_scan_devices(enumerator)) - { - struct udev_list_entry* entries = udev_enumerate_get_list_entry(enumerator); - struct udev_list_entry* entry; - - udev_list_entry_foreach(entry, entries) - { - core_count++; - } - } - - udev_enumerate_unref(enumerator); - udev_unref(udev); - - ifstream input("/proc/cpuinfo"); - if(input.is_open()) - { - string regexstr = "(.*\\S)\\s*:\\s*(\\S.*)"; - int expected = 3; - int found[expected * 3]; - const char* pcre_error; - int pcre_error_offset; - pcre* regex; - bool done = false; - bool started = false; + Platform* platform = Platform::instance(); - regex = pcre_compile(regexstr.c_str(), 0, &pcre_error, &pcre_error_offset, NULL); - if(!regex) { throw runtime_error("Unable to compile regular expression."); } - - while(!input.eof() && !done) - { - string line; - - getline(input, line); - int match = pcre_exec(regex, NULL, line.c_str(), line.length(), - 0, PCRE_NOTEMPTY,found, expected * 3); - - if(match == expected) - { - string name = line.substr(found[2], found[3] - found[2]); - string value = line.substr(found[4], found[5] - found[4]); - - // if we're at a second processor and we've already started, then we're done - if (name == "processor") - { - if (started) - { - done = true; - } - else - { - started = true; - } - } - else - { - if(name == "model name") model = value; - } - } - } - input.close(); - } - - // populate the managed object's values - management_object->set_model(model); - management_object->set_cores(core_count); + management_object->set_model(platform->get_processor_model()); + management_object->set_cores(platform->get_number_of_cores()); } void @@ -121,12 +45,5 @@ ProcessorsAgent::update(void) const void ProcessorsAgent::update_load_averages(void) const { - double load_average; - ifstream input; - - input.open("/proc/loadavg", ios::in); - input >> load_average; - input.close(); - - management_object->set_load_average(load_average); + management_object->set_load_average(Platform::instance()->get_load_average()); } -- 1.6.6.1 From dpierce at redhat.com Thu Apr 22 17:31:01 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Thu, 22 Apr 2010 13:31:01 -0400 Subject: [Ovirt-devel] [PATCH] Fixed the configuration setup to be more complete. Message-ID: <1271957461-19299-1-git-send-email-dpierce@redhat.com> It now checks to ensure that the following dependencies are installed on the system: * Ruby * Ruby development libraries * Rake * Ruby gem command Signed-off-by: Darryl L. Pierce --- configure.ac | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/configure.ac b/configure.ac index 02f4050..6b9f833 100644 --- a/configure.ac +++ b/configure.ac @@ -7,5 +7,13 @@ AC_CONFIG_HEADERS([config.h]) test x"$ac_ct_CC:$CFLAGS" = 'xgcc:-g -O2' \ && CFLAGS="$CFLAGS -Wshadow -Wall -Werror" +AC_CHECK_PROGS(RUBY, ruby rake gem) + +if test x"$RUBY" = x ; then + AC_MSG_ERROR([Missing ruby development programs.]) +fi + +AC_CHECK_LIB(ruby, main, , AC_MSG_ERROR[Cannot find ruby development libraries]) + AC_CONFIG_FILES([Makefile ovirt-server.spec]) AC_OUTPUT -- 1.7.0.1 From dpierce at redhat.com Thu Apr 22 20:04:58 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Thu, 22 Apr 2010 16:04:58 -0400 Subject: [Ovirt-devel] [PATCH] Fixed the autoconf setup to check for necessary libraries and tools. Message-ID: <1271966698-9378-1-git-send-email-dpierce@redhat.com> The script now checks for: * libvirt, hal, dbus, python libraries * checks for the pykickstart executables Signed-off-by: Darryl L. Pierce --- configure.ac | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/configure.ac b/configure.ac index b6e0973..c4feed2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,20 @@ AC_INIT([ovirt-node], [1.9.2], [ovirt-devel at redhat.com]) AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability tar-pax]) AC_PROG_CC + +AC_CHECK_PROGS(PYKICKSTART, ksflatten) + +if test x"$PYKICKSTART" = x ; then + AC_MSG_ERROR([Missing python kickstart support.]) +fi + +# TODO need a way to check for python-setuptools + +AC_CHECK_LIB(dbus-1, main, , AC_MSG_ERROR([Cannot find DBus development libraries.])) +AC_CHECK_LIB(virt, main, , AC_MSG_ERROR([Cannot find libvirt development libraries.])) +AC_CHECK_LIB(hal, main, , AC_MSG_ERROR([Cannot find HAL development libraries.])) +AC_CHECK_LIB(python2.6, main, , AC_MSG_ERROR([Cannot find python development libraries.])) + AC_CONFIG_HEADERS([config.h]) # If using gcc and default CFLAGS, enable some warnings. -- 1.7.0.1 From matinata at br.ibm.com Fri Apr 23 09:48:48 2010 From: matinata at br.ibm.com (Ricardo Marin Matinata) Date: Fri, 23 Apr 2010 06:48:48 -0300 Subject: [Ovirt-devel] [PATCH] Allow persistance of empty config files in ovirt_store_config v2 In-Reply-To: <1269538218-12341-1-git-send-email-matinata@br.ibm.com> References: <1269538218-12341-1-git-send-email-matinata@br.ibm.com> Message-ID: <1272016128.14897.2.camel@localhost> On Thu, 2010-03-25 at 14:30 -0300, Ricardo Marin Matinata wrote: > This fix enables the persistance of empty configuration files during firstboot, in ovirt_store_config, so configuration files like ssh/ssl keys that are dynamically generated (i.e. content is not known until the node has booted at least one time) to well known locations can be pre set for persistance. > > Signed-off-by: Ricardo Marin Matinata > --- > scripts/ovirt-functions | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions > index 482441a..1c3336d 100644 > --- a/scripts/ovirt-functions > +++ b/scripts/ovirt-functions > @@ -495,9 +495,9 @@ ovirt_store_config() { > fi > > if $persist_it; then > - # skip if file does not exist or is empty > - if [ ! -s "${filename}" ]; then > - printf " Skipping, file '${filename}' does not exist or is empty\n" > + # skip if file does not exist > + if [ ! -e "${filename}" ]; then > + printf " Skipping, file '${filename}' does not exist\n" > continue > fi > # skip if already bind-mounted Was this pushed in (I can't find it in the logs) ? If not, are there any impediments left ? Thanks ! -- Ricardo Marin Matinata Linux Technology Center IBM Brazil | Hortolandia | SP matinata br ibm com From apevec at gmail.com Fri Apr 23 11:55:59 2010 From: apevec at gmail.com (Alan Pevec) Date: Fri, 23 Apr 2010 13:55:59 +0200 Subject: [Ovirt-devel] [PATCH] Allow persistance of empty config files in ovirt_store_config v2 In-Reply-To: <1272016128.14897.2.camel@localhost> References: <1269538218-12341-1-git-send-email-matinata@br.ibm.com> <1272016128.14897.2.camel@localhost> Message-ID: > Was this pushed in (I can't find it in the logs) ? If not, are there any > impediments left ? Thanks ! pushed - it is now responsibility of the calling side to ensure persisted config is valid for the particular application e.g. sshd fails to start if host key is empty Thanks, Alan From imain at redhat.com Fri Apr 23 18:13:32 2010 From: imain at redhat.com (Ian Main) Date: Fri, 23 Apr 2010 11:13:32 -0700 Subject: [Ovirt-devel] [PATCH matahari] Removes HAL code from the HostAgent codebase. In-Reply-To: <1271871534-21115-1-git-send-email-dpierce@redhat.com> References: <1271871534-21115-1-git-send-email-dpierce@redhat.com> Message-ID: <1272046412.25456.1.camel@localhost.localdomain> On Wed, 2010-04-21 at 13:38 -0400, Darryl L. Pierce wrote: > Now all aspects of the host environment are details by other means. The > fully qualified hostname and architecture are taken from uname(). Memory > is taken from sysinfo(). The machine UUID is taken from DBus rather than > udev since udev reports hardware UUID which is not guaranteed to be > unique, while DBus is designed to be just that. > > Refactored, for now, the NICWrapper class to get its own HAL context > rather than it being supplied by the HostAgent class. This way the > HostAgent is completely HAL free. > > Signed-off-by: Darryl L. Pierce ACK From imain at redhat.com Fri Apr 23 18:15:56 2010 From: imain at redhat.com (Ian Main) Date: Fri, 23 Apr 2010 11:15:56 -0700 Subject: [Ovirt-devel] [PATCH matahari] Created a new platform-abstraction layer named Platform. In-Reply-To: <1271880608-10745-1-git-send-email-dpierce@redhat.com> References: <1271880608-10745-1-git-send-email-dpierce@redhat.com> Message-ID: <1272046556.25456.2.camel@localhost.localdomain> On Wed, 2010-04-21 at 16:10 -0400, Darryl L. Pierce wrote: > It provides an initial implementation, LinuxPlatform, which is by > default included in the build. Later code will refactor the build > process to include the appropriate implementation depending on the > target platform. > > Signed-off-by: Darryl L. Pierce Spiffy, I like it. ACK Ian From dpierce at redhat.com Fri Apr 23 18:22:08 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Fri, 23 Apr 2010 14:22:08 -0400 Subject: [Ovirt-devel] [PATCH matahari] Removes HAL code from the HostAgent codebase. In-Reply-To: <1272046412.25456.1.camel@localhost.localdomain> References: <1271871534-21115-1-git-send-email-dpierce@redhat.com> <1272046412.25456.1.camel@localhost.localdomain> Message-ID: <20100423182208.GJ5517@mcpierce-desktop.usersys.redhat.com> On Fri, Apr 23, 2010 at 11:13:32AM -0700, Ian Main wrote: > On Wed, 2010-04-21 at 13:38 -0400, Darryl L. Pierce wrote: > > Now all aspects of the host environment are details by other means. The > > fully qualified hostname and architecture are taken from uname(). Memory > > is taken from sysinfo(). The machine UUID is taken from DBus rather than > > udev since udev reports hardware UUID which is not guaranteed to be > > unique, while DBus is designed to be just that. > > > > Refactored, for now, the NICWrapper class to get its own HAL context > > rather than it being supplied by the HostAgent class. This way the > > HostAgent is completely HAL free. > > > > Signed-off-by: Darryl L. Pierce > > ACK Thanks. This is pushed upstream. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From dpierce at redhat.com Fri Apr 23 18:22:30 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Fri, 23 Apr 2010 14:22:30 -0400 Subject: [Ovirt-devel] [PATCH matahari] Created a new platform-abstraction layer named Platform. In-Reply-To: <1272046556.25456.2.camel@localhost.localdomain> References: <1271880608-10745-1-git-send-email-dpierce@redhat.com> <1272046556.25456.2.camel@localhost.localdomain> Message-ID: <20100423182230.GK5517@mcpierce-desktop.usersys.redhat.com> On Fri, Apr 23, 2010 at 11:15:56AM -0700, Ian Main wrote: > On Wed, 2010-04-21 at 16:10 -0400, Darryl L. Pierce wrote: > > It provides an initial implementation, LinuxPlatform, which is by > > default included in the build. Later code will refactor the build > > process to include the appropriate implementation depending on the > > target platform. > > > > Signed-off-by: Darryl L. Pierce > > Spiffy, I like it. > > ACK Thank you. This is now pushed upstream. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From dpierce at redhat.com Mon Apr 26 19:49:58 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Mon, 26 Apr 2010 15:49:58 -0400 Subject: [Ovirt-devel] [PATCH matahari] Created the NetworkDevice agent. Message-ID: <1272311398-31307-1-git-send-email-dpierce@redhat.com> Created a new class to represent network interface devices, named NetworkDeviceAgent. Signed-off-by: Darryl L. Pierce --- src/Makefile.am | 9 +- src/host.cpp | 26 +++-- src/host.h | 4 +- src/linux_platform.cpp | 70 +++++++++++ src/linux_platform.h | 4 + src/networkdevice.cpp | 49 ++++++++ src/networkdevice.h | 52 +++++++++ src/nic.cpp | 297 ------------------------------------------------ src/nic.h | 95 --------------- src/platform.h | 5 + src/processors.h | 5 + src/schema.xml | 22 +--- 12 files changed, 214 insertions(+), 424 deletions(-) create mode 100644 src/networkdevice.cpp create mode 100644 src/networkdevice.h delete mode 100644 src/nic.cpp delete mode 100644 src/nic.h diff --git a/src/Makefile.am b/src/Makefile.am index e4f394d..92ccec7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,10 +5,9 @@ sbin_PROGRAMS = matahari first = qmf/com/redhat/matahari/Host.cpp generated_file_list = \ - qmf/com/redhat/matahari/ArgsNICIdentify_nic.h \ qmf/com/redhat/matahari/Host.h \ - qmf/com/redhat/matahari/NIC.cpp \ - qmf/com/redhat/matahari/NIC.h \ + qmf/com/redhat/matahari/NetworkDevice.cpp \ + qmf/com/redhat/matahari/NetworkDevice.h \ qmf/com/redhat/matahari/Package.cpp \ qmf/com/redhat/matahari/Package.h \ qmf/com/redhat/matahari/Processors.cpp \ @@ -24,8 +23,8 @@ matahari_SOURCES = \ linux_platform.cpp \ linux_platform.h \ main.cpp \ - nic.cpp \ - nic.h \ + networkdevice.cpp \ + networkdevice.h \ platform.cpp \ platform.h \ processors.cpp \ diff --git a/src/host.cpp b/src/host.cpp index 11c5a8f..34d4550 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -25,6 +25,7 @@ #include #include "host.h" +#include "platform.h" #include "qmf/com/redhat/matahari/Host.h" using namespace qpid::management; @@ -41,6 +42,14 @@ HostAgent::setup(ManagementAgent* agent) // discover the aspects of the host processors.setup(agent, this); + networkdevices = Platform::instance()->get_network_devices(); + + for(vector::iterator iter = networkdevices.begin(); + iter != networkdevices.end(); + iter++) + { + iter->setup(agent, this); + } struct utsname details; string uuid = "Unknown"; @@ -94,20 +103,17 @@ HostAgent::setup(ManagementAgent* agent) management_object->set_arch(architecture); management_object->set_memory(memory); management_object->set_beeping(beeping); - - NICWrapper::fillNICInfo(this->nics, agent); - - // setup the nic objects - for(vector::iterator iter = nics.begin(); - iter != nics.end(); - iter++) - { - (*iter)->setupQMFObject(agent, this); - } } void HostAgent::update(void) { processors.update(); + + for(vector::iterator iter = networkdevices.begin(); + iter != networkdevices.end(); + iter++) + { + iter->update(); + } } diff --git a/src/host.h b/src/host.h index ba5a1ed..d2da776 100644 --- a/src/host.h +++ b/src/host.h @@ -26,7 +26,7 @@ #include "qmf/com/redhat/matahari/Host.h" -#include "nic.h" +#include "networkdevice.h" #include "processors.h" using namespace qpid::management; @@ -39,7 +39,7 @@ class HostAgent : public Manageable private: qmf::com::redhat::matahari::Host* management_object; ProcessorsAgent processors; - vector nics; + vector networkdevices; public: HostAgent() {} diff --git a/src/linux_platform.cpp b/src/linux_platform.cpp index 26418f5..fbcfdb9 100644 --- a/src/linux_platform.cpp +++ b/src/linux_platform.cpp @@ -18,9 +18,14 @@ */ #include +#include #include +#include +#include #include #include +#include +#include // TODO remove this wrapper once rhbz#583747 is fixed extern "C" { @@ -115,3 +120,68 @@ LinuxPlatform::get_load_average() const return load_average; } + +vector +LinuxPlatform::get_network_devices() const +{ + vector result; + + DIR* entries = opendir("/sys/class/net"); + + if(entries) + { + struct udev* udev = udev_new(); + struct dirent* entry; + + while(entry = (readdir(entries))) + { + string ifname = string(entry->d_name); + if(ifname != "." && ifname != "..") + { + string fullpath = "/sys/class/net/" + ifname; + struct udev_device* device = udev_device_new_from_syspath(udev, + fullpath.c_str()); + + if(udev_device_get_property_value(device, "ID_BUS")) + { + int sock = socket(AF_INET, SOCK_DGRAM, 0); + struct ifreq ifr; + string vendor = string(udev_device_get_property_value(device, "ID_VENDOR_FROM_DATABASE")); + string model = string(udev_device_get_property_value(device, "ID_MODEL_FROM_DATABASE")); + + if(sock >= 0) + { + ifr.ifr_addr.sa_family = AF_INET; + strncpy(ifr.ifr_name, ifname.c_str(), IFNAMSIZ - 1); + + if(!ioctl(sock, SIOCGIFHWADDR, &ifr)) + { + char macaddr[256]; + + sprintf(macaddr, + "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", + (unsigned char )ifr.ifr_hwaddr.sa_data[0], + (unsigned char )ifr.ifr_hwaddr.sa_data[1], + (unsigned char )ifr.ifr_hwaddr.sa_data[2], + (unsigned char )ifr.ifr_hwaddr.sa_data[3], + (unsigned char )ifr.ifr_hwaddr.sa_data[4], + (unsigned char )ifr.ifr_hwaddr.sa_data[5]); + + result.push_back(NetworkDeviceAgent(ifname, + vendor, + model, + string(macaddr))); + } + } + + udev_device_unref(device); + } + } + } + + udev_unref(udev); + closedir(entries); + } + + return result; +} diff --git a/src/linux_platform.h b/src/linux_platform.h index 13116df..095bc08 100644 --- a/src/linux_platform.h +++ b/src/linux_platform.h @@ -21,7 +21,10 @@ */ #include +#include + #include "platform.h" +#include "networkdevice.h" class LinuxPlatform : public Platform { @@ -30,6 +33,7 @@ class LinuxPlatform : public Platform virtual ~LinuxPlatform() {} virtual double get_load_average() const; + virtual vector get_network_devices() const; }; #endif diff --git a/src/networkdevice.cpp b/src/networkdevice.cpp new file mode 100644 index 0000000..5e30e33 --- /dev/null +++ b/src/networkdevice.cpp @@ -0,0 +1,49 @@ +/* networkingdevice.cpp - Copyright (C) 2010 Red Hat, Inc. + * Written by Darryl L. Pierce + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. A copy of the GNU General Public License is + * also available at http://www.gnu.org/copyleft/gpl.html. + */ + +#include +#include + +#include "networkdevice.h" + +namespace _qmf = qmf::com::redhat::matahari; + +NetworkDeviceAgent::NetworkDeviceAgent(string ifname, string vendor, string model, string macaddr) + :ifname(ifname) + ,vendor(vendor) + ,model(model) + ,macaddr(macaddr) +{} + +void +NetworkDeviceAgent::setup(ManagementAgent* agent, Manageable* parent) +{ + management_object = new _qmf::NetworkDevice(agent, this, parent); + agent->addObject(management_object); + + management_object->set_interface(ifname); + management_object->set_vendor(vendor); + management_object->set_model(model); + management_object->set_mac_address(macaddr); +} + +void +NetworkDeviceAgent::update() const +{ +} diff --git a/src/networkdevice.h b/src/networkdevice.h new file mode 100644 index 0000000..3884b22 --- /dev/null +++ b/src/networkdevice.h @@ -0,0 +1,52 @@ +#ifndef __NETWORKDEVICE_H +#define __NETWORKDEVICE_H + +/* networkdevice.h - Copyright (C) 2010 Red Hat, Inc. + * Written by Darryl L. Pierce + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. A copy of the GNU General Public License is + * also available at http://www.gnu.org/copyleft/gpl.html. + */ + +#include + +#include "qmf/com/redhat/matahari/NetworkDevice.h" + +using namespace qpid::management; +using namespace std; + +class NetworkDeviceAgent : public Manageable +{ + private: + qmf::com::redhat::matahari::NetworkDevice* management_object; + + string ifname; + string vendor; + string model; + string macaddr; + + public: + NetworkDeviceAgent(string ifname, string vendor, string model, string macaddr); + virtual ~NetworkDeviceAgent() {} + + string get_mac_address() const { return macaddr; } + + ManagementObject* GetManagementObject(void) const { return management_object; } + + void setup(ManagementAgent* agent, Manageable* parent); + void update() const; +}; + +#endif diff --git a/src/nic.cpp b/src/nic.cpp deleted file mode 100644 index 040ca67..0000000 --- a/src/nic.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* nic.cpp - Copyright (C) 2009 Red Hat, Inc. - * Written by Arjun Roy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. A copy of the GNU General Public License is - * also available at http://www.gnu.org/copyleft/gpl.html. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nic.h" -#include "qmf/com/redhat/matahari/NIC.h" -#include "qmf/com/redhat/matahari/ArgsNICIdentify_nic.h" - -using namespace qpid::management; -using namespace std; - -using qpid::management::Manageable; - -namespace _qmf = qmf::com::redhat::matahari; - -extern DBusConnection *dbus_connection; -extern DBusError dbus_error; - -ostream &operator<<(ostream& output, const NICWrapper& nic) { - output << "NIC" << endl; - output << "Interface Name: " << nic.interfaceName << endl; - output << "MAC Address: " << nic.macaddr << endl; - output << "IP Address: " << nic.ipaddr << endl; - output << "Netmask: " << nic.netmask << endl; - output << "Broadcast: " << nic.broadcast << endl; - output << "Bandwidth: " << nic.bandwidth << endl; - return output; -} - -void NICWrapper::setupQMFObject(ManagementAgent *agent, Manageable *parent) -{ - mgmt_object = new _qmf::NIC(agent, this, parent); - agent->addObject(mgmt_object); - syncQMFObject(); -} - -void NICWrapper::cleanupQMFObject(void) -{ - mgmt_object->resourceDestroy(); -} - -void NICWrapper::syncQMFObject(void) -{ - mgmt_object->set_interface(interfaceName); - mgmt_object->set_macaddr(macaddr); - mgmt_object->set_ipaddr(ipaddr); - mgmt_object->set_netmask(netmask); - mgmt_object->set_broadcast(broadcast); - mgmt_object->set_bandwidth(bandwidth); -} - -NICWrapper *NICWrapper::getNIC(ManagementAgent *agent, - LibHalContext *hal_ctx, - char *nic_handle) -{ - // Used to get the data - char *macaddr_c; - char *interface_c; - int sock, ret; - struct ifreq ifr; - struct ethtool_cmd ecmd; - - // The data that we care about - NICWrapper *nic = NULL; - string macaddr; - string interface; - string ipaddr; - string netmask; - string broadcast; - int bandwidth; - - // Grab the MAC Address from libhal - macaddr_c = libhal_device_get_property_string(hal_ctx, - nic_handle, - "net.address", - &dbus_error); - // Or throw an exception if we could not find it. No cleanup yet. - if (!macaddr_c) - throw runtime_error("Could not get mac address for NIC"); - - // Grab the interface name from libhal or return cleanup and fail - interface_c = libhal_device_get_property_string(hal_ctx, - nic_handle, - "net.interface", - &dbus_error); - // Or cleanup the macaddr and return NULL. - if (!interface_c) { - libhal_free_string(macaddr_c); - throw runtime_error("Could not get interface name for nic"); - } - - // Open socket for running ioctls for getting rest of data - sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock >= 0) { - // Get the IP Address - ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name, interface_c, IFNAMSIZ - 1); - cout << interface_c << endl; - - ret = ioctl(sock, SIOCGIFADDR, &ifr); - if(ret == 0) { - struct sockaddr_in *addr = (struct sockaddr_in *) &ifr.ifr_addr; - cout << "ip_address = " << inet_ntoa(addr->sin_addr) << endl; - ipaddr = inet_ntoa(addr->sin_addr); - } - else { - perror("SIOCGIFADDR"); - ipaddr = "unable to determine"; - } - // Get the netmask - ret = ioctl(sock, SIOCGIFNETMASK, &ifr); - if(ret == 0 && strcmp("255.255.255.255", - inet_ntoa(((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr))) { - - struct sockaddr_in *addr = (struct sockaddr_in *) &ifr.ifr_addr; - cout << "netmask = " << inet_ntoa(addr->sin_addr) << endl; - netmask = inet_ntoa(addr->sin_addr); - } - else { - perror("SIOCGIFNETMASK"); - netmask = "unable to determine"; - } - // Get the broadcast address - ret = ioctl(sock, SIOCGIFBRDADDR, &ifr); - if(ret == 0) { - struct sockaddr_in *addr = (struct sockaddr_in *) &ifr.ifr_addr; - cout << "broadcast = " << inet_ntoa(addr->sin_addr); - broadcast = inet_ntoa(addr->sin_addr); - } - else { - perror("SIOCGIFBRDADDR"); - broadcast = "unable to determine"; - } - // Get the bandwidth for this NIC - ecmd.cmd = ETHTOOL_GSET; - ifr.ifr_data = (caddr_t)&ecmd; - bandwidth = 10; - - // TODO: Error checking on this ioctl. For now, assume success - ret = ioctl(sock, SIOCETHTOOL, &ifr); - if (1) { - - if (ecmd.supported & SUPPORTED_10000baseT_Full) { - bandwidth = 10000; - } else if (ecmd.supported & SUPPORTED_2500baseX_Full) { - bandwidth = 2500; - } else if (ecmd.supported & (SUPPORTED_1000baseT_Half | - SUPPORTED_1000baseT_Full)) { - bandwidth = 1000; - } else if (ecmd.supported & (SUPPORTED_100baseT_Half | - SUPPORTED_100baseT_Full)) { - bandwidth = 100; - } else if (ecmd.supported & (SUPPORTED_10baseT_Half | - SUPPORTED_10baseT_Full)) { - bandwidth = 10; - } - } - else { - cout << "Unable to determine link speed, defaulting to 10" << endl; - } - // And we're done here - close(sock); - } - else { - /* Couldn't open socket, so cleanup and fail */ - libhal_free_string(interface_c); - libhal_free_string(macaddr_c); - throw runtime_error("Unable to open socket."); - } - // We have all the data. Create the NICWrapper instance - macaddr = macaddr_c; - interface = interface_c; - nic = new NICWrapper(interface, - macaddr, - ipaddr, - netmask, - broadcast, - bandwidth); - - // Free resources and return - libhal_free_string(interface_c); - libhal_free_string(macaddr_c); - return nic; -} - -/** - * void fillNICInfo(vector &nics, - * ManagementAgent *agent, - * LibHalContext *hal_ctx) - * - * Takes in a vector of NICWrapper object pointers and populates it with - * NICs found in the system found by querying dbus and making other system - * calls. - */ -void NICWrapper::fillNICInfo(vector &nics, - ManagementAgent *agent) -{ - LibHalContext* hal_ctx = get_hal_ctx(); - char **net_devices; - int num_results, i; - net_devices = libhal_find_device_by_capability(hal_ctx, - "net.80203", - &num_results, - &dbus_error); - if (!net_devices) - throw runtime_error("Error: Couldn't get NIC devices through libhal."); - - cout << "Found " << num_results << " NICs" << endl; - for (i = 0; i < num_results; i++) { - NICWrapper *nic; - char *nic_handle = net_devices[i]; - // If we couldn't read the info for a nic, free the list of devices - // and throw an error. Any devices added already will be cleaned up - // by the caller. - try { - nic = getNIC(agent, hal_ctx, nic_handle); - } - catch (...) { - libhal_free_string_array(net_devices); - throw; - } - // Add the NIC to our list - nics.push_back(nic); - } - // And we're all done. - libhal_free_string_array(net_devices); -} - -int NICWrapper::identifyNIC(int seconds) -{ - struct ethtool_value edata; - struct ifreq ifr; - int sock, ret; - - edata.cmd = ETHTOOL_PHYS_ID; - edata.data = seconds; // seconds of blink time - - strncpy(ifr.ifr_name, interfaceName.c_str(), IFNAMSIZ - 1); - ifr.ifr_data = (caddr_t)&edata; - - sock = socket(AF_INET, SOCK_DGRAM, 0); - ret = ioctl(sock, SIOCETHTOOL, &ifr); - close(sock); - - if (ret != 0) - ret = errno; - - return ret; -} - -Manageable::status_t -NICWrapper::ManagementMethod(uint32_t methodId, Args& args, string& text) -{ - switch (methodId) { - case _qmf::NIC::METHOD_IDENTIFY_NIC: - _qmf::ArgsNICIdentify_nic& ioArgs = (_qmf::ArgsNICIdentify_nic&) args; - int seconds = ioArgs.i_seconds; - ioArgs.o_ret = identifyNIC(seconds); - return STATUS_OK; - } - - return STATUS_NOT_IMPLEMENTED; -} diff --git a/src/nic.h b/src/nic.h deleted file mode 100644 index e0e5874..0000000 --- a/src/nic.h +++ /dev/null @@ -1,95 +0,0 @@ -/* nic.h - Copyright (C) 2009 Red Hat, Inc. - * Written by Arjun Roy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. A copy of the GNU General Public License is - * also available at http://www.gnu.org/copyleft/gpl.html. - */ - -#include -#include -#include - -#include "qmf/com/redhat/matahari/NIC.h" -#include "hal.h" - -using namespace qpid::management; -using namespace std; - -using qpid::management::Manageable; - -class NICWrapper : public Manageable -{ - friend ostream& operator <<(ostream &output, const NICWrapper& nic); - friend class HostWrapper; - - // NIC Parameters - string interfaceName; - string macaddr; - string ipaddr; - string netmask; - string broadcast; - int bandwidth; - - // QMF related fields - ManagementAgent *agent; - qmf::com::redhat::matahari::NIC *mgmt_object; - - // Methods to put up / take down QMF Objects - void cleanupQMFObject(void); - void syncQMFObject(void); - - // Constructors and Destructor are private - NICWrapper() {} - NICWrapper(const NICWrapper&) {} - ~NICWrapper() {} - - NICWrapper(const string &interfaceName__, - const string &macaddr__, - const string &ipaddr__, - const string &netmask__, - const string &broadcast__, - int bandwidth__) { - interfaceName = interfaceName__; - macaddr = macaddr__; - ipaddr = ipaddr__; - netmask = netmask__; - broadcast = broadcast__; - bandwidth = bandwidth__; - } - - static NICWrapper *getNIC(ManagementAgent *agent, - LibHalContext *hal_ctx, - char *nic_handle); - - int identifyNIC(int seconds); -public: - - void setupQMFObject(ManagementAgent *agent, Manageable *parent); - // Factory like method - static void fillNICInfo(vector &nics, - ManagementAgent *agent); - - // QMF Methods - ManagementObject *GetManagementObject(void) const { return mgmt_object; } - status_t ManagementMethod(uint32_t methodId, Args& args, string& text); - - // Field Accessors - const string &getInterfaceName(void) { return interfaceName; } - const string &getMacaddr(void) { return macaddr; } - const string &getIpaddr(void) { return ipaddr; } - const string &getNetmask(void) { return netmask; } - const string &getBroadcast(void) { return broadcast; } - int getBandwidth(void) { return bandwidth; } -}; diff --git a/src/platform.h b/src/platform.h index 514ad20..54fbe37 100644 --- a/src/platform.h +++ b/src/platform.h @@ -21,6 +21,8 @@ */ #include +#include +#include "networkdevice.h" using namespace std; @@ -57,6 +59,9 @@ class Platform // returns the load average for the platform virtual double get_load_average() const = 0; + + // returns the list of network devices for this platform + virtual vector get_network_devices() const = 0; }; #endif diff --git a/src/processors.h b/src/processors.h index 17a6a6a..e681453 100644 --- a/src/processors.h +++ b/src/processors.h @@ -1,3 +1,6 @@ +#ifndef __PROCESSORS_H +#define __PROCESSORS_H + /* processor.h - Copyright (C) 2010 Red Hat, Inc. * Written by Darryl L. Pierce * @@ -48,3 +51,5 @@ class ProcessorsAgent : public Manageable // agent methods void update_load_averages(void) const; }; + +#endif diff --git a/src/schema.xml b/src/schema.xml index 890e4ed..206e39b 100644 --- a/src/schema.xml +++ b/src/schema.xml @@ -23,21 +23,13 @@ - - - - - - - - - - - - - - - + + + + + + + -- 1.6.6.1 From dpierce at redhat.com Mon Apr 26 20:49:44 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Mon, 26 Apr 2010 16:49:44 -0400 Subject: [Ovirt-devel] Patch supercedes previous patch... Message-ID: <1272314985-12608-1-git-send-email-dpierce@redhat.com> In looking at the code I realized that the last of the HAL depenencies were removed with this patch. So, I'm pushing an updated patch that contains none of the HAL code in it. From dpierce at redhat.com Mon Apr 26 20:49:45 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Mon, 26 Apr 2010 16:49:45 -0400 Subject: [Ovirt-devel] [PATCH matahari] Created the NetworkDevice agent. In-Reply-To: <1272314985-12608-1-git-send-email-dpierce@redhat.com> References: <1272314985-12608-1-git-send-email-dpierce@redhat.com> Message-ID: <1272314985-12608-2-git-send-email-dpierce@redhat.com> Created a new class to represent network interface devices, named NetworkDeviceAgent. Removed the NICWrapper class, as well as the final vestiges of HAL dependencies. Signed-off-by: Darryl L. Pierce --- configure.ac | 3 - src/Makefile.am | 15 +-- src/hal.cpp | 83 -------------- src/hal.h | 24 ---- src/host.cpp | 26 +++-- src/host.h | 4 +- src/linux_platform.cpp | 70 +++++++++++ src/linux_platform.h | 4 + src/main.cpp | 1 - src/networkdevice.cpp | 49 ++++++++ src/networkdevice.h | 52 +++++++++ src/nic.cpp | 297 ------------------------------------------------ src/nic.h | 95 --------------- src/platform.h | 5 + src/processors.h | 5 + src/schema.xml | 22 +--- 16 files changed, 216 insertions(+), 539 deletions(-) delete mode 100644 src/hal.cpp delete mode 100644 src/hal.h create mode 100644 src/networkdevice.cpp create mode 100644 src/networkdevice.h delete mode 100644 src/nic.cpp delete mode 100644 src/nic.h diff --git a/configure.ac b/configure.ac index c51c23e..6666c95 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,5 @@ # Process this file with autoconf to produce a configure script. AC_INIT(matahari, 0.0.4) -AC_CONFIG_SRCDIR([src/nic.h]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE @@ -15,8 +14,6 @@ AC_HEADER_STDBOOL AC_TYPE_UINT32_T # Checks for libraries. -PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.2.12) -PKG_CHECK_MODULES(HAL, hal >= 0.5.12) PKG_CHECK_MODULES(LIBVIRT, libvirt >= 0.6.2) PKG_CHECK_MODULES(PCRE, libpcre >= 7.8) PKG_CHECK_MODULES(UDEV, libudev >= 145) diff --git a/src/Makefile.am b/src/Makefile.am index e4f394d..aed9e19 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,14 +1,13 @@ -INCLUDES = -I$(top_srcdir)/src/qmf/com/redhat/matahari $(HAL_CFLAGS) $(LIBVIRT_CFLAGS) $(PCRE_CFLAGS) $(UDEV_CFLAGS) +INCLUDES = -I$(top_srcdir)/src/qmf/com/redhat/matahari $(LIBVIRT_CFLAGS) $(PCRE_CFLAGS) $(UDEV_CFLAGS) sbin_PROGRAMS = matahari first = qmf/com/redhat/matahari/Host.cpp generated_file_list = \ - qmf/com/redhat/matahari/ArgsNICIdentify_nic.h \ qmf/com/redhat/matahari/Host.h \ - qmf/com/redhat/matahari/NIC.cpp \ - qmf/com/redhat/matahari/NIC.h \ + qmf/com/redhat/matahari/NetworkDevice.cpp \ + qmf/com/redhat/matahari/NetworkDevice.h \ qmf/com/redhat/matahari/Package.cpp \ qmf/com/redhat/matahari/Package.h \ qmf/com/redhat/matahari/Processors.cpp \ @@ -17,15 +16,13 @@ generated_file_list = \ nodist_matahari_SOURCES = $(generated_file_list) $(first) matahari_SOURCES = \ - hal.cpp \ - hal.h \ host.cpp \ host.h \ linux_platform.cpp \ linux_platform.h \ main.cpp \ - nic.cpp \ - nic.h \ + networkdevice.cpp \ + networkdevice.h \ platform.cpp \ platform.h \ processors.cpp \ @@ -41,6 +38,6 @@ CLEANFILES = $(generated_file_list) $(first) matahari_CPPFLAGS = -fno-strict-aliasing matahari_LDFLAGS = -L/usr/local/lib -matahari_LDADD = -lqmf $(HAL_LIBS) $(LIBVIRT_LIBS) $(PCRE_LIBS) $(UDEV_LIBS) +matahari_LDADD = -lqmf $(LIBVIRT_LIBS) $(PCRE_LIBS) $(UDEV_LIBS) dist_pkgdata_DATA = schema.xml diff --git a/src/hal.cpp b/src/hal.cpp deleted file mode 100644 index 66c1464..0000000 --- a/src/hal.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* hal_support.c - Copyright (C) 2008 Red Hat, Inc. - * Written by Darryl L. Pierce - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. A copy of the GNU General Public License is - * also available at http://www.gnu.org/copyleft/gpl.html. - */ - -#include "hal.h" -#include -#include - -DBusConnection *dbus_connection; -DBusError dbus_error; - -LibHalContext * -get_hal_ctx(void) -{ - LibHalContext *result = NULL; - - LibHalContext *ctx; - - ctx = libhal_ctx_new(); - if (ctx != NULL) { - dbus_error_init(&dbus_error); - dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error); - - if (!dbus_error_is_set(&dbus_error)) { - libhal_ctx_set_dbus_connection(ctx, dbus_connection); - - if (libhal_ctx_init(ctx, &dbus_error)) { - result = ctx; - } else { - fprintf(stderr, - "Failed to initial libhal context: %s : %s\n", - dbus_error.name, dbus_error.message); - } - } else { - fprintf(stderr, "Unable to connect to system bus: %s : %s\n", - dbus_error.name, dbus_error.message); - dbus_error_free(&dbus_error); - } - } else { - fprintf(stderr, "Unable to initialize HAL context.\n"); - } - - return result; -} - -void put_hal_ctx(LibHalContext *hal_ctx) -{ - libhal_ctx_shutdown(hal_ctx, NULL); - libhal_ctx_free(hal_ctx); -} - -char* get_uuid(LibHalContext *hal_ctx) -{ - const char *udi = "/org/freedesktop/Hal/devices/computer"; - const char *key = "system.hardware.uuid"; - char *value = NULL; - - int type = libhal_device_get_property_type(hal_ctx, udi, key, &dbus_error); - if (type == LIBHAL_PROPERTY_TYPE_STRING) { - value = libhal_device_get_property_string(hal_ctx, - udi, - key, - &dbus_error); - } - if (!value) - throw std::runtime_error("Unable to get host UUID"); - return value; -} diff --git a/src/hal.h b/src/hal.h deleted file mode 100644 index 03dd909..0000000 --- a/src/hal.h +++ /dev/null @@ -1,24 +0,0 @@ -/* hal.h - Copyright (C) 2009 Red Hat, Inc. - * Written by Arjun Roy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. A copy of the GNU General Public License is - * also available at http://www.gnu.org/copyleft/gpl.html. - */ - -#include - -LibHalContext *get_hal_ctx(void); -void put_hal_ctx(LibHalContext *hal_ctx); -char* get_uuid(LibHalContext *hal_ctx); diff --git a/src/host.cpp b/src/host.cpp index 11c5a8f..34d4550 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -25,6 +25,7 @@ #include #include "host.h" +#include "platform.h" #include "qmf/com/redhat/matahari/Host.h" using namespace qpid::management; @@ -41,6 +42,14 @@ HostAgent::setup(ManagementAgent* agent) // discover the aspects of the host processors.setup(agent, this); + networkdevices = Platform::instance()->get_network_devices(); + + for(vector::iterator iter = networkdevices.begin(); + iter != networkdevices.end(); + iter++) + { + iter->setup(agent, this); + } struct utsname details; string uuid = "Unknown"; @@ -94,20 +103,17 @@ HostAgent::setup(ManagementAgent* agent) management_object->set_arch(architecture); management_object->set_memory(memory); management_object->set_beeping(beeping); - - NICWrapper::fillNICInfo(this->nics, agent); - - // setup the nic objects - for(vector::iterator iter = nics.begin(); - iter != nics.end(); - iter++) - { - (*iter)->setupQMFObject(agent, this); - } } void HostAgent::update(void) { processors.update(); + + for(vector::iterator iter = networkdevices.begin(); + iter != networkdevices.end(); + iter++) + { + iter->update(); + } } diff --git a/src/host.h b/src/host.h index ba5a1ed..d2da776 100644 --- a/src/host.h +++ b/src/host.h @@ -26,7 +26,7 @@ #include "qmf/com/redhat/matahari/Host.h" -#include "nic.h" +#include "networkdevice.h" #include "processors.h" using namespace qpid::management; @@ -39,7 +39,7 @@ class HostAgent : public Manageable private: qmf::com::redhat::matahari::Host* management_object; ProcessorsAgent processors; - vector nics; + vector networkdevices; public: HostAgent() {} diff --git a/src/linux_platform.cpp b/src/linux_platform.cpp index 26418f5..fbcfdb9 100644 --- a/src/linux_platform.cpp +++ b/src/linux_platform.cpp @@ -18,9 +18,14 @@ */ #include +#include #include +#include +#include #include #include +#include +#include // TODO remove this wrapper once rhbz#583747 is fixed extern "C" { @@ -115,3 +120,68 @@ LinuxPlatform::get_load_average() const return load_average; } + +vector +LinuxPlatform::get_network_devices() const +{ + vector result; + + DIR* entries = opendir("/sys/class/net"); + + if(entries) + { + struct udev* udev = udev_new(); + struct dirent* entry; + + while(entry = (readdir(entries))) + { + string ifname = string(entry->d_name); + if(ifname != "." && ifname != "..") + { + string fullpath = "/sys/class/net/" + ifname; + struct udev_device* device = udev_device_new_from_syspath(udev, + fullpath.c_str()); + + if(udev_device_get_property_value(device, "ID_BUS")) + { + int sock = socket(AF_INET, SOCK_DGRAM, 0); + struct ifreq ifr; + string vendor = string(udev_device_get_property_value(device, "ID_VENDOR_FROM_DATABASE")); + string model = string(udev_device_get_property_value(device, "ID_MODEL_FROM_DATABASE")); + + if(sock >= 0) + { + ifr.ifr_addr.sa_family = AF_INET; + strncpy(ifr.ifr_name, ifname.c_str(), IFNAMSIZ - 1); + + if(!ioctl(sock, SIOCGIFHWADDR, &ifr)) + { + char macaddr[256]; + + sprintf(macaddr, + "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", + (unsigned char )ifr.ifr_hwaddr.sa_data[0], + (unsigned char )ifr.ifr_hwaddr.sa_data[1], + (unsigned char )ifr.ifr_hwaddr.sa_data[2], + (unsigned char )ifr.ifr_hwaddr.sa_data[3], + (unsigned char )ifr.ifr_hwaddr.sa_data[4], + (unsigned char )ifr.ifr_hwaddr.sa_data[5]); + + result.push_back(NetworkDeviceAgent(ifname, + vendor, + model, + string(macaddr))); + } + } + + udev_device_unref(device); + } + } + } + + udev_unref(udev); + closedir(entries); + } + + return result; +} diff --git a/src/linux_platform.h b/src/linux_platform.h index 13116df..095bc08 100644 --- a/src/linux_platform.h +++ b/src/linux_platform.h @@ -21,7 +21,10 @@ */ #include +#include + #include "platform.h" +#include "networkdevice.h" class LinuxPlatform : public Platform { @@ -30,6 +33,7 @@ class LinuxPlatform : public Platform virtual ~LinuxPlatform() {} virtual double get_load_average() const; + virtual vector get_network_devices() const; }; #endif diff --git a/src/main.cpp b/src/main.cpp index 8493864..5ab3ac2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,6 @@ #include -#include "hal.h" #include "host.h" #include "qmf/com/redhat/matahari/Package.h" diff --git a/src/networkdevice.cpp b/src/networkdevice.cpp new file mode 100644 index 0000000..5e30e33 --- /dev/null +++ b/src/networkdevice.cpp @@ -0,0 +1,49 @@ +/* networkingdevice.cpp - Copyright (C) 2010 Red Hat, Inc. + * Written by Darryl L. Pierce + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. A copy of the GNU General Public License is + * also available at http://www.gnu.org/copyleft/gpl.html. + */ + +#include +#include + +#include "networkdevice.h" + +namespace _qmf = qmf::com::redhat::matahari; + +NetworkDeviceAgent::NetworkDeviceAgent(string ifname, string vendor, string model, string macaddr) + :ifname(ifname) + ,vendor(vendor) + ,model(model) + ,macaddr(macaddr) +{} + +void +NetworkDeviceAgent::setup(ManagementAgent* agent, Manageable* parent) +{ + management_object = new _qmf::NetworkDevice(agent, this, parent); + agent->addObject(management_object); + + management_object->set_interface(ifname); + management_object->set_vendor(vendor); + management_object->set_model(model); + management_object->set_mac_address(macaddr); +} + +void +NetworkDeviceAgent::update() const +{ +} diff --git a/src/networkdevice.h b/src/networkdevice.h new file mode 100644 index 0000000..3884b22 --- /dev/null +++ b/src/networkdevice.h @@ -0,0 +1,52 @@ +#ifndef __NETWORKDEVICE_H +#define __NETWORKDEVICE_H + +/* networkdevice.h - Copyright (C) 2010 Red Hat, Inc. + * Written by Darryl L. Pierce + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. A copy of the GNU General Public License is + * also available at http://www.gnu.org/copyleft/gpl.html. + */ + +#include + +#include "qmf/com/redhat/matahari/NetworkDevice.h" + +using namespace qpid::management; +using namespace std; + +class NetworkDeviceAgent : public Manageable +{ + private: + qmf::com::redhat::matahari::NetworkDevice* management_object; + + string ifname; + string vendor; + string model; + string macaddr; + + public: + NetworkDeviceAgent(string ifname, string vendor, string model, string macaddr); + virtual ~NetworkDeviceAgent() {} + + string get_mac_address() const { return macaddr; } + + ManagementObject* GetManagementObject(void) const { return management_object; } + + void setup(ManagementAgent* agent, Manageable* parent); + void update() const; +}; + +#endif diff --git a/src/nic.cpp b/src/nic.cpp deleted file mode 100644 index 040ca67..0000000 --- a/src/nic.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* nic.cpp - Copyright (C) 2009 Red Hat, Inc. - * Written by Arjun Roy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. A copy of the GNU General Public License is - * also available at http://www.gnu.org/copyleft/gpl.html. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nic.h" -#include "qmf/com/redhat/matahari/NIC.h" -#include "qmf/com/redhat/matahari/ArgsNICIdentify_nic.h" - -using namespace qpid::management; -using namespace std; - -using qpid::management::Manageable; - -namespace _qmf = qmf::com::redhat::matahari; - -extern DBusConnection *dbus_connection; -extern DBusError dbus_error; - -ostream &operator<<(ostream& output, const NICWrapper& nic) { - output << "NIC" << endl; - output << "Interface Name: " << nic.interfaceName << endl; - output << "MAC Address: " << nic.macaddr << endl; - output << "IP Address: " << nic.ipaddr << endl; - output << "Netmask: " << nic.netmask << endl; - output << "Broadcast: " << nic.broadcast << endl; - output << "Bandwidth: " << nic.bandwidth << endl; - return output; -} - -void NICWrapper::setupQMFObject(ManagementAgent *agent, Manageable *parent) -{ - mgmt_object = new _qmf::NIC(agent, this, parent); - agent->addObject(mgmt_object); - syncQMFObject(); -} - -void NICWrapper::cleanupQMFObject(void) -{ - mgmt_object->resourceDestroy(); -} - -void NICWrapper::syncQMFObject(void) -{ - mgmt_object->set_interface(interfaceName); - mgmt_object->set_macaddr(macaddr); - mgmt_object->set_ipaddr(ipaddr); - mgmt_object->set_netmask(netmask); - mgmt_object->set_broadcast(broadcast); - mgmt_object->set_bandwidth(bandwidth); -} - -NICWrapper *NICWrapper::getNIC(ManagementAgent *agent, - LibHalContext *hal_ctx, - char *nic_handle) -{ - // Used to get the data - char *macaddr_c; - char *interface_c; - int sock, ret; - struct ifreq ifr; - struct ethtool_cmd ecmd; - - // The data that we care about - NICWrapper *nic = NULL; - string macaddr; - string interface; - string ipaddr; - string netmask; - string broadcast; - int bandwidth; - - // Grab the MAC Address from libhal - macaddr_c = libhal_device_get_property_string(hal_ctx, - nic_handle, - "net.address", - &dbus_error); - // Or throw an exception if we could not find it. No cleanup yet. - if (!macaddr_c) - throw runtime_error("Could not get mac address for NIC"); - - // Grab the interface name from libhal or return cleanup and fail - interface_c = libhal_device_get_property_string(hal_ctx, - nic_handle, - "net.interface", - &dbus_error); - // Or cleanup the macaddr and return NULL. - if (!interface_c) { - libhal_free_string(macaddr_c); - throw runtime_error("Could not get interface name for nic"); - } - - // Open socket for running ioctls for getting rest of data - sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock >= 0) { - // Get the IP Address - ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name, interface_c, IFNAMSIZ - 1); - cout << interface_c << endl; - - ret = ioctl(sock, SIOCGIFADDR, &ifr); - if(ret == 0) { - struct sockaddr_in *addr = (struct sockaddr_in *) &ifr.ifr_addr; - cout << "ip_address = " << inet_ntoa(addr->sin_addr) << endl; - ipaddr = inet_ntoa(addr->sin_addr); - } - else { - perror("SIOCGIFADDR"); - ipaddr = "unable to determine"; - } - // Get the netmask - ret = ioctl(sock, SIOCGIFNETMASK, &ifr); - if(ret == 0 && strcmp("255.255.255.255", - inet_ntoa(((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr))) { - - struct sockaddr_in *addr = (struct sockaddr_in *) &ifr.ifr_addr; - cout << "netmask = " << inet_ntoa(addr->sin_addr) << endl; - netmask = inet_ntoa(addr->sin_addr); - } - else { - perror("SIOCGIFNETMASK"); - netmask = "unable to determine"; - } - // Get the broadcast address - ret = ioctl(sock, SIOCGIFBRDADDR, &ifr); - if(ret == 0) { - struct sockaddr_in *addr = (struct sockaddr_in *) &ifr.ifr_addr; - cout << "broadcast = " << inet_ntoa(addr->sin_addr); - broadcast = inet_ntoa(addr->sin_addr); - } - else { - perror("SIOCGIFBRDADDR"); - broadcast = "unable to determine"; - } - // Get the bandwidth for this NIC - ecmd.cmd = ETHTOOL_GSET; - ifr.ifr_data = (caddr_t)&ecmd; - bandwidth = 10; - - // TODO: Error checking on this ioctl. For now, assume success - ret = ioctl(sock, SIOCETHTOOL, &ifr); - if (1) { - - if (ecmd.supported & SUPPORTED_10000baseT_Full) { - bandwidth = 10000; - } else if (ecmd.supported & SUPPORTED_2500baseX_Full) { - bandwidth = 2500; - } else if (ecmd.supported & (SUPPORTED_1000baseT_Half | - SUPPORTED_1000baseT_Full)) { - bandwidth = 1000; - } else if (ecmd.supported & (SUPPORTED_100baseT_Half | - SUPPORTED_100baseT_Full)) { - bandwidth = 100; - } else if (ecmd.supported & (SUPPORTED_10baseT_Half | - SUPPORTED_10baseT_Full)) { - bandwidth = 10; - } - } - else { - cout << "Unable to determine link speed, defaulting to 10" << endl; - } - // And we're done here - close(sock); - } - else { - /* Couldn't open socket, so cleanup and fail */ - libhal_free_string(interface_c); - libhal_free_string(macaddr_c); - throw runtime_error("Unable to open socket."); - } - // We have all the data. Create the NICWrapper instance - macaddr = macaddr_c; - interface = interface_c; - nic = new NICWrapper(interface, - macaddr, - ipaddr, - netmask, - broadcast, - bandwidth); - - // Free resources and return - libhal_free_string(interface_c); - libhal_free_string(macaddr_c); - return nic; -} - -/** - * void fillNICInfo(vector &nics, - * ManagementAgent *agent, - * LibHalContext *hal_ctx) - * - * Takes in a vector of NICWrapper object pointers and populates it with - * NICs found in the system found by querying dbus and making other system - * calls. - */ -void NICWrapper::fillNICInfo(vector &nics, - ManagementAgent *agent) -{ - LibHalContext* hal_ctx = get_hal_ctx(); - char **net_devices; - int num_results, i; - net_devices = libhal_find_device_by_capability(hal_ctx, - "net.80203", - &num_results, - &dbus_error); - if (!net_devices) - throw runtime_error("Error: Couldn't get NIC devices through libhal."); - - cout << "Found " << num_results << " NICs" << endl; - for (i = 0; i < num_results; i++) { - NICWrapper *nic; - char *nic_handle = net_devices[i]; - // If we couldn't read the info for a nic, free the list of devices - // and throw an error. Any devices added already will be cleaned up - // by the caller. - try { - nic = getNIC(agent, hal_ctx, nic_handle); - } - catch (...) { - libhal_free_string_array(net_devices); - throw; - } - // Add the NIC to our list - nics.push_back(nic); - } - // And we're all done. - libhal_free_string_array(net_devices); -} - -int NICWrapper::identifyNIC(int seconds) -{ - struct ethtool_value edata; - struct ifreq ifr; - int sock, ret; - - edata.cmd = ETHTOOL_PHYS_ID; - edata.data = seconds; // seconds of blink time - - strncpy(ifr.ifr_name, interfaceName.c_str(), IFNAMSIZ - 1); - ifr.ifr_data = (caddr_t)&edata; - - sock = socket(AF_INET, SOCK_DGRAM, 0); - ret = ioctl(sock, SIOCETHTOOL, &ifr); - close(sock); - - if (ret != 0) - ret = errno; - - return ret; -} - -Manageable::status_t -NICWrapper::ManagementMethod(uint32_t methodId, Args& args, string& text) -{ - switch (methodId) { - case _qmf::NIC::METHOD_IDENTIFY_NIC: - _qmf::ArgsNICIdentify_nic& ioArgs = (_qmf::ArgsNICIdentify_nic&) args; - int seconds = ioArgs.i_seconds; - ioArgs.o_ret = identifyNIC(seconds); - return STATUS_OK; - } - - return STATUS_NOT_IMPLEMENTED; -} diff --git a/src/nic.h b/src/nic.h deleted file mode 100644 index e0e5874..0000000 --- a/src/nic.h +++ /dev/null @@ -1,95 +0,0 @@ -/* nic.h - Copyright (C) 2009 Red Hat, Inc. - * Written by Arjun Roy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. A copy of the GNU General Public License is - * also available at http://www.gnu.org/copyleft/gpl.html. - */ - -#include -#include -#include - -#include "qmf/com/redhat/matahari/NIC.h" -#include "hal.h" - -using namespace qpid::management; -using namespace std; - -using qpid::management::Manageable; - -class NICWrapper : public Manageable -{ - friend ostream& operator <<(ostream &output, const NICWrapper& nic); - friend class HostWrapper; - - // NIC Parameters - string interfaceName; - string macaddr; - string ipaddr; - string netmask; - string broadcast; - int bandwidth; - - // QMF related fields - ManagementAgent *agent; - qmf::com::redhat::matahari::NIC *mgmt_object; - - // Methods to put up / take down QMF Objects - void cleanupQMFObject(void); - void syncQMFObject(void); - - // Constructors and Destructor are private - NICWrapper() {} - NICWrapper(const NICWrapper&) {} - ~NICWrapper() {} - - NICWrapper(const string &interfaceName__, - const string &macaddr__, - const string &ipaddr__, - const string &netmask__, - const string &broadcast__, - int bandwidth__) { - interfaceName = interfaceName__; - macaddr = macaddr__; - ipaddr = ipaddr__; - netmask = netmask__; - broadcast = broadcast__; - bandwidth = bandwidth__; - } - - static NICWrapper *getNIC(ManagementAgent *agent, - LibHalContext *hal_ctx, - char *nic_handle); - - int identifyNIC(int seconds); -public: - - void setupQMFObject(ManagementAgent *agent, Manageable *parent); - // Factory like method - static void fillNICInfo(vector &nics, - ManagementAgent *agent); - - // QMF Methods - ManagementObject *GetManagementObject(void) const { return mgmt_object; } - status_t ManagementMethod(uint32_t methodId, Args& args, string& text); - - // Field Accessors - const string &getInterfaceName(void) { return interfaceName; } - const string &getMacaddr(void) { return macaddr; } - const string &getIpaddr(void) { return ipaddr; } - const string &getNetmask(void) { return netmask; } - const string &getBroadcast(void) { return broadcast; } - int getBandwidth(void) { return bandwidth; } -}; diff --git a/src/platform.h b/src/platform.h index 514ad20..54fbe37 100644 --- a/src/platform.h +++ b/src/platform.h @@ -21,6 +21,8 @@ */ #include +#include +#include "networkdevice.h" using namespace std; @@ -57,6 +59,9 @@ class Platform // returns the load average for the platform virtual double get_load_average() const = 0; + + // returns the list of network devices for this platform + virtual vector get_network_devices() const = 0; }; #endif diff --git a/src/processors.h b/src/processors.h index 17a6a6a..e681453 100644 --- a/src/processors.h +++ b/src/processors.h @@ -1,3 +1,6 @@ +#ifndef __PROCESSORS_H +#define __PROCESSORS_H + /* processor.h - Copyright (C) 2010 Red Hat, Inc. * Written by Darryl L. Pierce * @@ -48,3 +51,5 @@ class ProcessorsAgent : public Manageable // agent methods void update_load_averages(void) const; }; + +#endif diff --git a/src/schema.xml b/src/schema.xml index 890e4ed..206e39b 100644 --- a/src/schema.xml +++ b/src/schema.xml @@ -23,21 +23,13 @@ - - - - - - - - - - - - - - - + + + + + + + -- 1.6.6.1 From juventus8666 at sohu.com Tue Apr 27 05:38:37 2010 From: juventus8666 at sohu.com (juventus8666) Date: Tue, 27 Apr 2010 13:38:37 +0800 Subject: [Ovirt-devel] install Message-ID: <201004271338356719343@sohu.com> I ovirt in research, The latest version? The new version of the installation files when out ? 2010-04-27 juventus8666 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dpierce at redhat.com Tue Apr 27 11:28:34 2010 From: dpierce at redhat.com (Darryl L. Pierce) Date: Tue, 27 Apr 2010 07:28:34 -0400 Subject: [Ovirt-devel] install In-Reply-To: <201004271338356719343@sohu.com> References: <201004271338356719343@sohu.com> Message-ID: <20100427112834.GE26176@mcpierce-desktop.usersys.redhat.com> On Tue, Apr 27, 2010 at 01:38:37PM +0800, juventus8666 wrote: > I ovirt in research, > The latest version? > The new version of the installation files when out ? > 2010-04-27 Hi. You can find the latest versions of ovirt-server and ovirt-node in our yum repo: http://www.ovirt.org/repos/ovirt/ Currently, the latest version is 1.9.1 for Fedora 12. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From apevec at gmail.com Fri Apr 30 21:39:54 2010 From: apevec at gmail.com (Alan Pevec) Date: Fri, 30 Apr 2010 23:39:54 +0200 Subject: [Ovirt-devel] [PATCH] Fixed the configuration setup to be more complete. In-Reply-To: <1271957461-19299-1-git-send-email-dpierce@redhat.com> References: <1271957461-19299-1-git-send-email-dpierce@redhat.com> Message-ID: after applying this patch, ./autogen.sh fails with: checking for ruby... ruby checking for main in -lruby... yes ./configure: line 3635: syntax error near unexpected token `fi' ./configure: line 3635: `fi' From apevec at gmail.com Fri Apr 30 21:42:23 2010 From: apevec at gmail.com (Alan Pevec) Date: Fri, 30 Apr 2010 23:42:23 +0200 Subject: [Ovirt-devel] [PATCH] Fixed the autoconf setup to check for necessary libraries and tools. In-Reply-To: <1271966698-9378-1-git-send-email-dpierce@redhat.com> References: <1271966698-9378-1-git-send-email-dpierce@redhat.com> Message-ID: ACK