Example #1
0
    def __init__(self, inventory_url):
        self.inventory_url = inventory_url
        configs = Configuration()
        configs.host = self.inventory_url + "/api/assisted-install/v1"
        configs.verify_ssl = False
        self.set_config_auth(configs)

        self.api = ApiClient(configuration=configs)
        self.client = api.InstallerApi(api_client=self.api)
def get_inventory_hosts(inventory_endpoint, cluster_id, token):
    configs = Configuration()
    configs.host = inventory_endpoint
    configs.api_key["X-Secret-Key"] = token
    apiClient = ApiClient(configuration=configs)
    client = api.InstallerApi(api_client=apiClient)
    hosts_list = client.list_hosts(cluster_id=cluster_id)
    return [
        InventoryHost(host) for host in hosts_list
        if host['status'] != 'disabled'
    ]
    def __init__(self, inventory_url, offline_token, pull_secret):
        self.inventory_url = inventory_url
        configs = Configuration()
        configs.host = self.inventory_url + "/api/assisted-install/v1"
        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)
    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)
def get_inventory_hosts(inventory_endpoint,
                        cluster_id,
                        token,
                        skip_cert_verification=False,
                        ca_cert_path=None):
    configs = Configuration()
    configs.host = inventory_endpoint
    configs.api_key["X-Secret-Key"] = token
    configs.verify_ssl = not skip_cert_verification
    configs.ssl_ca_cert = ca_cert_path
    apiClient = ApiClient(configuration=configs)
    client = api.InstallerApi(api_client=apiClient)
    hosts_list = client.list_hosts(cluster_id=cluster_id)
    return [
        InventoryHost(host) for host in hosts_list
        if host['status'] != 'disabled'
    ]
    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)

        fmt = CaseFormatKeys(case_name="cluster_id", severity_key="severity", case_timestamp="event_time")
        self._events_junit_exporter = JsonJunitExporter(fmt)
 def __init__(self, url, token=None, offlinetoken=None):
     self.url = url
     self.config = Configuration()
     self.config.host = self.url + "/api/assisted-install"
     self.config.verify_ssl = False
     proxies = urllib.request.getproxies()
     if proxies:
         proxy = proxies.get('https') or proxies.get('http')
         if 'http' not in proxy:
             proxy = "http://" + proxy
             warning(f"Detected proxy env var without scheme, updating proxy to {proxy}")
         self.config.proxy = proxy
     aihome = f"{os.environ['HOME']}/.aicli"
     if not os.path.exists(aihome):
         os.mkdir(aihome)
     if url in ['https://api.openshift.com', 'https://api.stage.openshift.com']:
         if offlinetoken is None:
             if os.path.exists(f'{aihome}/offlinetoken.txt'):
                 offlinetoken = open(f'{aihome}/offlinetoken.txt').read().strip()
             else:
                 error(f"offlinetoken needs to be set to gather token for {url}")
                 error("get it at https://cloud.redhat.com/openshift/token")
                 if os.path.exists('/i_am_a_container'):
                     error("use -e AI_OFFLINETOKEN=$AI_OFFLINETOKEN to expose it in container mode")
                 sys.exit(1)
         if not os.path.exists(f'{aihome}/offlinetoken.txt'):
             with open(f'{aihome}/offlinetoken.txt', 'w') as f:
                 f.write(offlinetoken)
         self.offlinetoken = offlinetoken
         self.token = token
         if os.path.exists(f'{aihome}/token.txt'):
             self.token = open(f'{aihome}/token.txt').read().strip()
         try:
             self.token = get_token(token=self.token, offlinetoken=self.offlinetoken)
         except Exception as e:
             error(f"Hit issue when trying to set token. Got {e}")
             if os.path.exists(f'{aihome}/offlinetoken.txt'):
                 error("Removing offlinetoken file")
                 os.remove(f'{aihome}/offlinetoken.txt')
             sys.exit(1)
         self.config.api_key['Authorization'] = self.token
         self.config.api_key_prefix['Authorization'] = 'Bearer'
     self.api = ApiClient(configuration=self.config)
     self.client = api.InstallerApi(api_client=self.api)
 def refresh_token(self, token, offlinetoken):
     self.token = get_token(token=self.token, offlinetoken=self.offlinetoken)
     self.config.api_key['Authorization'] = self.token
     self.api = ApiClient(configuration=self.config)
     self.client = api.InstallerApi(api_client=self.api)