Merge pull request #15202 from ioito/hotfix/qx-incloudsphere-misc

fix(region): incloudshpere reset password
This commit is contained in:
Zexi Li
2022-10-18 11:20:03 +08:00
committed by GitHub
7 changed files with 75 additions and 6 deletions
+5 -1
View File
@@ -94,6 +94,10 @@ func (self *SInCloudSphereGuestDriver) GetDefaultSysDiskBackend() string {
return api.STORAGE_LOCAL
}
func (self *SInCloudSphereGuestDriver) IsNeedRestartForResetLoginInfo() bool {
return false
}
func (self *SInCloudSphereGuestDriver) IsNeedInjectPasswordByCloudInit() bool {
return true
}
@@ -116,7 +120,7 @@ func (self *SInCloudSphereGuestDriver) GetAttachDiskStatus() ([]string, error) {
}
func (self *SInCloudSphereGuestDriver) GetChangeConfigStatus(guest *models.SGuest) ([]string, error) {
return []string{api.VM_READY}, nil
return []string{api.VM_READY, api.VM_RUNNING}, nil
}
func (self *SInCloudSphereGuestDriver) GetRebuildRootStatus() ([]string, error) {
+5 -2
View File
@@ -212,8 +212,11 @@ func (self *SRegion) ResizeDisk(id string, sizeGb int) error {
return errors.Wrapf(err, "GetDisk(%s)", id)
}
body := map[string]interface{}{
"size": sizeGb,
"name": disk.Name,
"size": sizeGb,
"name": disk.Name,
"bootable": disk.Bootable,
"volumePolicy": disk.VolumePolicy,
"dataStoreType": disk.DataStoreType,
}
return self.put("/volumes/"+disk.Id, nil, jsonutils.Marshal(body), nil)
}
+5 -2
View File
@@ -228,6 +228,7 @@ func (self *SHost) CreateVM(opts *cloudprovider.SManagedVMCreateConfig) (cloudpr
if strings.HasSuffix(opts.ExternalImageId, "qcow2") {
format = "QCOW2"
}
sizeGb := float64((image.GetSizeByte() + 1024/2) / 1024 / 1024 / 1024)
disks := []Disks{}
disks = append(disks, Disks{
BusModel: "IDE",
@@ -237,7 +238,7 @@ func (self *SHost) CreateVM(opts *cloudprovider.SManagedVMCreateConfig) (cloudpr
Bootable: true,
DataStoreId: opts.SysDisk.StorageExternalId,
Format: format,
Size: float64((image.GetSizeByte() + 1024/2) / 1024 / 1024 / 1024),
Size: sizeGb,
VolumePolicy: "THIN",
VvSourceDto: VvSourceDto{
FilePath: fmt.Sprintf("%s/%s", image.Path, image.Name),
@@ -316,7 +317,9 @@ func (self *SHost) CreateVM(opts *cloudprovider.SManagedVMCreateConfig) (cloudpr
DeviceType: "NETWORK",
Model: "E1000",
Queues: 1,
IP: opts.IpAddr,
Dhcp: true,
DhcpEnabled: true,
DhcpIP: opts.IpAddr,
},
},
"panickPolicy": "NO_ACTION",
+1
View File
@@ -91,6 +91,7 @@ type SInstanceNic struct {
SystemVMType string `json:"systemVmType"`
Dhcp bool `json:"dhcp"`
DhcpIP string `json:"dhcpIp"`
DhcpEnabled bool `json:"dhcpEnabled"`
UsedDpdk bool `json:"usedDpdk"`
Queues int `json:"queues"`
}
@@ -0,0 +1,33 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shell
import (
"yunion.io/x/onecloud/pkg/multicloud/incloudsphere"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
func init() {
type VersionShowOptions struct {
}
shellutils.R(&VersionShowOptions{}, "version-show", "show version", func(cli *incloudsphere.SRegion, args *VersionShowOptions) error {
version, err := cli.GetClient().GetVersion()
if err != nil {
return err
}
printObject(version)
return nil
})
}
+2 -1
View File
@@ -21,6 +21,7 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/utils"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient"
@@ -62,7 +63,7 @@ func (self *SStoragecache) GetICloudImages() ([]cloudprovider.ICloudImage, error
return nil, err
}
for j := range images {
if images[j].GetImageFormat() == "iso" {
if utils.IsInStringArray(images[j].GetImageFormat(), []string{"iso", "ova"}) {
continue
}
images[j].cache = self
+24
View File
@@ -0,0 +1,24 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package incloudsphere
type SVersion struct {
DisplayVersion string
}
func (self *SphereClient) GetVersion() (*SVersion, error) {
ret := &SVersion{}
return ret, self.get("system/version", nil, ret)
}