Skip to content

Commit

Permalink
move RegistrationStatus.pm from wagon to yast2 (fate#312712)
Browse files Browse the repository at this point in the history
This module is of general use and not specific to wagon
As it needs to be enhanced on behalf of fate312712 it easier to maintain
it in its new position.
  • Loading branch information
jdsn committed Oct 31, 2012
1 parent 03a5524 commit 3c8a956
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/modules/Makefile.am
Expand Up @@ -2,7 +2,7 @@

SUBDIRS = . testsuite

module_DATA = MailTableInclude.pm MailTable.pm $(wildcard *.ycp)
module_DATA = MailTableInclude.pm MailTable.pm $(wildcard *.ycp) $(wildcard *.pm)
EXTRA_DIST = $(module_DATA) Version.ycp.in

YCPCFLAGS = -M ../types/src
Expand Down
69 changes: 69 additions & 0 deletions library/modules/RegistrationStatus.pm
@@ -0,0 +1,69 @@
#
# Copyright (c) 2011 Novell, Inc.
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# 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, contact Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail,
# you may find current contact information at www.novell.com
#

package RegistrationStatus;

use strict;
use Data::Dumper;
use XML::Simple;

use YaST::YCP qw(:DATA :LOGGING);

our %TYPEINFO;

# see https://wiki.innerweb.novell.com/index.php/Registration#Add_Registration_Status_to_zmdconfig
# for more datils about the file format
my $reg_file = "/var/lib/suseRegister/registration-status.xml";

# return the default registration status file name
BEGIN{ $TYPEINFO{RegFile} = ["function", "string"]; }
sub RegFile {
my ($self) = @_;
return $reg_file;
}

# parse the default registration XML status file
BEGIN{ $TYPEINFO{Read} = ["function", ["map","any","any"]]; }
sub Read {
my ($self) = @_;
return ReadFile($reg_file);
}

# parse the requested registration XML status file, convert the XML file into a map
BEGIN{ $TYPEINFO{ReadFile} = ["function", ["map","any","any"], "string"]; }
sub ReadFile {
my $self = shift;
my $file = shift;

# create XML parser
my $parser = new XML::Simple;

# parse the file
my $data = $parser->XMLin($file);

my $dump = Dumper($data);
y2milestone("Parsed file $file: $dump");

return $data;
}

1

2 changes: 1 addition & 1 deletion yast2.spec.in
Expand Up @@ -28,7 +28,7 @@ Requires: coreutils sysconfig
Requires: yast2-xml yast2-hardware-detection
# for SLPAPI.pm
Requires: yast2-perl-bindings
# for ag_anyxml
# for ag_anyxml, RegistrationStatus.pm
Requires: perl-XML-Simple
# for ProductProfile.ycp
Requires: subscription-tools
Expand Down

0 comments on commit 3c8a956

Please sign in to comment.