Example #1
0
def _load_comoditrc_conf(options):
    """
    """

    profile_name = None
    if options.profile:
        profile_name = options.profile

    config = Config()
    try:
        org = config._get_value(profile_name, 'default_organization')
    except:
        org = ''

    if options.organization:
        org = options.organization

    return {
        'api': config.get_api(profile_name),
        'username': config.get_username(profile_name),
        'password': config.get_password(profile_name),
        'organization': org
    }
Example #2
0
        action="store_true",
        default=False)

    options = parser.parse_known_args(args=sys.argv)[0]

    # Use profile data to configure connection.
    if not options.api is None:
        api = options.api
    else:
        api = config.get_api(options.profile)
        options.api = api

    if not options.username is None:
        username = options.username
    else:
        username = config.get_username(options.profile)
        options.username = username

    if not options.password is None:
        password = options.password
    else:
        password = config.get_password(options.profile)
        options.password = password

    if (username == None) or (api == None) or (password == None):
        raise Exception("No credentials found")

    console = ComodITConsole(options.debug)
    console.connect(api, username, password, options.insecure)
    if options.file is None:
        console.interact()
Example #3
0
    parser.add_argument('-f', "--file", dest = "file", help = "Tells the client to execute the content of given file", default = None)
    parser.add_argument('-d', "--debug", dest = "debug", help = "Tells the client to work in debug mode, causing every exception to be considered as an error", action = "store_true", default = False)

    options = parser.parse_known_args(args = sys.argv)[0]

    # Use profile data to configure connection.
    if not options.api is None:
        api = options.api
    else:
        api = config.get_api(options.profile)
        options.api = api

    if not options.username is None:
        username = options.username
    else:
        username = config.get_username(options.profile)
        options.username = username

    if not options.password is None:
        password = options.password
    else:
        password = config.get_password(options.profile)
        options.password = password

    if (username == None) or (api == None) or (password == None):
        raise Exception("No credentials found")

    console = ComodITConsole(options.debug)
    console.connect(api, username, password, options.insecure)
    if options.file is None:
        console.interact()