-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.py
executable file
·54 lines (41 loc) · 1.53 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
45
46
47
48
49
50
51
52
53
#!/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'
ucs_path = server_path + '/cisco'
remote_management_module_utils = module_utils + '/remote_management/'
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(ucs_path):
os.makedirs(ucs_path)
touch(server_path + '/__init__.py')
touch(ucs_path + '/__init__.py')
# Copy files from library folder to ucs_path
copy_files(os.getcwd() + '/library', ucs_path)
# Copy common files to module_util
copy_files(os.getcwd() + '/utils', module_utils)
# Create the directory for the ucs module_utils/remote_management
if not os.path.isdir(remote_management_module_utils):
os.makedirs(remote_management_module_utils)
touch(remote_management_module_utils + '/__init__.py')
# Copy to module_utils/remote_management
copy_files(os.getcwd() + '/utils/remote_management', remote_management_module_utils)