Skip to content

Commit 93bc669

Browse files
committed
cli: Pass config file by value in cloudmonkey's config
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent 19d1a30 commit 93bc669

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

tools/cli/cloudmonkey/config.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
# Use following rules for versioning:
2020
# <cloudstack version>-<cli increment, starts from 0>
2121
__version__ = "4.1.0-0"
22+
__description__ = "Command Line Interface for Apache CloudStack"
23+
__maintainer__ = "Rohit Yadav"
24+
__maintaineremail__ = "bhaisaab@apache.org"
25+
__project__ = "The Apache CloudStack Team"
26+
__projectemail__ = "cloudstack-dev@incubator.apache.org"
27+
__projecturl__ = "http://incubator.apache.org/cloudstack"
2228

2329
try:
2430
import os
@@ -36,14 +42,14 @@
3642

3743
config_dir = expanduser('~/.cloudmonkey')
3844
config_file = expanduser(config_dir + '/config')
39-
cache_file = expanduser(config_dir + '/cache')
4045

4146
# cloudmonkey config fields
42-
config_fields = {'core': {}, 'ui': {}, 'server': {}, 'user': {}}
47+
config_fields = {'core': {}, 'server': {}, 'user': {}, 'ui': {}}
4348

4449
# core
4550
config_fields['core']['asyncblock'] = 'true'
4651
config_fields['core']['paramcompletion'] = 'false'
52+
config_fields['core']['cache_file'] = expanduser(config_dir + '/cache')
4753
config_fields['core']['history_file'] = expanduser(config_dir + '/history')
4854
config_fields['core']['log_file'] = expanduser(config_dir + '/log')
4955

@@ -64,8 +70,8 @@
6470
config_fields['user']['secretkey'] = ''
6571

6672

67-
def write_config(get_attr, first_time=False):
68-
global config_fields, config_file
73+
def write_config(get_attr, config_file, first_time=False):
74+
global config_fields
6975
config = ConfigParser()
7076
for section in config_fields.keys():
7177
config.add_section(section)
@@ -79,8 +85,8 @@ def write_config(get_attr, first_time=False):
7985
return config
8086

8187

82-
def read_config(get_attr, set_attr):
83-
global config_fields, config_dir, config_file
88+
def read_config(get_attr, set_attr, config_file):
89+
global config_fields, config_dir
8490
if not os.path.exists(config_dir):
8591
os.makedirs(config_dir)
8692

@@ -95,7 +101,7 @@ def read_config(get_attr, set_attr):
95101
except IOError, e:
96102
print "Error: config_file not found", e
97103
else:
98-
config = write_config(get_attr, True)
104+
config = write_config(get_attr, config_file, True)
99105
print "Welcome! Using `set` configure the necessary settings:"
100106
print " ".join(sorted(config_options))
101107
print "Config file:", config_file

0 commit comments

Comments
 (0)