From 81c2f0c935598182aff9ba5240832a609764d5bf Mon Sep 17 00:00:00 2001
From: jrbalderrama <3970-jrbalderrama@users.noreply.gitlab.inria.fr>
Date: Mon, 1 Apr 2019 12:13:58 +0200
Subject: [PATCH] WIP deploy with constants

---
 enoslib/infra/enos_g5k/configuration.py | 1 +
 enoslib/infra/enos_g5k/constants.py     | 2 ++
 enoslib/infra/enos_g5k/utils.py         | 6 ++----
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/enoslib/infra/enos_g5k/configuration.py b/enoslib/infra/enos_g5k/configuration.py
index 8df7094..7e2a4ca 100644
--- a/enoslib/infra/enos_g5k/configuration.py
+++ b/enoslib/infra/enos_g5k/configuration.py
@@ -15,6 +15,7 @@ class Configuration(BaseConfiguration):
         self.env_name = DEFAULT_ENV_NAME
         self.job_name = DEFAULT_JOB_NAME
         self.job_type = DEFAULT_JOB_TYPE
+        self.key = None
         self.oargrid_jobid = None
         self.oar_jobid = None
         self.oar_site = None
diff --git a/enoslib/infra/enos_g5k/constants.py b/enoslib/infra/enos_g5k/constants.py
index 308be06..086281e 100644
--- a/enoslib/infra/enos_g5k/constants.py
+++ b/enoslib/infra/enos_g5k/constants.py
@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+from pathlib import Path
 
 JOB_TYPE_DEPLOY = "deploy"
 DEFAULT_ENV_NAME = "debian9-x64-nfs"
@@ -7,5 +8,6 @@ DEFAULT_JOB_TYPE = JOB_TYPE_DEPLOY
 DEFAULT_QUEUE = "default"
 DEFAULT_WALLTIME = "02:00:00"
 DEFAULT_NUMBER = 1
+DEFAULT_SSH_KEYFILE = Path.home().joinpath(".ssh", "id_rsa.pub")
 
 NAMESERVER = "dns.grid5000.fr"
diff --git a/enoslib/infra/enos_g5k/utils.py b/enoslib/infra/enos_g5k/utils.py
index eefc0cd..369c3e6 100644
--- a/enoslib/infra/enos_g5k/utils.py
+++ b/enoslib/infra/enos_g5k/utils.py
@@ -1,10 +1,8 @@
 # -*- coding: utf-8 -*-
 from collections import defaultdict
-from pathlib import Path
 
 import copy
 import logging
-import os
 import time
 
 from execo import Host
@@ -13,7 +11,7 @@ import execo_g5k.api_utils as api
 from netaddr import IPAddress, IPNetwork, IPSet
 
 from enoslib.errors import EnosError
-from enoslib.infra.enos_g5k import remote
+from enoslib.infra.enos_g5k import remote, constants
 from enoslib.infra.enos_g5k.error import (MissingNetworkError,
                                           NotEnoughNodesError)
 from enoslib.infra.enos_g5k.schema import (PROD, KAVLAN_GLOBAL, KAVLAN_LOCAL,
@@ -342,7 +340,7 @@ def grid_deploy(gk, site, nodes, force_deploy, options):
     environment = options.pop("env_name")
     options.update(environment=environment)
     options.update(nodes=nodes)
-    key_path = Path.home().joinpath(".ssh", "id_rsa.pub")
+    key_path = constants.DEFAULT_SSH_KEYFILE
     options.update(key=key_path.read_text())
     logger.info("Deploying %s with options %s" % (nodes, options))
     deployment = gk.sites[site].deployments.create(options)
-- 
GitLab