def client_from_args(args): """Return client from args, as generated by parse_args. If the path given is FAKE, fake_juju_client() is used. Otherwise, the client is determined based on the path and version. """ if args.juju_bin == 'FAKE': client_class = ModelClient controller_state = FakeControllerState() version = '2.0.0' backend = FakeBackend(controller_state, full_path=args.juju_bin, version=version) else: version = ModelClient.get_version(args.juju_bin) client_class = get_client_class(version) backend = None juju_home = get_juju_home() with open(args.clouds_file) as f: clouds = yaml.safe_load(f) if args.config is None: config = {} else: with open(args.config) as f: config = yaml.safe_load(f) juju_data = client_class.config_class.from_cloud_region( args.cloud, args.region, config, clouds, juju_home) return client_class(juju_data, version, args.juju_bin, debug=args.debug, soft_deadline=args.deadline, _backend=backend)
def main(): args = parse_args() juju_bin = args.juju_bin version = ModelClient.get_version(juju_bin) client_class = get_client_class(version) if client_class.config_class is not JujuData: logging.warn('This test does not support old jujus.') with open(args.example_clouds) as f: clouds = yaml.safe_load(f)['clouds'] cloug_validation = CloudValidation(version) cloud_specs = iter_clouds(clouds, cloug_validation) with temp_dir() as juju_home: env = JujuData('foo', config=None, juju_home=juju_home) client = client_class(env, version, juju_bin) succeeded, xfailed, failed = assess_all_clouds(client, cloud_specs) write_status('Succeeded', succeeded) for bug, failures in sorted(xfailed.items()): write_status('Expected fail (bug #{})'.format(bug), failures) write_status('Failed', failed) if len(failed) > 0: return 1 return 0