Skip to content

Commit

Permalink
Merge pull request #58 from stdweird/more_aii_fixes
Browse files Browse the repository at this point in the history
Add more unittests to AII and start code refresh
  • Loading branch information
Piojo committed Apr 24, 2014
2 parents be745a6 + ce1e887 commit 0b979cb
Show file tree
Hide file tree
Showing 12 changed files with 295 additions and 155 deletions.
30 changes: 15 additions & 15 deletions aii-ks/src/main/perl/ks.pm
Expand Up @@ -232,9 +232,9 @@ sub kscommands
}
print <<EOF;
install
$installtype
text
reboot
$installtype
timezone --utc $tree->{timezone}
rootpw --iscrypted $tree->{rootpw}
EOF
Expand All @@ -253,7 +253,7 @@ EOF
print " --level=$tree->{logging}->{level}" if $tree->{logging}->{level};
print "\n";
}
print "bootloader --location=$tree->{bootloader_location}";
print "bootloader --location=$tree->{bootloader_location}";
print " --driveorder=", join(',', @{$tree->{bootdisk_order}})
if exists $tree->{bootdisk_order} && @{$tree->{bootdisk_order}};
print " --append=\"$tree->{bootloader_append}\""
Expand Down Expand Up @@ -301,19 +301,19 @@ EOF
print "ignoredisk --drives=",
join (',', @{$tree->{ignoredisk}}), "\n";
}
print "%packages ", join(" ",@{$tree->{packages_args}}), "\n",
join ("\n", @{$tree->{packages}}), "\n";

## enable services, if any
if (exists($tree->{enable_service}) && @{$tree->{enable_service}}) {
## should be a list of strings
my $services = join(" ",@{$tree->{enable_service}});
if ($services) {
print "services --enabled=",
join (',', @{$tree->{enable_service}}), "\n";;
}
};

## disable and enable services, if any
my @services;
push(@services, "--disabled=".join(',', @{$tree->{disable_service}})) if
(exists($tree->{disable_service}) && @{$tree->{disable_service}});
push(@services, "--enabled=".join(',', @{$tree->{enable_service}})) if
(exists($tree->{enable_service}) && @{$tree->{enable_service}});

print "services ", join (' ', @services), "\n" if (@services);

print "%packages ", join(" ",@{$tree->{packages_args}}), "\n",
join ("\n", @{$tree->{packages}}), "\n",
$config->getElement(END_SCRIPT_FIELD)->getValue(), "\n";
}

# Writes the mountpoint definitions and LVM and MD settings
Expand Down Expand Up @@ -1018,7 +1018,7 @@ EOF
ksfix_grub;
}

## disable services, if any
# delete services, if any
if (exists($tree->{disable_service})) {
## should be a list of strings
my $services = join(" ",@{$tree->{disable_service}});
Expand Down
9 changes: 3 additions & 6 deletions aii-ks/src/main/perl/ks.pod
Expand Up @@ -142,9 +142,7 @@ or "permissive".

=item * disable_service ? string[]

List of services to be disabled before the reboot, in order to avoid
nasty behaviour such as, f.i, grabbing lots of RPMs from CERN because
of Yum.
List of services to be disabled and removed before the reboot.

=item * base_packages ? string[]

Expand Down Expand Up @@ -206,10 +204,9 @@ Whether or not the firewall must be enabled.
List of trusted devices. Traffic from and to these devices will not be
filtered.

=item * services : string[]
=item * enable_service : string[]

List of service names to be allowed by the firewall. Each element must
be one of ssh, telnet, smtp, http, ftp. Defaults to "ssh".
List of service names to be allowed by the firewall.

=item * ports : long[]

Expand Down
46 changes: 46 additions & 0 deletions aii-ks/src/test/perl/kickstart_commands.t
@@ -0,0 +1,46 @@
use strict;
use warnings;
use Test::More;
use Test::Quattor qw(kickstart_commands);
use NCM::Component::ks;
use CAF::FileWriter;
use CAF::Object;

=pod
=head1 SYNOPSIS
Tests for the C<kscommands> method.
=cut

$CAF::Object::NoAction = 1;

my $fh = CAF::FileWriter->new("target/test/ks");
# This module simply prints to the default filehandle.
select($fh);

my $ks = NCM::Component::ks->new('ks');
my $cfg = get_config_for_profile('kickstart_commands');

NCM::Component::ks::kscommands($cfg);

like($fh, qr{^text}m, 'text mode install present');
like($fh, qr{^reboot}m, 'reboot after install present');
like($fh, qr{^skipx}m, 'skip x configuration present');
like($fh, qr{^auth\s--enableshadow\s--enablemd5}m, 'authentication parameters present');
like($fh, qr{^install\n^url\s--url http://baseos}m, 'installtype present');
like($fh, qr{^timezone\s--utc Europe/SomeCity}m, 'timezone present');
like($fh, qr{^rootpw\s--iscrypted veryverysecret}m, 'crypted root password present');
like($fh, qr{^bootloader\s--location=mbr}m, 'bootloader present');
like($fh, qr{^lang\sen_US.UTF-8}m, 'lang setting present');
like($fh, qr{^keyboard\sus}m, 'keyboard present');
like($fh, qr{^firewall\s--disabled }m, ' present');
like($fh, qr{^network\s--bootproto=dhcp}m, ' present');
like($fh, qr{^zerombr yes}m, 'zerombr present');
like($fh, qr{^services\s--disabled=disable1,DISABLE2\s--enabled=enable1,ENABLE2}m, "--dis/enable services present");

like($fh, qr{^%packages\s--ignoremissing\s--resolvedeps\n^package\n^package2\n^EENNDD\n}m, 'installtype present');


done_testing();
12 changes: 1 addition & 11 deletions aii-ks/src/test/resources/kernel-firmware.pan
Expand Up @@ -3,14 +3,4 @@
@}
object template kernel-firmware;

prefix "/software/packages";

"{kernel*}/{2.6.32-358.1.el6}/arch/x86_64" = "";
"{kernel-firmware}/{2.6.32-358.1.el6}/arch/noarch" = "";
"{ncm-spma}/{14.2.1-1}/arch/noarch" = "";
"{kernel-module-foo}" = nlist();

prefix "/system/aii/osinstall/ks";

"base_packages" = list("ncm-spma", "kernel-module-foo");
"disabled_repos" = list();
include 'kickstart';
47 changes: 47 additions & 0 deletions aii-ks/src/test/resources/kickstart.pan
@@ -0,0 +1,47 @@
@{
Base kickstart data
@}
template kickstart;

"/system/network/hostname" = 'x';
"/system/network/domainname" = 'y';

prefix "/software/packages";

"{kernel*}/{2.6.32-358.1.el6}/arch/x86_64" = "";
"{kernel-firmware}/{2.6.32-358.1.el6}/arch/noarch" = "";
"{ncm-spma}/{14.2.1-1}/arch/noarch" = "";
"{kernel-module-foo}" = nlist();


# pxelinux and kickstart couple if bootproto is not dhcp
prefix "/system/aii/nbp/pxelinux";
"ksdevice" = "eth0";

prefix "/system/aii/osinstall/ks";
"bootproto" = "dhcp";
"keyboard" = "us";
"lang" = "en_US.UTF-8";
"node_profile" = "https://somewhere/node_profile";
"rootpw" = "veryverysecret";
"osinstall_protocol" = "https";
"ackurl" = "http://ack";
"auth" = list ("enableshadow", "enablemd5");
"bootloader_location" = "mbr";
"clearmbr" = true;
"enable_sshd" = false;
"email_success" = false;
"installtype" = "url --url http://baseos";
"timezone" = "Europe/SomeCity";
"packages" = list("package", "package2");
"packages_args" = list("--ignoremissing","--resolvedeps");
"end_script" = "EENNDD";
"part_label" = false;
"volgroup_required" = false;


# optional
"enable_service" = list("enable1", "ENABLE2");
"disable_service" = list("disable1", "DISABLE2");
"base_packages" = list("ncm-spma", "kernel-module-foo");
"disabled_repos" = list();
7 changes: 7 additions & 0 deletions aii-ks/src/test/resources/kickstart_commands.pan
@@ -0,0 +1,7 @@
@{
Profile to ensure that the kickstart commands and packages section are generated
@}
object template kickstart_commands;

include 'kickstart';

4 changes: 2 additions & 2 deletions aii-pxelinux/pom.xml
Expand Up @@ -54,14 +54,14 @@
<groupId>org.quattor.maven</groupId>
<artifactId>assemblies</artifactId>
<type>tar.gz</type>
<version>1.22</version>
<version>1.34</version>
<classifier>assemblies</classifier>
</dependency>
<dependency>
<groupId>org.quattor.maven</groupId>
<artifactId>build-scripts</artifactId>
<type>tar.gz</type>
<version>1.22</version>
<version>1.34</version>
<classifier>scripts</classifier>
</dependency>
</dependencies>
Expand Down

0 comments on commit 0b979cb

Please sign in to comment.