-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wip/fix get harvester kubeconfig #1628
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -678,6 +678,7 @@ def delete(self, name, *, raw=False): | |
|
||
class ClusterManager(BaseManager): | ||
PATH_fmt = "v3/cluster/{uid}" | ||
PATH1_fmt = "v3/clusters/{uid}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks we didn't use this, is there any reason to add it? |
||
|
||
def create_data(self, name, k8s_version, kubeconfig): | ||
|
||
|
@@ -808,6 +809,10 @@ def create(self, name, k8s_version, kubeconfig, *, raw=False): | |
def delete(self, name, *, raw=False): | ||
return self._delete(self.PATH_fmt.format(uid=name), raw=raw) | ||
|
||
def generate_kubeconfig(self, name, *, raw=False): | ||
params = {'action': 'generateKubeconfig'} | ||
return self._create(f"v3/clusters/{name}", raw=raw, params=params) | ||
|
||
def explore(self, name): | ||
from .cluster_api import ClusterExploreAPI # circular dependency | ||
return ClusterExploreAPI(self.api.endpoint, self.api.session, name) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ def __init__(self): | |
|
||
def _storage_net_configured(self): | ||
code, data = self.settings.get('storage-network') | ||
if (cs := data.get('status', {}).get('conditions')): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The assignment expressions ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not supported in Python 3.6. We maintain a Python 3.6 environment in our tox config. Either we drop that as well, or we stick to Python 3.6 compatibility. |
||
|
||
cs = data.get('status', {}).get('conditions') | ||
if cs: | ||
if 'True' == cs[-1].get('status') and 'Completed' == cs[-1].get('reason'): | ||
return True, (code, data) | ||
return False, (code, data) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,7 +130,14 @@ def harvester_mgmt_cluster(api_client, rancher_api_client, unique_name, polling_ | |
@pytest.fixture(scope='module') | ||
def harvester_cloud_credential(api_client, rancher_api_client, | ||
harvester_mgmt_cluster, unique_name): | ||
harvester_kubeconfig = api_client.generate_kubeconfig() | ||
code, data = rancher_api_client.clusters.generate_kubeconfig( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the two configurations are same, could you check with @albinsun about the change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are not the same. One uses Rancher's API endpoint and authenticates with a Rancher token and the other one uses Harvester's API endpoint directly. |
||
harvester_mgmt_cluster['id'] | ||
) | ||
assert 200 == code, ( | ||
f"Failed to create kubconfig with error: {code}, {data}" | ||
) | ||
harvester_kubeconfig = data['config'] | ||
|
||
code, data = rancher_api_client.cloud_credentials.create( | ||
unique_name, | ||
harvester_kubeconfig, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the test output.