Compare commits

...

431 Commits

Author SHA1 Message Date
Zexi Li
5466a88ac3 Merge pull request #9115 from yousong/automated-cherry-pick-of-#9109-upstream-release-3.1
Automated cherry pick of #9109: fix(host): make sure it won't match vpc guests by accident
2020-12-01 20:22:08 +08:00
Yousong Zhou
3a23f64836 fix(host): make sure it won't match vpc guests by accident 2020-12-01 15:34:34 +08:00
yunion-ci-robot
cc48edc32d Merge pull request #8530 from rainzm/automated-cherry-pick-of-#8525-upstream-release-3.1
Automated cherry pick of #8525: fix(esxi): no callback in uploadHandler
2020-10-28 00:57:41 +08:00
rainzm
a77dfee4d3 fix(esxi): filter vmdk item in lease.info 2020-10-27 21:35:55 +08:00
rainzm
e70c1244e3 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:35:55 +08:00
rainzm
bc8ee81afd fix(esxi): no callback in uploadHandler 2020-10-27 21:35:55 +08:00
yunion-ci-robot
be3d7a4fbb Merge pull request #8318 from rainzm/automated-cherry-pick-of-#8314-upstream-release-3.1
Automated cherry pick of #8314: feat(esxi): do not specify portkey in NewVNIC
2020-10-16 10:40:34 +08:00
rainzm
3f8c5fd12c feat(esxi): do not specify portkey in NewVNIC 2020-10-16 08:25:36 +08:00
Zexi Li
d06343b6cf Merge pull request #8262 from rainzm/automated-cherry-pick-of-#8232-upstream-release-3.1
Automated cherry pick of #8232: fix(esxi): search template from whole vCenter
2020-10-13 10:08:24 +08:00
rainzm
19335a1fbf 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:51:33 +08:00
rainzm
999f6e2dba fix(esxi): search template from whole vCenter 2020-10-12 17:51:33 +08:00
yunion-ci-robot
6f94124e81 Merge pull request #8198 from rainzm/automated-cherry-pick-of-#8194-upstream-release-3.1
Automated cherry pick of #8194: fix(esxi): check nil value when NewVirtualMachine
2020-10-10 19:05:16 +08:00
yunion-ci-robot
fa457b0461 Merge pull request #8222 from yousong/automated-cherry-pick-of-#8218-upstream-release-3.1
Automated cherry pick of #8218: webconsole: ssh: each argument on its own line
2020-10-10 15:34:49 +08:00
Yousong Zhou
38778aae06 webconsole: ssh: add keyboard-interactive as an option
For ESXi 6.0

  Authentications that can continue: publickey,keyboard-interactive
2020-10-10 14:48:17 +08:00
Yousong Zhou
38cd512516 webconsole: ssh: each argument on its own line 2020-10-10 14:47:41 +08:00
yunion-ci-robot
23cc211deb Merge pull request #8187 from yousong/automated-cherry-pick-of-#8183-upstream-release-3.1
Automated cherry pick of #8183: vpcagent: ovn: increase dhcp lease, renew, rebind time
2020-10-10 11:56:13 +08:00
rainzm
48d764dd36 fix(esxi): check nil value when NewVirtualMachine 2020-10-10 11:39:06 +08:00
Yousong Zhou
d708af7781 vpcagent: ovn: increase dhcp lease, renew, rebind time 2020-10-09 10:29:12 +08:00
Zexi Li
4e806ed185 Merge pull request #7965 from zexi/automated-cherry-pick-of-#7961-upstream-release-3.1
Automated cherry pick of #7961: region: fix network schedtag not cleanup when network deleted
2020-09-18 12:45:13 +08:00
Zexi Li
0ac14febc8 region: fix network schedtag not cleanup when network deleted 2020-09-18 10:40:32 +08:00
Zexi Li
a1b2a4ddcd Merge pull request #7874 from rainzm/automated-cherry-pick-of-#7870-upstream-release-3.1
Automated cherry pick of #7870: fix(esxiagent): add HostDelayTaskWorkerCount
2020-09-11 20:56:12 +08:00
Zexi Li
f405cb921b Merge pull request #7866 from wanyaoqi/automated-cherry-pick-of-#7836-upstream-release-3.1
Automated cherry pick of #7836: host: fix rbd storage cache iso image
2020-09-11 20:54:01 +08:00
rainzm
112026b778 fix(esxiagent): add HostDelayTaskWorkerCount
之前,HostDelayWorker 是通过 hostutils.InitWorkerManager 来初始化,
worker的数量依赖于options.HostOptions.DefaultRequestWorkerCount, 因为
这个options没有经过初始化,所以就是0,导致worker count的数量变为1。

现在增加了 HostDelayTaskWorkerCount 来管理这个count,默认值为8。
2020-09-11 17:23:46 +08:00
wanyaoqi
b230711ded host: fix rbd storage cache iso image 2020-09-10 23:21:36 +08:00
yunion-ci-robot
716d4d2172 Merge pull request #7849 from rainzm/automated-cherry-pick-of-#7845-upstream-release-3.1
Automated cherry pick of #7845: Feat & Fix & Refactor for ESXi
2020-09-10 09:41:57 +08:00
rainzm
182777e677 fix(region): add RequestSyncstatusOnHost for SESXiGuestDriver
esxi 平台 Guest 进行 syncstatus 和其他平台有所区别,Vcenter 可能会更改
 VM 所在的 Host,所以在 Host 上寻找 VM 可能会出现 ErrNotFound。此时,应该
主动去整个 datacenter 中寻找 VM,然后更改 Host,进行同步。
2020-09-09 22:01:35 +08:00
rainzm
2fdb1430a4 fix(esxi): fetch templatevm from datacenter before clone vm
这里应该和image_cache那里保持一直,对template的获取应该从datacenter
中获取,而不是host。
2020-09-09 22:00:02 +08:00
rainzm
bb1f439a04 refactor(esxi): replace GetTemplateVMById with FetchTemplateVMById
FetchTemplateVMById 更好,因为它更轻量,更快。
2020-09-09 22:00:02 +08:00
rainzm
595be9b0ed feat(esxicli): better vm operator
现在,可以通过Datacenter来获取vm,不一定要指定HostIp,
Datacenter和HostIp必须指定一个。
2020-09-09 22:00:02 +08:00
rainzm
1f9b473521 feat(esxi): support fetchVM form datacenter 2020-09-09 22:00:02 +08:00
rainzm
6f47aa8ad3 refactor(esxi): fetchVms and fetchHardwareInfo
1. fetchHardwareInfo 只有一种error,原因是moVM的某些字段为nil,这种情况下,完全可以打印日志直接返回。
2. fetchVms 现在只返回[]*SVirtualMachine, 进一步的过滤(是不是template)交给调用者。
2020-09-09 22:00:02 +08:00
yunion-ci-robot
c2c981c40f Merge pull request #7826 from rainzm/automated-cherry-pick-of-#7821-upstream-release-3.1
Automated cherry pick of #7821: fix(esxiagent): return image extid not id
2020-09-08 20:23:54 +08:00
rainzm
3eefd80d84 fix(esxiagent): return image extid not id
调用 disk/image_cache 接口的Task StorageCacheImageTask 会根据回调
回来数据中的 image_id,来设置 storagecachedimage 中的 externalid,
所以这里的 image_id 应该是 externalid。
2020-09-08 15:35:00 +08:00
wanyaoqi
97d438e4a4 fix get storage capacity on init' (#7690) 2020-09-01 01:01:36 +08:00
Zexi Li
3aec0a110e Merge pull request #7626 from wanyaoqi/automated-cherry-pick-of-#7623-upstream-release-3.1
Automated cherry pick of #7623: fix gpfs check mountpoint
2020-08-25 17:41:28 +08:00
wanyaoqi
ab5245bd29 fix gpfs check mountpoint 2020-08-25 15:53:25 +08:00
Zexi Li
3eb4a31c46 Merge pull request #7578 from rainzm/automated-cherry-pick-of-#7575-upstream-release-3.1
Automated cherry pick of #7575: fix: GetIImages correctly without 'image_cache' dir
2020-08-16 23:42:03 +08:00
rainzm
e5a5439ac9 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:37:30 +08:00
Zexi Li
41e2a194e4 Merge pull request #7538 from wanyaoqi/automated-cherry-pick-of-#7530-upstream-release-3.1
Automated cherry pick of #7530: fix mount xfs
2020-08-11 11:16:53 +08:00
wanyaoqi
64c801dbca fix mount xfs 2020-08-10 20:06:19 +08:00
Zexi Li
34fa66230b Merge pull request #7450 from tb365/automated-cherry-pick-of-#7447-upstream-release-3.1
Automated cherry pick of #7447: aws elb listener&rule name too long fix
2020-08-02 10:08:50 +08:00
wanyaoqi
1fd2b2eebc fix cache non lvm disks (#7462) 2020-08-01 21:13:02 +08:00
tangbin
72e99816a2 aws elb listener&rule name too long fix 2020-08-01 11:13:20 +08:00
Zexi Li
1cf5771607 Merge pull request #7424 from rainzm/automated-cherry-pick-of-#7416-upstream-release-3.1
Automated cherry pick of #7416: fix(region): Don't allow address conflicts under vpc
2020-08-01 11:06:03 +08:00
rainzm
91efa6f48d fix(region): Don't allow address conflicts under vpc
Except for default vpc, vpc and wire have a one-to-one correspondence.
So prohibiting the address conflict of wire does not avoid
the address conflict of default vpc.
2020-08-01 10:53:09 +08:00
Zexi Li
400a87221d Merge pull request #7444 from wanyaoqi/automated-cherry-pick-of-#7441-upstream-release-3.1
Automated cherry pick of #7441: fix deploy admin auth key
2020-08-01 00:07:09 +08:00
wanyaoqi
7e6fb93a3e fix deploy admin auth key 2020-07-31 23:27:05 +08:00
Zexi Li
f91526f96f baremetal: fix hpssactl split last LV size out of limit (#7429) 2020-07-31 22:38:00 +08:00
Zexi Li
e5cabfb3a8 Merge pull request #7422 from ioito/automated-cherry-pick-of-#7417-upstream-release-3.1
Automated cherry pick of #7417: fix: avoid lost backend params
2020-07-31 18:08:07 +08:00
Zexi Li
68a31e0d14 Merge pull request #7410 from ioito/automated-cherry-pick-of-#7405-upstream-release-3.1
Automated cherry pick of #7405: fix: avoid account sync deadlock
2020-07-31 18:05:34 +08:00
Qu Xuan
be45e166cb fix: avoid lost backend params 2020-07-31 17:20:23 +08:00
Qu Xuan
0bc58b8fe3 fix: avoid account sync deadlock 2020-07-31 16:41:00 +08:00
Zexi Li
7d92493e3a Merge pull request #7362 from ioito/automated-cherry-pick-of-#7359-upstream-release-3.1
Automated cherry pick of #7359: fix: 修复vm绑定重复安全组
2020-07-28 20:56:11 +08:00
Qu Xuan
4663ecddf4 fix: 修复vm绑定重复安全组 2020-07-28 18:16:47 +08:00
Zexi Li
0bd0782268 Merge pull request #7341 from rainzm/automated-cherry-pick-of-#7338-upstream-release-3.1
Automated cherry pick of #7338: fix(region): Remove default secgroup for esxi guest
2020-07-27 19:49:28 +08:00
rainzm
c5b719b21f fix(region): Remove default secgroup for esxi guest
1. InitializeData remove all secgroup_id of esxi guest from database
2. Set input.SecgroupId as empty for guest whose GetMaxSecurityGroupCount
return 0
2020-07-27 14:54:47 +08:00
yunion-ci-robot
7b470196ef Merge pull request #7306 from wanyaoqi/automated-cherry-pick-of-#7302-upstream-release-3.1
Automated cherry pick of #7302: fix clone clean pending usage
2020-07-24 22:51:41 +08:00
wanyaoqi
f1113a9c23 fix clone clean pending usage 2020-07-23 18:39:22 +08:00
Zexi Li
b56e49de6d Merge pull request #7297 from wanyaoqi/automated-cherry-pick-of-#7294-upstream-release-3.1
Automated cherry pick of #7294: fix snapshot clean pending usage
2020-07-23 13:48:18 +08:00
wanyaoqi
3f270e8bd3 fix snapshot clean pending usage 2020-07-23 11:40:58 +08:00
Zexi Li
de893473d6 Merge pull request #7289 from tb365/automated-cherry-pick-of-#7286-upstream-release-3.1
Automated cherry pick of #7286: apigateway host imports data validate
2020-07-22 21:44:22 +08:00
tangbin
6809f62d95 format fix 2020-07-22 18:05:07 +08:00
tangbin
c345991bd4 fix empty else 2020-07-22 18:05:07 +08:00
tangbin
e5f95e0986 fix host import 2020-07-22 18:05:07 +08:00
tangbin
e8bd33751c fix huawei delete resource 2020-07-22 18:05:07 +08:00
tangbin
727801bff5 fix huawei elb disable healthcheck 2020-07-22 18:05:07 +08:00
tangbin
3e56e4acb8 lb sync project fix 2020-07-22 18:05:06 +08:00
tangbin
f79abe479a add more log 2020-07-22 17:51:27 +08:00
tangbin
ec8e58554a apigateway host imports data validate 2020-07-22 17:51:27 +08:00
Zexi Li
5a731d8176 Merge pull request #7284 from rainzm/automated-cherry-pick-of-#7281-upstream-release-3.1
Automated cherry pick of #7281: fix(esxi): Select correct unitNumber for ide control when creating disk
2020-07-22 13:52:33 +08:00
Rain Zheng
4515843a2c fix(esxi): Select correct unitNumber for ide control when creating disk 2020-07-21 20:49:48 +08:00
Zexi Li
8c1b1f80b6 Merge pull request #7261 from tb365/automated-cherry-pick-of-#7237-upstream-release-3.1
Automated cherry pick of #7237: huawei eip delete fix
2020-07-20 20:47:30 +08:00
tangbin
4b95ec7f0d huawei eip delete fix 2020-07-20 10:51:16 +08:00
Zexi Li
8ddf04e3dd Merge pull request #7219 from rainzm/automated-cherry-pick-of-#7216-upstream-release-3.1
Automated cherry pick of #7216: fix: prefetch image error when create guest with vmware template
2020-07-17 10:16:48 +08:00
rainzm
3b268ad6fb fix: prefetch image error when create guest with vmware template
1. Only need the corresponding vmware template in the vcenter where the host is
located.
2. Chose storagecache which cacheimage is ready before deploying.
2020-07-16 21:47:40 +08:00
yunion-ci-robot
21e7ea198c Merge pull request #7207 from zexi/automated-cherry-pick-of-#7201-upstream-release-3.1
Automated cherry pick of #7201: webconsole: fix old session make new session closed
2020-07-16 20:21:20 +08:00
Zexi Li
c09676aa9f webconsole: fix old session make new session closed 2020-07-16 18:51:09 +08:00
Zexi Li
ee69f560ae Merge pull request #7180 from ioito/automated-cherry-pick-of-#7177-upstream-release-3.1
Automated cherry pick of #7177: fix: 避免华为云安全组规则删除失败
2020-07-16 10:16:41 +08:00
Qu Xuan
92e75e87c9 fix: 避免华为云安全组规则删除失败 2020-07-15 17:14:45 +08:00
Zexi Li
4b2869cf4e Merge pull request #7161 from yousong/automated-cherry-pick-of-#7158-upstream-release-3.1
Automated cherry pick of #7158: iproute2: address: make Exact idempotent
2020-07-15 10:34:45 +08:00
Yousong Zhou
249abee22d iproute2: address: make Exact idempotent
Idempotence against address not available for Exact is not a bad idea if
we look at the name of that func

This should accomodate the race condition where keepalived will remove
vips should the primary address used for vrrp comms is removed, causing
later addr del to fail with "cannot assign requested address"
2020-07-14 16:42:49 +08:00
Zexi Li
27e99f8b51 Merge pull request #7150 from rainzm/automated-cherry-pick-of-#7147-upstream-release-3.1
Automated cherry pick of #7147: fix: mo.VirtualMachine's Config maybe nil
2020-07-14 11:34:52 +08:00
rainzm
5d1d963990 fix: mo.VirtualMachine's Config maybe nil 2020-07-13 23:30:04 +08:00
Zexi Li
9c27a7cafd Merge pull request #7128 from wanyaoqi/bugfix/wyq/cherry-pick-7125
Manual cherry pick of #7125: fix rbd set storage info
2020-07-10 20:16:07 +08:00
wanyaoqi
433aa54055 fix rbd set storage info 2020-07-10 14:56:15 +08:00
Zexi Li
cf8377ea72 Merge pull request #7109 from wanyaoqi/automated-cherry-pick-of-#7106-upstream-release-3.1
Automated cherry pick of #7106: fix set storage info bind mount
2020-07-09 21:19:44 +08:00
wanyaoqi
0a71acd86b fix set storage info bind mount 2020-07-09 14:56:37 +08:00
Zexi Li
780418219c Merge pull request #7064 from rainzm/automated-cherry-pick-of-#7061-upstream-release-3.1
Automated cherry pick of #7061: Update docker image onecloud-base and its references
2020-07-07 11:12:56 +08:00
rainzm
e5487fab4f Update docker image onecloud-base and its references 2020-07-06 21:06:20 +08:00
Zexi Li
546ec09848 Merge pull request #7039 from swordqiu/automated-cherry-pick-of-#7036-upstream-release-3.1
Automated cherry pick of #7036: fix: cloud account sync may block
2020-07-04 12:09:33 +08:00
Qiu Jian
1e49aa17b7 fix: cloud account sync may block 2020-07-04 10:25:41 +08:00
Zexi Li
bf3b06cd8c Merge pull request #7014 from wanyaoqi/automated-cherry-pick-of-#7006-upstream-release-3.1
Automated cherry pick of #7006: bind mount nfs storage path
2020-07-02 17:35:48 +08:00
wanyaoqi
289a6bcf4b bind mount nfs storage path 2020-07-02 17:34:59 +08:00
Zexi Li
46b80f79a3 Merge pull request #6993 from rainzm/automated-cherry-pick-of-#6990-upstream-release-3.1
Automated cherry pick of #6990: fix the bug introduced in #6643
2020-07-01 19:26:36 +08:00
rainzm
0438db6938 fix the bug introduced in #6643 2020-07-01 16:55:58 +08:00
Zexi Li
4d9b6e1599 Merge pull request #6978 from wanyaoqi/automated-cherry-pick-of-#6975-upstream-release-3.1
Automated cherry pick of #6975: fix deploy backup server order
2020-06-30 23:09:17 +08:00
wanyaoqi
2f4401a407 fix deploy backup server order 2020-06-30 22:04:30 +08:00
Zexi Li
e9855290e8 Merge pull request #6939 from swordqiu/automated-cherry-pick-of-#6936-upstream-release-3.1
Automated cherry pick of #6936: fix: sort quota list result by usage rate
2020-06-23 23:28:09 +08:00
Qiu Jian
228d45b7a1 fix: sort quota list result by usage rate 2020-06-23 22:24:42 +08:00
Zexi Li
f977e44885 Merge pull request #6924 from swordqiu/automated-cherry-pick-of-#6921-upstream-release-3.1
Automated cherry pick of #6921: fix: simplify forbidden user login message
2020-06-23 21:26:06 +08:00
Qiu Jian
ecfe897c2e fix: simplify forbidden user login message 2020-06-23 17:48:21 +08:00
yunion-ci-robot
7370f1ecf1 Merge pull request #6909 from wanyaoqi/automated-cherry-pick-of-#6906-upstream-release-3.1
Automated cherry pick of #6906: disable dhclient
2020-06-23 10:31:59 +08:00
wanyaoqi
bd0d22e7e4 disable dhclient 2020-06-22 21:31:33 +08:00
Zexi Li
997141525d Merge pull request #6896 from yousong/automated-cherry-pick-of-#6893-upstream-release-3.1
Automated cherry pick of #6893: cloudcommon: app: cosmetic change
2020-06-22 09:15:46 +08:00
Yousong Zhou
477d5845d5 cloudcommon: policy: fix interval and oneshot sync
Reduce CPU utilization caused by queued time.AfterFunc calls
2020-06-21 18:34:21 +08:00
Yousong Zhou
fb886c6f25 cloudcommon: app: cosmetic change 2020-06-21 18:34:21 +08:00
yunion-ci-robot
44a9f29c94 Merge pull request #6887 from swordqiu/automated-cherry-pick-of-#6885-upstream-release-3.1
Automated cherry pick of #6885: fix: wrong cloud provider status when sync disconnected cloud account
2020-06-19 09:49:08 +08:00
Qiu Jian
20473f6544 fix: wrong cloud provider status when sync disconnected cloud account 2020-06-19 01:22:58 +08:00
yunion-ci-robot
af19d59bc8 Merge pull request #6866 from yousong/automated-cherry-pick-of-#6859-upstream-release-3.1
Automated cherry pick of #6859: cloudaccounts: one sync task in queue per cloudaccount
2020-06-18 23:19:04 +08:00
Zexi Li
11a66c13c3 Merge pull request #6873 from ioito/automated-cherry-pick-of-#6871-upstream-release-3.1
Automated cherry pick of #6871: fix: 避免同步删除失败
2020-06-18 19:05:46 +08:00
Qu Xuan
ea4535cbbb fix: 避免同步删除失败 2020-06-18 17:21:39 +08:00
Yousong Zhou
2ab2c5b0dd cloudaccounts: one sync task in queue per cloudaccount 2020-06-18 17:12:33 +08:00
yunion-ci-robot
b1bd51d040 Merge pull request #6876 from tb365/automated-cherry-pick-of-#6875-upstream-release-3.1
Automated cherry pick of #6875: replace err with errors.cause
2020-06-18 15:16:03 +08:00
tangbin
e4c1d4181b replace err with errors.cause 2020-06-18 14:29:49 +08:00
Zexi Li
356fa8d02d Merge pull request #6863 from tb365/automated-cherry-pick-of-#6861-upstream-release-3.1
Automated cherry pick of #6861: shuzhou to suzhou
2020-06-17 18:50:55 +08:00
Zexi Li
dd32b0aacc Merge pull request #6842 from zexi/automated-cherry-pick-of-#6839-upstream-release-3.1
Automated cherry pick of #6839: scheduler: fix memory over committed
2020-06-17 18:49:40 +08:00
tangbin
4c00f92502 shuzhou to suzhou 2020-06-17 15:55:36 +08:00
Zexi Li
d4a714af2c Merge pull request #6856 from yousong/automated-cherry-pick-of-#6837-upstream-release-3.1
Automated cherry pick of #6837: appsrv: ring: release ring content on pop
2020-06-17 11:24:40 +08:00
Yousong Zhou
da702c8284 appsrv: rework TestRing 2020-06-17 10:53:42 +08:00
Yousong Zhou
649eac69ef appsrv: ring: release ring content on pop 2020-06-17 10:53:42 +08:00
Zexi Li
0cf01d2f0a Merge pull request #6851 from swordqiu/automated-cherry-pick-of-#6849-upstream-release-3.1
Automated cherry pick of #6849: fix: disable policy rule compaction
2020-06-17 10:29:07 +08:00
Qiu Jian
120ed1f695 fix: policy allow if one of the matching rules is allow 2020-06-16 23:11:35 +08:00
Qiu Jian
4acc7a580f fix: disable policy rule compaction 2020-06-16 23:11:34 +08:00
Zexi Li
facbe5433a Merge pull request #6846 from wanyaoqi/automated-cherry-pick-of-#6844-upstream-release-3.1
Automated cherry pick of #6844: fix cpu usage metrics
2020-06-16 21:00:51 +08:00
wanyaoqi
96088d3465 fix cpu usage metrics 2020-06-16 20:44:40 +08:00
Zexi Li
4b98425f0c Merge pull request #6826 from wanyaoqi/automated-cherry-pick-of-#6824-upstream-release-3.1
Automated cherry pick of #6824: fix windows install regedit record
2020-06-16 20:12:53 +08:00
Zexi Li
4ac3f8e4fa scheduler: fix memory over committed 2020-06-16 19:17:35 +08:00
wanyaoqi
d48b88ec83 fix windows install regedit record 2020-06-15 10:58:41 +08:00
Zexi Li
c0659c1453 Merge pull request #6819 from yousong/automated-cherry-pick-of-#6817-upstream-release-3.1
Automated cherry pick of #6817: guestnetworks: use math/rand instead of crypto/rand
2020-06-12 10:09:26 +08:00
Yousong Zhou
99598a4804 guestnetworks: reduce odds of collision seeded by epoch seconds 2020-06-11 21:22:52 +08:00
Yousong Zhou
651f2c3f9c guestnetworks: use math/rand instead of crypto/rand 2020-06-11 21:22:52 +08:00
Zexi Li
fa12b95e21 Merge pull request #6813 from ioito/automated-cherry-pick-of-#6810-upstream-release-3.1
Automated cherry pick of #6810: fix: 避免openstack磁盘和存储窜位
2020-06-11 17:52:22 +08:00
Zexi Li
93a659c81c Merge pull request #6805 from zexi/automated-cherry-pick-of-#6803-upstream-release-3.1
Automated cherry pick of #6803: webconsole: fix version and others handler not handle
2020-06-11 17:50:10 +08:00
Qu Xuan
9def31ddfe fix: 避免openstack磁盘和存储窜位 2020-06-11 14:14:19 +08:00
Zexi Li
f98104ad20 Merge pull request #6799 from wanyaoqi/automated-cherry-pick-of-#6797-upstream-release-3.1
Automated cherry pick of #6797: fix host list servers filter
2020-06-10 17:05:59 +08:00
Zexi Li
6b0be1317e webconsole: fix version and others handler not handle 2020-06-10 17:02:24 +08:00
wanyaoqi
5a9e9f66e4 fix host list servers filter 2020-06-10 14:08:26 +08:00
Zexi Li
b5d4885007 Merge pull request #6732 from ioito/automated-cherry-pick-of-#6663-upstream-release-3.1
Automated cherry pick of #6663: fix: 优化安全组同步逻辑
2020-06-10 11:28:55 +08:00
Zexi Li
58ba106c61 Merge pull request #6788 from rainzm/automated-cherry-pick-of-#6786-upstream-release-3.1
Automated cherry pick of #6786: fix: Hanle the error of vdisk.GetIStorage in syncCloudDisk
2020-06-10 11:28:06 +08:00
Zexi Li
fb406e91c4 Merge pull request #6781 from ioito/automated-cherry-pick-of-#6779-upstream-release-3.1
Automated cherry pick of #6779: fix: 更正华为云操作成功判断
2020-06-10 10:46:07 +08:00
Zexi Li
462ff5c2d8 Merge pull request #6784 from rainzm/automated-cherry-pick-of-#6782-upstream-release-3.1
Automated cherry pick of #6782: fix: Add '/version' handler for notify
2020-06-10 10:18:56 +08:00
Zexi Li
a1fbc8455b Merge pull request #6793 from swordqiu/automated-cherry-pick-of-#6791-upstream-release-3.1
Automated cherry pick of #6791: fix: policy-explain not working properly
2020-06-10 09:53:04 +08:00
Qiu Jian
50e28166ef fix: policy-explain not working properly 2020-06-09 22:29:44 +08:00
rainzm
92381b0213 fix: Hanle the error of vdisk.GetIStorage in syncCloudDisk 2020-06-09 19:50:30 +08:00
rainzm
65b1fbae34 fix: Add '/version' handler for notify 2020-06-09 18:55:34 +08:00
Qu Xuan
918265ea49 fix: 更正华为云操作成功判断 2020-06-09 18:21:25 +08:00
yunion-ci-robot
5591bbec4e Merge pull request #6771 from zexi/automated-cherry-pick-of-#6769-upstream-release-3.1
Automated cherry pick of #6769: region: retry set influxdb policy until completed
2020-06-08 21:11:09 +08:00
Zexi Li
8f0ac8e19b region: retry set influxdb policy until completed 2020-06-08 19:08:50 +08:00
Qu Xuan
307fb3a116 fix: 优化安全组同步逻辑 2020-06-08 14:12:57 +08:00
yunion-ci-robot
3bd3dda026 Merge pull request #6694 from ioito/automated-cherry-pick-of-#6692-upstream-release-3.1
Automated cherry pick of #6692: fix: 返回object默认acl
2020-06-06 10:59:46 +08:00
Qu Xuan
a396868d6a fix: 返回object默认acl 2020-06-05 11:00:56 +08:00
Zexi Li
794b2896f4 Merge pull request #6742 from swordqiu/automated-cherry-pick-of-#6740-upstream-release-3.1
Automated cherry pick of #6740: fix: xsky recode using endpoint as accesskey key
2020-06-04 21:41:06 +08:00
Zexi Li
2443cc9a3c Merge pull request #6738 from tb365/automated-cherry-pick-of-#6737-upstream-release-3.1
Automated cherry pick of #6737: ctyun sync host wire fix
2020-06-04 21:39:51 +08:00
Zexi Li
56ebaea85e Merge pull request #6746 from wanyaoqi/automated-cherry-pick-of-#6744-upstream-release-3.1
Automated cherry pick of #6744: bind mount local image path to container path
2020-06-04 21:24:19 +08:00
Zexi Li
37cefd0d64 Merge pull request #6749 from wanyaoqi/automated-cherry-pick-of-#6173-upstream-release-3.1
Automated cherry pick of #6173: support custom service url
2020-06-04 21:20:05 +08:00
wanyaoqi
8a2c03d683 support custom service url 2020-06-04 20:28:20 +08:00
wanyaoqi
ed136fb2f0 bind mount local image path to container path 2020-06-04 20:22:45 +08:00
Qiu Jian
3b3cbb94d6 fix: xsky recode using endpoint as accesskey key 2020-06-04 19:23:27 +08:00
tangbin
79614b5939 ctyun sync host wire fix 2020-06-04 18:53:00 +08:00
Zexi Li
6fce123623 Merge pull request #6724 from ioito/automated-cherry-pick-of-#6722-upstream-release-3.1
Automated cherry pick of #6722: fix: 添加region翻译
2020-06-04 10:28:27 +08:00
Qu Xuan
d9ddbb5bcf fix: 添加region翻译 2020-06-03 20:41:35 +08:00
Zexi Li
e871084a85 Merge pull request #6718 from tb365/automated-cherry-pick-of-#6696-upstream-release-3.1
Automated cherry pick of #6696: add-enterprise-info-update-climc
2020-06-03 17:26:18 +08:00
Zexi Li
170b08329d Merge pull request #6715 from wanyaoqi/automated-cherry-pick-of-#6713-upstream-release-3.1
Automated cherry pick of #6713: isolated device manager:
2020-06-03 17:25:28 +08:00
tangbin
a433306ba4 add-enterprise-info-update-climc 2020-06-03 16:26:14 +08:00
wanyaoqi
0737e5ed39 isolated device manager:
- fix find boot_vga got No such file or dirtory
2020-06-03 15:53:09 +08:00
yunion-ci-robot
b9c8dc01fb Merge pull request #6688 from ioito/automated-cherry-pick-of-#6686-upstream-release-3.1
Automated cherry pick of #6686: fix: 避免锁超时
2020-06-02 13:59:42 +08:00
Qu Xuan
748d547b88 fix: 避免锁超时 2020-06-02 11:15:15 +08:00
Zexi Li
59d979043e Merge pull request #6677 from ioito/automated-cherry-pick-of-#6675-upstream-release-3.1
Automated cherry pick of #6675: fix: add us-west4 for google region
2020-06-02 10:00:20 +08:00
Zexi Li
9f9e5eed10 Merge pull request #6672 from wanyaoqi/automated-cherry-pick-of-#6670-upstream-release-3.1
Automated cherry pick of #6670: get snapshots order by created at asc
2020-06-02 09:58:38 +08:00
Qu Xuan
e9638cc461 fix: add us-west4 for google region 2020-06-01 18:28:22 +08:00
wanyaoqi
8f15091db1 get snapshots order by created at asc 2020-06-01 15:10:25 +08:00
Zexi Li
3ee4ae370a Merge pull request #6660 from ioito/automated-cherry-pick-of-#6658-upstream-release-3.1
Automated cherry pick of #6658: fix: byte size fix
2020-05-29 19:14:42 +08:00
Qu Xuan
99eb111954 fix: byte size fix 2020-05-29 17:00:25 +08:00
Zexi Li
d968caaa47 Merge pull request #6655 from swordqiu/automated-cherry-pick-of-#6636-upstream-release-3.1
Automated cherry pick of #6636: fix: ignore match weights when searching matched policysets
2020-05-29 14:20:34 +08:00
Zexi Li
a5530fee10 Merge pull request #6652 from wanyaoqi/automated-cherry-pick-of-#6650-upstream-release-3.1
Automated cherry pick of #6650: fix migrate with multi local storage
2020-05-29 14:19:01 +08:00
Qiu Jian
87b4a151df fix: ignore match weights when searching matched policysets 2020-05-29 12:50:15 +08:00
wanyaoqi
1d463ed8c8 fix migrate with multi local storage 2020-05-29 11:54:19 +08:00
yunion-ci-robot
63638b15d1 Merge pull request #6645 from rainzm/automated-cherry-pick-of-#6643-upstream-release-3.1
Automated cherry pick of #6643: feat(notify): Support 'socpe:domain' when list contacts
2020-05-28 19:04:59 +08:00
yunion-ci-robot
5c4bf3e03c Merge pull request #6557 from zhaoxiangchun/automated-cherry-pick-of-#6544-upstream-release-3.1
Automated cherry pick of #6544: 类型是onecloud的notifier增加webconsole的alert
2020-05-28 19:02:00 +08:00
Zexi Li
b239ca7b15 Merge pull request #6639 from ioito/automated-cherry-pick-of-#6637-upstream-release-3.1
Automated cherry pick of #6637: fix: 避免因磁盘数量导致创建机器失败
2020-05-28 17:14:00 +08:00
rainzm
87ca98b362 feat(notify): Support 'socpe:domain' when list contacts
This is a temporary solution.
2020-05-28 15:28:55 +08:00
Qu Xuan
04eaf773fe fix: 避免因磁盘数量导致创建机器失败 2020-05-28 12:08:57 +08:00
Zexi Li
4aa2299b47 Merge pull request #6622 from ioito/automated-cherry-pick-of-#6619-upstream-release-3.1
Automated cherry pick of #6619: fix: 避免azure卸载磁盘失败
2020-05-27 17:52:14 +08:00
Qu Xuan
9c8337ae8f fix: 避免azure卸载磁盘失败 2020-05-27 15:56:40 +08:00
Zexi Li
a8e9c3f510 Merge pull request #6615 from yousong/bugfix/yousong-vpc-key-3.1
apis: WireDetails: fix wrong key for vpc name
2020-05-27 10:30:09 +08:00
Yousong Zhou
290a32b9de apis: WireDetails: fix wrong key for vpc name 2020-05-27 10:02:24 +08:00
Zexi Li
94fe13ddc5 Merge pull request #6600 from wanyaoqi/automated-cherry-pick-of-#6598-upstream-release-3.1
Automated cherry pick of #6598: fix remotefile fetch image propertites
2020-05-26 17:25:02 +08:00
Zexi Li
ad071de5a0 Merge pull request #6596 from ioito/automated-cherry-pick-of-#6594-upstream-release-3.1
Automated cherry pick of #6594: fix: bucket信息修正
2020-05-26 17:14:02 +08:00
wanyaoqi
b570dc9d82 fix remotefile fetch image propertites 2020-05-26 15:54:43 +08:00
Qu Xuan
aa9de0f84d fix: bucket信息修正 2020-05-26 15:10:25 +08:00
Zexi Li
9285208d1c Merge pull request #6584 from zexi/hotfix/k8s-repo-privilege-bk
fix k8s repo wrong privilege
2020-05-25 18:27:18 +08:00
Zexi Li
4112e7052d fix k8s repo wrong privilege 2020-05-25 16:58:06 +08:00
Zexi Li
f33aa39eed Merge pull request #6576 from zhaoxiangchun/automated-cherry-pick-of-#6573-upstream-release-3.1
Automated cherry pick of #6573: zstack宿主机监控中增加参数信息进行Unmarshal
2020-05-25 12:18:09 +08:00
zhaoxiangchun
cd2499c3b0 zstack宿主机监控中增加参数信息进行Unmarshal 2020-05-24 17:19:26 +08:00
Zexi Li
e2fa8d48e6 Merge pull request #6569 from swordqiu/automated-cherry-pick-of-#6567-upstream-release-3.1
Automated cherry pick of #6567: fix: default policy not effective
2020-05-22 22:48:31 +08:00
Zexi Li
a1750c6dd0 Merge pull request #6560 from ioito/automated-cherry-pick-of-#6558-upstream-release-3.1
Automated cherry pick of #6558: fix: 避免openstack以镜像做系统盘创建失败
2020-05-22 22:45:27 +08:00
Qiu Jian
5a93924ff2 fix: default policy not effective 2020-05-22 22:38:19 +08:00
Qu Xuan
0c32be0707 fix: 避免openstack以镜像做系统盘创建失败 2020-05-22 20:17:54 +08:00
zhaoxiangchun
62fe7d977d 类型是onecloud的notifier增加webconsole的alert 2020-05-22 20:04:49 +08:00
Zexi Li
fb4206d904 Merge pull request #6553 from swordqiu/automated-cherry-pick-of-#6551-upstream-release-3.1
Automated cherry pick of #6551: fix: empty matched policies list for roles
2020-05-22 19:32:24 +08:00
Qiu Jian
3afbb86fad fix: empty matched policies list for roles 2020-05-22 18:53:43 +08:00
Zexi Li
aeaa6939c7 Merge pull request #6542 from ioito/automated-cherry-pick-of-#6540-upstream-release-3.1
Automated cherry pick of #6540: fix: 避免因io问题导致同步镜像列表为空
2020-05-22 14:43:49 +08:00
Qu Xuan
950e7696bc fix: 避免因io问题导致同步镜像列表为空 2020-05-22 13:47:47 +08:00
Zexi Li
8bf5eb3321 Merge pull request #6538 from ioito/automated-cherry-pick-of-#6530-upstream-release-3.1
Automated cherry pick of #6530: fix: aliyun rds backup create fix
2020-05-22 12:36:48 +08:00
Qu Xuan
91e558e74a fix: aliyun rds backup create fix 2020-05-22 10:31:55 +08:00
Zexi Li
d196c943eb Merge pull request #6513 from ioito/automated-cherry-pick-of-#6511-upstream-release-3.1
Automated cherry pick of #6511: fix: 避免忽略本地allow any云上deny any安全组规则同步
2020-05-22 10:22:34 +08:00
Zexi Li
61e6a98328 Merge pull request #6522 from swordqiu/automated-cherry-pick-of-#6516-upstream-release-3.1
Automated cherry pick of #6516: fix: system privileges user cannot access system console
2020-05-22 10:15:22 +08:00
yunion-ci-robot
61e81748d7 Merge pull request #6507 from ioito/automated-cherry-pick-of-#6505-upstream-release-3.1
Automated cherry pick of #6505: fix: 上传镜像为转换列表之外时,subformat状态异常
2020-05-21 23:08:50 +08:00
Qiu Jian
51563912b0 fix: system privileges user cannot access system console 2020-05-21 18:44:37 +08:00
Qu Xuan
215f9c4d1d fix: 避免忽略本地allow any云上deny any安全组规则同步 2020-05-21 18:30:39 +08:00
Qu Xuan
a32021969a fix: 上传镜像为转换列表之外时,subformat状态异常 2020-05-21 17:41:55 +08:00
Zexi Li
18e98f598e Merge pull request #6501 from zhaoxiangchun/automated-cherry-pick-of-#6500-upstream-release-3.1
Automated cherry pick of #6500: 修复当prestate=alerting,newstate=alerting的情况无法触发notify的问题
2020-05-21 16:37:58 +08:00
Zexi Li
520af18f9e Merge pull request #6489 from rainzm/automated-cherry-pick-of-#6487-upstream-release-3.1
Automated cherry pick of #6487: Fix/esxi
2020-05-21 16:33:17 +08:00
zhaoxiangchun
28fab54660 修复当prestate=alerting,newstate=alerting的情况无法触发notify的问题 2020-05-21 13:57:14 +08:00
rainzm
4f9bbe0674 fix(esxi): Modify the disk size correctly when creating vm 2020-05-21 10:50:25 +08:00
rainzm
d3fb8a60d7 fix(esxi): Detach all disk first when deleting vm 2020-05-21 10:50:25 +08:00
rainzm
3276164c8b Kill processes in time & Add debug info 2020-05-21 10:50:25 +08:00
rainzm
d759c27bf6 fix(esxi): Remove 'Destory' operation that is unnecessary for VirtualDiskManager 2020-05-21 10:50:25 +08:00
rainzm
ce827235b3 fix(esxi): Separate detach disk and delete disk when rebuilding.
In previous versions, set
`removeSpec.FileOperation = types.VirtualDeviceConfigSpecFileOperationDestroy'
to delete disk indirectly.

But, when its parent has only one child, the parent will be deleted along with it.
And the consequence is failure to reinstall the system.

Now, detach disk without deleteing backing file and then remove backing
2020-05-21 10:50:25 +08:00
Zexi Li
9534c153c3 Merge pull request #6493 from zexi/automated-cherry-pick-of-#6491-upstream-release-3.1
Automated cherry pick of #6491: keystone: fix db not sync
2020-05-20 17:32:24 +08:00
Zexi Li
e4eb798fda keystone: fix db not sync 2020-05-20 17:23:07 +08:00
Zexi Li
34cef736d3 Merge pull request #6482 from zexi/automated-cherry-pick-of-#6481-upstream-release-3.1
Automated cherry pick of #6481: region: fix get resource details panic
2020-05-20 14:00:12 +08:00
Zexi Li
a175ca421f region: fix get resource details panic 2020-05-20 13:30:32 +08:00
Zexi Li
03b13297e8 Merge pull request #6476 from yousong/automated-cherry-pick-of-#6474-upstream-release-3.1
Automated cherry pick of #6474: cloudcommon: rbac: fix typo
2020-05-20 12:53:21 +08:00
Zexi Li
1b3c442407 Merge pull request #6480 from tb365/automated-cherry-pick-of-#6463-upstream-release-3.1
Automated cherry pick of #6463: add fuzzy ip matching
2020-05-20 12:51:58 +08:00
tangbin
949c202692 add fuzzy ip matching 2020-05-20 12:02:29 +08:00
Zexi Li
47be971d66 Merge pull request #6455 from ioito/automated-cherry-pick-of-#6453-upstream-release-3.1
Automated cherry pick of #6453: fix: 优化azure image同步逻辑
2020-05-20 11:08:27 +08:00
Yousong Zhou
77a36234a4 networks: return HTTP 404 for sql.ErrNoRows 2020-05-20 11:06:34 +08:00
Yousong Zhou
2f89114413 wires: default to "default" vpc on creation
Wire creation request right now only makes sense in context of classic
network ("default" vpc)
2020-05-20 11:06:34 +08:00
Yousong Zhou
2322118457 networks: eliminate a variable 2020-05-20 11:05:50 +08:00
Yousong Zhou
fa5fbccf2b guestdrivers: managed: use const api.EIP_STATUS_ASSOCIATE 2020-05-20 11:05:50 +08:00
Yousong Zhou
c5cf45772c cloudprovider: fix typo 2020-05-20 11:05:50 +08:00
Yousong Zhou
6daa0a1d4f cloudcommon: rbac: fix typo 2020-05-20 11:05:50 +08:00
yunion-ci-robot
a304d30020 Merge pull request #6471 from tb365/automated-cherry-pick-of-#6463-upstream-release-3.1
Automated cherry pick of #6463: add fuzzy ip matching
2020-05-19 19:29:40 +08:00
tangbin
8aed26a110 add fuzzy ip matching 2020-05-19 19:24:55 +08:00
Zexi Li
6c78e3d349 Merge pull request #6460 from ioito/automated-cherry-pick-of-#6458-upstream-release-3.1
Automated cherry pick of #6458: fix: 修复zstack使用win镜像时userdata base64加密问题
2020-05-19 19:13:56 +08:00
Zexi Li
83a5574e5d Merge pull request #6465 from zexi/automated-cherry-pick-of-#6462-upstream-release-3.1
Automated cherry pick of #6462: region: fix server create params not include specified resource
2020-05-19 19:08:52 +08:00
Zexi Li
f05ed6ccb6 region: fix server create params not include specified resource 2020-05-19 17:38:46 +08:00
Qu Xuan
73ca4a9ee8 fix: 修复zstack使用win镜像时userdata base64加密问题 2020-05-19 16:47:29 +08:00
Qu Xuan
144bc806b8 fix: 优化azure image同步逻辑 2020-05-19 16:24:47 +08:00
Zexi Li
144ebc6e8b Merge pull request #6445 from swordqiu/automated-cherry-pick-of-#6443-upstream-release-3.1
Automated cherry pick of #6443: fix: anonymous user may list resources
2020-05-19 10:17:58 +08:00
Zexi Li
33fd165939 Merge pull request #6439 from zexi/automated-cherry-pick-of-#6436-upstream-release-3.1
Automated cherry pick of #6436: baremetal: fix ssh put empty content file not created
2020-05-19 10:16:12 +08:00
Qiu Jian
08971d413a fix: anonymous user may list resources 2020-05-19 01:24:16 +08:00
Zexi Li
c321c6c4b7 Merge pull request #6425 from ioito/automated-cherry-pick-of-#6423-upstream-release-3.1
Automated cherry pick of #6423: fix: 避免仅同步一个region时,其余region状态变为准备中
2020-05-18 21:49:19 +08:00
Zexi Li
45d627da21 Merge pull request #6430 from ioito/automated-cherry-pick-of-#6428-upstream-release-3.1
Automated cherry pick of #6428: fix: 避免设置自动释放后磁盘的expired_at失效
2020-05-18 21:47:59 +08:00
Zexi Li
24a6b94fc8 baremetal: fix ssh put empty content file not created 2020-05-18 21:46:04 +08:00
Qu Xuan
7fd2a886b4 fix: 避免设置自动释放后磁盘的expired_at失效 2020-05-18 20:08:29 +08:00
Qu Xuan
4a9030636b fix: 避免仅同步一个region时,其余region状态变为准备中 2020-05-18 19:38:00 +08:00
Zexi Li
15ba242294 Merge pull request #6413 from rainzm/release/3.1
update vendor for release/3.1
2020-05-17 14:18:12 +08:00
Zexi Li
12b8efa2a1 Merge pull request #6414 from zhaoxiangchun/automated-cherry-pick-of-#6410-upstream-release-3.1
Automated cherry pick of #6410: 修复无法获取vmware宿主机监控数据的问题
2020-05-17 14:17:01 +08:00
zhaoxiangchun
715c1ba936 修复无法获取vmware宿主机监控数据的问题 2020-05-16 21:23:00 +08:00
rainzm
a50e8a797e update vendor 2020-05-16 21:21:45 +08:00
yunion-ci-robot
a314b7a37b Merge pull request #6390 from zexi/automated-cherry-pick-of-#6388-upstream-release-3.1
Automated cherry pick of #6388: region: fix baremetal can't enable public baremetal type network
2020-05-16 18:05:03 +08:00
Zexi Li
f3838108cd Merge pull request #6397 from swordqiu/automated-cherry-pick-of-#6395-upstream-release-3.1
Automated cherry pick of #6395: fix: server-sync-fix-nics should return errors if vnics ip is not reachable on host
2020-05-16 17:44:50 +08:00
Zexi Li
756e1f5570 Merge pull request #6377 from rainzm/automated-cherry-pick-of-#6375-upstream-release-3.1
Automated cherry pick of #6375: Fix/esxi
2020-05-16 17:41:39 +08:00
Zexi Li
9425460800 region: fix baremetal can't enable public baremetal type network 2020-05-16 17:30:59 +08:00
Qiu Jian
bebdc5532c fix: server-sync-fix-nics should return errors if vnics ip is not reachable on host 2020-05-15 22:20:18 +08:00
rainzm
069805fa89 fix(esxi): Allow the creation of duplicate vcenter machines.
Create vm with name whose vlaue is localVM.Uuid and try to rename again.
2020-05-15 21:36:50 +08:00
rainzm
eae078398b fix(esxi): Add usb to support mouse in vnc viewer 2020-05-15 21:36:50 +08:00
rainzm
068a89b234 fix(esxi): Fix GetDriver and add driver log for vdisk.
In GetDriver, return 'name' directly if driverMap is empty.
2020-05-15 21:36:50 +08:00
rainzm
b27a0af647 fix(esxi): Set 'WindowsDefaultAdminUser' as true when deploy vm.
'WindowsDefaultAdminUser' means that the default admin account is
'Administrator' when deploy windows vm.
2020-05-15 21:36:50 +08:00
rainzm
7bc16cacad fix(region): Set default value if rootdisk's driver is empty. 2020-05-15 21:36:50 +08:00
rainzm
700e513595 fix(esxi): Disable automatically add host to the dvs 2020-05-15 21:36:50 +08:00
rainzm
9113050534 fix(esxi): Set 'IsInit' as true when rebuildroot
IsInit is true will cause cloudinit enable. When rebuilding root, if there is cloudinit service in the image, it will cover the initialization work we did on the rebuilding.
2020-05-15 21:36:50 +08:00
Zexi Li
89c80a43f8 Merge pull request #6384 from zexi/automated-cherry-pick-of-#6381-upstream-release-3.1
Automated cherry pick of #6381: scheduler: fix min counter get count not correct
2020-05-15 15:28:30 +08:00
Zexi Li
e2d86cc624 scheduler: fix min counter get count not correct 2020-05-15 15:09:40 +08:00
Zexi Li
99e30e2dc1 Merge pull request #6362 from ioito/automated-cherry-pick-of-#6346-upstream-release-3.1
Automated cherry pick of #6346: fix: 优化windows powershell userdata
2020-05-15 11:09:58 +08:00
Zexi Li
110555570c Merge pull request #6360 from ioito/automated-cherry-pick-of-#6352-upstream-release-3.1
Automated cherry pick of #6352: fix: 优化rds zone同步逻辑
2020-05-15 11:05:52 +08:00
Qu Xuan
7a80b316ac fix: 优化windows powershell userdata 2020-05-14 20:43:41 +08:00
Qu Xuan
1445a91007 fix: 优化rds zone同步逻辑 2020-05-14 20:26:55 +08:00
Zexi Li
d4a81bedf9 Merge pull request #6356 from zexi/automated-cherry-pick-of-#6353-upstream-release-3.1
Automated cherry pick of #6353: scheduler: filter disabled cloudprovider
2020-05-14 18:59:29 +08:00
Zexi Li
05313e1f9a Merge pull request #6340 from swordqiu/automated-cherry-pick-of-#6338-upstream-release-3.1
Automated cherry pick of #6338: fix: avoid using background context
2020-05-14 18:19:31 +08:00
Zexi Li
372646dd0d scheduler: filter disabled cloudprovider 2020-05-14 18:15:32 +08:00
Zexi Li
617adad306 Merge pull request #6349 from zexi/automated-cherry-pick-of-#6347-upstream-release-3.1
Automated cherry pick of #6347: scheduler: set schedtag default strategy if input empty
2020-05-14 17:49:23 +08:00
Zexi Li
8ad98ea029 scheduler: set schedtag default strategy if input empty 2020-05-14 17:26:28 +08:00
Qiu Jian
869d434ce1 fix: avoid using background context 2020-05-14 17:05:10 +08:00
yunion-ci-robot
1b5c347408 Merge pull request #6321 from wanyaoqi/automated-cherry-pick-of-#6319-upstream-release-3.1
Automated cherry pick of #6319: do not close worker chan
2020-05-13 20:18:02 +08:00
wanyaoqi
bccdbae49d do not close worker chan
don't close worker chan after put work, will cause dead loop
2020-05-13 18:58:45 +08:00
Zexi Li
63fe793a2f Merge pull request #6304 from yousong/automated-cherry-pick-of-#6302-upstream-release-3.1
Automated cherry pick of #6302: vpcagent: ignore possible external subnets
2020-05-13 12:45:38 +08:00
Zexi Li
e9e6ff2425 Merge pull request #6311 from ioito/automated-cherry-pick-of-#6306-upstream-release-3.1
Automated cherry pick of #6306: fix: openstack 安全组规则同步
2020-05-13 12:42:00 +08:00
Zexi Li
dcdcbcae11 Merge pull request #6294 from ioito/automated-cherry-pick-of-#6292-upstream-release-3.1
Automated cherry pick of #6292: fix: 优化openstack错误处理
2020-05-13 10:42:51 +08:00
Yousong Zhou
b1d2f2e2fc vpcagent: ignore possible external subnets 2020-05-12 18:06:47 +08:00
Qu Xuan
0473fe6524 fix: openstack 安全组规则同步 2020-05-12 17:57:46 +08:00
Qu Xuan
08bef5e63f fix: 优化openstack错误处理 2020-05-12 14:09:35 +08:00
Zexi Li
743b4d2561 Merge pull request #6289 from yousong/automated-cherry-pick-of-#6287-upstream-release-3.1
Automated cherry pick of #6287: region: lbagent: undeploy: make it idempotent
2020-05-12 11:50:34 +08:00
Zexi Li
66b937acc5 Merge pull request #6284 from yousong/automated-cherry-pick-of-#6282-upstream-release-3.1
Automated cherry pick of #6282: region: lbagents: fix deleting pending_deleted objects
2020-05-12 11:43:46 +08:00
Yousong Zhou
0781273c26 region: lbagent: undeploy: make it idempotent
Both the following three can result in the same error message "Could not
find the requested service yunion-xx: host"

  -m systemd -a 'name=yunion-xx enabled=no state=stopped daemon_reload=yes'
  -m systemd -a 'name=yunion-xx enabled=no state=stopped daemon_reload=yes force=yes'
  -m service -a 'name=yunion-xx enabled=no state=stopped'

Use of ansibleplaybookv2 is overkill and can break console expectation.
Just turn to shell module for now
2020-05-12 10:39:17 +08:00
Yousong Zhou
8a619edb7a region: lbagents: fix deleting pending_deleted objects
This was broken since the introduction of virtual object
2020-05-12 10:11:22 +08:00
Zexi Li
32429e54b7 Merge pull request #6272 from zexi/automated-cherry-pick-of-#6270-upstream-release-3.1
Automated cherry pick of #6270: scheduler: get region nil panic
2020-05-11 21:07:44 +08:00
Zexi Li
28b00fc130 Merge pull request #6260 from ioito/automated-cherry-pick-of-#6258-upstream-release-3.1
Automated cherry pick of #6258: fix: 避免aliyun磁盘计费类型多次转换
2020-05-11 18:17:09 +08:00
Zexi Li
b42df76abd scheduler: get region nil panic 2020-05-11 18:02:36 +08:00
Qu Xuan
15ee6e6920 fix: 避免aliyun磁盘计费类型多次转换 2020-05-11 14:06:25 +08:00
Zexi Li
9bb48de844 Merge pull request #6255 from swordqiu/automated-cherry-pick-of-#6252-upstream-release-3.1
Automated cherry pick of #6252: fix: panic when disk has no valid storage_id
2020-05-11 10:01:46 +08:00
Qiu Jian
e8f7ab6676 fix: panic when disk has no valid storage_id 2020-05-11 02:58:03 +08:00
Zexi Li
14542810a8 Merge pull request #6249 from wanyaoqi/automated-cherry-pick-of-#6247-upstream-release-3.1
Automated cherry pick of #6247: fix import from libvirt
2020-05-10 21:35:11 +08:00
Zexi Li
3175bdd0cc Merge pull request #6235 from tb365/automated-cherry-pick-of-#6232-upstream-release-3.1
Automated cherry pick of #6232: huawei network id fix
2020-05-10 21:33:44 +08:00
wanyaoqi
25003603aa fix import from libvirt 2020-05-10 20:44:13 +08:00
Zexi Li
74ea904e4c Merge pull request #6244 from yousong/automated-cherry-pick-of-#6242-upstream-release-3.1
Automated cherry pick of #6242: disks: reword error message on bad DiskConfig struct
2020-05-10 11:29:08 +08:00
Yousong Zhou
ae2926168c disks: reword error message on bad DiskConfig struct 2020-05-10 00:18:39 +08:00
tangbin
12335b8f62 huawei network id fix 2020-05-09 20:11:47 +08:00
Zexi Li
b118cbe143 Merge pull request #6223 from yousong/automated-cherry-pick-of-#6221-upstream-release-3.1
Automated cherry pick of #6221: cloudprovider: add methods for getting http client
2020-05-09 19:02:21 +08:00
Zexi Li
8b0437f988 Merge pull request #6215 from yousong/automated-cherry-pick-of-#6213-upstream-release-3.1
Automated cherry pick of #6213: vpcagent: ovn: explicitly include gateway route in classless routes
2020-05-09 18:57:20 +08:00
Zexi Li
0fdb86ecb1 Merge pull request #6227 from yousong/automated-cherry-pick-of-#6225-upstream-release-3.1
Automated cherry pick of #6225: apigateway: handlers: register cloudnet modules
2020-05-09 18:47:47 +08:00
Yousong Zhou
254bac3ffe apigateway: handlers: register cloudnet modules 2020-05-09 16:41:27 +08:00
Yousong Zhou
472721bc18 multicloud: loader: guard against changing proxyFunc of default client 2020-05-09 12:56:51 +08:00
Yousong Zhou
f62c00d342 multicloud: avoid changing transport of global default http client 2020-05-09 12:56:51 +08:00
Yousong Zhou
b62c930289 cloudprovider: add methods for getting http client
Prepare for following changes to avoid using and changing default
client settings
2020-05-09 12:56:51 +08:00
Yousong Zhou
ed583438b1 vpcagent: ovn: explicitly include gateway route in classless routes 2020-05-08 16:36:44 +08:00
Zexi Li
0dda6257fc Merge pull request #6188 from zhaoxiangchun/automated-cherry-pick-of-#6185-upstream-release-3.1
Automated cherry pick of #6185: 修复谷歌监控无法获取的问题
2020-05-07 17:21:33 +08:00
Zexi Li
9944fc1e27 Merge pull request #6191 from zhaoxiangchun/automated-cherry-pick-of-#5863-upstream-release-3.1
Automated cherry pick of #5863: 优化邮件格式
2020-05-07 17:20:46 +08:00
zhaoxiangchun
86524a8574 优化邮件格式
1.邮件主题中的报警级别和web页面进行对应
2.向onecloud发送邮件时,通过html/template进行格式化
2020-05-07 15:31:22 +08:00
zhaoxiangchun
822c972ce8 修复谷歌监控无法获取的问题
直接返回调用RestAPI的json格式数据
2020-05-07 11:28:07 +08:00
Zexi Li
23ec7d77c7 Merge pull request #6170 from yousong/automated-cherry-pick-of-#6168-upstream-release-3.1
Automated cherry pick of #6168: dnsrecords: note that DnsRecordManager is a IAdminSharableVirtualModelManager
2020-05-07 11:23:19 +08:00
Zexi Li
83a30f1c7c Merge pull request #6176 from swordqiu/automated-cherry-pick-of-#6174-upstream-release-3.1
Automated cherry pick of #6174: fix: fail to fetch real client ip from httprequest
2020-05-07 11:16:27 +08:00
Qiu Jian
ff287c632e fix: fail to fetch real client ip from httprequest 2020-05-06 22:27:32 +08:00
Yousong Zhou
e98516a94a dnsrecords: allow updating only description
This commit includes the following changes

 - Eliminate unused arguments from validateModelData()
 - Remove "records" member of input data unconditionally
 - Allow updates to not include records related parameters, to allow
   updating only "description" without emitting "Empty record" error
2020-05-06 18:42:53 +08:00
Yousong Zhou
8176d74976 dnsrecords: note that DnsRecordManager is a IAdminSharableVirtualModelManager 2020-05-06 18:42:53 +08:00
yunion-ci-robot
59419868a0 Merge pull request #6160 from zhaoxiangchun/automated-cherry-pick-of-#6158-upstream-release-3.1
Automated cherry pick of #6158: bugfix mem paginate
2020-05-06 15:44:45 +08:00
zhaoxiangchun
c733a582dd bugfix mem paginate
通过totoal和offset 与limit比较确定最后返回数据
2020-05-06 11:06:03 +08:00
Zexi Li
6fcba7d320 Merge pull request #6155 from ioito/automated-cherry-pick-of-#6153-upstream-release-3.1
Automated cherry pick of #6153: fix: secgroupcache权限问题修复
2020-04-30 20:14:06 +08:00
Qu Xuan
0cb9db8835 fix: secgroupcache权限问题修复 2020-04-30 15:43:30 +08:00
Zexi Li
7230a47ed3 Merge pull request #6139 from ioito/automated-cherry-pick-of-#6137-upstream-release-3.1
Automated cherry pick of #6137: fix: 云账号创建可以指定项目
2020-04-30 10:36:42 +08:00
Zexi Li
c6e8eb6d10 Merge pull request #6127 from ioito/automated-cherry-pick-of-#6123-upstream-release-3.1
Automated cherry pick of #6123: fix: usage-handler 不统计虚拟的vpc wire
2020-04-30 10:36:21 +08:00
Zexi Li
7b9b78fed3 Merge pull request #6129 from swordqiu/automated-cherry-pick-of-#6120-upstream-release-3.1
Automated cherry pick of #6120: fix: sysadmin can override policy violation check
2020-04-29 21:15:48 +08:00
Qu Xuan
7a0420dc1a fix: 云账号创建可以指定项目 2020-04-29 20:06:58 +08:00
Zexi Li
952879c40e Merge pull request #6132 from tb365/bugfix/tb-bugfix-0429
fix: FindAnonymousStructPoint needs input as a pointer to struct
2020-04-29 19:29:34 +08:00
Qiu Jian
2fb5c0b24e fix: FindAnonymousStructPoint needs input as a pointer to struct 2020-04-29 18:11:56 +08:00
Qiu Jian
899184eb4b fix: sysadmin can override policy violation check 2020-04-29 17:59:36 +08:00
Qu Xuan
93330a3c2a fix: usage-handler 不统计虚拟的vpc wire 2020-04-29 17:58:26 +08:00
Zexi Li
001519224c Merge pull request #6113 from swordqiu/automated-cherry-pick-of-#6111-upstream-release-3.1
Automated cherry pick of #6111: fix: prevent policy violation
2020-04-29 13:10:29 +08:00
Zexi Li
949979fca1 Merge pull request #6097 from ioito/automated-cherry-pick-of-#6095-upstream-release-3.1
Automated cherry pick of #6095: fix: 普通用户可获取rds账号密码
2020-04-29 13:08:13 +08:00
Qiu Jian
5d6abcc7df fix: prevent policy violation 2020-04-28 23:56:37 +08:00
yunion-ci-robot
498961324c Merge pull request #6105 from ioito/automated-cherry-pick-of-#6103-upstream-release-3.1
Automated cherry pick of #6103: fix: 修复openstack存储同步问题
2020-04-28 23:40:41 +08:00
Qu Xuan
916a05c9bf fix: 修复openstack存储同步问题 2020-04-28 14:48:00 +08:00
Qu Xuan
44b78f47d5 fix: 普通用户可获取rds账号密码 2020-04-28 10:42:11 +08:00
Zexi Li
203284a6f9 Merge pull request #6089 from yousong/bugfix/yousong-vpcagent-3.1
[3.1] vpcagent: models: allow guest to have multiple vpc nics
2020-04-27 21:01:21 +08:00
Zexi Li
14be39a37f Merge pull request #6084 from yousong/bugfix/yousong-proxysetting-3.1
[3.1] region: cloudaccounts: fix updating failure caused by proxysetting
2020-04-27 20:53:55 +08:00
Yousong Zhou
05afabb69c vpcagent: models: allow guest to have multiple vpc nics
(cherry picked from commit 09cc38f962)
2020-04-27 17:52:29 +08:00
Yousong Zhou
95290a1c0d region: cloudaccounts: fix updating failure caused by proxysetting 2020-04-27 17:32:04 +08:00
Zexi Li
08f240762b Merge pull request #6070 from ioito/automated-cherry-pick-of-#6068-upstream-release-3.1
Automated cherry pick of #6068: fix: gcp use project name for cloudprovider
2020-04-27 16:03:23 +08:00
Qu Xuan
953f235110 fix: gcp use project name for cloudprovider 2020-04-27 14:17:03 +08:00
Zexi Li
861f827101 Merge pull request #6064 from rainzm/automated-cherry-pick-of-#6062-upstream-release-3.1
Automated cherry pick of #6062: fix/notify: Add deadline for rpc client
2020-04-27 12:48:07 +08:00
Rain
7c20400bc6 fix/notify: Add deadline for rpc client 2020-04-27 10:44:24 +08:00
Zexi Li
070876e760 Merge pull request #6047 from tb365/automated-cherry-pick-of-#6042-upstream-release-3.1
Automated cherry pick of #6042: huawei elb cookie timeout fix
2020-04-26 21:06:27 +08:00
Zexi Li
35542cb381 Merge pull request #6043 from tb365/automated-cherry-pick-of-#6040-upstream-release-3.1
Automated cherry pick of #6040: ctyun subnet create bugfix
2020-04-26 20:31:24 +08:00
tangbin
d0b166364a aws elb health check type fix 2020-04-26 20:10:24 +08:00
tangbin
b20725656e huawei elb cookie timeout fix 2020-04-26 20:10:24 +08:00
tangbin
fa6991ce94 ctyun subnet create bugfix 2020-04-26 20:08:18 +08:00
yunion-ci-robot
fb39dbc772 Merge pull request #6011 from swordqiu/automated-cherry-pick-of-#6008-upstream-release-3.1
Automated cherry pick of #6008: fix: GetOnPremiseNetworkOfIP should return underlay networks
2020-04-26 19:49:32 +08:00
Zexi Li
85c21e6dbb Merge pull request #6030 from ioito/automated-cherry-pick-of-#6028-upstream-release-3.1
Automated cherry pick of #6028: fix: json unmarshal
2020-04-26 18:19:23 +08:00
Zexi Li
77f0ccf889 Merge pull request #6027 from swordqiu/automated-cherry-pick-of-#6006-upstream-release-3.1
Automated cherry pick of #6006: fix: resolve parameter name conflict in google cloud account create input
2020-04-26 16:36:22 +08:00
Qu Xuan
da3383d81a fix: json unmarshal 2020-04-26 15:52:13 +08:00
Qiu Jian
5fec0b66a5 fix: resolve parameter name conflict in google cloud account create input 2020-04-26 11:47:55 +08:00
yunion-ci-robot
20b6277c6a Merge pull request #6016 from zexi/automated-cherry-pick-of-#6014-upstream-release-3.1
Automated cherry pick of #6014: scheduler: fix network predicate get wrong free port
2020-04-26 00:31:30 +08:00
Zexi Li
3eedb00e11 scheduler: fix network predicate get wrong free port 2020-04-25 23:55:13 +08:00
Qiu Jian
d8251ce270 fix: GetOnPremiseNetworkOfIP should return underlay networks 2020-04-25 16:31:03 +08:00
Zexi Li
7d4a57cf33 Merge pull request #5992 from ioito/automated-cherry-pick-of-#5918-upstream-release-3.1
Automated cherry pick of #5918: fix: 修复华为云eneterprise-project-list异常问题
2020-04-24 18:18:13 +08:00
Zexi Li
562fbb2afe Merge pull request #5997 from yousong/automated-cherry-pick-of-#5995-upstream-release-3.1
Automated cherry pick of #5995: lblistener: fix updating lblistener without backend_group field
2020-04-24 18:17:22 +08:00
Yousong Zhou
51f0d8448d lblistener: fix updating lblistener without backend_group field
Fixes dd01610931 ("lblistener: allow setting http/https listener
backendgroup to empty")
2020-04-24 14:23:02 +08:00
Qu Xuan
9d479e6293 fix: 修复华为云eneterprise-project-list异常问题 2020-04-24 14:12:50 +08:00
Zexi Li
3955c45d63 Merge pull request #5990 from ioito/automated-cherry-pick-of-#5903-upstream-release-3.1
Automated cherry pick of #5903: fix: esxi disk project sync
2020-04-24 14:09:54 +08:00
Zexi Li
49737431a2 Merge pull request #5988 from ioito/automated-cherry-pick-of-#5881-upstream-release-3.1
Automated cherry pick of #5881: fix: 阿里云资源组同步
2020-04-24 14:09:34 +08:00
Qu Xuan
52c76cb49c fix: esxi disk project sync 2020-04-24 11:35:07 +08:00
Qu Xuan
c1198af38e VMware resource pool同步 2020-04-24 11:33:48 +08:00
Qu Xuan
be56970506 fix: 华为企业项目映射同步 2020-04-24 11:33:48 +08:00
Qu Xuan
c2d83b0007 fix: 阿里云资源组同步 2020-04-24 11:32:26 +08:00
Zexi Li
080c77685c Merge pull request #5977 from ioito/automated-cherry-pick-of-#5975-upstream-release-3.1
Automated cherry pick of #5975: fix: 添加cloudevent过滤参数
2020-04-24 01:36:28 +08:00
Zexi Li
18c63a1fdc Merge pull request #5981 from ioito/automated-cherry-pick-of-#5979-upstream-release-3.1
Automated cherry pick of #5979: fix: cloudevent使用代理优化
2020-04-24 01:35:31 +08:00
Qu Xuan
7478891d74 fix: 添加cloudevent过滤参数 2020-04-23 17:58:27 +08:00
Qu Xuan
e336583552 fix: cloudevent使用代理优化 2020-04-23 17:55:25 +08:00
yunion-ci-robot
c0f88cc35d Merge pull request #5939 from ioito/automated-cherry-pick-of-#5915-upstream-release-3.1
Automated cherry pick of #5915: fix: 自动创建项目
2020-04-23 13:40:53 +08:00
Zexi Li
f636bd4c15 Merge pull request #5969 from swordqiu/automated-cherry-pick-of-#5966-upstream-release-3.1
Automated cherry pick of #5966: supermicro redfish support
2020-04-23 09:54:53 +08:00
Qiu Jian
eb7f0d465d remove errors import 2020-04-23 09:32:07 +08:00
Qiu Jian
fa2e55ce14 supermicro redfish support 2020-04-23 09:31:24 +08:00
Zexi Li
6d2c73e1bc Merge pull request #5930 from yousong/automated-cherry-pick-of-#5928-upstream-release-3.1
Automated cherry pick of #5928: lbagent: fend off unexpected resources just in case
2020-04-23 00:07:15 +08:00
Zexi Li
ce542891d9 Merge pull request #5963 from swordqiu/automated-cherry-pick-of-#5961-upstream-release-3.1
Automated cherry pick of #5961: fix: clean pending usage caused by pre-validate-create-data
2020-04-23 00:03:15 +08:00
Zexi Li
8f02b26ae3 Merge pull request #5922 from ioito/automated-cherry-pick-of-#5919-upstream-release-3.1
Automated cherry pick of #5919: fix: 非私有云同步region name
2020-04-22 23:59:45 +08:00
Zexi Li
4a3d0bef39 Merge pull request #5932 from ioito/automated-cherry-pick-of-#5931-upstream-release-3.1
Automated cherry pick of #5931: fix: 转换非标准存储类型到lrs
2020-04-22 23:57:17 +08:00
Zexi Li
93c94454d5 Merge pull request #5948 from tb365/automated-cherry-pick-of-#5945-upstream-release-3.1
Automated cherry pick of #5945: huawei elb sync vpc
2020-04-22 23:55:51 +08:00
Zexi Li
fa7dd281e8 Merge pull request #5954 from zexi/automated-cherry-pick-of-#5951-upstream-release-3.1
Automated cherry pick of #5951: baremetal: ensure power up add retries
2020-04-22 23:52:40 +08:00
Qiu Jian
5f78b96dad fix: clean pending usage caused by pre-validate-create-data 2020-04-22 23:48:24 +08:00
yunion-ci-robot
29d428a6db Merge pull request #5941 from tb365/automated-cherry-pick-of-#5927-upstream-release-3.1
Automated cherry pick of #5927: remove aws invalid backendgroup
2020-04-22 23:05:06 +08:00
Zexi Li
d8f1cd5bf6 baremetal: ensure power up add retries 2020-04-22 22:16:44 +08:00
tangbin
ead643b844 huawei elb sync vpc 2020-04-22 20:30:43 +08:00
tangbin
f399796852 remove aws invalid backendgroup 2020-04-22 19:01:21 +08:00
Qu Xuan
be77084d0e fix: 自动创建项目 2020-04-22 18:56:56 +08:00
Qu Xuan
61c52e6cb5 fix: 转换非标准存储类型到lrs 2020-04-22 18:53:45 +08:00
Yousong Zhou
3a42c05133 lbagent: fend off unexpected resources just in case
As resource we do not know whether they are bad, but surely we know
they are not what we expect
2020-04-22 18:50:50 +08:00
Qu Xuan
5d2d5f2cb1 fix: 非私有云同步region name 2020-04-22 18:00:02 +08:00
Zexi Li
849756946b Merge pull request #5902 from ioito/automated-cherry-pick-of-#5900-upstream-release-3.1
Automated cherry pick of #5900: fix: 尽量避免因代理问题导致google request异常
2020-04-22 15:12:20 +08:00
Zexi Li
18ae833a5e Merge pull request #5908 from swordqiu/automated-cherry-pick-of-#5906-upstream-release-3.1
Automated cherry pick of #5906: fix: blacklist keystone reset admin password
2020-04-22 15:07:38 +08:00
Qiu Jian
bfb913105d fix: blacklist keystone reset admin password 2020-04-22 15:03:09 +08:00
Qu Xuan
d9e5df08db fix: 尽量避免因代理问题导致google request异常 2020-04-22 10:48:47 +08:00
Zexi Li
daeca7f7bf Merge pull request #5893 from swordqiu/automated-cherry-pick-of-#5890-upstream-release-3.1
Automated cherry pick of #5890: fix: policy details should carry updated_at and created_at fields
2020-04-22 10:39:21 +08:00
Zexi Li
bd117d6d1e Merge pull request #5898 from swordqiu/automated-cherry-pick-of-#5895-upstream-release-3.1
Automated cherry pick of #5895: fix: delete idp also delete users/groups in target domain
2020-04-22 10:34:08 +08:00
Zexi Li
383b73551a Merge pull request #5886 from ioito/automated-cherry-pick-of-#5884-upstream-release-3.1
Automated cherry pick of #5884: fix: 仅当变更domainId时才需要更新projectId
2020-04-22 10:32:39 +08:00
Qiu Jian
71351daa59 fix: delete idp also delete users/groups in target domain 2020-04-22 10:15:34 +08:00
Qiu Jian
a5b44df050 fix: policy details should carry updated_at and created_at fields 2020-04-21 22:43:17 +08:00
Qu Xuan
882c5ddc86 fix: 仅当变更domainId时才需要更新projectId 2020-04-21 21:14:39 +08:00
Zexi Li
37e6b25f4a Merge pull request #5858 from ioito/automated-cherry-pick-of-#5856-upstream-release-3.1
Automated cherry pick of #5856: fix: show sql connection error
2020-04-20 20:55:38 +08:00
Zexi Li
5a2d4737f3 Merge pull request #5868 from tb365/automated-cherry-pick-of-#5865-upstream-release-3.1
Automated cherry pick of #5865: lblis & lbbg & lbr & lbb create add fetch owner id
2020-04-20 20:51:23 +08:00
tangbin
f7b11621a7 lblis & lbbg & lbr & lbb create add fetch owner id 2020-04-20 19:31:09 +08:00
Qu Xuan
13bef96917 fix: show sql connection error 2020-04-20 16:50:15 +08:00
Zexi Li
cfafea78e7 Merge pull request #5851 from swordqiu/automated-cherry-pick-of-#5850-upstream-release-3.1
Automated cherry pick of #5850: fix: allow any character in project/domain name, giveup displayname
2020-04-18 16:27:49 +08:00
Qiu Jian
e94e63d6d4 fix: allow any character in project/domain name, giveup displayname 2020-04-18 16:00:17 +08:00
Zexi Li
b8b8174632 Merge pull request #5848 from swordqiu/automated-cherry-pick-of-#5845-upstream-release-3.1
Automated cherry pick of #5845: fix: cloudproviderregion sync ignore panic
2020-04-18 12:02:31 +08:00
Zexi Li
59ead8ac15 Merge pull request #5843 from tb365/automated-cherry-pick-of-#5840-upstream-release-3.1
Automated cherry pick of #5840: aws elb create bugfix
2020-04-18 12:00:12 +08:00
yunion-ci-robot
0750fad9b4 Merge pull request #5849 from swordqiu/hotfix/qj-proxy-settting-id-revisit-3.1
fix: proxysetting_id => proxysetting revisited on 3.1
2020-04-17 22:50:05 +08:00
Qiu Jian
09274e2574 fix: proxysetting_id => proxysetting revisited on 3.1 2020-04-17 22:20:43 +08:00
Qiu Jian
102361dc2a fix: cloudproviderregion sync ignore panic 2020-04-17 22:08:58 +08:00
TangBin
a4197e96b1 huawei oss client bugfix 2020-04-17 20:47:47 +08:00
TangBin
ac2015d6df huawei oss client fix & huawei client init fix 2020-04-17 20:47:47 +08:00
tangbin
7dd0fcf719 aws elb create bugfix 2020-04-17 20:47:47 +08:00
Zexi Li
aed78bbb72 Merge pull request #5821 from swordqiu/automated-cherry-pick-of-#5818-upstream-release-3.1
Automated cherry pick of #5818: fix: non-redfish baremetal might support jnlp console
2020-04-17 00:05:18 +08:00
Zexi Li
ed29d7b702 Merge pull request #5826 from ioito/automated-cherry-pick-of-#5825-upstream-release-3.1
Automated cherry pick of #5825: fix: 尽量避免secgroup重名问题
2020-04-17 00:02:53 +08:00
Zexi Li
2fb625c0f0 Merge pull request #5835 from zhaoxiangchun/automated-cherry-pick-of-#5831-upstream-release-3.1
Automated cherry pick of #5831: 修复azure获取不到监控数据的问题
2020-04-17 00:01:26 +08:00
Zexi Li
62726047e8 Merge pull request #5837 from swordqiu/automated-cherry-pick-of-#5836-upstream-release-3.1
Automated cherry pick of #5836: fix: cas auto create project fetch failure
2020-04-16 23:59:54 +08:00
yunion-ci-robot
1c8285bbd2 Merge pull request #5812 from yousong/automated-cherry-pick-of-#5811-upstream-release-3.1
Automated cherry pick of #5811: region: lbagents: default to using public type endpoint of influxdb
2020-04-16 23:24:05 +08:00
Qiu Jian
0885c45f34 fix: cas auto create project fetch failure 2020-04-16 22:33:20 +08:00
zhaoxiangchun
5e623616d0 修复azure获取不到监控数据的问题 2020-04-16 20:13:21 +08:00
Zexi Li
98dbf2e10b Merge pull request #5806 from ioito/automated-cherry-pick-of-#5805-upstream-release-3.1
Automated cherry pick of #5805: fix: 优化rds sku list查询速度
2020-04-16 18:01:40 +08:00
Zexi Li
aee280b5d7 Merge pull request #5822 from swordqiu/hotfix/qj-update-depecated-by-tag-3.1
update deprecated-by tag for release 3.1
2020-04-16 17:59:41 +08:00
Qu Xuan
7fb48f891d fix: 尽量避免secgroup重名问题 2020-04-16 16:40:44 +08:00
Qiu Jian
a19cdad2f4 change deprecated-by to yunion:deprecated-by 2020-04-16 00:42:20 +08:00
Qiu Jian
175283c94d fix: non-redfish baremetal might support jnlp console 2020-04-15 23:55:58 +08:00
Yousong Zhou
3245626bb7 region: buckets: use identity_apis.EndpointInterfacePublic 2020-04-15 18:03:30 +08:00
Qu Xuan
3a18169f39 fix: 优化rds sku list查询速度 2020-04-15 18:01:50 +08:00
Yousong Zhou
ba79c4c67b image: use identity_apis.EndpointInterfacePublic 2020-04-15 18:01:46 +08:00
Yousong Zhou
08cfb1ee71 region: lbagents: default to using public type endpoint of influxdb 2020-04-15 18:01:46 +08:00
Zexi Li
cc38f00731 Merge pull request #5801 from zexi/automated-cherry-pick-of-#5798-upstream-release-3.1
Automated cherry pick of #5798: climc: support k8s service v3.2
2020-04-15 10:38:02 +08:00
Zexi Li
ca563a3221 climc: support k8s service v3.2 2020-04-15 10:37:05 +08:00
544 changed files with 9516 additions and 27252 deletions

View File

@@ -1,3 +1,3 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
ADD ./_output/bin/apigateway /opt/yunion/bin/apigateway

View File

@@ -1,3 +1,3 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
ADD ./_output/bin/cloudevent /opt/yunion/bin/cloudevent

View File

@@ -1,3 +1,3 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
ADD ./_output/bin/cloudnet /opt/yunion/bin/cloudnet

View File

@@ -1,3 +1,3 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
ADD ./_output/bin/devtool /opt/yunion/bin/devtool

View File

@@ -1,4 +1,4 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
COPY ./build/esxi-agent/root/opt/ /opt/
ADD ./_output/bin/esxi-agent /opt/yunion/bin/esxi-agent

View File

@@ -1,3 +1,3 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
ADD ./_output/bin/keystone /opt/yunion/bin/keystone

View File

@@ -1,4 +1,4 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
ADD ./_output/bin/logger /opt/yunion/bin/logger

View File

@@ -1,4 +1,4 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
ADD ./_output/bin/monitor /opt/yunion/bin/monitor

View File

@@ -1,4 +1,4 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
COPY ./build/notify/root/opt/ /opt/
ADD ./_output/bin/notify /opt/yunion/bin/notify

View File

@@ -7,7 +7,7 @@ ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
RUN apk update && \
apk add --no-cache tzdata ca-certificates && \
apk add --no-cache tzdata curl busybox-extras tcpdump strace ca-certificates && \
rm -rf /var/cache/apk/*
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

View File

@@ -1,4 +1,4 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
COPY ./build/region/root/opt/ /opt/
ADD ./_output/bin/region /opt/yunion/bin/region

View File

@@ -1,3 +1,3 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
ADD ./_output/bin/s3gateway /opt/yunion/bin/s3gateway

View File

@@ -1,3 +1,3 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
ADD ./_output/bin/scheduler /opt/yunion/bin/scheduler

View File

@@ -1,4 +1,4 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
ADD ./_output/bin/yunionconf /opt/yunion/bin/yunionconf

View File

@@ -26,6 +26,28 @@ import (
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func parseGcpCredential(filename string) (jsonutils.JSONObject, error) {
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
authParams, err := jsonutils.Parse(data)
if err != nil {
return nil, err
}
ret := jsonutils.NewDict()
for _, k := range []string{
"client_email",
"project_id",
"private_key_id",
"private_key",
} {
v, _ := authParams.Get(k)
ret.Add(v, fmt.Sprintf("gcp_%s", k))
}
return ret, nil
}
func init() {
type CloudaccountListOptions struct {
@@ -138,11 +160,7 @@ func init() {
R(&options.SGoogleCloudAccountCreateOptions{}, "cloud-account-create-google", "Create a Google cloud account", func(s *mcclient.ClientSession, args *options.SGoogleCloudAccountCreateOptions) error {
params := jsonutils.Marshal(args)
params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Google"), "provider")
data, err := ioutil.ReadFile(args.GoogleJsonFile)
if err != nil {
return err
}
authParams, err := jsonutils.Parse(data)
authParams, err := parseGcpCredential(args.GoogleJsonFile)
if err != nil {
return err
}
@@ -688,11 +706,7 @@ func init() {
})
R(&options.SGoogleCloudAccountUpdateCredentialOptions{}, "cloud-account-update-credential-google", "Update credential of a Google cloud account", func(s *mcclient.ClientSession, args *options.SGoogleCloudAccountUpdateCredentialOptions) error {
data, err := ioutil.ReadFile(args.GoogleJsonFile)
if err != nil {
return err
}
params, err := jsonutils.Parse(data)
params, err := parseGcpCredential(args.GoogleJsonFile)
if err != nil {
return err
}

View File

@@ -15,7 +15,14 @@
package shell
import (
"bufio"
"bytes"
"encoding/base64"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
"path/filepath"
"yunion.io/x/jsonutils"
@@ -56,4 +63,78 @@ func init() {
printObject(r)
return nil
})
type EnterpriseUpdateOptions struct {
Name string `help:"Enterprise name"`
Copyright string `help:"The Email"`
Logo string `help:"logo file path"`
LoginLogo string `help:"login page logo file path"`
Favicon string `help:"favicon path"`
}
R(&EnterpriseUpdateOptions{}, "infos-update", "update enterprise info", func(s *mcclient.ClientSession, args *EnterpriseUpdateOptions) error {
var b bytes.Buffer
w := multipart.NewWriter(&b)
if len(args.Name) > 0 {
w.WriteField("name", args.Name)
}
if len(args.Copyright) > 0 {
w.WriteField("copyright", args.Copyright)
}
writeFile := func(filedName, filePath string) error {
if len(filePath) == 0 {
return nil
}
c, err := ioutil.ReadFile(filePath)
if err != nil {
return err
}
var v string
c64 := base64.StdEncoding.EncodeToString(c)
ext := filepath.Ext(filePath)
switch ext {
case ".png":
v = fmt.Sprintf("data:image/png;base64,%s", c64)
case ".jpg":
v = fmt.Sprintf("data:image/jpg;base64,%s", c64)
default:
return fmt.Errorf("only support png/jpg image")
}
err = w.WriteField(filedName, v)
if err != nil {
return err
}
return nil
}
if err := writeFile("logo", args.Logo); err != nil {
return err
}
if err := writeFile("login_logo", args.LoginLogo); err != nil {
return err
}
if err := writeFile("favicon", args.Favicon); err != nil {
return err
}
header := make(http.Header)
header.Set("content-type", fmt.Sprintf("multipart/form-data; boundary=%s", w.Boundary()))
w.Close()
ret, err := modules.Info.Update(s, header, bufio.NewReader(&b))
if err != nil {
return err
}
printObject(ret)
return nil
})
}

View File

@@ -0,0 +1,9 @@
package k8s
import (
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
)
func initEvent() {
initK8sNamespaceResource("event", k8s.Events)
}

View File

@@ -16,6 +16,11 @@ package k8s
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"github.com/ghodss/yaml"
"yunion.io/x/jsonutils"
@@ -57,7 +62,7 @@ func init() {
initPVC()
initJob()
initCronJob()
initEvent()
initRbac()
initApp()
@@ -217,6 +222,71 @@ func NewK8sNsResourceGetCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cm
)
}
func NewK8sNsResourceGetRawCmd(cmdN CmdNameFactory, manager k8s.IClusterResourceManager) *Cmd {
return NewCommand(
&o.NamespaceResourceGetOptions{},
cmdN.Do("show-raw"),
fmt.Sprintf("Show k8s %s raw data", cmdN.Kind),
func(s *mcclient.ClientSession, args *o.NamespaceResourceGetOptions) error {
ret, err := manager.GetRaw(s, args.NAME, args.Params())
if err != nil {
return err
}
printObjectYAML(ret)
return nil
},
)
}
func NewK8sResourceEditRawCmd(cmdN CmdNameFactory, manager k8s.IClusterResourceManager) *Cmd {
return NewCommand(
&o.NamespaceResourceGetOptions{},
cmdN.Do("edit-raw"),
fmt.Sprintf("Edit and update k8s %s raw data", cmdN.Kind),
func(s *mcclient.ClientSession, args *o.NamespaceResourceGetOptions) error {
rawData, err := manager.GetRaw(s, args.NAME, args.Params())
if err != nil {
return err
}
yamlBytes := rawData.YAMLString()
tempfile, err := ioutil.TempFile("", fmt.Sprintf("k8s-%s-%s*.yaml", cmdN.Kind, args.NAME))
if err != nil {
return err
}
defer os.Remove(tempfile.Name())
if _, err := tempfile.Write([]byte(yamlBytes)); err != nil {
return err
}
if err := tempfile.Close(); err != nil {
return err
}
cmd := exec.Command("vim", tempfile.Name())
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
return err
}
content, err := ioutil.ReadFile(tempfile.Name())
if err != nil {
return err
}
jsonBytes, err := yaml.YAMLToJSON(content)
if err != nil {
return err
}
body, err := jsonutils.Parse(jsonBytes)
if err != nil {
return err
}
if _, err := manager.UpdateRaw(s, args.NAME, args.Params(), body.(*jsonutils.JSONDict)); err != nil {
return err
}
return nil
},
)
}
func NewK8sResourceDeleteCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
return NewCommand(
&o.ResourceDeleteOptions{},
@@ -244,11 +314,13 @@ func NewK8sNsResourceDeleteCmd(cmdN CmdNameFactory, manager modulebase.Manager)
return deleteCmd
}
func initK8sNamespaceResource(kind string, manager modulebase.Manager) *ShellCommands {
func initK8sNamespaceResource(kind string, manager k8s.IClusterResourceManager) *ShellCommands {
cmdN := NewCmdNameFactory(kind)
return NewShellCommands(cmdN.Do).AddR(
NewK8sNsResourceListCmd(cmdN, manager),
NewK8sNsResourceGetCmd(cmdN, manager),
NewK8sNsResourceDeleteCmd(cmdN, manager),
NewK8sNsResourceGetRawCmd(cmdN, manager),
NewK8sResourceEditRawCmd(cmdN, manager),
)
}

View File

@@ -285,12 +285,30 @@ func init() {
if err != nil {
log.Fatalf("Set log level %q: %v", "debug", err)
}
if args.Debug {
rbacutils.ShowMatchRuleDebug = true
}
auth.InitFromClientSession(s)
policy.EnableGlobalRbac(15*time.Second, 15*time.Second, false)
if args.Debug {
consts.EnableRbacDebug()
}
findPolicy := false
for !findPolicy {
all := policy.PolicyManager.AllPolicies()
for _, allP := range all {
if len(allP) > 0 {
findPolicy = true
break
}
}
if findPolicy {
break
}
time.Sleep(time.Second)
}
req := jsonutils.NewDict()
for i := 0; i < len(args.Request); i += 1 {
parts := strings.Split(args.Request[i], ":")
@@ -356,6 +374,7 @@ func init() {
Context: mcclient.SAuthContext{
Ip: args.Ip,
},
Token: "faketoken",
}
} else {
token = s.GetToken()
@@ -367,6 +386,10 @@ func init() {
}
printObject(result)
for _, r := range args.Role {
fmt.Println("role", r, "matched policies:", policy.PolicyManager.RoleMatchPolicies(r))
}
fmt.Println("userCred:", token)
for _, scope := range []rbacutils.TRbacScope{
rbacutils.ScopeSystem,
@@ -375,7 +398,7 @@ func init() {
rbacutils.ScopeUser,
rbacutils.ScopeNone,
} {
m := policy.PolicyManager.MatchedPolicies(scope, token)
m := policy.PolicyManager.MatchedPolicyNames(scope, token)
fmt.Println("matched", scope, "policies:", m)
}

View File

@@ -988,6 +988,7 @@ func init() {
config.Hosts[i].HostIp = yamlConfig.Hosts[i].HostIp
config.Hosts[i].XmlFilePath = yamlConfig.Hosts[i].XmlFilePath
config.Hosts[i].Servers = make([]compute.SLibvirtServerConfig, len(yamlConfig.Hosts[i].Servers))
config.Hosts[i].MonitorPath = yamlConfig.Hosts[i].MonitorPath
for j := 0; j < len(yamlConfig.Hosts[i].Servers); j++ {
config.Hosts[i].Servers[j].MacIp = make(map[string]string)
mac := yamlConfig.Hosts[i].Servers[j].Mac
@@ -1010,11 +1011,11 @@ func init() {
if err != nil {
return err
}
for i := 0; i < len(params); i++ {
val := jsonutils.NewDict()
val.Set(modules.Servers.KeywordPlural, params[i])
params[i] = val
}
//for i := 0; i < len(params); i++ {
// val := jsonutils.NewDict()
// val.Set(modules.Servers.KeywordPlural, params[i])
// params[i] = val
//}
results := modules.Servers.BatchPerformClassAction(s, "import-from-libvirt", params)
printBatchResults(results, modules.Servers.GetColumns(s))

8
go.mod
View File

@@ -3,7 +3,6 @@ module yunion.io/x/onecloud
go 1.12
require (
cloud.google.com/go v0.38.0
github.com/360EntSecGroup-Skylar/excelize v1.4.0
github.com/Azure/azure-sdk-for-go v36.1.0+incompatible
github.com/Azure/go-autorest/autorest v0.9.3
@@ -115,7 +114,6 @@ require (
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20191008142428-8d021180e987
google.golang.org/api v0.13.0 // indirect
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873
google.golang.org/grpc v1.23.1
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
@@ -129,12 +127,12 @@ require (
k8s.io/cluster-bootstrap v0.17.3
k8s.io/kubernetes v1.16.0
yunion.io/x/executor v0.0.0-20200227030256-a18417815e74
yunion.io/x/jsonutils v0.0.0-20200330063846-589d9924bb8b
yunion.io/x/jsonutils v0.0.0-20200415132054-2bf8a5e94501
yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3
yunion.io/x/pkg v0.0.0-20200403115157-880d716ed624
yunion.io/x/pkg v0.0.0-20200516092703-0a53bc9270aa
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
yunion.io/x/sqlchemy v0.0.0-20200312002602-1177cd8fbc57
yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3
yunion.io/x/structarg v0.0.0-20200423163001-168d0687be7e
)
replace (

16
go.sum
View File

@@ -371,8 +371,6 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g=
github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
@@ -897,8 +895,6 @@ gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e/go.mod h1:kS+toOQn6AQKjmK
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.6.1-0.20190607001116-5213b8090861/go.mod h1:btoxGiFvQNVUZQ8W08zLtrVS08CNpINPEfxXxgJL1Q4=
google.golang.org/api v0.13.0 h1:Q3Ui3V3/CVinFWFiW39Iw0kMuVrRzYX0wN6OPFp0lTA=
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
@@ -1015,8 +1011,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-20200330063846-589d9924bb8b h1:mt0TOKRk76yeH0whJfmKsceXBuudXLjvoj8NKGTqpEU=
yunion.io/x/jsonutils v0.0.0-20200330063846-589d9924bb8b/go.mod h1:T7kxQJR13+t7z0TuT+Wzd7MTxBOk2H9c0pO1ONQSv90=
yunion.io/x/jsonutils v0.0.0-20200415132054-2bf8a5e94501 h1:i1r9XvbdxH3FgTCLmTaRi3MzQqhiQimXJRlUOPgrxnU=
yunion.io/x/jsonutils v0.0.0-20200415132054-2bf8a5e94501/go.mod h1:T7kxQJR13+t7z0TuT+Wzd7MTxBOk2H9c0pO1ONQSv90=
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=
@@ -1025,11 +1021,11 @@ yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3/go.mod h1:LC6f/4FozL0iaAbnFt2
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-20200302034534-fdf44d54b070/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/pkg v0.0.0-20200403115157-880d716ed624 h1:yPayJlTJHOP0vKY6ovliZyTwJY9RvdWEF+QDqnxt/iw=
yunion.io/x/pkg v0.0.0-20200403115157-880d716ed624/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/pkg v0.0.0-20200516092703-0a53bc9270aa h1:VizPfW8+mLFEE7W/97zxQJbfdxchi2dn1M/Y7YBwTTc=
yunion.io/x/pkg v0.0.0-20200516092703-0a53bc9270aa/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-20200312002602-1177cd8fbc57 h1:KtQAuLJ00RSUVqkiRmJ1DiDABiw0U3xxXnzD3lGavaY=
yunion.io/x/sqlchemy v0.0.0-20200312002602-1177cd8fbc57/go.mod h1:FTdwPdGhMgh4E+UFXc9klI1Ok34fMuybTT+jLhOaIjI=
yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3 h1:bfC8EhXYvyGYldRWlzxiCM39Zfj3s3+zham9mW2h2LE=
yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3/go.mod h1:EP6NSv2C0zzqBDTKumv8hPWLb3XvgMZDHQRfyuOrQng=
yunion.io/x/structarg v0.0.0-20200423163001-168d0687be7e h1:pctCe/EPel3F1B83pJ2q9b34Umd1NdbLW1Yd+Lzur2s=
yunion.io/x/structarg v0.0.0-20200423163001-168d0687be7e/go.mod h1:EP6NSv2C0zzqBDTKumv8hPWLb3XvgMZDHQRfyuOrQng=

View File

@@ -361,7 +361,7 @@ func isUserAllowWebconsole(ctx context.Context, w http.ResponseWriter, req *http
return false
}
if !jsonutils.QueryBoolean(usr, "allow_web_console", true) {
httperrors.ForbiddenError(w, "forbidden user %q login from web", usr.String())
httperrors.ForbiddenError(w, "user forbidden login from web")
return false
}
return true
@@ -570,6 +570,7 @@ func (this *projectRoles) add(roleId, roleName string) {
func (this *projectRoles) getToken(scope rbacutils.TRbacScope, user, userId, domain, domainId string, ip string) mcclient.TokenCredential {
return &mcclient.SSimpleToken{
Token: "faketoken",
Domain: domain,
DomainId: domainId,
User: user,
@@ -609,12 +610,12 @@ func (this *projectRoles) json(user, userId, domain, domainId string, ip string)
}
obj.Add(roles, "roles")
for _, scope := range []rbacutils.TRbacScope{
rbacutils.ScopeSystem,
rbacutils.ScopeDomain,
rbacutils.ScopeProject,
rbacutils.ScopeDomain,
rbacutils.ScopeSystem,
} {
token := this.getToken(scope, user, userId, domain, domainId, ip)
matches := policy.PolicyManager.MatchedPolicies(scope, token)
matches := policy.PolicyManager.MatchedPolicyNames(scope, token)
obj.Add(jsonutils.NewStringArray(matches), fmt.Sprintf("%s_policies", scope))
if len(matches) > 0 {
obj.Add(jsonutils.JSONTrue, fmt.Sprintf("%s_capable", scope))
@@ -741,7 +742,7 @@ func getUserInfo(ctx context.Context, s *mcclient.ClientSession, token mcclient.
rbacutils.ScopeDomain,
rbacutils.ScopeProject,
} {
p := policy.PolicyManager.MatchedPolicies(scope, token)
p := policy.PolicyManager.MatchedPolicyNames(scope, token)
data.Add(jsonutils.NewStringArray(p), fmt.Sprintf("%s_policies", scope))
if scope == rbacutils.ScopeSystem {
data.Add(jsonutils.NewStringArray(p), "admin_policies")

View File

@@ -1,4 +1,4 @@
// Copyright 2018, OpenCensus Authors
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,14 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// +build !go1.11
package trace
package handler
import (
"context"
_ "yunion.io/x/onecloud/pkg/mcclient/modules/cloudnet"
)
func startExecutionTracerTask(ctx context.Context, name string) (context.Context, func()) {
return ctx, func() {}
}

View File

@@ -28,6 +28,7 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/utils"
"yunion.io/x/onecloud/pkg/apigateway/options"
"yunion.io/x/onecloud/pkg/appctx"
@@ -37,6 +38,7 @@ import (
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/util/httputils"
)
const (
@@ -171,19 +173,23 @@ func (mh *MiscHandler) DoBatchHostRegister(ctx context.Context, w http.ResponseW
}
paramKeys := []string{}
for _, title := range rows[0] {
i1 := -1
i2 := -1
for i, title := range rows[0] {
switch title {
case HOST_MAC:
paramKeys = append(paramKeys, "access_mac")
case HOST_NAME:
paramKeys = append(paramKeys, "name")
case HOST_IPMI_ADDR, HOST_IPMI_ADDR_OPTIONAL:
i1 = i
paramKeys = append(paramKeys, "ipmi_ip_addr")
case HOST_IPMI_USERNAME, HOST_IPMI_USERNAME_OPTIONAL:
paramKeys = append(paramKeys, "ipmi_username")
case HOST_IPMI_PASSWORD, HOST_IPMI_PASSWORD_OPTIONAL:
paramKeys = append(paramKeys, "ipmi_password")
case HOST_MNG_IP_ADDR, HOST_MNG_IP_ADDR_OPTIONAL:
i2 = i
paramKeys = append(paramKeys, "access_ip")
default:
e := httperrors.NewInternalServerError("empty file content")
@@ -199,8 +205,33 @@ func (mh *MiscHandler) DoBatchHostRegister(ctx context.Context, w http.ResponseW
return
}
ips := []string{}
hosts := bytes.Buffer{}
for _, row := range rows[1:] {
var e *httputils.JSONClientError
if i1 >= 0 && len(row[i1]) > 0 {
i1Ip := fmt.Sprintf("%d-%s", i1, row[i1])
if utils.IsInStringArray(i1Ip, ips) {
e = httperrors.NewDuplicateIdError("ip", row[i1])
} else {
ips = append(ips, i1Ip)
}
}
if i2 >= 0 && len(row[i2]) > 0 {
i2Ip := fmt.Sprintf("%d-%s", i2, row[i2])
if utils.IsInStringArray(i2Ip, ips) {
e = httperrors.NewDuplicateIdError("ip", row[i2])
} else {
ips = append(ips, i2Ip)
}
}
if e != nil {
httperrors.JsonClientError(w, e)
return
}
hosts.WriteString(strings.Join(row, ",") + "\n")
}

View File

@@ -606,28 +606,45 @@ func (f *ResourceHandlers) patchJointHandler(ctx context.Context, w http.Respons
}
}
// batch update Joint
// * batch update Joint
// * put specific
// /<resname>/<resid>/<resname2>
// /<resname>/<resid>/<spec>
func (f *ResourceHandlers) batchUpdateJointHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) {
req := newRequest(ctx, w, r).WithMod1().WithMod2()
req := newRequest(ctx, w, r).WithMod1()
if err := req.Error(); err != nil {
httperrors.GeneralServerError(w, err)
return
}
session := req.Session()
module := req.Mod1()
module2 := req.Mod2()
body := req.Body()
query := req.Query()
idlist := fetchIdList(query, w)
if idlist == nil {
if idlist, _ := query.GetArray("id"); len(idlist) == 0 {
// do put specific
spec := req.ResName2()
obj, e := module.PutSpecific(session, req.ResID(), spec, query, body)
if e != nil {
httperrors.GeneralServerError(w, e)
} else {
appsrv.SendJSON(w, obj)
}
return
}
req = req.WithMod2()
if err := req.Error(); err != nil {
httperrors.GeneralServerError(w, err)
return
}
module2 := req.Mod2()
jmod, e := modulebase.GetJointModule2(session, module, module2)
if e != nil { // update joint
httperrors.GeneralServerError(w, e)
return
}
idlist := fetchIdList(query, w)
ret := jmod.BatchUpdate(session, req.ResID(), idlist, query, body)
w.WriteHeader(207)
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))

View File

@@ -42,7 +42,11 @@ func (ps *SProxySetting) IsZero() bool {
type ProxySettingResourceInput struct {
// 代理配置
ProxySettingId string `json:"proxy_setting_id"`
ProxySetting string `json:"proxy_setting"`
// swagger:ignore
// Deprecated
ProxySettingId string `json:"proxy_setting_id" "yunion:deprecated-by":"proxy_setting"`
}
type ProxySettingTestInput struct {

View File

@@ -18,13 +18,59 @@ import (
"time"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/apis/compute"
)
type CloudeventListInput struct {
apis.VirtualResourceListInput
apis.ModelBaseListInput
compute.ManagedResourceListInput
// 列出指定云平台的资源,支持的云平台如下
//
// | Provider | 开始支持版本 | 平台 |
// |-----------|------------|-------------------------------------|
// | OneCloud | 0.0 | OneCloud内置私有云包括KVM和裸金属管理 |
// | VMware | 1.2 | VMware vCenter |
// | OpenStack | 2.6 | OpenStack M版本以上私有云 |
// | ZStack | 2.10 | ZStack私有云 |
// | Aliyun | 2.0 | 阿里云 |
// | Aws | 2.3 | Amazon AWS |
// | Azure | 2.2 | Microsoft Azure |
// | Google | 2.13 | Google Cloud Platform |
// | Qcloud | 2.3 | 腾讯云 |
// | Huawei | 2.5 | 华为公有云 |
// | Ucloud | 2.7 | UCLOUD |
// | Ctyun | 2.13 | 天翼云 |
// | S3 | 2.11 | 通用s3对象存储 |
// | Ceph | 2.11 | Ceph对象存储 |
// | Xsky | 2.11 | XSKY启明星辰Ceph对象存储 |
//
// enum: OneCloud,VMware,Aliyun,Qcloud,Azure,Aws,Huawei,OpenStack,Ucloud,ZStack,Google,Ctyun,S3,Ceph,Xsky"
Providers []string `json:"providers"`
// swagger:ignore
// Deprecated
Provider []string `json:"provider" "yunion:deprecated-by":"providers"`
// 列出指定云平台品牌的资源一般来说brand和provider相同除了以上支持的provider之外还支持以下band
//
// | Brand | Provider | 说明 |
// |----------|----------|------------|
// | DStack | ZStack | 滴滴云私有云 |
//
Brands []string `json:"brands"`
// swagger:ignore
// Deprecated
Brand []string `json:"brand" "yunion:deprecated-by":"brands"`
// 服务类型
Service []string `json:"service"`
// 订阅
Manager []string `json:"manager"`
// 账号
Account []string `json:"account"`
// 操作类型
Action []string `json:"action"`
// 操作日志起始时间
Since time.Time `json:"since"`

View File

@@ -285,7 +285,7 @@ type ServerConfigs struct {
// swagger:ignore
// Deprecated
// alias for InstanceType
Sku string `json:"sku" deprecated-by:"instance_type"`
Sku string `json:"sku" "yunion:deprecated-by":"instance_type"`
// 虚拟机高可用(创建备机)
// default: false
@@ -357,12 +357,13 @@ type ServerCreateInput struct {
// required: false
UserData string `json:"user_data"`
// Deprecated
// swagger:ignore
Keypair string `json:"keypair" deprecated-by:"keypair_id"`
KeypairId string `json:"keypair_id" "yunion:deprecated-by":"keypair"`
// 秘钥对Id
// required: false
KeypairId string `json:"keypair_id"`
Keypair string `json:"keypair"`
// 密码
// 要求: 密码长度 >= 20, 至少包含一个数字一个小写字母一个大小字母及特殊字符~`!@#$%^&*()-_=+[]{}|:';\",./<>?中的一个

View File

@@ -147,30 +147,30 @@ type ManagedResourceListInput struct {
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
Manager string `json:"manager" 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" 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" deprecated-by:"cloudprovider"`
CloudproviderId string `json:"cloudprovider_id" "yunion:deprecated-by":"cloudprovider"`
// 列出关联指定云账号(ID或Name)的资源
Cloudaccount string `json:"cloudaccount"`
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
CloudaccountId string `json:"cloudaccount_id" 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" 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" deprecated-by:"cloudaccount"`
AccountId string `json:"account_id" "yunion:deprecated-by":"cloudaccount"`
// 列出指定云平台的资源,支持的云平台如下
//
@@ -196,7 +196,7 @@ type ManagedResourceListInput struct {
Providers []string `json:"providers"`
// swagger:ignore
// Deprecated
Provider []string `json:"provider" deprecated-by:"providers"`
Provider []string `json:"provider" "yunion:deprecated-by":"providers"`
// 列出指定云平台品牌的资源一般来说brand和provider相同除了以上支持的provider之外还支持以下band
//
@@ -207,7 +207,7 @@ type ManagedResourceListInput struct {
Brands []string `json:"brands"`
// swagger:ignore
// Deprecated
Brand []string `json:"brand" deprecated-by:"brands"`
Brand []string `json:"brand" "yunion:deprecated-by":"brands"`
// 列出指定云环境的资源,支持云环境如下:
//

View File

@@ -51,11 +51,12 @@ const (
CITY_FU_ZHOU = "Fuzhou" //福州
CITY_WU_HAN = "Wuhan" //武汉
CITY_CHANG_SHA = "Changsha" //长沙
CITY_SHU_ZHOU = "Shuzhou" //苏州
CITY_SU_ZHOU = "Suzhou" //苏州
CITY_BAO_DING = "Baoding" //保定
CITY_NAN_JING = "Nanjing" //南京
CITY_FO_SHAN = "Foshan" //佛山
CITY_QUAN_ZHOU = "Quanzhou" //泉州
CITY_NEI_MENG_GU = "Neimenggu" //内蒙古
// 日本
CITY_TOKYO = "Tokyo" //东京
@@ -111,6 +112,7 @@ const (
CITY_US_GOV_WEST = "us-gov-west" //???
CITY_SOUTH_CAROLINA = "South Carolina" //南卡罗来纳州
CITY_SALT_LAKE_CITY = "Salt Lake City" //盐湖城
CITY_LAS_VEGAS = "Las Vegas" //拉斯维加斯
// 英国
CITY_LONDON = "London" //伦敦
@@ -149,6 +151,12 @@ const (
// 巴西
CITY_SAO_PAULO = "Sao Paulo" //圣保罗
// 智利
CITY_SANTIAGO = "Santiago" // 圣地亚哥
// 墨西哥
CITY_MEXICO = "Mexico" // 墨西哥
// 荷兰
CITY_HOLLAND = "Holland" //荷兰
@@ -194,4 +202,6 @@ const (
COUNTRY_CODE_VN = "VN" //越南
COUNTRY_CODE_CH = "CH" //瑞士
COUNTRY_CODE_NO = "NO" //挪威
COUNTRY_CODE_MX = "MX" //墨西哥
COUNTRY_CODE_CL = "CL" //智利
)

View File

@@ -212,7 +212,7 @@ type DbinstanceFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by dbinstance_id
DbinstanceId string `json:"dbinstance_id" deprecated-by:"dbinstance"`
DbinstanceId string `json:"dbinstance_id" "yunion:deprecated-by":"dbinstance"`
}
type DBInstanceDetails struct {

View File

@@ -89,7 +89,7 @@ type SnapshotPolicyFilterListInput struct {
// swagger:ignore
// Deprecated
// filter disk by snapshotpolicy_id
SnapshotpolicyId string `json:"snapshotpolicy_id" deprecated-by:"snapshotpolicy"`
SnapshotpolicyId string `json:"snapshotpolicy_id" "yunion:deprecated-by":"snapshotpolicy"`
}
type DiskListInput struct {
@@ -109,7 +109,7 @@ type DiskListInput struct {
// swagger:ignore
// Deprecated
// filter by disk type
Type string `json:"type" deprecated-by:"disk_type"`
Type string `json:"type" "yunion:deprecated-by":"disk_type"`
// 过滤指定disk_type的磁盘列表可能的值为sys, data, swap. volume
//
// | disk_type值 | 说明 |
@@ -128,7 +128,7 @@ type DiskFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by disk_id
DiskId string `json:"disk_id" deprecated-by:"disk"`
DiskId string `json:"disk_id" "yunion:deprecated-by":"disk"`
}
type SimpleGuest struct {

View File

@@ -27,15 +27,15 @@ type RegionalFilterListInput struct {
// swagger:ignore
// Deprecated
// description: this param will be deprecate at 3.0
CloudregionId string `json:"cloudregion_id" 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" 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" deprecated-by:"cloudregion"`
RegionId string `json:"region_id" "yunion:deprecated-by":"cloudregion"`
}
type ZonalFilterListInput struct {
@@ -46,7 +46,7 @@ type ZonalFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by zone_id
ZoneId string `json:"zone_id" deprecated-by:"zone"`
ZoneId string `json:"zone_id" "yunion:deprecated-by":"zone"`
// 过滤处于多个指定可用区内的资源
Zones []string `json:"zones"`
}
@@ -67,7 +67,7 @@ type HostFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by host_id
HostId string `json:"host_id" deprecated-by:"host"`
HostId string `json:"host_id" "yunion:deprecated-by":"host"`
}
type CloudregionListInput struct {

View File

@@ -28,15 +28,15 @@ type ServerFilterListInput struct {
// swagger:ignore
// Deprecated
// Filter by guest Id
ServerId string `json:"server_id" deprecated-by:"server"`
ServerId string `json:"server_id" "yunion:deprecated-by":"server"`
// swagger:ignore
// Deprecated
// Filter by guest Id
Guest string `json:"guest" deprecated-by:"server"`
Guest string `json:"guest" "yunion:deprecated-by":"server"`
// swagger:ignore
// Deprecated
// Filter by guest Id
GuestId string `json:"guest_id" deprecated-by:"server"`
GuestId string `json:"guest_id" "yunion:deprecated-by":"server"`
}
type ServerListInput struct {

View File

@@ -41,5 +41,5 @@ type GroupFilterListInput struct {
// swagger:ignore
// deprecated: true
// Filter by instance group Id
GroupId string `json:"group_id" deprecated-by:"group"`
GroupId string `json:"group_id" "yunion:deprecated-by":"group"`
}

View File

@@ -24,7 +24,7 @@ type VpcFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by vpc Id
VpcId string `json:"vpc_id" deprecated-by:"vpc"`
VpcId string `json:"vpc_id" "yunion:deprecated-by":"vpc"`
}
type WireFilterListInput struct {
@@ -35,7 +35,7 @@ type WireFilterListInput struct {
// swagger:ignore
// Deprecated
// fitler by wire id
WireId string `json:"wire_id" deprecated-by:"wire"`
WireId string `json:"wire_id" "yunion:deprecated-by":"wire"`
}
type NetworkFilterListInput struct {
@@ -46,7 +46,7 @@ type NetworkFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by networkId
NetworkId string `json:"network_id" deprecated-by:"network"`
NetworkId string `json:"network_id" "yunion:deprecated-by":"network"`
}
type NetworkListInput struct {
@@ -60,9 +60,13 @@ type NetworkListInput struct {
WireFilterListInput
// description: search ip address in network.
// description: Exact matching ip address in network.
// example: 10.168.222.1
Ip string `json:"ip"`
// description: Fuzzy matching ip address in network.
// example: 10.168.222.1
IpMatch string `json:"ip_match"`
}
type NetworkCreateInput struct {

View File

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

View File

@@ -162,7 +162,7 @@ type SecgroupFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by secgroup_id
SecgroupId string `json:"secgroup_id" deprecated-by:"secgroup"`
SecgroupId string `json:"secgroup_id" "yunion:deprecated-by":"secgroup"`
}
type SecgroupDetails struct {

View File

@@ -144,7 +144,7 @@ type StorageFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by storage_id
StorageId string `json:"storage_id" deprecated-by:"storage"`
StorageId string `json:"storage_id" "yunion:deprecated-by":"storage"`
}
type StorageShareFilterListInput struct {

View File

@@ -53,7 +53,7 @@ type WireDetails struct {
// example: 1
Networks int `json:"networks"`
// VPC名称
Vpc string `json:"vpc'`
Vpc string `json:"vpc"`
// VPC外部Id
VpcExtId string `json:"vpc_ext_id"`

View File

@@ -62,3 +62,7 @@ func (ra *SRoleAssignment) GetRoles() []string {
func (ra *SRoleAssignment) GetLoginIp() string {
return ""
}
func (ra *SRoleAssignment) GetTokenString() string {
return "faketoken"
}

View File

@@ -144,6 +144,10 @@ var (
"etcd_cacert",
"etcd_cert",
"etcd_key",
"bootstrap_admin_user_password",
"reset_admin_user_password",
"fernet_key_repository",
},
}
)

View File

@@ -40,10 +40,10 @@ type IdentityProviderCreateInput struct {
Template string `json:"template"`
// 默认导入用户和组的域
TargetDomainId string `json:"target_domain_id"`
TargetDomain string `json:"target_domain"`
// swagger:ignore
// Deprecated
TargetDomain string `json:"target_domain" "yunion:deprecated-by":"target_domain_id"`
TargetDomainId string `json:"target_domain_id" "yunion:deprecated-by":"target_domain"`
// 新建域的时候是否自动新建第一个项目
AutoCreateProject *bool `json:"auto_create_project"`

View File

@@ -48,15 +48,15 @@ type ProjectFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by project_id
ProjectId string `json:"project_id" deprecated-by:"project"`
ProjectId string `json:"project_id" "yunion:deprecated-by":"project"`
// swagger:ignore
// Deprecated
// filter by tenant
Tenant string `json:"tenant" deprecated-by:"project"`
Tenant string `json:"tenant" "yunion:deprecated-by":"project"`
// swagger:ignore
// Deprecated
// filter by tenant_id
TenantId string `json:"tenant_id" deprecated-by:"project"`
TenantId string `json:"tenant_id" "yunion:deprecated-by":"project"`
}
type UserFilterListInput struct {
@@ -65,7 +65,7 @@ type UserFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by user_id
UserId string `json:"user_id" deprecated-by:"user"`
UserId string `json:"user_id" "yunion:deprecated-by":"user"`
}
type GroupFilterListInput struct {
@@ -74,7 +74,7 @@ type GroupFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by group_id
GroupId string `json:"group_id" deprecated-by:"group"`
GroupId string `json:"group_id" "yunion:deprecated-by":"group"`
}
type RoleFilterListInput struct {
@@ -83,7 +83,7 @@ type RoleFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by role_id
RoleId string `json:"role_id" deprecated-by:"role"`
RoleId string `json:"role_id" "yunion:deprecated-by":"role"`
}
type ServiceFilterListInput struct {
@@ -92,7 +92,7 @@ type ServiceFilterListInput struct {
// swagger:ignore
// Deprecated
// filter by service_id
ServiceId string `json:"service_id" deprecated-by:"service"`
ServiceId string `json:"service_id" "yunion:deprecated-by":"service"`
}
type RoleListInput struct {

View File

@@ -28,11 +28,11 @@ type DomainizedResourceListInput struct {
// swagger:ignore
// Deprecated
// Project domain Id filter, alias for project_domain
ProjectDomainId string `json:"project_domain_id" 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" deprecated-by:"project_domain"`
DomainId string `json:"domain_id" "yunion:deprecated-by":"project_domain"`
}
type DomainizedResourceCreateInput struct {
@@ -53,15 +53,15 @@ type ProjectizedResourceListInput struct {
// swagger:ignore
// Deprecated
// Filter by project_id, alias for project
ProjectId string `json:"project_id" 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" 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" deprecated-by:"project"`
TenantId string `json:"tenant_id" "yunion:deprecated-by":"project"`
}
type ProjectizedResourceCreateInput struct {
@@ -82,7 +82,7 @@ type UserResourceListInput struct {
// swagger:ignore
// Deprecated
// Filter by userId
UserId string `json:"user_id" deprecated-by:"user"`
UserId string `json:"user_id" "yunion:deprecated-by":"user"`
}
func (input UserResourceListInput) UserStr() string {

View File

@@ -25,10 +25,12 @@ type Ring struct {
}
func NewRing(size int) *Ring {
r := Ring{buffer: make([]interface{}, size+1),
r := Ring{
buffer: make([]interface{}, size+1),
header: 0,
tail: 0,
lock: &sync.Mutex{}}
lock: &sync.Mutex{},
}
return &r
}
@@ -58,6 +60,7 @@ func (r *Ring) Pop() interface{} {
return nil
}
ret := r.buffer[r.tail]
r.buffer[r.tail] = nil
r.tail = nextPointer(r.tail, len(r.buffer))
return ret
}

View File

@@ -19,28 +19,33 @@ import (
)
func TestRing(t *testing.T) {
r := NewRing(10)
var v int32 = 10
r.Push(v)
v = 20
r.Push(v)
v = 30
r.Push(v)
v1 := r.Pop().(int32)
if v1 != 10 {
t.Error("Fail")
}
v2 := r.Pop().(int32)
if v2 != 20 {
t.Error("Fail")
}
v3 := r.Pop().(int32)
if v3 != 30 {
t.Error("Fail")
}
v4 := r.Pop()
if v4 != nil {
t.Error("Fail")
var (
r = NewRing(10)
push = func(v int32) {
r.Push(v)
}
pop = func(want int32) {
got := r.Pop().(int32)
if got != want {
t.Fatalf("got %d, want %d", got, want)
}
for i := r.header; i != r.tail; i = nextPointer(i, len(r.buffer)) {
if r.buffer[i] != nil {
t.Fatalf("head %d, tail %d, index %d not nil",
r.header, r.tail, i)
}
}
}
)
push(10)
push(20)
push(30)
pop(10)
pop(20)
pop(30)
if v := r.Pop(); v != nil {
t.Fatalf("want nil, got %#v", v)
}
}

View File

@@ -83,9 +83,6 @@ func (worker *SWorker) run() {
task := req.(*sWorkerTask)
if task.worker != nil {
task.worker <- worker
// worker channel is buffered
// close the worker channel
close(task.worker)
}
execCallback(task)
} else {

View File

@@ -163,12 +163,7 @@ func handleBaremetalCdromTask(ctx *Context, bm *baremetal.SBaremetalInstance) {
}
func handleBaremetalJnlpTask(ctx *Context, bm *baremetal.SBaremetalInstance) {
cli := bm.GetRedfishCli(ctx)
if cli == nil {
ctx.ResponseError(httperrors.NewNotSupportedError("Redfish API"))
return
}
jnlp, err := cli.GetConsoleJNLP(ctx)
jnlp, err := bm.GetConsoleJNLP(ctx)
if err != nil {
ctx.ResponseError(errors.Wrap(err, "GetConsoleJNLP"))
return

View File

@@ -64,6 +64,7 @@ import (
"yunion.io/x/onecloud/pkg/util/influxdb"
"yunion.io/x/onecloud/pkg/util/procutils"
"yunion.io/x/onecloud/pkg/util/redfish"
"yunion.io/x/onecloud/pkg/util/redfish/bmconsole"
"yunion.io/x/onecloud/pkg/util/ssh"
"yunion.io/x/onecloud/pkg/util/sysutils"
)
@@ -1935,6 +1936,25 @@ func (b *SBaremetalInstance) fetchPowerThermalMetrics(ctx context.Context) ([]in
return powerMetrics, thermalMetrics, nil
}
func (b *SBaremetalInstance) GetConsoleJNLP(ctx context.Context) (string, error) {
cli := b.GetRedfishCli(ctx)
if cli != nil {
return cli.GetConsoleJNLP(ctx)
}
conf := b.GetIPMIConfig()
bmc := bmconsole.NewBMCConsole(conf.IpAddr, conf.Username, conf.Password, false)
manufacture := b.GetManufacture()
switch strings.ToLower(manufacture) {
case "hp", "hpe":
return bmc.GetIloConsoleJNLP(ctx)
case "dell", "dell inc.":
return bmc.GetIdracConsoleJNLP(ctx, "", "")
case "supermicro":
return bmc.GetSupermicroConsoleJNLP(ctx)
}
return "", httperrors.NewNotImplementedError("Unsupported manufacture %s", manufacture)
}
func (b *SBaremetalInstance) getTags() []influxdb.SKeyValue {
tags := []influxdb.SKeyValue{
{

View File

@@ -43,7 +43,7 @@ func InspurProfile() IPMIProfile {
func LenovoProfile() IPMIProfile {
return IPMIProfile{
LanChannel: []int{8},
LanChannel: []int{1, 8},
RootName: "root",
RootId: 2,
}
@@ -51,7 +51,7 @@ func LenovoProfile() IPMIProfile {
func HpProfile() IPMIProfile {
return IPMIProfile{
LanChannel: []int{2},
LanChannel: []int{1, 2},
RootName: "root",
RootId: 1,
}

View File

@@ -64,6 +64,7 @@ func (s *BaremetalService) StartService() {
fsdriver.Init(nil)
app := app_common.InitApp(&o.Options.BaseOptions, false)
handler.InitHandlers(app)
s.startAgent(app)

View File

@@ -306,7 +306,13 @@ func (self *SBaremetalTaskBase) EnsurePowerUp() error {
if err != nil {
return errors.Wrapf(err, "Get power status")
}
maxTries := 10
count := 0
for status == "" || status == types.POWER_STATUS_OFF {
if count > maxTries {
break
}
log.Infof("Try power on %d times, pxe boot %v", count+1, self.PxeBoot)
if status == types.POWER_STATUS_OFF {
if self.PxeBoot {
err = self.Baremetal.DoPXEBoot()
@@ -314,7 +320,7 @@ func (self *SBaremetalTaskBase) EnsurePowerUp() error {
err = self.Baremetal.DoRedfishPowerOn()
}
if err != nil {
return errors.Wrapf(err, "Do boot power on")
log.Warningf("Do boot power on error: %v", err)
}
}
status, err = self.Baremetal.GetPowerStatus()
@@ -328,6 +334,7 @@ func (self *SBaremetalTaskBase) EnsurePowerUp() error {
return err
}
}
count++
}
if status != types.POWER_STATUS_ON {
return fmt.Errorf("Baremetal invalid restart status: %s", status)

View File

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

View File

@@ -83,8 +83,9 @@ func InitAuth(options *common_options.CommonOptions, authComplete auth.AuthCompl
func InitBaseAuth(options *common_options.BaseOptions) {
if options.EnableRbac {
policy.EnableGlobalRbac(time.Duration(options.RbacPolicySyncPeriodSeconds)*time.Second,
time.Duration(options.RbacPolicySyncFailedRetrySeconds)*time.Second,
policy.EnableGlobalRbac(
time.Second*time.Duration(options.RbacPolicySyncPeriodSeconds),
time.Second*time.Duration(options.RbacPolicySyncFailedRetrySeconds),
options.RbacDebug,
)
}

View File

@@ -402,7 +402,7 @@ func FetchServerCreateInputByJSON(obj jsonutils.JSONObject) (*compute.ServerCrea
input.InstanceType = skuName
}
if keypair := jsonutils.GetAnyString(obj, []string{"keypair", "keypair_id"}); keypair != "" {
input.KeypairId = keypair
input.Keypair = keypair
}
if secgroup := jsonutils.GetAnyString(obj, []string{"secgroup", "secgroup_id", "secgrp_id"}); len(secgroup) != 0 {
input.SecgroupId = secgroup

View File

@@ -44,7 +44,7 @@ func InitDB(options *common_options.DBOptions) {
dialect, sqlStr, err := options.GetDBConnection()
if err != nil {
log.Fatalf("Invalid SqlConnection string: %s", options.SqlConnection)
log.Fatalf("Invalid SqlConnection string: %s error: %v", options.SqlConnection, err)
}
dbConn, err := sql.Open(dialect, sqlStr)
if err != nil {

View File

@@ -686,7 +686,7 @@ func calculateListResult(data []jsonutils.JSONObject, total, limit, offset int64
}
}
// do limit
if limit > 0 && total > limit {
if limit > 0 && total-offset > limit {
data = data[:limit]
}
}
@@ -1155,6 +1155,12 @@ func (dispatcher *DBModelDispatcher) Create(ctx context.Context, query jsonutils
model, err := DoCreate(dispatcher.modelManager, ctx, userCred, query, data, ownerId)
if err != nil {
// log.Errorf("fail to doCreateItem %s", err)
if CancelPendingUsagesInContext != nil {
err := CancelPendingUsagesInContext(ctx, userCred)
if err != nil {
log.Errorf("CancelPendingUsagesInContext fail %s", err)
}
}
failErr := manager.OnCreateFailed(ctx, userCred, ownerId, query, data)
if failErr != nil {
log.Errorf("manager.OnCreateFailed %s", failErr)
@@ -1347,6 +1353,19 @@ func managerPerformCheckCreateData(
return nil, httperrors.NewForbiddenError("not allow to perform %s", action)
}
if InitPendingUsagesInContext != nil {
ctx = InitPendingUsagesInContext(ctx)
defer func() {
if CancelPendingUsagesInContext != nil {
err := CancelPendingUsagesInContext(ctx, userCred)
if err != nil {
log.Errorf("CancelPendingUsagesInContext fail %s", err)
}
}
}()
}
return ValidateCreateData(manager, ctx, userCred, ownerId, query, bodyDict)
}

View File

@@ -22,7 +22,6 @@ import (
"time"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/sqlchemy"
"yunion.io/x/onecloud/pkg/apis"
@@ -391,12 +390,6 @@ func (manager *SModelBaseManager) BatchCreateValidateCreateData(ctx context.Cont
}
func (manager *SModelBaseManager) OnCreateFailed(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
if CancelPendingUsagesInContext != nil {
err := CancelPendingUsagesInContext(ctx, userCred)
if err != nil {
return errors.Wrap(err, "CancelPendingUsagesInContext")
}
}
return nil
}

View File

@@ -205,14 +205,14 @@ func RegisterReferrer(man db.IModelManager) {
}
func ValidateProxySettingResourceInput(userCred mcclient.TokenCredential, input proxyapi.ProxySettingResourceInput) (*SProxySetting, proxyapi.ProxySettingResourceInput, error) {
m, err := ProxySettingManager.FetchByIdOrName(userCred, input.ProxySettingId)
m, err := ProxySettingManager.FetchByIdOrName(userCred, input.ProxySetting)
if err != nil {
if errors.Cause(err) == sql.ErrNoRows {
return nil, input, errors.Wrapf(httperrors.ErrResourceNotFound, "%s %s", ProxySettingManager.Keyword(), input.ProxySettingId)
return nil, input, errors.Wrapf(httperrors.ErrResourceNotFound, "%s %s", ProxySettingManager.Keyword(), input.ProxySetting)
} else {
return nil, input, errors.Wrapf(err, "ProxySettingManager.FetchByIdOrName")
}
}
input.ProxySettingId = m.GetId()
input.ProxySetting = m.GetId()
return m.(*SProxySetting), input, nil
}

View File

@@ -20,6 +20,7 @@ import (
"fmt"
"net/http"
"reflect"
"sort"
"strings"
"yunion.io/x/jsonutils"
@@ -435,7 +436,7 @@ func (manager *SQuotaBaseManager) listDomainQuotaHandler(ctx context.Context, w
httperrors.GeneralServerError(w, err)
return
}
manager.sendQuotaList(w, quotaList)
manager.sendQuotaList(w, sortQuotaByUsage(quotaList))
}
func (manager *SQuotaBaseManager) sendQuotaList(w http.ResponseWriter, quotaList []jsonutils.JSONObject) {
@@ -478,7 +479,7 @@ func (manager *SQuotaBaseManager) listProjectQuotaHandler(ctx context.Context, w
httperrors.GeneralServerError(w, err)
return
}
manager.sendQuotaList(w, quotaList)
manager.sendQuotaList(w, sortQuotaByUsage(quotaList))
}
func (manager *SQuotaBaseManager) listQuotas(ctx context.Context, userCred mcclient.TokenCredential, targetDomainId string, targetProjectId string, domainOnly bool, primaryOnly bool, refresh bool) ([]jsonutils.JSONObject, error) {
@@ -566,3 +567,33 @@ func (manager *SQuotaBaseManager) listQuotas(ctx context.Context, userCred mccli
}
return ret, nil
}
type tQuotaResultList []jsonutils.JSONObject
func (a tQuotaResultList) Len() int { return len(a) }
func (a tQuotaResultList) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a tQuotaResultList) Less(i, j int) bool { return usageRateOfQuota(a[i]) > usageRateOfQuota(a[j]) }
func usageRateOfQuota(quota jsonutils.JSONObject) float32 {
maxRate := float32(0)
quotaMap, _ := quota.GetMap()
for k, v := range quotaMap {
usageK := fmt.Sprintf("usage.%s", k)
if usageV, ok := quotaMap[usageK]; ok {
intV, _ := v.Int()
if intV > 0 {
intUsageV, _ := usageV.Int()
rate := float32(intUsageV) / float32(intV)
if maxRate < rate {
maxRate = rate
}
}
}
}
return maxRate
}
func sortQuotaByUsage(quotaList []jsonutils.JSONObject) []jsonutils.JSONObject {
sort.Sort(tQuotaResultList(quotaList))
return quotaList
}

View File

@@ -70,7 +70,7 @@ func isObjectRbacAllowed(model IModel, userCred mcclient.TokenCredential, action
if !requireScope.HigherThan(scope) {
return nil
}
return httperrors.NewForbiddenError(fmt.Sprintf("not enough privillege(require:%s,allow:%s)", requireScope, scope))
return httperrors.NewForbiddenError(fmt.Sprintf("not enough privilege(require:%s,allow:%s)", requireScope, scope))
}
func isJointObjectRbacAllowed(item IJointModel, userCred mcclient.TokenCredential, action string, extra ...string) error {

View File

@@ -66,8 +66,8 @@ func RegistUserCredCacheUpdater() {
auth.RegisterAuthHook(onAuthCompleteUpdateCache)
}
func onAuthCompleteUpdateCache(userCred mcclient.TokenCredential) {
TenantCacheManager.updateTenantCache(userCred)
func onAuthCompleteUpdateCache(ctx context.Context, userCred mcclient.TokenCredential) {
TenantCacheManager.updateTenantCache(ctx, userCred)
UserCacheManager.updateUserCache(userCred)
}
@@ -91,8 +91,8 @@ func (manager *STenantCacheManager) InitializeData() error {
return nil
}
func (manager *STenantCacheManager) updateTenantCache(userCred mcclient.TokenCredential) {
manager.Save(context.Background(), userCred.GetProjectId(), userCred.GetProjectName(),
func (manager *STenantCacheManager) updateTenantCache(ctx context.Context, userCred mcclient.TokenCredential) {
manager.Save(ctx, userCred.GetProjectId(), userCred.GetProjectName(),
userCred.GetProjectDomainId(), userCred.GetProjectDomain())
}
@@ -348,14 +348,14 @@ func (manager *STenantCacheManager) findFirstProjectOfDomain(domainId string) (*
return &tenant, nil
}
func (manager *STenantCacheManager) fetchDomainTenantsFromKeystone(domainId string) error {
func (manager *STenantCacheManager) fetchDomainTenantsFromKeystone(ctx context.Context, domainId string) error {
if len(domainId) == 0 {
log.Debugf("fetch empty domain!!!!")
debug.PrintStack()
return fmt.Errorf("Empty domainId")
}
s := auth.GetAdminSession(context.Background(), consts.GetRegion(), "v1")
s := auth.GetAdminSession(ctx, consts.GetRegion(), "v1")
params := jsonutils.Marshal(map[string]string{"domain_id": domainId})
tenants, err := modules.Projects.List(s, params)
if err != nil {
@@ -366,7 +366,7 @@ func (manager *STenantCacheManager) fetchDomainTenantsFromKeystone(domainId stri
tenantName, _ := tenant.GetString("name")
domainId, _ := tenant.GetString("domain_id")
domainName, _ := tenant.GetString("project_domain")
_, err = manager.Save(context.Background(), tenantId, tenantName, domainId, domainName)
_, err = manager.Save(ctx, tenantId, tenantName, domainId, domainName)
if err != nil {
return err
}
@@ -374,11 +374,11 @@ func (manager *STenantCacheManager) fetchDomainTenantsFromKeystone(domainId stri
return nil
}
func (manager *STenantCacheManager) FindFirstProjectOfDomain(domainId string) (*STenant, error) {
func (manager *STenantCacheManager) FindFirstProjectOfDomain(ctx context.Context, domainId string) (*STenant, error) {
tenant, err := manager.findFirstProjectOfDomain(domainId)
if err != nil {
if err == sql.ErrNoRows {
err = manager.fetchDomainTenantsFromKeystone(domainId)
err = manager.fetchDomainTenantsFromKeystone(ctx, domainId)
if err != nil {
return nil, errors.Wrap(err, "fetchDomainTenantsFromKeystone")
}

View File

@@ -20,6 +20,7 @@ import (
"sort"
"strings"
"sync"
"sync/atomic"
"time"
"yunion.io/x/jsonutils"
@@ -80,35 +81,42 @@ type SPolicyManager struct {
lock *sync.Mutex
}
type sPolicyData struct {
Type string `json:"type"`
Enabled bool `json:"enabled"`
DomainId string `json:"domain_id"`
IsPublic bool `json:"is_public"`
Policy jsonutils.JSONObject `json:"policy"`
}
func parseJsonPolicy(obj jsonutils.JSONObject) (string, *rbacutils.SRbacPolicy, error) {
typeStr, err := obj.GetString("type")
pData := sPolicyData{}
err := obj.Unmarshal(&pData)
if err != nil {
return "", nil, errors.Wrap(err, "missing type")
return "", nil, errors.Wrap(err, "Unmarshal")
}
domainId, err := obj.GetString("domain_id")
if err != nil {
return "", nil, errors.Wrap(err, "missing domain_id")
if !pData.Enabled {
return "", nil, errors.Wrap(httperrors.ErrInputParameter, "not enabled")
}
if len(pData.Type) == 0 {
return "", nil, errors.Wrap(httperrors.ErrInputParameter, "missing type")
}
isPublic := jsonutils.QueryBoolean(obj, "is_public", false)
blob, err := obj.Get("policy")
if err != nil {
log.Errorf("get blob error %s", err)
return "", nil, errors.Wrap(err, "json.Get")
if pData.Policy == nil {
return "", nil, errors.Wrap(httperrors.ErrInputParameter, "missing policy")
}
policy := rbacutils.SRbacPolicy{}
err = policy.Decode(blob)
err = policy.Decode(pData.Policy)
if err != nil {
log.Errorf("policy decode error %s", err)
return "", nil, errors.Wrap(err, "policy.Decode")
}
policy.DomainId = domainId
policy.IsPublic = isPublic
policy.DomainId = pData.DomainId
policy.IsPublic = pData.IsPublic
return typeStr, &policy, nil
return pData.Type, &policy, nil
}
func remotePolicyFetcher() (map[rbacutils.TRbacScope]map[string]*rbacutils.SRbacPolicy, error) {
@@ -121,7 +129,7 @@ func remotePolicyFetcher() (map[rbacutils.TRbacScope]map[string]*rbacutils.SRbac
params := jsonutils.NewDict()
params.Add(jsonutils.NewInt(2048), "limit")
params.Add(jsonutils.NewInt(int64(offset)), "offset")
params.Add(jsonutils.JSONTrue, "admin")
params.Add(jsonutils.NewString("system"), "scope")
params.Add(jsonutils.JSONTrue, "enabled")
result, err := modules.Policies.List(s, params)
if err != nil {
@@ -165,16 +173,38 @@ func (manager *SPolicyManager) start(refreshInterval time.Duration, retryInterva
policiesMap[policy.Scope] = policies
}
manager.defaultPolicies = policiesMap
log.Debugf("%#v", manager.defaultPolicies)
// log.Debugf("%#v", manager.defaultPolicies)
}
manager.cache = hashcache.NewCache(2048, manager.refreshInterval/2)
manager.SyncOnce()
manager.syncByInterval()
}
func (manager *SPolicyManager) syncByInterval() {
syncWorkerManager.Run(manager.syncByInterval_, nil, nil)
}
func (manager *SPolicyManager) syncByInterval_() {
err := manager.doSync()
var interval time.Duration
if err != nil {
interval = manager.failedRetryInterval
} else {
interval = manager.refreshInterval
}
time.AfterFunc(interval, manager.syncByInterval)
}
var syncOnce int32
func (manager *SPolicyManager) SyncOnce() {
syncWorkerManager.Run(manager.sync, nil, nil)
if atomic.CompareAndSwapInt32(&syncOnce, 0, 1) {
syncWorkerManager.Run(func() {
atomic.StoreInt32(&syncOnce, 0)
manager.doSync()
}, nil, nil)
}
}
func (manager *SPolicyManager) doSync() error {
@@ -202,17 +232,6 @@ func (manager *SPolicyManager) doSync() error {
return nil
}
func (manager *SPolicyManager) sync() {
err := manager.doSync()
var interval time.Duration
if err != nil {
interval = manager.failedRetryInterval
} else {
interval = manager.refreshInterval
}
time.AfterFunc(interval, manager.SyncOnce)
}
func queryKey(scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) string {
queryKeys := []string{string(scope)}
queryKeys = append(queryKeys, userCred.GetProjectId(), userCred.GetDomainId(), userCred.GetUserId())
@@ -315,42 +334,16 @@ func (manager *SPolicyManager) findPolicyByName(scope rbacutils.TRbacScope, name
}
func getMatchedPolicyNames(policies map[string]*rbacutils.SRbacPolicy, userCred rbacutils.IRbacIdentity) []string {
matchNames := make([]string, 0)
maxMatchWeight := 0
for k := range policies {
isMatched, matchWeight := policies[k].Match(userCred)
if !isMatched || matchWeight < maxMatchWeight {
continue
}
if maxMatchWeight < matchWeight {
maxMatchWeight = matchWeight
matchNames = matchNames[:0]
}
matchNames = append(matchNames, k)
}
_, matchNames := rbacutils.GetMatchedPolicies(policies, userCred)
return matchNames
}
func getMatchedPolicyRules(policies map[string]*rbacutils.SRbacPolicy, userCred rbacutils.IRbacIdentity, service string, resource string, action string, extra ...string) ([]rbacutils.SRbacRule, bool) {
matchRules := make([]rbacutils.SRbacRule, 0)
findMatchPolicy := false
maxMatchWeight := 0
for k := range policies {
isMatched, matchWeight := policies[k].Match(userCred)
if !isMatched || matchWeight < maxMatchWeight {
continue
}
if maxMatchWeight < matchWeight {
maxMatchWeight = matchWeight
matchRules = matchRules[:0]
}
findMatchPolicy = true
rule := policies[k].GetMatchRule(service, resource, action, extra...)
if rule != nil {
matchRules = append(matchRules, *rule)
}
matchPolicies, _ := rbacutils.GetMatchedPolicies(policies, userCred)
if len(matchPolicies) == 0 {
return nil, false
}
return matchRules, findMatchPolicy
return matchPolicies.GetMatchRules(service, resource, action, extra...), true
}
func (manager *SPolicyManager) allowWithoutCache(scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) rbacutils.TRbacResult {
@@ -406,8 +399,15 @@ func (manager *SPolicyManager) allowWithoutCache(scope rbacutils.TRbacScope, use
var result rbacutils.TRbacResult
if len(matchRules) > 0 {
rule := rbacutils.GetMatchRule(matchRules, service, resource, action, extra...)
result = rule.Result
result = rbacutils.Deny
for _, rule := range matchRules {
if rule.Result == rbacutils.Allow {
result = rbacutils.Allow
break
}
}
// rule := rbacutils.GetMatchRule(matchRules, service, resource, action, extra...)
// result = rule.Result
} else if findMatchPolicy {
// if find matched policy, but no rule matching, allow anyway
result = rbacutils.Allow
@@ -520,7 +520,7 @@ func (manager *SPolicyManager) IsScopeCapable(userCred mcclient.TokenCredential,
return false
}
func (manager *SPolicyManager) MatchedPolicies(scope rbacutils.TRbacScope, userCred rbacutils.IRbacIdentity) []string {
func (manager *SPolicyManager) MatchedPolicyNames(scope rbacutils.TRbacScope, userCred rbacutils.IRbacIdentity) []string {
ret := make([]string, 0)
policies, ok := manager.policies[scope]
if !ok {
@@ -544,13 +544,28 @@ func (manager *SPolicyManager) AllPolicies() map[string][]string {
}
func (manager *SPolicyManager) RoleMatchPolicies(roleName string) []string {
ident := rbacutils.NewRbacIdentity("", "", []string{roleName})
ret := make([]string, 0)
for _, policies := range manager.policies {
for name, policy := range policies {
if policy.MatchRole(roleName) {
if matched, _ := policy.Match(ident); matched {
ret = append(ret, name)
}
}
}
return ret
}
func (manager *SPolicyManager) GetMatchedPolicySet(userCred rbacutils.IRbacIdentity) (rbacutils.TRbacScope, rbacutils.TPolicySet) {
for _, scope := range []rbacutils.TRbacScope{
rbacutils.ScopeSystem,
rbacutils.ScopeDomain,
rbacutils.ScopeProject,
} {
macthed, _ := rbacutils.GetMatchedPolicies(manager.policies[scope], userCred)
if len(macthed) > 0 {
return scope, macthed
}
}
return rbacutils.ScopeNone, nil
}

View File

@@ -66,7 +66,9 @@ var (
meterDomainResources = []string{}
meterUserResources = []string{}
k8sSystemResources = []string{}
k8sSystemResources = []string{
"repos",
}
k8sDomainResources = []string{}
k8sUserResources = []string{}

View File

@@ -86,19 +86,6 @@ func (manager *SCloudeventManager) ListItemFilter(ctx context.Context, q *sqlche
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
}
/* input.Cloudprovider = input.CloudproviderStr()
if len(input.Cloudprovider) > 0 {
providerObj, err := CloudproviderManager.FetchByIdOrName(userCred, input.Cloudprovider)
if err != nil {
if err == sql.ErrNoRows {
return nil, httperrors.NewResourceNotFoundError2(CloudproviderManager.Keyword(), input.Cloudprovider)
} else {
return nil, httperrors.NewGeneralError(err)
}
}
q = q.Equals("cloudprovider_id", providerObj.GetId())
}*/
if len(input.Providers) > 0 {
q = q.In("provider", input.Providers)
}
@@ -107,6 +94,22 @@ func (manager *SCloudeventManager) ListItemFilter(ctx context.Context, q *sqlche
q = q.In("brand", input.Brands)
}
if len(input.Service) > 0 {
q = q.In("service", input.Service)
}
if len(input.Manager) > 0 {
q = q.In("manager", input.Manager)
}
if len(input.Account) > 0 {
q = q.In("account", input.Account)
}
if len(input.Action) > 0 {
q = q.In("action", input.Action)
}
if !input.Since.IsZero() {
q = q.GT("created_at", input.Since)
}

View File

@@ -36,8 +36,10 @@ import (
"yunion.io/x/onecloud/pkg/cloudevent/options"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/s3gateway/session"
"yunion.io/x/onecloud/pkg/util/httputils"
)
type SCloudproviderManager struct {
@@ -61,39 +63,27 @@ func init() {
type SCloudprovider struct {
db.SEnabledStatusStandaloneResourceBase
HealthStatus string `width:"16" charset:"ascii" default:"normal" nullable:"false" list:"domain"`
SyncStatus string
LastSync time.Time
LastSyncEndAt time.Time
LastSyncTimeAt time.Time
AccessUrl string `width:"64" charset:"ascii" nullable:"true" list:"domain" update:"domain"`
Account string `width:"128" charset:"ascii" nullable:"false" list:"domain"`
Secret string `length:"0" charset:"ascii" nullable:"false" list:"domain"`
Provider string `width:"64" charset:"ascii" list:"domain"`
Brand string `width:"64" charset:"ascii" list:"domain"`
ProxySetting *proxyapi.SProxySetting
}
func (manager *SCloudproviderManager) GetRegionCloudproviders(ctx context.Context, userCred mcclient.TokenCredential) ([]SCloudprovider, error) {
s := session.GetSession(ctx, userCred)
params := jsonutils.NewDict()
params.Add(jsonutils.JSONTrue, "details")
result, err := modules.Cloudproviders.List(s, params)
if err != nil {
return nil, errors.Wrap(err, "modules.Cloudproviders.List")
}
providers := []SCloudprovider{}
for _, _provider := range result.Data {
provider := SCloudprovider{}
provider.SetModelManager(manager, &provider)
err = _provider.Unmarshal(&provider)
if err != nil {
return nil, errors.Wrap(err, "_provider.Unmarshal")
}
providers = append(providers, provider)
err = jsonutils.Update(&providers, result.Data)
if err != nil {
return nil, errors.Wrap(err, "jsonutils.Update")
}
return providers, nil
}
@@ -108,17 +98,18 @@ func (manager *SCloudproviderManager) GetLocalCloudproviders() ([]SCloudprovider
return dbProviders, nil
}
func (manager *SCloudproviderManager) SyncCloudproviders(ctx context.Context, userCred mcclient.TokenCredential, isStart bool) {
func (manager *SCloudproviderManager) syncCloudproviders(ctx context.Context, userCred mcclient.TokenCredential) compare.SyncResult {
result := compare.SyncResult{}
providers, err := manager.GetRegionCloudproviders(ctx, userCred)
if err != nil {
log.Errorf("failed to get region cloudproviders: %v", err)
return
result.Error(errors.Wrap(err, "GetRegionCloudproviders"))
return result
}
dbProviders, err := manager.GetLocalCloudproviders()
if err != nil {
log.Errorf("failed to get local cloudproviders: %v", err)
return
result.Error(errors.Wrap(err, "GetLocalCloudproviders"))
return result
}
removed := make([]SCloudprovider, 0)
@@ -128,36 +119,48 @@ func (manager *SCloudproviderManager) SyncCloudproviders(ctx context.Context, us
err = compare.CompareSets(dbProviders, providers, &removed, &commondb, &commonext, &added)
if err != nil {
log.Errorf("compare.CompareSets: %v", err)
return
result.Error(errors.Wrap(err, "CompareSets"))
return result
}
for i := 0; i < len(removed); i++ {
err = removed[i].Delete(ctx, userCred)
if err != nil {
log.Errorf("failed to remove cloudprovider %s(%s) error: %v", removed[i].Name, removed[i].Id, err)
result.DeleteError(err)
continue
}
result.Delete()
}
for i := 0; i < len(commondb); i++ {
err = commondb[i].syncWithRegionProvider(ctx, userCred, commonext[i])
if err != nil {
log.Errorf("failed to sync cloudprovider %s(%s) error: %v", commondb[i].Name, commondb[i].Id, err)
result.UpdateError(err)
continue
}
result.Update()
}
for i := 0; i < len(added); i++ {
err = manager.newFromRegionProvider(ctx, userCred, added[i])
if err != nil {
log.Errorf("failed to add cloudprovider %s(%s) error: %v", added[i].Name, added[i].Id, err)
result.AddError(err)
continue
}
result.Add()
}
return result
}
func (manager *SCloudproviderManager) SyncCloudproviders(ctx context.Context, userCred mcclient.TokenCredential, isStart bool) {
result := manager.syncCloudproviders(ctx, userCred)
info := result.Result()
log.Infof("sync cloudproviders result: %s", info)
}
func (provider *SCloudprovider) syncWithRegionProvider(ctx context.Context, userCred mcclient.TokenCredential, cloudprovider SCloudprovider) error {
_, err := db.Update(provider, func() error {
provider.Status = cloudprovider.Status
provider.Secret = cloudprovider.Secret
provider.Enabled = cloudprovider.Enabled
provider.Brand = cloudprovider.Brand
return nil
@@ -173,8 +176,7 @@ func (self *SCloudprovider) MarkSyncing(userCred mcclient.TokenCredential) error
return nil
})
if err != nil {
log.Errorf("Failed to MarkSyncing error: %v", err)
return err
return errors.Wrap(err, "db.Update")
}
return nil
}
@@ -186,8 +188,7 @@ func (self *SCloudprovider) MarkEndSync(userCred mcclient.TokenCredential) error
return nil
})
if err != nil {
log.Errorf("Failed to markEndSync error: %v", err)
return err
return errors.Wrap(err, "db.Update")
}
return nil
}
@@ -198,8 +199,7 @@ func (self *SCloudprovider) SetLastSyncTimeAt(userCred mcclient.TokenCredential,
return nil
})
if err != nil {
log.Errorf("Failed to SetLastSyncTimeAt error: %v", err)
return err
return errors.Wrap(err, "db.Update")
}
return nil
}
@@ -209,30 +209,36 @@ func (manager *SCloudproviderManager) newFromRegionProvider(ctx context.Context,
return manager.TableSpec().Insert(&cloudprovider)
}
func (manager *SCloudproviderManager) SyncCloudeventTask(ctx context.Context, userCred mcclient.TokenCredential, isStart bool) {
func (manager *SCloudproviderManager) syncCloudeventTask(ctx context.Context, userCred mcclient.TokenCredential) error {
cloudproviders := []SCloudprovider{}
q := manager.Query().IsTrue("enabled").Equals("status", api.CLOUD_PROVIDER_CONNECTED).Equals("sync_status", api.CLOUD_PROVIDER_SYNC_STATUS_IDLE)
err := db.FetchModelObjects(manager, q, &cloudproviders)
if err != nil {
log.Errorf("failed to fetch cloudproviders")
return
return errors.Wrap(err, "db.FetchModelObjects")
}
for _, provider := range cloudproviders {
err = provider.StartCloudeventSyncTask(ctx, userCred)
for i := range cloudproviders {
err = cloudproviders[i].StartCloudeventSyncTask(ctx, userCred)
if err != nil {
log.Errorf("Failed start cloudevent sync task error: %v", err)
log.Errorf("Failed start cloudevent sync task for cloudprovider %s (%s) error: %v", cloudproviders[i].Name, cloudproviders[i].Id, err)
}
}
return
return nil
}
func (manager *SCloudproviderManager) SyncCloudeventTask(ctx context.Context, userCred mcclient.TokenCredential, isStart bool) {
err := manager.syncCloudeventTask(ctx, userCred)
if err != nil {
log.Errorf("syncCloudeventTask error: %v", err)
}
}
func (provider *SCloudprovider) StartCloudeventSyncTask(ctx context.Context, userCred mcclient.TokenCredential) error {
params := jsonutils.NewDict()
provider.MarkSyncing(userCred)
task, err := taskman.TaskManager.NewTask(ctx, "CloudeventSyncTask", provider, userCred, params, "", "", nil)
if err != nil {
return errors.Wrap(err, "NewTask")
}
provider.MarkSyncing(userCred)
task.ScheduleRun(nil)
return nil
}
@@ -277,11 +283,43 @@ func (self *SCloudprovider) GetNextTimeRange() (time.Time, time.Time, error) {
return start, end, nil
}
func (provider *SCloudprovider) getPassword() (string, error) {
type SCloudproviderDelegate struct {
Id string
Name string
Enabled bool
Status string
SyncStatus string
AccessUrl string
Account string
Secret string
Provider string
Brand string
ProxySetting proxyapi.SProxySetting
}
func (self *SCloudprovider) GetDelegate() (*SCloudproviderDelegate, error) {
s := auth.GetAdminSession(context.Background(), options.Options.Region, "")
result, err := modules.Cloudproviders.Get(s, self.Id, nil)
if err != nil {
return nil, errors.Wrap(err, "modules.Cloudproviders.Get")
}
provider := &SCloudproviderDelegate{}
err = result.Unmarshal(provider)
if err != nil {
return nil, errors.Wrap(err, "result.Unmarshal")
}
return provider, nil
}
func (provider *SCloudproviderDelegate) getPassword() (string, error) {
return utils.DescryptAESBase64(provider.Id, provider.Secret)
}
func (provider *SCloudprovider) getAccessUrl() string {
func (provider *SCloudproviderDelegate) getAccessUrl() string {
return provider.AccessUrl
}
@@ -297,33 +335,40 @@ func (provider SCloudprovider) GetExternalId() string {
return provider.Id
}
func (provider *SCloudprovider) GetProvider() (cloudprovider.ICloudProvider, error) {
if !provider.Enabled {
func (self *SCloudprovider) GetProvider() (cloudprovider.ICloudProvider, error) {
if !self.Enabled {
return nil, errors.Error("Cloud provider is not enabled")
}
accessUrl := provider.getAccessUrl()
passwd, err := provider.getPassword()
delegate, err := self.GetDelegate()
if err != nil {
return nil, err
return nil, errors.Wrap(err, "GetDelegate")
}
accessUrl := delegate.getAccessUrl()
passwd, err := delegate.getPassword()
if err != nil {
return nil, errors.Wrap(err, "delegate.getPassword")
}
ps := provider.ProxySetting
cfg := &httpproxy.Config{
HTTPProxy: ps.HTTPProxy,
HTTPSProxy: ps.HTTPSProxy,
NoProxy: ps.NoProxy,
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
var proxyFunc httputils.TransportProxyFunc
{
cfg := &httpproxy.Config{
HTTPProxy: delegate.ProxySetting.HTTPProxy,
HTTPSProxy: delegate.ProxySetting.HTTPSProxy,
NoProxy: delegate.ProxySetting.NoProxy,
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc = func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
}
return cloudprovider.GetProvider(
cloudprovider.ProviderConfig{
Id: provider.Id,
Name: provider.Name,
Vendor: provider.Provider,
Id: self.Id,
Name: self.Name,
Vendor: self.Provider,
URL: accessUrl,
Account: provider.Account,
Account: delegate.Account,
Secret: passwd,
ProxyFunc: proxyFunc,

View File

@@ -17,6 +17,8 @@ package cloudprovider
import (
"context"
"fmt"
"net/http"
"time"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
@@ -33,66 +35,66 @@ const (
)
type SCloudaccountCredential struct {
// 账号所在的项目
// 账号所在的项目 (openstack)
ProjectName string `json:"project_name"`
// 账号所在的域
// 账号所在的域 (openstack)
// default: Default
DomainName string `json:"domain_name"`
// 用户名
// 用户名 (openstack, zstack, esxi)
Username string `json:"username"`
// 密码
// 密码 (openstack, zstack, esxi)
Password string `json:"password"`
// 认证地址
// 认证地址 (openstack,zstack)
AuthUrl string `json:"auto_url"`
// 秘钥id
// 秘钥id (Aliyun, Aws, huawei, ucloud, ctyun, zstack, s3)
AccessKeyId string `json:"access_key_id"`
// 秘钥key
// 秘钥key (Aliyun, Aws, huawei, ucloud, ctyun, zstack, s3)
AccessKeySecret string `json:"access_key_secret"`
// 环境
// 环境 (Azure, Aws, huawei, ctyun)
Environment string `json:"environment"`
// 目录ID
// 目录ID (Azure)
DirectoryId string `json:"directory_id"`
// 客户端ID
// 客户端ID (Azure)
ClientId string `json:"client_id"`
// 客户端秘钥
// 客户端秘钥 (Azure)
ClientSecret string `json:"client_secret"`
// 主机IP
// 主机IP (esxi)
Host string `json:"host"`
// 主机端口
// 主机端口 (esxi)
Port int `json:"port"`
// 端点
// 端点 (s3)
Endpoint string `json:"endpoint"`
// app id
// app id (Qcloud)
AppId string `json:"app_id"`
//秘钥ID
//秘钥ID (Qcloud)
SecretId string `json:"secret_id"`
//秘钥key
//秘钥key (Qcloud)
SecretKey string `json:"secret_key"`
// Google服务账号email
ClientEmail string `json:"client_email"`
// Google服务账号project id
ProjectId string `json:"project_id"`
// Google服务账号秘钥id
PrivateKeyId string `json:"private_key_id"`
// Google服务账号秘钥
PrivateKey string `json:"private_key"`
// Google服务账号email (gcp)
GCPClientEmail string `json:"gcp_client_email"`
// Google服务账号project id (gcp)
GCPProjectId string `json:"gcp_project_id"`
// Google服务账号秘钥id (gcp)
GCPPrivateKeyId string `json:"gcp_private_key_id"`
// Google服务账号秘钥 (gcp)
GCPPrivateKey string `json:"gcp_private_key"`
}
type SCloudaccount struct {
@@ -155,6 +157,18 @@ type ProviderConfig struct {
ProxyFunc httputils.TransportProxyFunc
}
func (cp *ProviderConfig) HttpClient() *http.Client {
client := httputils.GetClient(true, 15*time.Second)
httputils.SetClientProxyFunc(client, cp.ProxyFunc)
return client
}
func (cp *ProviderConfig) AdaptiveTimeoutHttpClient() *http.Client {
client := httputils.GetAdaptiveTimeoutClient()
httputils.SetClientProxyFunc(client, cp.ProxyFunc)
return client
}
type ICloudProviderFactory interface {
GetProvider(cfg ProviderConfig) (ICloudProvider, error)
@@ -243,7 +257,7 @@ func GetProviderFactory(provider string) (ICloudProviderFactory, error) {
if ok {
return factory, nil
}
log.Errorf("Provider %s not registerd", provider)
log.Errorf("Provider %s not registered", provider)
return nil, fmt.Errorf("No such provider %s", provider)
}

View File

@@ -37,6 +37,8 @@ const (
CLOUD_SHELL = "cloud-shell"
CLOUD_SHELL_WITHOUT_ENCRYPT = "cloud-shell-without-encrypt"
CLOUD_CONFIG = "cloud-config"
CLOUD_POWER_SHELL = "powershell"
CLOUD_EC2 = "ec2"
)
type SManagedVMCreateConfig struct {

View File

@@ -270,6 +270,7 @@ func GetIBucketStats(bucket ICloudBucket) (SBucketStats, error) {
if objs.IsTruncated {
return stats, errors.Wrap(httperrors.ErrTooLarge, "too many objects")
}
stats.ObjectCount, stats.SizeBytes = 0, 0
for _, obj := range objs.Objects {
stats.SizeBytes += obj.GetSizeBytes()
stats.ObjectCount += 1

View File

@@ -20,7 +20,6 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/tristate"
"yunion.io/x/pkg/util/secrules"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/billing"
@@ -338,10 +337,10 @@ type ICloudSecurityGroup interface {
ICloudResource
GetDescription() string
GetRules() ([]secrules.SecurityRule, error)
GetRules() ([]SecurityRule, error)
GetVpcId() string
SyncRules(rules []secrules.SecurityRule) error
SyncRules(common, inAdds, outAdds, inDels, outDels []SecurityRule) error
Delete() error
}
@@ -750,7 +749,9 @@ type ICloudDBInstance interface {
GetConnectionStr() string
GetInternalConnectionStr() string
GetIZoneId() string
GetZone1Id() string
GetZone2Id() string
GetZone3Id() string
GetIVpcId() string
GetDBNetwork() (*SDBInstanceNetwork, error)

View File

@@ -14,7 +14,15 @@
package cloudprovider
import "yunion.io/x/pkg/util/secrules"
import (
"sort"
"strings"
"yunion.io/x/log"
"yunion.io/x/pkg/util/secrules"
)
const DEFAULT_CLOUD_RULE_ID = "default_cloud_rule_id"
type SecurityGroupCreateInput struct {
Name string
@@ -22,3 +30,268 @@ type SecurityGroupCreateInput struct {
VpcId string
Rules []secrules.SecurityRule
}
type SecurityRule struct {
secrules.SecurityRule
Name string
ExternalId string
}
type TPriorityOrder int
var (
PriorityOrderByDesc = TPriorityOrder(1)
PriorityOrderByAsc = TPriorityOrder(-1)
)
func (r SecurityRule) String() string {
return r.SecurityRule.String()
}
type SecurityRuleSet []SecurityRule
func (srs SecurityRuleSet) Len() int {
return len(srs)
}
func (srs SecurityRuleSet) Swap(i, j int) {
srs[i], srs[j] = srs[j], srs[i]
}
func (srs SecurityRuleSet) Less(i, j int) bool {
return srs[i].Priority < srs[j].Priority || (srs[i].Priority == srs[j].Priority && srs[i].String() < srs[j].String())
}
func (srs SecurityRuleSet) AllowList() secrules.SecurityRuleSet {
rules := secrules.SecurityRuleSet{}
for _, r := range srs {
rules = append(rules, r.SecurityRule)
}
return rules.AllowList()
}
func AddDefaultRule(rules []SecurityRule, defaultRule SecurityRule, localRuleStr string, order TPriorityOrder, min, max int, onlyAllowRules bool) []SecurityRule {
if defaultRule.String() == localRuleStr {
return rules
}
defaultRule.ExternalId = DEFAULT_CLOUD_RULE_ID
if order == PriorityOrderByDesc {
defaultRule.Priority = min
} else {
defaultRule.Priority = max
}
defaultRule.Priority -= int(order)
if onlyAllowRules {
defaultRule.Priority = -1
}
return append(rules, defaultRule)
}
func SortSecurityRule(rules SecurityRuleSet, order TPriorityOrder, onlyAllowRules bool) {
if onlyAllowRules {
sort.Sort(rules)
return
}
if order == PriorityOrderByAsc {
sort.Sort(sort.Reverse(rules))
return
}
sort.Sort(rules)
}
func CompareRules(
minPriority, maxPriority int, order TPriorityOrder,
localRules secrules.SecurityRuleSet, remoteRules []SecurityRule,
defaultInRule, defaultOutRule SecurityRule,
onlyAllowRules bool, debug bool,
) (common, inAdds, outAdds, inDels, outDels []SecurityRule) {
localInRules := secrules.SecurityRuleSet{}
localOutRules := secrules.SecurityRuleSet{}
for i := range localRules {
if localRules[i].Direction == secrules.DIR_IN {
localInRules = append(localInRules, localRules[i])
} else {
localOutRules = append(localOutRules, localRules[i])
}
}
inRules := SecurityRuleSet{}
outRules := SecurityRuleSet{}
for i := 0; i < len(remoteRules); i++ {
if remoteRules[i].Direction == secrules.DIR_IN {
inRules = append(inRules, remoteRules[i])
} else {
outRules = append(outRules, remoteRules[i])
}
}
var inCommon, outCommon = inRules, outRules
defaultLocalInRule := *secrules.MustParseSecurityRule("in:deny any")
defaultLocalOutRule := *secrules.MustParseSecurityRule("out:allow any")
inRules = AddDefaultRule(inRules, defaultInRule, defaultLocalInRule.String(), order, minPriority, maxPriority, onlyAllowRules)
outRules = AddDefaultRule(outRules, defaultOutRule, defaultLocalOutRule.String(), order, minPriority, maxPriority, onlyAllowRules)
if defaultLocalInRule.String() != defaultInRule.String() {
localInRules = append(localInRules, defaultLocalInRule)
}
if defaultLocalOutRule.String() != defaultOutRule.String() {
localOutRules = append(localOutRules, defaultLocalOutRule)
}
sort.Sort(localInRules)
sort.Sort(localOutRules)
localInAllowList := localInRules.AllowList()
localOutAllowList := localOutRules.AllowList()
if onlyAllowRules {
localInRules = localInAllowList
localOutRules = localOutAllowList
}
SortSecurityRule(inRules, order, onlyAllowRules)
SortSecurityRule(outRules, order, onlyAllowRules)
inAllowList := inRules.AllowList()
outAllowList := outRules.AllowList()
inEquals, outEquals := inAllowList.Equals(localInAllowList), outAllowList.Equals(localOutAllowList)
if inEquals && outEquals {
return
}
// priority从小到大排列(从默认规则开始对比)
sort.Sort(sort.Reverse(localInRules))
sort.Sort(sort.Reverse(localOutRules))
sort.Sort(sort.Reverse(inRules))
sort.Sort(sort.Reverse(outRules))
startPriority := minPriority - 1
if order == PriorityOrderByAsc {
startPriority = maxPriority + 1
}
var addPriority = func(priority int, order TPriorityOrder, inc int, min, max int, onlyAllowRules bool) int {
if onlyAllowRules {
return 0
}
inc = inc * int(order) //+ int(order)
priority += inc
if priority < min {
return min
}
if priority > max {
return max
}
return priority
}
var getInitPriority = func(init, min, max int) int {
if init < min || init > max {
return (min + max) / 2
}
return init
}
var compare = func(localRules secrules.SecurityRuleSet, remoteRules SecurityRuleSet) (common, add, del []SecurityRule) {
i, j, inc, prePriority := 0, 0, 1, 0
for i < len(localRules) || j < len(remoteRules) {
if i < len(localRules) && j < len(remoteRules) {
ruleStr := remoteRules[j].String()
localRuleStr := localRules[i].String()
if debug {
log.Debugf("compare local priority(%d) %s -> remote name(%s) priority(%d) %s\n", localRules[i].Priority, localRules[i].String(), remoteRules[j].Name, remoteRules[j].Priority, remoteRules[j].String())
}
cmp := strings.Compare(ruleStr, localRuleStr)
if cmp == 0 {
prePriority = remoteRules[j].Priority
if remoteRules[j].ExternalId == DEFAULT_CLOUD_RULE_ID {
remoteRules[j].Priority = addPriority(remoteRules[j].Priority, order, 1, minPriority, maxPriority, onlyAllowRules)
}
common = append(common, remoteRules[j])
i++
j++
} else if cmp < 0 {
if remoteRules[j].ExternalId != DEFAULT_CLOUD_RULE_ID {
del = append(del, remoteRules[j])
}
j++
} else {
initPriority := getInitPriority(prePriority, minPriority, maxPriority)
localRules[i].Priority = addPriority(initPriority, order, inc, minPriority, maxPriority, onlyAllowRules)
add = append(add, SecurityRule{SecurityRule: localRules[i]})
i++
inc++
}
} else if i >= len(localRules) {
if remoteRules[j].ExternalId != DEFAULT_CLOUD_RULE_ID {
del = append(del, remoteRules[j])
}
j++
} else if j >= len(remoteRules) {
initPriority := startPriority
if len(remoteRules) > 0 {
initPriority = remoteRules[len(remoteRules)-1].Priority
}
initPriority = getInitPriority(initPriority, minPriority, maxPriority) // 若是初始添加规则,尽量以中间为节点,避免仅出现天地规则
localRules[i].Priority = addPriority(initPriority, order, inc, minPriority, maxPriority, onlyAllowRules)
add = append(add, SecurityRule{SecurityRule: localRules[i]})
i++
inc++
}
}
return
}
type rulePair struct {
localRules []secrules.SecurityRule
remoteRules []SecurityRule
protocol string
}
var splitRules = func(localRules []secrules.SecurityRule, remoteRules []SecurityRule) []rulePair {
rules := map[string]rulePair{}
for _, r := range localRules {
pair, ok := rules[r.Protocol]
if !ok {
pair = rulePair{localRules: []secrules.SecurityRule{}, remoteRules: []SecurityRule{}, protocol: r.Protocol}
}
pair.localRules = append(pair.localRules, r)
rules[r.Protocol] = pair
}
for _, r := range remoteRules {
pair, ok := rules[r.Protocol]
if !ok {
pair = rulePair{localRules: []secrules.SecurityRule{}, remoteRules: []SecurityRule{}, protocol: r.Protocol}
}
pair.remoteRules = append(pair.remoteRules, r)
rules[r.Protocol] = pair
}
ret := []rulePair{}
for _, r := range rules {
ret = append(ret, r)
}
return ret
}
var compareRules = func(localRules []secrules.SecurityRule, remoteRules []SecurityRule) (common, add, dels []SecurityRule) {
pairs := splitRules(localRules, remoteRules)
for _, r := range pairs {
_common, _add, _dels := compare(r.localRules, r.remoteRules)
common = append(common, _common...)
add = append(add, _add...)
dels = append(dels, _dels...)
}
return
}
if !inEquals {
inCommon, inAdds, inDels = compareRules(localInRules, inRules)
}
if !outEquals {
outCommon, outAdds, outDels = compareRules(localOutRules, outRules)
}
common = append(inCommon, outCommon...)
return
}

View File

@@ -549,7 +549,7 @@ func GetDiskSpecV2(storages []*BaremetalStorage) api.DiskDriverSpec {
if len(driverStorages) == 0 {
continue
}
spec[driver] = getSpec(storages)
spec[driver] = getSpec(driverStorages)
}
return spec
}

View File

@@ -78,6 +78,14 @@ func (self *SAwsGuestDriver) IsNeedInjectPasswordByCloudInit(desc *cloudprovider
return true
}
func (self *SAwsGuestDriver) IsWindowsUserDataTypeNeedEncode() bool {
return true
}
func (self *SAwsGuestDriver) GetWindowsUserDataType() string {
return cloudprovider.CLOUD_EC2
}
func (self *SAwsGuestDriver) GetLinuxDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
// return fetchAwsUserName(desc)
if desc.OsType == "Windows" {

View File

@@ -298,6 +298,14 @@ func (self *SBaseGuestDriver) IsNeedInjectPasswordByCloudInit(desc *cloudprovide
return false
}
func (self *SBaseGuestDriver) GetWindowsUserDataType() string {
return cloudprovider.CLOUD_POWER_SHELL
}
func (self *SBaseGuestDriver) IsWindowsUserDataTypeNeedEncode() bool {
return false
}
func (self *SBaseGuestDriver) GetUserDataType() string {
return cloudprovider.CLOUD_CONFIG
}

View File

@@ -172,7 +172,7 @@ func (self *SESXiGuestDriver) GetJsonDescAtHost(ctx context.Context, userCred mc
if img.ImageType != cloudprovider.CachedImageTypeSystem {
return desc
}
sciSubQ := models.StoragecachedimageManager.Query("storagecache_id").Equals("cachedimage_id", templateId).SubQuery()
sciSubQ := models.StoragecachedimageManager.Query("storagecache_id").Equals("cachedimage_id", templateId).Equals("status", api.CACHED_IMAGE_STATUS_READY).SubQuery()
scQ := models.StoragecacheManager.Query().In("id", sciSubQ)
storageCaches := make([]models.SStoragecache, 0, 1)
err = db.FetchModelObjects(models.StoragecacheManager, scQ, &storageCaches)
@@ -346,3 +346,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

@@ -16,6 +16,7 @@ package guestdrivers
import (
"context"
"encoding/base64"
"fmt"
"math"
"strings"
@@ -346,7 +347,15 @@ func (self *SManagedVirtualizedGuestDriver) RequestDeployGuestOnHost(ctx context
desc.UserData = oUserData.UserDataBase64()
}
if strings.ToLower(desc.OsType) == strings.ToLower(osprofile.OS_TYPE_WINDOWS) {
desc.UserData = oUserData.UserDataPowerShell()
switch guest.GetDriver().GetWindowsUserDataType() {
case cloudprovider.CLOUD_EC2:
desc.UserData = oUserData.UserDataEc2()
default:
desc.UserData = oUserData.UserDataPowerShell()
}
if guest.GetDriver().IsWindowsUserDataTypeNeedEncode() {
desc.UserData = base64.StdEncoding.EncodeToString([]byte(desc.UserData))
}
}
}
@@ -462,20 +471,20 @@ func (self *SManagedVirtualizedGuestDriver) RemoteDeployGuestForCreate(ctx conte
return nil, err
}
ret, expect := 0, len(desc.DataDisks)+1
err = cloudprovider.RetryUntil(func() (bool, error) {
idisks, err := iVM.GetIDisks()
if err != nil {
log.Errorf("fail to find vm disks %s after create", err)
return false, err
return false, errors.Wrap(err, "iVM.GetIDisks")
}
if len(idisks) == len(desc.DataDisks)+1 {
ret = len(idisks)
if ret >= expect { // 有可能自定义镜像里面也有磁盘,会导致返回的磁盘多于创建时的磁盘
return true, nil
} else {
return false, nil
}
return false, nil
}, 10)
if err != nil {
return nil, errors.Wrap(err, "GuestDriver.RemoteDeployGuestForCreate.RetryUntil")
return nil, errors.Wrapf(err, "GuestDriver.RemoteDeployGuestForCreate.RetryUntil expect %d disks return %d disks", expect, ret)
}
guest.GetDriver().RemoteActionAfterGuestCreated(ctx, userCred, guest, host, iVM, &desc)
@@ -1033,7 +1042,7 @@ func (self *SManagedVirtualizedGuestDriver) RequestAssociateEip(ctx context.Cont
return nil, fmt.Errorf("ManagedVirtualizedGuestDriver.RequestAssociateEip fail to local associate EIP %s", err)
}
eip.SetStatus(userCred, api.EIP_STATUS_READY, "associate")
eip.SetStatus(userCred, api.EIP_STATUS_READY, api.EIP_STATUS_ASSOCIATE)
return nil, nil
})

View File

@@ -154,6 +154,10 @@ func (self *SZStackGuestDriver) GetUserDataType() string {
return cloudprovider.CLOUD_SHELL
}
func (self *SZStackGuestDriver) IsWindowsUserDataTypeNeedEncode() bool {
return true
}
func (self *SZStackGuestDriver) GetLinuxDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
userName := "root"
if desc.OsType == "Windows" {

View File

@@ -31,6 +31,7 @@ import (
"yunion.io/x/sqlchemy"
api "yunion.io/x/onecloud/pkg/apis/compute"
identity_apis "yunion.io/x/onecloud/pkg/apis/identity"
"yunion.io/x/onecloud/pkg/appsrv"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
@@ -535,7 +536,7 @@ func joinPath(ep, path string) string {
func (bucket *SBucket) getMoreDetails(out api.BucketDetails) api.BucketDetails {
out.CloudproviderInfo = bucket.getCloudProviderInfo()
s3gwUrl, _ := auth.GetServiceURL("s3gateway", options.Options.Region, "", "public")
s3gwUrl, _ := auth.GetServiceURL("s3gateway", options.Options.Region, "", identity_apis.EndpointInterfacePublic)
if len(s3gwUrl) > 0 {
accessUrls := make([]cloudprovider.SBucketAccessUrl, 0)
if bucket.AccessUrls != nil {
@@ -654,10 +655,10 @@ func (bucket *SBucket) GetDetailsObjects(
}
ret := jsonutils.NewDict()
ret.Add(retArray, "data")
ret.Add(jsonutils.NewString("key"), "marker_field")
ret.Add(jsonutils.NewString("DESC"), "marker_order")
if len(nextMarker) > 0 {
ret.Add(jsonutils.NewString(nextMarker), "next_marker")
ret.Add(jsonutils.NewString("key"), "marker_field")
ret.Add(jsonutils.NewString("DESC"), "marker_order")
}
return ret, nil
}

View File

@@ -22,6 +22,7 @@ import (
"net/url"
"strconv"
"strings"
"sync"
"time"
"yunion.io/x/jsonutils"
@@ -323,10 +324,7 @@ func (self *SCloudaccount) ValidateUpdateData(ctx context.Context, userCred mccl
if err := v.Validate(data); err != nil {
return nil, err
}
proxySetting := v.Model.(*proxy.SProxySetting)
if proxySetting != nil {
if proxySetting, ok := v.Model.(*proxy.SProxySetting); ok && proxySetting.Id != self.ProxySettingId {
// updated proxy setting, so do the check
proxyFunc := proxySetting.HttpTransportProxyFunc()
secret, _ := self.getPassword()
@@ -401,8 +399,8 @@ func (manager *SCloudaccountManager) ValidateCreateData(ctx context.Context, use
var proxyFunc httputils.TransportProxyFunc
{
if input.ProxySettingId == "" {
input.ProxySettingId = proxyapi.ProxySettingId_DIRECT
if input.ProxySetting == "" {
input.ProxySetting = proxyapi.ProxySettingId_DIRECT
}
var proxySetting *proxy.SProxySetting
proxySetting, input.ProxySettingResourceInput, err = proxy.ValidateProxySettingResourceInput(userCred, input.ProxySettingResourceInput)
@@ -641,13 +639,13 @@ func (self *SCloudaccount) StartSyncCloudProviderInfoTask(ctx context.Context, u
log.Errorf("CloudAccountSyncInfoTask newTask error %s", err)
return err
}
self.markStartSync(userCred)
self.markStartSync(userCred, syncRange)
db.OpsLog.LogEvent(self, db.ACT_SYNC_HOST_START, "", userCred)
task.ScheduleRun(nil)
return nil
}
func (self *SCloudaccount) markStartSync(userCred mcclient.TokenCredential) error {
func (self *SCloudaccount) markStartSync(userCred mcclient.TokenCredential, syncRange *SSyncRange) error {
_, err := db.Update(self, func() error {
self.SyncStatus = api.CLOUD_PROVIDER_SYNC_STATUS_QUEUED
return nil
@@ -659,7 +657,7 @@ func (self *SCloudaccount) markStartSync(userCred mcclient.TokenCredential) erro
providers := self.GetCloudproviders()
for i := range providers {
if providers[i].Enabled {
err := providers[i].markStartingSync(userCred)
err := providers[i].markStartingSync(userCred, syncRange)
if err != nil {
return errors.Wrap(err, "providers.markStartSync")
}
@@ -686,9 +684,9 @@ func (self *SCloudaccount) MarkEndSyncWithLock(ctx context.Context, userCred mcc
lockman.LockObject(ctx, self)
defer lockman.ReleaseObject(ctx, self)
if self.SyncStatus == api.CLOUD_PROVIDER_SYNC_STATUS_IDLE {
return nil
}
// if self.SyncStatus == api.CLOUD_PROVIDER_SYNC_STATUS_IDLE {
// return nil
// }
providers := self.GetCloudproviders()
for i := range providers {
@@ -837,7 +835,7 @@ func (self *SCloudaccount) importSubAccount(ctx context.Context, userCred mcclie
ownerId = userCred
} else {
// find default project of domain
t, err := db.TenantCacheManager.FindFirstProjectOfDomain(ownerId.GetProjectDomainId())
t, err := db.TenantCacheManager.FindFirstProjectOfDomain(ctx, ownerId.GetProjectDomainId())
if err != nil {
log.Errorf("cannot find a valid porject for domain %s", ownerId.GetProjectDomainId())
return nil, err
@@ -918,13 +916,13 @@ func (self *SCloudaccount) GetHostCount() (int, error) {
func (self *SCloudaccount) GetVpcCount() (int, error) {
subq := CloudproviderManager.Query("id").Equals("cloudaccount_id", self.Id).SubQuery()
q := VpcManager.Query().In("manager_id", subq)
q := VpcManager.Query().In("manager_id", subq).IsFalse("is_emulated")
return q.CountWithError()
}
func (self *SCloudaccount) GetStorageCount() (int, error) {
subq := CloudproviderManager.Query("id").Equals("cloudaccount_id", self.Id).SubQuery()
q := StorageManager.Query().In("manager_id", subq)
q := StorageManager.Query().In("manager_id", subq).IsFalse("is_emulated")
return q.CountWithError()
}
@@ -1498,6 +1496,18 @@ func (manager *SCloudaccountManager) initAllRecords() {
}
}
func (self *SCloudaccount) CanSync() bool {
if self.SyncStatus == api.CLOUD_PROVIDER_SYNC_STATUS_QUEUED || self.SyncStatus == api.CLOUD_PROVIDER_SYNC_STATUS_SYNCING || self.getSyncStatus2() == api.CLOUD_PROVIDER_SYNC_STATUS_SYNCING {
if self.LastSync.IsZero() || time.Now().Sub(self.LastSync) > 1800*time.Second {
return true
} else {
return false
}
} else {
return true
}
}
func (manager *SCloudaccountManager) AutoSyncCloudaccountTask(ctx context.Context, userCred mcclient.TokenCredential, isStart bool) {
if isStart && !options.Options.IsSlaveNode {
// mark all the records to be idle
@@ -1533,7 +1543,7 @@ func (account *SCloudaccount) probeAccountStatus(ctx context.Context, userCred m
manager, err := account.getProviderInternal()
if err != nil {
log.Errorf("account.GetProvider failed: %s", err)
return nil, err
return nil, errors.Wrap(err, "account.getProviderInternal")
}
balance, status, err := manager.GetBalance()
if err != nil {
@@ -1551,7 +1561,7 @@ func (account *SCloudaccount) probeAccountStatus(ctx context.Context, userCred m
sysInfo, err := manager.GetSysInfo()
if err != nil {
log.Errorf("manager.GetSysInfo fail %s", err)
return nil, err
return nil, errors.Wrap(err, "manager.GetSysInfo")
}
factory := manager.GetFactory()
diff, err := db.Update(account, func() error {
@@ -1604,7 +1614,7 @@ func (account *SCloudaccount) syncAccountStatus(ctx context.Context, userCred mc
if err != nil {
account.markAllProvidersDicconnected(ctx, userCred)
account.markAccountDiscconected(ctx, userCred)
return err
return errors.Wrap(err, "account.probeAccountStatus")
}
account.markAccountConnected(ctx, userCred)
providers := account.importAllSubaccounts(ctx, userCred, subaccounts)
@@ -1613,7 +1623,7 @@ func (account *SCloudaccount) syncAccountStatus(ctx context.Context, userCred mc
_, err := providers[i].prepareCloudproviderRegions(ctx, userCred)
if err != nil {
log.Errorf("syncCloudproviderRegion fail %s", err)
return err
return errors.Wrap(err, "providers[i].prepareCloudproviderRegions")
}
}
}
@@ -1632,13 +1642,39 @@ func (account *SCloudaccount) markAutoSync(userCred mcclient.TokenCredential) er
return nil
}
var (
cloudaccountPendingSyncs = map[string]struct{}{}
cloudaccountPendingSyncsMutex = &sync.Mutex{}
)
func (account *SCloudaccount) SubmitSyncAccountTask(ctx context.Context, userCred mcclient.TokenCredential, waitChan chan error, autoSync bool) {
cloudaccountPendingSyncsMutex.Lock()
defer cloudaccountPendingSyncsMutex.Unlock()
if _, ok := cloudaccountPendingSyncs[account.Id]; ok {
if waitChan != nil {
go func() {
// an active cloudaccount sync task is running, return with conflict error
log.Errorf("an active cloudaccount sync task is running, early return with conflict error")
waitChan <- errors.Wrap(httperrors.ErrConflict, "cloudaccountPendingSyncs")
}()
}
return
}
cloudaccountPendingSyncs[account.Id] = struct{}{}
RunSyncCloudAccountTask(func() {
func() {
cloudaccountPendingSyncsMutex.Lock()
defer cloudaccountPendingSyncsMutex.Unlock()
delete(cloudaccountPendingSyncs, account.Id)
}()
log.Debugf("syncAccountStatus %s %s", account.Id, account.Name)
err := account.syncAccountStatus(ctx, userCred)
if waitChan != nil {
if err != nil {
account.markEndSync(userCred)
err = errors.Wrap(err, "account.syncAccountStatus")
}
waitChan <- err
} else {
@@ -1648,7 +1684,8 @@ func (account *SCloudaccount) SubmitSyncAccountTask(ctx context.Context, userCre
account.markAutoSync(userCred)
providers := account.GetEnabledCloudproviders()
for i := range providers {
providers[i].syncCloudproviderRegions(ctx, userCred, syncRange, nil, autoSync)
provider := &providers[i]
provider.syncCloudproviderRegions(ctx, userCred, syncRange, nil, autoSync)
syncCnt += 1
}
}

View File

@@ -26,12 +26,14 @@ import (
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/compare"
"yunion.io/x/pkg/util/timeutils"
"yunion.io/x/pkg/utils"
"yunion.io/x/sqlchemy"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/nopanic"
)
type SCloudproviderregionManager struct {
@@ -220,17 +222,23 @@ func (manager *SCloudproviderregionManager) FetchByIdsOrCreate(providerId string
return cpr
}
func (self *SCloudproviderregion) markStartingSync(userCred mcclient.TokenCredential) error {
func (self *SCloudproviderregion) markStartingSync(userCred mcclient.TokenCredential, syncRange *SSyncRange) error {
if !self.Enabled {
return fmt.Errorf("Cloudprovider(%s)region(%s) disabled", self.CloudproviderId, self.CloudregionId)
}
_, err := db.Update(self, func() error {
self.SyncStatus = api.CLOUD_PROVIDER_SYNC_STATUS_QUEUING
return nil
})
if err != nil {
log.Errorf("Failed to markStartingSync error: %v", err)
return err
regionIds := []string{}
if syncRange != nil {
regionIds, _ = syncRange.GetRegionIds()
}
if syncRange == nil || len(regionIds) == 0 || utils.IsInStringArray(self.CloudregionId, regionIds) {
_, err := db.Update(self, func() error {
self.SyncStatus = api.CLOUD_PROVIDER_SYNC_STATUS_QUEUING
return nil
})
if err != nil {
log.Errorf("Failed to markStartingSync error: %v", err)
return err
}
}
return nil
}
@@ -380,10 +388,12 @@ func (self *SCloudproviderregion) getSyncTaskKey() string {
func (self *SCloudproviderregion) submitSyncTask(userCred mcclient.TokenCredential, syncRange SSyncRange, waitChan chan bool) {
self.markStartSync(userCred)
RunSyncCloudproviderRegionTask(self.getSyncTaskKey(), func() {
err := self.DoSync(context.Background(), userCred, syncRange)
if err != nil {
log.Errorf("DoSync faild %v", err)
}
nopanic.Run(func() {
err := self.DoSync(context.Background(), userCred, syncRange)
if err != nil {
log.Errorf("DoSync faild %v", err)
}
})
if waitChan != nil {
waitChan <- true
}

View File

@@ -243,15 +243,15 @@ func (self *SCloudprovider) GetGuestCount() (int, error) {
}
func (self *SCloudprovider) GetHostCount() (int, error) {
return HostManager.Query().Equals("manager_id", self.Id).CountWithError()
return HostManager.Query().Equals("manager_id", self.Id).IsFalse("is_emulated").CountWithError()
}
func (self *SCloudprovider) getVpcCount() (int, error) {
return VpcManager.Query().Equals("manager_id", self.Id).CountWithError()
return VpcManager.Query().Equals("manager_id", self.Id).IsFalse("is_emulated").CountWithError()
}
func (self *SCloudprovider) getStorageCount() (int, error) {
return StorageManager.Query().Equals("manager_id", self.Id).CountWithError()
return StorageManager.Query().Equals("manager_id", self.Id).IsFalse("is_emulated").CountWithError()
}
func (self *SCloudprovider) getStoragecacheCount() (int, error) {
@@ -302,56 +302,60 @@ func (self *SCloudprovider) getPassword() (string, error) {
return utils.DescryptAESBase64(self.Id, self.Secret)
}
func (self *SCloudprovider) syncProject(ctx context.Context, userCred mcclient.TokenCredential) error {
if len(self.ProjectId) > 0 {
_, err := db.TenantCacheManager.FetchTenantById(ctx, self.ProjectId)
if err != nil && err != sql.ErrNoRows {
log.Errorf("fetch existing tenant by id fail %s", err)
return errors.Wrap(err, "db.TenantCacheManager.FetchTenantById")
} else if err == nil {
return nil // find the project, skip sync
func getTenant(ctx context.Context, projectId string, name string) (*db.STenant, error) {
if len(projectId) > 0 {
tenant, err := db.TenantCacheManager.FetchTenantById(ctx, projectId)
if err != nil {
return nil, errors.Wrap(err, "TenantCacheManager.FetchTenantById")
}
return tenant, nil
}
if len(self.Name) == 0 {
log.Errorf("syncProject: provider name is empty???")
return errors.Error("cannot syncProject for empty name")
if len(name) == 0 {
return nil, errors.Error("cannot syncProject for empty name")
}
return db.TenantCacheManager.FetchTenantByName(ctx, name)
}
tenant, err := db.TenantCacheManager.FetchTenantByIdOrName(ctx, self.Name)
if err != nil && err != sql.ErrNoRows {
log.Errorf("fetchTenantByIdorName error %s: %s", self.Name, err)
return errors.Wrap(err, "db.TenantCacheManager.FetchTenantByIdOrName")
func createTenant(ctx context.Context, name, domainId, desc string) (string, string, error) {
s := auth.GetAdminSession(ctx, options.Options.Region, "")
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(name), "generate_name")
params.Add(jsonutils.NewString(domainId), "domain_id")
params.Add(jsonutils.NewString(desc), "description")
resp, err := modules.Projects.Create(s, params)
if err != nil {
return "", "", errors.Wrap(err, "Projects.Create")
}
projectId, err := resp.GetString("id")
if err != nil {
return "", "", errors.Wrap(err, "resp.GetString")
}
return domainId, projectId, nil
}
func getOrCreateTenant(ctx context.Context, name, domainId, projectId, desc string) (string, string, error) {
tenant, err := getTenant(ctx, projectId, name)
if err != nil && errors.Cause(err) != sql.ErrNoRows {
return "", "", err
}
if err == sql.ErrNoRows || tenant.DomainId != domainId {
return createTenant(ctx, name, domainId, desc)
}
return tenant.DomainId, tenant.Id, nil
}
func (self *SCloudprovider) syncProject(ctx context.Context, userCred mcclient.TokenCredential) error {
account := self.GetCloudaccount()
if account == nil {
return errors.Error("no valid cloudaccount???")
}
var projectId, domainId string
if err == sql.ErrNoRows || tenant.DomainId != account.DomainId { // create one
s := auth.GetAdminSession(ctx, options.Options.Region, "")
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(self.Name), "generate_name")
domainId = account.DomainId
params.Add(jsonutils.NewString(domainId), "domain_id")
params.Add(jsonutils.NewString(fmt.Sprintf("auto create from cloud provider %s (%s)", self.Name, self.Id)), "description")
project, err := modules.Projects.Create(s, params)
if err != nil {
log.Errorf("create project fail %s", err)
return err
}
projectId, err = project.GetString("id")
if err != nil {
return err
}
} else {
domainId = tenant.DomainId
projectId = tenant.Id
desc := fmt.Sprintf("auto create from cloud provider %s (%s)", self.Name, self.Id)
domainId, projectId, err := getOrCreateTenant(ctx, self.Name, account.DomainId, self.ProjectId, desc)
if err != nil {
return errors.Wrap(err, "getOrCreateTenant")
}
return self.saveProject(userCred, domainId, projectId)
@@ -384,6 +388,44 @@ type SSyncRange struct {
Host []string
}
func (sr *SSyncRange) GetRegionIds() ([]string, error) {
regionIds := []string{}
if len(sr.Host) == 0 && len(sr.Zone) == 0 && len(sr.Region) == 0 {
return regionIds, nil
}
hostQ := HostManager.Query().SubQuery()
hosts := hostQ.Query().Filter(sqlchemy.OR(
sqlchemy.In(hostQ.Field("id"), sr.Host),
sqlchemy.In(hostQ.Field("name"), sr.Host),
)).SubQuery()
zoneQ := ZoneManager.Query().SubQuery()
zones := zoneQ.Query().Filter(sqlchemy.OR(
sqlchemy.In(zoneQ.Field("id"), sr.Zone),
sqlchemy.In(zoneQ.Field("name"), sr.Zone),
sqlchemy.In(zoneQ.Field("id"), hosts.Query(hosts.Field("zone_id")).SubQuery()),
)).SubQuery()
regionQ := CloudregionManager.Query().SubQuery()
q := regionQ.Query(regionQ.Field("id")).Filter(sqlchemy.OR(
sqlchemy.In(regionQ.Field("id"), sr.Region),
sqlchemy.In(regionQ.Field("name"), sr.Region),
sqlchemy.In(regionQ.Field("id"), zones.Query(zones.Field("cloudregion_id")).SubQuery()),
))
rows, err := q.Rows()
if err != nil {
return nil, errors.Wrap(err, "q.Rows")
}
defer rows.Close()
for rows.Next() {
var regionId string
err = rows.Scan(&regionId)
if err != nil {
return nil, errors.Wrap(err, "rows.Scan")
}
regionIds = append(regionIds, regionId)
}
return regionIds, nil
}
func (sr *SSyncRange) NeedSyncInfo() bool {
if sr.FullSync {
return true
@@ -539,7 +581,7 @@ func (self *SCloudprovider) StartSyncCloudProviderInfoTask(ctx context.Context,
cloudaccount.markAutoSync(userCred)
cloudaccount.MarkSyncing(userCred)
}
self.markStartSync(userCred)
self.markStartSync(userCred, syncRange)
db.OpsLog.LogEvent(self, db.ACT_SYNC_HOST_START, "", userCred)
task.ScheduleRun(nil)
return nil
@@ -606,7 +648,7 @@ func (self *SCloudprovider) PerformChangeProject(ctx context.Context, userCred m
return nil, self.StartSyncCloudProviderInfoTask(ctx, userCred, &SSyncRange{FullSync: true, DeepSync: true}, "")
}
func (self *SCloudprovider) markStartingSync(userCred mcclient.TokenCredential) error {
func (self *SCloudprovider) markStartingSync(userCred mcclient.TokenCredential, syncRange *SSyncRange) error {
_, err := db.Update(self, func() error {
self.SyncStatus = api.CLOUD_PROVIDER_SYNC_STATUS_QUEUING
return nil
@@ -618,7 +660,7 @@ func (self *SCloudprovider) markStartingSync(userCred mcclient.TokenCredential)
cprs := self.GetCloudproviderRegions()
for i := range cprs {
if cprs[i].Enabled {
err := cprs[i].markStartingSync(userCred)
err := cprs[i].markStartingSync(userCred, syncRange)
if err != nil {
return errors.Wrap(err, "cprs[i].markStartingSync")
}
@@ -627,7 +669,7 @@ func (self *SCloudprovider) markStartingSync(userCred mcclient.TokenCredential)
return nil
}
func (self *SCloudprovider) markStartSync(userCred mcclient.TokenCredential) error {
func (self *SCloudprovider) markStartSync(userCred mcclient.TokenCredential, syncRange *SSyncRange) error {
_, err := db.Update(self, func() error {
self.SyncStatus = api.CLOUD_PROVIDER_SYNC_STATUS_QUEUED
return nil
@@ -639,7 +681,7 @@ func (self *SCloudprovider) markStartSync(userCred mcclient.TokenCredential) err
cprs := self.GetCloudproviderRegions()
for i := range cprs {
if cprs[i].Enabled {
err := cprs[i].markStartingSync(userCred)
err := cprs[i].markStartingSync(userCred, syncRange)
if err != nil {
return errors.Wrap(err, "cprs[i].markStartingSync")
}
@@ -1136,9 +1178,10 @@ func (provider *SCloudprovider) GetCloudproviderRegions() []SCloudproviderregion
func (provider *SCloudprovider) syncCloudproviderRegions(ctx context.Context, userCred mcclient.TokenCredential, syncRange SSyncRange, wg *sync.WaitGroup, autoSync bool) {
provider.markSyncing(userCred)
cprs := provider.GetCloudproviderRegions()
regionIds, _ := syncRange.GetRegionIds()
syncCnt := 0
for i := range cprs {
if cprs[i].Enabled && cprs[i].CanSync() && (!autoSync || cprs[i].needAutoSync()) {
if cprs[i].Enabled && cprs[i].CanSync() && (!autoSync || cprs[i].needAutoSync()) && (len(regionIds) == 0 || utils.IsInStringArray(cprs[i].CloudregionId, regionIds)) {
syncCnt += 1
var waitChan chan bool = nil
if wg != nil {
@@ -1237,6 +1280,14 @@ func (self *SCloudprovider) StartCloudproviderDeleteTask(ctx context.Context, us
return nil
}
func (self *SCloudprovider) GetRegionDriver() (IRegionDriver, error) {
driver := GetRegionDriver(self.Provider)
if driver == nil {
return nil, fmt.Errorf("failed to found region driver for %s", self.Provider)
}
return driver, nil
}
func (self *SCloudprovider) ClearSchedDescCache() error {
hosts := make([]SHost, 0)
q := HostManager.Query().Equals("manager_id", self.Id)

View File

@@ -406,6 +406,9 @@ func (self *SCloudregion) syncWithCloudRegion(ctx context.Context, userCred mccl
}
diff, err := db.UpdateWithLock(ctx, self, func() error {
if !utils.IsInStringArray(self.Provider, api.PRIVATE_CLOUD_PROVIDERS) {
self.Name = cloudRegion.GetName()
}
self.Status = cloudRegion.GetStatus()
self.SGeographicInfo = cloudRegion.GetGeographicInfo()
self.Provider = cloudRegion.GetProvider()

View File

@@ -60,7 +60,8 @@ type SDBInstanceAccount struct {
db.SExternalizedResourceBase
// 数据库密码
Secret string `width:"256" charset:"ascii" nullable:"false" list:"domain" create:"optional"`
Secret string `width:"256" charset:"ascii" nullable:"false" list:"user" create:"optional"`
// RDS实例Id
DBInstanceId string `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
}
@@ -100,7 +101,7 @@ func (manager *SDBInstanceAccountManager) FetchOwnerId(ctx context.Context, data
}
return instance.(*SDBInstance).GetOwnerId(), nil
}
return nil, nil
return db.FetchProjectInfo(ctx, data)
}
func (manager *SDBInstanceAccountManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery {

View File

@@ -100,7 +100,7 @@ func (manager *SDBInstanceDatabaseManager) FetchOwnerId(ctx context.Context, dat
}
return instance.(*SDBInstance).GetOwnerId(), nil
}
return nil, nil
return db.FetchProjectInfo(ctx, data)
}
func (manager *SDBInstanceDatabaseManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery {

View File

@@ -59,7 +59,7 @@ type SDBInstanceSku struct {
SCloudregionResourceBase
Provider string `width:"32" charset:"ascii" nullable:"false" list:"user" create:"admin_required" update:"admin"`
StorageType string `list:"user" create:"optional"`
StorageType string `width:"32" index:"true" list:"user" create:"optional"`
DiskSizeStep int `list:"user" default:"1" create:"optional"` //步长
MaxDiskSizeGb int `list:"user" create:"optional"`
MinDiskSizeGb int `list:"user" create:"optional"`
@@ -72,9 +72,9 @@ type SDBInstanceSku struct {
VcpuCount int `nullable:"false" default:"1" list:"user" create:"optional"`
VmemSizeMb int `nullable:"false" list:"user" create:"required"`
Category string `nullable:"false" list:"user" create:"optional"`
Engine string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"required"`
EngineVersion string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"required"`
Category string `width:"32" index:"true" nullable:"false" list:"user" create:"optional"`
Engine string `width:"16" index:"true" charset:"ascii" nullable:"false" list:"user" create:"required"`
EngineVersion string `width:"16" index:"true" charset:"ascii" nullable:"false" list:"user" create:"required"`
Zone1 string `width:"128" charset:"ascii" nullable:"false" list:"user" create:"admin_optional" update:"admin"`
Zone2 string `width:"128" charset:"ascii" nullable:"false" list:"user" create:"admin_optional" update:"admin"`

View File

@@ -123,9 +123,6 @@ type SDBInstance struct {
Zone2 string `width:"36" charset:"ascii" nullable:"false" create:"optional" list:"user"`
// 可用区3
Zone3 string `width:"36" charset:"ascii" nullable:"false" create:"optional" list:"user"`
// 可用区Id(对应公有云的可用区Id)
ZoneId string `width:"36" charset:"ascii" nullable:"false" create:"optional"`
}
func (manager *SDBInstanceManager) GetContextManagers() [][]db.IModelManager {
@@ -383,14 +380,6 @@ func (self *SDBInstance) GetVpc() (*SVpc, error) {
return vpc.(*SVpc), nil
}
func (self *SDBInstance) GetZone() (*SZone, error) {
zone, err := ZoneManager.FetchById(self.ZoneId)
if err != nil {
return nil, err
}
return zone.(*SZone), nil
}
func (self *SDBInstance) GetNetwork() (*SNetwork, error) {
dbnet := DBInstanceNetworkManager.Query().SubQuery()
q := NetworkManager.Query()
@@ -1165,9 +1154,12 @@ func (self *SDBInstance) syncRemoveCloudDBInstance(ctx context.Context, userCred
lockman.LockObject(ctx, self)
defer lockman.ReleaseObject(ctx, self)
self.DeletePreventionOff(self, userCred)
err := self.ValidateDeleteCondition(ctx)
if err != nil { // cannot delete
return self.SetStatus(userCred, api.VPC_STATUS_UNKNOWN, "sync to delete")
self.SetStatus(userCred, api.VPC_STATUS_UNKNOWN, "sync to delete")
return errors.Wrap(err, "ValidateDeleteCondition")
}
return self.RealDelete(ctx, userCred)
}
@@ -1182,7 +1174,7 @@ func (self *SDBInstance) ValidateDeleteCondition(ctx context.Context) error {
func (self *SDBInstance) GetDBInstanceSkuQuery() *sqlchemy.SQuery {
q := DBInstanceSkuManager.Query().Equals("storage_type", self.StorageType).Equals("category", self.Category).
Equals("cloudregion_id", self.CloudregionId).Equals("engine", self.Engine).Equals("engine_version", self.EngineVersion)
for k, v := range map[string]string{"zone1": self.Zone1, "zone2": self.Zone2, "zone3": self.Zone3, "zone_id": self.ZoneId} {
for k, v := range map[string]string{"zone1": self.Zone1, "zone2": self.Zone2, "zone3": self.Zone3} {
if len(v) > 0 {
q = q.Equals(k, v)
}
@@ -1285,6 +1277,30 @@ func (self *SDBInstance) SetZoneInfo(ctx context.Context, userCred mcclient.Toke
return err
}
func (self *SDBInstance) SetZoneIds(extInstance cloudprovider.ICloudDBInstance) {
zone1 := extInstance.GetZone1Id()
if len(zone1) > 0 {
zone, _ := db.FetchByExternalId(ZoneManager, zone1)
if zone != nil {
self.Zone1 = zone.GetId()
}
}
zone2 := extInstance.GetZone2Id()
if len(zone2) > 0 {
zone, _ := db.FetchByExternalId(ZoneManager, zone2)
if zone != nil {
self.Zone2 = zone.GetId()
}
}
zone3 := extInstance.GetZone3Id()
if len(zone3) > 0 {
zone, _ := db.FetchByExternalId(ZoneManager, zone3)
if zone != nil {
self.Zone3 = zone.GetId()
}
}
}
func (self *SDBInstance) SyncWithCloudDBInstance(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, extInstance cloudprovider.ICloudDBInstance) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
self.Engine = extInstance.GetEngine()
@@ -1295,22 +1311,22 @@ func (self *SDBInstance) SyncWithCloudDBInstance(ctx context.Context, userCred m
self.DiskSizeGB = extInstance.GetDiskSizeGB()
self.StorageType = extInstance.GetStorageType()
self.Status = extInstance.GetStatus()
self.Port = extInstance.GetPort()
self.ConnectionStr = extInstance.GetConnectionStr()
self.InternalConnectionStr = extInstance.GetInternalConnectionStr()
self.MaintainTime = extInstance.GetMaintainTime()
self.ZoneId = extInstance.GetIZoneId()
err := self.setZoneInfo()
if err != nil {
log.Errorf("failed to set zone info for dbinstance %s(%s) error: %v", self.Name, self.Id, err)
}
self.SetZoneIds(extInstance)
if createdAt := extInstance.GetCreatedAt(); !createdAt.IsZero() {
self.CreatedAt = createdAt
}
if expiredAt := extInstance.GetExpiredAt(); !expiredAt.IsZero() {
self.ExpiredAt = expiredAt
}
factory, err := provider.GetProviderFactory()
if err != nil {
return errors.Wrap(err, "SyncWithCloudDBInstance.GetProviderFactory")
@@ -1368,11 +1384,7 @@ func (manager *SDBInstanceManager) newFromCloudDBInstance(ctx context.Context, u
instance.InternalConnectionStr = extInstance.GetInternalConnectionStr()
instance.MaintainTime = extInstance.GetMaintainTime()
instance.ZoneId = extInstance.GetIZoneId()
err = instance.setZoneInfo()
if err != nil {
log.Errorf("failed to set zone info for dbinstance %s error: %v", instance.ExternalId, err)
}
instance.SetZoneIds(extInstance)
if secgroupId := extInstance.GetSecurityGroupId(); len(secgroupId) > 0 {
q := SecurityGroupCacheManager.Query().Equals("manager_id", provider.Id).Equals("external_id", secgroupId)

View File

@@ -416,7 +416,9 @@ func (manager *SDiskManager) ValidateCreateData(ctx context.Context, userCred mc
input.Hypervisor,
)
} else {
diskConfig.Backend = api.STORAGE_LOCAL
if len(diskConfig.Backend) == 0 {
diskConfig.Backend = api.STORAGE_LOCAL
}
serverInput, err := ValidateScheduleCreateData(ctx, userCred, input.ToServerCreateInput(), input.Hypervisor)
if err != nil {
return nil, err
@@ -830,6 +832,9 @@ func (disk *SDisk) doResize(ctx context.Context, userCred mcclient.TokenCredenti
}
addDisk := sizeMb - disk.DiskSize
storage := disk.GetStorage()
if storage == nil {
return httperrors.NewInternalServerError("disk has no valid storage")
}
if host := storage.GetMasterHost(); host != nil {
if err := host.GetHostDriver().ValidateDiskSize(storage, sizeMb>>10); err != nil {
return httperrors.NewInputParameterError(err.Error())
@@ -986,6 +991,10 @@ func (self *SDisk) ValidatePurgeCondition(ctx context.Context) error {
func (self *SDisk) validateDeleteCondition(ctx context.Context, isPurge bool) error {
if !isPurge {
storage := self.GetStorage()
if storage == nil {
// storage is empty, a dirty data, allow delete
return nil
}
host := storage.GetMasterHost()
if host == nil {
return httperrors.NewBadRequestError("storage of disk no valid host")
@@ -1098,6 +1107,9 @@ func (self *SDisk) GetPathAtHost(host *SHost) string {
func (self *SDisk) GetFetchUrl() string {
storage := self.GetStorage()
if storage == nil {
return ""
}
host := storage.GetMasterHost()
return fmt.Sprintf("%s/disks/%s", host.GetFetchUrl(true), self.Id)
}
@@ -1126,7 +1138,10 @@ func (manager *SDiskManager) syncCloudDisk(ctx context.Context, userCred mcclien
diskObj, err := db.FetchByExternalId(manager, vdisk.GetGlobalId())
if err != nil {
if err == sql.ErrNoRows {
vstorage, _ := vdisk.GetIStorage()
vstorage, err := vdisk.GetIStorage()
if err != nil {
return nil, errors.Wrapf(err, "unable to GetIStorage of vdisk %q", vdisk.GetName())
}
storageObj, err := db.FetchByExternalId(StorageManager, vstorage.GetGlobalId())
if err != nil {
@@ -1323,7 +1338,6 @@ func (self *SDisk) syncWithCloudDisk(ctx context.Context, userCred mcclient.Toke
}
extDisk.Refresh()
storage := self.GetStorage()
diff, err := db.UpdateWithLock(ctx, self, func() error {
// self.Name = extDisk.GetName()
self.Status = extDisk.GetStatus()
@@ -1350,8 +1364,12 @@ func (self *SDisk) syncWithCloudDisk(ctx context.Context, userCred mcclient.Toke
self.IsEmulated = extDisk.IsEmulated()
if provider.GetFactory().IsSupportPrepaidResources() && !recycle {
self.BillingType = extDisk.GetBillingType()
self.ExpiredAt = extDisk.GetExpiredAt()
if billintType := extDisk.GetBillingType(); len(billintType) > 0 {
self.BillingType = extDisk.GetBillingType()
}
if expiredAt := extDisk.GetExpiredAt(); !expiredAt.IsZero() {
self.ExpiredAt = extDisk.GetExpiredAt()
}
}
if createdAt := extDisk.GetCreatedAt(); !createdAt.IsZero() {
@@ -1370,6 +1388,10 @@ func (self *SDisk) syncWithCloudDisk(ctx context.Context, userCred mcclient.Toke
if err != nil {
return errors.Wrapf(err, "Get snapshot policies of ICloudDisk %s.", extDisk.GetId())
}
storage := self.GetStorage()
if storage == nil {
return fmt.Errorf("no valid storage")
}
err = SnapshotPolicyDiskManager.SyncByDisk(ctx, userCred, snapshotpolicies, syncOwnerId, self, storage)
if err != nil {
return err
@@ -1527,7 +1549,7 @@ func parseDiskInfo(ctx context.Context, userCred mcclient.TokenCredential, info
// diskConfig.SizeMb = options.Options.DefaultDiskSize // MB
// else
if len(info.ImageId) == 0 && info.SizeMb == 0 {
return nil, httperrors.NewInputParameterError("Diskinfo not contains either imageID or size")
return nil, httperrors.NewInputParameterError("Diskinfo index %d: both imageID and size are absent", info.Index)
}
return info, nil
}
@@ -1905,6 +1927,9 @@ func (self *SDisk) SwitchToBackup(userCred mcclient.TokenCredential) error {
func (self *SDisk) ClearHostSchedCache() error {
storage := self.GetStorage()
if storage == nil {
return fmt.Errorf("no valid storage")
}
hosts := storage.GetAllAttachingHosts()
if hosts == nil {
return fmt.Errorf("get attaching host error")
@@ -2064,7 +2089,11 @@ func (disk *SDisk) validateDiskAutoCreateSnapshot() error {
if len(guests) == 0 {
return fmt.Errorf("Disks %s not attach guest, can't create snapshot", disk.GetName())
}
if len(guests) == 1 && utils.IsInStringArray(disk.GetStorage().StorageType, api.FIEL_STORAGE) {
storage := disk.GetStorage()
if storage == nil {
return fmt.Errorf("no valid storage")
}
if len(guests) == 1 && utils.IsInStringArray(storage.StorageType, api.FIEL_STORAGE) {
if !utils.IsInStringArray(guests[0].Status, []string{api.VM_RUNNING, api.VM_READY}) {
return fmt.Errorf("Guest(%s) in status(%s) cannot do disk snapshot", guests[0].Id, guests[0].Status)
}
@@ -2245,6 +2274,9 @@ func (self *SDisk) GetDynamicConditionInput() *jsonutils.JSONDict {
func (self *SDisk) IsNeedWaitSnapshotsDeleted() (bool, error) {
storage := self.GetStorage()
if storage == nil {
return false, fmt.Errorf("no valid storage")
}
if storage.StorageType == api.STORAGE_RBD {
scnt, err := self.GetSnapshotCount()
if err != nil {
@@ -2311,7 +2343,12 @@ func (self *SDisk) syncSnapshots(ctx context.Context, userCred mcclient.TokenCre
}
provider := self.GetCloudprovider()
syncOwnerId := provider.GetOwnerId()
region := self.GetStorage().GetRegion()
storage := self.GetStorage()
if storage == nil {
syncResult.Error(fmt.Errorf("no valid storage"))
return syncResult
}
region := storage.GetRegion()
extSnapshots, err := extDisk.GetISnapshots()
if err != nil {

View File

@@ -37,6 +37,8 @@ type SDnsRecordManager struct {
db.SAdminSharableVirtualResourceBaseManager
}
var _ db.IAdminSharableVirtualModelManager = DnsRecordManager
var DnsRecordManager *SDnsRecordManager
func init() {
@@ -276,35 +278,38 @@ func (man *SDnsRecordManager) checkRecordValue(typ, val string) error {
func (man *SDnsRecordManager) validateModelData(
ctx context.Context,
userCred mcclient.TokenCredential,
ownerId mcclient.IIdentityProvider,
query jsonutils.JSONObject,
data *jsonutils.JSONDict,
) (*jsonutils.JSONDict, error) {
records, err := man.ParseInputInfo(data)
isCreate bool,
) (records []string, err error) {
data.Remove("records")
records, err = man.ParseInputInfo(data)
if err != nil {
return nil, err
return
}
if len(records) == 0 {
return nil, httperrors.NewInputParameterError("Empty record")
if isCreate {
err = httperrors.NewInputParameterError("Empty record")
return
}
return
}
recType := man.getRecordsType(records)
name, err := data.GetString("name")
if err != nil {
return nil, err
return
}
err = man.checkRecordName(recType, name)
if err != nil {
return nil, err
return
}
if data.Contains("ttl") {
jo, err := data.Get("ttl")
var (
ttl int64
)
ttl, err = data.Int("ttl")
if err != nil {
return nil, err
}
ttl, err := jo.Int()
if err != nil {
return nil, httperrors.NewInputParameterError("invalid ttl: %s", err)
err = httperrors.NewInputParameterError("invalid ttl: %s", err)
return
}
if ttl == 0 {
// - Create: use the database default
@@ -312,10 +317,11 @@ func (man *SDnsRecordManager) validateModelData(
data.Remove("ttl")
} else if ttl < 0 || ttl > 0x7fffffff {
// positive values of a signed 32 bit number.
return nil, httperrors.NewInputParameterError("invalid ttl: %d", ttl)
err = httperrors.NewInputParameterError("invalid ttl: %d", ttl)
return
}
}
return data, err
return records, nil
}
func (man *SDnsRecordManager) ValidateCreateData(
@@ -325,7 +331,7 @@ func (man *SDnsRecordManager) ValidateCreateData(
query jsonutils.JSONObject,
data *jsonutils.JSONDict,
) (*jsonutils.JSONDict, error) {
data, err := man.validateModelData(ctx, userCred, ownerId, query, data)
_, err := man.validateModelData(ctx, data, true)
if err != nil {
return nil, err
}
@@ -402,15 +408,11 @@ func (rec *SDnsRecord) GetInfo() []string {
func (rec *SDnsRecord) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
data.UpdateDefault(jsonutils.Marshal(rec))
data, err := DnsRecordManager.validateModelData(ctx, userCred, rec.GetOwnerId(), query, data)
records, err := DnsRecordManager.validateModelData(ctx, data, false)
if err != nil {
return nil, err
}
{
records, err := DnsRecordManager.ParseInputInfo(data)
if err != nil {
return nil, err
}
if len(records) > 0 {
data.Set("records", jsonutils.NewString(strings.Join(records, DNS_RECORDS_SEPARATOR)))
}
return rec.SAdminSharableVirtualResourceBase.ValidateUpdateData(ctx, userCred, query, data)

View File

@@ -116,7 +116,7 @@ func elasticcacheSubResourceFetchOwnerId(ctx context.Context, data jsonutils.JSO
return ec.(*SElasticcache).GetOwnerId(), nil
}
return nil, nil
return db.FetchProjectInfo(ctx, data)
}
// elastic cache 子资源获取owner query
@@ -325,9 +325,12 @@ func (self *SElasticcache) syncRemoveCloudElasticcache(ctx context.Context, user
lockman.LockObject(ctx, self)
defer lockman.ReleaseObject(ctx, self)
self.DeletePreventionOff(self, userCred)
err := self.ValidateDeleteCondition(ctx)
if err != nil {
return self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_ERROR, "sync to delete")
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_ERROR, "sync to delete")
return errors.Wrap(err, "ValidateDeleteCondition")
}
return self.Delete(ctx, userCred)
}

View File

@@ -182,8 +182,10 @@ func (self *SExternalProject) SyncWithCloudProject(ctx context.Context, userCred
diff, err := db.UpdateWithLock(ctx, self, func() error {
self.Name = ext.GetName()
self.IsEmulated = ext.IsEmulated()
self.ProjectId = provider.ProjectId
self.DomainId = provider.DomainId
if self.DomainId != provider.DomainId {
self.ProjectId = provider.ProjectId
self.DomainId = provider.DomainId
}
return nil
})
if err != nil {
@@ -198,18 +200,25 @@ func (manager *SExternalProjectManager) newFromCloudProject(ctx context.Context,
project := SExternalProject{}
project.SetModelManager(manager, &project)
newName, err := db.GenerateName(manager, userCred, extProject.GetName())
if err != nil {
return nil, err
}
project.Name = newName
project.Name = extProject.GetName()
project.ExternalId = extProject.GetGlobalId()
project.IsEmulated = extProject.IsEmulated()
project.ManagerId = provider.Id
project.DomainId = provider.DomainId
project.ProjectId = provider.ProjectId
account := provider.GetCloudaccount()
if account != nil && account.AutoCreateProject {
desc := fmt.Sprintf("auto create from cloud project %s (%s)", project.Name, project.ExternalId)
domainId, projectId, err := getOrCreateTenant(ctx, project.Name, provider.DomainId, "", desc)
if err != nil {
log.Errorf("failed to get or create tenant %s(%s) %v", project.Name, project.ExternalId, err)
} else {
project.DomainId = domainId
project.ProjectId = projectId
}
}
err = manager.TableSpec().Insert(&project)
err := manager.TableSpec().Insert(&project)
if err != nil {
log.Errorf("newFromCloudProject fail %s", err)
return nil, err

View File

@@ -3991,6 +3991,20 @@ func (self *SGuest) PerformSyncFixNics(ctx context.Context,
return nil, httperrors.NewInputParameterError("missing field ip, list of ip")
}
iplist := iplistArray.(*jsonutils.JSONArray).GetStringArray()
errs := make([]error, 0)
for i := range vnics {
ip := vnics[i].GetIP()
if len(ip) == 0 {
continue
}
_, err := host.getNetworkOfIPOnHost(ip)
if err != nil {
errs = append(errs, errors.Wrap(err, ip))
}
}
if len(errs) > 0 {
return nil, httperrors.NewInvalidStatusError(errors.NewAggregate(errs).Error())
}
result := self.SyncVMNics(ctx, userCred, host, vnics, iplist)
if result.IsError() {
return nil, httperrors.NewInternalServerError(result.Result())
@@ -4461,6 +4475,9 @@ func (self *SGuest) PerformSnapshotAndClone(
quotas.CancelPendingUsage(ctx, userCred, &pendingUsage, &pendingUsage, false)
quotas.CancelPendingUsage(ctx, userCred, &pendingRegionUsage, &pendingRegionUsage, false)
return nil, httperrors.NewInternalServerError("create instance snapshot failed: %s", err)
} else {
cancelRegionUsage := &SRegionQuota{Snapshot: snapshotUsage.Snapshot}
quotas.CancelPendingUsage(ctx, userCred, &pendingRegionUsage, cancelRegionUsage, true)
}
err = self.StartInstanceSnapshotAndCloneTask(

View File

@@ -246,8 +246,8 @@ func (gt *SGuestTemplate) getMoreDetails(ctx context.Context, userCred mcclient.
configInfo.Disks = disks
// keypair
if len(input.KeypairId) > 0 {
model, err := KeypairManager.FetchById(input.KeypairId)
if len(input.Keypair) > 0 {
model, err := KeypairManager.FetchByIdOrName(userCred, input.Keypair)
if err == nil {
keypair := model.(*SKeypair)
configInfo.Keypair = keypair.GetName()
@@ -341,7 +341,7 @@ func (gt *SGuestTemplate) PerformPublic(ctx context.Context, userCred mcclient.T
// check for below private resource in the guest template
privateResource := map[string]int{
"keypair": len(input.KeypairId),
"keypair": len(input.Keypair),
"instance group": len(input.InstanceGroupIds),
"instance snapshot": len(input.InstanceSnapshotId),
}

View File

@@ -178,15 +178,11 @@ func (self *SGuestdisk) GetJsonDescAtHost(host *SHost) jsonutils.JSONObject {
desc.Add(jsonutils.NewString(storagecacheimg.Path), "image_path")
}
}
storage := disk.GetStorage()
// XXX ???
if host.HostType == api.HOST_TYPE_HYPERVISOR {
desc.Add(jsonutils.NewString(disk.StorageId), "storage_id")
localpath := disk.GetPathAtHost(host)
if len(localpath) == 0 {
desc.Add(jsonutils.JSONTrue, "migrating")
target := host.GetLeastUsedStorage(storage.StorageType)
desc.Add(jsonutils.NewString(target.Id), "target_storage_id")
disk.SetStatus(nil, api.DISK_START_MIGRATE, "migration")
} else {
desc.Add(jsonutils.NewString(localpath), "path")

View File

@@ -178,6 +178,8 @@ type IGuestDriver interface {
IsNeedInjectPasswordByCloudInit(desc *cloudprovider.SManagedVMCreateConfig) bool
GetUserDataType() string
GetWindowsUserDataType() string
IsWindowsUserDataTypeNeedEncode() bool
CancelExpireTime(ctx context.Context, userCred mcclient.TokenCredential, guest *SGuest) error
IsSupportCdrom(guest *SGuest) (bool, error)

View File

@@ -16,11 +16,9 @@ package models
import (
"context"
"crypto/md5"
"crypto/rand"
"database/sql"
"fmt"
"io"
"math/rand"
"regexp"
"time"
@@ -37,6 +35,7 @@ import (
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
randutil "yunion.io/x/onecloud/pkg/util/rand"
"yunion.io/x/onecloud/pkg/util/rbacutils"
)
@@ -225,17 +224,6 @@ func (manager *SGuestnetworkManager) newGuestNetwork(ctx context.Context, userCr
return &gn, nil
}
func (self *SGuestnetwork) getVirtualRand(width int, randomized bool) string {
hash := md5.New()
io.WriteString(hash, self.GuestId)
io.WriteString(hash, self.NetworkId)
if randomized {
io.WriteString(hash, fmt.Sprintf("%d", time.Now().Unix()))
}
hex := fmt.Sprintf("%x", hash.Sum(nil))
return hex[:width]
}
func (self *SGuestnetwork) generateIfname(network *SNetwork, virtual bool, randomized bool) string {
// It may happen that external networks when synced can miss ifname hint
network.ensureIfnameHint()
@@ -246,8 +234,7 @@ func (self *SGuestnetwork) generateIfname(network *SNetwork, virtual bool, rando
nName = nName[:(MAX_IFNAME_SIZE - 4)]
}
if virtual {
rand := self.getVirtualRand(3, randomized)
return fmt.Sprintf("%s-%s", nName, rand)
return fmt.Sprintf("%s-%s", nName, randutil.String(3))
} else {
ip, _ := netutils.NewIPV4Addr(self.IpAddr)
cliaddr := ip.CliAddr(network.GuestIpMask)

View File

@@ -520,6 +520,26 @@ func (manager *SGuestManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field
return q, nil
}
func (manager *SGuestManager) InitializeData() error {
guests := make([]SGuest, 0, 10)
q := manager.Query().Equals("hypervisor", "esxi")
err := db.FetchModelObjects(manager, q, &guests)
if err != nil {
return errors.Wrap(err, "db.FetchModelObjects")
}
// remove secgroup for esxi guest
for i := range guests {
if len(guests[i].SecgrpId) == 0 {
continue
}
db.Update(&guests[i], func() error {
guests[i].SecgrpId = ""
return nil
})
}
return nil
}
func (guest *SGuest) GetHypervisor() string {
if len(guest.Hypervisor) == 0 {
return api.HYPERVISOR_DEFAULT
@@ -1116,6 +1136,9 @@ func (manager *SGuestManager) validateCreateData(
rootDiskConfig.SizeMb = sysMinDiskMB
}
}
if len(rootDiskConfig.Driver) == 0 {
rootDiskConfig.Driver = osProf.DiskDriver
}
log.Debugf("ROOT DISK: %#v", rootDiskConfig)
input.Disks[0] = rootDiskConfig
//data.Set("disk.0", jsonutils.Marshal(rootDiskConfig))
@@ -1211,13 +1234,13 @@ func (manager *SGuestManager) validateCreateData(
input.IsolatedDevices[idx] = devConfig
}
keypairId := input.KeypairId
keypairId := input.Keypair
if len(keypairId) > 0 {
keypairObj, err := KeypairManager.FetchByIdOrName(userCred, keypairId)
if err != nil {
return nil, httperrors.NewResourceNotFoundError("Keypair %s not found", keypairId)
}
input.KeypairId = keypairObj.GetId()
input.Keypair = keypairObj.GetId()
}
secGrpIds := []string{}
@@ -1246,6 +1269,7 @@ func (manager *SGuestManager) validateCreateData(
maxSecgrpCount := GetDriver(hypervisor).GetMaxSecurityGroupCount()
if maxSecgrpCount == 0 { //esxi 不支持安全组
input.SecgroupId = ""
input.Secgroups = []string{}
} else if len(input.Secgroups)+1 > maxSecgrpCount {
return nil, httperrors.NewInputParameterError("%s shall bind up to %d security groups", hypervisor, maxSecgrpCount)
@@ -1512,10 +1536,13 @@ func (guest *SGuest) PostCreate(ctx context.Context, userCred mcclient.TokenCred
guest.setUserData(ctx, userCred, userData)
}
secgroups, _ := jsonutils.GetStringArray(data, "secgroups")
for _, secgroup := range secgroups {
gs := SGuestsecgroup{SecgroupId: secgroup}
gs.GuestId = guest.Id
GuestsecgroupManager.TableSpec().Insert(&gs)
for _, secgroupId := range secgroups {
if secgroupId != guest.SecgrpId {
gs := SGuestsecgroup{}
gs.SecgroupId = secgroupId
gs.GuestId = guest.Id
GuestsecgroupManager.TableSpec().Insert(&gs)
}
}
}
@@ -3185,14 +3212,19 @@ func (self *SGuest) createDiskOnStorage(ctx context.Context, userCred mcclient.T
return nil, err
}
cancelUsage := SQuota{}
cancelUsage.Storage = disk.DiskSize
keys, err := self.GetQuotaKeys()
if err != nil {
return nil, err
if pendingUsage != nil {
cancelUsage := SQuota{}
cancelUsage.Storage = disk.DiskSize
keys, err := self.GetQuotaKeys()
if err != nil {
return nil, err
}
cancelUsage.SetKeys(keys)
err = quotas.CancelPendingUsage(ctx, userCred, pendingUsage, &cancelUsage, true)
if err != nil {
return nil, err
}
}
cancelUsage.SetKeys(keys)
err = quotas.CancelPendingUsage(ctx, userCred, pendingUsage, &cancelUsage, true)
return disk, nil
}
@@ -4684,7 +4716,9 @@ func (self *SGuest) ToCreateInput(userCred mcclient.TokenCredential) *api.Server
for idx, disk := range genInput.Disks {
tmpD := disk
if idx < len(userInput.Disks) {
tmpD.Schedtags = userInput.Disks[idx].Schedtags
inputDisk := userInput.Disks[idx]
tmpD.Schedtags = inputDisk.Schedtags
tmpD.Storage = inputDisk.Storage
}
disks = append(disks, tmpD)
}
@@ -4694,7 +4728,9 @@ func (self *SGuest) ToCreateInput(userCred mcclient.TokenCredential) *api.Server
for idx, net := range genInput.Networks {
tmpN := net
if idx < len(userInput.Networks) {
tmpN.Schedtags = userInput.Disks[idx].Schedtags
inputNet := userInput.Networks[idx]
tmpN.Schedtags = inputNet.Schedtags
tmpN.Network = inputNet.Network
}
nets = append(nets, tmpN)
}
@@ -4714,7 +4750,7 @@ func (self *SGuest) ToCreateInput(userCred mcclient.TokenCredential) *api.Server
userInput.ShutdownBehavior = genInput.ShutdownBehavior
userInput.IsSystem = genInput.IsSystem
userInput.SecgroupId = genInput.SecgroupId
userInput.KeypairId = genInput.KeypairId
userInput.Keypair = genInput.Keypair
userInput.EipBw = genInput.EipBw
userInput.EipChargeType = genInput.EipChargeType
// cloned server should belongs to the project creating it
@@ -4776,7 +4812,7 @@ func (self *SGuest) toCreateInput() *api.ServerCreateInput {
r.IsolatedDevices = self.ToIsolatedDevicesConfig()
if keypair := self.getKeypair(); keypair != nil {
r.KeypairId = keypair.Id
r.Keypair = keypair.Id
}
if host := self.GetHost(); host != nil {
r.ResourceType = host.ResourceType

View File

@@ -3660,10 +3660,16 @@ func (self *SHost) EnableNetif(ctx context.Context, userCred mcclient.TokenCrede
}
net, err = wire.GetCandidatePrivateNetwork(userCred, false, netTypes)
if err != nil {
return fmt.Errorf("fail to find network %s", err)
return fmt.Errorf("fail to find private network %s", err)
}
if net == nil {
return fmt.Errorf("No network found")
net, err = wire.GetCandidatePublicNetwork(false, netTypes)
if err != nil {
return fmt.Errorf("fail to find public network %s", err)
}
if net == nil {
return fmt.Errorf("No network found")
}
}
}
} else if net.WireId != wire.Id {
@@ -4717,3 +4723,15 @@ func (self *SHost) StartSyncConfig(ctx context.Context, userCred mcclient.TokenC
task.ScheduleRun(nil)
return 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

@@ -43,6 +43,7 @@ func InitDB() error {
SecurityGroupManager,
SecurityGroupCacheManager,
NetworkManager,
GuestManager,
LoadbalancerCertificateManager,
LoadbalancerAclManager,
LoadbalancerManager,

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