def main(): parser = optparse.OptionParser() parser.add_option( "-H", "--host", dest="host", default='localhost', action='store', help= "[Optional] IP address or DNS name of a ZStack management node. Default value: localhost" ) parser.add_option( "-p", "--port", dest="port", default='8080', action='store', help= "[Optional] Port that the ZStack management node is listening on. Default value: 8080" ) parser.add_option("-d", "--deploy", dest="deploy_config_file", default=None, action='store', help="[Optional] deploy a cloud from a XML file.") parser.add_option( "-t", "--template", dest="deploy_config_template_file", default=None, action='store', help= "[Optional] variable template file for XML file specified in option '-d'" ) parser.add_option("-D", "--dump", dest="zstack_config_dump_file", default=None, action='store', help="[Optional] dump a cloud to a XML file") parser.add_option( "-P", "--password", dest="admin_password", default='password', action='store', help= "[Optional] admin account password for dumping and recovering cloud environment. It can only be used when set -D or -d option. Default is 'password'." ) parser.add_option( "-s", "--no-secure", dest="no_secure", default=False, action='store_true', help= "[Optional] if setting -s, will save password information in command history. " ) (options, args) = parser.parse_args() cmd = ' '.join(args) os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = options.host os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_PORT'] = options.port if options.zstack_config_dump_file: admin_passwd = hashlib.sha512(options.admin_password).hexdigest() read_config.dump_zstack(options.zstack_config_dump_file, admin_passwd) elif options.deploy_config_file: # deploy ZStack pre-configed environment. xml_config = parse_config.DeployConfig( options.deploy_config_file, options.deploy_config_template_file) deploy_xml_obj = xml_config.get_deploy_config() admin_passwd = hashlib.sha512(options.admin_password).hexdigest() try: deploy_xml_obj.deployerConfig except: deploy_config.deploy_initial_database(deploy_xml_obj, admin_passwd) else: deploy_config.deploy_initial_database( deploy_xml_obj.deployerConfig, admin_passwd) print('Successfully deployed a cloud from: %s' % options.deploy_config_file) else: cli = Cli(options) cli.main(cmd)
def main(): parser = optparse.OptionParser() parser.add_option( "-H", "--host", dest="host", default='localhost', action='store', help= "[Optional] IP address or DNS name of a ZStack management node. Default value: localhost" ) parser.add_option( "-p", "--port", dest="port", default='8080', action='store', help= "[Optional] Port that the ZStack management node is listening on. Default value: 8080" ) parser.add_option("-d", "--deploy", dest="deploy_config_file", default=None, action='store', help="[Optional] deploy a cloud from a XML file.") parser.add_option( "-t", "--tempate", dest="deploy_config_template_file", default=None, action='store', help= "[Optional] variable template file for XML file spcified in option '-d'" ) parser.add_option("-D", "--dump", dest="zstack_config_dump_file", default=None, action='store', help="[Optional] dump a cloud to a XML file") (options, args) = parser.parse_args() cmd = ' '.join(args) os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = options.host os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_PORT'] = options.port if options.zstack_config_dump_file: read_config.dump_zstack(options.zstack_config_dump_file) elif options.deploy_config_file: #deploy ZStack pre-configed environment. xml_config = parse_config.DeployConfig( options.deploy_config_file, options.deploy_config_template_file) deploy_xml_obj = xml_config.get_deploy_config() try: deploy_xml_obj.deployerConfig except: deploy_config.deploy_initial_database(deploy_xml_obj) else: deploy_config.deploy_initial_database( deploy_xml_obj.deployerConfig) print('Successfully deployed a cloud from: %s' % options.deploy_config_file) else: cli = Cli(options) cli.main(cmd)
def main(): parser = optparse.OptionParser() parser.add_option( "-H", "--host", dest="host", default='localhost', action='store', help="[Optional] IP address or DNS name of a ZStack management node. Default value: localhost") parser.add_option( "-p", "--port", dest="port", default='8080', action='store', help="[Optional] Port that the ZStack management node is listening on. Default value: 8080") parser.add_option( "-d", "--deploy", dest="deploy_config_file", default=None, action='store', help="[Optional] deploy a cloud from a XML file.") parser.add_option( "-t", "--tempate", dest="deploy_config_template_file", default=None, action='store', help="[Optional] variable template file for XML file spcified in option '-d'") parser.add_option( "-D", "--dump", dest="zstack_config_dump_file", default=None, action='store', help="[Optional] dump a cloud to a XML file") parser.add_option( "-P", "--password", dest="admin_password", default='password', action='store', help="[Optional] admin account password for dumping and recovering cloud environment. It can only be used when set -D or -d option. Default is 'password'.") parser.add_option( "-s", "--no-secure", dest="no_secure", default=False, action='store_true', help="[Optional] if setting -s, will save password information in command history. ") (options, args) = parser.parse_args() cmd = ' '.join(args) os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = options.host os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_PORT'] = options.port if options.zstack_config_dump_file: admin_passwd = hashlib.sha512(options.admin_password).hexdigest() read_config.dump_zstack(options.zstack_config_dump_file, \ admin_passwd) elif options.deploy_config_file: #deploy ZStack pre-configed environment. xml_config = parse_config.DeployConfig(options.deploy_config_file, \ options.deploy_config_template_file) deploy_xml_obj = xml_config.get_deploy_config() admin_passwd = hashlib.sha512(options.admin_password).hexdigest() try: deploy_xml_obj.deployerConfig except: deploy_config.deploy_initial_database(deploy_xml_obj, admin_passwd) else: deploy_config.deploy_initial_database(deploy_xml_obj.deployerConfig\ , admin_passwd) print('Successfully deployed a cloud from: %s' % options.deploy_config_file) else: cli = Cli(options) cli.main(cmd)
def main(): parser = optparse.OptionParser() parser.add_option( "-H", "--host", dest="host", default='localhost', action='store', help="[Optional] IP address or DNS name of a ZStack management node. Default value: localhost") parser.add_option( "-p", "--port", dest="port", default='8080', action='store', help="[Optional] Port that the ZStack management node is listening on. Default value: 8080") parser.add_option( "-d", "--deploy", dest="deploy_config_file", default=None, action='store', help="[Optional] deploy a cloud from a XML file.") parser.add_option( "-t", "--tempate", dest="deploy_config_template_file", default=None, action='store', help="[Optional] variable template file for XML file spcified in option '-d'") parser.add_option( "-D", "--dump", dest="zstack_config_dump_file", default=None, action='store', help="[Optional] dump a cloud to a XML file") (options, args) = parser.parse_args() cmd = ' '.join(args) os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = options.host os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_PORT'] = options.port if options.zstack_config_dump_file: read_config.dump_zstack(options.zstack_config_dump_file) elif options.deploy_config_file: #deploy ZStack pre-configed environment. xml_config = parse_config.DeployConfig(options.deploy_config_file, options.deploy_config_template_file) deploy_xml_obj = xml_config.get_deploy_config() try: deploy_xml_obj.deployerConfig except: deploy_config.deploy_initial_database(deploy_xml_obj) else: deploy_config.deploy_initial_database(deploy_xml_obj.deployerConfig) print('Successfully deployed a cloud from: %s' % options.deploy_config_file) else: cli = Cli(options) cli.main(cmd)