Browse Source

minor changes

Razvan Becheriu 9 years ago
parent
commit
74b0e91737

+ 1 - 1
src/bin/admin/admin-utils.sh

@@ -76,7 +76,7 @@ pgsql_execute_script() {
         retcode=$?
     else
         export PGPASSWORD=$db_password
-        psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U $db_user -d $db_name -h localhost -f $file
+        psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U $db_user -d $db_name -f $file
         retcode=$?
     fi
     return $retcode

+ 3 - 14
src/bin/admin/kea-admin.in

@@ -203,17 +203,6 @@ pgsql_init() {
 cql_init() {
     printf "Checking if there is a database initialized already... Please ignore errors.\n"
 
-    result=`cql_execute "DESCRIBE KEYSPACES;"`
-    if [ "$result" != "" ]; then
-        result=`echo "$result" | sed -n "/$db_name/ p"`
-        if [ "$result" = "" ]; then
-            printf "Creating keyspace $db_name...\n"
-            cql_execute "CREATE KEYSPACE $db_name WITH replication = {'class' : 'SimpleStrategy','replication_factor' : 1};"
-        else
-            printf "Keyspace $db_name already exists.\n"
-        fi
-    fi
-
     result=`cql_execute "USE $db_name; DESCRIBE tables;"`
     if [ "$result"="<empty>" ]; then
         printf "Creating and initializing tables using script %s...\n" $scripts_dir/cql/dhcpdb_create.cql
@@ -225,7 +214,7 @@ cql_init() {
     version=`cql_version`
     printf "Lease DB version reported after initialization: $version\n"
 
-    return 0
+    exit 0
 }
 
 ### Functions that implement database version checking commands
@@ -340,7 +329,7 @@ cql_upgrade() {
 
     version=`cql_version`
     printf "Lease DB version reported after upgrade: $version\n"
-    return 0
+    exit 0
 }
 
 # Utility function which tests if the given file exists and
@@ -535,7 +524,7 @@ cql_dump() {
     # delete the tmp file on success
     rm $tmp_file
     echo lease$dump_type successfully dumped to $dump_file
-    return 0
+    exit 0
 }
 
 ### Script starts here ###

+ 1 - 1
src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc

@@ -94,7 +94,7 @@ public:
 /// CqlLeaseMgr test fixure set.  This test checks that the database can be
 /// opened: the fixtures assume that and check basic operations.
 
-TEST(CQLOpenTest, OpenDatabase) {
+TEST(CqlOpenTest, OpenDatabase) {
 
     // Schema needs to be created for the test to work.
     destroyCqlSchema(false, true);

+ 5 - 5
src/lib/dhcpsrv/testutils/cql_schema.cc

@@ -38,15 +38,15 @@ bool softWipeEnabled() {
     return (false);
 }
 
-void destroyCqlSchema(bool , bool show_err) {
-//    if (force_wipe || !softWipeEnabled()) {
+void destroyCqlSchema(bool force_wipe, bool show_err) {
+    if (force_wipe || !softWipeEnabled()) {
         // Do full wipe
         runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_drop.cql", show_err);
-//    } else {
+    } else {
 
         // do soft wipe (just remove the data, not the structures)
-//        runCqlScript(DATABASE_SCRIPTS_DIR, "cql/soft_wipe.cql", show_err);
-//    }
+        runCqlScript(DATABASE_SCRIPTS_DIR, "cql/soft_wipe.cql", show_err);
+    }
 }
 
 void createCqlSchema(bool force_wipe, bool show_err) {

+ 1 - 0
src/share/database/scripts/cql/dhcpdb_create.cql

@@ -29,7 +29,7 @@
 
 -- SOURCE dhcpdb_create.cql
 
+-- This script is also called from kea-admin, see kea-admin lease-init cql
 
 -- Over time, Kea database schema will evolve. Each version is marked with
 -- major.minor version. This file is organized sequentially, i.e. database