Alternating colors for debug. Change ntp server to

array. Remove some useless printing.
This commit is contained in:
Michael Chapman
2013-09-27 22:40:30 +10:00
parent 87a0b22271
commit cb2711a3da
4 changed files with 35 additions and 32 deletions

View File

@@ -43,7 +43,7 @@ host {
}
class { ntp:
servers => 'ntp.esl.cisco.com',
servers => [ 'ntp.esl.cisco.com' ],
autoupdate => true,
}

View File

@@ -27,7 +27,7 @@ def main():
parser_make.add_argument('-p', '--data_path', default='./data', help='Path to the data directory containing yaml config')
parser_make.add_argument('-f', '--fragment_path', default='./stack-builder/fragments', help='Path to config fragments')
#parser_make.add_argument('-n', '--noop', action='store_false', help='Make no API calls, just print what would have been done')
parser_make.add_argument('-d', '--debug', action='store_false', help='print debug output')
parser_make.add_argument('-d', '--debug', action='store_true', help='print debug output')
parser_make.set_defaults(func=make)
parser_get = subparsers.add_parser('get', help='get help')
@@ -47,7 +47,6 @@ def main():
parser_frag.set_defaults(func=show)
args = parser.parse_args()
print args
args.func(n, q, args)

View File

@@ -7,7 +7,7 @@
and pushing the appropriate metadata and init scripts to them
"""
import debug
import subprocess
import os
import uuid
@@ -17,9 +17,6 @@ import fragment
from metadata import build_metadata
from debug import dprint
debug = False
noop = False
def build_server_deploy():
with open ('./stack-builder/fragments/build-config.sh', 'r') as b:
return b.read()
@@ -111,7 +108,6 @@ def make_subnet(q, ci_network_name, test_net, index=1, dhcp=True, gateway=False)
return test_subnet
def boot_puppetised_instance(n, name, image, nic_list, key='m', os_flavor=u'm1.medium',deploy="",files=None, meta={}):
dprint("Booting " + name)
images = n.images.list()
for i,image in enumerate([image.name for image in images]):
if image == image:
@@ -123,13 +119,13 @@ def boot_puppetised_instance(n, name, image, nic_list, key='m', os_flavor=u'm1.m
boot_flavor = flavors[i]
print("Booting " + name)
dprint("Boot image:" + str(boot_image))
dprint("Boot flavor:" + str(boot_flavor))
dprint("Boot nics" + str(nic_list))
dprint("Boot key" + str(key))
dprint("Boot deploy" + str(deploy))
dprint("Boot files" + str(files))
dprint("Boot meta" + str(meta))
dprint("Boot image: " + str(boot_image))
dprint("Boot flavor: " + str(boot_flavor))
dprint("Boot nics: " + str(nic_list))
dprint("Boot key: " + str(key))
dprint("Boot deploy: " + str(deploy))
dprint("Boot files: " + str(files))
dprint("Boot meta: " + str(meta))
return n.servers.create(name, image=boot_image, flavor=boot_flavor, userdata=deploy, files=files, key_name=key, nics=nic_list, config_drive=True, meta=meta)
@@ -192,12 +188,9 @@ def make(n, q, args):
data_path = args.data_path
fragment_path = args.fragment_path
# These are globals
if args.debug:
debug = True
if args.noop:
noop = True
print 'Debugging is on!'
debug.debug = True
test_id = uuid.uuid4().hex
print "Running test: " + test_id
@@ -231,7 +224,8 @@ def make(n, q, args):
# Not sure if we need this
control_node_internal = net1_ports[0]['fixed_ips'][0]['ip_address']
config_meta = build_metadata(data_path)
config_meta = build_metadata(data_path)
dprint('Metadata Without hardcodes ' + str(config_meta))
# Put this into metadata and parse it on-node
# from config drive. There are limits on the count
# according to the doc but TODO confirm this
@@ -252,13 +246,16 @@ def make(n, q, args):
#'installer_repo' : 'michaeltchapman'
})
dprint("Metadata:\n" + str(config_meta))
dprint('Metadata With hardcodes ' + str(config_meta))
build_deploy = fragment.compose('build-server', data_path, fragment_path, scenario, config_meta)
control_deploy = fragment.compose('control-server', data_path, fragment_path, scenario, config_meta)
compute_deploy = fragment.compose('compute-server02', data_path, fragment_path, scenario, config_meta)
dprint('build_deploy: ' + str(build_deploy))
dprint('control_deploy: ' + str(control_deploy))
dprint('compute_deploy: ' + str(compute_deploy))
build_node = boot_puppetised_instance(n,
'build-server',
image,
@@ -289,6 +286,7 @@ def make(n, q, args):
def get(n, q, args):
if args.test_id:
print "Servers for test: " + test_id
run_instances = []
instances = n.servers.list()
for instance in instances:
@@ -297,9 +295,12 @@ def get(n, q, args):
run_instances.append(instance)
else:
run_instances = []
run_instances = {}
instances = n.servers.list()
for instance in instances:
if 'ci_test_id' in instance.metadata:
run_instances.append(instance)
if instance.metadata['ci_test_id'] not in run_instances:
run_instances[instance.metadata['ci_test_id']] = [instance.id]
else:
run_instances[instance.metadata['ci_test_id']].append(instance.id)
print run_instances

View File

@@ -1,10 +1,13 @@
from build import debug, noop
debug = False
even = True
def dprint(string):
global even
global debug
if debug:
print '\033[94m' + str(string) + '\033[0m'
def nprint(string):
if noop:
print '\033[92m' + str(string) + '\033[0m'
if even:
print '\x1b[34m' + str(string) + '\x1b[0m'
even = False
else:
print '\x1b[1;34m' + str(string) + '\x1b[0m'
even = True