예제 #1
0
파일: convert_config.py 프로젝트: mjs/juju
def main():
    parser = ArgumentParser(
        description=dedent('''\
            Convert environments.yaml to 2.0 format.

            environments.yaml from JUJU_HOME will be used.
            Existing configs in the output directory will be overwritten.

            Does not support configs of type 'local'.
            '''))
    parser.add_argument('config_dir', metavar='OUTPUT_DIR',
                        help='Directory to write updated configs to.')
    args = parser.parse_args()
    clouds_credentials = JujuData('', {})
    clouds_credentials.load_yaml()
    for environment, config in get_environments().items():
        if config['type'] == 'local':
            continue
        env = JujuData(environment, config)
        env.clouds = clouds_credentials.clouds
        env.credentials = clouds_credentials.credentials
        print(environment)
        sys.stdout.flush()
        out_path = os.path.join(args.config_dir,
                                '{}.yaml'.format(environment))
        with open(out_path, 'w') as out_file:
            write_new_config(env, out_file)
예제 #2
0
def main():
    parser = ArgumentParser(description=dedent('''\
            Convert environments.yaml to 2.0 format.

            environments.yaml from JUJU_HOME will be used.
            Existing configs in the output directory will be overwritten.

            Does not support configs of type 'local'.
            '''))
    parser.add_argument('config_dir',
                        metavar='OUTPUT_DIR',
                        help='Directory to write updated configs to.')
    args = parser.parse_args()
    clouds_credentials = JujuData('', {})
    clouds_credentials.load_yaml()
    for environment, config in get_environments().items():
        if config['type'] == 'local':
            continue
        env = JujuData(environment, config)
        env.clouds = clouds_credentials.clouds
        env.credentials = clouds_credentials.credentials
        print(environment)
        sys.stdout.flush()
        out_path = os.path.join(args.config_dir, '{}.yaml'.format(environment))
        with open(out_path, 'w') as out_file:
            write_new_config(env, out_file)
예제 #3
0
 def isalive(self):
     juju_data = JujuData('foo', juju_home=self.juju_home)
     juju_data.load_yaml()
     creds = juju_data.credentials.setdefault('credentials', {})
     creds.update({self.cloud: {
         'default-region': self.extra_env['OS_REGION_NAME'],
         self.extra_env['OS_USERNAME']: {
             'domain-name': '',
             'user-domain-name': '',
             'project-domain-name': '',
             'auth-type': 'userpass',
             'username': self.extra_env['OS_USERNAME'],
             'password': self.extra_env['OS_PASSWORD'],
             'tenant-name': self.extra_env['OS_TENANT_NAME'],
             }}})
     juju_data.dump_yaml(self.juju_home, {})
     return False