From 688c3c58e58d78ff6a242a16986d84b92dbd1a1c Mon Sep 17 00:00:00 2001
From: Einar Forselv <eforselv@gmail.com>
Date: Tue, 3 Dec 2019 01:47:15 +0100
Subject: [PATCH] db containers: Implement methods

---
 restic_volume_backup/containers_db.py | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/restic_volume_backup/containers_db.py b/restic_volume_backup/containers_db.py
index b0dcba6..2fe3399 100644
--- a/restic_volume_backup/containers_db.py
+++ b/restic_volume_backup/containers_db.py
@@ -1,5 +1,5 @@
 from restic_volume_backup.containers import Container
-from restic_volume_backup.restic
+from restic_volume_backup.restic import commands
 
 
 class MariadbContainer(Container):
@@ -16,7 +16,13 @@ class MariadbContainer(Container):
 
     def ping(self) -> bool:
         """Check the availability of the service"""
-        raise NotImplementedError("Base container class don't implement this")
+        creds = self.get_credentials()
+        return commands.ping_mysql(
+            creds['host'],
+            creds['port'],
+            creds['username'],
+            creds['password'],
+        )
 
     def dump_command(self) -> list:
         """list: create a dump command restic and use to send data through stdin"""
@@ -37,7 +43,13 @@ class MysqlContainer(Container):
 
     def ping(self) -> bool:
         """Check the availability of the service"""
-        raise NotImplementedError("Base container class don't implement this")
+        creds = self.get_credentials()
+        return commands.ping_mysql(
+            creds['host'],
+            creds['port'],
+            creds['username'],
+            creds['password'],
+        )
 
     def dump_command(self) -> list:
         """list: create a dump command restic and use to send data through stdin"""
@@ -58,7 +70,8 @@ class PostgresContainer(Container):
 
     def ping(self) -> bool:
         """Check the availability of the service"""
-        raise NotImplementedError("Base container class don't implement this")
+        # raise NotImplementedError("Base container class don't implement this")
+        print("Implement postgres ping!")
 
     def dump_command(self) -> list:
         """list: create a dump command restic and use to send data through stdin"""