Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding more (debug) logs to make ccm more (new) user friendly … #734

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ccmlib/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ def _update_config(self):
extension.append_to_cluster_config(self, config_map)
with open(filename, 'w') as f:
yaml.safe_dump(config_map, f)
common.debug("{} was updated.".format(filename))

def __update_pids(self, started):
for node, p, _ in started:
Expand Down
1 change: 1 addition & 0 deletions ccmlib/cluster_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ClusterFactory():
def load(path, name):
cluster_path = os.path.join(path, name)
filename = os.path.join(cluster_path, 'cluster.conf')
common.debug("Loading {} ...".format(filename))
with open(filename, 'r') as f:
data = yaml.safe_load(f)
try:
Expand Down
2 changes: 2 additions & 0 deletions ccmlib/cmds/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def validate(self, parser, options, args, cluster_name=False, node_name=False, l
else:
self.path = options.config_dir

common.debug("Using ccm data and config path {} ...".format(self.path))

if cluster_name:
if len(args) == 0:
print_('Missing cluster name', file=sys.stderr)
Expand Down
2 changes: 2 additions & 0 deletions ccmlib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ def get_user_home():
def get_config():
config_path = os.path.join(get_default_path(), CONFIG_FILE)
if not os.path.exists(config_path):
common.debug("Config file does not exist at {}.".format(config_path))
return {}

common.debug("Loading config file from {} ...".format(config_path))
with open(config_path, 'r') as f:
return yaml.safe_load(f)

Expand Down
17 changes: 14 additions & 3 deletions ccmlib/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@
GITHUB_REPO = "https://github.com/apache/cassandra.git"
GITHUB_TAGS = "https://api.github.com/repos/apache/cassandra/git/refs/tags"
CCM_CONFIG = ConfigParser.RawConfigParser()
CCM_CONFIG.read(os.path.join(os.path.expanduser("~"), ".ccm", "config"))

config_path = os.path.join(os.path.expanduser("~"), ".ccm", "config")
read_ok = CCM_CONFIG.read(config_path)
if len(read_ok) == 0:
common.debug("Config file {} was not found or could not be read.".format(config_path))
else:
common.debug("Config file {} was successfully read.".format(config_path))

def setup(version, verbose=False):
binary = True
Expand Down Expand Up @@ -112,6 +116,8 @@ def setup(version, verbose=False):
return (version_directory(version), None)
else:
raise e
else:
common.debug("Cassandra version was found in {}, no need to download.".format(cdir))
return (cdir, version)


Expand Down Expand Up @@ -289,6 +295,7 @@ def download_dse_version(version, username, password, verbose=False):
tar.extractall(path=__get_dir())
tar.close()
target_dir = os.path.join(__get_dir(), version)
common.debug("Moving extracted files to {} ...".format(target_dir))
if os.path.exists(target_dir):
rmdirs(target_dir)
shutil.move(os.path.join(__get_dir(), dir), target_dir)
Expand Down Expand Up @@ -319,6 +326,7 @@ def download_opscenter_version(version, username, password, target_version, verb
tar.extractall(path=__get_dir())
tar.close()
target_dir = os.path.join(__get_dir(), target_version)
common.debug("Moving extracted files to {} ...".format(target_dir))
if os.path.exists(target_dir):
rmdirs(target_dir)
shutil.move(os.path.join(__get_dir(), dir), target_dir)
Expand Down Expand Up @@ -353,6 +361,7 @@ def download_version(version, url=None, verbose=False, binary=False):
tar.extractall(path=__get_dir())
tar.close()
target_dir = os.path.join(__get_dir(), version)
common.debug("Moving extracted files to {} ...".format(target_dir))
if os.path.exists(target_dir):
rmdirs(target_dir)
shutil.move(os.path.join(__get_dir(), dir), target_dir)
Expand Down Expand Up @@ -476,10 +485,12 @@ def version_directory(version):
try:
validate_install_dir(dir)
return dir
except ArgumentError:
except ArgumentError as e:
common.warning(e)
rmdirs(dir)
return None
else:
common.debug("Directory {} for Cassandra version {} was not found.".format(dir, version))
return None


Expand Down