Compare commits

...

247 Commits

Author SHA1 Message Date
Zexi Li
af3ee4af02 Merge pull request #9114 from yousong/automated-cherry-pick-of-#9109-upstream-release-3.2
Automated cherry pick of #9109: fix(host): make sure it won't match vpc guests by accident
2020-12-01 20:22:04 +08:00
Yousong Zhou
12a100f81b fix(host): make sure it won't match vpc guests by accident 2020-12-01 15:34:14 +08:00
yunion-ci-robot
e3509fcae8 Merge pull request #8529 from rainzm/automated-cherry-pick-of-#8525-upstream-release-3.2
Automated cherry pick of #8525: fix(esxi): no callback in uploadHandler
2020-10-28 00:58:40 +08:00
yunion-ci-robot
3cf538db43 Merge pull request #8516 from ioito/automated-cherry-pick-of-#8512-upstream-release-3.2
Automated cherry pick of #8512: fix: avoid sync project panic
2020-10-28 00:46:43 +08:00
rainzm
262d4d650b fix(esxi): filter vmdk item in lease.info 2020-10-27 21:34:58 +08:00
rainzm
fabcc221a9 fix(esxi): use correct device index
1. Sort devices via their Key.
2. There is no relationship between vdisk index and vnics length.
2020-10-27 21:34:58 +08:00
rainzm
a4c781b4d5 fix(esxi): no callback in uploadHandler 2020-10-27 21:34:58 +08:00
Qu Xuan
6256b3f88d fix: avoid sync project panic 2020-10-27 16:14:39 +08:00
yunion-ci-robot
4bd45eef3e Merge pull request #8503 from yousong/automated-cherry-pick-of-#8499-upstream-release-3.2
Automated cherry pick of #8499: lockman: test: add prefix setting
2020-10-26 21:24:42 +08:00
Yousong Zhou
21a0cad5e9 lockman: test: add prefix setting 2020-10-26 20:37:13 +08:00
yunion-ci-robot
311f4cd079 Merge pull request #8491 from ioito/automated-cherry-pick-of-#8487-upstream-release-3.2
Automated cherry pick of #8487: fix: avoid delete public ip when sync eip list
2020-10-26 17:02:41 +08:00
Qu Xuan
de817bd4a7 fix: avoid delete public ip when sync eip list 2020-10-26 16:19:49 +08:00
Zexi Li
fb5276aee4 Merge pull request #8376 from ioito/automated-cherry-pick-of-#8373-upstream-release-3.2
Automated cherry pick of #8373: fix: 新增google存储类型
2020-10-19 15:11:25 +08:00
Zexi Li
f8d689ba87 Merge pull request #8372 from ioito/automated-cherry-pick-of-#8369-upstream-release-3.2
Automated cherry pick of #8369: fix: use correct worker
2020-10-19 15:10:25 +08:00
Qu Xuan
698d13f3ef fix: 新增google存储类型 2020-10-19 14:23:52 +08:00
Qu Xuan
8943a16570 fix: use correct worker 2020-10-19 11:43:15 +08:00
yunion-ci-robot
82a3e65bc4 Merge pull request #8317 from rainzm/automated-cherry-pick-of-#8314-upstream-release-3.2
Automated cherry pick of #8314: feat(esxi): do not specify portkey in NewVNIC
2020-10-16 10:40:35 +08:00
rainzm
b272de37ec feat(esxi): do not specify portkey in NewVNIC 2020-10-16 08:25:09 +08:00
yunion-ci-robot
0447b4ade0 Merge pull request #8311 from ioito/automated-cherry-pick-of-#8308-upstream-release-3.2
Automated cherry pick of #8308: fix: 避免并发同步安全组导致规则混乱
2020-10-15 23:01:35 +08:00
Qu Xuan
64973bf486 fix: 避免并发同步安全组导致规则混乱 2020-10-15 22:27:49 +08:00
yunion-ci-robot
f335e270cf Merge pull request #8245 from zexi/automated-cherry-pick-of-#8242-upstream-release-3.2
Automated cherry pick of #8242: baremetal: fix pxe filter network by guest_dhcp
2020-10-13 10:30:29 +08:00
Zexi Li
5ba53e43b3 Merge pull request #8261 from rainzm/automated-cherry-pick-of-#8232-upstream-release-3.2
Automated cherry pick of #8232: fix(esxi): search template from whole vCenter
2020-10-13 10:06:49 +08:00
rainzm
d80f15af58 fix(esxi): use system disk of template only when cloning vm
1. Create a driver if necessary.
2. After cloning the virtual machine, remove all data disks.
3. Create new data disks.
2020-10-12 17:50:30 +08:00
rainzm
1fe71b8392 fix(esxi): search template from whole vCenter 2020-10-12 17:50:30 +08:00
Zexi Li
1e2e134ad0 baremetal: fix pxe filter network by guest_dhcp 2020-10-12 11:38:05 +08:00
yunion-ci-robot
d456364746 Merge pull request #8197 from rainzm/automated-cherry-pick-of-#8194-upstream-release-3.2
Automated cherry pick of #8194: fix(esxi): check nil value when NewVirtualMachine
2020-10-10 19:06:18 +08:00
yunion-ci-robot
1d82b2fe90 Merge pull request #8215 from tb365/automated-cherry-pick-of-#8214-upstream-release-3.2
Automated cherry pick of #8214: remove aws lbbg cache metedata
2020-10-10 18:55:20 +08:00
yunion-ci-robot
eb3d66750b Merge pull request #8221 from yousong/automated-cherry-pick-of-#8218-upstream-release-3.2
Automated cherry pick of #8218: webconsole: ssh: each argument on its own line
2020-10-10 15:34:49 +08:00
Yousong Zhou
88b752b35c webconsole: ssh: add keyboard-interactive as an option
For ESXi 6.0

  Authentications that can continue: publickey,keyboard-interactive
2020-10-10 14:44:26 +08:00
Yousong Zhou
225067eb88 webconsole: ssh: each argument on its own line 2020-10-10 14:44:26 +08:00
TangBin
d55429d4cd remove aws lbbg cache metedata 2020-10-10 14:27:25 +08:00
yunion-ci-robot
c3ec288464 Merge pull request #8186 from yousong/automated-cherry-pick-of-#8183-upstream-release-3.2
Automated cherry pick of #8183: vpcagent: ovn: increase dhcp lease, renew, rebind time
2020-10-10 11:56:12 +08:00
rainzm
af03b18155 fix(esxi): check nil value when NewVirtualMachine 2020-10-10 11:36:44 +08:00
Yousong Zhou
d40d6a6a74 vpcagent: ovn: increase dhcp lease, renew, rebind time 2020-10-09 10:26:59 +08:00
yunion-ci-robot
dd8629e9aa Merge pull request #8160 from tb365/automated-cherry-pick-of-#8159-upstream-release-3.2
Automated cherry pick of #8159: aliyun public elb region fix
2020-09-29 23:28:41 +08:00
TangBin
6d2f1d25c1 aliyun public elb region fix 2020-09-29 22:04:50 +08:00
yunion-ci-robot
1e95a83db0 Merge pull request #8155 from tb365/automated-cherry-pick-of-#8154-upstream-release-3.2
Automated cherry pick of #8154: aliyun public elb brand fix
2020-09-29 18:18:34 +08:00
TangBin
1e7776ba71 aliyun public elb brand fix 2020-09-29 16:47:25 +08:00
yunion-ci-robot
d4900cc6ac Merge pull request #8062 from ioito/automated-cherry-pick-of-#8059-upstream-release-3.2
Automated cherry pick of #8059: fix: avoid serial vm creation
2020-09-29 10:33:34 +08:00
Zexi Li
732120c796 Merge pull request #8130 from tb365/automated-cherry-pick-of-#8129-upstream-release-3.2
Automated cherry pick of #8129: aliyun create public lb fix
2020-09-28 16:24:23 +08:00
TangBin
70d22e6428 aliyun create public lb fix 2020-09-28 14:19:48 +08:00
yunion-ci-robot
62dfa77b87 Merge pull request #8119 from wanyaoqi/automated-cherry-pick-of-#8116-upstream-release-3.2
Automated cherry pick of #8116: umount nfs on detach storage
2020-09-27 21:03:36 +08:00
wanyaoqi
788e1bb225 increase rbd check timeout 2020-09-27 20:22:10 +08:00
wanyaoqi
02f7c5ac35 umount nfs on detach storage 2020-09-27 20:22:10 +08:00
Zexi Li
a675971d90 Merge pull request #8113 from tb365/automated-cherry-pick-of-#8087-upstream-release-3.2
Automated cherry pick of #8087: huawei snapshot delete fix
2020-09-27 17:29:49 +08:00
TangBin
38be1b0908 huawei util missing import fix 2020-09-27 15:14:37 +08:00
TangBin
e3242abf15 huawei client request add throttling control 2020-09-27 15:13:16 +08:00
TangBin
0171bf71d3 huawei elb get params log 2020-09-27 15:13:16 +08:00
TangBin
70170836fb qcloud elb create listener fix 2020-09-27 15:13:16 +08:00
TangBin
ec7707d397 huawei snapshot delete fix 2020-09-27 15:13:16 +08:00
Zexi Li
6e61174307 Merge pull request #8091 from wanyaoqi/automated-cherry-pick-of-#8088-upstream-release-3.2
Automated cherry pick of #8088: set stagefail on clean fail
2020-09-27 14:46:10 +08:00
wanyaoqi
0d96419b64 set stagefail on clean fail 2020-09-27 11:47:07 +08:00
Zexi Li
a7644951fe Merge pull request #8098 from ioito/automated-cherry-pick-of-#8095-upstream-release-3.2
Automated cherry pick of #8095: fix: avoid purge storages
2020-09-25 20:54:51 +08:00
Qu Xuan
96b6b3cf6f fix: avoid purge storages 2020-09-25 19:18:04 +08:00
Zexi Li
3cc7557964 Merge pull request #8074 from ioito/automated-cherry-pick-of-#8071-upstream-release-3.2
Automated cherry pick of #8071: fix: sql err
2020-09-24 21:19:38 +08:00
ioito
c433050318 fix: sql err 2020-09-24 20:23:33 +08:00
ioito
1505dc6e04 fix: avoid serial vm creation 2020-09-24 16:41:50 +08:00
Zexi Li
f14fbb4007 Merge pull request #8004 from tb365/automated-cherry-pick-of-#8003-upstream-release-3.2
Automated cherry pick of #8003: regional network filter bugfix
2020-09-23 21:09:14 +08:00
TangBin
396a99c4cb regional network filter bugfix 2020-09-22 20:02:33 +08:00
yunion-ci-robot
1356ae3124 Merge pull request #7995 from tb365/automated-cherry-pick-of-#7994-upstream-release-3.2
Automated cherry pick of #7994: ctyun sync secgroup fix & cloudaccount delete fix
2020-09-22 14:08:19 +08:00
TangBin
fc480ffa1a ctyun sync secgroup fix & cloudaccount delete fix 2020-09-22 13:53:20 +08:00
Zexi Li
4e7f02fa68 Merge pull request #7967 from tb365/automated-cherry-pick-of-#7966-upstream-release-3.2
Automated cherry pick of #7966: ctyun add region cn-bj1
2020-09-18 21:04:54 +08:00
TangBin
614ad609bf ctyun add region cn-bj1 2020-09-18 14:22:51 +08:00
Zexi Li
94a2645341 Merge pull request #7964 from zexi/automated-cherry-pick-of-#7961-upstream-release-3.2
Automated cherry pick of #7961: region: fix network schedtag not cleanup when network deleted
2020-09-18 12:45:07 +08:00
Zexi Li
3ad40222c2 region: fix network schedtag not cleanup when network deleted 2020-09-18 10:39:43 +08:00
Zexi Li
63e0f2ee76 Merge pull request #7958 from wanyaoqi/automated-cherry-pick-of-#7953-upstream-release-3.2
Automated cherry pick of #7953: fix set host image cache properties
2020-09-16 21:38:29 +08:00
Zexi Li
e14304a5af Merge pull request #7951 from wanyaoqi/automated-cherry-pick-of-#7948-upstream-release-3.2
Automated cherry pick of #7948: fix update image status after save failed
2020-09-16 21:35:47 +08:00
wanyaoqi
85c61ab14c fix set host image cache properties 2020-09-16 20:53:03 +08:00
wanyaoqi
f393424ca8 fix update image status after save failed 2020-09-16 19:15:05 +08:00
Zexi Li
5aebb04ce3 Merge pull request #7924 from ioito/automated-cherry-pick-of-#7921-upstream-release-3.2
Automated cherry pick of #7921: fix: bucket object cnt fix
2020-09-16 11:30:13 +08:00
Qu Xuan
0d99dc1981 fix: bucket object cnt fix 2020-09-15 19:15:32 +08:00
yunion-ci-robot
4334ccf537 Merge pull request #7908 from wanyaoqi/automated-cherry-pick-of-#7905-upstream-release-3.2
Automated cherry pick of #7905: webconsole: fix defer order to release zombie process
2020-09-15 10:26:10 +08:00
wanyaoqi
285c696e6d webconsole: fix defer order to release zombie process 2020-09-14 18:22:13 +08:00
Zexi Li
ce6e7542a5 Merge pull request #7898 from wanyaoqi/automated-cherry-pick-of-#7895-upstream-release-3.2
Automated cherry pick of #7895: disk: check disk is need renew on guest set renew
2020-09-14 13:02:17 +08:00
wanyaoqi
5ec462bc8e disk: check disk is need renew on guest set renew 2020-09-14 12:08:52 +08:00
Zexi Li
4868674fee Merge pull request #7882 from ioito/automated-cherry-pick-of-#7879-upstream-release-3.2
Automated cherry pick of #7879: fix: avoid sync natgateway eip panic
2020-09-11 21:03:57 +08:00
Zexi Li
2e560c1f04 Merge pull request #7873 from rainzm/automated-cherry-pick-of-#7870-upstream-release-3.2
Automated cherry pick of #7870: fix(esxiagent): add HostDelayTaskWorkerCount
2020-09-11 20:55:47 +08:00
Zexi Li
71b1244846 Merge pull request #7865 from wanyaoqi/automated-cherry-pick-of-#7836-upstream-release-3.2
Automated cherry pick of #7836: host: fix rbd storage cache iso image
2020-09-11 20:54:07 +08:00
Qu Xuan
545f9eebf1 fix: avoid sync natgateway eip panic 2020-09-11 19:18:15 +08:00
rainzm
e6ce176233 fix(esxiagent): add HostDelayTaskWorkerCount
之前,HostDelayWorker 是通过 hostutils.InitWorkerManager 来初始化,
worker的数量依赖于options.HostOptions.DefaultRequestWorkerCount, 因为
这个options没有经过初始化,所以就是0,导致worker count的数量变为1。

现在增加了 HostDelayTaskWorkerCount 来管理这个count,默认值为8。
2020-09-11 17:23:13 +08:00
wanyaoqi
f59d56e796 host: fix rbd storage cache iso image 2020-09-10 23:20:29 +08:00
yunion-ci-robot
37e36f5a08 Merge pull request #7848 from rainzm/automated-cherry-pick-of-#7845-upstream-release-3.2
Automated cherry pick of #7845: Feat & Fix & Refactor for ESXi
2020-09-10 09:41:57 +08:00
rainzm
05abebeea5 fix(region): add RequestSyncstatusOnHost for SESXiGuestDriver
esxi 平台 Guest 进行 syncstatus 和其他平台有所区别,Vcenter 可能会更改
 VM 所在的 Host,所以在 Host 上寻找 VM 可能会出现 ErrNotFound。此时,应该
主动去整个 datacenter 中寻找 VM,然后更改 Host,进行同步。
2020-09-09 21:58:48 +08:00
rainzm
747d70a747 fix(esxi): fetch templatevm from datacenter before clone vm
这里应该和image_cache那里保持一直,对template的获取应该从datacenter
中获取,而不是host。
2020-09-09 21:58:17 +08:00
rainzm
ebf3692ba0 refactor(esxi): replace GetTemplateVMById with FetchTemplateVMById
FetchTemplateVMById 更好,因为它更轻量,更快。
2020-09-09 21:58:16 +08:00
rainzm
7dfe68322a feat(esxicli): better vm operator
现在,可以通过Datacenter来获取vm,不一定要指定HostIp,
Datacenter和HostIp必须指定一个。
2020-09-09 21:58:16 +08:00
rainzm
59861adabc feat(esxi): support fetchVM form datacenter 2020-09-09 21:58:16 +08:00
rainzm
40b3e8e382 refactor(esxi): fetchVms and fetchHardwareInfo
1. fetchHardwareInfo 只有一种error,原因是moVM的某些字段为nil,这种情况下,完全可以打印日志直接返回。
2. fetchVms 现在只返回[]*SVirtualMachine, 进一步的过滤(是不是template)交给调用者。
2020-09-09 21:58:16 +08:00
Zexi Li
c81563b03d Merge pull request #7825 from rainzm/automated-cherry-pick-of-#7821-upstream-release-3.2
Automated cherry pick of #7821: fix(esxiagent): return image extid not id
2020-09-08 20:25:59 +08:00
rainzm
a18b34c365 fix(esxiagent): return image extid not id
调用 disk/image_cache 接口的Task StorageCacheImageTask 会根据回调
回来数据中的 image_id,来设置 storagecachedimage 中的 externalid,
所以这里的 image_id 应该是 externalid。
2020-09-08 15:34:35 +08:00
yunion-ci-robot
f64267897e Merge pull request #7801 from wanyaoqi/automated-cherry-pick-of-#7798-upstream-release-3.2
Automated cherry pick of #7798: guest short desc add backup host id
2020-09-07 21:01:51 +08:00
yunion-ci-robot
ad8d6e76b5 Merge pull request #7792 from wanyaoqi/automated-cherry-pick-of-#7789-upstream-release-3.2
Automated cherry pick of #7789: fix get ubuntu version
2020-09-07 20:59:44 +08:00
wanyaoqi
c266722c31 guest short desc add backup host id 2020-09-07 17:06:36 +08:00
wanyaoqi
4d0cb2b150 fix get ubuntu version 2020-09-07 16:01:59 +08:00
yunion-ci-robot
2171de57ee Merge pull request #7785 from rainzm/automated-cherry-pick-of-#7782-upstream-release-3.2
Automated cherry pick of #7782: fix(notify): Replace String() with GetString()
2020-09-07 15:26:42 +08:00
rainzm
021b4a1ae2 fix(notify): Replace String() with GetString()
The String() of jsonutils.JSONObject will add a pair of
double quotes around the content. The GetString() will
get a clean content.
2020-09-07 15:12:07 +08:00
yunion-ci-robot
b108fe81d2 Merge pull request #7775 from swordqiu/automated-cherry-pick-of-#7772-upstream-release-3.2
Automated cherry pick of #7772: fix: skup syncing lb, rds, redis instances in tasks
2020-09-05 15:47:42 +08:00
Qiu Jian
9f854385e5 fix: skup syncing lb, rds, redis instances in tasks 2020-09-05 14:31:06 +08:00
Zexi Li
b319be6d0a Merge pull request #7747 from wanyaoqi/automated-cherry-pick-of-#7744-upstream-release-3.2
Automated cherry pick of #7744: glance: check min disk size on update
2020-09-04 10:30:01 +08:00
wanyaoqi
fa28094906 glance: check min disk size on update 2020-09-03 20:02:17 +08:00
yunion-ci-robot
f797ec2fb9 Merge pull request #7726 from tb365/automated-cherry-pick-of-#7725-upstream-release-3.2
Automated cherry pick of #7725: create classic vpc fix
2020-09-03 10:32:41 +08:00
TangBin
5ca7179ce1 create classic vpc fix 2020-09-02 18:24:56 +08:00
wanyaoqi
c2b81cf638 hostinfo: try create network add is_on_premise (#7709) 2020-09-01 20:01:41 +08:00
wanyaoqi
ddb7981922 fix host get guests (#7685) 2020-09-01 01:08:36 +08:00
wanyaoqi
8020d70bab fix get storage capacity on init' (#7689) 2020-09-01 01:02:37 +08:00
Zexi Li
d78c549b4a Merge pull request #7625 from wanyaoqi/automated-cherry-pick-of-#7623-upstream-release-3.2
Automated cherry pick of #7623: fix gpfs check mountpoint
2020-08-25 17:41:23 +08:00
wanyaoqi
849a74c0a6 fix gpfs check mountpoint 2020-08-25 15:52:27 +08:00
屈轩
e016109d6e fix: avoid storage=nil, dis can not delete (#7610)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
2020-08-22 12:33:36 +08:00
Jian Qiu
c67aa4991d fix: opslog filter by owner_project_ids and owner_domain_ids (#7602)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
2020-08-21 10:57:23 +08:00
Jian Qiu
f71b787abb fix: dns record create ignore is_public field (#7589)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
2020-08-18 10:51:57 +08:00
Zexi Li
780dea24d1 Merge pull request #7581 from swordqiu/automated-cherry-pick-of-#7580-upstream-release-3.2
Automated cherry pick of #7580: fix: allow delete shared role and policy
2020-08-16 23:43:24 +08:00
Zexi Li
a8c65cbeed Merge pull request #7577 from rainzm/automated-cherry-pick-of-#7575-upstream-release-3.2
Automated cherry pick of #7575: fix: GetIImages correctly without 'image_cache' dir
2020-08-16 23:41:56 +08:00
Qiu Jian
b41bd4066c fix: allow delete shared role and policy 2020-08-15 21:04:48 +08:00
rainzm
c5a731daa9 fix: GetIImages correctly without 'image_cache' dir
After creating vms, there is no dir named 'image_cache' exists in
storage of esxi. So handle this case to not affecte the synchronization of the
VMware Template.
2020-08-14 20:36:58 +08:00
屈轩
3bc1381c36 fix: aovid duplicate sku name (#7574)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
2020-08-14 20:35:49 +08:00
Zexi Li
ff880efe8c Merge pull request #7571 from zexi/hotfix/jsontag-syntax-v32
fix: json TAG_PREFIX invalid syntax
2020-08-14 17:42:04 +08:00
Jian Qiu
813a8c2021 fix: init wire domain_id for local vpc (#7569)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
2020-08-14 17:29:51 +08:00
Zexi Li
4f9b8a29da fix: json TAG_PREFIX invalid syntax 2020-08-14 17:02:54 +08:00
屈轩
db7621081a fix: avoid virtual resource project id is empty when cloudaccount with no project (#7562)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
2020-08-14 10:37:49 +08:00
Jian Qiu
3032f7e26b fix: network port count stat recode (#7556)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
2020-08-14 10:33:48 +08:00
Zexi Li
44c0d0ce47 Merge pull request #7549 from wanyaoqi/automated-cherry-pick-of-#7547-upstream-release-3.2
Automated cherry pick of #7547: support diable usb kbd
2020-08-11 18:41:34 +08:00
Zexi Li
5eb4b549ba Merge pull request #7543 from ioito/automated-cherry-pick-of-#7541-upstream-release-3.2
Automated cherry pick of #7541: fix: separete enabled and status field
2020-08-11 18:39:24 +08:00
wanyaoqi
3b6662f7fa support diable usb kbd 2020-08-11 15:33:16 +08:00
Qu Xuan
551ea72afb fix: separete enabled and status field 2020-08-11 14:55:09 +08:00
Zexi Li
2c9378cc9a Merge pull request #7537 from wanyaoqi/automated-cherry-pick-of-#7530-upstream-release-3.2
Automated cherry pick of #7530: fix mount xfs
2020-08-11 11:16:39 +08:00
wanyaoqi
be3244d0b5 fix usage get storage capbility (#7529) 2020-08-10 20:07:56 +08:00
wanyaoqi
9c756c1cc9 fix mount xfs 2020-08-10 20:05:09 +08:00
屈轩
fa47f50e32 fix: optimized huawei security group get and create operation (#7522)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
2020-08-10 15:38:44 +08:00
wanyaoqi
40b3074acb set disk status on disk detached (#7519) 2020-08-10 12:05:46 +08:00
Zexi Li
035dcaa08b Merge pull request #7510 from ioito/automated-cherry-pick-of-#7508-upstream-release-3.2
Automated cherry pick of #7508: fix: avoid nil pointer
2020-08-10 10:24:58 +08:00
Qu Xuan
efd888ab45 fix: avoid nil pointer 2020-08-07 11:16:24 +08:00
Zexi Li
3dd36fbc46 Merge pull request #7500 from ioito/automated-cherry-pick-of-#7498-upstream-release-3.2
Automated cherry pick of #7498: fix: 隐藏auzre经典类型存储
2020-08-07 11:06:14 +08:00
Zexi Li
d3f1c3c202 Merge pull request #7503 from ioito/automated-cherry-pick-of-#7501-upstream-release-3.2
Automated cherry pick of #7501: fix: 提高zstack认证兼容性
2020-08-07 11:05:19 +08:00
Qu Xuan
0d301c554c fix: 提高zstack认证兼容性 2020-08-06 19:25:25 +08:00
Qu Xuan
19fc35afa5 fix: 隐藏auzre经典类型存储 2020-08-06 18:01:37 +08:00
屈轩
ed7576f2ac fix: 增加openstack兼容性 (#7494)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
2020-08-06 11:56:18 +08:00
Zexi Li
5bcc5f1e34 Merge pull request #7486 from wanyaoqi/automated-cherry-pick-of-#7484-upstream-release-3.2
Automated cherry pick of #7484: fix host info get sshkey
2020-08-04 13:51:21 +08:00
wanyaoqi
93a8856c2a fix host info get sshkey 2020-08-04 10:37:16 +08:00
Zexi Li
44dabd9af7 Merge pull request #7480 from swordqiu/automated-cherry-pick-of-#7479-upstream-release-3.2
Automated cherry pick of #7479: fix: typo running_geusts => running_guests
2020-08-03 16:58:32 +08:00
Zexi Li
67c1324feb Merge pull request #7476 from ioito/automated-cherry-pick-of-#7474-upstream-release-3.2
Automated cherry pick of #7474: fix: typo
2020-08-03 16:57:54 +08:00
Qiu Jian
9af38305d7 fix: typo running_geusts => running_guests 2020-08-03 16:32:19 +08:00
Qu Xuan
0fd6e1c460 fix: typo 2020-08-03 10:57:19 +08:00
Zexi Li
03b1be05f9 Merge pull request #7471 from swordqiu/automated-cherry-pick-of-#7470-upstream-release-3.2
Automated cherry pick of #7470: fix: ignore bucket-set-acl not implemented error
2020-08-03 09:24:54 +08:00
Qiu Jian
938264a1aa fix: ignore bucket-set-acl not implemented error 2020-08-03 02:24:47 +08:00
Zexi Li
731d86439a Merge pull request #7449 from tb365/automated-cherry-pick-of-#7447-upstream-release-3.2
Automated cherry pick of #7447: aws elb listener&rule name too long fix
2020-08-02 10:08:42 +08:00
屈轩
53bf3d7740 fix: avoid host globalid change (#7467)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
2020-08-02 03:03:03 +08:00
wanyaoqi
be18d0a34f fix reauth condition on influxdb not found (#7458) 2020-08-01 21:27:04 +08:00
wanyaoqi
9687884ac5 fix cache non lvm disks (#7461) 2020-08-01 21:14:03 +08:00
tangbin
ccb2cbce41 aws elb listener&rule name too long fix 2020-08-01 11:13:00 +08:00
Zexi Li
f232c4cd4f Merge pull request #7421 from rainzm/automated-cherry-pick-of-#7416-upstream-release-3.2
Automated cherry pick of #7416: fix(region): Don't allow address conflicts under vpc
2020-08-01 11:05:00 +08:00
Zexi Li
4661370b37 Merge pull request #7436 from tb365/automated-cherry-pick-of-#7435-upstream-release-3.2
Automated cherry pick of #7435: loadblancer listener modify name fix
2020-08-01 10:57:53 +08:00
tangbin
ee8166352a fix redis reset account password action log 2020-08-01 10:53:59 +08:00
tangbin
9f3684a1f6 loadblancer listener modify name fix 2020-08-01 10:53:34 +08:00
rainzm
2e3a4abca3 fix(region): Don't allow address conflicts under vpc
Except for default vpc, vpc and wire have a one-to-one correspondence.
So prohibiting the address conflict of wire does not avoid
the address conflict of default vpc.
2020-08-01 10:52:27 +08:00
Zexi Li
a14da344c0 Merge pull request #7439 from swordqiu/automated-cherry-pick-of-#7438-upstream-release-3.2
Automated cherry pick of #7438: fix: sync share mode between vpc and wire
2020-08-01 10:39:28 +08:00
Zexi Li
a3f71e8959 Merge pull request #7443 from wanyaoqi/automated-cherry-pick-of-#7441-upstream-release-3.2
Automated cherry pick of #7441: fix deploy admin auth key
2020-08-01 00:06:33 +08:00
wanyaoqi
d925cb080d fix deploy admin auth key 2020-07-31 23:24:46 +08:00
Zexi Li
3ca28cfcc7 baremetal: fix hpssactl split last LV size out of limit (#7428) 2020-07-31 22:40:02 +08:00
Qiu Jian
8c33cc9445 fix: sync share mode between vpc and wire 2020-07-31 22:30:16 +08:00
Zexi Li
37b9a960ef Merge pull request #7420 from ioito/automated-cherry-pick-of-#7417-upstream-release-3.2
Automated cherry pick of #7417: fix: avoid lost backend params
2020-07-31 18:07:59 +08:00
Zexi Li
f69370c4db Merge pull request #7415 from ioito/automated-cherry-pick-of-#7413-upstream-release-3.2
Automated cherry pick of #7413: fix: openstack win image user data need encode
2020-07-31 18:06:48 +08:00
Zexi Li
fb8f8847d0 Merge pull request #7407 from ioito/automated-cherry-pick-of-#7405-upstream-release-3.2
Automated cherry pick of #7405: fix: avoid account sync deadlock
2020-07-31 18:05:31 +08:00
Zexi Li
fc7de4722b Merge pull request #7408 from swordqiu/automated-cherry-pick-of-#7400-upstream-release-3.2
Automated cherry pick of #7400: fix: ignore general s3 set acl not implemented error
2020-07-31 18:04:05 +08:00
屈轩
f43af31195 fix: 避免glance metadata-list project scope无权限 (#7404)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
2020-07-31 18:01:48 +08:00
屈轩
0b13608d90 fix: 优化openstack项目认证 (#7399)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
2020-07-31 18:00:17 +08:00
屈轩
04e1a25c60 fix: 避免在仅调整虚拟机磁盘时opslog日志记录mem cpu异常 (#7394)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
2020-07-31 17:57:02 +08:00
Qu Xuan
b09dbdd69f fix: avoid lost backend params 2020-07-31 17:19:49 +08:00
Qu Xuan
ae26dc1214 fix: openstack win image user data need encode 2020-07-31 16:55:43 +08:00
Qu Xuan
cbc4739b1a fix: avoid account sync deadlock 2020-07-31 16:32:57 +08:00
Qiu Jian
5cfe521a23 fix: ignore general s3 set acl not implemented error 2020-07-31 16:31:52 +08:00
Zexi Li
1dd8a0c066 Merge pull request #7389 from rainzm/automated-cherry-pick-of-#7387-upstream-release-3.2
Automated cherry pick of #7387: fix(region): zone from guesttemplate's preferzone maybe nil
2020-07-30 17:41:49 +08:00
rainzm
661611f338 fix(region): zone from guesttemplate's preferzone maybe nil 2020-07-30 16:12:36 +08:00
Zexi Li
5bfd7f3494 Merge pull request #7353 from ioito/automated-cherry-pick-of-#7318-upstream-release-3.2
Automated cherry pick of #7318: fix: openstack多项目问题
2020-07-30 15:53:40 +08:00
Zexi Li
4553879a1a Merge pull request #7386 from ioito/automated-cherry-pick-of-#7384-upstream-release-3.2
Automated cherry pick of #7384: fix: avoid parse json err nil pointer
2020-07-30 15:15:38 +08:00
Qu Xuan
fb25efa0cf fix: openstack多项目问题 2020-07-30 14:48:16 +08:00
Qu Xuan
7c2268417b fix: avoid parse json err nil pointer 2020-07-30 11:32:31 +08:00
Zexi Li
97be89b9f6 Merge pull request #7380 from ioito/automated-cherry-pick-of-#7378-upstream-release-3.2
Automated cherry pick of #7378: fix: 添加阿里云rds备份恢复限制条件
2020-07-29 21:38:48 +08:00
Zexi Li
4e31734f0e Merge pull request #7376 from swordqiu/automated-cherry-pick-of-#7375-upstream-release-3.2
Automated cherry pick of #7375: fix: change owner should check required domain list
2020-07-29 17:31:44 +08:00
Qu Xuan
6d0b4f37f7 fix: 添加阿里云rds备份恢复限制条件 2020-07-29 16:56:24 +08:00
Qiu Jian
244e83b8ae fix: change owner should check required domain list 2020-07-29 13:01:14 +08:00
Zexi Li
dd42c55d1e Merge pull request #7374 from ioito/automated-cherry-pick-of-#7358-upstream-release-3.2
Automated cherry pick of #7358: fix: 普通视图下,安全组仅统计可看到的vm count
2020-07-29 10:27:18 +08:00
Zexi Li
c9f61ca7d5 Merge pull request #7361 from ioito/automated-cherry-pick-of-#7359-upstream-release-3.2
Automated cherry pick of #7359: fix: 修复vm绑定重复安全组
2020-07-28 20:56:06 +08:00
Qu Xuan
439cf1948e fix: 普通视图下,安全组仅统计可看到的vm count 2020-07-28 20:53:32 +08:00
Zexi Li
d2916c079f Merge pull request #7370 from ioito/automated-cherry-pick-of-#7368-upstream-release-3.2
Automated cherry pick of #7368: fix: 同步sku与磁盘类型关系
2020-07-28 20:48:10 +08:00
Qu Xuan
cf294a1f58 fix: 同步sku与磁盘类型关系 2020-07-28 19:47:50 +08:00
Zexi Li
63bff57a05 Merge pull request #7366 from zexi/automated-cherry-pick-of-#7364-upstream-release-3.2
Automated cherry pick of #7364: adjust schedule resource condition width
2020-07-28 18:50:29 +08:00
Zexi Li
620b31e0f3 Merge pull request #7356 from ioito/automated-cherry-pick-of-#7354-upstream-release-3.2
Automated cherry pick of #7354: fix: 避免创建rds备份时对rds进行一些操作
2020-07-28 18:49:47 +08:00
Zexi Li
95b21d541d adjust schedule resource condition width 2020-07-28 18:37:23 +08:00
Qu Xuan
d6782d5324 fix: 修复vm绑定重复安全组 2020-07-28 18:15:45 +08:00
Qu Xuan
fd233a6869 fix: 避免创建rds备份时对rds进行一些操作 2020-07-28 16:03:06 +08:00
Zexi Li
92a7fad56c Merge pull request #7340 from rainzm/automated-cherry-pick-of-#7338-upstream-release-3.2
Automated cherry pick of #7338: fix(region): Remove default secgroup for esxi guest
2020-07-27 19:49:24 +08:00
Zexi Li
788c845ca3 Merge pull request #7345 from rainzm/automated-cherry-pick-of-#7343-upstream-release-3.2
Automated cherry pick of #7343: fix: modify list details for guesttemplate
2020-07-27 19:48:28 +08:00
Zexi Li
7554cd5268 Merge pull request #7322 from swordqiu/automated-cherry-pick-of-#7321-upstream-release-3.2
Automated cherry pick of #7321: fix: choose candidate list from the list returned from backend
2020-07-27 15:53:56 +08:00
Zexi Li
15fe440911 Merge pull request #7325 from swordqiu/automated-cherry-pick-of-#7324-upstream-release-3.2
Automated cherry pick of #7324: fix: schedtag should be system resource
2020-07-27 15:49:59 +08:00
Zexi Li
7a4d0cf507 Merge pull request #7328 from tb365/automated-cherry-pick-of-#7327-upstream-release-3.2
Automated cherry pick of #7327: huawei fetch regions&projects fix
2020-07-27 15:21:51 +08:00
rainzm
0824b5445e Add metadata for GuestTempalte details 2020-07-27 15:18:40 +08:00
rainzm
951f53a96b Add network info when list scalingGroup details 2020-07-27 15:18:40 +08:00
rainzm
260d259392 fix: modify list details for guesttemplate 2020-07-27 15:18:40 +08:00
Zexi Li
54b16d94c7 Merge pull request #7333 from swordqiu/automated-cherry-pick-of-#7332-upstream-release-3.2
Automated cherry pick of #7332: fix: cloud account delete may fail due to inconsistent status
2020-07-27 15:13:01 +08:00
rainzm
52008bace0 fix(region): Remove default secgroup for esxi guest
1. InitializeData remove all secgroup_id of esxi guest from database
2. Set input.SecgroupId as empty for guest whose GetMaxSecurityGroupCount
return 0
2020-07-27 14:54:19 +08:00
屈轩
5df48d5b76 fix: 避免status_code>=400并且resp为空时err为nil (#7266)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
2020-07-27 04:43:24 +08:00
yunion-ci-robot
88f46fc0c2 Merge pull request #7313 from ioito/automated-cherry-pick-of-#7310-upstream-release-3.2
Automated cherry pick of #7310: fix: 支持多项目安全组规则过滤
2020-07-25 23:56:45 +08:00
Qiu Jian
44f3226061 fix: cloud account delete may fail due to inconsistent status 2020-07-25 23:08:17 +08:00
yunion-ci-robot
d997501c64 Merge pull request #7305 from wanyaoqi/automated-cherry-pick-of-#7302-upstream-release-3.2
Automated cherry pick of #7302: fix clone clean pending usage
2020-07-24 22:52:44 +08:00
tangbin
8f7e75772c go fmt 2020-07-24 18:31:04 +08:00
tangbin
c723def4b7 go fmt 2020-07-24 18:31:04 +08:00
tangbin
31a9373b7b host upload template check 2020-07-24 18:31:03 +08:00
tangbin
a85af97bef huawei fetch regions&projects fix 2020-07-24 18:31:02 +08:00
Qiu Jian
143fa7a896 fix: schedtag should be system resource 2020-07-24 17:03:38 +08:00
Qiu Jian
7e68b1c6a2 fix: choose candidate list from the list returned from backend 2020-07-24 16:41:43 +08:00
Qu Xuan
ec16b2abbd fix: 支持多项目安全组规则过滤 2020-07-23 20:36:59 +08:00
wanyaoqi
a8a2f07742 fix clone clean pending usage 2020-07-23 18:39:02 +08:00
Zexi Li
b627985733 Merge pull request #7296 from wanyaoqi/automated-cherry-pick-of-#7294-upstream-release-3.2
Automated cherry pick of #7294: fix snapshot clean pending usage
2020-07-23 13:48:08 +08:00
wanyaoqi
89a355132c fix snapshot clean pending usage 2020-07-23 11:36:46 +08:00
Zexi Li
0e9d0052e9 Merge pull request #7288 from tb365/automated-cherry-pick-of-#7286-upstream-release-3.2
Automated cherry pick of #7286: apigateway host imports data validate
2020-07-22 21:44:07 +08:00
tangbin
2b67f052b7 format fix 2020-07-22 17:50:46 +08:00
tangbin
6280ea485d fix empty else 2020-07-22 17:50:46 +08:00
tangbin
0b7ab48836 fix host import 2020-07-22 17:50:46 +08:00
tangbin
88d67e0f36 fix huawei delete resource 2020-07-22 17:50:46 +08:00
tangbin
faffc39a34 fix huawei elb disable healthcheck 2020-07-22 17:50:46 +08:00
tangbin
9ce1527d35 lb sync project fix 2020-07-22 17:50:45 +08:00
tangbin
1b480af798 add more log 2020-07-22 17:50:45 +08:00
tangbin
dfbd0af963 apigateway host imports data validate 2020-07-22 17:50:45 +08:00
Zexi Li
83e67c50c3 Merge pull request #7278 from ioito/automated-cherry-pick-of-#7276-upstream-release-3.2
Automated cherry pick of #7276: fix: 避免未能导出共享安全组规则
2020-07-22 13:55:50 +08:00
Zexi Li
27fa4752a2 Merge pull request #7275 from swordqiu/automated-cherry-pick-of-#7273-upstream-release-3.2
Automated cherry pick of #7273: fix: image upload not clean pending usage
2020-07-22 13:54:45 +08:00
Zexi Li
4281636f42 Merge pull request #7283 from rainzm/automated-cherry-pick-of-#7281-upstream-release-3.2
Automated cherry pick of #7281: fix(esxi): Select correct unitNumber for ide control when creating disk
2020-07-22 13:52:26 +08:00
Rain Zheng
d670f37156 fix(esxi): Select correct unitNumber for ide control when creating disk 2020-07-21 20:49:18 +08:00
Qu Xuan
9fef6dfb46 fix: 避免未能导出共享安全组规则 2020-07-21 17:14:54 +08:00
yunion-ci-robot
1f6762b4a0 Merge pull request #7272 from zexi/automated-cherry-pick-of-#7270-upstream-release-3.2
Automated cherry pick of #7270: baremetal: set zone when enable netif
2020-07-21 11:49:25 +08:00
Qiu Jian
2a892fd845 fix: image upload not clean pending usage 2020-07-21 01:43:40 +08:00
yunion-ci-robot
1d1674faf9 Merge pull request #7269 from tb365/automated-cherry-pick-of-#7267-upstream-release-3.2
Automated cherry pick of #7267: fix GetOrCreateVpcForClassicNetwork
2020-07-20 20:49:27 +08:00
Zexi Li
ae1acc891c Merge pull request #7262 from tb365/automated-cherry-pick-of-#7237-upstream-release-3.2
Automated cherry pick of #7237: huawei eip delete fix
2020-07-20 20:47:34 +08:00
Zexi Li
9fd48cee3c baremetal: set zone when enable netif 2020-07-20 20:45:30 +08:00
tangbin
ea14aaa52e fix GetOrCreateVpcForClassicNetwork 2020-07-20 18:52:08 +08:00
tangbin
38440ed276 huawei eip delete fix 2020-07-20 10:51:56 +08:00
Zexi Li
2910eeb89b Merge pull request #7241 from ioito/automated-cherry-pick-of-#7225-upstream-release-3.2
Automated cherry pick of #7225: fix: rds备份恢复优化
2020-07-20 02:07:57 +08:00
Zexi Li
53d0d4c4e7 Merge pull request #7230 from wanyaoqi/automated-cherry-pick-of-#7228-upstream-release-3.2
Automated cherry pick of #7228: fix server sync status
2020-07-20 02:06:41 +08:00
Zexi Li
e3270c90e6 Merge pull request #7236 from ioito/automated-cherry-pick-of-#7234-upstream-release-3.2
Automated cherry pick of #7234: fix: globalvpc跟随云账号共享
2020-07-20 02:05:46 +08:00
Zexi Li
31883f5984 Merge pull request #7232 from tb365/automated-cherry-pick-of-#7231-upstream-release-3.2
Automated cherry pick of #7231: acl delete condition fix
2020-07-20 02:02:25 +08:00
Zexi Li
1e7b5e2e2c Merge pull request #7250 from wanyaoqi/automated-cherry-pick-of-#7248-upstream-release-3.2
Automated cherry pick of #7248: fix error output
2020-07-19 20:53:59 +08:00
Zexi Li
c939399546 Merge pull request #7252 from swordqiu/automated-cherry-pick-of-#7251-upstream-release-3.2
Automated cherry pick of #7251: fix: quota usage not updated after disk resizing
2020-07-19 20:25:07 +08:00
Qiu Jian
f2e4a9af63 fix: quota usage not updated after disk resizing 2020-07-19 13:24:31 +08:00
wanyaoqi
e4c24c436c fix error output 2020-07-19 12:35:25 +08:00
Qu Xuan
144f40b472 fix: rds备份恢复优化 2020-07-18 20:48:28 +08:00
Qu Xuan
0af8c519be fix: globalvpc跟随云账号共享 2020-07-17 20:47:10 +08:00
tangbin
e1665416f1 acl delete condition fix 2020-07-17 20:41:34 +08:00
wanyaoqi
050d019f7f fix server sync status 2020-07-17 20:25:56 +08:00
321 changed files with 6535 additions and 3086 deletions

View File

@@ -35,7 +35,10 @@ type BaseEventListOptions struct {
Action []string `help:"Log action"`
User string `help:"filter by operator user"`
Project string `help:"filter by owner project"`
Project string `help:"filter by operator user's project"`
OwnerProjectIds []string `help:"filter by owner project ids"`
OwnerDomainIds []string `help:"filter by owner domain ids"`
PagingMarker string `help:"marker for pagination"`
}
@@ -107,6 +110,12 @@ func doEventList(man modulebase.ResourceManager, s *mcclient.ClientSession, args
if len(args.Scope) > 0 {
params.Add(jsonutils.NewString(args.Scope), "scope")
}
if len(args.OwnerProjectIds) > 0 {
params.Add(jsonutils.NewStringArray(args.OwnerProjectIds), "owner_project_ids")
}
if len(args.OwnerDomainIds) > 0 {
params.Add(jsonutils.NewStringArray(args.OwnerDomainIds), "owner_domain_ids")
}
if len(args.PagingMarker) > 0 {
params.Add(jsonutils.NewString(args.PagingMarker), "paging_marker")
}

View File

@@ -15,6 +15,8 @@
package shell
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
@@ -78,4 +80,30 @@ func init() {
printObject(result)
return nil
})
R(&GlobalVpcShowOptions{}, "global-vpc-change-owner-candidate-domains", "Show candiate domains of a global vpc for changing owner", func(s *mcclient.ClientSession, args *GlobalVpcShowOptions) error {
result, err := modules.GlobalVpcs.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
type GlobalVpcChangeOwnerOptions struct {
ID string `help:"ID or name of vpc" json:"-"`
ProjectDomain string `json:"project_domain" help:"target domain"`
}
R(&GlobalVpcChangeOwnerOptions{}, "global-vpc-change-owner", "Change owner domain of a global vpc", func(s *mcclient.ClientSession, args *GlobalVpcChangeOwnerOptions) error {
if len(args.ProjectDomain) == 0 {
return fmt.Errorf("empty project_domain")
}
params := jsonutils.Marshal(args)
ret, err := modules.GlobalVpcs.PerformAction(s, args.ID, "change-owner", params)
if err != nil {
return err
}
printObject(ret)
return nil
})
}

View File

@@ -54,6 +54,7 @@ type ImageOptionalOptions struct {
Hypervisor []string `help:"Prefer hypervisor type" choices:"kvm|esxi|baremetal|container|openstack|ctyun"`
DiskDriver string `help:"Perfer disk driver" choices:"virtio|scsi|pvscsi|ide|sata"`
NetDriver string `help:"Preferred network driver" choices:"virtio|e1000|vmxnet3"`
DisableUsbKbd bool `help:"Disable usb keyboard on this image(for hypervisor kvm)"`
}
func addImageOptionalOptions(s *mcclient.ClientSession, params *jsonutils.JSONDict, args ImageOptionalOptions) error {
@@ -131,6 +132,9 @@ func addImageOptionalOptions(s *mcclient.ClientSession, params *jsonutils.JSONDi
if len(args.Hypervisor) > 0 {
params.Add(jsonutils.NewString(strings.Join(args.Hypervisor, ",")), "properties", "hypervisor")
}
if args.DisableUsbKbd {
params.Add(jsonutils.NewString("true"), "properties", "disable_usb_kbd")
}
return nil
}
@@ -252,7 +256,7 @@ func init() {
}
type ImageDeleteOptions struct {
ID []string `help:"Image ID or name"`
ID []string `help:"Image ID or name" json:"-"`
OverridePendingDelete *bool `help:"Delete image directly instead of pending delete" short-token:"f"`
}
R(&ImageDeleteOptions{}, "image-delete", "Delete a image", func(s *mcclient.ClientSession, args *ImageDeleteOptions) error {

View File

@@ -25,14 +25,14 @@ import (
func init() {
type SecGroupRulesListOptions struct {
options.BaseListOptions
Secgroup string `help:"Secgroup ID or Name"`
SecgroupName string `help:"Search rules by fuzzy secgroup name"`
Project string `help:"Filter rules by project"`
Direction string `help:"filter Direction of rule" choices:"in|out"`
Protocol string `help:"filter Protocol of rule" choices:"any|tcp|udp|icmp"`
Action string `help:"filter Actin of rule" choices:"allow|deny"`
Ports string `help:"filter Ports of rule"`
Ip string `help:"filter cidr of rule"`
Secgroup string `help:"Secgroup ID or Name"`
SecgroupName string `help:"Search rules by fuzzy secgroup name"`
Projects []string `help:"Filter rules by project"`
Direction string `help:"filter Direction of rule" choices:"in|out"`
Protocol string `help:"filter Protocol of rule" choices:"any|tcp|udp|icmp"`
Action string `help:"filter Actin of rule" choices:"allow|deny"`
Ports string `help:"filter Ports of rule"`
Ip string `help:"filter cidr of rule"`
}
R(&SecGroupRulesListOptions{}, "secgroup-rule-list", "List all security group", func(s *mcclient.ClientSession, args *SecGroupRulesListOptions) error {

View File

@@ -1146,6 +1146,7 @@ func init() {
ID string `help:"ID or name of VM"`
DisableIsaSerial string `help:"disable isa serial device" choices:"true|false"`
DisablePvpanic string `help:"disable pvpanic device" choices:"true|false"`
DisableUsbKbd string `help:"disable usb kbd" choices:"true|false"`
}
R(&ServerQemuParams{}, "server-set-qemu-params", "config qemu params", func(s *mcclient.ClientSession,
@@ -1157,6 +1158,9 @@ func init() {
if len(opts.DisablePvpanic) > 0 {
params.Set("disable_pvpanic", jsonutils.NewString(opts.DisablePvpanic))
}
if len(opts.DisableUsbKbd) > 0 {
params.Set("disable_usb_kbd", jsonutils.NewString(opts.DisableUsbKbd))
}
result, err := modules.Servers.PerformAction(s, opts.ID, "set-qemu-params", params)
if err != nil {
return err

View File

@@ -18,17 +18,21 @@ import (
"fmt"
"os"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/multicloud/google"
_ "yunion.io/x/onecloud/pkg/multicloud/google/shell"
"yunion.io/x/onecloud/pkg/util/fileutils2"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
Help bool `help:"Show help"`
AuthFile string `help:"google cloud auth json file path" default:"$GOOGLE_AUTH_FILE"`
ClientEmail string `help:"Client email" default:"$GOOGLE_CLIENT_EMAIL"`
ProjectID string `help:"Project ID" default:"$GOOGLE_PROJECT_ID"`
PrivateKeyID string `help:"Private Key ID" default:"$GOOGLE_PRIVATE_KEY_ID"`
@@ -78,6 +82,20 @@ func showErrorAndExit(e error) {
}
func newClient(options *BaseOptions) (*google.SRegion, error) {
if len(options.AuthFile) > 0 {
jsonStr, err := fileutils2.FileGetContents(options.AuthFile)
if err != nil {
return nil, errors.Wrap(err, "FileGetContents")
}
jsonCfg, err := jsonutils.ParseString(jsonStr)
if err != nil {
return nil, errors.Wrap(err, "jsonutils.ParseString")
}
options.ClientEmail, _ = jsonCfg.GetString("client_email")
options.PrivateKeyID, _ = jsonCfg.GetString("private_key_id")
options.PrivateKey, _ = jsonCfg.GetString("private_key")
options.ProjectID, _ = jsonCfg.GetString("project_id")
}
if len(options.ClientEmail) == 0 {
return nil, fmt.Errorf("Missing ClientEmail")
}

9
go.mod
View File

@@ -117,6 +117,7 @@ require (
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb
google.golang.org/grpc v1.26.0
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
gopkg.in/fatih/set.v0 v0.2.1
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.44.0 // indirect
gopkg.in/ldap.v3 v3.0.3
@@ -127,12 +128,12 @@ require (
k8s.io/cluster-bootstrap v0.17.3
k8s.io/kubernetes v1.16.0
yunion.io/x/executor v0.0.0-20200227030256-a18417815e74
yunion.io/x/jsonutils v0.0.0-20200710080709-7ca71cdb9383
yunion.io/x/jsonutils v0.0.0-20200814075449-927b118adbd8
yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3
yunion.io/x/pkg v0.0.0-20200713121502-18154120c49b
yunion.io/x/pkg v0.0.0-20200814072949-4f1b541857d6
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
yunion.io/x/sqlchemy v0.0.0-20200702064124-195445bc4b11
yunion.io/x/structarg v0.0.0-20200708124353-ea9a441ecaf8
yunion.io/x/sqlchemy v0.0.0-20200814052348-164f1f20f8a6
yunion.io/x/structarg v0.0.0-20200720093445-9f850fa222ce
)
replace (

20
go.sum
View File

@@ -1013,6 +1013,8 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY=
gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gcfg.v1 v1.2.0/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo=
@@ -1106,8 +1108,8 @@ vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc/go.mod h1:so/NYdZXCz+E3ZpW0uAoCj
yunion.io/x/executor v0.0.0-20200227030256-a18417815e74 h1:A15C6VdVRWvmQ9pAJHrUs9yan5qKlYH7uaRxHg1kRbk=
yunion.io/x/executor v0.0.0-20200227030256-a18417815e74/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
yunion.io/x/jsonutils v0.0.0-20200710080709-7ca71cdb9383 h1:XEhTD+FGjBjEIWwcY0Ez1lY3oTTzjUOcRgH/i4eFM5A=
yunion.io/x/jsonutils v0.0.0-20200710080709-7ca71cdb9383/go.mod h1:3U5hspYn9apQHaXKY+fJ4Qgwjey32Kc+Mq+mUe9NamQ=
yunion.io/x/jsonutils v0.0.0-20200814075449-927b118adbd8 h1:KQVw5EmohJCqBDMdZ3fAcOQNNMIYgVuNCNWNwg4EM3A=
yunion.io/x/jsonutils v0.0.0-20200814075449-927b118adbd8/go.mod h1:p0nyMqGA/apTxxyLIU/o1k4V7Vujl2O6ey30L594sYE=
yunion.io/x/log v0.0.0-20190514041436-04ce53b17c6b/go.mod h1:+gauLs73omeJAPlsXcevLsJLKixV+sR/E7WSYTSx1fE=
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d h1:59zrDL7Ft+hDukguJRmLr/Gdu/9V75x+yX99ovZwfaA=
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d/go.mod h1:LC6f/4FozL0iaAbnFt2eDX9jlsyo3WiOUPm03d7+U4U=
@@ -1115,13 +1117,11 @@ yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3 h1:5Wc5hkB8PtMudmHuzCyok960Ru
yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3/go.mod h1:LC6f/4FozL0iaAbnFt2eDX9jlsyo3WiOUPm03d7+U4U=
yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/pkg v0.0.0-20200708071451-a663dc94e16b h1:wwPzH8iMRYjtaSM2pBN7nOqeZxR4XW5wdz2VE1KH/Ug=
yunion.io/x/pkg v0.0.0-20200708071451-a663dc94e16b/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/pkg v0.0.0-20200713121502-18154120c49b h1:Ov/eKwwNeQje7SggkopExzcCW/GfaUouvXkcY6RUEcM=
yunion.io/x/pkg v0.0.0-20200713121502-18154120c49b/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/pkg v0.0.0-20200814072949-4f1b541857d6 h1:UarEDTBGkgcgc+nc+PZ75uo9M9+jiOGd5P2B90TxDNw=
yunion.io/x/pkg v0.0.0-20200814072949-4f1b541857d6/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e h1:v+EzIadodSwkdZ/7bremd7J8J50Cise/HCylsOJngmo=
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo=
yunion.io/x/sqlchemy v0.0.0-20200702064124-195445bc4b11 h1:srrssomGJLh4OaDaY/1so+2FUBjZxdwQx/1pZ6403YU=
yunion.io/x/sqlchemy v0.0.0-20200702064124-195445bc4b11/go.mod h1:FTdwPdGhMgh4E+UFXc9klI1Ok34fMuybTT+jLhOaIjI=
yunion.io/x/structarg v0.0.0-20200708124353-ea9a441ecaf8 h1:35Q2ce/gI2cuVhsuLS7WsL2K9SxwMEtWTopt/99iYsk=
yunion.io/x/structarg v0.0.0-20200708124353-ea9a441ecaf8/go.mod h1:EP6NSv2C0zzqBDTKumv8hPWLb3XvgMZDHQRfyuOrQng=
yunion.io/x/sqlchemy v0.0.0-20200814052348-164f1f20f8a6 h1:k7E8Zjwzyk/lo1dDO0jtLbODwYRNv+w/zsUJrKWCXvo=
yunion.io/x/sqlchemy v0.0.0-20200814052348-164f1f20f8a6/go.mod h1:FTdwPdGhMgh4E+UFXc9klI1Ok34fMuybTT+jLhOaIjI=
yunion.io/x/structarg v0.0.0-20200720093445-9f850fa222ce h1:kU8xE7O5uZ1GSJVMZHoJ+jrNL7csUQHYGyAPW9QfNpE=
yunion.io/x/structarg v0.0.0-20200720093445-9f850fa222ce/go.mod h1:EP6NSv2C0zzqBDTKumv8hPWLb3XvgMZDHQRfyuOrQng=

View File

@@ -28,6 +28,7 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/utils"
"yunion.io/x/onecloud/pkg/apigateway/options"
"yunion.io/x/onecloud/pkg/appctx"
@@ -37,6 +38,7 @@ import (
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/util/httputils"
)
const (
@@ -57,6 +59,12 @@ const (
BATCH_HOST_REGISTER_QUANTITY_LIMITATION = 1000
)
var (
BatchHostRegisterTemplate = []string{HOST_MAC, HOST_NAME, HOST_IPMI_ADDR_OPTIONAL, HOST_IPMI_USERNAME_OPTIONAL, HOST_IPMI_PASSWORD_OPTIONAL}
BatchHostISORegisterTemplate = []string{HOST_NAME, HOST_IPMI_ADDR, HOST_IPMI_USERNAME, HOST_IPMI_PASSWORD, HOST_MNG_IP_ADDR}
BatchHostPXERegisterTemplate = []string{HOST_NAME, HOST_IPMI_ADDR, HOST_IPMI_USERNAME, HOST_IPMI_PASSWORD, HOST_MNG_IP_ADDR_OPTIONAL}
)
func FetchSession(ctx context.Context, r *http.Request, apiVersion string) *mcclient.ClientSession {
token := AppContextToken(ctx)
session := auth.GetSession(ctx, token, FetchRegion(r), apiVersion)
@@ -170,20 +178,43 @@ func (mh *MiscHandler) DoBatchHostRegister(ctx context.Context, w http.ResponseW
return
}
// check header line
titlesOk := false
for _, t := range [][]string{BatchHostRegisterTemplate, BatchHostISORegisterTemplate, BatchHostPXERegisterTemplate} {
if len(t) == len(rows[0]) {
for _, title := range rows[0] {
if !utils.IsInStringArray(title, t) {
break
}
}
titlesOk = true
}
}
if !titlesOk {
httperrors.InputParameterError(w, "template file is invalid.please check.")
return
}
paramKeys := []string{}
for _, title := range rows[0] {
i1 := -1
i2 := -1
for i, title := range rows[0] {
switch title {
case HOST_MAC:
paramKeys = append(paramKeys, "access_mac")
case HOST_NAME:
paramKeys = append(paramKeys, "name")
case HOST_IPMI_ADDR, HOST_IPMI_ADDR_OPTIONAL:
i1 = i
paramKeys = append(paramKeys, "ipmi_ip_addr")
case HOST_IPMI_USERNAME, HOST_IPMI_USERNAME_OPTIONAL:
paramKeys = append(paramKeys, "ipmi_username")
case HOST_IPMI_PASSWORD, HOST_IPMI_PASSWORD_OPTIONAL:
paramKeys = append(paramKeys, "ipmi_password")
case HOST_MNG_IP_ADDR, HOST_MNG_IP_ADDR_OPTIONAL:
i2 = i
paramKeys = append(paramKeys, "access_ip")
default:
e := httperrors.NewInternalServerError("empty file content")
@@ -199,8 +230,33 @@ func (mh *MiscHandler) DoBatchHostRegister(ctx context.Context, w http.ResponseW
return
}
ips := []string{}
hosts := bytes.Buffer{}
for _, row := range rows[1:] {
var e *httputils.JSONClientError
if i1 >= 0 && len(row[i1]) > 0 {
i1Ip := fmt.Sprintf("%d-%s", i1, row[i1])
if utils.IsInStringArray(i1Ip, ips) {
e = httperrors.NewDuplicateIdError("ip", row[i1])
} else {
ips = append(ips, i1Ip)
}
}
if i2 >= 0 && len(row[i2]) > 0 {
i2Ip := fmt.Sprintf("%d-%s", i2, row[i2])
if utils.IsInStringArray(i2Ip, ips) {
e = httperrors.NewDuplicateIdError("ip", row[i2])
} else {
ips = append(ips, i2Ip)
}
}
if e != nil {
httperrors.JsonClientError(w, e)
return
}
hosts.WriteString(strings.Join(row, ",") + "\n")
}
@@ -375,21 +431,21 @@ func (mh *MiscHandler) getDownloadsHandler(ctx context.Context, w http.ResponseW
var content bytes.Buffer
switch template {
case "BatchHostRegister":
records := [][]string{{HOST_MAC, HOST_NAME, HOST_IPMI_ADDR_OPTIONAL, HOST_IPMI_USERNAME_OPTIONAL, HOST_IPMI_PASSWORD_OPTIONAL}}
records := [][]string{BatchHostRegisterTemplate}
content, err = writeXlsx("hosts", records)
if err != nil {
httperrors.InternalServerError(w, "internal server error")
return
}
case "BatchHostISORegister":
records := [][]string{{HOST_NAME, HOST_IPMI_ADDR, HOST_IPMI_USERNAME, HOST_IPMI_PASSWORD, HOST_MNG_IP_ADDR}}
records := [][]string{BatchHostISORegisterTemplate}
content, err = writeXlsx("hosts", records)
if err != nil {
httperrors.InternalServerError(w, "internal server error")
return
}
case "BatchHostPXERegister":
records := [][]string{{HOST_NAME, HOST_IPMI_ADDR, HOST_IPMI_USERNAME, HOST_IPMI_PASSWORD, HOST_MNG_IP_ADDR_OPTIONAL}}
records := [][]string{BatchHostPXERegisterTemplate}
content, err = writeXlsx("hosts", records)
if err != nil {
httperrors.InternalServerError(w, "internal server error")

View File

@@ -57,7 +57,7 @@ type ProxySettingResourceInput struct {
// swagger:ignore
// Deprecated
ProxySettingId string `json:"proxy_setting_id" "yunion:deprecated-by":"proxy_setting"`
ProxySettingId string `json:"proxy_setting_id" yunion-deprecated-by:"proxy_setting"`
}
type ProxySettingTestInput struct {

View File

@@ -285,7 +285,7 @@ type ServerConfigs struct {
// swagger:ignore
// Deprecated
// alias for InstanceType
Sku string `json:"sku" "yunion:deprecated-by":"instance_type"`
Sku string `json:"sku" yunion-deprecated-by:"instance_type"`
// 虚拟机高可用(创建备机)
// default: false
@@ -359,7 +359,7 @@ type ServerCreateInput struct {
// swagger:ignore
// Deprecated
KeypairId string `json:"keypair_id" "yunion:deprecated-by":"keypair"`
KeypairId string `json:"keypair_id" yunion-deprecated-by:"keypair"`
// 秘钥对Id
// required: false
@@ -466,7 +466,8 @@ type ServerCreateInput struct {
// swagger:ignore
OsType string `json:"os_type"`
// swagger:ignore
DisableUsbKbd bool `json:"disable_usb_kbd"`
// swagger:ignore
OsProfile jsonutils.JSONObject `json:"__os_profile__"`
// swagger:ignore

View File

@@ -42,7 +42,7 @@ type LoadbalancerAclResourceInput struct {
// swagger:ignore
// Deprecated
AclId string `json:"acl_id" "yunion:deprecated-by":"acl"`
AclId string `json:"acl_id" yunion-deprecated-by:"acl"`
}
type LoadbalancerAclFilterListInput struct {

View File

@@ -43,7 +43,7 @@ type LoadbalancerCertificateResourceInput struct {
// swagger:ignore
// Deprecated
CertificateId string `json:"certificate_id" "yunion:deprecated-by":"certificate"`
CertificateId string `json:"certificate_id" yunion-deprecated-by:"certificate"`
}
type LoadbalancerCertificateFilterListInput struct {

View File

@@ -66,7 +66,7 @@ type CloudenvResourceListInput struct {
Providers []string `json:"providers"`
// swagger:ignore
// Deprecated
Provider []string `json:"provider" "yunion:deprecated-by":"providers"`
Provider []string `json:"provider" yunion-deprecated-by:"providers"`
// 列出指定云平台品牌的资源一般来说brand和provider相同除了以上支持的provider之外还支持以下band
//
@@ -77,7 +77,7 @@ type CloudenvResourceListInput struct {
Brands []string `json:"brands"`
// swagger:ignore
// Deprecated
Brand []string `json:"brand" "yunion:deprecated-by":"brands"`
Brand []string `json:"brand" yunion-deprecated-by:"brands"`
// 列出指定云环境的资源,支持云环境如下:
//
@@ -180,9 +180,9 @@ type CloudaccountCreateInput struct {
// 自动同步间隔时间
SyncIntervalSeconds int `json:"sync_interval_seconds"`
// 自动根据云上项目或订阅创建本地项目
// 自动根据云上项目或订阅创建本地项目, OpenStack此参数为true
// default: false
AutoCreateProject bool `json:"auto_create_project"`
AutoCreateProject *bool `json:"auto_create_project"`
// 额外信息,例如账单的access key
Options *jsonutils.JSONDict `json:"options"`
@@ -227,7 +227,7 @@ type CloudaccountListInput struct {
// 代理
ProxySetting string `json:"proxy_setting"`
// swagger:ignore
ProxySettingId string `json:"proxy_setting_id" "yunion:deprecated-by":"proxy_setting"`
ProxySettingId string `json:"proxy_setting_id" yunion-deprecated-by:"proxy_setting"`
}
type ProviderProject struct {

View File

@@ -147,15 +147,15 @@ type CloudproviderResourceInput struct {
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
Manager string `json:"manager" "yunion:deprecated-by":"cloudprovider"`
Manager string `json:"manager" yunion-deprecated-by:"cloudprovider"`
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
ManagerId string `json:"manager_id" "yunion:deprecated-by":"cloudprovider"`
ManagerId string `json:"manager_id" yunion-deprecated-by:"cloudprovider"`
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
CloudproviderId string `json:"cloudprovider_id" "yunion:deprecated-by":"cloudprovider"`
CloudproviderId string `json:"cloudprovider_id" yunion-deprecated-by:"cloudprovider"`
}
type ManagedResourceListInput struct {
@@ -169,15 +169,15 @@ type ManagedResourceListInput struct {
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
CloudaccountId string `json:"cloudaccount_id" "yunion:deprecated-by":"cloudaccount"`
CloudaccountId string `json:"cloudaccount_id" yunion-deprecated-by:"cloudaccount"`
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
Account string `json:"account" "yunion:deprecated-by":"cloudaccount"`
Account string `json:"account" yunion-deprecated-by:"cloudaccount"`
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
AccountId string `json:"account_id" "yunion:deprecated-by":"cloudaccount"`
AccountId string `json:"account_id" yunion-deprecated-by:"cloudaccount"`
// 过滤资源是否为非OneCloud内置私有云管理的资源
// default: false
@@ -251,3 +251,23 @@ type CloudproviderUpdateInput struct {
type CloudproviderCreateInput struct {
}
type CloudproviderGetStorageClassInput struct {
CloudregionResourceInput
}
type CloudproviderGetStorageClassOutput struct {
// 对象存储存储类型
StorageClasses []string `json:"storage_classes"`
}
type CloudproviderGetCannedAclInput struct {
CloudregionResourceInput
}
type CloudproviderGetCannedAclOutput struct {
// Bucket支持的预置ACL列表
BucketCannedAcls []string `json:"bucket_canned_acls"`
// Object支持的预置ACL列表
ObjectCannedAcls []string `json:"object_canned_acls"`
}

View File

@@ -101,7 +101,7 @@ type DBInstanceCreateInput struct {
// | ----- | ------ | --- |
// | 华为云 |ha, single, replica| |
// | 阿里云 |basic, high_availability, always_on, finance||
// | Google |SECOND_GEN | FIRST_GEN 目前谷歌已弃用|
// | Google |Zonal, Regional | |
// 翻译:
// basic: 基础版
// high_availability: 高可用
@@ -110,7 +110,8 @@ type DBInstanceCreateInput struct {
// ha: 高可用
// single: 单机
// replica: 只读
// SECNOD_GEN: 第二代
// Zonal: 单区域
// Regional: 区域级
// required: true
Category string `json:"category"`
@@ -170,9 +171,22 @@ type SDBInstanceChangeConfigInput struct {
type SDBInstanceRecoveryConfigInput struct {
apis.Meta
DBInstancebackup string
DBInstancebackupId string `json:"dbinstancebackup_id"`
Databases map[string]string `json:"databases,allowempty"`
// swagger:ignore
DBInstancebackup string `json:"dbinstancebackup" yunion-deprecated-by:"dbinstancebackup_id"`
// 备份Id
//
//
// | 平台 | 支持引擎 | 说明 |
// | ----- | ------ | --- |
// | 华为云 |MySQL, SQL Server | 仅SQL Server支持恢复到当前实例 |
// | 阿里云 |MySQL, SQL Server | MySQL要求必须开启单库单表恢复功能 并且只能是MySQL 8.0 高可用版本地SSD盘MySQL 5.7 高可用版本地SSD盘或MySQL 5.6 高可用版, MySQL仅支持恢复到当前实例|
// | Google |MySQL, PostgreSQL, SQL Server | PostgreSQL备份恢复时要求实例不能有副本 |
DBInstancebackupId string `json:"dbinstancebackup_id"`
// 数据库信息, 例如 {"src":"dest"} 是将备份中的src数据库恢复到目标实例的dest数据库中, 阿里云此参数为必传
// example: {"sdb1":"ddb1"}
Databases map[string]string `json:"databases,allowempty"`
}
type DBInstanceListInput struct {
@@ -313,7 +327,7 @@ type DBInstanceResourceInput struct {
// swagger:ignore
// Deprecated
DBInstanceId string `json:"dbinstance_id" "yunion:deprecated-by":"dbinstance"`
DBInstanceId string `json:"dbinstance_id" yunion-deprecated-by:"dbinstance"`
}
type DBInstanceFilterListInputBase struct {

View File

@@ -70,13 +70,13 @@ type SDBInstanceSetPrivilegesInput struct {
type DBInstancePrivilege struct {
// 数据库名称
Database string
Database string `json:"database"`
// 账号名称
Account string
Account string `json:"account"`
// 数据库Id
DBInstancedatabaseId string
DBInstancedatabaseId string `json:"dbinstancedatabase_id"`
// 权限
Privileges string
Privileges string `json:"privileges"`
}
type DBInstanceAccountDetails struct {

View File

@@ -16,19 +16,20 @@ package compute
const (
//实例状态
DBINSTANCE_DEPLOYING = "deploying" //部署中
DBINSTANCE_RUNNING = "running" //运行中
DBINSTANCE_REBOOTING = "rebooting" //重启中
DBINSTANCE_MIGRATING = "migrating" //迁移中
DBINSTANCE_BACKING_UP = "backing_up" //备份中
DBINSTANCE_RESTORING = "restoring" //备份恢复中
DBINSTANCE_RESTORE_FAILED = "restore_failed"
DBINSTANCE_IMPORTING = "importing" //数据导入中
DBINSTANCE_CLONING = "cloning" //克隆
DBINSTANCE_DELETING = "deleting" //删除
DBINSTANCE_DELETE_FAILED = "delete_failed" //删除失败
DBINSTANCE_MAINTENANCE = "maintenance" //维护中
DBINSTANCE_UNKNOWN = "unknown"
DBINSTANCE_DEPLOYING = "deploying" //部署中
DBINSTANCE_RUNNING = "running" //运行中
DBINSTANCE_REBOOTING = "rebooting" //重启中
DBINSTANCE_MIGRATING = "migrating" //迁移中
DBINSTANCE_BACKING_UP = "backing_up" //备份中
DBINSTANCE_BACKING_UP_FAILED = "backing_up_failed" //备份失败
DBINSTANCE_RESTORING = "restoring" //备份恢复中
DBINSTANCE_RESTORE_FAILED = "restore_failed"
DBINSTANCE_IMPORTING = "importing" //数据导入
DBINSTANCE_CLONING = "cloning" //克隆
DBINSTANCE_DELETING = "deleting" //删除
DBINSTANCE_DELETE_FAILED = "delete_failed" //删除失败
DBINSTANCE_MAINTENANCE = "maintenance" //维护中
DBINSTANCE_UNKNOWN = "unknown"
DBINSTANCE_CHANGE_CONFIG = "change_config" //调整配置
DBINSTANCE_CHANGE_CONFIG_FAILED = "change_config_failed" //调整配置失败

View File

@@ -88,7 +88,7 @@ type SnapshotPolicyResourceInput struct {
// swagger:ignore
// Deprecated
// filter disk by snapshotpolicy_id
SnapshotpolicyId string `json:"snapshotpolicy_id" "yunion:deprecated-by":"snapshotpolicy"`
SnapshotpolicyId string `json:"snapshotpolicy_id" yunion-deprecated-by:"snapshotpolicy"`
}
type SnapshotPolicyFilterListInput struct {
@@ -113,7 +113,7 @@ type DiskListInput struct {
// swagger:ignore
// Deprecated
// filter by disk type
Type string `json:"type" "yunion:deprecated-by":"disk_type"`
Type string `json:"type" yunion-deprecated-by:"disk_type"`
// 过滤指定disk_type的磁盘列表可能的值为sys, data, swap. volume
//
// | disk_type值 | 说明 |
@@ -137,13 +137,13 @@ type DiskListInput struct {
Template string `json:"template"`
// swagger:ignore
// Deprecated
TemplateId string `json:"template_id" "yunion:deprecated-by":"template"`
TemplateId string `json:"template_id" yunion-deprecated-by:"template"`
// 快照
Snapshot string `json:"snapshot"`
// swagger:ignore
// Deprecated
SnapshotId string `json:"snapshot_id" "yunion:deprecated-by":"snapshot"`
SnapshotId string `json:"snapshot_id" yunion-deprecated-by:"snapshot"`
}
type DiskResourceInput struct {
@@ -152,7 +152,7 @@ type DiskResourceInput struct {
// swagger:ignore
// Deprecated
// filter by disk_id
DiskId string `json:"disk_id" "yunion:deprecated-by":"disk"`
DiskId string `json:"disk_id" yunion-deprecated-by:"disk"`
}
type DiskFilterListInputBase struct {

View File

@@ -14,5 +14,11 @@
package compute
import "yunion.io/x/onecloud/pkg/apis"
type DnsRecordCreateInput struct {
apis.AdminSharableVirtualResourceBaseCreateInput
}
type DnsRecordUpdateInput struct {
}

View File

@@ -53,7 +53,7 @@ type ELasticcacheResourceInput struct {
// swagger:ignore
// Deprecated
ElasticcacheId string `json:"elasticcache_id" "yunion:deprecated-by":"elasticcache"`
ElasticcacheId string `json:"elasticcache_id" yunion-deprecated-by:"elasticcache"`
}
type ElasticcacheFilterListInput struct {

View File

@@ -24,15 +24,15 @@ type CloudregionResourceInput struct {
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
CloudregionId string `json:"cloudregion_id" "yunion:deprecated-by":"cloudregion"`
CloudregionId string `json:"cloudregion_id" yunion-deprecated-by:"cloudregion"`
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
Region string `json:"region" "yunion:deprecated-by":"cloudregion"`
Region string `json:"region" yunion-deprecated-by:"cloudregion"`
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
RegionId string `json:"region_id" "yunion:deprecated-by":"cloudregion"`
RegionId string `json:"region_id" yunion-deprecated-by:"cloudregion"`
}
type RegionalFilterListInput struct {
@@ -64,6 +64,23 @@ type ZonalFilterListBase struct {
OrderByZone string `json:"order_by_zone"`
}
func (input ZonalFilterListBase) ZoneList() []string {
zoneStr := input.Zone
if len(zoneStr) > 0 {
input.Zones = append(input.Zones, zoneStr)
}
return input.Zones
}
func (input ZonalFilterListBase) FirstZone() string {
if len(input.Zone) > 0 {
return input.Zone
}
if len(input.Zones) > 0 {
return input.Zones[0]
}
return ""
}
func (input ZonalFilterListInput) ZoneList() []string {
zoneStr := input.Zone
if len(zoneStr) > 0 {
@@ -117,5 +134,5 @@ type ZoneResourceInput struct {
// swagger:ignore
// Deprecated
ZoneId string `json:"zone_id" "yunion:deprecated-by":"zone"`
ZoneId string `json:"zone_id" yunion-deprecated-by:"zone"`
}

View File

@@ -42,7 +42,7 @@ type GlobalVpcResourceInput struct {
// swagger:ignore
// Deprecated
GlobalvpcId string `json:"globalvpc_id" "yunion:deprecated-by":"globalvpc"`
GlobalvpcId string `json:"globalvpc_id" yunion-deprecated-by:"globalvpc"`
}
type GlobalVpcResourceListInput struct {

View File

@@ -30,13 +30,13 @@ type ServerListInput struct {
HostFilterListInput
NetworkFilterListInput `"yunion:ambiguous-prefix":"vpc_"`
NetworkFilterListInput `yunion-ambiguous-prefix:"vpc_"`
billing.BillingResourceListInput
GroupFilterListInput
SecgroupFilterListInput
//DiskFilterListInput `"yunion:ambiguous-prefix":"storage_"`
//DiskFilterListInput `yunion-ambiguous-prefix:"storage_"`
ScalingGroupFilterListInput
// 只列出裸金属主机
@@ -66,7 +66,7 @@ type ServerListInput struct {
// 列出可以挂载磁盘的主机
AttachableServersForDisk string `json:"attachable_servers_for_disk"`
// Deprecated:列出可以挂载磁盘的主机
Disk string `json:"disk" "yunion:deprecated-by":"attachable_servers_for_disk"`
Disk string `json:"disk" yunion-deprecated-by:"attachable_servers_for_disk"`
// 按主机资源类型进行排序
// enum: shared,prepaid,dedicated
@@ -267,15 +267,15 @@ type ServerResourceInput struct {
// swagger:ignore
// Deprecated
// Filter by guest Id
ServerId string `json:"server_id" "yunion:deprecated-by":"server"`
ServerId string `json:"server_id" yunion-deprecated-by:"server"`
// swagger:ignore
// Deprecated
// Filter by guest Id
Guest string `json:"guest" "yunion:deprecated-by":"server"`
Guest string `json:"guest" yunion-deprecated-by:"server"`
// swagger:ignore
// Deprecated
// Filter by guest Id
GuestId string `json:"guest_id" "yunion:deprecated-by":"server"`
GuestId string `json:"guest_id" yunion-deprecated-by:"server"`
}
type ServerFilterListInput struct {

View File

@@ -57,6 +57,7 @@ type GuestTemplateDetails struct {
Secgroups []string `json:"secgroups"`
Zone string `json:"zone"`
ZoneId string `json:"zone_id"`
Brand string `json:"brand"`
ConfigInfo GuestTemplateConfigInfo `json:"config_info"`
@@ -71,9 +72,7 @@ type GuestTemplateListInput struct {
}
type GuestTemplateConfigInfo struct {
Region string `json:"region"`
Zone string `json:"zone"`
Hypervisor string `json:"hypervisor"`
Metadata map[string]string `json:"metadata"`
Secgroup string `json:"secgroup"`
Sku GuestTemplateSku `json:"sku"`
Disks []GuestTemplateDisk `json:"disks"`

View File

@@ -138,7 +138,7 @@ type HostDetails struct {
NonsystemGuests int `json:"nonsystem_guests"`
// 运行中云主机数量
// example: 2
RunningGuests int `json:"running_geusts"`
RunningGuests int `json:"running_guests"`
// CPU超分率
CpuCommitRate float64 `json:"cpu_commit_rate"`
// 内存超分率
@@ -224,7 +224,7 @@ type HostResourceInput struct {
// swagger:ignore
// Deprecated
// filter by host_id
HostId string `json:"host_id" "yunion:deprecated-by":"host"`
HostId string `json:"host_id" yunion-deprecated-by:"host"`
}
type HostRegisterMetadata struct {

View File

@@ -21,7 +21,7 @@ type HostJointResourceDetailsBase struct {
Host string `json:"host"`
// 裸金属服务器名称
// Deprecated
Baremetal string `json:"baremetal" "yunion:deprecated-by":"host"`
Baremetal string `json:"baremetal" yunion-deprecated-by:"host"`
}
type HostJointResourceDetails struct {

View File

@@ -149,7 +149,7 @@ type GuestTemplateFilterListInput struct {
GuestTemplate string `json:"guest_template"`
// swagger:ignore
// Deprecated
GuestTemplateId string `json:"guest_template_id" "yunion:deprecated-by":"guest_template"`
GuestTemplateId string `json:"guest_template_id" yunion-deprecated-by:"guest_template"`
}
type ServiceCatalogListInput struct {

View File

@@ -50,7 +50,7 @@ type GroupResourceInput struct {
// swagger:ignore
// Deprecated
// Filter by instance group Id
GroupId string `json:"group_id" "yunion:deprecated-by":"group"`
GroupId string `json:"group_id" yunion-deprecated-by:"group"`
}
type GroupFilterListInput struct {

View File

@@ -201,7 +201,10 @@ type LoadbalancerResourceInfo struct {
// 可用区ID
ZoneId string `json:"zone_id"`
ZoneResourceInfoBase
ZoneResourceInfo
// cloud provider info
ManagedResourceInfo
}
type LoadbalancerResourceInput struct {
@@ -210,7 +213,7 @@ type LoadbalancerResourceInput struct {
// swagger:ignore
// Deprecated
LoadbalancerId string `json:"loadbalancer_id" "yunion:deprecated-by":"loadbalancer"`
LoadbalancerId string `json:"loadbalancer_id" yunion-deprecated-by:"loadbalancer"`
}
type LoadbalancerFilterListInput struct {

View File

@@ -39,7 +39,7 @@ type LoadbalancerBackendGroupResourceInput struct {
// swagger:ignore
// Deprecated
BackendGroupId string `json:"backend_group_id" "yunion:deprecated-by":"backend_group"`
BackendGroupId string `json:"backend_group_id" yunion-deprecated-by:"backend_group"`
}
type LoadbalancerBackendGroupFilterListInput struct {

View File

@@ -45,7 +45,7 @@ type LoadbalancerClusterResourceInput struct {
// swagger:ignore
// Deprecated
ClusterId string `json:"cluster_id" "yunion:deprecated-by":"cluster"`
ClusterId string `json:"cluster_id" yunion-deprecated-by:"cluster"`
}
type LoadbalancerClusterFilterListInput struct {

View File

@@ -45,7 +45,7 @@ type LoadbalancerListenerResourceInput struct {
// 负载均衡监听器ID
// swagger:ignore
// Deprecated
ListenerId string `json:"listener_id" "yunion:deprecated-by":"listener"`
ListenerId string `json:"listener_id" yunion-deprecated-by:"listener"`
}
type LoadbalancerListenerFilterListInput struct {

View File

@@ -89,7 +89,7 @@ type NatGatewayResourceInput struct {
// swagger:ignore
// Deprecated
NatgatewayId string `json:"natgateway_id" "yunion:deprecated-by":"natgateway"`
NatgatewayId string `json:"natgateway_id" yunion-deprecated-by:"natgateway"`
}
type NatGatewayFilterListInput struct {

View File

@@ -24,7 +24,7 @@ type WireResourceInput struct {
// swagger:ignore
// Deprecated
// fitler by wire id
WireId string `json:"wire_id" "yunion:deprecated-by":"wire"`
WireId string `json:"wire_id" yunion-deprecated-by:"wire"`
}
type WireFilterListBase struct {
@@ -47,7 +47,7 @@ type NetworkResourceInput struct {
// swagger:ignore
// Deprecated
// filter by networkId
NetworkId string `json:"network_id" "yunion:deprecated-by":"network"`
NetworkId string `json:"network_id" yunion-deprecated-by:"network"`
}
type NetworkFilterListBase struct {

View File

@@ -134,9 +134,15 @@ type ScalingGroupDetails struct {
// example: OneCloud
Brand string `json:"brand"`
// description: 网络ID
// example: net-12345
Networks []string `json:"networks"`
// description: 网络信息
Networks []ScalingGroupNetwork `json:"networks"`
}
type ScalingGroupNetwork struct {
Id string `json:"id"`
Name string `json:"name"`
GuestIpStart string `json:"guest_ip_start"`
GuestIpEnd string `json:"guest_ip_end"`
}
type ScalingGroupResourceInfo struct {

View File

@@ -45,7 +45,7 @@ type SchedtagResourceInput struct {
// swagger:ignore
// Deprecated
// filter by schedtag_id
SchedtagId string `json:"schedtag_id" "yunion:deprecated-by":"schedtag"`
SchedtagId string `json:"schedtag_id" yunion-deprecated-by:"schedtag"`
}
type SchedtagFilterListInput struct {
@@ -69,7 +69,7 @@ type SchedtagListInput struct {
// swagger:ignore
// Deprecated
// filter by type, alias for resource_type
Type string `json:"type" "yunion:deprecated-by":"resource_type"`
Type string `json:"type" yunion-deprecated-by:"resource_type"`
DefaultStrategy []string `json:"default_strategy"`
}

View File

@@ -174,6 +174,8 @@ type SecurityGroupRuleListInput struct {
apis.ResourceBaseListInput
SecgroupFilterListInput
Projects []string `json:"projects"`
// 以direction字段过滤安全组规则
Direction string `json:"direction"`
// 以action字段过滤安全组规则
@@ -192,12 +194,10 @@ type SecgroupResourceInput struct {
// swagger:ignore
// Deprecated
// filter by secgroup_id
SecgroupId string `json:"secgroup_id" "yunion:deprecated-by":"secgroup"`
SecgroupId string `json:"secgroup_id" yunion-deprecated-by:"secgroup"`
// 模糊匹配安全组规则名称
SecgroupName string `json:"secgroup_name"`
apis.ProjectizedResourceInput
}
type SecgroupFilterListInput struct {

View File

@@ -81,6 +81,7 @@ const (
STORAGE_GOOGLE_LOCAL_SSD = "local-ssd" //本地SSD暂存盘 (最多8个)
STORAGE_GOOGLE_PD_STANDARD = "pd-standard" //标准永久性磁盘
STORAGE_GOOGLE_PD_SSD = "pd-ssd" //SSD永久性磁盘
STORAGE_GOOGLE_PD_BALANCED = "pd-balanced" //平衡永久性磁盘
// ctyun storage type
STORAGE_CTYUN_SSD = "SSD" // 超高IO云硬盘
@@ -127,7 +128,7 @@ var (
STORAGE_ZSTACK_LOCAL_STORAGE, STORAGE_ZSTACK_CEPH, STORAGE_GPFS,
}
HOST_STORAGE_LOCAL_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_ZSTACK_LOCAL_STORAGE}
HOST_STORAGE_LOCAL_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_ZSTACK_LOCAL_STORAGE, STORAGE_OPENSTACK_NOVA}
STORAGE_LIMITED_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_NAS, STORAGE_RBD, STORAGE_NFS, STORAGE_GPFS}
@@ -144,7 +145,7 @@ type StorageResourceInput struct {
// swagger:ignore
// Deprecated
// filter by storage_id
StorageId string `json:"storage_id" "yunion:deprecated-by":"storage"`
StorageId string `json:"storage_id" yunion-deprecated-by:"storage"`
}
type StorageFilterListInputBase struct {

View File

@@ -48,13 +48,13 @@ type StoragecachedimageListInput struct {
Storagecache string `json:"storagecache"`
// Deprecated
// swagger:ignore
StoragecacheId string `json:"storagecache_id" "yunion:deprecated-by":"storagecache"`
StoragecacheId string `json:"storagecache_id" yunion-deprecated-by:"storagecache"`
// 以镜像缓存过滤
Cachedimage string `json:"cachedimage"`
// Deprecated
// swagger:ignore
CachedimageId string `json:"cachedimage_id" "yunion:deprecated-by":"cachedimage"`
CachedimageId string `json:"cachedimage_id" yunion-deprecated-by:"cachedimage"`
// 镜像状态
Status []string `json:"status"`

View File

@@ -80,7 +80,7 @@ type VpcResourceInput struct {
// swagger:ignore
// Deprecated
// filter by vpc Id
VpcId string `json:"vpc_id" "yunion:deprecated-by":"vpc"`
VpcId string `json:"vpc_id" yunion-deprecated-by:"vpc"`
}
type VpcFilterListInputBase struct {

View File

@@ -73,7 +73,7 @@ type IdentityProviderCreateInput struct {
TargetDomain string `json:"target_domain"`
// swagger:ignore
// Deprecated
TargetDomainId string `json:"target_domain_id" "yunion:deprecated-by":"target_domain"`
TargetDomainId string `json:"target_domain_id" yunion-deprecated-by:"target_domain"`
// 新建域的时候是否自动新建第一个项目
AutoCreateProject *bool `json:"auto_create_project"`

View File

@@ -49,22 +49,22 @@ type ProjectFilterListInput struct {
ProjectDomain string `json:"project_domain"`
// swagger:ignore
// Deprecated
ProjectDomainId string `json:"project_domain_id" "yunion:deprecated-by":"project-domain"`
ProjectDomainId string `json:"project_domain_id" yunion-deprecated-by:"project-domain"`
// 以项目ID或Name过滤列表结果
Project string `json:"project"`
// swagger:ignore
// Deprecated
// filter by project_id
ProjectId string `json:"project_id" "yunion:deprecated-by":"project"`
ProjectId string `json:"project_id" yunion-deprecated-by:"project"`
// swagger:ignore
// Deprecated
// filter by tenant
Tenant string `json:"tenant" "yunion:deprecated-by":"project"`
Tenant string `json:"tenant" yunion-deprecated-by:"project"`
// swagger:ignore
// Deprecated
// filter by tenant_id
TenantId string `json:"tenant_id" "yunion:deprecated-by":"project"`
TenantId string `json:"tenant_id" yunion-deprecated-by:"project"`
}
type UserFilterListInput struct {
@@ -79,7 +79,7 @@ type UserFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by user_id
UserId string `json:"user_id" "yunion:deprecated-by":"user"`
UserId string `json:"user_id" yunion-deprecated-by:"user"`
}
type GroupFilterListInput struct {
@@ -94,7 +94,7 @@ type GroupFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by group_id
GroupId string `json:"group_id" "yunion:deprecated-by":"group"`
GroupId string `json:"group_id" yunion-deprecated-by:"group"`
}
type RoleFilterListInput struct {
@@ -109,7 +109,7 @@ type RoleFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by role_id
RoleId string `json:"role_id" "yunion:deprecated-by":"role"`
RoleId string `json:"role_id" yunion-deprecated-by:"role"`
}
type ServiceFilterListInput struct {
@@ -121,7 +121,7 @@ type ServiceFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by service_id
ServiceId string `json:"service_id" "yunion:deprecated-by":"service"`
ServiceId string `json:"service_id" yunion-deprecated-by:"service"`
// 以服务名称排序
OrderByService string `json:"order_by_service"`
@@ -325,7 +325,7 @@ type RegionFilterListInput struct {
Region string `json:"region"`
// swagger:ignore
// Deprecated
RegionId string `json:"region_id" "yunion:deprecated-by":"region"`
RegionId string `json:"region_id" yunion-deprecated-by:"region"`
}
type RegionListInput struct {

View File

@@ -48,6 +48,7 @@ const (
IMAGE_IS_READONLY = "is_readonly"
IMAGE_PARTITION_TYPE = "partition_type"
IMAGE_INSTALLED_CLOUDINIT = "installed_cloud_init"
IMAGE_DISABLE_USB_KBD = "disable_usb_kbd"
IMAGE_STATUS_UPDATING = "updating"
)

View File

@@ -88,3 +88,12 @@ type ImageCreateInput struct {
// 镜像属性
Properties map[string]string `json:"properties"`
}
type ImageUpdateStatusInput struct {
apis.Meta
// 镜像状态
Status string `json:"status"`
// 更新镜像状态原因
Reason string `json:"reason"`
}

View File

@@ -21,15 +21,15 @@ type DomainizedResourceInput struct {
// swagger:ignore
// Deprecated
Domain string `json:"domain" "yunion:deprecated-by":"project_domain"`
Domain string `json:"domain" yunion-deprecated-by:"project_domain"`
// swagger:ignore
// Deprecated
// Project domain Id filter, alias for project_domain
ProjectDomainId string `json:"project_domain_id" "yunion:deprecated-by":"project_domain"`
ProjectDomainId string `json:"project_domain_id" yunion-deprecated-by:"project_domain"`
// swagger:ignore
// Deprecated
// Domain Id filter, alias for project_domain
DomainId string `json:"domain_id" "yunion:deprecated-by":"project_domain"`
DomainId string `json:"domain_id" yunion-deprecated-by:"project_domain"`
}
type ProjectizedResourceInput struct {
@@ -39,15 +39,15 @@ type ProjectizedResourceInput struct {
// swagger:ignore
// Deprecated
// Filter by project_id, alias for project
ProjectId string `json:"project_id" "yunion:deprecated-by":"project"`
ProjectId string `json:"project_id" yunion-deprecated-by:"project"`
// swagger:ignore
// Deprecated
// Filter by tenant ID or Name, alias for project
Tenant string `json:"tenant" "yunion:deprecated-by":"project"`
Tenant string `json:"tenant" yunion-deprecated-by:"project"`
// swagger:ignore
// Deprecated
// Filter by tenant_id, alias for project
TenantId string `json:"tenant_id" "yunion:deprecated-by":"project"`
TenantId string `json:"tenant_id" yunion-deprecated-by:"project"`
}
type DomainizedResourceCreateInput struct {
@@ -75,6 +75,27 @@ type SharableVirtualResourceCreateInput struct {
SharableResourceBaseCreateInput
}
type AdminSharableVirtualResourceBaseCreateInput struct {
SharableVirtualResourceCreateInput
// 记录
Records string `json:"records"`
}
type StatusDomainLevelUserResourceCreateInput struct {
StatusDomainLevelResourceCreateInput
// 本地用户Id若为空则使用当前用户Id作为此参数值
OwnerId string `json:"owner_id"`
}
type UserResourceCreateInput struct {
StandaloneResourceCreateInput
// 本地用户Id若为空则使用当前用户Id作为此参数值
OwnerId string `json:"owner_id"`
}
type VirtualResourceCreateInput struct {
StatusStandaloneResourceCreateInput
ProjectizedResourceCreateInput

View File

@@ -50,7 +50,7 @@ type ProjectizedResourceListInput struct {
OrderByProject string `json:"order_by_project"`
// swagger:ignore
// Deprecated
OrderByTenant string `json:"order_by_tenant" "yunion:deprecated-by":"order_by_project"`
OrderByTenant string `json:"order_by_tenant" yunion-deprecated-by:"order_by_project"`
}
type UserResourceListInput struct {
@@ -59,7 +59,7 @@ type UserResourceListInput struct {
// swagger:ignore
// Deprecated
// Filter by userId
UserId string `json:"user_id" "yunion:deprecated-by":"user"`
UserId string `json:"user_id" yunion-deprecated-by:"user"`
}
type ModelBaseListInput struct {

View File

@@ -137,11 +137,11 @@ type ProjectizedResourceInfo struct {
// 资源归属项目的ID(向后兼容别名)
// Deprecated
TenantId string `json:"project_id" "yunion:deprecated-by":"tenant_id"`
TenantId string `json:"project_id" yunion-deprecated-by:"tenant_id"`
// 资源归属项目的名称(向后兼容别名)
// Deprecated
Tenant string `json:"project" "yunion:deprecated-by":"tenant"`
Tenant string `json:"project" yunion-deprecated-by:"tenant"`
}
type ScopedResourceBaseInfo struct {

View File

@@ -28,14 +28,14 @@ type ParameterListInput struct {
// Deprecated
// swagger:ignore
ServiceId string `json:"service_id" "yunion:deprecated-by":"service"`
ServiceId string `json:"service_id" yunion-deprecated-by:"service"`
// 用户名称或ID
User string `json:"user"`
// Deprecated
// swagger:ignore
UserId string `json:"user_id" "yunion:deprecated-by":"user"`
UserId string `json:"user_id" yunion-deprecated-by:"user"`
// filter by name
Name []string `json:"name"`

View File

@@ -269,6 +269,9 @@ func (req *dhcpRequest) findNetworkConf(session *mcclient.ClientSession, filterU
params.Add(jsonutils.NewString(
fmt.Sprintf("guest_dhcp.endswith(',%s')", req.RelayAddr)),
"filter.3")
params.Add(jsonutils.NewString(
fmt.Sprintf("guest_dhcp.equals(%s)", req.RelayAddr)),
"filter.4")
params.Add(jsonutils.JSONTrue, "filter_any")
}
params.Add(jsonutils.JSONTrue, "is_on_premise")

View File

@@ -249,11 +249,17 @@ func (adapter *HPSARaidAdaptor) buildRaid(level string, devs []*baremetal.Bareme
return fmt.Errorf("getLastArray: %v", err)
}
cmds := []string{}
for _, sz := range conf.Size[1:] {
restSize := conf.Size[1:]
for idx, sz := range restSize {
isLast := idx == len(restSize)-1
sizeStr := fmt.Sprintf("size=%d", sz)
if isLast {
sizeStr = "size=max"
}
args = []string{"controller", fmt.Sprintf("slot=%d", adapter.index),
"array", array, "create", "type=ld",
fmt.Sprintf("raid=%s", level),
fmt.Sprintf("size=%d", sz),
sizeStr,
}
args = append(args, params...)
cmds = append(cmds, GetCommand(args...))

View File

@@ -51,7 +51,22 @@ func (manager *SAdminSharableVirtualResourceBaseManager) GetIAdminSharableVirtua
return manager.GetVirtualObject().(IAdminSharableVirtualModelManager)
}
func (manager *SAdminSharableVirtualResourceBaseManager) ValidateCreateData(man IAdminSharableVirtualModelManager, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
func (manager *SAdminSharableVirtualResourceBaseManager) ValidateCreateData(
ctx context.Context,
userCred mcclient.TokenCredential,
ownerId mcclient.IIdentityProvider,
query jsonutils.JSONObject,
input apis.AdminSharableVirtualResourceBaseCreateInput,
) (apis.AdminSharableVirtualResourceBaseCreateInput, error) {
var err error
input.SharableVirtualResourceCreateInput, err = manager.SSharableVirtualResourceBaseManager.ValidateCreateData(ctx, userCred, ownerId, query, input.SharableVirtualResourceCreateInput)
if err != nil {
return input, errors.Wrap(err, "SSharableVirtualResourceBaseManager.ValidateCreateData")
}
return input, nil
}
func (manager *SAdminSharableVirtualResourceBaseManager) ValidateRecordsData(man IAdminSharableVirtualModelManager, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
records, err := man.ParseInputInfo(data)
if err != nil {
return nil, err

View File

@@ -77,6 +77,10 @@ func (model *SDomainizedResourceBase) GetChangeOwnerCandidateDomainIds() []strin
return nil
}
func (model *SDomainizedResourceBase) GetChangeOwnerRequiredDomainIds() []string {
return nil
}
func ValidateCreateDomainId(domainId string) error {
if !consts.GetNonDefaultDomainProjects() && domainId != identity.DEFAULT_DOMAIN_ID {
return httperrors.NewForbiddenError("project in non-default domain is prohibited")

View File

@@ -24,6 +24,7 @@ import (
"yunion.io/x/sqlchemy"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/logclient"
@@ -133,6 +134,9 @@ func (model *SDomainLevelResourceBase) AllowPerformChangeOwner(ctx context.Conte
}
func (model *SDomainLevelResourceBase) PerformChangeOwner(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformChangeDomainOwnerInput) (jsonutils.JSONObject, error) {
if !consts.GetNonDefaultDomainProjects() {
return nil, errors.Wrap(httperrors.ErrForbidden, "not allow to change owner of domain resource if non_default_domain_projects is turned off")
}
if model.GetIStandaloneModel().IsShared() {
return nil, errors.Wrap(httperrors.ErrForbidden, "cannot change owner of shared resource")
}
@@ -162,6 +166,11 @@ func (model *SDomainLevelResourceBase) PerformChangeOwner(ctx context.Context, u
if len(candidates) > 0 && !utils.IsInStringArray(ownerId.GetProjectDomainId(), candidates) {
return nil, errors.Wrap(httperrors.ErrForbidden, "target domain not in change owner candidate list")
}
requires := model.GetIDomainLevelModel().GetChangeOwnerRequiredDomainIds()
log.Debugf("%s required domains: %s", model.Keyword(), requires)
if len(requires) > 0 && !utils.IsInStringArray(ownerId.GetProjectDomainId(), requires) {
return nil, errors.Wrap(httperrors.ErrForbidden, "target domain not in change owner required list")
}
if !IsAdminAllowPerform(userCred, model, "change-owner") {
return nil, errors.Wrap(httperrors.ErrNotSufficientPrivilege, "require system privileges")

View File

@@ -22,6 +22,7 @@ import (
"yunion.io/x/sqlchemy"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
@@ -200,6 +201,9 @@ func (model *SInfrasResourceBase) PerformChangeOwner(
query jsonutils.JSONObject,
input apis.PerformChangeDomainOwnerInput,
) (jsonutils.JSONObject, error) {
if !consts.GetNonDefaultDomainProjects() {
return nil, errors.Wrap(httperrors.ErrForbidden, "not allow to change owner of domain resource if non_default_domain_projects is turned off")
}
if model.IsShared() {
return nil, errors.Wrap(httperrors.ErrInvalidStatus, "cannot change owner when shared!")
}

View File

@@ -26,7 +26,8 @@ func TestEctdLockManager(t *testing.T) {
shared := newSharedObject()
for i := 0; i < 4; i++ {
lockman, err := NewEtcdLockManager(&SEtcdLockManagerConfig{
Endpoints: []string{"localhost:2379"},
LockPrefix: "test-etcd-lock-manager",
Endpoints: []string{"localhost:2379"},
})
if err != nil {
t.Skipf("new etcd lockman: %v", err)

View File

@@ -22,6 +22,7 @@ import (
type IOwnerResourceBaseModel interface {
GetChangeOwnerCandidateDomainIds() []string
GetChangeOwnerRequiredDomainIds() []string
}
type IManagedResourceBase interface {

View File

@@ -16,6 +16,7 @@ package db
import (
"context"
"database/sql"
"fmt"
"strconv"
"strings"
@@ -460,28 +461,7 @@ func (manager *SOpsLogManager) ListItemFilter(
userCred mcclient.TokenCredential,
query jsonutils.JSONObject,
) (*sqlchemy.SQuery, error) {
/*userStrs := jsonutils.GetQueryStringArray(query, "user")
if len(userStrs) > 0 {
for i := range userStrs {
usrObj, err := DefaultUserFetcher(ctx, userStrs[i])
if err != nil {
if err == sql.ErrNoRows {
return nil, httperrors.NewResourceNotFoundError2("user", userStrs[i])
} else if err == sqlchemy.ErrDuplicateEntry {
return nil, httperrors.NewDuplicateNameError("user", userStrs[i])
} else {
return nil, httperrors.NewGeneralError(err)
}
}
userStrs[i] = usrObj.GetId()
}
if len(userStrs) == 1 {
q = q.Filter(sqlchemy.Equals(q.Field("user_id"), userStrs[0]))
} else {
q = q.Filter(sqlchemy.In(q.Field("user_id"), userStrs))
}
}
projStrs := jsonutils.GetQueryStringArray(query, "project")
projStrs := jsonutils.GetQueryStringArray(query, "owner_project_ids")
if len(projStrs) > 0 {
for i := range projStrs {
projObj, err := DefaultProjectFetcher(ctx, projStrs[i])
@@ -494,12 +474,23 @@ func (manager *SOpsLogManager) ListItemFilter(
}
projStrs[i] = projObj.GetId()
}
if len(projStrs) == 1 {
q = q.Filter(sqlchemy.Equals(q.Field("owner_tenant_id"), projStrs[0]))
} else {
q = q.Filter(sqlchemy.In(q.Field("owner_tenant_id"), projStrs))
q = q.Filter(sqlchemy.In(q.Field("owner_tenant_id"), projStrs))
}
domainStrs := jsonutils.GetQueryStringArray(query, "owner_domain_ids")
if len(domainStrs) > 0 {
for i := range domainStrs {
domainObj, err := DefaultDomainFetcher(ctx, domainStrs[i])
if err != nil {
if err == sql.ErrNoRows {
return nil, httperrors.NewResourceNotFoundError2("domain", domainStrs[i])
} else {
return nil, httperrors.NewGeneralError(err)
}
}
domainStrs[i] = domainObj.GetId()
}
}*/
q = q.Filter(sqlchemy.In(q.Field("owner_domain_id"), domainStrs))
}
objTypes := jsonutils.GetQueryStringArray(query, "obj_type")
if len(objTypes) > 0 {
if len(objTypes) == 1 {

View File

@@ -71,6 +71,7 @@ type IQuotaManager interface {
checkSetPendingQuota(ctx context.Context, userCred mcclient.TokenCredential, quota IQuota) error
cancelPendingUsage(ctx context.Context, userCred mcclient.TokenCredential, localUsage IQuota, cancelUsage IQuota, save bool) error
cancelUsage(ctx context.Context, userCred mcclient.TokenCredential, usage IQuota) error
addUsage(ctx context.Context, userCred mcclient.TokenCredential, usage IQuota) error
getQuotaCount(ctx context.Context, request IQuota, pendingKey IQuotaKeys) (int, error)
FetchIdNames(ctx context.Context, idMap map[string]map[string]string) (map[string]map[string]string, error)

View File

@@ -113,6 +113,17 @@ func (manager *SQuotaBaseManager) _cancelUsage(ctx context.Context, userCred mcc
return manager.changeUsage(ctx, userCred, usage, false)
}
func (manager *SQuotaBaseManager) addUsage(ctx context.Context, userCred mcclient.TokenCredential, usage IQuota) error {
LockQuota(ctx, manager, usage)
defer ReleaseQuota(ctx, manager, usage)
return manager._addUsage(ctx, userCred, usage)
}
func (manager *SQuotaBaseManager) _addUsage(ctx context.Context, userCred mcclient.TokenCredential, usage IQuota) error {
return manager.changeUsage(ctx, userCred, usage, true)
}
func (manager *SQuotaBaseManager) changeUsage(ctx context.Context, userCred mcclient.TokenCredential, usage IQuota, isAdd bool) error {
usages, err := manager.usageStore.GetParentQuotas(ctx, usage.GetKeys())
if err != nil {

View File

@@ -87,6 +87,20 @@ func cancelUsage(ctx context.Context, userCred mcclient.TokenCredential, usage I
}
}
func AddUsages(ctx context.Context, userCred mcclient.TokenCredential, usages []db.IUsage) {
for _, usage := range usages {
addUsage(ctx, userCred, usage.(IQuota))
}
}
func addUsage(ctx context.Context, userCred mcclient.TokenCredential, usage IQuota) {
manager := getQuotaManager(usage)
err := manager.addUsage(ctx, userCred, usage)
if err != nil {
log.Errorf("cancelUsage %s fail: %s", jsonutils.Marshal(usage), err)
}
}
func GetQuotaCount(ctx context.Context, request IQuota, pendingKeys IQuotaKeys) (int, error) {
manager := getQuotaManager(request)
return manager.getQuotaCount(ctx, request, pendingKeys)

View File

@@ -126,7 +126,7 @@ func RawNotify(recipientId []string, isGroup bool, channel notify.TNotifyChannel
msg.Topic = topic
body, _ := getContent(event, "content", channel, data)
if len(body) == 0 {
body = data.String()
body, _ = data.GetString()
}
msg.Msg = body
// log.Debugf("send notification %s %s", topic, body)

View File

@@ -29,6 +29,11 @@ var (
Action: PolicyActionPerform,
Result: rbacutils.Allow,
},
{
Resource: "metadatas",
Action: PolicyActionList,
Result: rbacutils.Allow,
},
},
},
{

View File

@@ -190,6 +190,8 @@ type ICloudProviderFactory interface {
IsCloudeventRegional() bool
GetMaxCloudEventSyncDays() int
GetMaxCloudEventKeepDays() int
IsNeedForceAutoCreateProject() bool
}
type ICloudProvider interface {
@@ -215,6 +217,8 @@ type ICloudProvider interface {
GetCloudRegionExternalIdPrefix() string
GetStorageClasses(regionId string) []string
GetBucketCannedAcls(regionId string) []string
GetObjectCannedAcls(regionId string) []string
GetCapabilities() []string
GetICloudQuotas() ([]ICloudQuota, error)
@@ -408,6 +412,10 @@ func (factory *baseProviderFactory) GetMaxCloudEventKeepDays() int {
return 7
}
func (factory *baseProviderFactory) IsNeedForceAutoCreateProject() bool {
return false
}
type SPremiseBaseProviderFactory struct {
baseProviderFactory
}

View File

@@ -88,6 +88,7 @@ type SDBInstanceBackupCreateConfig struct {
}
type SDBInstanceRecoveryConfig struct {
BackupId string
Databases map[string]string
BackupId string
Databases map[string]string
OriginDBInstanceExternalId string
}

View File

@@ -97,7 +97,7 @@ func (region *SFakeOnPremiseRegion) GetISecurityGroupById(id string) (ICloudSecu
return nil, ErrNotSupported
}
func (region *SFakeOnPremiseRegion) GetISecurityGroupByName(vpcId string, name string) (ICloudSecurityGroup, error) {
func (region *SFakeOnPremiseRegion) GetISecurityGroupByName(opts *SecurityGroupFilterOptions) (ICloudSecurityGroup, error) {
return nil, ErrNotSupported
}

View File

@@ -0,0 +1,22 @@
// 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 cloudprovider
type SNetworkCreateOptions struct {
Name string
Desc string
ProjectId string
Cidr string
}

View File

@@ -23,6 +23,7 @@ import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/billing"
"yunion.io/x/onecloud/pkg/util/rbacutils"
)
type ICloudResource interface {
@@ -70,7 +71,7 @@ type ICloudRegion interface {
GetIDiskById(id string) (ICloudDisk, error)
GetISecurityGroupById(secgroupId string) (ICloudSecurityGroup, error)
GetISecurityGroupByName(vpcId string, name string) (ICloudSecurityGroup, error)
GetISecurityGroupByName(opts *SecurityGroupFilterOptions) (ICloudSecurityGroup, error)
CreateISecurityGroup(conf *SecurityGroupCreateInput) (ICloudSecurityGroup, error)
CreateIVpc(name string, desc string, cidr string) (ICloudVpc, error)
@@ -342,7 +343,7 @@ type ICloudEIP interface {
}
type ICloudSecurityGroup interface {
ICloudResource
IVirtualResource
GetDescription() string
GetRules() ([]SecurityRule, error)
@@ -450,7 +451,7 @@ type ICloudWire interface {
GetINetworkById(netid string) (ICloudNetwork, error)
CreateINetwork(name string, cidr string, desc string) (ICloudNetwork, error)
CreateINetwork(opts *SNetworkCreateOptions) (ICloudNetwork, error)
}
type ICloudNetwork interface {
@@ -463,8 +464,11 @@ type ICloudNetwork interface {
GetIpMask() int8
GetGateway() string
GetServerType() string
// GetIsPublic() bool
// GetPublicScope() rbacutils.TRbacScope
//GetIsPublic() bool
// 仅私有云有用,公有云无效
// 1. scope = none 非共享, network仅会属于一个项目,并且私有
// 2. scope = system 系统共享 云账号共享会跟随云账号共享,云账号非共享,会共享到network所在域
GetPublicScope() rbacutils.TRbacScope
Delete() error

View File

@@ -24,11 +24,18 @@ import (
const DEFAULT_CLOUD_RULE_ID = "default_cloud_rule_id"
type SecurityGroupFilterOptions struct {
VpcId string
Name string
ProjectId string
}
type SecurityGroupCreateInput struct {
Name string
Desc string
VpcId string
Rules []secrules.SecurityRule
Name string
Desc string
VpcId string
ProjectId string
Rules []secrules.SecurityRule
}
type SecurityRule struct {

View File

@@ -368,3 +368,42 @@ func (self *SESXiGuestDriver) RequestAssociateEip(ctx context.Context, userCred
func (self *SESXiGuestDriver) IsSupportCdrom(guest *models.SGuest) (bool, error) {
return false, nil
}
func (self *SESXiGuestDriver) RequestSyncstatusOnHost(ctx context.Context, guest *models.SGuest, host *models.SHost, userCred mcclient.TokenCredential) (jsonutils.JSONObject, error) {
ihost, err := host.GetIHost()
if err != nil {
return nil, err
}
ivm, err := ihost.GetIVMById(guest.GetExternalId())
if err != nil && errors.Cause(err) != errors.ErrNotFound {
return nil, err
}
// VM may be migrated by Vcenter, try to find VM from whole datacenter.
if err != nil {
ehost := ihost.(*esxi.SHost)
dc, err := ehost.GetDatacenter()
if err != nil {
return nil, errors.Wrapf(err, "ehost.GetDatacenter")
}
vm, err := dc.FetchVMById(guest.GetExternalId())
if err != nil {
log.Errorf("fail to find ivm by id %q in dc %q: %v", guest.GetExternalId(), dc.GetName(), err)
return nil, err
}
ihost = vm.GetIHost()
host = models.HostManager.FetchHostByExtId(ihost.GetGlobalId())
if host == nil {
return nil, errors.Wrapf(errors.ErrNotFound, "find ivm %q in ihost %q which is not existed here", guest.GetExternalId(), ihost.GetGlobalId())
}
ivm = vm
}
err = guest.SyncAllWithCloudVM(ctx, userCred, host, ivm)
if err != nil {
return nil, err
}
status := GetCloudVMStatus(ivm)
body := jsonutils.NewDict()
body.Add(jsonutils.NewString(status), "status")
return body, nil
}

View File

@@ -77,6 +77,7 @@ func (self *SGoogleGuestDriver) GetStorageTypes() []string {
return []string{
api.STORAGE_GOOGLE_PD_SSD,
api.STORAGE_GOOGLE_PD_STANDARD,
api.STORAGE_GOOGLE_PD_BALANCED,
api.STORAGE_GOOGLE_LOCAL_SSD,
}
}
@@ -113,7 +114,7 @@ func (self *SGoogleGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *m
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
if !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD}) {
if !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD, api.STORAGE_GOOGLE_PD_BALANCED}) {
return fmt.Errorf("Cannot resize %s disk", storage.StorageType)
}
return nil
@@ -132,13 +133,15 @@ func (self *SGoogleGuestDriver) ValidateCreateData(ctx context.Context, userCred
minGB := -1
maxGB := -1
switch disk.Backend {
case api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD:
case api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD, api.STORAGE_GOOGLE_PD_BALANCED:
minGB = 10
maxGB = 65536
case api.STORAGE_GOOGLE_LOCAL_SSD:
minGB = 375
maxGB = 375
localDisk++
default:
return nil, httperrors.NewInputParameterError("Unknown google storage type %s", disk.Backend)
}
if i == 0 && disk.Backend == api.STORAGE_GOOGLE_LOCAL_SSD {
return nil, httperrors.NewInputParameterError("System disk does not support %s disk", disk.Backend)

View File

@@ -321,7 +321,7 @@ func (self *SManagedVirtualizedGuestDriver) RequestDeployGuestOnHost(ctx context
secgroups := guest.GetSecgroups()
for i, secgroup := range secgroups {
externalId, err := region.GetDriver().RequestSyncSecurityGroup(ctx, task.GetUserCred(), vpcId, vpc, &secgroup)
externalId, err := region.GetDriver().RequestSyncSecurityGroup(ctx, task.GetUserCred(), vpcId, vpc, &secgroup, desc.ProjectId)
if err != nil {
return errors.Wrap(err, "RequestSyncSecurityGroup")
}
@@ -435,8 +435,8 @@ func (self *SManagedVirtualizedGuestDriver) RemoteDeployGuestForCreate(ctx conte
}
iVM, err := func() (cloudprovider.ICloudVM, error) {
lockman.LockObject(ctx, host)
defer lockman.ReleaseObject(ctx, host)
lockman.LockObject(ctx, guest)
defer lockman.ReleaseObject(ctx, guest)
iVM, err := ihost.CreateVM(&desc)
if err != nil {
@@ -976,10 +976,19 @@ func (self *SManagedVirtualizedGuestDriver) RequestSyncSecgroupsOnHost(ctx conte
return errors.Wrap(err, "GetSecurityGroupVpcId")
}
remoteProjectId := ""
provider := host.GetCloudprovider()
if provider != nil {
remoteProjectId, err = provider.SyncProject(ctx, task.GetUserCred(), guest.ProjectId)
if err != nil {
log.Errorf("failed to sync project %s for guest %s error: %v", guest.ProjectId, guest.Name, err)
}
}
secgroups := guest.GetSecgroups()
externalIds := []string{}
for _, secgroup := range secgroups {
externalId, err := region.GetDriver().RequestSyncSecurityGroup(ctx, task.GetUserCred(), vpcId, vpc, &secgroup)
externalId, err := region.GetDriver().RequestSyncSecurityGroup(ctx, task.GetUserCred(), vpcId, vpc, &secgroup, remoteProjectId)
if err != nil {
return errors.Wrap(err, "RequestSyncSecurityGroup")
}

View File

@@ -114,6 +114,10 @@ func (self *SOpenStackGuestDriver) IsNeedInjectPasswordByCloudInit(desc *cloudpr
return true
}
func (self *SOpenStackGuestDriver) IsWindowsUserDataTypeNeedEncode() bool {
return true
}
func (self *SOpenStackGuestDriver) IsNeedRestartForResetLoginInfo() bool {
return false
}

View File

@@ -48,7 +48,7 @@ func (self *SGoogleHostDriver) ValidateDiskSize(storage *models.SStorage, sizeGb
minGB := 10
maxGB := -1
switch storage.StorageType {
case api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD:
case api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD, api.STORAGE_GOOGLE_PD_BALANCED:
maxGB = 65536
default:
return fmt.Errorf("Not support resize %s disk", storage.StorageType)

View File

@@ -28,6 +28,7 @@ import (
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/compare"
"yunion.io/x/pkg/utils"
"yunion.io/x/sqlchemy"
api "yunion.io/x/onecloud/pkg/apis/compute"
@@ -198,7 +199,13 @@ func (manager *SBucketManager) newFromCloudBucket(
stats := extBucket.GetStats()
bucket.SizeBytes = stats.SizeBytes
if bucket.SizeBytes < 0 {
bucket.SizeBytes = 0
}
bucket.ObjectCnt = stats.ObjectCount
if bucket.ObjectCnt < 0 {
bucket.ObjectCnt = 0
}
limit := extBucket.GetLimit()
limitSupport := extBucket.LimitSupport()
@@ -258,7 +265,13 @@ func (bucket *SBucket) syncWithCloudBucket(
diff, err := db.UpdateWithLock(ctx, bucket, func() error {
stats := extBucket.GetStats()
bucket.SizeBytes = stats.SizeBytes
if bucket.SizeBytes < 0 {
bucket.SizeBytes = 0
}
bucket.ObjectCnt = stats.ObjectCount
if bucket.ObjectCnt < 0 {
bucket.ObjectCnt = 0
}
if !statsOnly {
limit := extBucket.GetLimit()
@@ -420,6 +433,16 @@ func (manager *SBucketManager) ValidateCreateData(
return input, httperrors.NewInputParameterError("invalid bucket name %s: %s", input.Name, err)
}
if len(input.StorageClass) > 0 {
driver, err := managerV.GetProvider()
if err != nil {
return input, errors.Wrap(err, "GetProvider")
}
if !utils.IsInStringArray(input.StorageClass, driver.GetStorageClasses(cloudRegionV.Id)) {
return input, errors.Wrapf(httperrors.ErrInputParameter, "invalid storage class %s", input.StorageClass)
}
}
quotaKeys := fetchRegionalQuotaKeys(rbacutils.ScopeProject, ownerId, cloudRegionV, managerV)
pendingUsage := SRegionQuota{Bucket: 1}
pendingUsage.SetKeys(quotaKeys)
@@ -956,14 +979,17 @@ func (bucket *SBucket) PerformUpload(
return nil, httperrors.NewInputParameterError("Content-Length negative %d", sizeBytes)
}
storageClass := appParams.Request.Header.Get(api.BUCKET_UPLOAD_OBJECT_STORAGECLASS_HEADER)
driver, err := bucket.GetDriver()
if err != nil {
return nil, errors.Wrap(err, "GetDriver")
}
if len(storageClass) > 0 && !utils.IsInStringArray(storageClass, driver.GetStorageClasses(bucket.CloudregionId)) {
return nil, errors.Wrapf(httperrors.ErrInputParameter, "invalid storage class %s", storageClass)
}
aclStr := appParams.Request.Header.Get(api.BUCKET_UPLOAD_OBJECT_ACL_HEADER)
if len(aclStr) > 0 {
switch cloudprovider.TBucketACLType(aclStr) {
case cloudprovider.ACLPrivate, cloudprovider.ACLAuthRead, cloudprovider.ACLPublicRead, cloudprovider.ACLPublicReadWrite:
// do nothing
default:
return nil, httperrors.NewInputParameterError("invalid acl: %s", aclStr)
}
if len(aclStr) > 0 && !utils.IsInStringArray(aclStr, driver.GetObjectCannedAcls(bucket.CloudregionId)) {
return nil, errors.Wrapf(httperrors.ErrInputParameter, "invalid acl %s", aclStr)
}
inc := cloudprovider.SBucketStats{}
@@ -1038,15 +1064,23 @@ func (bucket *SBucket) PerformAcl(
) (jsonutils.JSONObject, error) {
err := input.Validate()
if err != nil {
return nil, err
return nil, errors.Wrap(err, "ValidateInput")
}
provider, err := bucket.GetDriver()
if err != nil {
return nil, errors.Wrap(err, "GetDriver")
}
iBucket, objects, err := bucket.processObjectsActionInput(input.BucketObjectsActionInput)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "processObjectsActionInput")
}
if len(objects) == 0 {
if !utils.IsInStringArray(string(input.Acl), provider.GetBucketCannedAcls(bucket.CloudregionId)) {
return nil, errors.Wrapf(httperrors.ErrInputParameter, "unsupported bucket canned acl %s", input.Acl)
}
err = iBucket.SetAcl(input.Acl)
if err != nil {
return nil, httperrors.NewInternalServerError("setAcl error %s", err)
@@ -1059,6 +1093,10 @@ func (bucket *SBucket) PerformAcl(
return nil, nil
}
if !utils.IsInStringArray(string(input.Acl), provider.GetObjectCannedAcls(bucket.CloudregionId)) {
return nil, errors.Wrapf(httperrors.ErrInputParameter, "unsupported object canned acl %s", input.Acl)
}
errs := make([]error, 0)
for _, object := range objects {
err := object.SetAcl(input.Acl)

View File

@@ -35,7 +35,6 @@ import (
"yunion.io/x/onecloud/pkg/apis"
proxyapi "yunion.io/x/onecloud/pkg/apis/cloudcommon/proxy"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/proxy"
@@ -47,7 +46,6 @@ import (
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/multicloud/esxi/vcenter"
"yunion.io/x/onecloud/pkg/util/choices"
"yunion.io/x/onecloud/pkg/util/httputils"
@@ -342,17 +340,37 @@ func (manager *SCloudaccountManager) ValidateCreateData(
return input, err
}
if len(input.Project) > 0 {
_, input.ProjectizedResourceInput, err = db.ValidateProjectizedResourceInput(ctx, input.ProjectizedResourceInput)
if err != nil {
return input, errors.Wrap(err, "db.ValidateProjectizedResourceInput")
}
}
if !cloudprovider.IsSupported(input.Provider) {
return input, httperrors.NewInputParameterError("Unsupported provider %s", input.Provider)
}
providerDriver, _ := cloudprovider.GetProviderFactory(input.Provider)
forceAutoCreateProject := providerDriver.IsNeedForceAutoCreateProject()
if forceAutoCreateProject {
input.AutoCreateProject = &forceAutoCreateProject
}
if len(input.Project) > 0 {
var proj *db.STenant
proj, input.ProjectizedResourceInput, err = db.ValidateProjectizedResourceInput(ctx, input.ProjectizedResourceInput)
if err != nil {
return input, errors.Wrap(err, "db.ValidateProjectizedResourceInput")
}
if proj.DomainId != ownerId.GetProjectDomainId() {
return input, httperrors.NewInputParameterError("Project %s(%s) not belong to domain %s(%s)", proj.Name, proj.Id, ownerId.GetProjectDomain(), ownerId.GetProjectDomainId())
}
if input.AutoCreateProject != nil && *input.AutoCreateProject {
log.Warningf("project_id and auto_create_project should not be turned on at the same time")
}
if !forceAutoCreateProject {
input.AutoCreateProject = nil
}
} else if input.AutoCreateProject == nil || !*input.AutoCreateProject {
log.Warningf("auto_create_project is off while no project_id specified")
createProject := true
input.AutoCreateProject = &createProject
}
input.SCloudaccount, err = providerDriver.ValidateCreateCloudaccountData(ctx, userCred, input.SCloudaccountCredential)
if err != nil {
return input, err
@@ -430,20 +448,6 @@ func (manager *SCloudaccountManager) ValidateCreateData(
input.SyncIntervalSeconds = options.Options.MinimalSyncIntervalSeconds
}
if !input.AutoCreateProject {
if userCred.GetProjectDomainId() != ownerId.GetProjectDomainId() {
s := auth.GetAdminSession(ctx, consts.GetRegion(), "v1")
params := jsonutils.Marshal(map[string]string{"domain_id": ownerId.GetProjectDomainId()})
tenants, err := modules.Projects.List(s, params)
if err != nil {
return input, err
}
if tenants.Total == 0 {
return input, httperrors.NewInputParameterError("There is no projects under the domain %s", ownerId.GetProjectDomainId())
}
}
}
input.EnabledStatusInfrasResourceBaseCreateInput, err = manager.SEnabledStatusInfrasResourceBaseManager.ValidateCreateData(ctx, userCred, ownerId, query, input.EnabledStatusInfrasResourceBaseCreateInput)
if err != nil {
return input, err
@@ -1899,9 +1903,11 @@ func (account *SCloudaccount) SubmitSyncAccountTask(ctx context.Context, userCre
defer cloudaccountPendingSyncsMutex.Unlock()
if _, ok := cloudaccountPendingSyncs[account.Id]; ok {
if waitChan != nil {
// an active cloudaccount sync task is running, return with conflict error
log.Errorf("an active cloudaccount sync task is running, early return with conflict error")
waitChan <- errors.Wrap(httperrors.ErrConflict, "cloudaccountPendingSyncs")
go func() {
// an active cloudaccount sync task is running, return with conflict error
log.Errorf("an active cloudaccount sync task is running, early return with conflict error")
waitChan <- errors.Wrap(httperrors.ErrConflict, "cloudaccountPendingSyncs")
}()
}
return
}

View File

@@ -1563,33 +1563,56 @@ func (provider *SCloudprovider) AllowGetDetailsStorageClasses(
func (provider *SCloudprovider) GetDetailsStorageClasses(
ctx context.Context,
userCred mcclient.TokenCredential,
query jsonutils.JSONObject,
) (jsonutils.JSONObject, error) {
input api.CloudproviderGetStorageClassInput,
) (api.CloudproviderGetStorageClassOutput, error) {
output := api.CloudproviderGetStorageClassOutput{}
driver, err := provider.GetProvider()
if err != nil {
return nil, httperrors.NewInternalServerError("fail to get provider driver %s", err)
return output, httperrors.NewInternalServerError("fail to get provider driver %s", err)
}
extId := ""
regionStr := jsonutils.GetAnyString(query, []string{"cloudregion", "cloudregion_id"})
if len(regionStr) > 0 {
regionObj, err := CloudregionManager.FetchByIdOrName(userCred, regionStr)
if len(input.Cloudregion) > 0 {
_, input.CloudregionResourceInput, err = ValidateCloudregionResourceInput(userCred, input.CloudregionResourceInput)
if err != nil {
if err == sql.ErrNoRows {
return nil, httperrors.NewResourceNotFoundError2(CloudregionManager.Keyword(), regionStr)
} else {
return nil, httperrors.NewGeneralError(err)
}
return output, errors.Wrap(err, "ValidateCloudregionResourceInput")
}
extId = regionObj.(*SCloudregion).GetExternalId()
}
sc := driver.GetStorageClasses(extId)
sc := driver.GetStorageClasses(input.Cloudregion)
if sc == nil {
return nil, httperrors.NewInternalServerError("storage classes not supported")
return output, httperrors.NewInternalServerError("storage classes not supported")
}
ret := jsonutils.NewDict()
ret.Add(jsonutils.NewStringArray(sc), "storage_classes")
return ret, nil
output.StorageClasses = sc
return output, nil
}
func (provider *SCloudprovider) AllowGetDetailsCannedAcls(
ctx context.Context,
userCred mcclient.TokenCredential,
query jsonutils.JSONObject,
) bool {
return db.IsAdminAllowGetSpec(userCred, provider, "canned-acls")
}
func (provider *SCloudprovider) GetDetailsCannedAcls(
ctx context.Context,
userCred mcclient.TokenCredential,
input api.CloudproviderGetCannedAclInput,
) (api.CloudproviderGetCannedAclOutput, error) {
output := api.CloudproviderGetCannedAclOutput{}
driver, err := provider.GetProvider()
if err != nil {
return output, httperrors.NewInternalServerError("fail to get provider driver %s", err)
}
if len(input.Cloudregion) > 0 {
_, input.CloudregionResourceInput, err = ValidateCloudregionResourceInput(userCred, input.CloudregionResourceInput)
if err != nil {
return output, errors.Wrap(err, "ValidateCloudregionResourceInput")
}
}
output.BucketCannedAcls = driver.GetBucketCannedAcls(input.Cloudregion)
output.ObjectCannedAcls = driver.GetObjectCannedAcls(input.Cloudregion)
return output, nil
}
func (provider *SCloudprovider) getAccountShareInfo() apis.SAccountShareInfo {

View File

@@ -117,6 +117,22 @@ func (self *SCloudregion) ValidateDeleteCondition(ctx context.Context) error {
return self.SEnabledStatusStandaloneResourceBase.ValidateDeleteCondition(ctx)
}
func (self *SCloudregion) GetElasticIps(managerId, eipMode string) ([]SElasticip, error) {
q := ElasticipManager.Query().Equals("cloudregion_id", self.Id)
if len(managerId) > 0 {
q = q.Equals("manager_id", managerId)
}
if len(eipMode) > 0 {
q = q.Equals("mode", eipMode)
}
eips := []SElasticip{}
err := db.FetchModelObjects(ElasticipManager, q, &eips)
if err != nil {
return nil, errors.Wrapf(err, "db.FetchModelObjects")
}
return eips, nil
}
func (self *SCloudregion) GetZoneQuery() *sqlchemy.SQuery {
zones := ZoneManager.Query()
if self.Id == api.DEFAULT_REGION_ID {

View File

@@ -240,6 +240,10 @@ func syncRegionVPCs(ctx context.Context, userCred mcclient.TokenCredential, sync
lockman.LockObject(ctx, &localVpcs[j])
defer lockman.ReleaseObject(ctx, &localVpcs[j])
if localVpcs[j].Deleted {
return
}
syncVpcWires(ctx, userCred, syncResults, provider, &localVpcs[j], remoteVpcs[j], syncRange)
if localRegion.GetDriver().IsSecurityGroupBelongVpc() || localRegion.GetDriver().IsSupportClassicSecurityGroup() || j == 0 { //有vpc属性的每次都同步,支持classic的vpc也同步否则仅同步一次
syncVpcSecGroup(ctx, userCred, syncResults, provider, &localVpcs[j], remoteVpcs[j], syncRange)
@@ -311,6 +315,10 @@ func syncVpcNatgateways(ctx context.Context, userCred mcclient.TokenCredential,
lockman.LockObject(ctx, &localNatGateways[i])
defer lockman.ReleaseObject(ctx, &localNatGateways[i])
if localNatGateways[i].Deleted {
return
}
syncNatGatewayEips(ctx, userCred, provider, &localNatGateways[i], remoteNatGateways[i])
syncNatDTable(ctx, userCred, provider, &localNatGateways[i], remoteNatGateways[i])
syncNatSTable(ctx, userCred, provider, &localNatGateways[i], remoteNatGateways[i])
@@ -392,6 +400,9 @@ func syncVpcWires(ctx context.Context, userCred mcclient.TokenCredential, syncRe
lockman.LockObject(ctx, &localWires[i])
defer lockman.ReleaseObject(ctx, &localWires[i])
if localWires[i].Deleted {
return
}
syncWireNetworks(ctx, userCred, syncResults, provider, &localWires[i], remoteWires[i], syncRange)
}()
}
@@ -446,6 +457,10 @@ func syncZoneStorages(ctx context.Context, userCred mcclient.TokenCredential, sy
lockman.LockObject(ctx, &localStorages[i])
defer lockman.ReleaseObject(ctx, &localStorages[i])
if localStorages[i].Deleted {
return
}
if !isInCache(storageCachePairs, localStorages[i].StoragecacheId) && !isInCache(newCacheIds, localStorages[i].StoragecacheId) {
cachePair := syncStorageCaches(ctx, userCred, provider, &localStorages[i], remoteStorages[i])
if cachePair.remote != nil && cachePair.local != nil {
@@ -531,6 +546,10 @@ func syncZoneHosts(ctx context.Context, userCred mcclient.TokenCredential, syncR
lockman.LockObject(ctx, &localHosts[i])
defer lockman.ReleaseObject(ctx, &localHosts[i])
if localHosts[i].Deleted {
return
}
syncMetadata(ctx, userCred, &localHosts[i], remoteHosts[i])
newCachePairs = syncHostStorages(ctx, userCred, syncResults, provider, &localHosts[i], remoteHosts[i], storageCachePairs)
syncHostWires(ctx, userCred, syncResults, provider, &localHosts[i], remoteHosts[i])
@@ -624,6 +643,10 @@ func syncHostVMs(ctx context.Context, userCred mcclient.TokenCredential, syncRes
lockman.LockObject(ctx, syncVMPairs[i].Local)
defer lockman.ReleaseObject(ctx, syncVMPairs[i].Local)
if syncVMPairs[i].Local.Deleted || syncVMPairs[i].Local.PendingDeleted {
return
}
syncVMPeripherals(ctx, userCred, syncVMPairs[i].Local, syncVMPairs[i].Remote, localHost, provider, driver)
// syncMetadata(ctx, userCred, syncVMPairs[i].Local, syncVMPairs[i].Remote)
// syncVMNics(ctx, userCred, provider, localHost, syncVMPairs[i].Local, syncVMPairs[i].Remote)
@@ -773,6 +796,10 @@ func syncRegionDBInstances(ctx context.Context, userCred mcclient.TokenCredentia
lockman.LockObject(ctx, &localInstances[i])
defer lockman.ReleaseObject(ctx, &localInstances[i])
if localInstances[i].Deleted || localInstances[i].PendingDeleted {
return
}
syncDBInstanceNetwork(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i])
syncDBInstanceParameters(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i])
syncDBInstanceDatabases(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i])
@@ -880,6 +907,10 @@ func syncDBInstanceAccounts(ctx context.Context, userCred mcclient.TokenCredenti
lockman.LockObject(ctx, &localAccounts[i])
defer lockman.ReleaseObject(ctx, &localAccounts[i])
if localAccounts[i].Deleted {
return
}
syncDBInstanceAccountPrivileges(ctx, userCred, syncResults, &localAccounts[i], remoteAccounts[i])
}()
@@ -963,6 +994,10 @@ func syncRegionNetworkInterfaces(ctx context.Context, userCred mcclient.TokenCre
lockman.LockObject(ctx, &localInterfaces[i])
defer lockman.ReleaseObject(ctx, &localInterfaces[i])
if localInterfaces[i].Deleted {
return
}
syncInterfaceAddresses(ctx, userCred, &localInterfaces[i], remoteInterfaces[i])
}()
}
@@ -1141,15 +1176,17 @@ func syncOnPremiseCloudProviderInfo(
}
}
log.Debugf("storageCachePairs count %d", len(storageCachePairs))
for i := range storageCachePairs {
// alway sync on-premise cached images
// if storageCachePairs[i].isNew || syncRange.DeepSync {
result := storageCachePairs[i].syncCloudImages(ctx, userCred)
syncResults.Add(StoragecachedimageManager, result)
msg := result.Result()
log.Infof("syncCloudImages result: %s", msg)
// }
if cloudprovider.IsSupportCompute(driver) {
log.Debugf("storageCachePairs count %d", len(storageCachePairs))
for i := range storageCachePairs {
// alway sync on-premise cached images
// if storageCachePairs[i].isNew || syncRange.DeepSync {
result := storageCachePairs[i].syncCloudImages(ctx, userCred)
syncResults.Add(StoragecachedimageManager, result)
msg := result.Result()
log.Infof("syncCloudImages result: %s", msg)
// }
}
}
return nil
@@ -1192,7 +1229,7 @@ func SyncCloudProject(userCred mcclient.TokenCredential, model db.IVirtualModel,
extProject, err := ExternalProjectManager.GetProject(extProjectId, managerId)
if err != nil {
log.Errorf("sync project for %s %s error: %v", model.Keyword(), model.GetName(), err)
} else {
} else if len(extProject.ProjectId) > 0 {
newOwnerId = extProject.GetOwnerId()
}
}

View File

@@ -259,11 +259,16 @@ func (self *SDBInstanceBackup) PostCreate(ctx context.Context, userCred mcclient
}
func (self *SDBInstanceBackup) StartDBInstanceBackupCreateTask(ctx context.Context, userCred mcclient.TokenCredential, data *jsonutils.JSONDict, parentTaskId string) error {
self.SetStatus(userCred, api.DBINSTANCE_BACKUP_CREATING, "")
task, err := taskman.TaskManager.NewTask(ctx, "DBInstanceBackupCreateTask", self, userCred, data, parentTaskId, "", nil)
if err != nil {
return err
return errors.Wrap(err, "NewTask")
}
instance, err := self.GetDBInstance()
if err != nil {
return errors.Wrap(err, "GetDBInstance")
}
instance.SetStatus(userCred, api.DBINSTANCE_BACKING_UP, "")
self.SetStatus(userCred, api.DBINSTANCE_BACKUP_CREATING, "")
task.ScheduleRun(nil)
return nil
}

View File

@@ -675,22 +675,19 @@ func (self *SDBInstance) AllowPerformRecovery(ctx context.Context, userCred mccl
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "recovery")
}
func (self *SDBInstance) PerformRecovery(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
func (self *SDBInstance) PerformRecovery(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.SDBInstanceRecoveryConfigInput) (jsonutils.JSONObject, error) {
if !utils.IsInStringArray(self.Status, []string{api.DBINSTANCE_RUNNING}) {
return nil, httperrors.NewInvalidStatusError("Cannot do recovery dbinstance in status %s required status %s", self.Status, api.DBINSTANCE_RUNNING)
}
params := data.(*jsonutils.JSONDict)
backupV := validators.NewModelIdOrNameValidator("dbinstancebackup", "dbinstancebackup", userCred)
err := backupV.Validate(params)
_backup, err := DBInstanceBackupManager.FetchByIdOrName(userCred, input.DBInstancebackupId)
if err != nil {
return nil, err
}
input := &api.SDBInstanceRecoveryConfigInput{}
err = params.Unmarshal(input)
if err != nil {
return nil, httperrors.NewInputParameterError("Failed to unmarshal input config: %v", err)
if errors.Cause(err) == sql.ErrNoRows {
return nil, httperrors.NewResourceNotFoundError2("dbinstancebackup", input.DBInstancebackupId)
}
return nil, httperrors.NewGeneralError(err)
}
input.DBInstancebackupId = _backup.GetId()
databases, err := self.GetDBInstanceDatabases()
if err != nil {
@@ -702,7 +699,7 @@ func (self *SDBInstance) PerformRecovery(ctx context.Context, userCred mcclient.
dbDatabases = append(dbDatabases, database.Name)
}
backup := backupV.Model.(*SDBInstanceBackup)
backup := _backup.(*SDBInstanceBackup)
for src, dest := range input.Databases {
if len(dest) == 0 {
dest = src
@@ -725,6 +722,20 @@ func (self *SDBInstance) PerformRecovery(ctx context.Context, userCred mcclient.
return nil, httperrors.NewInputParameterError("backup and instance not in same cloudregion")
}
if len(backup.Engine) > 0 && backup.Engine != self.Engine {
return nil, httperrors.NewInputParameterError("can not recover data from diff rds engine")
}
driver, err := self.GetRegionDriver()
if err != nil {
return nil, httperrors.NewGeneralError(err)
}
err = driver.ValidateDBInstanceRecovery(ctx, userCred, self, backup, input)
if err != nil {
return nil, err
}
return nil, self.StartDBInstanceRecoveryTask(ctx, userCred, input.JSON(input), "")
}
@@ -1276,6 +1287,13 @@ func (manager *SDBInstanceManager) SyncDBInstances(ctx context.Context, userCred
return nil, nil, syncResult
}
for i := range dbInstances {
if taskman.TaskManager.IsInTask(&dbInstances[i]) {
syncResult.Error(fmt.Errorf("dbInstance %s(%s)in task", dbInstances[i].Name, dbInstances[i].Id))
return nil, nil, syncResult
}
}
removed := make([]SDBInstance, 0)
commondb := make([]SDBInstance, 0)
commonext := make([]cloudprovider.ICloudDBInstance, 0)

View File

@@ -495,7 +495,9 @@ func (manager *SDiskManager) ValidateCreateData(ctx context.Context, userCred mc
input.Hypervisor,
)
} else {
diskConfig.Backend = api.STORAGE_LOCAL
if len(diskConfig.Backend) == 0 {
diskConfig.Backend = api.STORAGE_LOCAL
}
serverInput, err := ValidateScheduleCreateData(ctx, userCred, input.ToServerCreateInput(), input.Hypervisor)
if err != nil {
return nil, err

View File

@@ -337,11 +337,26 @@ func (man *SDnsRecordManager) ValidateCreateData(
query jsonutils.JSONObject,
data *jsonutils.JSONDict,
) (*jsonutils.JSONDict, error) {
_, err := man.validateModelData(ctx, data, true)
var err error
input := apis.AdminSharableVirtualResourceBaseCreateInput{}
err = data.Unmarshal(&input)
if err != nil {
return nil, errors.Wrap(err, "Unmarshal AdminSharableVirtualResourceBaseCreateInput")
}
input, err = man.SAdminSharableVirtualResourceBaseManager.ValidateCreateData(ctx, userCred, ownerId, query, input)
if err != nil {
return nil, errors.Wrap(err, "SAdminSharableVirtualResourceBaseManager.ValidateCreateData")
}
data.Update(jsonutils.Marshal(input))
_, err = man.validateModelData(ctx, data, true)
if err != nil {
return nil, err
}
return man.SAdminSharableVirtualResourceBaseManager.ValidateCreateData(man, data)
return man.SAdminSharableVirtualResourceBaseManager.ValidateRecordsData(man, data)
}
func (man *SDnsRecordManager) QueryDns(projectId, name string) *SDnsRecord {

View File

@@ -105,7 +105,7 @@ type SDynamicschedtag struct {
// 动态调度标间的匹配条件
// example: host.sys_load > 1.5 || host.mem_used_percent > 0.7 => "high_load"
Condition string `width:"256" charset:"ascii" nullable:"false" list:"user" create:"required" update:"admin"`
Condition string `width:"1024" charset:"ascii" nullable:"false" list:"user" create:"required" update:"admin"`
// 动态调度标签对应的调度标签
// SchedtagId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" update:"admin"`

View File

@@ -448,6 +448,13 @@ func (manager *SElasticcacheManager) SyncElasticcaches(ctx context.Context, user
return nil, nil, syncResult
}
for i := range dbInstances {
if taskman.TaskManager.IsInTask(&dbInstances[i]) {
syncResult.Error(fmt.Errorf("ElasticCacheInstance %s(%s)in task", dbInstances[i].Name, dbInstances[i].Id))
return nil, nil, syncResult
}
}
removed := make([]SElasticcache, 0)
commondb := make([]SElasticcache, 0)
commonext := make([]cloudprovider.ICloudElasticcache, 0)
@@ -584,7 +591,7 @@ func (manager *SElasticcacheManager) newFromCloudElasticcache(ctx context.Contex
instance.NetworkType = extInstance.GetNetworkType()
if instance.NetworkType == api.LB_NETWORK_TYPE_CLASSIC {
vpc, err := VpcManager.GetOrCreateVpcForClassicNetwork(region)
vpc, err := VpcManager.GetOrCreateVpcForClassicNetwork(provider, region)
if err != nil {
return nil, errors.Wrap(err, "NewVpcForClassicNetwork")
}
@@ -901,7 +908,7 @@ func (self *SElasticcache) GetCreateHuaweiElasticcacheParams(data *jsonutils.JSO
// fill security group here
if len(self.SecurityGroupId) > 0 {
sgCache, err := SecurityGroupCacheManager.GetSecgroupCache(context.Background(), nil, self.SecurityGroupId, self.VpcId, self.GetRegion().Id, self.GetCloudprovider().Id)
sgCache, err := SecurityGroupCacheManager.GetSecgroupCache(context.Background(), nil, self.SecurityGroupId, self.VpcId, self.GetRegion().Id, self.GetCloudprovider().Id, "")
if err != nil {
return nil, errors.Wrap(err, "elasticcache.GetCreateHuaweiElasticcacheParams.SecurityGroup")
}

View File

@@ -242,19 +242,6 @@ func (manager *SElasticipManager) QueryDistinctExtraField(q *sqlchemy.SQuery, fi
return q, httperrors.ErrNotFound
}
func (manager *SElasticipManager) getEipsByRegion(region *SCloudregion, provider *SCloudprovider) ([]SElasticip, error) {
eips := make([]SElasticip, 0)
q := manager.Query().Equals("cloudregion_id", region.Id)
if provider != nil {
q = q.Equals("manager_id", provider.Id)
}
err := db.FetchModelObjects(manager, q, &eips)
if err != nil {
return nil, err
}
return eips, nil
}
func (self *SElasticip) GetRegion() *SCloudregion {
return CloudregionManager.FetchRegionById(self.CloudregionId)
}
@@ -323,7 +310,7 @@ func (manager *SElasticipManager) SyncEips(ctx context.Context, userCred mcclien
// remoteEips := make([]cloudprovider.ICloudEIP, 0)
syncResult := compare.SyncResult{}
dbEips, err := manager.getEipsByRegion(region, provider)
dbEips, err := region.GetElasticIps(provider.Id, api.EIP_MODE_STANDALONE_EIP)
if err != nil {
syncResult.Error(err)
return syncResult
@@ -421,8 +408,11 @@ func (self *SElasticip) SyncInstanceWithCloudEip(ctx context.Context, userCred m
case api.EIP_ASSOCIATE_TYPE_SERVER:
sq := HostManager.Query().SubQuery()
return q.Join(sq, sqlchemy.Equals(sq.Field("id"), q.Field("host_id"))).Filter(sqlchemy.Equals(sq.Field("manager_id"), self.ManagerId))
case api.EIP_ASSOCIATE_TYPE_NAT_GATEWAY, api.EIP_ASSOCIATE_TYPE_LOADBALANCER:
case api.EIP_ASSOCIATE_TYPE_LOADBALANCER:
return q.Equals("manager_id", self.ManagerId)
case api.EIP_ASSOCIATE_TYPE_NAT_GATEWAY:
sq := VpcManager.Query("id").Equals("manager_id", self.ManagerId)
return q.In("vpc_id", sq.SubQuery())
}
return q
})

View File

@@ -240,3 +240,12 @@ func (globalVpc *SGlobalVpc) GetRequiredSharedDomainIds() []string {
}
return db.ISharableMergeShareRequireDomainIds(requires...)
}
func (globalVpc *SGlobalVpc) GetChangeOwnerRequiredDomainIds() []string {
requires := stringutils2.SSortedStrings{}
vpcs, _ := globalVpc.GetVpcs()
for i := range vpcs {
requires = stringutils2.Append(requires, vpcs[i].DomainId)
}
return requires
}

View File

@@ -3056,6 +3056,13 @@ func (self *SGuest) PerformSetQemuParams(ctx context.Context, userCred mcclient.
return nil, err
}
}
usbKbd, err := data.GetString("disable_usb_kbd")
if err == nil {
err = self.SetMetadata(ctx, "disable_usb_kbd", usbKbd, userCred)
if err != nil {
return nil, err
}
}
return nil, nil
}
@@ -3612,9 +3619,11 @@ func (self *SGuest) SaveRenewInfo(
guestdisks := self.GetDisks()
for i := 0; i < len(guestdisks); i += 1 {
disk := guestdisks[i].GetDisk()
err = disk.SaveRenewInfo(ctx, userCred, bc, expireAt, billingType)
if err != nil {
return err
if disk.AutoDelete {
err = disk.SaveRenewInfo(ctx, userCred, bc, expireAt, billingType)
if err != nil {
return err
}
}
}
return nil
@@ -4623,6 +4632,9 @@ func (self *SGuest) PerformSnapshotAndClone(
quotas.CancelPendingUsage(ctx, userCred, &pendingUsage, &pendingUsage, false)
quotas.CancelPendingUsage(ctx, userCred, &pendingRegionUsage, &pendingRegionUsage, false)
return nil, httperrors.NewInternalServerError("create instance snapshot failed: %s", err)
} else {
cancelRegionUsage := &SRegionQuota{Snapshot: snapshotUsage.Snapshot}
quotas.CancelPendingUsage(ctx, userCred, &pendingRegionUsage, cancelRegionUsage, true)
}
err = self.StartInstanceSnapshotAndCloneTask(

View File

@@ -315,25 +315,19 @@ func (gt *SGuestTemplate) getMoreDetails(ctx context.Context, userCred mcclient.
return out, err
}
configInfo := computeapis.GuestTemplateConfigInfo{}
if len(input.PreferRegion) != 0 {
region := CloudregionManager.FetchRegionById(input.PreferRegion)
if region != nil {
input.PreferRegion = region.GetName()
}
configInfo.Region = input.PreferRegion
}
if len(input.PreferZone) != 0 {
zone := ZoneManager.FetchZoneById(input.PreferZone)
if zone != nil {
input.PreferZone = zone.GetName()
out.ZoneId = zone.GetId()
}
out.Zone = input.PreferZone
configInfo.Zone = input.PreferZone
}
configInfo.Hypervisor = gt.Hypervisor
out.Brand = Hypervisor2Brand(gt.Hypervisor)
// metadata
configInfo.Metadata = input.Metadata
// sku deal
if len(input.InstanceType) > 0 {
skuOutput := computeapis.GuestTemplateSku{}

View File

@@ -187,7 +187,7 @@ func (self *SGuestdisk) DoSave(driver string, cache string, mountpoint string) e
func (self *SGuestdisk) GetDisk() *SDisk {
disk, err := DiskManager.FetchById(self.DiskId)
if err != nil {
log.Errorf("GetDisk fail: %s", err)
log.Errorf("GetDisk %s fail: %s", self.DiskId, err)
return nil
}
return disk.(*SDisk)
@@ -287,6 +287,10 @@ func (self *SGuestdisk) GetDetailedJson() *jsonutils.JSONDict {
func (self *SGuestdisk) GetDetailedString() string {
disk := self.GetDisk()
if disk == nil {
return ""
}
var fs string
if len(disk.GetTemplateId()) > 0 {
fs = "root"

View File

@@ -535,6 +535,26 @@ func (manager *SGuestManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field
return q, httperrors.ErrNotFound
}
func (manager *SGuestManager) InitializeData() error {
guests := make([]SGuest, 0, 10)
q := manager.Query().Equals("hypervisor", "esxi")
err := db.FetchModelObjects(manager, q, &guests)
if err != nil {
return errors.Wrap(err, "db.FetchModelObjects")
}
// remove secgroup for esxi guest
for i := range guests {
if len(guests[i].SecgrpId) == 0 {
continue
}
db.Update(&guests[i], func() error {
guests[i].SecgrpId = ""
return nil
})
}
return nil
}
func (guest *SGuest) GetHypervisor() string {
if len(guest.Hypervisor) == 0 {
return api.HYPERVISOR_DEFAULT
@@ -1087,6 +1107,7 @@ func (manager *SGuestManager) validateCreateData(
if len(imgProperties) == 0 {
imgProperties = map[string]string{"os_type": "Linux"}
}
input.DisableUsbKbd = imgProperties[imageapi.IMAGE_DISABLE_USB_KBD] == "true"
osType := input.OsType
osProf, err = osprofile.GetOSProfileFromImageProperties(imgProperties, hypervisor)
@@ -1313,6 +1334,7 @@ func (manager *SGuestManager) validateCreateData(
maxSecgrpCount := GetDriver(hypervisor).GetMaxSecurityGroupCount()
if maxSecgrpCount == 0 { //esxi 不支持安全组
input.SecgroupId = ""
input.Secgroups = []string{}
} else if len(input.Secgroups)+1 > maxSecgrpCount {
return nil, httperrors.NewInputParameterError("%s shall bind up to %d security groups", hypervisor, maxSecgrpCount)
@@ -1644,17 +1666,22 @@ func (guest *SGuest) PostCreate(ctx context.Context, userCred mcclient.TokenCred
if osProfileJson != nil {
guest.setOSProfile(ctx, userCred, osProfileJson)
}
if jsonutils.QueryBoolean(data, imageapi.IMAGE_DISABLE_USB_KBD, false) {
guest.SetMetadata(ctx, imageapi.IMAGE_DISABLE_USB_KBD, "true", userCred)
}
userData, _ := data.GetString("user_data")
if len(userData) > 0 {
guest.setUserData(ctx, userCred, userData)
}
secgroups, _ := jsonutils.GetStringArray(data, "secgroups")
for _, secgroup := range secgroups {
gs := SGuestsecgroup{}
gs.SecgroupId = secgroup
gs.GuestId = guest.Id
GuestsecgroupManager.TableSpec().Insert(&gs)
for _, secgroupId := range secgroups {
if secgroupId != guest.SecgrpId {
gs := SGuestsecgroup{}
gs.SecgroupId = secgroupId
gs.GuestId = guest.Id
GuestsecgroupManager.TableSpec().Insert(&gs)
}
}
}
@@ -1947,8 +1974,10 @@ func (self *SGuest) getNetworksDetails() string {
func (self *SGuest) getDisksDetails() string {
var buf bytes.Buffer
for _, disk := range self.GetDisks() {
buf.WriteString(disk.GetDetailedString())
buf.WriteString("\n")
if details := disk.GetDetailedString(); len(details) > 0 {
buf.WriteString(details)
buf.WriteString("\n")
}
}
return buf.String()
}
@@ -2703,7 +2732,8 @@ func getCloudNicNetwork(vnic cloudprovider.ICloudNic, host *SHost, ipList []stri
if vnet == nil {
if vnic.InClassicNetwork() {
region := host.GetRegion()
vpc, err := VpcManager.GetOrCreateVpcForClassicNetwork(region)
cloudprovider := host.GetCloudprovider()
vpc, err := VpcManager.GetOrCreateVpcForClassicNetwork(cloudprovider, region)
if err != nil {
return nil, errors.Wrap(err, "NewVpcForClassicNetwork")
}
@@ -4192,6 +4222,14 @@ func (self *SGuest) GetShortDesc(ctx context.Context) *jsonutils.JSONDict {
billingInfo.SCloudProviderInfo = host.getCloudProviderInfo()
}
if len(self.BackupHostId) > 0 {
backupHost := HostManager.FetchHostById(self.BackupHostId)
if backupHost != nil {
desc.Set("backup_host", jsonutils.NewString(backupHost.Name))
desc.Set("backup_host_id", jsonutils.NewString(backupHost.Id))
}
}
if priceKey := self.GetMetadata("ext:price_key", nil); len(priceKey) > 0 {
billingInfo.PriceKey = priceKey
}

View File

@@ -698,7 +698,7 @@ func (self *SHost) GetHoststorages() []SHoststorage {
hoststorages := make([]SHoststorage, 0)
q := self.GetHoststoragesQuery()
err := db.FetchModelObjects(HoststorageManager, q, &hoststorages)
if err != nil {
if err != nil && errors.Cause(err) != sql.ErrNoRows {
log.Errorf("GetHoststorages error %s", err)
return nil
}
@@ -710,7 +710,9 @@ func (self *SHost) GetHoststorageOfId(storageId string) *SHoststorage {
hoststorage.SetModelManager(HoststorageManager, &hoststorage)
err := self.GetHoststoragesQuery().Equals("storage_id", storageId).First(&hoststorage)
if err != nil {
log.Errorf("GetHoststorageOfId fail %s", err)
if errors.Cause(err) != sql.ErrNoRows {
log.Errorf("GetHoststorageOfId fail %s", err)
}
return nil
}
return &hoststorage
@@ -729,7 +731,9 @@ func (self *SHost) GetHoststorageByExternalId(extId string) *SHoststorage {
err := q.First(&hoststorage)
if err != nil {
log.Errorf("GetHoststorageByExternalId fail %s", err)
if errors.Cause(err) != sql.ErrNoRows {
log.Errorf("GetHoststorageByExternalId fail %s", err)
}
return nil
}
@@ -1377,6 +1381,17 @@ func (self *SHost) GetGuests() []SGuest {
return guests
}
func (self *SHost) GetKvmGuests() []SGuest {
q := GuestManager.Query().Equals("host_id", self.Id).Equals("hypervisor", api.HYPERVISOR_KVM)
guests := make([]SGuest, 0)
err := db.FetchModelObjects(GuestManager, q, &guests)
if err != nil {
log.Errorf("GetGuests %s", err)
return nil
}
return guests
}
func (self *SHost) GetGuestCount() (int, error) {
q := self.GetGuestsQuery()
return q.CountWithError()
@@ -3948,6 +3963,14 @@ func (self *SHost) EnableNetif(ctx context.Context, userCred mcclient.TokenCrede
if wire == nil {
return fmt.Errorf("No wire attached")
}
if self.ZoneId == "" {
if _, err := self.SaveUpdates(func() error {
self.ZoneId = wire.ZoneId
return nil
}); err != nil {
return errors.Wrapf(err, "set host zone_id %s by wire", wire.ZoneId)
}
}
hw, err := HostwireManager.FetchByHostIdAndMac(self.Id, netif.Mac)
if err != nil {
return err
@@ -4797,7 +4820,7 @@ func (host *SHost) PerformHostMaintenance(ctx context.Context, userCred mcclient
preferHostId = host.Id
}
guests := host.GetGuests()
guests := host.GetKvmGuests()
for i := 0; i < len(guests); i++ {
lockman.LockObject(ctx, &guests[i])
defer lockman.ReleaseObject(ctx, &guests[i])
@@ -5124,6 +5147,15 @@ func (host *SHost) PerformChangeOwner(ctx context.Context, userCred mcclient.Tok
return ret, nil
}
func (host *SHost) GetChangeOwnerRequiredDomainIds() []string {
requires := stringutils2.SSortedStrings{}
guests := host.GetGuests()
for i := range guests {
requires = stringutils2.Append(requires, guests[i].DomainId)
}
return requires
}
func GetHostQuotaKeysFromCreateInput(input api.HostCreateInput) quotas.SDomainRegionalCloudResourceKeys {
ownerId := &db.SOwnerId{DomainId: input.ProjectDomain}
var zone *SZone
@@ -5208,3 +5240,15 @@ func (manager *SHostManager) ListItemExportKeys(ctx context.Context,
}
return q, nil
}
func (manager *SHostManager) FetchHostByExtId(extid string) *SHost {
host := SHost{}
host.SetModelManager(manager, &host)
err := manager.Query().Equals("external_id", extid).First(&host)
if err != nil {
log.Errorf("fetchHostByExtId fail %s", err)
return nil
} else {
return &host
}
}

View File

@@ -44,6 +44,7 @@ func InitDB() error {
SecurityGroupManager,
SecurityGroupCacheManager,
NetworkManager,
GuestManager,
LoadbalancerCertificateManager,
LoadbalancerAclManager,
LoadbalancerManager,
@@ -51,6 +52,7 @@ func InitDB() error {
LoadbalancerListenerRuleManager,
LoadbalancerBackendGroupManager,
LoadbalancerBackendManager,
AwsCachedLbbgManager,
LoadbalancerClusterManager,
SchedtagManager,
DynamicschedtagManager,

View File

@@ -363,22 +363,27 @@ func (lbacl *SLoadbalancerAcl) PerformPatch(ctx context.Context, userCred mcclie
}
func (lbacl *SLoadbalancerAcl) ValidateDeleteCondition(ctx context.Context) error {
man := CachedLoadbalancerAclManager
t := man.TableSpec().Instance()
pdF := t.Field("pending_deleted")
men := []db.IModelManager{
LoadbalancerListenerManager,
CachedLoadbalancerAclManager,
}
lbaclId := lbacl.Id
n, err := t.Query().
Filter(sqlchemy.OR(sqlchemy.IsNull(pdF), sqlchemy.IsFalse(pdF))).
Equals("acl_id", lbaclId).
CountWithError()
if err != nil {
return httperrors.NewInternalServerError("get acl count fail %s", err)
}
if n > 0 {
// return fmt.Errorf("acl %s is still referred to by %d %s",
// lbaclId, n, man.KeywordPlural())
return httperrors.NewResourceBusyError("acl %s is still referred to by %d %s", lbaclId, n, man.KeywordPlural())
for _, man := range men {
t := man.TableSpec().Instance()
pdF := t.Field("pending_deleted")
n, err := t.Query().
Filter(sqlchemy.OR(sqlchemy.IsNull(pdF), sqlchemy.IsFalse(pdF))).
Equals("acl_id", lbaclId).
CountWithError()
if err != nil {
return httperrors.NewInternalServerError("get acl count fail %s", err)
}
if n > 0 {
return httperrors.NewResourceBusyError("acl %s is still referred to by %d %s", lbaclId, n, man.KeywordPlural())
}
}
return nil
}

View File

@@ -159,16 +159,14 @@ func (man *SAwsCachedLbManager) SyncLoadbalancerBackends(ctx context.Context, us
if err != nil {
syncResult.UpdateError(err)
} else {
syncMetadata(ctx, userCred, &commondb[i], commonext[i])
syncResult.Update()
}
}
for i := 0; i < len(added); i++ {
local, err := man.newFromCloudLoadbalancerBackend(ctx, userCred, loadbalancerBackendgroup, added[i], syncOwnerId)
_, err := man.newFromCloudLoadbalancerBackend(ctx, userCred, loadbalancerBackendgroup, added[i], syncOwnerId)
if err != nil {
syncResult.AddError(err)
} else {
syncMetadata(ctx, userCred, local, added[i])
syncResult.Add()
}
}

View File

@@ -16,6 +16,7 @@ package models
import (
"context"
"database/sql"
"fmt"
"strconv"
"strings"
@@ -249,7 +250,6 @@ func (man *SAwsCachedLbbgManager) SyncLoadbalancerBackendgroups(ctx context.Cont
if err != nil {
syncResult.UpdateError(err)
} else {
syncMetadata(ctx, userCred, &commondb[i], commonext[i])
localLbgs = append(localLbgs, commondb[i])
remoteLbbgs = append(remoteLbbgs, commonext[i])
syncResult.Update()
@@ -277,7 +277,6 @@ func (man *SAwsCachedLbbgManager) SyncLoadbalancerBackendgroups(ctx context.Cont
if err != nil {
syncResult.AddError(err)
} else {
syncMetadata(ctx, userCred, new, added[i])
localLbgs = append(localLbgs, *new)
remoteLbbgs = append(remoteLbbgs, added[i])
syncResult.Add()
@@ -434,3 +433,30 @@ func (man *SAwsCachedLbbgManager) newFromCloudLoadbalancerBackendgroup(ctx conte
db.OpsLog.LogEvent(lbbg, db.ACT_CREATE, lbbg.GetShortDesc(ctx), userCred)
return lbbg, nil
}
func (man *SAwsCachedLbbgManager) InitializeData() error {
ret := []db.SMetadata{}
q := db.Metadata.Query().Equals("obj_type", man.Keyword())
err := db.FetchModelObjects(db.Metadata, q, &ret)
if err != nil {
if errors.Cause(err) != sql.ErrNoRows {
log.Debugf("SAwsCachedLbbgManager.InitializeData %s", err)
}
return nil
}
for i := range ret {
item := ret[i]
_, err := db.Update(&item, func() error {
return item.MarkDelete()
})
if err != nil {
log.Debugf("SAwsCachedLbbgManager.MarkDelete %s", err)
return nil
}
}
log.Debugf("SAwsCachedLbbgManager cleaned %d dirty data.", len(ret))
return nil
}

View File

@@ -162,16 +162,14 @@ func (man *SHuaweiCachedLbManager) SyncLoadbalancerBackends(ctx context.Context,
if err != nil {
syncResult.UpdateError(err)
} else {
syncMetadata(ctx, userCred, &commondb[i], commonext[i])
syncResult.Update()
}
}
for i := 0; i < len(added); i++ {
local, err := man.newFromCloudLoadbalancerBackend(ctx, userCred, loadbalancerBackendgroup, added[i], syncOwnerId)
_, err := man.newFromCloudLoadbalancerBackend(ctx, userCred, loadbalancerBackendgroup, added[i], syncOwnerId)
if err != nil {
syncResult.AddError(err)
} else {
syncMetadata(ctx, userCred, local, added[i])
syncResult.Add()
}
}

View File

@@ -222,7 +222,6 @@ func (man *SHuaweiCachedLbbgManager) SyncLoadbalancerBackendgroups(ctx context.C
if err != nil {
syncResult.UpdateError(err)
} else {
syncMetadata(ctx, userCred, &commondb[i], commonext[i])
localLbgs = append(localLbgs, commondb[i])
remoteLbbgs = append(remoteLbbgs, commonext[i])
syncResult.Update()
@@ -233,7 +232,6 @@ func (man *SHuaweiCachedLbbgManager) SyncLoadbalancerBackendgroups(ctx context.C
if err != nil {
syncResult.AddError(err)
} else {
syncMetadata(ctx, userCred, new, added[i])
localLbgs = append(localLbgs, *new)
remoteLbbgs = append(remoteLbbgs, added[i])
syncResult.Add()

View File

@@ -234,16 +234,14 @@ func (man *SQcloudCachedLbManager) SyncLoadbalancerBackends(ctx context.Context,
if err != nil {
syncResult.UpdateError(err)
} else {
syncMetadata(ctx, userCred, &commondb[i], commonext[i])
syncResult.Update()
}
}
for i := 0; i < len(added); i++ {
local, err := man.newFromCloudLoadbalancerBackend(ctx, userCred, loadbalancerBackendgroup, added[i], syncOwnerId)
_, err := man.newFromCloudLoadbalancerBackend(ctx, userCred, loadbalancerBackendgroup, added[i], syncOwnerId)
if err != nil {
syncResult.AddError(err)
} else {
syncMetadata(ctx, userCred, local, added[i])
syncResult.Add()
}
}

View File

@@ -294,7 +294,6 @@ func (man *SQcloudCachedLbbgManager) SyncLoadbalancerBackendgroups(ctx context.C
if err != nil {
syncResult.UpdateError(err)
} else {
syncMetadata(ctx, userCred, &commondb[i], commonext[i])
localLbgs = append(localLbgs, commondb[i])
remoteLbbgs = append(remoteLbbgs, commonext[i])
syncResult.Update()
@@ -305,7 +304,6 @@ func (man *SQcloudCachedLbbgManager) SyncLoadbalancerBackendgroups(ctx context.C
if err != nil {
syncResult.AddError(err)
} else {
syncMetadata(ctx, userCred, newlbbg, added[i])
localLbgs = append(localLbgs, *newlbbg)
remoteLbbgs = append(remoteLbbgs, added[i])
syncResult.Add()

Some files were not shown because too many files have changed in this diff Show More