reprepare.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package tasks
  15. import (
  16. "context"
  17. "yunion.io/x/jsonutils"
  18. "yunion.io/x/onecloud/pkg/mcclient"
  19. "yunion.io/x/onecloud/pkg/util/ssh"
  20. )
  21. var _ IServerBaseDeployTask = new(SBaremetalReprepareTask)
  22. type SBaremetalReprepareTask struct {
  23. SBaremetalServerBaseDeployTask
  24. }
  25. func NewBaremetalReprepareTask(
  26. userCred mcclient.TokenCredential,
  27. baremetal IBaremetal,
  28. taskId string,
  29. data jsonutils.JSONObject,
  30. ) ITask {
  31. task := &SBaremetalReprepareTask{
  32. SBaremetalServerBaseDeployTask: newBaremetalServerBaseDeployTask(userCred, baremetal, taskId, data),
  33. }
  34. task.SetVirtualObject(task)
  35. task.SetStage(task.InitPXEBootTask)
  36. return task
  37. }
  38. func (self *SBaremetalReprepareTask) GetName() string {
  39. return "BaremetalReprepareTask"
  40. }
  41. func (self *SBaremetalReprepareTask) DoDeploys(ctx context.Context, term *ssh.Client) (jsonutils.JSONObject, error) {
  42. task := newBaremetalPrepareTask(self.Baremetal, self.userCred)
  43. err := task.DoPrepare(ctx, term)
  44. return nil, err
  45. }
  46. func (self *SBaremetalReprepareTask) PostDeploys(ctx context.Context, term *ssh.Client) error {
  47. self.Baremetal.AutoSyncStatus(ctx)
  48. return nil
  49. }