def list_manifests(self, name): results = [] cluster_id = self.get_cluster_id(name) manifests_api = api.ManifestsApi(api_client=self.api) manifests = manifests_api.v2_list_cluster_manifests(cluster_id) for manifest in manifests: results.append({'file_name': manifest['file_name'], 'folder': manifest['folder']}) return results
def __init__(self, inventory_url: str, offline_token: Optional[str], pull_secret: str): self.inventory_url = inventory_url configs = Configuration() configs.host = self.get_host(configs) configs.verify_ssl = False self.set_config_auth(configs, offline_token) self._set_x_secret_key(configs, pull_secret) self.api = ApiClient(configuration=configs) self.client = api.InstallerApi(api_client=self.api) self.events = api.EventsApi(api_client=self.api) self.versions = api.VersionsApi(api_client=self.api) self.domains = api.ManagedDomainsApi(api_client=self.api) self.operators = api.OperatorsApi(api_client=self.api) self.manifest = api.ManifestsApi(api_client=self.api) fmt = CaseFormatKeys( case_name="cluster-event-test", static_case_name=True, severity_key="severity", case_timestamp="event_time" ) self._events_junit_exporter = JsonJunitExporter(fmt)
def upload_manifests(self, name, directory, openshift=False): cluster_id = self.get_cluster_id(name) if not os.path.exists(directory): error(f"Directory {directory} not found") sys.exit(1) elif not os.path.isdir(directory): error(f"{directory} is not a directory") sys.exit(1) manifests_api = api.ManifestsApi(api_client=self.api) _fics = os.listdir(directory) if not _fics: error(f"No files found in directory {directory}") sys.exit(0) for _fic in _fics: if not _fic.endswith('.yml') and not _fic.endswith('.yaml'): warning(f"skipping file {_fic}") continue info(f"uploading file {_fic}") content = base64.b64encode(open(f"{directory}/{_fic}").read().encode()).decode("UTF-8") folder = 'manifests' if not openshift else 'openshift' manifest_info = {'file_name': _fic, 'content': content, 'folder': folder} create_manifest_params = models.CreateManifestParams(**manifest_info) manifests_api.v2_create_cluster_manifest(cluster_id, create_manifest_params)