Commit 7a128d1d authored by SIMONIN Matthieu's avatar SIMONIN Matthieu

from_yaml fallbacks to anonymous connection

Fix #6
parent ea578161
Pipeline #97677 passed with stage
in 1 minute and 50 seconds
......@@ -73,7 +73,8 @@ password: MYPASSWORD
#+END_EXAMPLE
#+BEGIN_hint
Inside Grid'5000, you'l probably need to set ~verify_ssl: False~
From a Grid'5000 frontend this file is optionnal. In all other cases the
configuration file is mandatory.
#+END_hint
- Using a virtualenv is recommended (python 3.5+ is required)
......
......@@ -76,7 +76,8 @@ conform with the Grid5000 API models (with an ’s’!)
.. hint::
Inside Grid’5000, you’l probably need to set ``verify_ssl: False``
From a Grid’5000 frontend this file is optionnal. In all other cases the
configuration file is mandatory.
- Using a virtualenv is recommended (python 3.5+ is required)
......
......@@ -11,7 +11,7 @@ logging.basicConfig(level=logging.DEBUG)
def _to_network_address(host, interface):
"""Translate a host to a network address
e.g:
paranoia-20.rennes.grid5000.fr -> paranoia-20-eth2.rennes.grid5000.fr
paravance-20.rennes.grid5000.fr -> paravance-20-eth2.rennes.grid5000.fr
"""
splitted = host.split('.')
splitted[0] = splitted[0] + "-" + interface
......@@ -26,7 +26,7 @@ site = gk.sites["rennes"]
job = site.jobs.create({"name": "pyg5k",
"command": "sleep 3600",
"resources": "{type='kavlan'}/vlan=1+{cluster='paranoia'}nodes=1",
"resources": "{type='kavlan'}/vlan=1+{cluster='paravance'}nodes=1",
"types": ["deploy"]
})
......
......@@ -91,9 +91,16 @@ class Grid5000(object):
@classmethod
def from_yaml(cls, yaml_file):
with open(yaml_file, "r") as f:
conf = yaml.load(f)
return cls(**conf)
try:
with open(yaml_file, "r") as f:
conf = yaml.load(f)
return cls(**conf)
except Exception as e:
logging.warn(e)
logging.info(
"...Falling back to anonymous connection"
)
return cls()
def __enter__(self):
return self
......
__version__ = "0.1.2"
\ No newline at end of file
__version__ = "0.1.2"
......@@ -31,3 +31,4 @@ ignore = E121,E122,E123,E124,E125,E127,E128,E129,E131,E241,H405,F821,W503,F405
show-source = true
exclude = venv,.git,.tox,dist,*egg,ansible,tests
max-complexity = 12
max-line-length = 88
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment