mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix(region): vendor update for deploy vm struct params (#19113)
This commit is contained in:
@@ -88,7 +88,7 @@ require (
|
||||
k8s.io/client-go v0.19.3
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231222093526-d35740f80896
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231227025516-4b8aef06c15e
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
|
||||
yunion.io/x/jsonutils v1.0.1-0.20230613121553-0f3b41e2ef19
|
||||
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
|
||||
|
||||
@@ -1201,8 +1201,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231222093526-d35740f80896 h1:+mqvBWP2GaX13HhZlfbqZ1xX2T9Fl1OWm4Qx7TYmqgU=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231222093526-d35740f80896/go.mod h1:aj1gR9PPb6eqqKOwvANe26CoZFY8ydmXy0fuvgKYXH0=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231227025516-4b8aef06c15e h1:MMvjpuPn5uTynnWZfX5nE2+DYpyri8SVPgVQLKMVk8c=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231227025516-4b8aef06c15e/go.mod h1:aj1gR9PPb6eqqKOwvANe26CoZFY8ydmXy0fuvgKYXH0=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
|
||||
@@ -733,7 +733,12 @@ func (drv *SManagedVirtualizedGuestDriver) RemoteDeployGuestForDeploy(ctx contex
|
||||
params := task.GetParams()
|
||||
log.Debugf("Deploy VM params %s", params.String())
|
||||
|
||||
deleteKeypair := jsonutils.QueryBoolean(params, "__delete_keypair__", false)
|
||||
opts := &cloudprovider.SInstanceDeployOptions{
|
||||
Username: desc.Account,
|
||||
PublicKey: desc.PublicKey,
|
||||
Password: desc.Password,
|
||||
}
|
||||
opts.DeleteKeypair = jsonutils.QueryBoolean(params, "__delete_keypair__", false)
|
||||
|
||||
if len(desc.UserData) > 0 {
|
||||
err := iVM.UpdateUserData(desc.UserData)
|
||||
@@ -747,15 +752,15 @@ func (drv *SManagedVirtualizedGuestDriver) RemoteDeployGuestForDeploy(ctx contex
|
||||
defer lockman.ReleaseObject(ctx, guest)
|
||||
|
||||
// 避免DeployVM函数里面执行顺序不一致导致与预期结果不符
|
||||
if deleteKeypair {
|
||||
desc.Password, desc.PublicKey = "", ""
|
||||
if opts.DeleteKeypair {
|
||||
opts.Password, opts.PublicKey = "", ""
|
||||
}
|
||||
|
||||
if len(desc.PublicKey) > 0 {
|
||||
desc.Password = ""
|
||||
opts.Password = ""
|
||||
}
|
||||
|
||||
e := iVM.DeployVM(ctx, desc.Name, desc.Account, desc.Password, desc.PublicKey, deleteKeypair, desc.Description)
|
||||
e := iVM.DeployVM(ctx, opts)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
@@ -272,11 +272,11 @@ func (self *SInstance) RebuildRoot(ctx context.Context, opts *cloudprovider.SMan
|
||||
return self.DisksInfo[0].Id, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
input := api.ServerDeployInput{}
|
||||
input.Password = password
|
||||
if len(publicKey) > 0 {
|
||||
keypairId, err := self.host.zone.region.syncKeypair(name, publicKey)
|
||||
input.Password = opts.Password
|
||||
if len(opts.PublicKey) > 0 {
|
||||
keypairId, err := self.host.zone.region.syncKeypair(self.Name, opts.PublicKey)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "syncKeypair")
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1465,7 +1465,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
|
||||
# sigs.k8s.io/yaml v1.2.0
|
||||
## explicit; go 1.12
|
||||
sigs.k8s.io/yaml
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231222093526-d35740f80896
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231227025516-4b8aef06c15e
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+10
@@ -187,6 +187,7 @@ type SManagedVMRebuildRootConfig struct {
|
||||
PublicKey string
|
||||
SysSizeGB int
|
||||
OsType string
|
||||
UserData string
|
||||
}
|
||||
|
||||
func (vmConfig *SManagedVMCreateConfig) GetConfig(config *jsonutils.JSONDict) error {
|
||||
@@ -360,3 +361,12 @@ type SInstanceUpdateOptions struct {
|
||||
NAME string
|
||||
Description string
|
||||
}
|
||||
|
||||
type SInstanceDeployOptions struct {
|
||||
Username string
|
||||
Password string
|
||||
PublicKey string
|
||||
KeypairName string
|
||||
DeleteKeypair bool
|
||||
UserData string
|
||||
}
|
||||
|
||||
+1
-1
@@ -372,7 +372,7 @@ type ICloudVM interface {
|
||||
|
||||
RebuildRoot(ctx context.Context, config *SManagedVMRebuildRootConfig) (string, error)
|
||||
|
||||
DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error
|
||||
DeployVM(ctx context.Context, opts *SInstanceDeployOptions) error
|
||||
|
||||
ChangeConfig(ctx context.Context, config *SManagedVMChangeConfig) error
|
||||
|
||||
|
||||
+16
-34
@@ -459,17 +459,8 @@ func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstan
|
||||
return self.host.zone.region.UpdateVM(self.InstanceId, input, self.OSType)
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
var keypairName string
|
||||
if len(publicKey) > 0 {
|
||||
var err error
|
||||
keypairName, err = self.host.zone.region.syncKeypair(publicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return self.host.zone.region.DeployVM(self.InstanceId, name, password, keypairName, deleteKeypair, description)
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return self.host.zone.region.DeployVM(self.InstanceId, opts)
|
||||
}
|
||||
|
||||
func (self *SInstance) RebuildRoot(ctx context.Context, desc *cloudprovider.SManagedVMRebuildRootConfig) (string, error) {
|
||||
@@ -829,50 +820,41 @@ func (self *SRegion) DeleteVM(instanceId string) error {
|
||||
// }
|
||||
}
|
||||
|
||||
func (self *SRegion) DeployVM(instanceId string, name string, password string, keypairName string, deleteKeypair bool, description string) error {
|
||||
func (self *SRegion) DeployVM(instanceId string, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
instance, err := self.GetInstance(instanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 修改密钥时直接返回
|
||||
if deleteKeypair {
|
||||
if opts.DeleteKeypair {
|
||||
err = self.DetachKeyPair(instanceId, instance.KeyPairName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(keypairName) > 0 {
|
||||
var keypairName string
|
||||
if len(opts.PublicKey) > 0 {
|
||||
var err error
|
||||
keypairName, err = self.syncKeypair(opts.PublicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = self.AttachKeypair(instanceId, keypairName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
params := make(map[string]string)
|
||||
|
||||
// if resetPassword {
|
||||
// params["Password"] = seclib2.RandomPassword2(12)
|
||||
// }
|
||||
// 指定密码的情况下,使用指定的密码
|
||||
if len(password) > 0 {
|
||||
params["Password"] = password
|
||||
}
|
||||
|
||||
if len(name) > 0 && instance.InstanceName != name {
|
||||
params["InstanceName"] = name
|
||||
}
|
||||
|
||||
if len(description) > 0 && instance.Description != description {
|
||||
params["Description"] = description
|
||||
}
|
||||
|
||||
if len(params) > 0 {
|
||||
if len(opts.Password) > 0 {
|
||||
params := make(map[string]string)
|
||||
params["Password"] = opts.Password
|
||||
return self.modifyInstanceAttribute(instanceId, params)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
|
||||
+16
-34
@@ -442,17 +442,8 @@ func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstan
|
||||
return self.host.zone.region.UpdateVM(self.InstanceId, input)
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
var keypairName string
|
||||
if len(publicKey) > 0 {
|
||||
var err error
|
||||
keypairName, err = self.host.zone.region.syncKeypair(publicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return self.host.zone.region.DeployVM(self.InstanceId, name, password, keypairName, deleteKeypair, description)
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return self.host.zone.region.DeployVM(self.InstanceId, opts)
|
||||
}
|
||||
|
||||
func (self *SInstance) RebuildRoot(ctx context.Context, desc *cloudprovider.SManagedVMRebuildRootConfig) (string, error) {
|
||||
@@ -717,50 +708,41 @@ func (self *SRegion) DeleteVM(instanceId string) error {
|
||||
// }
|
||||
}
|
||||
|
||||
func (self *SRegion) DeployVM(instanceId string, name string, password string, keypairName string, deleteKeypair bool, description string) error {
|
||||
func (self *SRegion) DeployVM(instanceId string, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
instance, err := self.GetInstance(instanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 修改密钥时直接返回
|
||||
if deleteKeypair {
|
||||
if opts.DeleteKeypair {
|
||||
err = self.DetachKeyPair(instanceId, instance.KeyPairName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(keypairName) > 0 {
|
||||
var keypairName string
|
||||
if len(opts.PublicKey) > 0 {
|
||||
var err error
|
||||
keypairName, err = self.syncKeypair(opts.PublicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = self.AttachKeypair(instanceId, keypairName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
params := make(map[string]string)
|
||||
|
||||
// if resetPassword {
|
||||
// params["Password"] = seclib2.RandomPassword2(12)
|
||||
// }
|
||||
// 指定密码的情况下,使用指定的密码
|
||||
if len(password) > 0 {
|
||||
params["Password"] = password
|
||||
}
|
||||
|
||||
if len(name) > 0 && instance.InstanceName != name {
|
||||
params["InstanceName"] = name
|
||||
}
|
||||
|
||||
if len(description) > 0 && instance.Description != description {
|
||||
params["Description"] = description
|
||||
}
|
||||
|
||||
if len(params) > 0 {
|
||||
if len(opts.Password) > 0 {
|
||||
params := make(map[string]string)
|
||||
params["Password"] = opts.Password
|
||||
return self.modifyInstanceAttribute(instanceId, params)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
|
||||
+2
-19
@@ -609,25 +609,8 @@ func (self *SInstance) RebuildRoot(ctx context.Context, desc *cloudprovider.SMan
|
||||
return diskId, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, desc string) error {
|
||||
del := map[string]string{}
|
||||
if name != self.GetName() {
|
||||
del["Name"] = self.GetName()
|
||||
}
|
||||
if desc != self.GetDescription() {
|
||||
del["Desription"] = self.GetDescription()
|
||||
}
|
||||
if len(del) > 0 {
|
||||
self.host.zone.region.DeleteTags(self.InstanceId, del)
|
||||
}
|
||||
add := map[string]string{}
|
||||
if len(name) > 0 {
|
||||
add["Name"] = name
|
||||
}
|
||||
if len(desc) > 0 {
|
||||
add["Description"] = desc
|
||||
}
|
||||
return self.host.zone.region.CreateTags(self.InstanceId, add)
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SInstance) ChangeConfig(ctx context.Context, config *cloudprovider.SManagedVMChangeConfig) error {
|
||||
|
||||
+9
-9
@@ -499,15 +499,15 @@ func (region *SRegion) ChangeVMConfig(ctx context.Context, instanceId string, nc
|
||||
return instacen.ChangeConfig(ctx, &cloudprovider.SManagedVMChangeConfig{Cpu: ncpu, MemoryMB: vmem})
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
if len(publicKey) > 0 || len(password) > 0 {
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
if len(opts.PublicKey) > 0 || len(opts.Password) > 0 {
|
||||
// 先判断系统是否安装了vmAgent,然后等待扩展准备完成后再重置密码
|
||||
err := self.WaitEnableVMAccessReady()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return self.host.zone.region.DeployVM(ctx, self.ID, string(self.GetOsType()), name, password, publicKey, deleteKeypair, description)
|
||||
return self.host.zone.region.DeployVM(ctx, self.ID, string(self.GetOsType()), opts)
|
||||
}
|
||||
|
||||
type VirtualMachineExtensionProperties struct {
|
||||
@@ -655,19 +655,19 @@ func (region *SRegion) resetPassword(osType, instanceId, username, password stri
|
||||
return region.resetLoginInfo(osType, instanceId, setting)
|
||||
}
|
||||
|
||||
func (region *SRegion) DeployVM(ctx context.Context, instanceId, osType, name, password, publicKey string, deleteKeypair bool, description string) error {
|
||||
func (region *SRegion) DeployVM(ctx context.Context, instanceId, osType string, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
instance, err := region.GetInstance(instanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if deleteKeypair {
|
||||
if opts.DeleteKeypair {
|
||||
return nil
|
||||
}
|
||||
if len(publicKey) > 0 {
|
||||
return region.resetPublicKey(osType, instanceId, instance.Properties.OsProfile.AdminUsername, publicKey)
|
||||
if len(opts.PublicKey) > 0 {
|
||||
return region.resetPublicKey(osType, instanceId, instance.Properties.OsProfile.AdminUsername, opts.PublicKey)
|
||||
}
|
||||
if len(password) > 0 {
|
||||
return region.resetPassword(osType, instanceId, instance.Properties.OsProfile.AdminUsername, password)
|
||||
if len(opts.Password) > 0 {
|
||||
return region.resetPassword(osType, instanceId, instance.Properties.OsProfile.AdminUsername, opts.Password)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+2
-2
@@ -168,9 +168,9 @@ func (self *SInstance) ChangeConfig(ctx context.Context, config *cloudprovider.S
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
attrs := make(map[string]string)
|
||||
if password != "" {
|
||||
if opts.Password != "" {
|
||||
attrs["InstanceAction"] = "ResetPassword"
|
||||
}
|
||||
return self.node.cluster.region.modifyInstanceAttribute(self.InstancesSet.InstanceId, attrs)
|
||||
|
||||
+6
-6
@@ -439,18 +439,18 @@ func (self *SRegion) DetachKeypair(vmId, keyName string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
if len(password) > 0 {
|
||||
return self.host.zone.region.ResetVMPassword(self.GetId(), password)
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
if len(opts.Password) > 0 {
|
||||
return self.host.zone.region.ResetVMPassword(self.GetId(), opts.Password)
|
||||
}
|
||||
if len(publicKey) > 0 {
|
||||
keypair, err := self.host.zone.region.syncKeypair(publicKey)
|
||||
if len(opts.PublicKey) > 0 {
|
||||
keypair, err := self.host.zone.region.syncKeypair(opts.Password)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "syncKeypair")
|
||||
}
|
||||
return self.host.zone.region.AttachKeypair(self.InstanceId, keypair.KeyPairName)
|
||||
}
|
||||
if deleteKeypair && len(self.KeypairName) > 0 {
|
||||
if opts.DeleteKeypair && len(self.KeypairName) > 0 {
|
||||
return self.host.zone.region.DetachKeypair(self.InstanceId, self.KeypairName)
|
||||
}
|
||||
return nil
|
||||
|
||||
+1
-1
@@ -334,7 +334,7 @@ func (self *SInstance) RebuildRoot(ctx context.Context, config *cloudprovider.SM
|
||||
return "", cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -273,7 +273,7 @@ func (svm *SVirtualMachine) GetInstanceType() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (svm *SVirtualMachine) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
func (svm *SVirtualMachine) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
||||
+16
-11
@@ -408,26 +408,31 @@ func (instance *SInstance) UpdateUserData(userData string) error {
|
||||
return instance.host.zone.region.SetMetadata(instance.SelfLink, instance.Metadata)
|
||||
}
|
||||
|
||||
func (instance *SInstance) RebuildRoot(ctx context.Context, desc *cloudprovider.SManagedVMRebuildRootConfig) (string, error) {
|
||||
diskId, err := instance.host.zone.region.RebuildRoot(instance.Id, desc.ImageId, desc.SysSizeGB)
|
||||
func (instance *SInstance) RebuildRoot(ctx context.Context, opts *cloudprovider.SManagedVMRebuildRootConfig) (string, error) {
|
||||
diskId, err := instance.host.zone.region.RebuildRoot(instance.Id, opts.ImageId, opts.SysSizeGB)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "region.RebuildRoot")
|
||||
}
|
||||
return diskId, instance.DeployVM(ctx, "", desc.Account, desc.Password, desc.PublicKey, false, "")
|
||||
deployOpts := &cloudprovider.SInstanceDeployOptions{
|
||||
Username: opts.Account,
|
||||
Password: opts.Password,
|
||||
PublicKey: opts.PublicKey,
|
||||
}
|
||||
return diskId, instance.DeployVM(ctx, deployOpts)
|
||||
}
|
||||
|
||||
func (instance *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
func (instance *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
conf := cloudinit.SCloudConfig{
|
||||
SshPwauth: cloudinit.SSH_PASSWORD_AUTH_ON,
|
||||
}
|
||||
user := cloudinit.NewUser(username)
|
||||
if len(password) > 0 {
|
||||
user.Password(password)
|
||||
user := cloudinit.NewUser(opts.Username)
|
||||
if len(opts.Password) > 0 {
|
||||
user.Password(opts.Password)
|
||||
}
|
||||
if len(publicKey) > 0 {
|
||||
user.SshKey(publicKey)
|
||||
if len(opts.PublicKey) > 0 {
|
||||
user.SshKey(opts.PublicKey)
|
||||
}
|
||||
if len(password) > 0 || len(publicKey) > 0 {
|
||||
if len(opts.Password) > 0 || len(opts.PublicKey) > 0 {
|
||||
conf.MergeUser(user)
|
||||
items := []SMetadataItem{}
|
||||
instance.Refresh()
|
||||
@@ -441,7 +446,7 @@ func (instance *SInstance) DeployVM(ctx context.Context, name string, username s
|
||||
instance.Metadata.Items = items
|
||||
return instance.host.zone.region.SetMetadata(instance.SelfLink, instance.Metadata)
|
||||
}
|
||||
if deleteKeypair {
|
||||
if opts.DeleteKeypair {
|
||||
items := []SMetadataItem{}
|
||||
items = append(items, SMetadataItem{Key: METADATA_STARTUP_SCRIPT, Value: cloudinit.CLOUD_SHELL_HEADER + "\nrm -rf /root/.ssh/authorized_keys"})
|
||||
instance.Refresh()
|
||||
|
||||
+5
-24
@@ -688,8 +688,8 @@ func (self *SInstance) RebuildRoot(ctx context.Context, desc *cloudprovider.SMan
|
||||
return idisks[0].GetId(), nil
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
return self.host.zone.region.DeployVM(self.GetId(), name, password, publicKey, deleteKeypair, description)
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return self.host.zone.region.DeployVM(self.GetId(), opts)
|
||||
}
|
||||
|
||||
func (self *SInstance) ChangeConfig(ctx context.Context, config *cloudprovider.SManagedVMChangeConfig) error {
|
||||
@@ -1215,30 +1215,11 @@ func (self *SRegion) ChangeRoot(ctx context.Context, userId, instanceId, imageId
|
||||
// https://support.huaweicloud.com/api-ecs/zh-cn_topic_0110109377.html
|
||||
// 一键式重置密码 需要安装安装一键式重置密码插件 https://support.huaweicloud.com/usermanual-ecs/zh-cn_topic_0068095385.html
|
||||
// 目前不支持直接重置密钥
|
||||
func (self *SRegion) DeployVM(instanceId string, name string, password string, keypairName string, deleteKeypair bool, description string) error {
|
||||
serverObj := jsonutils.NewDict()
|
||||
if len(name) > 0 {
|
||||
serverObj.Add(jsonutils.NewString(name), "name")
|
||||
}
|
||||
|
||||
// if len(description) > 0 {
|
||||
// serverObj.Add(jsonutils.NewString(description), "description")
|
||||
// }
|
||||
|
||||
if serverObj.Size() > 0 {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(serverObj, "server")
|
||||
// 这里华为返回的image字段是字符串。和SInstance的定义的image是字典结构不一致。
|
||||
err := DoUpdate(self.ecsClient.NovaServers.Update, instanceId, params, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(password) > 0 {
|
||||
func (self *SRegion) DeployVM(instanceId string, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
if len(opts.Password) > 0 {
|
||||
params := jsonutils.NewDict()
|
||||
passwdObj := jsonutils.NewDict()
|
||||
passwdObj.Add(jsonutils.NewString(password), "new_password")
|
||||
passwdObj.Add(jsonutils.NewString(opts.Password), "new_password")
|
||||
params.Add(passwdObj, "reset-password")
|
||||
|
||||
err := DoUpdateWithSpec(self.ecsClient.NovaServers.UpdateInContextWithSpec, instanceId, "os-reset-password", params)
|
||||
|
||||
+5
-18
@@ -622,11 +622,8 @@ func (self *SInstance) RebuildRoot(ctx context.Context, opts *cloudprovider.SMan
|
||||
return idisks[0].GetId(), nil
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
if self.GetName() == name {
|
||||
name = ""
|
||||
}
|
||||
return self.host.zone.region.DeployVM(self.GetId(), name, password, publicKey, deleteKeypair, description)
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return self.host.zone.region.DeployVM(self.GetId(), opts)
|
||||
}
|
||||
|
||||
func (self *SInstance) ChangeConfig(ctx context.Context, config *cloudprovider.SManagedVMChangeConfig) error {
|
||||
@@ -943,19 +940,9 @@ func (self *SRegion) BatchResetServersPassword(instanceId string, password strin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRegion) DeployVM(instanceId string, name string, password string, keypairName string, deleteKeypair bool, description string) error {
|
||||
if len(name) > 0 {
|
||||
err := self.UpdateVM(instanceId, cloudprovider.SInstanceUpdateOptions{
|
||||
NAME: name,
|
||||
Description: description,
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "update vm name")
|
||||
}
|
||||
}
|
||||
|
||||
if len(password) > 0 {
|
||||
err := self.BatchResetServersPassword(instanceId, password)
|
||||
func (self *SRegion) DeployVM(instanceId string, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
if len(opts.Password) > 0 {
|
||||
err := self.BatchResetServersPassword(instanceId, opts.Password)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "BatchResetServersPassword")
|
||||
}
|
||||
|
||||
+1
-1
@@ -337,7 +337,7 @@ func (self *SInstance) RebuildRoot(ctx context.Context, config *cloudprovider.SM
|
||||
return "", cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -200,7 +200,7 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return self.host.zone.region.DeleteVM(self.UUID)
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -611,8 +611,8 @@ func (instance *SInstance) GetVNCInfo(input *cloudprovider.ServerVncInput) (*clo
|
||||
return instance.host.zone.region.GetInstanceVNC(instance.Id, origin)
|
||||
}
|
||||
|
||||
func (instance *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
return instance.host.zone.region.DeployVM(instance.Id, name, password, publicKey, deleteKeypair, description)
|
||||
func (instance *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return instance.host.zone.region.DeployVM(instance.Id, opts)
|
||||
}
|
||||
|
||||
func (instance *SInstance) RebuildRoot(ctx context.Context, desc *cloudprovider.SManagedVMRebuildRootConfig) (string, error) {
|
||||
@@ -699,11 +699,11 @@ func (region *SRegion) DeleteVM(instanceId string) error {
|
||||
return region.doDeleteVM(instanceId)
|
||||
}
|
||||
|
||||
func (region *SRegion) DeployVM(instanceId string, name string, password string, keypairName string, deleteKeypair bool, description string) error {
|
||||
if len(password) > 0 {
|
||||
func (region *SRegion) DeployVM(instanceId string, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
if len(opts.Password) > 0 {
|
||||
params := map[string]map[string]string{
|
||||
"changePassword": {
|
||||
"adminPass": password,
|
||||
"adminPass": opts.Password,
|
||||
},
|
||||
}
|
||||
resource := fmt.Sprintf("/servers/%s/action", instanceId)
|
||||
|
||||
+1
-1
@@ -324,7 +324,7 @@ func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstan
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -245,8 +245,8 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return self.host.zone.region.DeleteVM(self.VmID)
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
return self.host.zone.region.ResetVmPassword(self.VmID, username, password)
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return self.host.zone.region.ResetVmPassword(self.VmID, opts.Username, opts.Password)
|
||||
}
|
||||
|
||||
func (self *SInstance) DetachDisk(ctx context.Context, diskId string) error {
|
||||
|
||||
+11
-28
@@ -457,17 +457,8 @@ func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstan
|
||||
return self.host.zone.region.UpdateVM(self.InstanceId, input.NAME)
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
var keypairName string
|
||||
if len(publicKey) > 0 {
|
||||
var err error
|
||||
keypairName, err = self.host.zone.region.syncKeypair(publicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return self.host.zone.region.DeployVM(self.InstanceId, name, password, keypairName, deleteKeypair, description)
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return self.host.zone.region.DeployVM(self.InstanceId, opts)
|
||||
}
|
||||
|
||||
func (self *SInstance) RebuildRoot(ctx context.Context, desc *cloudprovider.SManagedVMRebuildRootConfig) (string, error) {
|
||||
@@ -761,14 +752,14 @@ func (self *SRegion) DeleteVM(instanceId string) error {
|
||||
return self.doDeleteVM(instanceId)
|
||||
}
|
||||
|
||||
func (self *SRegion) DeployVM(instanceId string, name string, password string, keypairName string, deleteKeypair bool, description string) error {
|
||||
func (self *SRegion) DeployVM(instanceId string, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
instance, err := self.GetInstance(instanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 修改密钥时直接返回
|
||||
if deleteKeypair {
|
||||
if opts.DeleteKeypair {
|
||||
for i := 0; i < len(instance.LoginSettings.KeyIds); i++ {
|
||||
err = self.DetachKeyPair(instanceId, instance.LoginSettings.KeyIds[i])
|
||||
if err != nil {
|
||||
@@ -777,27 +768,19 @@ func (self *SRegion) DeployVM(instanceId string, name string, password string, k
|
||||
}
|
||||
}
|
||||
|
||||
if len(keypairName) > 0 {
|
||||
if len(opts.PublicKey) > 0 {
|
||||
keypairName, err := self.syncKeypair(opts.PublicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = self.AttachKeypair(instanceId, keypairName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
params := make(map[string]string)
|
||||
|
||||
if len(name) > 0 && instance.InstanceName != name {
|
||||
params["InstanceName"] = name
|
||||
}
|
||||
|
||||
if len(params) > 0 {
|
||||
err := self.modifyInstanceAttribute(instanceId, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(password) > 0 {
|
||||
return self.instanceOperation(instanceId, "ResetInstancesPassword", map[string]string{"Password": password}, true)
|
||||
if len(opts.Password) > 0 {
|
||||
return self.instanceOperation(instanceId, "ResetInstancesPassword", map[string]string{"Password": opts.Password}, true)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ func (self *SInstance) RebuildRoot(ctx context.Context, config *cloudprovider.SM
|
||||
return "", cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -505,12 +505,12 @@ func (self *SInstance) RebuildRoot(ctx context.Context, desc *cloudprovider.SMan
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
if len(publicKey) > 0 {
|
||||
func (self *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
if len(opts.PublicKey) > 0 {
|
||||
return fmt.Errorf("DeployVM not support assign ssh keypair")
|
||||
}
|
||||
|
||||
if deleteKeypair {
|
||||
if opts.DeleteKeypair {
|
||||
return fmt.Errorf("DeployVM not support delete ssh keypair")
|
||||
}
|
||||
|
||||
@@ -518,8 +518,8 @@ func (self *SInstance) DeployVM(ctx context.Context, name string, username strin
|
||||
return fmt.Errorf("DeployVM instance status %s , expected %s.", self.GetStatus(), api.VM_READY)
|
||||
}
|
||||
|
||||
if len(password) > 0 {
|
||||
err := self.host.zone.region.ResetVMPasswd(self.GetId(), password)
|
||||
if len(opts.Password) > 0 {
|
||||
err := self.host.zone.region.ResetVMPasswd(self.GetId(), opts.Password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+13
-29
@@ -439,17 +439,8 @@ func (instance *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SIn
|
||||
return instance.host.zone.region.UpdateVM(instance.InstanceId, input.NAME, input.Description)
|
||||
}
|
||||
|
||||
func (instance *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
var keypairName string
|
||||
if len(publicKey) > 0 {
|
||||
var err error
|
||||
keypairName, err = instance.host.zone.region.syncKeypair(publicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return instance.host.zone.region.DeployVM(instance.InstanceId, name, password, keypairName, deleteKeypair, description)
|
||||
func (instance *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
return instance.host.zone.region.DeployVM(instance.InstanceId, opts)
|
||||
}
|
||||
|
||||
func (instance *SInstance) AttachDisk(ctx context.Context, diskId string) error {
|
||||
@@ -646,43 +637,36 @@ func (region *SRegion) UpdateVM(instanceId string, name, description string) err
|
||||
return region.modifyInstanceAttribute(instanceId, params)
|
||||
}
|
||||
|
||||
func (region *SRegion) DeployVM(instanceId string, name string, password string, keypairName string, deleteKeypair bool, description string) error {
|
||||
func (region *SRegion) DeployVM(instanceId string, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
instance, err := region.GetInstance(instanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if deleteKeypair {
|
||||
if opts.DeleteKeypair {
|
||||
err = region.DetachKeyPair(instanceId, instance.KeyPairName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(keypairName) > 0 {
|
||||
if len(opts.PublicKey) > 0 {
|
||||
keypairName, err := instance.host.zone.region.syncKeypair(opts.PublicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = region.AttachKeypair(instanceId, keypairName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
params := make(map[string]string)
|
||||
|
||||
if len(password) > 0 {
|
||||
params["Password"] = password
|
||||
}
|
||||
|
||||
if len(name) > 0 && instance.InstanceName != name {
|
||||
params["InstanceName"] = name
|
||||
}
|
||||
|
||||
if len(description) > 0 && instance.Description != description {
|
||||
params["Description"] = description
|
||||
}
|
||||
|
||||
if len(params) > 0 {
|
||||
if len(opts.Password) > 0 {
|
||||
params := make(map[string]string)
|
||||
params["Password"] = opts.Password
|
||||
return region.modifyInstanceAttribute(instanceId, params)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+7
-19
@@ -368,24 +368,12 @@ func (region *SRegion) UpdateVM(instanceId string, params jsonutils.JSONObject)
|
||||
return err
|
||||
}
|
||||
|
||||
func (instance *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
if instance.Name != name || instance.Description != description {
|
||||
params := map[string]interface{}{
|
||||
"updateVmInstance": map[string]string{
|
||||
"name": name,
|
||||
"description": description,
|
||||
},
|
||||
}
|
||||
err := instance.host.zone.region.UpdateVM(instance.UUID, jsonutils.Marshal(params))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(password) > 0 {
|
||||
func (instance *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SInstanceDeployOptions) error {
|
||||
if len(opts.Password) > 0 {
|
||||
params := map[string]interface{}{
|
||||
"changeVmPassword": map[string]string{
|
||||
"account": username,
|
||||
"password": password,
|
||||
"account": opts.Username,
|
||||
"password": opts.Password,
|
||||
},
|
||||
}
|
||||
err := instance.host.zone.region.UpdateVM(instance.UUID, jsonutils.Marshal(params))
|
||||
@@ -393,10 +381,10 @@ func (instance *SInstance) DeployVM(ctx context.Context, name string, username s
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(publicKey) > 0 {
|
||||
if len(opts.PublicKey) > 0 {
|
||||
params := map[string]interface{}{
|
||||
"setVmSshKey": map[string]string{
|
||||
"SshKey": publicKey,
|
||||
"SshKey": opts.PublicKey,
|
||||
},
|
||||
}
|
||||
err := instance.host.zone.region.UpdateVM(instance.UUID, jsonutils.Marshal(params))
|
||||
@@ -404,7 +392,7 @@ func (instance *SInstance) DeployVM(ctx context.Context, name string, username s
|
||||
return err
|
||||
}
|
||||
}
|
||||
if deleteKeypair {
|
||||
if opts.DeleteKeypair {
|
||||
err := instance.host.zone.region.client.delete("vm-instances", fmt.Sprintf("%s/ssh-keys", instance.UUID), "")
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+9
-24
@@ -416,10 +416,8 @@ const (
|
||||
multicastPrefix = "224.0.0.0/4"
|
||||
)
|
||||
|
||||
var privatePrefixes []IPV4Prefix
|
||||
var privateIPRanges []IPV4AddrRange
|
||||
|
||||
// var customizedPrivateIPRanges []IPV4AddrRange
|
||||
var customizedPrivateIPRanges []IPV4AddrRange
|
||||
var hostLocalIPRange IPV4AddrRange
|
||||
var linkLocalIPRange IPV4AddrRange
|
||||
var multicastIPRange IPV4AddrRange
|
||||
@@ -445,42 +443,29 @@ func initPrivateIPRanges() {
|
||||
"198.18.0.0/15",
|
||||
"192.168.0.0/16",
|
||||
}
|
||||
|
||||
privatePrefixes = make([]IPV4Prefix, 0)
|
||||
privateIPRanges = make([]IPV4AddrRange, 0)
|
||||
for _, prefix := range prefs {
|
||||
privateIPRanges = make([]IPV4AddrRange, len(prefs))
|
||||
for i, prefix := range prefs {
|
||||
prefix, err := NewIPV4Prefix(prefix)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
privatePrefixes = append(privatePrefixes, prefix)
|
||||
privateIPRanges = append(privateIPRanges, prefix.ToIPRange())
|
||||
privateIPRanges[i] = prefix.ToIPRange()
|
||||
}
|
||||
}
|
||||
|
||||
func SetPrivatePrefixes(pref []string) {
|
||||
for _, prefStr := range pref {
|
||||
find := false
|
||||
for i := range privatePrefixes {
|
||||
if privatePrefixes[i].String() == prefStr {
|
||||
find = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if find {
|
||||
continue
|
||||
}
|
||||
prefix, err := NewIPV4Prefix(prefStr)
|
||||
customizedPrivateIPRanges = make([]IPV4AddrRange, 0)
|
||||
for _, prefix := range pref {
|
||||
prefix, err := NewIPV4Prefix(prefix)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
privatePrefixes = append(privatePrefixes, prefix)
|
||||
privateIPRanges = append(privateIPRanges, prefix.ToIPRange())
|
||||
customizedPrivateIPRanges = append(customizedPrivateIPRanges, prefix.ToIPRange())
|
||||
}
|
||||
}
|
||||
|
||||
func GetPrivateIPRanges() []IPV4AddrRange {
|
||||
return privateIPRanges
|
||||
return append(privateIPRanges, customizedPrivateIPRanges...)
|
||||
}
|
||||
|
||||
func IsPrivate(addr IPV4Addr) bool {
|
||||
|
||||
Reference in New Issue
Block a user