| 1 | package XAS::Lib::Batch::Server; | ||
| 2 | |||
| 3 | our $VERSION = '0.01'; | ||
| 4 | |||
| 5 | use XAS::Class | ||
| 6 | debug => 0, | ||
| 7 | version => $VERSION, | ||
| 8 | base => 'XAS::Lib::Batch', | ||
| 9 | ; | ||
| 10 | |||
| 11 | # ---------------------------------------------------------------------- | ||
| 12 | # Public Methods | ||
| 13 | # ---------------------------------------------------------------------- | ||
| 14 | |||
| 15 | sub qstat { | ||
| 16 | my $self = shift; | ||
| 17 | my $p = $self->validate_params(\@_, { | ||
| 18 | -queue => { optional => 1, default => undef }, | ||
| 19 | -host => { optional => 1, default => undef }, | ||
| 20 | }); | ||
| 21 | |||
| 22 | return $self->do_server_stat($p); | ||
| 23 | |||
| 24 | } | ||
| 25 | |||
| 26 | sub qenable { | ||
| 27 | my $self = shift; | ||
| 28 | my $p = $self->validate_params(\@_, { | ||
| 29 | -queue => { optional => 1, default => undef }, | ||
| 30 | -host => { optional => 1, default => undef }, | ||
| 31 | }); | ||
| 32 | |||
| 33 | return $self->do_server_enable($p); | ||
| 34 | |||
| 35 | } | ||
| 36 | |||
| 37 | sub qdisable { | ||
| 38 | my $self = shift; | ||
| 39 | my $p = $self->validate_params(\@_, { | ||
| 40 | -queue => { optional => 1, default => undef }, | ||
| 41 | -host => { optional => 1, default => undef }, | ||
| 42 | }); | ||
| 43 | |||
| 44 | return $self->do_server_disable($p); | ||
| 45 | |||
| 46 | } | ||
| 47 | |||
| 48 | # ---------------------------------------------------------------------- | ||
| 49 | # Private Methods | ||
| 50 | # ---------------------------------------------------------------------- | ||
| 51 | |||
| 52 | 1; | ||
| 53 | |||
| 54 | __END__ | ||
| 55 | |||
| 56 | =head1 NAME | ||
| 57 | |||
| 58 | XAS::Lib::Batch::Server - A class for the XAS environment | ||
| 59 | |||
| 60 | =head1 SYNOPSIS | ||
| 61 | |||
| 62 | use XAS::Lib::Batch::Server; | ||
| 63 | |||
| 64 | my $server = XAS::Lib::Batch::Server->new(); | ||
| 65 | |||
| 66 | my $stat = $server->qstat(); | ||
| 67 | |||
| 68 | =head1 DESCRIPTION | ||
| 69 | |||
| 70 | This module provides an interface for manipulating servers in a Batch System. | ||
| 71 | Each available method is a wrapper around a given command. A command line | ||
| 72 | is built, executed, and the return code is checked. If the return code is | ||
| 73 | non-zero an exception is thrown. The exception will include the return code | ||
| 74 | and the first line from stderr. | ||
| 75 | |||
| 76 | Since each method is a wrapper, there is a corresponding man page for the | ||
| 77 | actual command. They should also be checked when problems arise. | ||
| 78 | |||
| 79 | =head1 METHODS | ||
| 80 | |||
| 81 | =head2 new | ||
| 82 | |||
| 83 | This method initializes the module and takes these parameters: | ||
| 84 | |||
| 85 | =over 4 | ||
| 86 | |||
| 87 | =item B<-interface> | ||
| 88 | |||
| 89 | The command line interface to use. This defaults to 'XAS::Lib::Batch::Interface::Torque'. | ||
| 90 | |||
| 91 | =back | ||
| 92 | |||
| 93 | =head2 qstat(...) | ||
| 94 | |||
| 95 | This method returns that status of a server. This status will be a hash | ||
| 96 | reference of the parsed output on stdout. It takes the following paramters: | ||
| 97 | |||
| 98 | =over 4 | ||
| 99 | |||
| 100 | =item B<-host> | ||
| 101 | |||
| 102 | The optional host that the server may be on. Defaults to 'localhost'. | ||
| 103 | |||
| 104 | =back | ||
| 105 | |||
| 106 | =head2 qdisable(...) | ||
| 107 | |||
| 108 | This method will disable a queue or if the queue is not given, batch processing | ||
| 109 | at the server. It takes the following paramters: | ||
| 110 | |||
| 111 | =over 4 | ||
| 112 | |||
| 113 | =item B<-queue> | ||
| 114 | |||
| 115 | The optional name of the queue. | ||
| 116 | |||
| 117 | =item B<-host> | ||
| 118 | |||
| 119 | The optional host that the queue may be on. Defaults to 'localhost'. | ||
| 120 | |||
| 121 | =back | ||
| 122 | |||
| 123 | =head2 qenable(...) | ||
| 124 | |||
| 125 | This method will enable a queue or if the queue is not given, batch processing | ||
| 126 | at the server. It takes the following paramters: | ||
| 127 | |||
| 128 | =over 4 | ||
| 129 | |||
| 130 | =item B<-queue> | ||
| 131 | |||
| 132 | The optional name of the queue. | ||
| 133 | |||
| 134 | =item B<-host> | ||
| 135 | |||
| 136 | The optional host that the queue may be on. Defaults to 'localhost'. | ||
| 137 | |||
| 138 | =back | ||
| 139 | |||
| 140 | =head1 SEE ALSO | ||
| 141 | |||
| 142 | =over 4 | ||
| 143 | |||
| 144 | =item L<XAS::Lib::Batch|XAS::Lib::Batch> | ||
| 145 | |||
| 146 | =item L<XAS|XAS> | ||
| 147 | |||
| 148 | =back | ||
| 149 | |||
| 150 | =head1 AUTHOR | ||
| 151 | |||
| 152 | Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt> | ||
| 153 | |||
| 154 | =head1 COPYRIGHT AND LICENSE | ||
| 155 | |||
| 156 | Copyright (c) 2015 Kevin L. Esteb | ||
| 157 | |||
| 158 | This is free software; you can redistribute it and/or modify it under | ||
| 159 | the terms of the Artistic License 2.0. For details, see the full text | ||
| 160 | of the license at http://www.perlfoundation.org/artistic_license_2_0. | ||
| 161 | |||
| 162 | =cut |