-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
338 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,40 @@ | ||
import logging | ||
import os | ||
import time | ||
import uuid | ||
|
||
from smbprotocol.connection import Connection | ||
|
||
log = logging.getLogger(__name__) | ||
logging.basicConfig(level=logging.INFO) | ||
|
||
|
||
def test_connection(server, port): | ||
conn = Connection(uuid.uuid4(), server, port=port) | ||
print("Opening connection to %s:%d" % (server, port)) | ||
log.info("Opening connection to %s:%d", server, port) | ||
conn.connect(timeout=5) | ||
conn.disconnect(True) | ||
|
||
|
||
if __name__ == "__main__": | ||
server = os.environ.get("SMB_SERVER", "127.0.0.1") | ||
port = int(os.environ.get("SMB_PORT", 445)) | ||
print("Waiting for SMB server to be online") | ||
log.info("Waiting for SMB server to be online") | ||
|
||
attempt = 1 | ||
total_attempts = 20 | ||
while attempt < total_attempts: | ||
print("Starting attempt %d" % attempt) | ||
log.info("Starting attempt %d", attempt) | ||
try: | ||
test_connection(server, port) | ||
break | ||
except Exception as e: | ||
print("Connection attempt %d failed: %s" % (attempt, str(e))) | ||
log.info("Connection attempt %d failed: %s", attempt, e) | ||
attempt += 1 | ||
if attempt == total_attempts: | ||
raise Exception("Timeout while waiting for SMB server to come online") | ||
raise Exception("Timeout while waiting for SMB server to come online") from e | ||
|
||
print("Sleeping for 5 seconds before next attempt") | ||
log.info("Sleeping for 5 seconds before next attempt") | ||
time.sleep(5) | ||
|
||
print("Connection successful") | ||
log.info("Connection successful") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.