예제 #1
0
파일: cli.py 프로젝트: zeronewb/maas
 def __call__(self, options):
     with ProfileConfig.open() as config:
         for profile_name in config:
             profile = config[profile_name]
             url = profile["url"]
             profile["description"] = fetch_api_description(url)
             config[profile_name] = profile
예제 #2
0
파일: cli.py 프로젝트: zeronewb/maas
 def __call__(self, options):
     # Try and obtain credentials interactively if they're not given, or
     # read them from stdin if they're specified as "-".
     credentials = obtain_credentials(options.url, options.credentials)
     # Check for bogus credentials. Do this early so that the user is not
     # surprised when next invoking the MAAS CLI.
     if credentials is not None:
         try:
             valid_apikey = check_valid_apikey(
                 options.url, credentials, options.insecure)
         except UnexpectedResponse as e:
             raise SystemExit("%s" % e)
         else:
             if not valid_apikey:
                 raise SystemExit("The MAAS server rejected your API key.")
     # Get description of remote API.
     description = fetch_api_description(options.url, options.insecure)
     # Save the config.
     profile_name = options.profile_name
     with ProfileConfig.open() as config:
         config[profile_name] = {
             "credentials": credentials,
             "description": description,
             "name": profile_name,
             "url": options.url,
             }
         profile = config[profile_name]
     self.print_whats_next(profile)
예제 #3
0
파일: cli.py 프로젝트: deepakhajare/maas
 def __call__(self, options):
     with ProfileConfig.open() as config:
         for profile_name in config:
             profile = config[profile_name]
             url = profile["url"]
             profile["description"] = fetch_api_description(url)
             config[profile_name] = profile
예제 #4
0
파일: cli.py 프로젝트: shawnallen85/maas
 def __call__(self, options):
     try:
         with ProfileConfig.open() as config:
             for profile_name in config:
                 profile = config[profile_name]
                 url = profile["url"]
                 profile["description"] = fetch_api_description(url)
                 config[profile_name] = profile
     except FileNotFoundError:
         return
예제 #5
0
파일: cli.py 프로젝트: zeronewb/maas
 def __call__(self, options):
     with ProfileConfig.open() as config:
         for profile_name in config:
             profile = config[profile_name]
             url = profile["url"]
             creds = profile["credentials"]
             if creds is None:
                 print(profile_name, url)
             else:
                 creds = convert_tuple_to_string(creds)
                 print(profile_name, url, creds)
예제 #6
0
파일: cli.py 프로젝트: deepakhajare/maas
 def __call__(self, options):
     with ProfileConfig.open() as config:
         for profile_name in config:
             profile = config[profile_name]
             url = profile["url"]
             creds = profile["credentials"]
             if creds is None:
                 print(profile_name, url)
             else:
                 creds = convert_tuple_to_string(creds)
                 print(profile_name, url, creds)
예제 #7
0
파일: api.py 프로젝트: cloudbase/maas
def register_api_commands(parser):
    """Register all profiles as subcommands on `parser`."""
    with ProfileConfig.open() as config:
        for profile_name in config:
            profile = config[profile_name]
            profile_parser = parser.subparsers.add_parser(
                profile["name"], help="Interact with %(url)s" % profile,
                description=(
                    "Issue commands to the MAAS region controller at %(url)s."
                    % profile),
                epilog=profile_help)
            register_resources(profile, profile_parser)
예제 #8
0
def register_api_commands(parser):
    """Register all profiles as subcommands on `parser`."""
    with ProfileConfig.open() as config:
        for profile_name in config:
            profile = config[profile_name]
            profile_parser = parser.subparsers.add_parser(
                profile["name"], help="Interact with %(url)s" % profile,
                description=(
                    "Issue commands to the MAAS region controller at %(url)s."
                    % profile),
                epilog=profile_help)
            register_resources(profile, profile_parser)
예제 #9
0
파일: cli.py 프로젝트: deepakhajare/maas
 def __call__(self, options):
     # Try and obtain credentials interactively if they're not given, or
     # read them from stdin if they're specified as "-".
     credentials = obtain_credentials(options.credentials)
     # Get description of remote API.
     description = fetch_api_description(options.url, options.insecure)
     # Save the config.
     profile_name = options.profile_name
     with ProfileConfig.open() as config:
         config[profile_name] = {
             "credentials": credentials,
             "description": description,
             "name": profile_name,
             "url": options.url,
             }
         profile = config[profile_name]
     self.print_whats_next(profile)
예제 #10
0
파일: cli.py 프로젝트: cloudbase/maas
 def __call__(self, options):
     # Try and obtain credentials interactively if they're not given, or
     # read them from stdin if they're specified as "-".
     credentials = obtain_credentials(options.credentials)
     # Get description of remote API.
     description = fetch_api_description(options.url, options.insecure)
     # Save the config.
     profile_name = options.profile_name
     with ProfileConfig.open() as config:
         config[profile_name] = {
             "credentials": credentials,
             "description": description,
             "name": profile_name,
             "url": options.url,
         }
         profile = config[profile_name]
     self.print_whats_next(profile)
예제 #11
0
파일: cli.py 프로젝트: zeronewb/maas
 def __call__(self, options):
     with ProfileConfig.open() as config:
         del config[options.profile_name]
예제 #12
0
파일: cli.py 프로젝트: deepakhajare/maas
 def __call__(self, options):
     with ProfileConfig.open() as config:
         del config[options.profile_name]