[PATCH] Change the date format used in RHEV OVF output
Date formats were previously undefined in RHEV's OVF output. They are now defined as: 'yyyy/mm/dd hh:mm:ss'. This change updates dates output by virt-v2v to use the new format. --- lib/Sys/VirtV2V/Target/RHEV.pm | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/Sys/VirtV2V/Target/RHEV.pm b/lib/Sys/VirtV2V/Target/RHEV.pm index 911e5c6..f14c54f 100644 --- a/lib/Sys/VirtV2V/Target/RHEV.pm +++ b/lib/Sys/VirtV2V/Target/RHEV.pm @@ -543,10 +543,7 @@ sub create_guest $memsize = int($memsize / 1024); # Generate a creation date - my $now = gmtime(); - my $vmcreation = sprintf("%02d/%02d/%d %02d:%02d:%02d", - $now->mday(), $now->mon() + 1, $now->year() + 1900, - $now->hour(), $now->min(), $now->sec()); + my $vmcreation = _format_time(gmtime()); my $osuuid = Sys::VirtV2V::Target::RHEV::UUIDHelper::get_uuid(); @@ -651,6 +648,14 @@ EOF $nfs->check_exit(); } +sub _format_time +{ + my ($time) = @_; + return sprintf("%04d/%02d/%02d %02d:%02d:%02d", + $time->year() + 1900, $time->mon() + 1, $time->mday(), + $time->hour(), $time->min(), $time->sec()); +} + sub _disks { my $self = shift; @@ -756,11 +761,7 @@ sub _disks $e->addText('00000000-0000-0000-0000-000000000000'); $item->appendChild($e); - my $volcreation = gmtime($vol->_get_creation()); - my $voldate = sprintf("%02d/%02d/%d %02d:%02d:%02d", - $volcreation->mday(), $volcreation->mon() + 1, - $volcreation->year() + 1900, $volcreation->hour(), - $volcreation->min(), $volcreation->sec()); + my $voldate = _format_time(gmtime($vol->_get_creation())); $e = $ovf->createElement('rasd:CreationDate'); $e->addText($voldate); -- 1.6.6.1
On Wed, Apr 14, 2010 at 11:59:53AM +0100, Matthew Booth wrote:
Date formats were previously undefined in RHEV's OVF output. They are now defined as: 'yyyy/mm/dd hh:mm:ss'.
This change updates dates output by virt-v2v to use the new format.
Can't find any reference to dates in the standard itself, but shouldn't they use the ISO format, ie. YYYY-MM-DD? Anyway, since this patch is just to interoperate with RHEV, ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
participants (2)
-
Matthew Booth -
Richard W.M. Jones