Commit 4d73e362 authored by Matthieu Lamalle's avatar Matthieu Lamalle Committed by Lionel Morin

211 transfert files

parent ee0ae1e7
......@@ -67,7 +67,7 @@ RUN curl https://repo.saltstack.com/apt/ubuntu/18.04/amd64/2018.3/SALTSTACK-GPG-
ENV EOLE_FORMULA_DIR=/srv/formulas
ENV EOLE_CONFIGURATION_FORMULA_URL="https://dev-eole.ac-dijon.fr/git/eole-configuration-formula.git"
ENV EOLE_CONFIGURATION_FORMULA_REF=ecc1d134036bfcb5abb34b0d55defce8abbb8ad1
ENV EOLE_CONFIGURATION_FORMULA_REF=80a799e758a4b660b1fce54909b1db5833b9a661
RUN git clone "${EOLE_CONFIGURATION_FORMULA_URL}" "${EOLE_FORMULA_DIR}/eole-configuration-formula" \
&& cd "${EOLE_FORMULA_DIR}/eole-configuration-formula" \
......
......@@ -5,7 +5,7 @@ import asyncio
import signal
import time
import json, yaml
from os import path, makedirs, getpid, unlink, remove, walk, path
from os import path, makedirs, getpid, unlink, remove, walk, path, stat
import tarfile
import base64
......@@ -154,6 +154,7 @@ class SaltRunner(ZephirCommonController):
pillar_file_path = '/srv/pillar/pillars_{0}.sls'.format(server_id)
creole_files_path = '{0}/creole_files.tar.gz'.format(minion_dir)
makedirs(minion_dir, exist_ok=True)
server = await self.call('v1.server.describe',
......@@ -164,12 +165,12 @@ class SaltRunner(ZephirCommonController):
servermodel_id = server['servermodelid']
with open(pillar_file_path, 'w') as fh:
if server['configuration']:
if json.loads(server['configuration']):
yaml.dump(json.loads(server['configuration']), fh, allow_unicode=True)
else:
yaml.dump({}, fh)
fh.close()
del server
servermodel = await self.call('v1.servermodel.describe',
servermodelid=servermodel_id,
......@@ -182,33 +183,39 @@ class SaltRunner(ZephirCommonController):
with open(creolefuncs_file_path, 'w') as fh:
fh.write(servermodel['creolefuncs'])
with open(creole_files_path, 'wb') as fh:
eoleconfig = {"eole":{"configuration": { "files":{}}}}
with open(creole_files_path, 'wb') as fh:
fh.write(base64.b64decode(servermodel['conffiles']))
tar = tarfile.open(creole_files_path,'r:gz')
tar.extractall(f'{minion_dir}')
remove(creole_files_path)
files = []
# r=root, d=directories, f = files
for r, d, f in walk(f'{minion_dir}/creole_files'):
for file in f:
files.append(path.join(r, file))
for f in files:
print(f)
for file in f:
mode = oct(stat(path.join(r, file)).st_mode)[-3:]
pathtofile = path.join(r.replace(f'{minion_dir}/creole_files', ''), file)
eoleconfig['eole']['configuration']['files'][pathtofile] = {}
eoleconfig['eole']['configuration']['files'][pathtofile]['owner'] = 'root'
eoleconfig['eole']['configuration']['files'][pathtofile]['group'] = 'root'
eoleconfig['eole']['configuration']['files'][pathtofile]['mode'] = mode
if json.loads(server['configuration']):
with open(pillar_file_path, 'a') as fh:
fh.write(yaml.dump(eoleconfig, default_flow_style=False))
del server
self._download_env(server_id, servermodel)
def _download_env(self, server_id, servermodel):
minion_dir = '{0}{1}'.format(MINION_DIR, server_id)
makedirs(minion_dir, exist_ok=True)
env_file_path = '{0}/config.env'.format(minion_dir)
env_file_path = '{0}/config.env'.format(minion_dir)
with open(env_file_path, 'w') as fh:
fh.write(servermodel['probes'])
fh.write(servermodel['probes'])
async def download_env(self,server_id):
async def download_env(self,server_id):
_session_user = {'profil': 'root'}
server = await self.call('v1.server.describe',
_session_user=_session_user,
......
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