1 # ============LICENSE_START=======================================================
3 # ================================================================================
4 # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=========================================================
19 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 # -*- coding: utf-8 -*-
23 Provides profiles commands
29 from dcae_cli.util.exc import DcaeException
30 from dcae_cli.util.profiles import (get_profiles, activate_profile, get_active_name, update_profile,
31 delete_profile, create_profile)
40 @click.argument('name')
42 '''Sets profile NAME as the active profile'''
43 activate_profile(name)
46 @profiles.command(name='list')
48 '''Lists available profiles'''
49 profiles = get_profiles(include_active=False)
50 active = get_active_name()
51 names = sorted(profiles.keys())
52 outputs = ("{} {}".format(' ' if not name == active else '* ', name) for name in names)
53 click.echo('\n'.join(outputs))
57 @click.argument('name')
59 '''Prints the profile dictionary'''
60 profiles = get_profiles()
62 click.echo(json.dumps(profiles[name], sort_keys=True, indent=4))
64 raise DcaeException("Profile '{}' does not exist.".format(e))
68 @click.argument('name', type=click.STRING)
70 '''Creates a new profile NAME initialized with defaults'''
74 @profiles.command(name='set')
75 @click.argument('name')
76 @click.argument('key')
77 @click.argument('value')
78 def update(name, key, value):
79 '''Updates profile NAME such that KEY=VALUE'''
80 update_profile(name, **{key: value})
84 @click.argument('name')
86 '''Deletes profile NAME'''