Skip to content

Commit 7b801dd

Browse files
committed
ESC (end stage cleanup) step 0: fix 'salt.' imports and move things around
1 parent 721f2bc commit 7b801dd

26 files changed

+510
-92
lines changed

contrib/dep-orbital-strike.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
THIS_DIR="$(git rev-parse --show-toplevel)"
4+
5+
UNINSTALL=(
6+
salt-ssh
7+
jinja2
8+
)
9+
10+
UNDEPEND=(
11+
"${UNINSTALL[@]}"
12+
six
13+
)
14+
15+
16+
( set -x
17+
pip uninstall -y hubblestack "${UNINSTALL[@]}"
18+
)
19+
20+
IFS='|'
21+
KILL="${UNDEPEND[*]}"
22+
unset IFS
23+
24+
( set -x
25+
find "$THIS_DIR" -type f -name \*req\*.txt \
26+
| grep -v /abandoned/ \
27+
| xargs -r sed -i -re "/$KILL/d"
28+
sed -i -re "/'$KILL.+',/d" setup.py
29+
)

contrib/unused-import-scan.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
find hubblestack tests -type f -name \*.py \
4+
| xargs -r pylint --disable=all --enable=unused-import

doc/requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
sphinx
22
sphinx-autobuild
33
sphinx_rtd_theme
4-
salt-ssh

hubblestack/daemon.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
import uuid
2222
from datetime import datetime
2323

24-
import salt.fileserver
25-
import salt.fileserver.gitfs
24+
import hubblestack.fileserver
25+
import hubblestack.fileserver.gitfs
2626
import hubblestack.modules.cmdmod
27-
import salt.utils
27+
import hubblestack.utils
2828
import hubblestack.utils.platform
29-
import salt.utils.jid
30-
import salt.utils.gitfs
29+
import hubblestack.utils.jid
30+
import hubblestack.utils.gitfs
3131
import hubblestack.utils.path
3232
from croniter import croniter
3333

@@ -81,15 +81,15 @@ def _clear_gitfs_locks():
8181
# Clear old locks
8282
if 'gitfs' in __opts__['fileserver_backend'] or 'git' in __opts__['fileserver_backend']:
8383
git_objects = [
84-
salt.utils.gitfs.GitFS(
84+
hubblestack.utils.gitfs.GitFS(
8585
__opts__,
8686
__opts__['gitfs_remotes'],
87-
per_remote_overrides=salt.fileserver.gitfs.PER_REMOTE_OVERRIDES,
88-
per_remote_only=salt.fileserver.gitfs.PER_REMOTE_ONLY)]
87+
per_remote_overrides=hubblestack.fileserver.gitfs.PER_REMOTE_OVERRIDES,
88+
per_remote_only=hubblestack.fileserver.gitfs.PER_REMOTE_ONLY)]
8989
ret = {}
9090
for obj in git_objects:
9191
lock_type = 'update'
92-
cleared, errors = salt.fileserver.clear_lock(obj.clear_lock, 'gitfs', remote=None,
92+
cleared, errors = hubblestack.fileserver.clear_lock(obj.clear_lock, 'gitfs', remote=None,
9393
lock_type=lock_type)
9494
if cleared:
9595
ret.setdefault('cleared', []).extend(cleared)
@@ -143,7 +143,7 @@ def main():
143143
count = 0
144144
while True:
145145
try:
146-
file_client = salt.fileclient.get_file_client(__opts__)
146+
file_client = hubblestack.fileclient.get_file_client(__opts__)
147147
file_client.channel.fs.update()
148148
last_fc_update = time.time()
149149
break
@@ -362,7 +362,7 @@ def _execute_function(jobdata, func, returners, args, kwargs):
362362
continue
363363
log.debug('Returning job data to %s', returner)
364364
returner_ret = {'id': __grains__['id'],
365-
'jid': salt.utils.jid.gen_jid(__opts__),
365+
'jid': hubblestack.utils.jid.gen_jid(__opts__),
366366
'fun': func,
367367
'fun_args': args + ([kwargs] if kwargs else []),
368368
'return': ret}
@@ -429,7 +429,7 @@ def run_function():
429429
else:
430430
log.info('Returning job data to %s', returner)
431431
returner_ret = {'id': __grains__['id'],
432-
'jid': salt.utils.jid.gen_jid(__opts__),
432+
'jid': hubblestack.utils.jid.gen_jid(__opts__),
433433
'fun': __opts__['function'],
434434
'fun_args': args + ([kwargs] if kwargs else []),
435435
'return': ret}
@@ -483,7 +483,7 @@ def load_config(args=None):
483483
# them a signal 15 (otherwise refuse to run)
484484
if not __opts__.get('ignore_running', False):
485485
check_pidfile(kill_other=True, scan_proc=scan_proc)
486-
salt.utils.daemonize()
486+
hubblestack.utils.daemonize()
487487
create_pidfile()
488488
elif not __opts__['function'] and not __opts__['version'] and not __opts__['buildinfo']:
489489
# check the pidfile and possibly refuse to run (assuming this isn't a single function call)

hubblestack/extmods/utils/__init__.py

Whitespace-only changes.

hubblestack/fileclient.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
CommandExecutionError, MinionError
2424
)
2525
import hubblestack.loader
26-
import salt.payload
27-
import hubblestack.extmods.fileserver
26+
import hubblestack.payload
27+
import hubblestack.fileserver
2828
import hubblestack.utils.data
2929
import hubblestack.utils.files
3030
import hubblestack.utils.gzip_util
@@ -82,7 +82,7 @@ class Client(object):
8282
def __init__(self, opts):
8383
self.opts = opts
8484
self.utils = hubblestack.loader.utils(self.opts)
85-
self.serial = salt.payload.Serial(self.opts)
85+
self.serial = hubblestack.payload.Serial(self.opts)
8686

8787
# Add __setstate__ and __getstate__ so that the object may be
8888
# deep copied. It normally can't be deep copied because its
@@ -1113,7 +1113,7 @@ class FSClient(RemoteClient):
11131113
def __init__(self, opts): # pylint: disable=W0231
11141114
Client.__init__(self, opts) # pylint: disable=W0233
11151115
self._closing = False
1116-
self.channel = hubblestack.extmods.fileserver.FSChan(opts)
1116+
self.channel = hubblestack.fileserver.FSChan(opts)
11171117
self.auth = DumbAuth()
11181118

11191119

hubblestack/extmods/fileserver/__init__.py hubblestack/fileserver/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import errno
77

88
import hubblestack.loader
9-
import salt.payload
9+
import hubblestack.payload
1010
import hubblestack.utils.path
1111
import hubblestack.utils.files
1212
import hubblestack.utils.data
@@ -130,7 +130,7 @@ def check_env_cache(opts, env_cache):
130130
try:
131131
with hubblestack.utils.files.fopen(env_cache, 'rb') as fp_:
132132
log.trace('Returning env cache data from %s', env_cache)
133-
serial = salt.payload.Serial(opts)
133+
serial = hubblestack.payload.Serial(opts)
134134
return hubblestack.utils.data.decode(serial.load(fp_))
135135
except (IOError, OSError):
136136
pass
@@ -227,7 +227,7 @@ def check_file_list_cache(opts, form, list_cache, w_lock):
227227
"""
228228
refresh_cache = False
229229
save_cache = True
230-
serial = salt.payload.Serial(opts)
230+
serial = hubblestack.payload.Serial(opts)
231231
wait_lock(w_lock, list_cache, 5 * 60)
232232
if not os.path.isfile(list_cache) and _lock_cache(w_lock):
233233
refresh_cache = True
@@ -289,7 +289,7 @@ def write_file_list_cache(opts, data, list_cache, w_lock):
289289
returns the match (if found, along with booleans used by the fileserver
290290
backend to determine if the cache needs to be refreshed/written).
291291
'''
292-
serial = salt.payload.Serial(opts)
292+
serial = hubblestack.payload.Serial(opts)
293293
with hubblestack.utils.files.fopen(list_cache, 'w+b') as fp_:
294294
fp_.write(serial.dumps(data))
295295
_unlock_cache(w_lock)
@@ -888,4 +888,4 @@ def send(self, load, tries=None, timeout=None, raw=False): # pylint: disable=un
888888
return getattr(self.fs, cmd)(load)
889889

890890
def close(self):
891-
pass
891+
pass

hubblestack/extmods/fileserver/azurefs.py hubblestack/fileserver/azurefs.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
import os.path
5656
import shutil
5757

58-
import hubblestack.extmods.fileserver
58+
import hubblestack.fileserver
5959
import hubblestack.utils.files
6060
import hubblestack.utils.gzip_util
6161
import hubblestack.utils.hashutils
@@ -103,7 +103,7 @@ def find_file(path, saltenv='base', **kwargs):
103103
if container.get('saltenv', 'base') != saltenv:
104104
continue
105105
full = os.path.join(_get_container_path(container), path)
106-
if os.path.isfile(full) and not hubblestack.extmods.fileserver.is_file_ignored(
106+
if os.path.isfile(full) and not hubblestack.fileserver.is_file_ignored(
107107
__opts__, path):
108108
fnd['path'] = full
109109
fnd['rel'] = path
@@ -234,7 +234,7 @@ def update():
234234
fname = os.path.join(root, f)
235235
relpath = os.path.relpath(fname, path)
236236
if relpath not in blob_set:
237-
hubblestack.extmods.fileserver.wait_lock(fname + '.lk', fname)
237+
hubblestack.fileserver.wait_lock(fname + '.lk', fname)
238238
try:
239239
os.unlink(fname)
240240
except Exception:
@@ -260,7 +260,7 @@ def update():
260260
os.makedirs(os.path.dirname(fname))
261261
# Lock writes
262262
lk_fn = fname + '.lk'
263-
hubblestack.extmods.fileserver.wait_lock(lk_fn, fname)
263+
hubblestack.fileserver.wait_lock(lk_fn, fname)
264264
with hubblestack.utils.files.fopen(lk_fn, 'w+') as fp_:
265265
fp_.write('')
266266

@@ -298,7 +298,7 @@ def update():
298298
# Write out file list
299299
container_list = path + '.list'
300300
lk_fn = container_list + '.lk'
301-
hubblestack.extmods.fileserver.wait_lock(lk_fn, container_list)
301+
hubblestack.fileserver.wait_lock(lk_fn, container_list)
302302
with hubblestack.utils.files.fopen(lk_fn, 'w+') as fp_:
303303
fp_.write('')
304304
with hubblestack.utils.files.fopen(container_list, 'w') as fp_:
@@ -354,7 +354,7 @@ def file_list(load):
354354
continue
355355
container_list = _get_container_path(container) + '.list'
356356
lk = container_list + '.lk'
357-
hubblestack.extmods.fileserver.wait_lock(lk, container_list, 5)
357+
hubblestack.fileserver.wait_lock(lk, container_list, 5)
358358
if not os.path.exists(container_list):
359359
continue
360360
with hubblestack.utils.files.fopen(container_list, 'r') as fp_:

hubblestack/extmods/fileserver/gitfs.py hubblestack/fileserver/gitfs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
'insecure_auth')
6767

6868
from hubblestack.utils.signing import find_wrapf
69-
from hubblestack.extmods.utils.gitfs import GitFS
69+
from hubblestack.utils.gitfs import GitFS
7070
from hubblestack.utils.exceptions import FileserverConfigError
7171

7272
log = logging.getLogger(__name__)

hubblestack/extmods/fileserver/roots.py hubblestack/fileserver/roots.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import errno
2323
import logging
2424

25-
import hubblestack.extmods.fileserver
25+
import hubblestack.fileserver
2626
import hubblestack.utils.files
2727
import hubblestack.utils.gzip_util
2828
import hubblestack.utils.hashutils
@@ -86,14 +86,14 @@ def _add_file_stat(fnd):
8686
# An invalid index option was passed
8787
return fnd
8888
full = os.path.join(root, path)
89-
if os.path.isfile(full) and not hubblestack.extmods.fileserver.is_file_ignored(__opts__, full):
89+
if os.path.isfile(full) and not hubblestack.fileserver.is_file_ignored(__opts__, full):
9090
fnd['path'] = full
9191
fnd['rel'] = path
9292
return _add_file_stat(fnd)
9393
return fnd
9494
for root in __opts__['file_roots'][saltenv]:
9595
full = os.path.join(root, path)
96-
if os.path.isfile(full) and not hubblestack.extmods.fileserver.is_file_ignored(__opts__, full):
96+
if os.path.isfile(full) and not hubblestack.fileserver.is_file_ignored(__opts__, full):
9797
fnd['path'] = full
9898
fnd['rel'] = path
9999
return _add_file_stat(fnd)
@@ -139,7 +139,7 @@ def update():
139139
When we are asked to update (regular interval) lets reap the cache
140140
"""
141141
try:
142-
hubblestack.extmods.fileserver.reap_fileserver_cache_dir(
142+
hubblestack.fileserver.reap_fileserver_cache_dir(
143143
os.path.join(__opts__['cachedir'], 'roots', 'hash'),
144144
find_file
145145
)
@@ -154,7 +154,7 @@ def update():
154154
'backend': 'roots'}
155155

156156
# generate the new map
157-
new_mtime_map = hubblestack.extmods.fileserver.generate_mtime_map(__opts__, __opts__['file_roots'])
157+
new_mtime_map = hubblestack.fileserver.generate_mtime_map(__opts__, __opts__['file_roots'])
158158

159159
old_mtime_map = {}
160160
# if you have an old map, load that
@@ -175,7 +175,7 @@ def update():
175175
)
176176

177177
# compare the maps, set changed to the return value
178-
data['changed'] = hubblestack.extmods.fileserver.diff_mtime_map(old_mtime_map, new_mtime_map)
178+
data['changed'] = hubblestack.fileserver.diff_mtime_map(old_mtime_map, new_mtime_map)
179179

180180
# compute files that were removed and added
181181
old_files = set(old_mtime_map.keys())
@@ -293,7 +293,7 @@ def _file_lists(load, form):
293293
list_cache = os.path.join(list_cachedir, '{0}.p'.format(load['saltenv']))
294294
w_lock = os.path.join(list_cachedir, '.{0}.w'.format(load['saltenv']))
295295
cache_match, refresh_cache, save_cache = \
296-
hubblestack.extmods.fileserver.check_file_list_cache(
296+
hubblestack.fileserver.check_file_list_cache(
297297
__opts__, form, list_cache, w_lock
298298
)
299299
if cache_match is not None:
@@ -328,7 +328,7 @@ def _translate_sep(path):
328328
continue
329329
rel_path = _translate_sep(os.path.relpath(abs_path, fs_root))
330330
log.trace('roots: %s relative path is %s', abs_path, rel_path)
331-
if hubblestack.extmods.fileserver.is_file_ignored(__opts__, rel_path):
331+
if hubblestack.fileserver.is_file_ignored(__opts__, rel_path):
332332
continue
333333
tgt.add(rel_path)
334334
try:
@@ -390,7 +390,7 @@ def _translate_sep(path):
390390

391391
if save_cache:
392392
try:
393-
hubblestack.extmods.fileserver.write_file_list_cache(
393+
hubblestack.fileserver.write_file_list_cache(
394394
__opts__, ret, list_cache, w_lock
395395
)
396396
except NameError:

hubblestack/extmods/fileserver/s3fs.py hubblestack/fileserver/s3fs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
import logging
8888

8989
# Import salt libs
90-
import hubblestack.extmods.fileserver as fs
90+
import hubblestack.fileserver as fs
9191
import hubblestack.utils.files
9292
import hubblestack.utils.gzip_util
9393
import hubblestack.utils.hashutils

hubblestack/loader.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@
5050

5151
log = logging.getLogger(__name__)
5252

53-
# XXX: we only need this while we're still loading salt modules
54-
def __salt_basepath():
55-
import salt.syspaths
56-
return os.path.abspath(salt.syspaths.INSTALL_DIR)
57-
58-
# XXX: we only need this while we're still loading salt modules
59-
SALT_BASE_PATH = __salt_basepath()
6053
HUBBLE_BASE_PATH = os.path.abspath(hubblestack.syspaths.INSTALL_DIR)
6154
LOADED_BASE_NAME = 'hubble.loaded'
6255

@@ -107,9 +100,6 @@ def _module_dirs(
107100
hubblestack_type = 'hubblestack_' + (int_type or ext_type)
108101
files_base_types = os.path.join(base_path or HUBBLE_BASE_PATH, 'files', hubblestack_type)
109102

110-
# XXX should be removed eventually:
111-
salt_base_types = os.path.join(SALT_BASE_PATH, int_type or ext_type)
112-
113103
ext_type_types = []
114104
if ext_dirs:
115105
if tag is not None and ext_type_dirs is None:
@@ -139,8 +129,8 @@ def _module_dirs(
139129
cli_module_dirs.insert(0, maybe_dir)
140130

141131
if explain:
142-
return (cli_module_dirs, ext_type_types, [files_base_types, salt_base_types, ext_types, sys_types])
143-
return cli_module_dirs + ext_type_types + [files_base_types, salt_base_types, ext_types, sys_types]
132+
return (cli_module_dirs, ext_type_types, [files_base_types, ext_types, sys_types])
133+
return cli_module_dirs + ext_type_types + [files_base_types, ext_types, sys_types]
144134

145135

146136
def modules(
@@ -301,7 +291,7 @@ def grains(opts, force_refresh=False, proxy=None):
301291
if 'conf_file' in opts:
302292
pre_opts = {}
303293
pre_opts.update(hubblestack.config.load_config(
304-
opts['conf_file'], 'SALT_MINION_CONFIG',
294+
opts['conf_file'], 'HUBBLE_CONFIG',
305295
hubblestack.config.DEFAULT_OPTS['conf_file']
306296
))
307297
default_include = pre_opts.get(
@@ -444,10 +434,8 @@ def _generate_module(name):
444434
def _mod_type(module_path):
445435
if module_path.startswith(HUBBLE_BASE_PATH):
446436
if 'extmods' in module_path:
447-
return 'e_int' # XXX: we should remove this when we nolonger have internal extmods
437+
return 'e_int'
448438
return 'int'
449-
if module_path.startswith(SALT_BASE_PATH):
450-
return 'salt' # XXX: we should remove this after we nolonger depend on salt
451439
return 'ext'
452440

453441

0 commit comments

Comments
 (0)