forked from CiscoUcs/imc-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
executable file
·47 lines (34 loc) · 1.12 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
import os
import sys
try:
import ansible
except:
print("Ansible is not installed")
sys.exit(1)
ansible_path = ansible.__path__[0]
module_utils = ansible_path + '/module_utils/'
extras_path = ansible_path + '/modules/extras'
server_path = extras_path + '/server'
imc_path = server_path + '/cisco'
def touch(fname, times=None):
with open(fname, 'a'):
os.utime(fname, times)
def copy_files(src, dest):
import shutil
src_files = os.listdir(src)
for file_name in src_files:
src_file = os.path.join(src, file_name)
dst_file = os.path.join(dest, file_name)
if (os.path.isfile(src_file)):
print(src_file, "===>", dst_file)
shutil.copy(src_file, dst_file)
# Create the directory for the main module under extras/server/cisco repo
if not os.path.isdir(imc_path):
os.makedirs(imc_path)
touch(server_path + '/__init__.py')
touch(imc_path + '/__init__.py')
# Copy files from library folder to imc_path
copy_files(os.getcwd() + '/library', imc_path)
# Copy common files to module_util
copy_files(os.getcwd() + '/utils', module_utils)