diff options
author | Oliver Tappe | 2007-03-15 22:41:10 +0100 |
---|---|---|
committer | Oliver Tappe | 2007-03-15 22:41:10 +0100 |
commit | 03db5fcadee81bd5ce66665f18b611e106783c27 (patch) | |
tree | 1071ff956228157c52fbd5b5087ca8928b37d0f9 /config-db/OpenSLX/MetaDB | |
parent | * removed 'nbd' from supported export types as I have learned from Dirk yeste... (diff) | |
download | core-03db5fcadee81bd5ce66665f18b611e106783c27.tar.gz core-03db5fcadee81bd5ce66665f18b611e106783c27.tar.xz core-03db5fcadee81bd5ce66665f18b611e106783c27.zip |
* largish overhaul, changed ConfigDB to be object-oriented (could be improved, though!)
* slxos-setup, slxos-export, slxconfig and slxconfig-demuxer can now be run one after the
other in order to get a complete setup
* still problems when trying to boot that system here, need to investigate...
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@774 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db/OpenSLX/MetaDB')
-rw-r--r-- | config-db/OpenSLX/MetaDB/Base.pm | 256 | ||||
-rw-r--r-- | config-db/OpenSLX/MetaDB/CSV.pm | 2 | ||||
-rw-r--r-- | config-db/OpenSLX/MetaDB/DBI.pm | 136 | ||||
-rw-r--r-- | config-db/OpenSLX/MetaDB/SQLite.pm | 2 | ||||
-rw-r--r-- | config-db/OpenSLX/MetaDB/mysql.pm | 2 |
5 files changed, 198 insertions, 200 deletions
diff --git a/config-db/OpenSLX/MetaDB/Base.pm b/config-db/OpenSLX/MetaDB/Base.pm index f42b5412..41d35d9f 100644 --- a/config-db/OpenSLX/MetaDB/Base.pm +++ b/config-db/OpenSLX/MetaDB/Base.pm @@ -21,11 +21,11 @@ sub new confess "Don't create OpenSLX::MetaDB::Base - objects directly!"; } -sub connectConfigDB +sub connect { } -sub disconnectConfigDB +sub disconnect { } @@ -36,51 +36,51 @@ sub quote ################################################################################ ### data access interface ################################################################################ -sub fetchVendorOSesByFilter +sub fetchVendorOSByFilter { } -sub fetchVendorOSesByID +sub fetchVendorOSByID { } -sub fetchSystemsByFilter +sub fetchExportByFilter { } -sub fetchSystemsByID +sub fetchExportByID { } -sub fetchSystemIDsOfVendorOS +sub fetchExportIDsOfVendorOS { } -sub fetchSystemIDsOfClient +sub fetchSystemByFilter { } -sub fetchSystemIDsOfGroup +sub fetchSystemByID { } -sub fetchSystemVariantsByFilter +sub fetchSystemIDsOfExport { } -sub fetchSystemVariantsByID +sub fetchSystemIDsOfClient { } -sub fetchSystemVariantIDsOfSystem +sub fetchSystemIDsOfGroup { } -sub fetchClientsByFilter +sub fetchClientByFilter { } -sub fetchClientsByID +sub fetchClientByID { } @@ -92,11 +92,11 @@ sub fetchClientIDsOfGroup { } -sub fetchGroupsByFilter +sub fetchGroupByFilter { } -sub fetchGroupsByID +sub fetchGroupByID { } @@ -136,27 +136,27 @@ sub changeVendorOS { } -sub addSystem +sub addExport { } -sub removeSystem +sub removeExport { } -sub changeSystem +sub changeExport { } -sub addSystemVariant +sub addSystem { } -sub removeSystemVariant +sub removeSystem { } -sub changeSystemVariant +sub changeSystem { } @@ -425,7 +425,7 @@ allow the user to access data: =over -=item C<fetchVendorOSesByFilter([%$filter], [$resultCols])> +=item C<fetchVendorOSByFilter([%$filter], [$resultCols])> Fetches and returns information about all vendor-OSes that match the given filter. @@ -447,7 +447,7 @@ An array of hash-refs containing the resulting data rows. =back -=item C<fetchVendorOSesByID(@$ids, [$resultCols])> +=item C<fetchVendorOSByID(@$ids, [$resultCols])> Fetches and returns information the vendor-OSes with the given IDs. @@ -467,21 +467,21 @@ An array of hash-refs containing the resulting data rows. =back -=item C<fetchSystemsByFilter([%$filter], [$resultCols])> +=item C<fetchExportByFilter([%$filter], [$resultCols])> -Fetches and returns information about all systems that match the given filter. +Fetches and returns information about all exports that match the given +filter. =over -=item Param C<$filter> +=item Param C<filter> A hash-ref containing the filter criteria that shall be applied - default is no filtering. See L</"Filters"> for more info. -=item Param C<$resultCols> [Optional] +=item Param C<resultCols> -A comma-separated list of colunm names that shall be returned. If not defined, -all available data must be returned. +A string listing the columns that shall be returned - default is all columns. =item Return Value @@ -489,15 +489,15 @@ An array of hash-refs containing the resulting data rows. =back -=item C<fetchSystemsByID(@$ids, [$resultCols])> +=item C<fetchExportByID(@$ids, [$resultCols])> -Fetches and returns information the systems with the given IDs. +Fetches and returns information the exports with the given IDs. =over =item Param C<ids> -An array of the system-IDs you are interested in. +An array of the export-IDs you are interested in. =item Param C<resultCols> @@ -509,15 +509,15 @@ An array of hash-refs containing the resulting data rows. =back -=item C<fetchSystemIDsOfVendorOS($id)> +=item C<fetchExportIDsOfVendorOS($id)> -Fetches the IDs of all systems that make use of the vendor-OS with the given ID. +Fetches the IDs of all exports that make use of the vendor-OS with the given ID. =over =item Param C<id> -ID of the vendor-OS whose systems shall be returned. +ID of the vendor-OS whose exports shall be returned. =item Return Value @@ -525,101 +525,99 @@ An array of system-IDs. =back -=item C<fetchSystemIDsOfClient($id)> +=item C<fetchSystemByFilter([%$filter], [$resultCols])> -Fetches the IDs of all systems that are used by the client with the given -ID. +Fetches and returns information about all systems that match the given filter. =over -=item Param C<id> +=item Param C<$filter> -ID of the client whose systems shall be returned. +A hash-ref containing the filter criteria that shall be applied - default +is no filtering. See L</"Filters"> for more info. + +=item Param C<$resultCols> [Optional] + +A comma-separated list of colunm names that shall be returned. If not defined, +all available data must be returned. =item Return Value -An array of system-IDs. +An array of hash-refs containing the resulting data rows. =back -=item C<fetchSystemIDsOfGroup($id)> +=item C<fetchSystemByID(@$ids, [$resultCols])> -Fetches the IDs of all systems that are part of the group with the given -ID. +Fetches and returns information the systems with the given IDs. =over -=item Param C<id> +=item Param C<ids> -ID of the group whose systems shall be returned. +An array of the system-IDs you are interested in. + +=item Param C<resultCols> + +A string listing the columns that shall be returned - default is all columns. =item Return Value -An array of system-IDs. +An array of hash-refs containing the resulting data rows. =back -=item C<fetchSystemVariantsByFilter([%$filter], [$resultCols])> +=item C<fetchSystemIDsOfExport($id)> -Fetches and returns information about all system variants that match the given -filter. +Fetches the IDs of all systems that make use of the export with the given ID. =over -=item Param C<$filter> - -A hash-ref containing the filter criteria that shall be applied - default -is no filtering. See L</"Filters"> for more info. - -=item Param C<$resultCols> [Optional] +=item Param C<id> -A comma-separated list of colunm names that shall be returned. If not defined, -all available data must be returned. +ID of the export whose systems shall be returned. =item Return Value -An array of hash-refs containing the resulting data rows. +An array of system-IDs. =back -=item C<fetchSystemVariantsByID(@$ids, [$resultCols])> +=item C<fetchSystemIDsOfClient($id)> -Fetches and returns information the systems variants with the given IDs. +Fetches the IDs of all systems that are used by the client with the given +ID. =over -=item Param C<ids> - -An array of the system-variant-IDs you are interested in. - -=item Param C<resultCols> +=item Param C<id> -A string listing the columns that shall be returned - default is all columns. +ID of the client whose systems shall be returned. =item Return Value -An array of hash-refs containing the resulting data rows. +An array of system-IDs. =back -=item C<fetchSystemVariantIDsOfSystem($id)> +=item C<fetchSystemIDsOfGroup($id)> -Fetches the IDs of all system variants that belong to the system with the given +Fetches the IDs of all systems that are part of the group with the given ID. =over =item Param C<id> -ID of the system whose variants shall be returned. +ID of the group whose systems shall be returned. =item Return Value -An array of system-variant-IDs. +An array of system-IDs. =back -=item C<fetchClientsByFilter([%$filter], [$resultCols])> +=item C<fetchClientByFilter([%$filter], [$resultCols])> Fetches and returns information about all clients that match the given filter. @@ -641,7 +639,7 @@ An array of hash-refs containing the resulting data rows. =back -=item C<fetchClientsByID(@$ids, [$resultCols])> +=item C<fetchClientByID(@$ids, [$resultCols])> Fetches and returns information the clients with the given IDs. @@ -697,7 +695,7 @@ An array of client-IDs. -=item C<fetchGroupsByFilter([%$filter], [$resultCols])> +=item C<fetchGroupByFilter([%$filter], [$resultCols])> Fetches and returns information about all groups that match the given filter. @@ -721,7 +719,7 @@ An array of hash-refs containing the resulting data rows. -=item C<fetchGroupsByID(@$ids, [$resultCols])> +=item C<fetchGroupByID(@$ids, [$resultCols])> Fetches and returns information the groups with the given IDs. @@ -861,163 +859,163 @@ C<1> if the vendorOS(es) could be changed, C<undef> if not. -=item C<addSystem(@$valRows)> +=item C<addExport(@$valRows)> -Adds one or more systems to the database. +Adds one or more export to the database. =over =item Param C<valRows> -An array-ref containing hash-refs with the data of the new system(s). +An array-ref containing hash-refs with the data of the new export(s). =item Return Value -The IDs of the new system(s), C<undef> if the creation failed. +The IDs of the new export(s), C<undef> if the creation failed. =back -=item C<removeSystem(@$systemIDs)> +=item C<removeExport(@$exportIDs)> -Removes one or more systems from the database. +Removes one or more export from the database. =over -=item Param C<systemIDs> +=item Param C<exportIDs> -An array-ref containing the IDs of the systems that shall be removed. +An array-ref containing the IDs of the exports that shall be removed. =item Return Value -C<1> if the system(s) could be removed, C<undef> if not. +C<1> if the export(s) could be removed, C<undef> if not. =back -=item C<changeSystem(@$systemIDs, @$valRows)> +=item C<changeExport(@$exportIDs, @$valRows)> -Changes the data of one or more systems. +Changes the data of one or more export. =over -=item Param C<systemIDs> +=item Param C<vendorOSIDs> -An array-ref containing the IDs of the systems that shall be changed. +An array-ref containing the IDs of the exports that shall be changed. =item Param C<valRows> -An array-ref containing hash-refs with the new data for the system(s). +An array-ref containing hash-refs with the new data for the export(s). =item Return Value -C<1> if the system(s) could be changed, C<undef> if not. +C<1> if the export(s) could be changed, C<undef> if not. =back -=item C<setClientIDsOfSystem($systemID, @$clientIDs)> +=item C<addSystem(@$valRows)> -Specifies all clients that should offer the given system for booting. +Adds one or more systems to the database. =over -=item Param C<systemID> - -The ID of the system whose clients you'd like to specify. - -=item Param C<clientIDs> +=item Param C<valRows> -An array-ref containing the IDs of the clients that shall be connected to the -system. +An array-ref containing hash-refs with the data of the new system(s). =item Return Value -C<1> if the system/client references could be set, C<undef> if not. +The IDs of the new system(s), C<undef> if the creation failed. =back -=item C<setGroupIDsOfSystem($systemID, @$groupIDs)> +=item C<removeSystem(@$systemIDs)> -Specifies all groups that should offer the given system for booting. +Removes one or more systems from the database. =over -=item Param C<systemID> - -The ID of the system whose groups you'd like to specify. - -=item Param C<clientIDs> +=item Param C<systemIDs> -An array-ref containing the IDs of the groups that shall be connected to the -system. +An array-ref containing the IDs of the systems that shall be removed. =item Return Value -C<1> if the system/group references could be set, C<undef> if not. +C<1> if the system(s) could be removed, C<undef> if not. =back -=item C<addSystemVariant(@$valRows)> +=item C<changeSystem(@$systemIDs, @$valRows)> -Adds one or more system-variants to the database. +Changes the data of one or more systems. =over +=item Param C<systemIDs> + +An array-ref containing the IDs of the systems that shall be changed. + =item Param C<valRows> -An array-ref containing hash-refs with the data of the new system-variant(s). +An array-ref containing hash-refs with the new data for the system(s). =item Return Value -The IDs of the new system-variant(s), C<undef> if the creation failed. +C<1> if the system(s) could be changed, C<undef> if not. =back -=item C<removeSystemVariant(@$systemVariantIDs)> +=item C<setClientIDsOfSystem($systemID, @$clientIDs)> -Removes one or more system-variants from the database. +Specifies all clients that should offer the given system for booting. =over -=item Param C<systemIDs> +=item Param C<systemID> + +The ID of the system whose clients you'd like to specify. -An array-ref containing the IDs of the system-variants that shall be removed. +=item Param C<clientIDs> + +An array-ref containing the IDs of the clients that shall be connected to the +system. =item Return Value -C<1> if the system-variant(s) could be removed, C<undef> if not. +C<1> if the system/client references could be set, C<undef> if not. =back -=item C<changeSystemVariant(@$systemVariantIDs, @$valRows)> +=item C<setGroupIDsOfSystem($systemID, @$groupIDs)> -Changes the data of one or more system-variants. +Specifies all groups that should offer the given system for booting. =over -=item Param C<systemVariantIDs> +=item Param C<systemID> -An array-ref containing the IDs of the system-variants that shall be changed. +The ID of the system whose groups you'd like to specify. -=item Param C<valRows> +=item Param C<clientIDs> -An array-ref containing hash-refs with the new data for the system-variant(s). +An array-ref containing the IDs of the groups that shall be connected to the +system. =item Return Value -C<1> if the system-variant(s) could be changed, C<undef> if not. +C<1> if the system/group references could be set, C<undef> if not. =back @@ -1255,6 +1253,6 @@ C<1> if the settings could be changed, C<undef> if not. The following methods need to be implemented in a MetaDB driver in order to be able to automatically adjust to new database schema versions (by adding -and/or removing tables and table-columns). +and/or removing tables and table-columns). =cut diff --git a/config-db/OpenSLX/MetaDB/CSV.pm b/config-db/OpenSLX/MetaDB/CSV.pm index bed7bbd9..55da0beb 100644 --- a/config-db/OpenSLX/MetaDB/CSV.pm +++ b/config-db/OpenSLX/MetaDB/CSV.pm @@ -37,7 +37,7 @@ sub new return bless $self, $class; } -sub connectConfigDB +sub connect { my $self = shift; diff --git a/config-db/OpenSLX/MetaDB/DBI.pm b/config-db/OpenSLX/MetaDB/DBI.pm index ad4c12b5..4479ed84 100644 --- a/config-db/OpenSLX/MetaDB/DBI.pm +++ b/config-db/OpenSLX/MetaDB/DBI.pm @@ -30,7 +30,7 @@ sub new confess "Don't call OpenSLX::MetaDB::DBI::new directly!"; } -sub disconnectConfigDB +sub disconnect { my $self = shift; @@ -83,7 +83,7 @@ sub _doSelect return @vals; } -sub fetchVendorOSesByFilter +sub fetchVendorOSByFilter { my $self = shift; my $filter = shift; @@ -99,7 +99,7 @@ sub fetchVendorOSesByFilter return $self->_doSelect($sql); } -sub fetchVendorOSesByID +sub fetchVendorOSByID { my $self = shift; my $ids = shift; @@ -112,14 +112,14 @@ sub fetchVendorOSesByID return $self->_doSelect($sql); } -sub fetchSystemsByFilter +sub fetchExportByFilter { my $self = shift; my $filter = shift; my $resultCols = shift; - $resultCols = '*' unless (defined $resultCols); - my $sql = "SELECT $resultCols FROM system"; + $resultCols = '*' unless (defined $resultCols); + my $sql = "SELECT $resultCols FROM export"; my $connector; foreach my $col (keys %$filter) { $connector = !defined $connector ? 'WHERE' : 'AND'; @@ -128,7 +128,7 @@ sub fetchSystemsByFilter return $self->_doSelect($sql); } -sub fetchSystemsByID +sub fetchExportByID { my $self = shift; my $ids = shift; @@ -137,51 +137,29 @@ sub fetchSystemsByID $resultCols = '*' unless (defined $resultCols); my $idStr = join ',', @$ids; return if !length($idStr); - my $sql = "SELECT $resultCols FROM system WHERE id IN ($idStr)"; + my $sql = "SELECT $resultCols FROM export WHERE id IN ($idStr)"; return $self->_doSelect($sql); } -sub fetchSystemIDsOfVendorOS +sub fetchExportIDsOfVendorOS { my $self = shift; my $vendorOSID = shift; my $sql = qq[ - SELECT id FROM system WHERE vendor_os_id = '$vendorOSID' + SELECT id FROM export WHERE vendor_os_id = '$vendorOSID' ]; return $self->_doSelect($sql, 'id'); } -sub fetchSystemIDsOfClient -{ - my $self = shift; - my $clientID = shift; - - my $sql = qq[ - SELECT system_id FROM client_system_ref WHERE client_id = '$clientID' - ]; - return $self->_doSelect($sql, 'system_id'); -} - -sub fetchSystemIDsOfGroup -{ - my $self = shift; - my $groupID = shift; - - my $sql = qq[ - SELECT system_id FROM group_system_ref WHERE group_id = '$groupID' - ]; - return $self->_doSelect($sql, 'system_id'); -} - -sub fetchSystemVariantsByFilter +sub fetchSystemByFilter { my $self = shift; my $filter = shift; my $resultCols = shift; $resultCols = '*' unless (defined $resultCols); - my $sql = "SELECT $resultCols FROM system_variant"; + my $sql = "SELECT $resultCols FROM system"; my $connector; foreach my $col (keys %$filter) { $connector = !defined $connector ? 'WHERE' : 'AND'; @@ -190,7 +168,7 @@ sub fetchSystemVariantsByFilter return $self->_doSelect($sql); } -sub fetchSystemVariantsByID +sub fetchSystemByID { my $self = shift; my $ids = shift; @@ -199,22 +177,44 @@ sub fetchSystemVariantsByID $resultCols = '*' unless (defined $resultCols); my $idStr = join ',', @$ids; return if !length($idStr); - my $sql = "SELECT $resultCols FROM system_variant WHERE id IN ($idStr)"; + my $sql = "SELECT $resultCols FROM system WHERE id IN ($idStr)"; return $self->_doSelect($sql); } -sub fetchSystemVariantIDsOfSystem +sub fetchSystemIDsOfExport { my $self = shift; - my $systemID = shift; + my $exportID = shift; my $sql = qq[ - SELECT id FROM system_variant WHERE system_id = '$systemID' + SELECT id FROM system WHERE export_id = '$exportID' ]; return $self->_doSelect($sql, 'id'); } -sub fetchClientsByFilter +sub fetchSystemIDsOfClient +{ + my $self = shift; + my $clientID = shift; + + my $sql = qq[ + SELECT system_id FROM client_system_ref WHERE client_id = '$clientID' + ]; + return $self->_doSelect($sql, 'system_id'); +} + +sub fetchSystemIDsOfGroup +{ + my $self = shift; + my $groupID = shift; + + my $sql = qq[ + SELECT system_id FROM group_system_ref WHERE group_id = '$groupID' + ]; + return $self->_doSelect($sql, 'system_id'); +} + +sub fetchClientByFilter { my $self = shift; my $filter = shift; @@ -230,7 +230,7 @@ sub fetchClientsByFilter return $self->_doSelect($sql); } -sub fetchClientsByID +sub fetchClientByID { my $self = shift; my $ids = shift; @@ -265,7 +265,7 @@ sub fetchClientIDsOfGroup return $self->_doSelect($sql, 'client_id'); } -sub fetchGroupsByFilter +sub fetchGroupByFilter { my $self = shift; my $filter = shift; @@ -281,7 +281,7 @@ sub fetchGroupsByFilter return $self->_doSelect($sql); } -sub fetchGroupsByID +sub fetchGroupByID { my $self = shift; my $ids = shift; @@ -526,6 +526,31 @@ sub changeVendorOS return $self->_doUpdate('vendor_os', $vendorOSIDs, $valRows); } +sub addExport +{ + my $self = shift; + my $valRows = shift; + + return $self->_doInsert('export', $valRows); +} + +sub removeExport +{ + my $self = shift; + my $exportIDs = shift; + + return $self->_doDelete('export', $exportIDs); +} + +sub changeExport +{ + my $self = shift; + my $exportIDs = shift; + my $valRows = shift; + + return $self->_doUpdate('export', $exportIDs, $valRows); +} + sub addSystem { my $self = shift; @@ -573,31 +598,6 @@ sub setGroupIDsOfSystem 'system_id', 'group_id', \@currGroups); } -sub addSystemVariant -{ - my $self = shift; - my $valRows = shift; - - return $self->_doInsert('system_variant', $valRows); -} - -sub removeSystemVariant -{ - my $self = shift; - my $systemVariantIDs = shift; - - return $self->_doDelete('system_variant', $systemVariantIDs); -} - -sub changeSystemVariant -{ - my $self = shift; - my $systemVariantIDs = shift; - my $valRows = shift; - - return $self->_doUpdate('system_variant', $systemVariantIDs, $valRows); -} - sub addClient { my $self = shift; diff --git a/config-db/OpenSLX/MetaDB/SQLite.pm b/config-db/OpenSLX/MetaDB/SQLite.pm index 059467d8..d7d0a2b6 100644 --- a/config-db/OpenSLX/MetaDB/SQLite.pm +++ b/config-db/OpenSLX/MetaDB/SQLite.pm @@ -35,7 +35,7 @@ sub new return bless $self, $class; } -sub connectConfigDB +sub connect { my $self = shift; diff --git a/config-db/OpenSLX/MetaDB/mysql.pm b/config-db/OpenSLX/MetaDB/mysql.pm index 3f42b966..1e0d01c3 100644 --- a/config-db/OpenSLX/MetaDB/mysql.pm +++ b/config-db/OpenSLX/MetaDB/mysql.pm @@ -35,7 +35,7 @@ sub new return bless $self, $class; } -sub connectConfigDB +sub connect { my $self = shift; |