@@ -412,119 +412,122 @@ def main(argv):
412
412
,"mongo_user=" ,"mongo_pass=" ,"blueking_cmdb_url=" ,"blueking_paas_url=" ,"listen_port=" ])
413
413
414
414
except getopt .GetoptError as e :
415
- print "\n \t " ,e .msg
416
- print "\n \t usage:" \
417
- ,"\n \t -discovery <discovery> the ZooKeeper server address, eg:127.0.0.1:2181" \
418
- ,"\n \t --database <database> the database name, default cmdb" \
419
- ,"\n \t --redis_ip <redis_ip> the redis ip, eg:127.0.0.1" \
420
- ,"\n \t --redis_port <redis_port> the redis port, default:6379" \
421
- ,"\n \t --redis_pass <redis_pass> the redis user password" \
422
- ,"\n \t --mongo_ip <mongo_ip> the mongo ip ,eg:127.0.0.1" \
423
- ,"\n \t --mongo_port <mongo_port> the mongo port, eg:27017" \
424
- ,"\n \t --mongo_user <mongo_user> the mongo user name, default:cc" \
425
- ,"\n \t --mongo_pass <mongo_pass> the mongo password" \
426
- ,"\n \t --blueking_cmdb_url <blueking_cmdb_url> the cmdb site url, eg: http://127.0.0.1:8088 or http://bk.tencent.com" \
427
- ,"\n \t --blueking_paas_url <blueking_paas_url> the blueking pass url, eg: http://127.0.0.1:8088 or http://bk.tencent.com" \
428
- ,"\n \t --listen_port <listen_port> the cmdb_webserver listen port, should be the port as same as -c <blueking_cmdb_url> specified, default:8083"
429
-
415
+ print ("\n \t " ,e .msg )
416
+ print ('''
417
+ usage:
418
+ --discovery <discovery> the ZooKeeper server address, eg:127.0.0.1:2181
419
+ --database <database> the database name, default cmdb
420
+ --redis_ip <redis_ip> the redis ip, eg:127.0.0.1
421
+ --redis_port <redis_port> the redis port, default:6379
422
+ --redis_pass <redis_pass> the redis user password
423
+ --mongo_ip <mongo_ip> the mongo ip ,eg:127.0.0.1
424
+ --mongo_port <mongo_port> the mongo port, eg:27017
425
+ --mongo_user <mongo_user> the mongo user name, default:cc
426
+ --mongo_pass <mongo_pass> the mongo password
427
+ --blueking_cmdb_url <blueking_cmdb_url> the cmdb site url, eg: http://127.0.0.1:8088 or http://bk.tencent.com
428
+ --blueking_paas_url <blueking_paas_url> the blueking paas url, eg: http://127.0.0.1:8088 or http://bk.tencent.com
429
+ --listen_port <listen_port> the cmdb_webserver listen port, should be the port as same as -c <blueking_cmdb_url> specified, default:8083
430
+ ''' )
431
+
430
432
sys .exit (2 )
431
433
if len (opts ) == 0 :
432
- print "\n \t usage:" \
433
- ,"\n \t --discovery <discovery> the ZooKeeper server address, eg:127.0.0.1:2181" \
434
- ,"\n \t --database <database> the database name, default cmdb" \
435
- ,"\n \t --redis_ip <redis_ip> the redis ip, eg:127.0.0.1" \
436
- ,"\n \t --redis_port <redis_port> the redis port, default:6379" \
437
- ,"\n \t --redis_pass <redis_pass> the redis user password" \
438
- ,"\n \t --mongo_ip <mongo_ip> the mongo ip ,eg:127.0.0.1" \
439
- ,"\n \t --mongo_port <mongo_port> the mongo port, eg:27017" \
440
- ,"\n \t --mongo_user <mongo_user> the mongo user name, default:cc" \
441
- ,"\n \t --mongo_pass <mongo_pass> the mongo password" \
442
- ,"\n \t --blueking_cmdb_url <blueking_cmdb_url> the cmdb site url, eg: http://127.0.0.1:8088 or http://bk.tencent.com" \
443
- ,"\n \t --blueking_paas_url <blueking_paas_url> the blueking paas url, eg: http://127.0.0.1:8088 or http://bk.tencent.com" \
444
- ,"\n \t --listen_port <listen_port> the cmdb_webserver listen port, should be the port as same as -c <blueking_cmdb_url> specified, default:8083"
445
-
434
+ print ('''
435
+ usage:
436
+ --discovery <discovery> the ZooKeeper server address, eg:127.0.0.1:2181
437
+ --database <database> the database name, default cmdb
438
+ --redis_ip <redis_ip> the redis ip, eg:127.0.0.1
439
+ --redis_port <redis_port> the redis port, default:6379
440
+ --redis_pass <redis_pass> the redis user password
441
+ --mongo_ip <mongo_ip> the mongo ip ,eg:127.0.0.1
442
+ --mongo_port <mongo_port> the mongo port, eg:27017
443
+ --mongo_user <mongo_user> the mongo user name, default:cc
444
+ --mongo_pass <mongo_pass> the mongo password
445
+ --blueking_cmdb_url <blueking_cmdb_url> the cmdb site url, eg: http://127.0.0.1:8088 or http://bk.tencent.com
446
+ --blueking_paas_url <blueking_paas_url> the blueking paas url, eg: http://127.0.0.1:8088 or http://bk.tencent.com
447
+ --listen_port <listen_port> the cmdb_webserver listen port, should be the port as same as -c <blueking_cmdb_url> specified, default:8083
448
+ ''' )
446
449
sys .exit (2 )
447
- #print opts
450
+
448
451
for opt , arg in opts :
449
452
if opt in ('-h' ,'--help' ):
450
- print 'init.py --discovery <discovery> --database <database> --redis_ip <redis_ip> --redis_port <redis_port> --redis_pass <redis_pass> --mongo_ip <mongo_ip> --mongo_port <mongo_port> --mongo_user <mongo_user> --mongo_pass <mongo_pass> --blueking_cmdb_url <blueking_cmdb_url> --blueking_paas_url <blueking_paas_url> --listen_port <listen_port>'
453
+ print ( 'init.py --discovery <discovery> --database <database> --redis_ip <redis_ip> --redis_port <redis_port> --redis_pass <redis_pass> --mongo_ip <mongo_ip> --mongo_port <mongo_port> --mongo_user <mongo_user> --mongo_pass <mongo_pass> --blueking_cmdb_url <blueking_cmdb_url> --blueking_paas_url <blueking_paas_url> --listen_port <listen_port>' )
451
454
sys .exit ()
452
455
elif opt in ("-d" , "--discovery" ):
453
456
rd_server = arg
454
- print 'rd_server:' + rd_server
457
+ print ( 'rd_server:' + rd_server )
455
458
elif opt in ("-D" , "--database" ):
456
459
db_name = arg
457
- print 'database:' ,db_name
460
+ print ( 'database:' ,db_name )
458
461
elif opt in ("-r" , "--redis_ip" ):
459
462
redis_ip = arg
460
- print 'redis_ip:' + redis_ip
463
+ print ( 'redis_ip:' + redis_ip )
461
464
elif opt in ("-p" ,"--redis_port" ):
462
465
redis_port = arg
463
- print 'redis_port:' ,redis_port
466
+ print ( 'redis_port:' ,redis_port )
464
467
elif opt in ("-s" ,"--redis_pass" ):
465
468
redis_pass = arg
466
- print 'redis_pass:' ,redis_pass
469
+ print ( 'redis_pass:' ,redis_pass )
467
470
elif opt in ("-m" ,"--mongo_ip" ):
468
471
mongo_ip = arg
469
- print 'mongo_ip:' ,mongo_ip
472
+ print ( 'mongo_ip:' ,mongo_ip )
470
473
elif opt in ("-P" ,"--mongo_port" ):
471
474
mongo_port = arg
472
- print 'mongo_port:' ,mongo_port
475
+ print ( 'mongo_port:' ,mongo_port )
473
476
elif opt in ("-X" ,"--mongo_user" ):
474
477
mongo_user = arg
475
- print 'mongo_user:' ,mongo_user
478
+ print ( 'mongo_user:' ,mongo_user )
476
479
elif opt in ("-S" ,"--mongo_pass" ):
477
480
mongo_pass = arg
478
- print 'mongo_pass:' ,mongo_pass
481
+ print ( 'mongo_pass:' ,mongo_pass )
479
482
elif opt in ("-u" ,"--blueking_cmdb_url" ):
480
483
cc_url = arg
481
- print 'blueking_cmdb_url:' ,cc_url
484
+ print ( 'blueking_cmdb_url:' ,cc_url )
482
485
elif opt in ("-U" ,"--blueking_paas_url" ):
483
486
paas_url = arg
484
- print 'blueking_pass_url:' ,paas_url
487
+ print ( 'blueking_pass_url:' ,paas_url )
485
488
elif opt in ("-l" ,"--listen_port" ):
486
489
server_ports ["cmdb_webserver" ]= arg
487
- print "listen_port:" ,server_ports ["cmdb_webserver" ]
490
+ print ( "listen_port:" ,server_ports ["cmdb_webserver" ])
488
491
489
492
if 0 == len (rd_server ):
490
- print 'please input the ZooKeeper address, eg:127.0.0.1:2181'
493
+ print ( 'please input the ZooKeeper address, eg:127.0.0.1:2181' )
491
494
sys .exit ()
492
495
if 0 == len (db_name ):
493
- print 'please input the database name, eg:cmdb'
496
+ print ( 'please input the database name, eg:cmdb' )
494
497
sys .exit ()
495
498
if 0 == len (redis_ip ):
496
- print 'please input the redis ip, eg: 127.0.0.1'
499
+ print ( 'please input the redis ip, eg: 127.0.0.1' )
497
500
sys .exit ()
498
501
if redis_port < 0 :
499
- print 'please input the redis port, eg:6379'
502
+ print ( 'please input the redis port, eg:6379' )
500
503
sys .exit ()
501
504
if 0 == len (redis_pass ):
502
- print 'please input the redis password'
505
+ print ( 'please input the redis password' )
503
506
sys .exit ()
504
507
if 0 == len (mongo_ip ):
505
- print 'please input the mongo ip, eg:127.0.0.1'
508
+ print ( 'please input the mongo ip, eg:127.0.0.1' )
506
509
sys .exit ()
507
510
if mongo_port < 0 :
508
- print 'please input the mongo port, eg:27017'
511
+ print ( 'please input the mongo port, eg:27017' )
509
512
sys .exit ()
510
513
if 0 == len (mongo_user ):
511
- print 'please input the mongo user, eg:cc'
514
+ print ( 'please input the mongo user, eg:cc' )
512
515
sys .exit ()
513
516
if 0 == len (mongo_pass ):
514
- print 'please input the mongo password'
517
+ print ( 'please input the mongo password' )
515
518
sys .exit ()
516
519
if 0 == len (cc_url ):
517
- print 'please input the blueking cmdb url'
520
+ print ( 'please input the blueking cmdb url' )
518
521
sys .exit ()
519
522
if 0 == len (paas_url ):
520
- print 'please input the blueking paas url'
523
+ print ( 'please input the blueking paas url' )
521
524
sys .exit ()
522
525
if not cc_url .startswith ("http://" ):
523
- print 'blueking cmdb url not start with http://'
526
+ print ( 'blueking cmdb url not start with http://' )
524
527
sys .exit ()
525
528
526
529
generate_config_file (rd_server ,db_name ,redis_ip ,redis_port ,redis_user ,redis_pass ,mongo_ip ,mongo_port ,mongo_user ,mongo_pass ,cc_url ,paas_url )
527
530
update_start_script (rd_server , server_ports )
528
- print 'initial configurations success, configs could be found at cmdb_adminserver/configures'
531
+ print ( 'initial configurations success, configs could be found at cmdb_adminserver/configures' )
529
532
if __name__ == "__main__" :
530
533
main (sys .argv [1 :])
0 commit comments