Mentions légales du service

Skip to content
Snippets Groups Projects
Verified Commit 7a128d1d authored by SIMONIN Matthieu's avatar SIMONIN Matthieu
Browse files

from_yaml fallbacks to anonymous connection

Fix #6
parent ea578161
No related branches found
No related tags found
1 merge request!1from_yaml fallbacks to anonymous connection
Pipeline #97677 passed
...@@ -73,7 +73,8 @@ password: MYPASSWORD ...@@ -73,7 +73,8 @@ password: MYPASSWORD
#+END_EXAMPLE #+END_EXAMPLE
#+BEGIN_hint #+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 #+END_hint
- Using a virtualenv is recommended (python 3.5+ is required) - Using a virtualenv is recommended (python 3.5+ is required)
......
...@@ -76,7 +76,8 @@ conform with the Grid5000 API models (with an ’s’!) ...@@ -76,7 +76,8 @@ conform with the Grid5000 API models (with an ’s’!)
.. hint:: .. 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) - Using a virtualenv is recommended (python 3.5+ is required)
......
...@@ -11,7 +11,7 @@ logging.basicConfig(level=logging.DEBUG) ...@@ -11,7 +11,7 @@ logging.basicConfig(level=logging.DEBUG)
def _to_network_address(host, interface): def _to_network_address(host, interface):
"""Translate a host to a network address """Translate a host to a network address
e.g: 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 = host.split('.')
splitted[0] = splitted[0] + "-" + interface splitted[0] = splitted[0] + "-" + interface
...@@ -26,7 +26,7 @@ site = gk.sites["rennes"] ...@@ -26,7 +26,7 @@ site = gk.sites["rennes"]
job = site.jobs.create({"name": "pyg5k", job = site.jobs.create({"name": "pyg5k",
"command": "sleep 3600", "command": "sleep 3600",
"resources": "{type='kavlan'}/vlan=1+{cluster='paranoia'}nodes=1", "resources": "{type='kavlan'}/vlan=1+{cluster='paravance'}nodes=1",
"types": ["deploy"] "types": ["deploy"]
}) })
......
...@@ -91,9 +91,16 @@ class Grid5000(object): ...@@ -91,9 +91,16 @@ class Grid5000(object):
@classmethod @classmethod
def from_yaml(cls, yaml_file): def from_yaml(cls, yaml_file):
with open(yaml_file, "r") as f: try:
conf = yaml.load(f) with open(yaml_file, "r") as f:
return cls(**conf) 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): def __enter__(self):
return self return self
......
__version__ = "0.1.2" __version__ = "0.1.2"
\ No newline at end of file
...@@ -31,3 +31,4 @@ ignore = E121,E122,E123,E124,E125,E127,E128,E129,E131,E241,H405,F821,W503,F405 ...@@ -31,3 +31,4 @@ ignore = E121,E122,E123,E124,E125,E127,E128,E129,E131,E241,H405,F821,W503,F405
show-source = true show-source = true
exclude = venv,.git,.tox,dist,*egg,ansible,tests exclude = venv,.git,.tox,dist,*egg,ansible,tests
max-complexity = 12 max-complexity = 12
max-line-length = 88
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment