Baremetal: support deploy_steps for the provisioning API#2120
Baremetal: support deploy_steps for the provisioning API#2120jtopjian merged 1 commit intogophercloud:masterfrom
Conversation
891b897 to
9bd1f12
Compare
|
Build succeeded.
|
|
@dtantsur I took a stab at doing the code hunting requirement and came up with:
If this is correct, please let me know if this is ready for review. |
|
HI @jtopjian! Yeah, you're on the right track. This feature was added in https://opendev.org/openstack/ironic/commit/3138acc836c933aa179b9a92c14a226a8b903fe5, its API part starts in https://opendev.org/openstack/ironic/src/commit/6ae5bc4642c4619946a48512501b4ae37246f7ff/ironic/api/controllers/v1/node.py#L850 and progresses further ending up in the code you've found. Note that there is a related concept of deploy templates which makes code hunting somewhere more complicated. This change does not implement deploy templates, only the smaller API addition from the above mentioned commit. |
|
Tested with the following code: client.Microversion = "1.69"
updates := nodes.UpdateOpts {
nodes.UpdateOperation {
Op: nodes.AddOp,
Path: "/instance_info/image_source",
Value: "file:///httpboot/centos8.qcow2",
},
}
_, err = nodes.Update(client, "testvm1", updates).Extract()
if err != nil {
panic(fmt.Sprintf("Cannot update: %s", err))
}
files := []struct {
Path string `json:"path"`
Content string `json:"content"`
} {
{
Path: "/etc/motd",
Content: "SGVsbG8gSXJvbmljIFdvcmxkIQo=",
},
}
opts := nodes.ProvisionStateOpts {
Target: nodes.TargetActive,
DeploySteps: []nodes.DeployStep {
nodes.DeployStep {
Step: "inject_files",
Interface: "deploy",
Priority: 50,
Args: map[string]interface{}{
"files": files,
},
},
},
}
err = nodes.ChangeProvisionState(client, "testvm1", opts).ExtractErr()
if err != nil {
panic(fmt.Sprintf("Cannot provision: %s", err))
}(Note that I'm using a deploy step that has not merged yet) |
|
@dtantsur Thanks! Those links helped. Notably: which defines the data model being added in this PR. I just needed to see something that showed the fields of the It looks like the If you wanted, you could create a custom string type called type DeployStepInterface string
const (
InterfaceDeploy DeployStepInterface = "deploy"
...
)
type DeployStep struct {
Interface DeployStepInterface `json:"interface" required:"true"`
...
}
....
opts := nodes.ProvisionStateOpts {
Target: nodes.TargetActive,
DeploySteps: []nodes.DeployStep {
nodes.DeployStep {
Step: "inject_files",
Interface: nodes.InterfaceDeploy,
Priority: 50,
Args: map[string]interface{}{
"files": files,
},
},
},
}This is up to you, though. There are areas in Gophercloud that implement this and other areas that use a generic "string". If you prefer to use a |
Good call, I completely forgot that we limit the interfaces supported for deploy steps (I also forgot why we do that, but that's a different conversation). Will change. |
Deploy steps work similarly to clean steps but during deployment. For: gophercloud#2119
9bd1f12 to
04a5ac4
Compare
|
@jtopjian updated and applied the same change to clean steps. |
|
Build succeeded.
|
For: #2119