This message was deleted.
# extensions
a
This message was deleted.
w
There isn't an official way to do what you're asking since we don't document and fully support all the props we pass to the machine-config. I think it's a reasonable ask and you may want to make a feature request. With that said I think you might have a couple options if you take a look at all the props we pass to the machine-config here https://github.com/rancher/dashboard/blob/master/shell/edit/provisioning.cattle.io.cluster/tabs/MachinePool.vue#L266-L285 I think you could make use of
machine-pools
to inspect the other pools. Or you could make use of the
pool-id
to create/maintain your own copies of the data entered and use that to set your own defaults.
g
Thank you, I’ll check that!
@wooden-engine-7388 When I click the
+
button to create a second machine pool the
data()
function gets called in my extension's
pkg/triton/machine-config/triton.vue
file and I'm stepping through the debugger inspecting
this
and
this.value
but I'm not seeing
machine-pools
nor
machinePools
. Is that where I should be looking?
Found it in
this.$attrs["machine-pools"]
Actually, that doesn't show any values set in
this.$attrs["machine-pools"][0].config
even after entering the data so I must be looking in the wrong place...
w
``this.$attrs["machine-pools"][0].config` is the right place. If you set values then create a new pool you should see the values in the previously defined pool. The object isn't reactive though so if you change values it won't be reflected in existing pools. If you need it to be reactive I think your best bet is going to be creating a global object that you can populate yourself as the config values change. You could use the pool name, id or uuid to key off of.
Just showing you were on the right track looking where you were
g
Interesting, must be an issue with my extension then. I’m probably not setting the values under
this.value
soon enough. I based it on the OpenStack example but I’ll look at the built-in DigitalOcean machine-config code. Thanks for the confirmation that I’m on the right track.
Ah, DO uses the format
v-model:value="value.monitoring"
whereas I’m using
v-model="package"
which doesn’t make it into
value
yet so that’s probably my issue. I’ll try that approach.
@wooden-engine-7388 Switching over to that method worked so thank you!
@wooden-engine-7388 One more question since you pointed out the DigitalOcean machine-config example... I see that each of the built-in machine-config implementations set
this.credential
(https://github.com/rancher/dashboard/blob/3fae34cc922776775a3effea42b10e6a4f3044f8/shell/machine-config/digitalocean.vue#L35) but it looks like DigitalOcean only uses it to set the
defaultRegion
if it's not already set. I see that DigitalOcean credentials also have an access token so I'm wondering why I'm not seeing any code in there to grab the access token from the cloud credential and set it in
this.value
such as
this.value.accessToken = this.credential.digitaloceancredentialConfig.accessToken;
...
I see that the OpenStack example also queries and sets
this.credential
(https://github.com/rancher/ui-plugin-examples/blob/main/pkg/node-driver/machine-config/openstack.vue#L73) but then also queries the secret (not sure why this is needed since you can get the data from the credential) and sets
this.password
rather than
this.value.password
and then has a comment in
syncValue()
that says
// Note: We don't need to provide password as this is picked up via the credential
(https://github.com/rancher/ui-plugin-examples/blob/main/pkg/node-driver/machine-config/openstack.vue#L197).
I'm just wondering if I need to explicitly grab stuff from the credential or secret and set it in
this.value
or whether there is some magic done behind the scenes and I don't need to...
When I don't explicitly populate the values from the credential to
this.value
it doesn't appear to work. When I create the cluster and inspect the
TritonMachineTemplate
I see
spec.template.spec
has the machine-config fields I filled out and there is
spec.template.spec.common.cloudCredentialSecretName
which references a secret that has all the data from the cloud credentials but none of them seem to get passed automatically to my custom node driver so I guess I need to explicitly set them?
@wooden-engine-7388 Any chance you can verify above?