aboutsummaryrefslogtreecommitdiffstats
path: root/opnfv/utils/Connection.py
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-11-17 11:35:39 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2016-11-17 14:06:09 +0100
commitfdf8cd017eb17a1cf9eaeff7018cbb69e838b891 (patch)
tree9aa9d9784a090df52e06913a8e7e5600190788b2 /opnfv/utils/Connection.py
parent9de1ded9cf18dfce75d1a85c54242c74e3133fcd (diff)
Transform fetch_os_creds.sh into python Class
JIRA: RELENG-168 Change-Id: Id5b1fca430c37917b554a54dd0678d9d7497dc11 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'opnfv/utils/Connection.py')
-rw-r--r--opnfv/utils/Connection.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/opnfv/utils/Connection.py b/opnfv/utils/Connection.py
new file mode 100644
index 0000000..a3be514
--- /dev/null
+++ b/opnfv/utils/Connection.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2016 Orange and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+
+
+import os
+import time
+
+
+class Connection(object):
+
+ def __init__(self):
+ pass
+
+ def verify_connectivity(self, target):
+ for x in range(0, 10):
+ ping_cmd = ("ping -c 1 -W 1 %s >/dev/null" % target)
+ response = os.system(ping_cmd)
+ if response == 0:
+ return os.EX_OK
+ time.sleep(1)
+ return os.EX_UNAVAILABLE
+
+ def check_internet_access(self, url="www.google.com"):
+ return self.verify_connectivity(url)