Compare commits

..

136 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
156 changed files with 1662 additions and 676 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

@@ -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
}

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

6
go.mod
View File

@@ -128,11 +128,11 @@ 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/sqlchemy v0.0.0-20200814052348-164f1f20f8a6
yunion.io/x/structarg v0.0.0-20200720093445-9f850fa222ce
)

14
go.sum
View File

@@ -1108,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=
@@ -1117,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/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

@@ -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"`
// 列出指定云环境的资源,支持云环境如下:
//
@@ -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

View File

@@ -172,7 +172,7 @@ type SDBInstanceRecoveryConfigInput struct {
apis.Meta
// swagger:ignore
DBInstancebackup string `json:"dbinstancebackup" "yunion:deprecated-by":"dbinstancebackup_id"`
DBInstancebackup string `json:"dbinstancebackup" yunion-deprecated-by:"dbinstancebackup_id"`
// 备份Id
//
@@ -327,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

@@ -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 {
@@ -134,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

@@ -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

@@ -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

@@ -194,7 +194,7 @@ 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"`

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云硬盘
@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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 {

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

@@ -199,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()
@@ -259,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()

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

@@ -1229,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

@@ -1287,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

@@ -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

@@ -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)

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

@@ -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

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

@@ -1107,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)
@@ -1665,6 +1666,9 @@ 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 {
@@ -1970,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()
}
@@ -2726,7 +2732,7 @@ func getCloudNicNetwork(vnic cloudprovider.ICloudNic, host *SHost, ipList []stri
if vnet == nil {
if vnic.InClassicNetwork() {
region := host.GetRegion()
cloudprovider := region.GetCloudprovider()
cloudprovider := host.GetCloudprovider()
vpc, err := VpcManager.GetOrCreateVpcForClassicNetwork(cloudprovider, region)
if err != nil {
return nil, errors.Wrap(err, "NewVpcForClassicNetwork")
@@ -4216,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

@@ -1381,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()
@@ -4809,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])
@@ -5229,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

@@ -52,6 +52,7 @@ func InitDB() error {
LoadbalancerListenerRuleManager,
LoadbalancerBackendGroupManager,
LoadbalancerBackendManager,
AwsCachedLbbgManager,
LoadbalancerClusterManager,
SchedtagManager,
DynamicschedtagManager,

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()

View File

@@ -75,6 +75,12 @@ func (self *SLoadbalancerResourceBase) GetCloudprovider() *SCloudprovider {
if vpc != nil {
return vpc.GetCloudprovider()
}
lb := self.GetLoadbalancer()
if lb != nil {
return lb.GetCloudprovider()
}
return nil
}
@@ -161,23 +167,28 @@ func (manager *SLoadbalancerResourceBaseManager) FetchCustomizeColumns(
vpcList := make([]interface{}, len(rows))
zoneList := make([]interface{}, len(rows))
manList := make([]interface{}, len(rows))
for i := range rows {
rows[i] = api.LoadbalancerResourceInfo{}
if lb, ok := lbs[lbIds[i]]; ok {
rows[i].Loadbalancer = lb.Name
rows[i].VpcId = lb.VpcId
rows[i].ZoneId = lb.ZoneId
rows[i].ManagerId = lb.ManagerId
}
vpcList[i] = &SVpcResourceBase{rows[i].VpcId}
zoneList[i] = &SZoneResourceBase{rows[i].ZoneId}
manList[i] = &SManagedResourceBase{rows[i].ManagerId}
}
vpcRows := manager.SVpcResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, vpcList, fields, isList)
zoneRows := manager.SZoneResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, zoneList, fields, isList)
manRows := manager.SManagedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, manList, fields, isList)
for i := range rows {
rows[i].VpcResourceInfo = vpcRows[i]
rows[i].ZoneResourceInfoBase = zoneRows[i].ZoneResourceInfoBase
rows[i].ZoneResourceInfo = zoneRows[i]
rows[i].ManagedResourceInfo = manRows[i]
}
return rows
}

View File

@@ -436,10 +436,7 @@ func (lb *SLoadbalancer) GetCreateLoadbalancerParams(iRegion cloudprovider.IClou
ChargeType: lb.ChargeType,
LoadbalancerSpec: lb.LoadbalancerSpec,
}
iRegion, err := lb.GetIRegion()
if err != nil {
return nil, err
}
if len(lb.ZoneId) > 0 {
zone := lb.GetZone()
if zone == nil {
@@ -447,7 +444,7 @@ func (lb *SLoadbalancer) GetCreateLoadbalancerParams(iRegion cloudprovider.IClou
}
iZone, err := iRegion.GetIZoneById(zone.ExternalId)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "GetIZoneById")
}
params.ZoneID = iZone.GetId()
}
@@ -462,7 +459,7 @@ func (lb *SLoadbalancer) GetCreateLoadbalancerParams(iRegion cloudprovider.IClou
}
iVpc, err := iRegion.GetIVpcById(vpc.ExternalId)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "GetIVpcById")
}
params.VpcID = iVpc.GetId()
}
@@ -476,7 +473,7 @@ func (lb *SLoadbalancer) GetCreateLoadbalancerParams(iRegion cloudprovider.IClou
for i := range networks {
iNetwork, err := networks[i].GetINetwork()
if err != nil {
return nil, err
return nil, errors.Wrap(err, "GetINetwork")
}
params.NetworkIDs = append(params.NetworkIDs, iNetwork.GetId())
}
@@ -706,6 +703,13 @@ func (man *SLoadbalancerManager) SyncLoadbalancers(ctx context.Context, userCred
return nil, nil, syncResult
}
for i := range dbLbs {
if taskman.TaskManager.IsInTask(&dbLbs[i]) {
syncResult.Error(fmt.Errorf("loadbalancer %s(%s)in task", dbLbs[i].Name, dbLbs[i].Id))
return nil, nil, syncResult
}
}
removed := []SLoadbalancer{}
commondb := []SLoadbalancer{}
commonext := []cloudprovider.ICloudLoadbalancer{}

View File

@@ -822,16 +822,17 @@ func (manager *SNetworkManager) GetOnPremiseNetworkOfIP(ipAddr string, serverTyp
func (manager *SNetworkManager) allNetworksQ(providers []string, brands []string, cloudEnv string, rangeObjs []db.IStandaloneModel) *sqlchemy.SQuery {
networks := manager.Query().SubQuery()
hostwires := HostwireManager.Query().SubQuery()
hosts := HostManager.Query().SubQuery()
wires := WireManager.Query().SubQuery()
vpcs := VpcManager.Query().SubQuery()
q := networks.Query(networks.Field("id"))
q = q.Join(hostwires, sqlchemy.Equals(hostwires.Field("wire_id"), networks.Field("wire_id")))
q = q.Join(hosts, sqlchemy.Equals(hosts.Field("id"), hostwires.Field("host_id")))
q = q.Filter(sqlchemy.IsTrue(hosts.Field("enabled")))
q = q.Filter(sqlchemy.OR(
sqlchemy.Equals(hosts.Field("host_type"), api.HOST_TYPE_BAREMETAL),
sqlchemy.Equals(hosts.Field("host_status"), api.HOST_ONLINE)))
return AttachUsageQuery(q, hosts, nil, nil, providers, brands, cloudEnv, rangeObjs)
q = q.Join(wires, sqlchemy.Equals(q.Field("wire_id"), wires.Field("id")))
q = q.Join(vpcs, sqlchemy.Equals(wires.Field("vpc_id"), vpcs.Field("id")))
q = CloudProviderFilter(q, vpcs.Field("manager_id"), providers, brands, cloudEnv)
q = RangeObjectsFilter(q, rangeObjs, vpcs.Field("cloudregion_id"), wires.Field("zone_id"), vpcs.Field("manager_id"), nil, nil)
return q
}
func (manager *SNetworkManager) totalPortCountQ(
@@ -1690,6 +1691,7 @@ func (self *SNetwork) CustomizeDelete(ctx context.Context, userCred mcclient.Tok
}
func (self *SNetwork) RealDelete(ctx context.Context, userCred mcclient.TokenCredential) error {
DeleteResourceJointSchedtags(self, ctx, userCred)
db.OpsLog.LogEvent(self, db.ACT_DELOCATE, self.GetShortDesc(ctx), userCred)
self.SetStatus(userCred, api.NETWORK_STATUS_DELETED, "real delete")
self.ClearSchedDescCache()

View File

@@ -369,7 +369,7 @@ func (self *SSchedtag) GetObjectQuery() *sqlchemy.SQuery {
q := objs.Query()
q = q.Join(objschedtags, sqlchemy.AND(sqlchemy.Equals(objschedtags.Field(jointMan.GetMasterIdKey(jointMan)), objs.Field("id")),
sqlchemy.IsFalse(objschedtags.Field("deleted"))))
q = q.Filter(sqlchemy.IsTrue(objs.Field("enabled")))
// q = q.Filter(sqlchemy.IsTrue(objs.Field("enabled")))
q = q.Filter(sqlchemy.Equals(objschedtags.Field("schedtag_id"), self.Id))
return q
}
@@ -379,7 +379,8 @@ func (self *SSchedtag) GetJointManager() ISchedtagJointManager {
}
func (self *SSchedtag) GetObjectCount() (int, error) {
return self.GetJointManager().Query().Equals("schedtag_id", self.Id).CountWithError()
q := self.GetObjectQuery()
return q.CountWithError()
}
func (self *SSchedtag) getSchedPoliciesCount() (int, error) {

View File

@@ -1142,10 +1142,15 @@ func (manager *SServerSkuManager) newFromCloudSku(ctx context.Context, userCred
sku.Status = api.SkuStatusReady
sku.constructSku(extSku)
sku.Name = extSku.GetName()
var err error
sku.Name, err = db.GenerateName(manager, userCred, extSku.GetName())
if err != nil {
return errors.Wrap(err, "db.GenerateName")
}
sku.CloudregionId = api.DEFAULT_REGION_ID
sku.SetModelManager(manager, sku)
err := manager.TableSpec().Insert(sku)
err = manager.TableSpec().Insert(sku)
if err != nil {
return errors.Wrapf(err, "newFromCloudSku.Insert")
}

View File

@@ -953,8 +953,6 @@ func (manager *SStorageManager) totalCapacityQ(
q = RangeObjectsFilter(q, rangeObjs, nil, storages.Field("zone_id"), storages.Field("manager_id"), nil, storages.Field("id"))
}
q = q.Distinct()
if storageOwnership {
switch scope {
case rbacutils.ScopeSystem:

View File

@@ -26,9 +26,10 @@ import (
)
var (
syncAccountWorker *appsrv.SWorkerManager
syncWorkers []*appsrv.SWorkerManager
syncWorkerRing *hashring.HashRing
syncSecgroupWorker *appsrv.SWorkerManager
syncAccountWorker *appsrv.SWorkerManager
syncWorkers []*appsrv.SWorkerManager
syncWorkerRing *hashring.HashRing
)
func InitSyncWorkers(count int) {
@@ -50,6 +51,12 @@ func InitSyncWorkers(count int) {
2048,
true,
)
syncSecgroupWorker = appsrv.NewWorkerManager(
"syncSecgroupProbeWorkerManager",
1,
2048,
true,
)
}
func RunSyncCloudproviderRegionTask(key string, syncFunc func()) {
@@ -62,3 +69,7 @@ func RunSyncCloudproviderRegionTask(key string, syncFunc func()) {
func RunSyncCloudAccountTask(probeFunc func()) {
syncAccountWorker.Run(probeFunc, nil, nil)
}
func RunSyncSecgroupTask(syncFunc func()) {
syncSecgroupWorker.Run(syncFunc, nil, nil)
}

View File

@@ -29,6 +29,7 @@ import (
"yunion.io/x/onecloud/pkg/apis"
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/quotas"
@@ -182,7 +183,7 @@ func (manager *SVpcManager) getVpcExternalIdForClassicNetwork(regionId, cloudpro
func (manager *SVpcManager) GetOrCreateVpcForClassicNetwork(cloudprovider *SCloudprovider, region *SCloudregion) (*SVpc, error) {
externalId := manager.getVpcExternalIdForClassicNetwork(region.Id, cloudprovider.Id)
_vpc, err := db.FetchByExternalIdAndManagerId(manager, externalId, func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
return q.Equals("manager_id", region.ManagerId)
return q.Equals("manager_id", cloudprovider.Id)
})
if err == nil {
return _vpc.(*SVpc), nil
@@ -199,7 +200,7 @@ func (manager *SVpcManager) GetOrCreateVpcForClassicNetwork(cloudprovider *SClou
vpc.SetEnabled(false)
vpc.Status = api.VPC_STATUS_UNAVAILABLE
vpc.ExternalId = externalId
vpc.ManagerId = region.ManagerId
vpc.ManagerId = cloudprovider.Id
err = manager.TableSpec().Insert(vpc)
if err != nil {
return nil, errors.Wrap(err, "Insert vpc for classic network")
@@ -1024,6 +1025,11 @@ func (self *SVpc) initWire(ctx context.Context, zone *SZone) (*SWire, error) {
wire.ZoneId = zone.Id
wire.IsEmulated = true
wire.Name = fmt.Sprintf("vpc-%s", self.Name)
wire.DomainId = self.DomainId
wire.IsPublic = self.IsPublic
wire.PublicScope = self.PublicScope
wire.SetModelManager(WireManager, wire)
err := WireManager.TableSpec().Insert(wire)
if err != nil {
@@ -1176,3 +1182,100 @@ func (manager *SVpcManager) ListItemExportKeys(ctx context.Context,
return q, nil
}
func (vpc *SVpc) PerformPublic(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformPublicDomainInput) (jsonutils.JSONObject, error) {
if vpc.Id == api.DEFAULT_VPC_ID && rbacutils.String2ScopeDefault(input.Scope, rbacutils.ScopeSystem) != rbacutils.ScopeSystem {
return nil, httperrors.NewForbiddenError("For default vpc, only system level sharing can be set")
}
_, err := vpc.SEnabledStatusInfrasResourceBase.PerformPublic(ctx, userCred, query, input)
if err != nil {
return nil, errors.Wrap(err, "SEnabledStatusInfrasResourceBase.PerformPublic")
}
// perform public for all emulated wires
wires := vpc.GetWires()
for i := range wires {
if wires[i].IsEmulated {
_, err := wires[i].PerformPublic(ctx, userCred, query, input)
if err != nil {
return nil, errors.Wrap(err, "wire.PerformPublic")
}
}
}
return nil, nil
}
func (vpc *SVpc) PerformPrivate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformPrivateInput) (jsonutils.JSONObject, error) {
if vpc.Id == "default" {
return nil, httperrors.NewForbiddenError("Prohibit making default vpc private")
}
// perform private for all emulated wires
emptyNets := true
wires := vpc.GetWires()
for i := range wires {
if wires[i].DomainId == vpc.DomainId {
nets, _ := wires[i].getNetworks(nil, rbacutils.ScopeNone)
for j := range nets {
if nets[j].DomainId != vpc.DomainId {
emptyNets = false
break
}
}
if !emptyNets {
break
}
} else {
emptyNets = false
break
}
}
if emptyNets {
for i := range wires {
nets, _ := wires[i].getNetworks(nil, rbacutils.ScopeNone)
netfail := false
for j := range nets {
if nets[j].IsPublic && nets[j].GetPublicScope().HigherEqual(rbacutils.ScopeDomain) {
var err error
if consts.GetNonDefaultDomainProjects() {
netinput := apis.PerformPublicProjectInput{}
netinput.Scope = string(rbacutils.ScopeDomain)
_, err = nets[j].PerformPublic(ctx, userCred, nil, netinput)
} else {
_, err = nets[j].PerformPrivate(ctx, userCred, nil, input)
}
if err != nil {
log.Errorf("nets[j].PerformPublic fail %s", err)
netfail = true
break
}
}
}
if netfail {
break
}
_, err := wires[i].PerformPrivate(ctx, userCred, query, input)
if err != nil {
log.Errorf("wires[i].PerformPrivate fail %s", err)
break
}
}
}
return vpc.SEnabledStatusInfrasResourceBase.PerformPrivate(ctx, userCred, query, input)
}
func (vpc *SVpc) PerformChangeOwner(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformChangeDomainOwnerInput) (jsonutils.JSONObject, error) {
_, err := vpc.SEnabledStatusInfrasResourceBase.PerformChangeOwner(ctx, userCred, query, input)
if err != nil {
return nil, errors.Wrap(err, "SEnabledStatusInfrasResourceBase.PerformChangeOwner")
}
wires := vpc.GetWires()
for i := range wires {
if wires[i].IsEmulated {
_, err := wires[i].PerformChangeOwner(ctx, userCred, query, input)
if err != nil {
return nil, errors.Wrap(err, "wires[i].PerformChangeOwner")
}
}
}
return nil, nil
}

View File

@@ -192,11 +192,11 @@ func (manager *SWireResourceBaseManager) ListItemFilter(
}
err = q.First(region)
if err != nil {
return nil, errors.Wrap(err, "q.First")
return nil, errors.Wrap(err, "regionQ.First")
}
if utils.IsInStringArray(region.Provider, api.REGIONAL_NETWORK_PROVIDERS) {
vpcQ := VpcManager.Query().SubQuery()
q = q.Join(vpcQ, sqlchemy.Equals(vpcQ.Field("id"), q.Field("vpc_id"))).
wireQ = wireQ.Join(vpcQ, sqlchemy.Equals(vpcQ.Field("id"), wireQ.Field("vpc_id"))).
Filter(sqlchemy.Equals(vpcQ.Field("cloudregion_id"), region.Id))
} else {
zoneQuery := api.ZonalFilterListInput{

View File

@@ -1910,7 +1910,7 @@ func (self *SHuaWeiRegionDriver) RequestCreateLoadbalancer(ctx context.Context,
}
eip, err := db.FetchByExternalIdAndManagerId(models.ElasticipManager, ieip.GetGlobalId(), func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
return q.Equals("manager_id", lb.MarkUnDelete)
return q.Equals("manager_id", lb.ManagerId)
})
if err != nil {
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.FetchByExternalId")

View File

@@ -1476,95 +1476,109 @@ func (self *SManagedVirtualizationRegionDriver) RequestSyncSecurityGroup(ctx con
return "", errors.Wrap(err, "SSecurityGroupCache.Register")
}
iRegion, err := vpc.GetIRegion()
if err != nil {
return "", errors.Wrap(err, "vpc.GetIRegion")
}
waitChan := make(chan error)
var iSecgroup cloudprovider.ICloudSecurityGroup = nil
if len(cache.ExternalId) > 0 {
iSecgroup, err = iRegion.GetISecurityGroupById(cache.ExternalId)
if err != nil {
if errors.Cause(err) != cloudprovider.ErrNotFound {
return "", errors.Wrap(err, "iRegion.GetSecurityGroupById")
}
cache.ExternalId = ""
}
}
if len(cache.ExternalId) == 0 {
if strings.ToLower(secgroup.Name) == "default" { //避免有些云不支持default关键字
secgroup.Name = "DefaultGroup"
}
// 避免有的云不支持重名安全组
randomString := func(prefix string, length int) string {
return fmt.Sprintf("%s-%s", prefix, rand.String(length))
}
opts := &cloudprovider.SecurityGroupFilterOptions{
Name: randomString(secgroup.Name, 1),
VpcId: vpcId,
ProjectId: remoteProjectId,
}
for i := 2; i < 30; i++ {
_, err := iRegion.GetISecurityGroupByName(opts)
models.RunSyncSecgroupTask(func() {
err := func() error {
iRegion, err := vpc.GetIRegion()
if err != nil {
if errors.Cause(err) == cloudprovider.ErrNotFound {
break
}
if errors.Cause(err) != cloudprovider.ErrDuplicateId {
return "", err
return errors.Wrap(err, "vpc.GetIRegion")
}
var iSecgroup cloudprovider.ICloudSecurityGroup = nil
if len(cache.ExternalId) > 0 {
iSecgroup, err = iRegion.GetISecurityGroupById(cache.ExternalId)
if err != nil {
if errors.Cause(err) != cloudprovider.ErrNotFound {
return errors.Wrap(err, "iRegion.GetSecurityGroupById")
}
cache.ExternalId = ""
}
}
opts.Name = randomString(secgroup.Name, i)
}
conf := &cloudprovider.SecurityGroupCreateInput{
Name: opts.Name,
Desc: secgroup.Description,
VpcId: vpcId,
ProjectId: remoteProjectId,
Rules: secgroup.GetSecRules(""),
}
iSecgroup, err = iRegion.CreateISecurityGroup(conf)
if err != nil {
return "", errors.Wrap(err, "iRegion.CreateISecurityGroup")
}
}
_, err = db.Update(cache, func() error {
cache.ExternalId = iSecgroup.GetGlobalId()
cache.Name = iSecgroup.GetName()
cache.Status = api.SECGROUP_CACHE_STATUS_READY
return nil
if len(cache.ExternalId) == 0 {
if strings.ToLower(secgroup.Name) == "default" { //避免有些云不支持default关键字
secgroup.Name = "DefaultGroup"
}
// 避免有的云不支持重名安全组
randomString := func(prefix string, length int) string {
return fmt.Sprintf("%s-%s", prefix, rand.String(length))
}
opts := &cloudprovider.SecurityGroupFilterOptions{
Name: randomString(secgroup.Name, 1),
VpcId: vpcId,
ProjectId: remoteProjectId,
}
for i := 2; i < 30; i++ {
_, err := iRegion.GetISecurityGroupByName(opts)
if err != nil {
if errors.Cause(err) == cloudprovider.ErrNotFound {
break
}
if errors.Cause(err) != cloudprovider.ErrDuplicateId {
return errors.Wrapf(err, "GetISecurityGroupByName")
}
}
opts.Name = randomString(secgroup.Name, i)
}
conf := &cloudprovider.SecurityGroupCreateInput{
Name: opts.Name,
Desc: secgroup.Description,
VpcId: vpcId,
ProjectId: remoteProjectId,
Rules: secgroup.GetSecRules(""),
}
iSecgroup, err = iRegion.CreateISecurityGroup(conf)
if err != nil {
return errors.Wrapf(err, "iRegion.CreateISecurityGroup")
}
}
_, err = db.Update(cache, func() error {
cache.ExternalId = iSecgroup.GetGlobalId()
cache.Name = iSecgroup.GetName()
cache.Status = api.SECGROUP_CACHE_STATUS_READY
return nil
})
if err != nil {
return errors.Wrapf(err, "db.Update")
}
rules, err := iSecgroup.GetRules()
if err != nil {
return errors.Wrapf(err, "iSecgroup.GetRules")
}
maxPriority := region.GetDriver().GetSecurityGroupRuleMaxPriority()
minPriority := region.GetDriver().GetSecurityGroupRuleMinPriority()
defaultInRule := region.GetDriver().GetDefaultSecurityGroupInRule()
defaultOutRule := region.GetDriver().GetDefaultSecurityGroupOutRule()
order := region.GetDriver().GetSecurityGroupRuleOrder()
onlyAllowRules := region.GetDriver().IsOnlySupportAllowRules()
localRules := secrules.SecurityRuleSet(secgroup.GetSecRules(""))
common, inAdds, outAdds, inDels, outDels := cloudprovider.CompareRules(minPriority, maxPriority, order, localRules, rules, defaultInRule, defaultOutRule, onlyAllowRules, false)
if len(inAdds) == 0 && len(inDels) == 0 && len(outAdds) == 0 && len(outDels) == 0 {
return nil
}
return iSecgroup.SyncRules(common, inAdds, outAdds, inDels, outDels)
}()
waitChan <- err
})
err = <-waitChan
if err != nil {
return "", errors.Wrap(err, "db.Update")
return "", err
}
rules, err := iSecgroup.GetRules()
cache, err = models.SecurityGroupCacheManager.Register(ctx, userCred, secgroup.Id, vpcId, region.Id, vpc.ManagerId, remoteProjectId)
if err != nil {
return "", errors.Wrap(err, "iSecgroup.GetRules")
}
maxPriority := region.GetDriver().GetSecurityGroupRuleMaxPriority()
minPriority := region.GetDriver().GetSecurityGroupRuleMinPriority()
defaultInRule := region.GetDriver().GetDefaultSecurityGroupInRule()
defaultOutRule := region.GetDriver().GetDefaultSecurityGroupOutRule()
order := region.GetDriver().GetSecurityGroupRuleOrder()
onlyAllowRules := region.GetDriver().IsOnlySupportAllowRules()
localRules := secrules.SecurityRuleSet(secgroup.GetSecRules(""))
common, inAdds, outAdds, inDels, outDels := cloudprovider.CompareRules(minPriority, maxPriority, order, localRules, rules, defaultInRule, defaultOutRule, onlyAllowRules, false)
if len(inAdds) == 0 && len(inDels) == 0 && len(outAdds) == 0 && len(outDels) == 0 {
return cache.ExternalId, nil
}
err = iSecgroup.SyncRules(common, inAdds, outAdds, inDels, outDels)
if err != nil {
return "", errors.Wrap(err, "iSecgroup.SyncRules")
return "", errors.Wrap(err, "SSecurityGroupCache.Register")
}
return cache.ExternalId, nil

View File

@@ -16,8 +16,11 @@ package tasks
import (
"context"
"database/sql"
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
@@ -62,6 +65,18 @@ func (self *CloudAccountDeleteTask) OnInit(ctx context.Context, obj db.IStandalo
func (self *CloudAccountDeleteTask) OnAllCloudProviderDeleteComplete(ctx context.Context, obj db.IStandaloneModel, body jsonutils.JSONObject) {
account := obj.(*models.SCloudaccount)
// check providers deleted success
count, err := account.GetProviderCount()
if err != nil && errors.Cause(err) != sql.ErrNoRows {
self.OnAllCloudProviderDeleteCompleteFailed(ctx, obj, jsonutils.NewString(err.Error()))
return
}
if count > 0 {
self.OnAllCloudProviderDeleteCompleteFailed(ctx, obj, jsonutils.NewString(fmt.Sprintf("cloudprovider deleted failed count %d", count)))
return
}
account.RealDelete(ctx, self.UserCred)
self.SetStageComplete(ctx, nil)

View File

@@ -157,5 +157,5 @@ func (self *SnapshotCleanupTask) OnDeleteSnapshot(ctx context.Context, obj db.IS
func (self *SnapshotCleanupTask) OnDeleteSnapshotFailed(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
log.Errorf("snapshot delete faield %s", data)
self.OnDeleteSnapshot(ctx, obj, data)
self.SetStageFailed(ctx, data.String())
}

View File

@@ -101,10 +101,13 @@ func (self *DiskDeleteTask) startDeleteDisk(ctx context.Context, disk *models.SD
)
storage = disk.GetStorage()
if storage != nil {
host = storage.GetMasterHost()
if storage == nil { // dirty data
self.OnGuestDiskDeleteComplete(ctx, disk, nil)
return
}
host = storage.GetMasterHost()
isPurge := false
if (host == nil || !host.GetEnabled()) && jsonutils.QueryBoolean(self.Params, "purge", false) {
isPurge = true
@@ -112,21 +115,25 @@ func (self *DiskDeleteTask) startDeleteDisk(ctx context.Context, disk *models.SD
disk.SetStatus(self.UserCred, api.DISK_DEALLOC, "")
if isPurge {
self.OnGuestDiskDeleteComplete(ctx, disk, nil)
return
}
if isNeed, _ := disk.IsNeedWaitSnapshotsDeleted(); isNeed { // for kvm rbd disk
self.OnGuestDiskDeleteComplete(ctx, disk, nil)
return
}
if len(disk.BackupStorageId) > 0 {
self.SetStage("OnMasterStorageDeleteDiskComplete", nil)
} else {
if isNeed, _ := disk.IsNeedWaitSnapshotsDeleted(); isNeed {
self.OnGuestDiskDeleteComplete(ctx, disk, nil)
return
}
if len(disk.BackupStorageId) > 0 {
self.SetStage("OnMasterStorageDeleteDiskComplete", nil)
} else {
self.SetStage("OnGuestDiskDeleteComplete", nil)
}
if host == nil {
self.OnGuestDiskDeleteCompleteFailed(ctx, disk, jsonutils.NewString("fail to find master host"))
} else if err := host.GetHostDriver().RequestDeallocateDiskOnHost(ctx, host, storage, disk, self); err != nil {
self.OnGuestDiskDeleteCompleteFailed(ctx, disk, jsonutils.NewString(err.Error()))
}
self.SetStage("OnGuestDiskDeleteComplete", nil)
}
if host == nil {
self.OnGuestDiskDeleteCompleteFailed(ctx, disk, jsonutils.NewString("fail to find master host"))
return
}
err := host.GetHostDriver().RequestDeallocateDiskOnHost(ctx, host, storage, disk, self)
if err != nil {
self.OnGuestDiskDeleteCompleteFailed(ctx, disk, jsonutils.NewString(err.Error()))
return
}
}

View File

@@ -99,7 +99,7 @@ func (self *GuestDetachDiskTask) OnDetachDiskComplete(ctx context.Context, guest
return
}
}
models.StartResourceSyncStatusTask(ctx, self.GetUserCred(), disk, "DiskSyncstatusTask", "")
disk.SetStatus(self.UserCred, api.DISK_READY, "on detach disk complete")
keepDisk := jsonutils.QueryBoolean(self.Params, "keep_disk", true)
host := guest.GetHost()
purge := false

View File

@@ -133,7 +133,6 @@ func Start(app *appsrv.Application) error {
}
func (agent *SEsxiAgent) AddImageCacheHandler(prefix string, app *appsrv.Application) {
hostutils.InitWorkerManager()
app.AddHandler("POST",
fmt.Sprintf("%s/disks/image_cache", prefix),
auth.Authenticate(func(ctx context.Context, w http.ResponseWriter, r *http.Request) {

View File

@@ -75,7 +75,7 @@ func uploadHandler(ctx context.Context, w http.ResponseWriter, r *http.Request)
httperrors.MissingParameterError(w, "miss disk")
return
}
hostutils.DelayTask(ctx, esxi.EsxiAgent.AgentStorage.SaveToGlance, disk)
hostutils.DelayTaskWithoutReqctx(ctx, esxi.EsxiAgent.AgentStorage.SaveToGlance, disk)
hostutils.ResponseOk(ctx, w)
}

View File

@@ -19,18 +19,19 @@ import common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
type EsxiOptions struct {
common_options.CommonOptions
ListenInterface string `help:"Master address of host server" default:"br0"`
ListenAddress string `help:"Host serve IP address to select when multiple address bind to ListenInterface"`
EsxiAgentPath string `default:"/opt/cloud/workspace/esxi_agent" help:"Path for esxi agent configuration files"`
ImageCachePath string `help:"Path for storing image caches"`
ImageCacheLimit int `help:"Maximal storage space for image caching, in GB" default:"20"`
AgentTempPath string `help:"Path for ESXI Agent"`
AgentTempLimit int `help:"Maximal storage space for ESXi agent, in GB" default:"20"`
LinuxDefaultRootUser bool `help:"Default account for Linux system is root" default:"false"`
WindowsDefaultAdminUser bool `help:"Default account for Windows system is Administrator" default:"true"`
DefaultImageSaveFormat string `help:"Default image save format, default is vmdk, canbe qcow2" default:"vmdk"`
Zone string `help:"Zone where the agent locates"`
DeployServerSocketPath string `help:"Deploy server listen socket path" default:"/var/run/deploy.sock"`
ListenInterface string `help:"Master address of host server" default:"br0"`
ListenAddress string `help:"Host serve IP address to select when multiple address bind to ListenInterface"`
EsxiAgentPath string `default:"/opt/cloud/workspace/esxi_agent" help:"Path for esxi agent configuration files"`
ImageCachePath string `help:"Path for storing image caches"`
ImageCacheLimit int `help:"Maximal storage space for image caching, in GB" default:"20"`
AgentTempPath string `help:"Path for ESXI Agent"`
AgentTempLimit int `help:"Maximal storage space for ESXi agent, in GB" default:"20"`
LinuxDefaultRootUser bool `help:"Default account for Linux system is root" default:"false"`
WindowsDefaultAdminUser bool `help:"Default account for Windows system is Administrator" default:"true"`
DefaultImageSaveFormat string `help:"Default image save format, default is vmdk, canbe qcow2" default:"vmdk"`
Zone string `help:"Zone where the agent locates"`
DeployServerSocketPath string `help:"Deploy server listen socket path" default:"/var/run/deploy.sock"`
HostDelayTaskWorkerCount int `default:"8" help:"Host delay worker thread count, default is 8"`
}
var (

View File

@@ -30,6 +30,7 @@ import (
"yunion.io/x/onecloud/pkg/esxi/options"
"yunion.io/x/onecloud/pkg/hostman/guestfs/fsdriver"
"yunion.io/x/onecloud/pkg/hostman/hostdeployer/deployclient"
"yunion.io/x/onecloud/pkg/hostman/hostutils"
)
type SExsiAgentService struct {
@@ -70,6 +71,7 @@ func (s *SExsiAgentService) StartService() {
fsdriver.Init(nil)
deployclient.Init(options.Options.DeployServerSocketPath)
hostutils.InitWorkerManagerWithCount(options.Options.HostDelayTaskWorkerCount)
app := app_common.InitApp(&options.Options.BaseOptions, false)
handler.InitHandlers(app)

View File

@@ -764,7 +764,7 @@ func (d *SUbuntuRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.Release
lines := strings.Split(string(rel), "\n")
for _, l := range lines {
if strings.HasPrefix(l, distroKey) {
version = strings.TrimSpace(l[len(distroKey) : len(l)-1])
version = strings.TrimSpace(l[len(distroKey):])
}
}
return deployapi.NewReleaseInfo(d.GetName(), version, d.GetArch(rootFs))

View File

@@ -103,7 +103,7 @@ func (p *SKVMGuestDiskPartition) MountPartReadOnly() bool {
func (p *SKVMGuestDiskPartition) Mount() bool {
if len(p.fs) == 0 || utils.IsInStringArray(p.fs, []string{"swap", "btrfs"}) {
log.Errorf("Mount fs failed: %s", p.fs)
log.Errorf("Mount fs failed: unsupport fs %s on %s", p.fs, p.partDev)
return false
}
err := p.fsck()
@@ -127,6 +127,7 @@ func (p *SKVMGuestDiskPartition) Mount() bool {
p.readonly = true
}
}
log.Infof("mount fs %s on %s success", p.fs, p.partDev)
return true
}
@@ -154,7 +155,21 @@ func (p *SKVMGuestDiskPartition) mount(readonly bool) error {
cmds = append(cmds, "-o", opt)
}
cmds = append(cmds, p.partDev, p.mountPath)
_, err := procutils.NewCommand(cmds[0], cmds[1:]...).Output()
var err error
if fsType == "xfs" {
uuids := fileutils2.GetDevUuid(p.partDev)
uuid := uuids["UUID"]
if len(uuid) > 0 {
LockXfsPartition(uuid)
defer func() {
if err != nil {
UnlockXfsPartition(uuid)
}
}()
}
}
_, err = procutils.NewCommand(cmds[0], cmds[1:]...).Output()
return err
}
@@ -217,6 +232,13 @@ func (p *SKVMGuestDiskPartition) Umount() bool {
tries += 1
_, err := procutils.NewCommand("umount", p.mountPath).Output()
if err == nil {
if p.fs == "xfs" {
uuids := fileutils2.GetDevUuid(p.partDev)
uuid := uuids["UUID"]
if len(uuid) > 0 {
UnlockXfsPartition(uuid)
}
}
procutils.NewCommand("blockdev", "--flushbufs", p.partDev).Output()
os.Remove(p.mountPath)
return true

View File

@@ -0,0 +1,40 @@
package guestfs
import (
"sync"
"yunion.io/x/log"
)
func LockXfsPartition(uuid string) {
log.Infof("xfs lock %s", uuid)
var (
xfsLock *sync.Mutex
ok bool
)
mapLock.Lock()
xfsLock, ok = xfsMountUniqueTool[uuid]
if !ok {
xfsLock = new(sync.Mutex)
xfsMountUniqueTool[uuid] = xfsLock
}
mapLock.Unlock()
xfsLock.Lock()
}
func UnlockXfsPartition(uuid string) {
log.Infof("xfs unlock %s", uuid)
mapLock.Lock()
xfsLock := xfsMountUniqueTool[uuid]
mapLock.Unlock()
xfsLock.Unlock()
}
var (
mapLock = sync.Mutex{}
xfsMountUniqueTool = map[string]*sync.Mutex{}
)

View File

@@ -993,10 +993,13 @@ func (s *SKVMGuestInstance) ExecSuspendTask(ctx context.Context) {
func (s *SKVMGuestInstance) GetNicDescMatch(mac, ip, port, bridge string) jsonutils.JSONObject {
nics, _ := s.Desc.GetArray("nics")
for _, nic := range nics {
nicBridge, _ := nic.GetString("bridge")
if bridge == "" && nicBridge != "" && nicBridge == options.HostOptions.OvnIntegrationBridge {
continue
}
nicMac, _ := nic.GetString("mac")
nicIp, _ := nic.GetString("ip")
nicPort, _ := nic.GetString("ifname")
nicBridge, _ := nic.GetString("bridge")
if (len(mac) == 0 || netutils2.MacEqual(nicMac, mac)) &&
(len(ip) == 0 || nicIp == ip) &&
(len(port) == 0 || nicPort == port) &&

View File

@@ -79,6 +79,11 @@ func (s *SKVMGuestInstance) getOsname() string {
return osName
}
func (s *SKVMGuestInstance) disableUsbKbd() bool {
val, _ := s.Desc.GetString("metadata", "disable_usb_kbd")
return val == "true"
}
func (s *SKVMGuestInstance) getOsDistribution() string {
osDis, _ := s.Desc.GetString("metadata", "os_distribution")
return osDis
@@ -499,7 +504,7 @@ func (s *SKVMGuestInstance) _generateStartScript(data *jsonutils.JSONDict) (stri
cmd += " -device virtio-serial"
cmd += " -usb"
if !utils.IsInStringArray(s.getOsDistribution(), []string{OS_NAME_OPENWRT, OS_NAME_CIRROS}) {
if !utils.IsInStringArray(s.getOsDistribution(), []string{OS_NAME_OPENWRT, OS_NAME_CIRROS}) && !s.disableUsbKbd() {
cmd += " -device usb-kbd"
}
// # if osname == self.OS_NAME_ANDROID:

View File

@@ -757,6 +757,7 @@ func (h *SHostInfo) tryCreateNetworkOnWire() {
params.Set("mask", jsonutils.NewInt(int64(mask)))
params.Set("is_on_premise", jsonutils.JSONTrue)
params.Set("server_type", jsonutils.NewString(api.NETWORK_TYPE_BAREMETAL))
params.Set("is_on_premise", jsonutils.JSONTrue)
ret, err := modules.Networks.PerformClassAction(
hostutils.GetComputeSession(context.Background()),
"try-create-network", params)
@@ -1295,6 +1296,9 @@ func (h *SHostInfo) onGetStorageInfoSucc(hoststorages []jsonutils.JSONObject) {
func (h *SHostInfo) uploadStorageInfo() {
for _, s := range storageman.GetManager().Storages {
if err := s.SetStorageInfo(s.GetId(), s.GetStorageName(), s.GetStorageConf()); err != nil {
h.onFail(err)
}
res, err := s.SyncStorageInfo()
if err != nil {
h.onFail(err)

View File

@@ -189,7 +189,11 @@ func DelayTaskWithWorker(
}
func InitWorkerManager() {
wm = workmanager.NewWorkManger(TaskFailed, TaskComplete, options.HostOptions.DefaultRequestWorkerCount)
InitWorkerManagerWithCount(options.HostOptions.DefaultRequestWorkerCount)
}
func InitWorkerManagerWithCount(count int) {
wm = workmanager.NewWorkManger(TaskFailed, TaskComplete, count)
}
func InitK8sWorkerManager() {

View File

@@ -191,8 +191,8 @@ func (l *SLocalImageCache) prepare(ctx context.Context, zone, srcUrl, format str
}
func (l *SLocalImageCache) fetch(ctx context.Context, zone, srcUrl, format string) bool {
if (fileutils2.Exists(l.GetPath()) &&
l.remoteFile.VerifyIntegrity()) || l.remoteFile.Fetch() {
if (fileutils2.Exists(l.GetPath()) && l.remoteFile.VerifyIntegrity()) ||
l.remoteFile.Fetch() {
if len(l.Manager.GetId()) > 0 {
_, err := hostutils.RemoteStoragecacheCacheImage(ctx,
l.Manager.GetId(), l.imageId, "ready", l.GetPath())

View File

@@ -24,7 +24,6 @@ import (
"yunion.io/x/log"
"yunion.io/x/onecloud/pkg/hostman/hostutils"
"yunion.io/x/onecloud/pkg/hostman/options"
"yunion.io/x/onecloud/pkg/hostman/storageman/remotefile"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/util/procutils"
@@ -75,11 +74,11 @@ func (r *SRbdImageCache) Acquire(ctx context.Context, zone, srcUrl, format strin
}
r.imageName = localImageCache.GetName()
if !r.Load() {
log.Debugf("convert local image %s to rbd pool %s", r.imageId, r.Manager.GetPath())
log.Infof("convert local image %s to rbd pool %s", r.imageId, r.Manager.GetPath())
err := procutils.NewRemoteCommandAsFarAsPossible(qemutils.GetQemuImg(),
"convert", "-O", "raw", localImageCache.GetPath(), r.GetPath()).Run()
if err != nil {
log.Errorf("failed to convert image %s", options.HostOptions.ServersPath)
log.Errorf("failed to convert image %s", err)
return false
}
}

View File

@@ -211,26 +211,16 @@ func (c *SAgentImageCacheManager) prefetchImageCacheByUpload(ctx context.Context
}
func (c *SAgentImageCacheManager) perfetchTemplateVMImageCache(ctx context.Context, data *sImageCacheData) (jsonutils.JSONObject, error) {
client, err := esxi.NewESXiClientFromAccessInfo(ctx, &data.Datastore)
if err != nil {
return nil, errors.Wrap(err, "esxi.NewESXiClientFromJson")
}
// data.StorageCacheExternalId is Host Ip associated with the StorageCache in where CachedImage stored
host, err := client.FindHostByIp(data.StorageCacheHostIp)
_, err = client.SearchTemplateVM(data.ImageExternalId)
if err != nil {
return nil, err
}
dc, err := host.GetDatacenter()
if err != nil {
return nil, errors.Wrap(err, "host.GetDatacenter")
}
_, err = dc.GetTemplateVMById(data.ImageExternalId)
if err != nil {
return nil, err
return nil, errors.Wrapf(err, "SEsxiClient.SearchTemplateVM for image %q", data.ImageExternalId)
}
res := jsonutils.NewDict()
res.Add(jsonutils.NewString(data.ImageId), "image_id")
res.Add(jsonutils.NewString(data.ImageExternalId), "image_id")
return res, nil
}

View File

@@ -111,7 +111,7 @@ func (c *SRbdImageCacheManager) PrefetchImageCache(ctx context.Context, data int
if err != nil {
return nil, err
}
format := "qcow2"
format, _ := body.GetString("format")
srcUrl, _ := body.GetString("src_url")
zone, _ := body.GetString("zone")

View File

@@ -259,7 +259,13 @@ func (r *SRemoteFile) downloadInternal(getData bool, preChksum string) bool {
}
func (r *SRemoteFile) setProperties(header http.Header) {
r.chksum = header.Get("X-Image-Meta-Checksum")
r.format = header.Get("X-Image-Meta-Disk_format")
r.name = header.Get("X-Image-Meta-Name")
if chksum := header.Get("X-Image-Meta-Checksum"); len(chksum) > 0 {
r.chksum = chksum
}
if format := header.Get("X-Image-Meta-Disk_format"); len(format) > 0 {
r.format = format
}
if name := header.Get("X-Image-Meta-Name"); len(name) > 0 {
r.name = name
}
}

View File

@@ -125,6 +125,7 @@ type IStorage interface {
disksBackingFile, srcSnapshots jsonutils.JSONObject, rebaseDisks bool, diskDesc jsonutils.JSONObject) error
Accessible() error
Detach() error
}
type SBaseStorage struct {
@@ -262,6 +263,7 @@ func (s *SBaseStorage) bindMountTo(sPath string) error {
return errors.Errorf("bind mount temp path to local image path failed %s", out)
}
}
log.Infof("bind mount %s -> %s", tempPath, sPath)
return nil
}

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