Compare commits

..

165 Commits

Author SHA1 Message Date
yunion-ci-robot
423777c775 Merge pull request #4796 from tb365/automated-cherry-pick-of-#4795-upstream-release-3.0
Automated cherry pick of #4795: add filter skus by domain id
2020-01-10 20:25:58 +08:00
yunion-ci-robot
52f2a1f3b4 Merge pull request #4722 from tb365/automated-cherry-pick-of-#4712-upstream-release-3.0
Automated cherry pick of #4712: cloud account support manually sync skus
2020-01-10 20:06:59 +08:00
yunion-ci-robot
dd0ced571d Merge pull request #4806 from tb365/automated-cherry-pick-of-#4801-upstream-release-3.0
Automated cherry pick of #4801: kvm elb listener update bugfix
2020-01-10 19:50:58 +08:00
yunion-ci-robot
dbd959d040 Merge pull request #4767 from tb365/automated-cherry-pick-of-#4766-upstream-release-3.0
Automated cherry pick of #4766: _getModule fix
2020-01-10 19:22:59 +08:00
TangBin
9be50f0007 kvm elb listener update bugfix 2020-01-10 18:52:00 +08:00
TangBin
840b6e9a16 spelling mistakes fix 2020-01-10 17:17:25 +08:00
TangBin
ec83f583c2 user register ingore blank row 2020-01-10 17:17:25 +08:00
TangBin
2983659c53 add filter skus by domain id 2020-01-10 17:17:25 +08:00
Zexi Li
af20c84a50 Merge pull request #4794 from rainzm/automated-cherry-pick-of-#4779-upstream-release-3.0
Automated cherry pick of #4779: fix(esxi-agent): Avoid redundant agent & Adjust workspace path
2020-01-10 11:51:57 +08:00
Rain
5cee576fc4 fix(esxi-agent): Avoid redundant agent & Adjust workspace path
1. There is only one esxi agent needed in OneCloud.
2. Workspace path shoule be EsxiAgentPath not the parent directory of this.
3. The VM name is too long for vcenter when importing VM so that shrink
it.
2020-01-10 11:01:37 +08:00
yunion-ci-robot
ba89e19f3e Merge pull request #4778 from rainzm/automated-cherry-pick-of-#4754-upstream-release-3.0
Automated cherry pick of #4754: fix(region): Sync HostStorage in syncOnPremiseCloudProviderInfo
2020-01-10 10:36:58 +08:00
yunion-ci-robot
73faf76bbb Merge pull request #4762 from wanyaoqi/automated-cherry-pick-of-#4761-upstream-release-3.0
Automated cherry pick of #4761: image-properties-add-disable-delete
2020-01-10 10:28:58 +08:00
yunion-ci-robot
17bd125542 Merge pull request #4769 from wanyaoqi/automated-cherry-pick-of-#4768-upstream-release-3.0
Automated cherry pick of #4768: fix guest start no task complete
2020-01-10 10:22:58 +08:00
yunion-ci-robot
3b14136705 Merge pull request #4783 from swordqiu/automated-cherry-pick-of-#4780-upstream-release-3.0
Automated cherry pick of #4780: fix: initialize service config on keystone when service boot
2020-01-10 10:19:58 +08:00
yunion-ci-robot
a968e3544c Merge pull request #4785 from yousong/automated-cherry-pick-of-#4784-upstream-release-3.0
Automated cherry pick of #4784: dnsrecords: add helper methods
2020-01-10 10:15:57 +08:00
Yousong Zhou
9d20a58a85 dns: chain load records for cname 2020-01-09 23:23:34 +08:00
Yousong Zhou
a719ad6d82 dns: prepare for responding with A record of cname value 2020-01-09 23:23:34 +08:00
Yousong Zhou
2f9e3f7da0 dnsrecords: add helper methods 2020-01-09 23:23:34 +08:00
Qiu Jian
5f8758e5c4 fix: initialize service config on keystone when service boot 2020-01-09 22:15:27 +08:00
Rain
ae2369befd fix(region): Sync HostStorage in syncOnPremiseCloudProviderInfo
情景:绕过OneCloud,删除 storage 上的所有 vm 并且删除 storage 然后新建 storage。

问题:因为存在 vm 在使用此 storage ,所以在同步的时候,对应的 storage
会删除失败,并且阻止了 storagecache 的同步。这样在创建机器的时候,如果
使用旧的 storage 就会导致创建失败(因为此 Host 已经不再使用对应的
remote storage); 如果使用新的 storage 就会因为找不到对应的 storage cache 而失败。

修改:如果因为以上原因删除失败的 storage 的 storage_type 为 local
那么就把这个 storage 置为 offline,并且不再阻止 storage cache 的同步。
2020-01-09 21:04:32 +08:00
wanyaoqi
a4a7d004c8 fix guest start no task complete 2020-01-09 17:13:03 +08:00
TangBin
9a7d223311 _getModule fix 2020-01-09 16:42:16 +08:00
wanyaoqi
d9910a0364 image-properties-add-disable-delete 2020-01-09 15:42:02 +08:00
TangBin
6ad8ff188d cloud account support manually sync skus 2020-01-09 11:17:04 +08:00
yunion-ci-robot
641cd05a9a Merge pull request #4756 from rainzm/automated-cherry-pick-of-#4755-upstream-release-3.0
Automated cherry pick of #4755: fix(esxi-agent): Adjust the VM Path in Datastore
2020-01-09 10:28:57 +08:00
Zexi Li
570a6bbab7 Merge pull request #4760 from swordqiu/automated-cherry-pick-of-#4757-upstream-release-3.0
Automated cherry pick of #4757: fix: brand of compute quota key should be fixed
2020-01-09 09:58:54 +08:00
yunion-ci-robot
01a466b989 Merge pull request #4710 from wanyaoqi/automated-cherry-pick-of-#4709-upstream-release-3.0
Automated cherry pick of #4709: host misc fix
2020-01-09 00:05:58 +08:00
yunion-ci-robot
4fd7e6fcf0 Merge pull request #4725 from yousong/automated-cherry-pick-of-#4724-upstream-release-3.0
Automated cherry pick of #4724: wires: lift name length, charset constraint
2020-01-08 23:44:59 +08:00
Qiu Jian
8a2841f672 fix: brand of compute quota key should be fixed 2020-01-08 23:36:12 +08:00
yunion-ci-robot
0adccb5c8b Merge pull request #4751 from ioito/automated-cherry-pick-of-#4750-upstream-release-3.0
Automated cherry pick of #4750: fix: cloudevent 成功条件补充
2020-01-08 23:33:59 +08:00
Rain
a712df096a fix(esxi-agent): Adjust the VM Path in Datastore 2020-01-08 21:09:44 +08:00
Qu Xuan
ed75a7262b fix: cloudevent 成功条件补充 2020-01-08 20:44:13 +08:00
Zexi Li
adea5e3441 Merge pull request #4738 from swordqiu/automated-cherry-pick-of-#4735-upstream-release-3.0
Automated cherry pick of #4735: fix: misc quota bugs 1. snapshot pending usage not cleaned after created 2. server-attach-network error 3. loadbalancer fail to set cloudregion_id
2020-01-08 19:17:40 +08:00
Yousong Zhou
64f29934f0 wires: lift name length, charset constraint 2020-01-08 19:15:17 +08:00
yunion-ci-robot
6cc5c4d942 Merge pull request #4729 from ioito/automated-cherry-pick-of-#4728-upstream-release-3.0
Automated cherry pick of #4728: fix: eip duplicate name
2020-01-08 19:05:57 +08:00
Qiu Jian
e817fb0920 fix: misc quota bugs 1. snapshot pending usage not cleaned after created 2. server-attach-network error 3. loadbalancer fail to set cloudregion_id 2020-01-08 18:53:36 +08:00
Qu Xuan
2c412db6c8 fix: eip duplicate name 2020-01-08 18:11:15 +08:00
yunion-ci-robot
d08761095c Merge pull request #4699 from rainzm/automated-cherry-pick-of-#4695-upstream-release-3.0
Automated cherry pick of #4695: fix(glance): Cancel pending usage of image quota correctly
2020-01-08 16:11:58 +08:00
yunion-ci-robot
03cf19f1db Merge pull request #4705 from tb365/automated-cherry-pick-of-#4701-upstream-release-3.0
Automated cherry pick of #4701: azure skus sync fix
2020-01-08 15:53:59 +08:00
Zexi Li
3c77aa38ff Merge pull request #4715 from wanyaoqi/automated-cherry-pick-of-#4714-upstream-release-3.0
Automated cherry pick of #4714: set subimage some field nullable
2020-01-08 15:42:48 +08:00
wanyaoqi
d3a2ebeacb set subimage some field nullable 2020-01-08 15:36:44 +08:00
yunion-ci-robot
d868952b0d Merge pull request #4706 from ioito/automated-cherry-pick-of-#4655-upstream-release-3.0
Automated cherry pick of #4655: optimized: 优化公有云日志查询
2020-01-08 14:56:57 +08:00
wanyaoqi
9ac505c907 host misc fix 2020-01-08 14:22:18 +08:00
yunion-ci-robot
05ee08e411 Merge pull request #4684 from yousong/automated-cherry-pick-of-#4683-upstream-release-3.0
Automated cherry pick of #4683: hostman: distro name OpenWrt instead of OpenWRT
2020-01-08 12:57:59 +08:00
Qu Xuan
ef39ed3d0c optimized: 优化公有云日志查询 2020-01-08 11:46:38 +08:00
yunion-ci-robot
85ac87b7c9 Merge pull request #4651 from ioito/automated-cherry-pick-of-#4650-upstream-release-3.0
Automated cherry pick of #4650: fix: 避免创建rds account, database后未设置exteranl_id
2020-01-08 11:42:56 +08:00
yunion-ci-robot
3b3480b29b Merge pull request #4637 from ioito/automated-cherry-pick-of-#4636-upstream-release-3.0
Automated cherry pick of #4636: fix: 加强密码校验
2020-01-08 11:38:58 +08:00
TangBin
6628f15ab0 huawei redis sync fix 2020-01-08 11:34:42 +08:00
TangBin
9f55497161 ctyun default gateway fix 2020-01-08 11:34:42 +08:00
TangBin
9e96e4f7e4 huawei network default gateway fix 2020-01-08 11:34:42 +08:00
TangBin
12c87f630a network create GuestIpPrefix fix 2020-01-08 11:34:42 +08:00
TangBin
5d2fb3bf56 azure skus sync fix 2020-01-08 11:34:42 +08:00
Rain
af5b218377 fix(glance): Cancel pending usage of image quota correctly
ImageNumber always be zero because the 'image_number' in data was
removed so that canceling pending usage not work.
2020-01-08 11:33:32 +08:00
yunion-ci-robot
802197f161 Merge pull request #4642 from tb365/automated-cherry-pick-of-#4634-upstream-release-3.0
Automated cherry pick of #4634: huawei image delete bugfix
2020-01-08 11:26:59 +08:00
yunion-ci-robot
45f3ee7989 Merge pull request #4690 from ioito/automated-cherry-pick-of-#4685-upstream-release-3.0
Automated cherry pick of #4685: fix: next marker format
2020-01-08 10:09:57 +08:00
Zexi Li
d9a43ae92a Merge pull request #4682 from swordqiu/automated-cherry-pick-of-#4676-upstream-release-3.0
Automated cherry pick of #4676: fix: guest network default share scope should be system if non-default-domain-projects is off
2020-01-07 19:30:44 +08:00
Zexi Li
8ae4e5bcec Merge pull request #4675 from swordqiu/automated-cherry-pick-of-#4666-upstream-release-3.0
Automated cherry pick of #4666: fix: guess brand on guest create
2020-01-07 19:28:49 +08:00
yunion-ci-robot
67dd167835 Merge pull request #4665 from ioito/automated-cherry-pick-of-#4656-upstream-release-3.0
Automated cherry pick of #4656: fix: 避免拥有带宽包的腾讯云创建机器失败
2020-01-07 18:08:59 +08:00
Qu Xuan
2d1d8db96a fix: next marker format 2020-01-07 18:02:23 +08:00
Yousong Zhou
9e42b83406 hostman: openwrt: deploy public key for root 2020-01-07 18:00:34 +08:00
Yousong Zhou
1a16fbd9cf hostman: split DeployAuthorizedKeys() 2020-01-07 18:00:34 +08:00
Yousong Zhou
77d19d2ec3 hostman: openwrt: support deploy networking scripts 2020-01-07 18:00:34 +08:00
Yousong Zhou
5391943537 hostman: openwrt: deploy hostname with board config 2020-01-07 18:00:34 +08:00
Yousong Zhou
5c1044a1f6 hostman: distro name OpenWrt instead of OpenWRT 2020-01-07 18:00:34 +08:00
yunion-ci-robot
6e87e25b38 Merge pull request #4659 from ioito/automated-cherry-pick-of-#4658-upstream-release-3.0
Automated cherry pick of #4658: fix: 避免同步安全组失败后,没有任何日志记录
2020-01-07 17:09:57 +08:00
Qiu Jian
95565e4b6d fix: guest network default share scope should be system if non-default-domain-projects is off 2020-01-07 16:58:36 +08:00
Qiu Jian
6c0bdeac49 fix: guess brand on guest create 2020-01-07 15:13:40 +08:00
Qu Xuan
5100ced74c fix: 避免拥有带宽包的腾讯云创建机器失败 2020-01-07 14:59:11 +08:00
Qu Xuan
f022f4138e fix: 避免同步安全组失败后,没有任何日志记录 2020-01-07 11:48:43 +08:00
yunion-ci-robot
6ecf644277 Merge pull request #4639 from rainzm/automated-cherry-pick-of-#4635-upstream-release-3.0
Automated cherry pick of #4635: fix: Workmanager delayTaskWithoutReqctx
2020-01-07 09:33:56 +08:00
Rain
ee34fbdafe fix: Workmanager delayTaskWithoutReqctx
The context of delayTaskWithoutReqctx should have 'taskid' value.
2020-01-06 15:21:04 +08:00
yunion-ci-robot
61ff4ddbc8 Merge pull request #4649 from swordqiu/automated-cherry-pick-of-#4645-upstream-release-3.0
Automated cherry pick of #4645: fix: comment out TestDialTimeout
2020-01-06 15:12:59 +08:00
Qu Xuan
ec7bc017dd fix: 避免创建rds account, database后未设置exteranl_id 2020-01-06 13:38:09 +08:00
Qiu Jian
a96d17efcc fix: comment out TestDialTimeout 2020-01-06 13:12:04 +08:00
TangBin
ac1d08d619 huawei image delete bugfix 2020-01-06 11:52:49 +08:00
Qu Xuan
d032dccd91 fix: 加强密码校验 2020-01-06 11:45:03 +08:00
yunion-ci-robot
987495c463 Merge pull request #4633 from wanyaoqi/automated-cherry-pick-of-#4632-upstream-release-3.0
Automated cherry pick of #4632: host image support container deploy:
2020-01-05 19:10:39 +08:00
wanyaoqi
dc2fd237f0 host image support container deploy: 2020-01-05 18:52:11 +08:00
Zexi Li
03cca94b0c Merge pull request #4630 from swordqiu/automated-cherry-pick-of-#4627-upstream-release-3.0
Automated cherry pick of #4627: fix: increase default sync worker count from 2 to 5
2020-01-05 12:22:58 +08:00
Qiu Jian
3365161fa5 fix: increase default sync worker count from 2 to 5 2020-01-05 12:21:27 +08:00
Zexi Li
e810d4567e Merge pull request #4625 from swordqiu/automated-cherry-pick-of-#4601-upstream-release-3.0
Automated cherry pick of #4601: fix: remove bw/ebw quota limit
2020-01-04 23:59:38 +08:00
Qiu Jian
954341e4ab remove bw/ebw quota from scheduler 2020-01-04 23:35:42 +08:00
Qiu Jian
becfe078d5 fix: remove bw/ebw quota limit 2020-01-04 23:35:42 +08:00
Zexi Li
8915b934b1 Merge pull request #4622 from zexi/automated-cherry-pick-of-#4621-upstream-release-3.0
Automated cherry pick of #4621: fix: fmt error
2020-01-04 23:21:01 +08:00
Zexi Li
b67da6996f Merge pull request #4620 from swordqiu/automated-cherry-pick-of-#4616-upstream-release-3.0
Automated cherry pick of #4616: fix: huawei uncache image fail
2020-01-04 23:20:19 +08:00
Zexi Li
ce40f6378f Merge pull request #4610 from ioito/automated-cherry-pick-of-#4609-upstream-release-3.0
Automated cherry pick of #4609: fix: 避免仅删除value时,行为演变为删除标签
2020-01-04 23:17:56 +08:00
Zexi Li
2c2b1544c6 fix: fmt error 2020-01-04 23:12:39 +08:00
Qiu Jian
44114e8d94 fix: huawei uncache image fail 2020-01-04 23:03:53 +08:00
Zexi Li
b9405e72e7 Merge pull request #4608 from rainzm/automated-cherry-pick-of-#4602-upstream-release-3.0
Automated cherry pick of #4602: fix(notify): Fix the error of filter about contacts
2020-01-04 22:29:57 +08:00
Rain
3a5b32fc60 fix(notify): Fix the error of filter about contacts 2020-01-04 22:26:43 +08:00
Qu Xuan
9bbba1a3cc fix: 避免仅删除value时,行为演变为删除标签 2020-01-04 22:16:07 +08:00
Zexi Li
25277900d4 Merge pull request #4600 from rainzm/automated-cherry-pick-of-#4597-upstream-release-3.0
Automated cherry pick of #4597: fix(region): Add reset_password in guest template's ConfigInfo
2020-01-04 22:03:25 +08:00
Rain
4cdf779700 fix(region): Cancel the check about project when creating service catlog 2020-01-04 21:40:16 +08:00
Rain
dc09cb88c4 fix(region): Add reset_password in guest template's ConfigInfo 2020-01-04 21:40:16 +08:00
Zexi Li
155ef44d8f Merge pull request #4595 from rainzm/automated-cherry-pick-of-#4592-upstream-release-3.0
Automated cherry pick of #4592: fix(region): Fix that 'Can_delete' disappears due to parameter structuring
2020-01-04 21:10:02 +08:00
Zexi Li
e08b7ff91d Merge pull request #4591 from rainzm/automated-cherry-pick-of-#4588-upstream-release-3.0
Automated cherry pick of #4588: fix(region): Set normal's snapshotpolicy's status as ready
2020-01-04 21:09:41 +08:00
yunion-ci-robot
fa544dbdc7 Merge pull request #4596 from rainzm/automated-cherry-pick-of-#4419-upstream-release-3.0
Automated cherry pick of #4419: feature(esxi-agent): Esxi Agent Golang
2020-01-04 21:08:41 +08:00
Rain
67f0dc3f8b feature(esxi-agent): Esxi Agent Golang
1. 修改了host-deployer 使其支持 vmware vddk 的 deploy guest fs 操作。
2. esxi agent python ==> Go

fix(esxi-agent): Fix some bugs and irregular contents

fix(esxi-agent): Partial parameter structure

fix(esxi-agent): Add ovf template and remove some binary file

fix(esxi-agent): Format Code

fix(esxi-agent): fix based on reviewers' comments

fix(esxi-agent): fix host-deployer because of occasional unknown panic

fix: DelayTask should have a new Context

fix(esxi-agent): call hostutils.DelayTask

change '_interface' package to 'iagent' package

fix(esxi-agent): Fix some irregular code
2020-01-04 21:04:29 +08:00
Rain
d333e30d52 fix(region): Fix that 'Can_delete' disappears due to parameter structuring 2020-01-04 21:03:56 +08:00
Rain
94068ce53e feature(region): Add bind/unbind-snapshotpolicy api for disk 2020-01-04 21:00:33 +08:00
Rain
7a0b6fd2ee fix(region): Set normal's snapshotpolicy's status as ready 2020-01-04 21:00:33 +08:00
屈轩
c0115d5a9c fix: 子网删除忽略弹性网卡 (#4575) 2020-01-04 20:52:54 +08:00
Jian Qiu
50ea8fc5a8 Automated cherry pick of #4527: fix: httpclient timeout value cleanup, use notimeout client for oss (#4531)
* fix: httpclient timeout value cleanup, use notimeout client for oss

* Adaptive timeout client

* more test cases

* remove resolve timeout test case

* use adptive timeout only if timeout = 0
2020-01-04 20:52:25 +08:00
yunion-ci-robot
fec4cb1804 Merge pull request #4570 from bistuzx/automated-cherry-pick-of-#4557-upstream-release-3.0
Automated cherry pick of #4557: add cloud account create&update options
2020-01-04 20:28:43 +08:00
yunion-ci-robot
49b3bf2dce Merge pull request #4582 from ioito/automated-cherry-pick-of-#4581-upstream-release-3.0
Automated cherry pick of #4581: fix: 修复zstack安全组创建失败问题
2020-01-04 20:12:39 +08:00
yunion-ci-robot
b89a445451 Merge pull request #4559 from ioito/automated-cherry-pick-of-#4558-upstream-release-3.0
Automated cherry pick of #4558: fix: openstack eip dissociate optimized
2020-01-04 20:02:36 +08:00
Qu Xuan
d3a0e345d9 fix: 修复zstack安全组创建失败问题 2020-01-04 20:01:21 +08:00
Zexi Li
0542deef75 Merge pull request #4568 from swordqiu/automated-cherry-pick-of-#4564-upstream-release-3.0
Automated cherry pick of #4564: fix: minio fail to set object metadata
2020-01-04 19:52:52 +08:00
Zexi Li
0db77fc304 Merge pull request #4552 from swordqiu/automated-cherry-pick-of-#4549-upstream-release-3.0
Automated cherry pick of #4549: fix: domain quota-list include domain's own quota
2020-01-04 19:46:26 +08:00
Zexi Li
c6a8eae499 Merge pull request #4580 from zexi/automated-cherry-pick-of-#4579-upstream-release-3.0
Automated cherry pick of #4579: dockerfile: component use base image
2020-01-04 19:28:01 +08:00
Zexi Li
62f0a84a83 dockerfile: component use base image 2020-01-04 19:28:35 +08:00
张旭
aa6e9a8107 add cloud account create&update options 2020-01-04 19:19:06 +08:00
yunion-ci-robot
8528410bf8 Merge pull request #4554 from tb365/automated-cherry-pick-of-#4553-upstream-release-3.0
Automated cherry pick of #4553: elastic account add random password
2020-01-04 19:05:36 +08:00
Qu Xuan
d2f33742a0 fix: openstack eip dissociate optimized 2020-01-04 18:43:30 +08:00
Qiu Jian
b4b1494e1c fix: minio fail to set object metadata 2020-01-04 18:37:42 +08:00
TangBin
bb8c9d1b47 get eip bugfix 2020-01-04 18:23:22 +08:00
TangBin
ab1d2c0c24 get eip bugfix 2020-01-04 18:23:22 +08:00
TangBin
ef1b8f5245 host batch register bugfix 2020-01-04 18:23:22 +08:00
TangBin
8d1f755b4e elastic cache account add login info api 2020-01-04 18:23:22 +08:00
TangBin
ad32d9063a elastic account add random password 2020-01-04 18:23:22 +08:00
yunion-ci-robot
7ca467e35b Merge pull request #4538 from wanyaoqi/automated-cherry-pick-of-#4535-upstream-release-3.0
Automated cherry pick of #4535: fix disk filter by guest
2020-01-04 18:20:36 +08:00
Qiu Jian
8270238116 fix: domain quota-list include domain's own quota 2020-01-04 17:18:50 +08:00
Zexi Li
ac4f897510 Merge pull request #4544 from swordqiu/automated-cherry-pick-of-#4539-upstream-release-3.0
Automated cherry pick of #4539: fix: add cloudprovider capabilities
2020-01-04 17:03:35 +08:00
wanyaoqi
0eef43bb0a add recover on guest suddenly shotdown 2020-01-04 16:51:59 +08:00
Qiu Jian
5096ee9de3 minor fixes 2020-01-04 16:21:41 +08:00
Qiu Jian
34e0d8dd27 minor fixes 2020-01-04 16:21:41 +08:00
Qiu Jian
975154b98a minor fixes 2020-01-04 16:21:41 +08:00
Qiu Jian
1b23d6c755 add cloudevent capabilities 2020-01-04 16:21:41 +08:00
Qiu Jian
cdbc49a1a8 fix: add cloudprovider capabilities 2020-01-04 16:21:41 +08:00
wanyaoqi
86df323603 fix disk filter by guest 2020-01-04 15:19:16 +08:00
Zexi Li
422dcf8020 Merge pull request #4534 from zexi/automated-cherry-pick-of-#4533-upstream-release-3.0
Automated cherry pick of #4533: devtool: use public influxdb endpoint
2020-01-04 14:50:40 +08:00
Zexi Li
a47bdf3566 devtool: use public influxdb endpoint 2020-01-04 14:37:00 +08:00
yunion-ci-robot
275832f438 Merge pull request #4512 from tb365/automated-cherry-pick-of-#4509-upstream-release-3.0
Automated cherry pick of #4509: account create bugfix
2020-01-04 12:55:36 +08:00
TangBin
dbbe173e51 InitPendingUsagesInContext fix 2020-01-04 12:42:09 +08:00
TangBin
f0276d1a01 account&provider health status check 2020-01-04 12:42:09 +08:00
TangBin
0cfb8dbd5a elastic skus add region_ext_id & zone_ext_id 2020-01-04 12:42:09 +08:00
TangBin
ad0ddf6dd9 disk delete condition validator 2020-01-04 12:42:09 +08:00
TangBin
3b1c4dc2e5 huawei oss client read http ProxyFromEnvironment 2020-01-04 12:42:09 +08:00
TangBin
4d907584e2 network operations add action log 2020-01-04 12:42:09 +08:00
TangBin
2b9a995b13 account create bugfix 2020-01-04 12:42:09 +08:00
Zexi Li
6dc2ccee60 Merge pull request #4521 from zexi/automated-cherry-pick-of-#4520-upstream-release-3.0
Automated cherry pick of #4520: baremetal: fix megaraid check jbod always disabled
2020-01-03 21:51:22 +08:00
yunion-ci-robot
2bd77ec202 Merge pull request #4514 from ioito/automated-cherry-pick-of-#4513-upstream-release-3.0
Automated cherry pick of #4513: fix: 腾讯云不支持描述字段参数
2020-01-03 21:28:39 +08:00
Zexi Li
30fab89baa baremetal: fix megaraid check jbod always disabled 2020-01-03 21:21:33 +08:00
Qu Xuan
8d47608e4e fix: 腾讯云不支持描述字段参数 2020-01-03 20:41:28 +08:00
Zexi Li
eeeb81bf3f Merge pull request #4502 from swordqiu/automated-cherry-pick-of-#4498-upstream-release-3.0
Automated cherry pick of #4498: fix: allow delete cloudaccount with auto-sync enabled
2020-01-03 19:06:20 +08:00
yunion-ci-robot
78d68a023b Merge pull request #4505 from rainzm/automated-cherry-pick-of-#4497-upstream-release-3.0
Automated cherry pick of #4497: fix(huawei): Add 'X-Project-ID' header for huawei nat reuqest
2020-01-03 19:03:36 +08:00
yunion-ci-robot
6534a7c6a5 Merge pull request #4493 from ioito/automated-cherry-pick-of-#4492-upstream-release-3.0
Automated cherry pick of #4492: fix: 修复provider为空的套餐
2020-01-03 18:38:36 +08:00
Rain
9d60403817 fix(huawei): Add 'X-Project-ID' header for huawei nat reuqest 2020-01-03 17:23:52 +08:00
Qiu Jian
6ba7cbbb37 fix: allow delete cloudaccount with auto-sync enabled 2020-01-03 17:17:24 +08:00
Zexi Li
047bf47534 Merge pull request #4491 from swordqiu/automated-cherry-pick-of-#4488-upstream-release-3.0
Automated cherry pick of #4488: scheduler schedule according to quota limit
2020-01-03 17:13:42 +08:00
Qiu Jian
243590995f fix: OutOfQuota error code 500 2020-01-03 16:02:44 +08:00
Qiu Jian
53a9c010cb automatically save pendingUsage in context 2020-01-03 16:02:44 +08:00
Qiu Jian
9a6d9df76d remove obsolete codes 2020-01-03 16:02:44 +08:00
Qiu Jian
8870fe2d1f bug fixes 2020-01-03 16:02:43 +08:00
Qiu Jian
d2d8a7eeaa move lb from zonequota to regionquota 2020-01-03 16:02:43 +08:00
Qiu Jian
56be0bb3c5 scheduler schedule according to quota limit 2020-01-03 16:02:43 +08:00
Qu Xuan
d9956a9445 fix: 修复provider为空的套餐 2020-01-03 15:54:18 +08:00
Zexi Li
0702803b52 Merge pull request #4487 from rainzm/automated-cherry-pick-of-#4483-upstream-release-3.0
Automated cherry pick of #4483: fix(notify): Always update websocket config
2020-01-03 11:22:47 +08:00
Zexi Li
f12c77ca4c Merge pull request #4479 from swordqiu/automated-cherry-pick-of-#4478-upstream-release-3.0
Automated cherry pick of #4478: fix: bucket list object may skip first matched object
2020-01-03 11:01:21 +08:00
Rain
e0e72f4dc2 fix(notify): Always update websocket config 2020-01-02 19:15:23 +08:00
Qiu Jian
1cd4472073 fix: sort objects and directories 2020-01-02 17:47:07 +08:00
Qiu Jian
71c877428e fix: bucket list object may skip first matched object 2020-01-02 17:47:07 +08:00
rainzm
20a2dc5bf3 fix(region): Add support for suspend when syncing status of guest (#4477) 2020-01-02 16:34:22 +08:00
Zexi Li
e00f4a1f7d Merge pull request #4473 from zexi/automated-cherry-pick-of-#4411-upstream-release-3.0
Automated cherry pick of #4411: host misc fix
2020-01-02 12:32:16 +08:00
wanyaoqi
72c489140d host misc fix
- host check not require ntpd
- create host record use generate name
2020-01-02 12:32:32 +08:00
3498 changed files with 173790 additions and 548337 deletions

38
.circleci/Dockerfile Normal file
View File

@@ -0,0 +1,38 @@
FROM centos:7
MAINTAINER Yousong Zhou <zhouyousong@yunion.cn>
RUN true \
&& yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
&& yum install -y git wget \
&& yum groupinstall -y "Development Tools" \
&& : ceph for cmd/host \
&& rpm --import 'https://download.ceph.com/keys/release.asc' \
&& yum install -y https://download.ceph.com/rpm-luminous/el7/noarch/ceph-release-1-1.el7.noarch.rpm \
&& yum install -y libcephfs-devel librbd-devel librados-devel \
&& yum clean all
WORKDIR /opt
RUN true \
&& wget https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz \
&& tar xzf go1.13.3.linux-amd64.tar.gz \
&& rm -vf go1.13.3.linux-amd64.tar.gz \
&& true
ENV GOROOT="/opt/go"
ENV PATH="/opt/go/bin:${PATH}"
RUN useradd -c "OneCloud Builder" --create-home --home-dir /home/build --shell /bin/bash build
ENV HOME /home/build
WORKDIR /home/build
USER build
ENV GOPATH="/home/build/go"
ENV PATH="${GOPATH}/bin:${PATH}"
RUN true \
&& mkdir -p "$GOPATH" \
&& d="$GOPATH/src/golang.org/x/tools" \
&& mkdir -p "$d" \
&& git clone --branch yun --depth 8 https://github.com/yousong/tools "$d" \
&& cd "$d" \
&& go install ./cmd/goimports \
&& true

View File

@@ -5,10 +5,10 @@ version: 2
jobs:
check:
docker:
- image: yunionio/centos-build:1.0-1
- image: yunionio/onecloud-ci:v1.0.3
environment:
ONECLOUD_CI_BUILD: "1"
working_directory: /root/go/onecloud
working_directory: /home/build/go/src/yunion.io/x/onecloud
steps:
- checkout
- run:
@@ -18,7 +18,7 @@ jobs:
requires:
- check
docker:
- image: yunionio/centos-build:1.0-1
- image: yunionio/onecloud-ci:v1.0.2
environment:
ONECLOUD_CI_BUILD: "1"
@@ -26,14 +26,14 @@ jobs:
#### expecting it in the form of
#### /go/src/github.com/circleci/go-tool
#### /go/src/bitbucket.org/circleci/go-tool
working_directory: /root/go/onecloud
working_directory: /home/build/go/src/yunion.io/x/onecloud
parallelism: 4
steps:
- checkout
- restore_cache:
key: onecloud-build-cache-{{ checksum "go.mod" }}-{{ checksum "Makefile" }}
paths:
- /root/.cache/go-build
- /home/build/.cache/go-build
- run:
command: |
targets="$(circleci tests glob "cmd/*" | grep -v cmd/host-image | circleci tests split)"
@@ -43,7 +43,7 @@ jobs:
- save_cache:
key: onecloud-build-cache-{{ checksum "go.mod" }}-{{ checksum "Makefile" }}
paths:
- /root/.cache/go-build
- /home/build/.cache/go-build
- store_artifacts:
path: _output/
@@ -51,16 +51,16 @@ jobs:
requires:
- check
docker:
- image: yunionio/centos-build:1.0-1
- image: yunionio/onecloud-ci:v1.0.2
environment:
GO111MODULE: "on"
working_directory: /root/go/onecloud
working_directory: /home/build/go/src/yunion.io/x/onecloud
steps:
- checkout
- restore_cache:
key: onecloud-test-cache-{{ checksum "go.mod" }}-{{ checksum "Makefile" }}
paths:
- /root/.cache/go-build
- /home/build/.cache/go-build
- run:
name: unit_test
command: |
@@ -68,7 +68,7 @@ jobs:
- save_cache:
key: onecloud-test-cache-{{ checksum "go.mod" }}-{{ checksum "Makefile" }}
paths:
- /root/.cache/go-build
- /home/build/.cache/go-build
workflows:
version: 2

View File

@@ -1,15 +1,9 @@
**这个 PR 实现什么功能/修复什么问题**:
<!--
- [ ] 功能、bugfix描述
- [ ] 冒烟测试
- [ ] 单元测试编写
-->
**是否需要 backport 到之前的 release 分支**:
<!--
如果不需要,填写 "NONE".
如果需要,就以下面 item 的格式写 release 分支名,并提交对应的 cherry-pick PR:
- release/3.1
- release/2.8.0
- release/2.6.0
-->

View File

@@ -29,47 +29,16 @@ jobs:
- name: Build
run: |
sudo apt-get update
sudo apt-get install librados-dev librbd-dev # baremetal-agent needs this
sudo apt-get install librados-dev librbd-dev
make cmd/apigateway cmd/climc cmd/keystone
make cmd/logger cmd/region cmd/scheduler cmd/webconsole
make cmd/yunionconf cmd/glance cmd/torrent cmd/s3gateway
make cmd/ansibleserver cmd/cloudnet cmd/notify
make cmd/host && ./scripts/bundle_libraries.sh _output/bin/bundles/host _output/bin/host && ./scripts/host_find_libraries.sh _output/bin/bundles/host
make cmd/host-deployer && ./scripts/bundle_libraries.sh _output/bin/bundles/host-deployer _output/bin/host-deployer
make cmd/baremetal-agent && ./scripts/bundle_libraries.sh _output/bin/bundles/baremetal-agent _output/bin/baremetal-agent
make cmd/cloudevent cmd/devtool
make cmd/*cli
make cmd/esxi-agent
make docker-alpine-build F='-j4 cmd/host cmd/vpcagent cmd/region-dns'
- name: Image region
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: registry.cn-beijing.aliyuncs.com/yunionio/region
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: registry.cn-beijing.aliyuncs.com
snapshot: true
dockerfile: build/docker/Dockerfile.region
- name: Image host
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: registry.cn-beijing.aliyuncs.com/yunionio/host
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: registry.cn-beijing.aliyuncs.com
snapshot: true
dockerfile: build/docker/Dockerfile.host
- name: Image host-deployer
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: registry.cn-beijing.aliyuncs.com/yunionio/host-deployer
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: registry.cn-beijing.aliyuncs.com
snapshot: true
dockerfile: build/docker/Dockerfile.host-deployer
- name: Image baremetal-agent
uses: elgohr/Publish-Docker-Github-Action@master
@@ -81,26 +50,6 @@ jobs:
snapshot: true
dockerfile: build/docker/Dockerfile.baremetal-agent
- name: Image esxi-agent
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: registry.cn-beijing.aliyuncs.com/yunionio/esxi-agent
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: registry.cn-beijing.aliyuncs.com
snapshot: true
dockerfile: build/docker/Dockerfile.esxi-agent
- name: Image vpcagent
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: registry.cn-beijing.aliyuncs.com/yunionio/vpcagent
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: registry.cn-beijing.aliyuncs.com
snapshot: true
dockerfile: build/docker/Dockerfile.vpcagent
- name: Image climc
uses: elgohr/Publish-Docker-Github-Action@master
with:
@@ -131,6 +80,16 @@ jobs:
snapshot: true
dockerfile: build/docker/Dockerfile.logger
- name: Image region
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: registry.cn-beijing.aliyuncs.com/yunionio/region
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: registry.cn-beijing.aliyuncs.com
snapshot: true
dockerfile: build/docker/Dockerfile.region
- name: Image scheduler
uses: elgohr/Publish-Docker-Github-Action@master
with:
@@ -201,7 +160,27 @@ jobs:
snapshot: true
dockerfile: build/docker/Dockerfile.notify
- name: Image cloudevent
- name: Image host
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: registry.cn-beijing.aliyuncs.com/yunionio/host
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: registry.cn-beijing.aliyuncs.com
snapshot: true
dockerfile: build/docker/Dockerfile.host
- name: Image host-deployer
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: registry.cn-beijing.aliyuncs.com/yunionio/host-deployer
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: registry.cn-beijing.aliyuncs.com
snapshot: true
dockerfile: build/docker/Dockerfile.host-deployer
- name: Image cloudevent
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: registry.cn-beijing.aliyuncs.com/yunionio/cloudevent
@@ -220,13 +199,3 @@ jobs:
registry: registry.cn-beijing.aliyuncs.com
snapshot: true
dockerfile: build/docker/Dockerfile.devtool
- name: Image region DNS
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: registry.cn-beijing.aliyuncs.com/yunionio/region-dns
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: registry.cn-beijing.aliyuncs.com
snapshot: true
dockerfile: build/docker/Dockerfile.region-dns

1
.gitignore vendored
View File

@@ -30,7 +30,6 @@ _output
/relay
/structargtest
.idea
.vscode
GPATH
GRTAGS
GTAGS

View File

@@ -10,7 +10,7 @@ BUILD_SCRIPT := $(ROOT_DIR)/build/build.sh
ifeq ($(ONECLOUD_CI_BUILD),)
GIT_COMMIT := $(shell git rev-parse --short HEAD)
GIT_BRANCH := $(shell git name-rev --name-only HEAD)
GIT_VERSION := $(shell git describe --always --tags --abbrev=14 $(GIT_COMMIT)^{commit})
GIT_VERSION := $(shell git describe --tags --abbrev=14 $(GIT_COMMIT)^{commit})
GIT_TREE_STATE := $(shell s=`git status --porcelain 2>/dev/null`; if [ -z "$$s" ]; then echo "clean"; else echo "dirty"; fi)
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
else
@@ -51,7 +51,6 @@ ifdef LIBQEMUIO_PATH
X_CGO_LDFLAGS := ${CGO_LDFLAGS_ENV} -laio -lqemuio -lpthread -L ${LIBQEMUIO_PATH}/src
endif
export GOOS ?= linux
export GO111MODULE:=on
export CGO_CFLAGS = ${X_CGO_CFLAGS}
export CGO_LDFLAGS = ${X_CGO_LDFLAGS}
@@ -76,7 +75,7 @@ install: prepare_dir
gencopyright:
@bash scripts/gencopyright.sh pkg cmd
@sh scripts/gencopyright.sh pkg cmd
test:
@go test $(GO_BUILD_FLAGS) $(shell go list ./... | egrep -v 'host-image|hostimage')
@@ -84,9 +83,6 @@ test:
vet:
go vet ./...
cmd/esxi-agent: prepare_dir
CGO_ENABLED=0 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
cmd/%: prepare_dir
$(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
@@ -188,82 +184,48 @@ dep:
@$(MAKE) mod
mod:
go get -d $(patsubst %,%@master,$(shell GO111MODULE=on go mod edit -print | sed -n -e 's|.*\(yunion.io/x/[a-z].*\) v.*|\1|p'))
go get $(patsubst %,%@master,$(shell GO111MODULE=on go mod edit -print | sed -n -e 's|.*\(yunion.io/x/[a-z].*\) v.*|\1|p'))
go mod tidy
go mod vendor -v
DOCKER_BUILD_IMAGE_VERSION?=1.0-1
DOCKER_BUILD_IMAGE_VERSION?=latest
define dockerCentOSBuildCmd
set -o xtrace
define dockerBuildCmd
set -o errexit
set -o pipefail
cd /root/onecloud
cd /home/build/onecloud
export GOFLAGS=-mod=vendor
make $(1)
chown -R $(shell id -u):$(shell id -g) _output
endef
docker-centos-build: export dockerCentOSBuildCmd:=$(call dockerCentOSBuildCmd,$(F))
docker-centos-build:
docker-build: export dockerBuildCmd:=$(call dockerBuildCmd,$(F))
docker-build:
echo "$$dockerBuildCmd"
docker rm --force onecloud-ci-build &>/dev/null || true
docker run \
--name onecloud-ci-build \
--rm \
--volume $(CURDIR):/root/onecloud \
--volume $(CURDIR)/_output/_cache:/root/.cache \
registry.cn-beijing.aliyuncs.com/yunionio/centos-build:$(DOCKER_BUILD_IMAGE_VERSION) \
/bin/bash -c "$$dockerCentOSBuildCmd"
--volume $(CURDIR):/home/build/onecloud \
yunionio/onecloud-ci:$(DOCKER_BUILD_IMAGE_VERSION) \
/bin/bash -c "$$dockerBuildCmd"
chown -R $$(id -u):$$(id -g) _output
ls -lh _output/bin
# NOTE we need a way to stop and remove the container started by docker-build.
# No --tty, --stop-signal won't work
docker-centos-build-stop:
docker-centos stop --time 0 onecloud-ci-build || true
docker-build-stop:
docker stop --time 0 onecloud-ci-build || true
.PHONY: docker-centos-build
.PHONY: docker-centos-build-stop
define dockerAlpineBuildCmd
set -o xtrace
set -o errexit
set -o pipefail
cd /root/go/src/yunion.io/x/onecloud
export GOFLAGS=-mod=vendor
make $(1)
chown -R $(shell id -u):$(shell id -g) _output
endef
docker-alpine-build: export dockerAlpineBuildCmd:=$(call dockerAlpineBuildCmd,$(F))
docker-alpine-build:
docker rm --force onecloud-docker-alpine-build &>/dev/null || true
docker run --rm \
--name onecloud-docker-alpine-build \
-v $(CURDIR):/root/go/src/yunion.io/x/onecloud \
-v $(CURDIR)/_output/alpine-build:/root/go/src/yunion.io/x/onecloud/_output \
-v $(CURDIR)/_output/alpine-build/_cache:/root/.cache \
registry.cn-beijing.aliyuncs.com/yunionio/alpine-build:1.0-1 \
/bin/sh -c "$$dockerAlpineBuildCmd"
ls -lh _output/alpine-build/bin
docker-alpine-build-stop:
docker stop --time 0 onecloud-docker-alpine-build || true
.PHONY: docker-alpine-build
.PHONY: docker-alpine-build-stop
.PHONY: docker-build
.PHONY: docker-build-stop
define helpText
Build with docker
make docker-centos-build F='-j4'
make docker-centos-build F='-j4 cmd/region cmd/climc'
make docker-centos-build-stop
make docker-alpine-build F='-j4'
make docker-alpine-build F='-j4 cmd/host cmd/host-deployer'
make docker-alpine-build-stop
make docker-build F='-j4'
make docker-build F='-j4 cmd/region cmd/climc'
make docker-build-stop
Tidy up go modules and vendor directory
@@ -291,15 +253,10 @@ gen-swagger: gen-swagger-check
$(ROOT_DIR)/scripts/codegen.py swagger-code
$(ROOT_DIR)/scripts/codegen.py swagger-yaml
swagger-serve-only:
swagger-serve: gen-swagger
$(ROOT_DIR)/scripts/codegen.py swagger-serve
swagger-serve: gen-model-api gen-swagger swagger-serve-only
swagger-site: gen-model-api gen-swagger
$(ROOT_DIR)/scripts/codegen.py swagger-site
.PHONY: gen-model-api-check gen-model-api gen-swagger-check gen-swagger swagger-serve swagger-site
.PHONY: gen-model-api-check gen-model-api gen-swagger-check gen-swagger swagger-serve
REGISTRY ?= "registry.cn-beijing.aliyuncs.com/yunionio"
VERSION ?= $(shell git describe --exact-match 2> /dev/null || \

View File

@@ -1,42 +0,0 @@
#!/bin/bash
set -e
pushd $(dirname $BASH_SOURCE) > /dev/null
CUR_DIR=$(pwd -P)
popd > /dev/null
ACCOUNT=$1
if [ -z "$ACCOUNT" ]; then
echo "Usage: $0 <cloud-acount-id-or-name>"
exit 1
fi
ACCOUNT_ID=$(climc cloud-account-show $ACCOUNT | grep -w " id " | awk '{print $4}')
ACCOUNT_NAME=$(climc cloud-account-show $ACCOUNT | grep -w " name " | awk '{print $4}')
if [ -z "$ACCOUNT_ID" ]; then
echo "Cloud account $ACCOUNT not found"
exit 1
fi
echo "Ready to clean cloud account $ACCOUNT_NAME($ACCOUNT_ID)..."
echo "1. Disable cloud account $ACCOUNT_NAME($ACCOUNT_ID) ..."
climc cloud-account-disable $ACCOUNT_ID
echo "2. Clean all providers ..."
for provider_id in $(climc cloud-provider-list --account $ACCOUNT_ID --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
echo "### to clean cloud provider $provider_id ..."
$CUR_DIR/clean_provider.sh $provider_id
done
echo "3. Delete cloud account ..."
climc cloud-account-delete $ACCOUNT_ID

View File

@@ -1,27 +0,0 @@
#/bin/bash
set -e
EIP=$1
if [ -z "$EIP" ]; then
echo "Usage: $0 <eip_id_or_name>"
exit 1
fi
EIP_NAME=$(climc eip-show $EIP | grep -w " name " | awk '{print $4}')
EIP_ID=$(climc eip-show $EIP | grep -w " id " | awk '{print $4}')
if [ -z "$EIP_ID" ]; then
echo "Cannot find eip $EIP_ID"
exit 1
fi
echo "To clean eip $EIP_NAME($EIP_ID)..."
clean_eip() {
local EID=$1
climc eip-purge $EID
}
clean_eip $EIP_ID

View File

@@ -1,80 +0,0 @@
#!/bin/bash
set -e
HOST=$1
if [ -z "$HOST" ]; then
echo "Usage: $0 <host_id_or_name>"
exit 1
fi
error_exit() {
echo "Error: $1"
exit 1
}
HOSTID=$(climc host-show $HOST | grep -w " id " | awk '{print $4}')
HOSTNAME=$(climc host-show $HOST | grep -w " name " | awk '{print $4}')
if [ -z "$HOSTNAME" ]; then
error_exit "Cannot find host $HOST"
fi
if [ -z "$HOSTID" ]; then
error_exit "Cannot find host $HOST"
fi
echo "Ready to purge host $HOSTNAME($HOSTID)..."
echo "1. Disable $HOSTNAME($HOSTID)"
if ! climc host-disable $HOSTID > /dev/null; then
error_exit "Fail to disable $HOST"
fi
echo "2. Clean servers on $HOSTNAME($HOSTID)"
for i in $(climc server-list --host $HOSTID --admin --limit 2048 --system | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
climc server-update --delete enable $i > /dev/null
climc server-purge $i > /dev/null
done
for i in $(climc server-list --host $HOSTID --admin --limit 2048 --pending-delete --system | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
climc server-purge $i > /dev/null
done
echo "3. Clean disks on $HOSTNAME($HOSTID)"
for storageid in $(climc host-storage-list --host $HOSTID --show-emulated | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $4}')
do
STORAGENAME=$(climc storage-show $storageid | grep -w " name " | awk '{print $4}')
STORAGE_TYPE=$(climc storage-show $storageid | grep -w " storage_type " | awk '{print $4}')
if [ "$STORAGE_TYPE" == "local" ]; then
for diskid in $(climc disk-list --admin --system --details --search $storageid --limit 2048 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
climc disk-purge $diskid > /dev/null
done
for diskid in $(climc disk-list --admin --system --details --search $storageid --pending-delete --limit 2048 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
climc disk-purge $diskid > /dev/null
done
fi
done
echo "4. Remove host $HOSTNAME($HOSTID)"
BAREMETAL=$(climc host-show $HOSTID | grep -w " is_baremetal " | awk '{print $4}')
HOSTTYPE=$(climc host-show $HOSTID | grep -w " host_type " | awk '{print $4}')
if [ "$BAREMETAL" == "true" ] && [ "$HOSTTYPE" != "baremetal" ]; then
climc host-update --host-type baremetal $HOSTID > /dev/null
fi
climc host-delete $HOSTID > /dev/null
echo "DONE."

View File

@@ -1,27 +0,0 @@
#!/bin/bash
set -e
LB=$1
if [ -z "$LB" ]; then
echo "Usage: $0 <loadbalancer_id_or_name>"
exit 1
fi
LB_ID=$(climc lb-show $LB | grep -w " id " | awk '{print $4}')
LB_NAME=$(climc lb-show $LB | grep -w " name " | awk '{print $4}')
if [ -z "$LB_ID" ]; then
echo "Loadbalancer $LB not found"
exit 1
fi
echo "Ready to remove loadbalancer $LB_NAME($LB_ID) ..."
clean_loadbalancer() {
local LID=$1
climc lb-purge $LID
}
clean_loadbalancer $LB_ID

View File

@@ -1,27 +0,0 @@
#!/bin/bash
set -e
LB_ACL=$1
if [ -z "$LB_ACL" ]; then
echo "Usage: $0 <loadbalancer_id_or_name>"
exit 1
fi
LB_ACL_ID=$(climc lbacl-show $LB_ACL | grep -w " id " | awk '{print $4}')
LB_ACL_NAME=$(climc lbacl-show $LB_ACL | grep -w " name " | awk '{print $4}')
if [ -z "$LB_ACL_ID" ]; then
echo "Loadbalancer ACL $LB_ACL_ID not found"
exit 1
fi
echo "Ready to remove loadbalancer acl $LB_ACL_NAME($LB_ACL_ID) ..."
clean_loadbalancer_acl() {
local LID=$1
climc lbacl-purge $LID
}
clean_loadbalancer_acl $LB_ACL_ID

View File

@@ -1,27 +0,0 @@
#!/bin/bash
set -e
LB_CERT=$1
if [ -z "$LB_CERT" ]; then
echo "Usage: $0 <loadbalancer_id_or_name>"
exit 1
fi
LB_CERT_ID=$(climc lbcert-show $LB_CERT | grep -w " id " | awk '{print $4}')
LB_CERT_NAME=$(climc lbcert-show $LB_CERT | grep -w " name " | awk '{print $4}')
if [ -z "$LB_CERT_ID" ]; then
echo "Loadbalancer certificate $LB_CERT_ID not found"
exit 1
fi
echo "Ready to remove loadbalancer certificate $LB_CERT_NAME($LB_CERT_ID) ..."
clean_loadbalancer_cert() {
local LID=$1
climc lbcert-purge $LID
}
clean_loadbalancer_cert $LB_CERT_ID

View File

@@ -1,96 +0,0 @@
#!/bin/bash
set -e
pushd $(dirname $BASH_SOURCE) > /dev/null
CUR_DIR=$(pwd -P)
popd > /dev/null
PROVIDER=$1
if [ -z "$PROVIDER" ]; then
echo "Usage: $0 <cloud-provider-id-or-name>"
exit 1
fi
PROVIDER_ID=$(climc cloud-provider-show $PROVIDER | grep -w " id " | awk '{print $4}')
PROVIDER_NAME=$(climc cloud-provider-show $PROVIDER | grep -w " name " | awk '{print $4}')
if [ -z "$PROVIDER_ID" ]; then
echo "Cloud provider $PROVIDER not found"
exit 1
fi
echo "Ready to clean cloud provider $PROVIDER_NAME($PROVIDER_ID)..."
echo "1. Disable cloud provider $PROVIDER_NAME($PROVIDER_ID) ..."
climc cloud-provider-disable $PROVIDER_ID
echo "2. Clean all hosts ..."
for hostid in $(climc host-list --manager $PROVIDER_ID --admin --show-emulated --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
$CUR_DIR/clean_host.sh $hostid
done
echo "3. Clean all loadbalancer ..."
for lbid in $(climc lb-list --manager $PROVIDER_ID --admin --show-emulated --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
$CUR_DIR/clean_loadbalancer.sh $lbid
done
echo "4. Clean all loadbalancer acl ..."
for lbaclid in $(climc lbacl-list --manager $PROVIDER_ID --admin --show-emulated --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
$CUR_DIR/clean_loadbalancer_acl.sh $lbaclid
done
echo "5. Clean all loadbalancer certificate ..."
for lbcertid in $(climc lbcert-list --manager $PROVIDER_ID --admin --show-emulated --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
$CUR_DIR/clean_loadbalancer_certificate.sh $lbcertid
done
echo "6. Clean all vpc ..."
for vpcid in $(climc vpc-list --manager $PROVIDER_ID --admin --show-emulated --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
$CUR_DIR/clean_vpc.sh $vpcid
done
echo "7. Clean all eips ..."
for eipid in $(climc eip-list --admin --manager $PROVIDER_ID --admin --show-emulated --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
$CUR_DIR/clean_eip.sh $eipid
done
echo "8. Clean all snapshots ..."
for snapid in $(climc snapshot-list --admin --manager $PROVIDER_ID --admin --show-emulated --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
echo "to clean snapshot $snapid ..."
$CUR_DIR/clean_snapshot.sh $snapid
done
echo "9. Clean all storagecache ..."
for cacheid in $(climc storage-cache-list --manager $PROVIDER_ID --admin --show-emulated --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
$CUR_DIR/clean_storagecache.sh $cacheid
done
echo "10. Clean all storages ..."
for storeid in $(climc storage-list --manager $PROVIDER_ID --admin --show-emulated --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
$CUR_DIR/clean_storage.sh $storeid
done
echo "Delete cloud provider ..."
climc cloud-provider-delete $PROVIDER_ID

View File

@@ -1,27 +0,0 @@
#/bin/bash
set -e
SNAPSHOT=$1
if [ -z "$SNAPSHOT" ]; then
echo "Usage: $0 <snapshot_id_or_name>"
exit 1
fi
SNAPSHOT_NAME=$(climc snapshot-show $SNAPSHOT | grep -w " name " | awk '{print $4}')
SNAPSHOT_ID=$(climc snapshot-show $SNAPSHOT | grep -w " id " | awk '{print $4}')
if [ -z "$SNAPSHOT_ID" ]; then
echo "Cannot find snapshot $SNAPSHOT_ID"
exit 1
fi
echo "To clean snapshot $SNAPSHOT_NAME($SNAPSHOT_ID)..."
clean_snapshot() {
local SNAP_ID=$1
climc snapshot-purge $SNAP_ID > /dev/null
}
clean_snapshot $SNAPSHOT_ID

View File

@@ -1,34 +0,0 @@
#!/bin/bash
set -e
STORAGE=$1
if [ -z "$STORAGE" ]; then
echo "Usage: $0 <storage_id_or_name>"
exit 1
fi
STORAGE_ID=$(climc storage-show $STORAGE | grep -w " id " | awk '{print $4}')
STORAGE_NAME=$(climc storage-show $STORAGE | grep -w " name " | awk '{print $4}')
if [ -z "$STORAGE_ID" ]; then
echo "Storage $STORAGE not found"
exit 1
fi
echo "Clean disks on storage $STORAGE_NAME($STORAGE_ID) ..."
for disk_id in $(climc disk-list --admin --storage $STORAGE_ID --show-emulated --limit 2048 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
climc disk-purge $disk_id > /dev/null
done
for disk_id in $(climc disk-list --admin --storage $STORAGE_ID --show-emulated --pending-delete --limit 2048 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
climc disk-purge $disk_id > /dev/null
done
# CACHE_ID=$(climc storage-show $STORAGE_ID | grep -w " storagecache_id " | awk '{print $4}')
climc storage-delete $STORAGE_ID > /dev/null

View File

@@ -1,28 +0,0 @@
#!/bin/bash
set -e
CACHE=$1
if [ -z "$CACHE" ]; then
echo "Usage: $0 <storage_cache_id_or_name>"
exit 1
fi
CACHE_ID=$(climc storage-cache-show $CACHE | grep -w " id " | awk '{print $4}')
CACHE_NAME=$(climc storage-cache-show $CACHE | grep -w " name " | awk '{print $4}')
if [ -z "$CACHE_ID" ]; then
echo "Storage cache $CACHE not found"
exit 1
fi
echo "Ready to remove storagecache $CACHE_NAME($CACHE_ID) ..."
for imgid in $(climc storage-cached-image-list --storagecache $CACHE_ID --show-emulated --limit 0 | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $4}')
do
climc storagecache-uncache-image $CACHE_ID $imgid --force # > /dev/null
done
climc storage-cache-delete $CACHE_ID > /dev/null

View File

@@ -1,55 +0,0 @@
#/bin/bash
set -e
VPC=$1
if [ -z "$VPC" ]; then
echo "Usage: $0 <vpc_id_or_name>"
exit 1
fi
VPC_NAME=$(climc vpc-show $VPC | grep -w " name " | awk '{print $4}')
VPC_ID=$(climc vpc-show $VPC | grep -w " id " | awk '{print $4}')
if [ -z "$VPC_ID" ]; then
echo "Cannot find vpc $VPC"
exit 1
fi
echo "To clean vpc $VPC_NAME($VPC_ID)..."
clean_network() {
climc network-purge $1 > /dev/null
}
clean_wire() {
local WIRE_ID=$1
for net_id in $(climc network-list --admin --wire $WIRE_ID --show-emulated | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
clean_network $net_id
done
climc wire-delete $wire_id > /dev/null
}
clean_vpc() {
local VPC_ID=$1
climc vpc-purge $VPC_ID > /dev/null
}
echo "1. Clean wires ..."
for wire_id in $(climc wire-list --vpc $VPC_ID --show-emulated | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
clean_wire $wire_id
done
echo "2. Clean route tables ..."
for routetable_id in $(climc routetable-list --vpc $VPC_ID --show-emulated | egrep '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | awk '{print $2}')
do
climc routetable-purge $routetable_id >/dev/null
done
echo "3. clean vpc ..."
clean_vpc $VPC_ID

View File

@@ -1,3 +1,3 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/ansibleserver-base:1.0.0
FROM registry.cn-beijing.aliyuncs.com/yunionio/ansibleserver-base:latest
ADD ./_output/alpine-build/bin/ansibleserver /opt/yunion/bin/ansibleserver
ADD ./_output/bin/ansibleserver /opt/yunion/bin/ansibleserver

View File

@@ -1,11 +1,13 @@
FROM alpine:3.11.6
FROM frolvlad/alpine-glibc:glibc-2.28
MAINTAINER "Yousong Zhou <zhouyousong@yunionyun.com>"
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
# openssh-client, for ansible ssh connection
RUN set -x \
&& apk update \
&& apk add openssh-client \
&& apk add ansible \
&& apk add tzdata ca-certificates \
&& rm -rf /var/cache/apk/*
ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
RUN apk update && \
apk add --no-cache tzdata ansible ca-certificates && \
rm -rf /var/cache/apk/*
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

View File

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

View File

@@ -1,4 +1,4 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/baremetal-base:v0.0.1
FROM registry.cn-beijing.aliyuncs.com/yunionio/baremetal-base:latest
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"

View File

@@ -32,8 +32,3 @@ COPY ./opt/cloud/yunion/baremetal/pxelinux.0 /opt/cloud/yunion/baremetal
ADD ./mkisofs /bin/mkisofs
ADD ./.mkisofs.bin /bin/.mkisofs.bin
ADD ./bundles/mkisofs /bin/bundles/mkisofs
# use GNU timeout command replace busybox timeout command
RUN rm /usr/bin/timeout
ADD ./timeout /bin/timeout
ADD ./.timeout.bin /bin/.timeout.bin
ADD ./bundles/timeout /bin/bundles/timeout

View File

@@ -1,5 +1,3 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/climc-base:v20200308
ADD ./build/climc/root/opt /opt
FROM registry.cn-beijing.aliyuncs.com/yunionio/climc-base:latest
ADD ./_output/bin/climc ./_output/bin/*cli /opt/yunion/bin/

View File

@@ -6,7 +6,7 @@ ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
RUN apk add --no-cache bash bash-completion tzdata ca-certificates vim && \
RUN apk add --no-cache bash bash-completion tzdata ca-certificates && \
rm -rf /var/cache/apk/*
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,11 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-base:v0.1.0
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-base
MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com"
ENV TZ Asia/Shanghai
RUN apk add librados librbd
RUN mkdir -p /opt/yunion/bin
ADD ./_output/alpine-build/bin/host /opt/yunion/bin/host
ADD ./_output/bin/host /opt/yunion/bin/host
ADD ./_output/bin/.host.bin /opt/yunion/bin/.host.bin
ADD ./_output/bin/bundles/host /opt/yunion/bin/bundles/host

View File

@@ -1,4 +1,4 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:v0.0.3
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base
MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com"

View File

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

View File

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

View File

@@ -1,4 +0,0 @@
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:v0.1
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
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 curl busybox-extras tcpdump strace ca-certificates && \
apk add --no-cache tzdata 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:v0.1
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
COPY ./build/region/root/opt/ /opt/
ADD ./_output/bin/region /opt/yunion/bin/region

View File

@@ -1,4 +1,3 @@
FROM alpine:3.11.3
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
RUN mkdir -p /opt/yunion/bin
ADD ./_output/alpine-build/bin/region-dns /opt/yunion/bin/region-dns
ADD ./_output/bin/region-dns /opt/yunion/bin/region-dns

View File

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

View File

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

View File

@@ -1,6 +0,0 @@
FROM registry.cn-beijing.aliyuncs.com/yunionio/openvswitch:2.9.6-1
MAINTAINER "Yousong Zhou <zhouyousong@yunion.cn>"
RUN mkdir -p /opt/yunion/bin
ADD ./_output/alpine-build/bin/vpcagent /opt/yunion/bin/vpcagent

View File

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

View File

@@ -1,19 +0,0 @@
[Unit]
Description=Yunion Host Image Server
Documentation=https://docs.yunion.cn
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/yunion/bin/host-image --conf /etc/yunion/host.conf
WorkingDirectory=/opt/yunion/bin
KillMode=process
Restart=always
RestartSec=30
LimitNOFILE=500000
LimitNPROC=500000
[Install]
WantedBy=multi-user.target

View File

@@ -1,2 +0,0 @@
DESCRIPTION="Yunion Host Image Server"
SERVICE="yes"

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
{{.os_type}} 镜像 {{.name}} 上传完成

View File

@@ -1,66 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<table style="width: 650px; margin-bottom: 20px;" border="0" cellpadding="0" cellspacing="0" align="center">
<tr style="height: 50px; background: #333; overflow: hidden;">
<td>
<table style="margin-left: 20px;">
<tr>
<td>
<img src="data:{{.login_logo_format}};base64,{{.login_logo}}" alt="" style="color: #fff; height: 32px; vertical-align: middle;">
</td>
</tr>
</table>
</td>
<td>
<table style="float: right;">
<tr>
<td style="padding-left: 20px; padding-right: 20px;">
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">产品</a>
</td>
<td style="padding-left: 20px; padding-right: 20px;">
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">解决方案</a>
</td>
<td style="padding-left: 20px; padding-right: 20px;">
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">服务</a>
</td>
<td style="padding-left: 20px; padding-right: 20px;">
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">帮助与文档</a>
</td>
<td style="padding-left: 20px; padding-right: 20px;">
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">关于我们</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width: 100%;" colspan="2">
<table style="padding: 20px 10px; width: 100%;">
<tr>
<td style="padding-bottom: 20px;">
亲爱的{{.name}},您好:
</td>
</tr>
<tr>
<td style="padding-bottom: 10px;">请点击下面的链接,完成用户邮箱的激活:</td>
</tr>
<tr>
<td style="padding-bottom: 30px;"><a href="{{.link}}">{{.link}}</a></td>
</tr>
</table>
</td>
</tr>
<tr style="width: 96%;">
<td colspan="2" style="border-top: 1px dashed #ccc; color: #333; font-size: 12px; padding-bottom: 10px; font-weight: 100;">*为了确保您的帐号安全该链接仅48小时内访问有效请勿直接回复此邮件。</td>
</tr>
<tr>
<td colspan="2" style="background: #333; text-align: right; padding-right: 20px; font-size: 12px; color: #fff; height: 50px;">版权所有 © {{.copyright}} 保留一切权利</td>
</tr>
</table>
</body>
</html>

View File

@@ -1 +0,0 @@
镜像 {{.name}} 上传完成

View File

@@ -1 +0,0 @@
Yunion Verify

View File

@@ -84,11 +84,7 @@ func newClient(options *BaseOptions) (*aliyun.SRegion, error) {
return nil, fmt.Errorf("Missing secret")
}
cli, err := aliyun.NewAliyunClient(
aliyun.NewAliyunClientConfig(
options.AccessKey, options.Secret,
).Debug(options.Debug),
)
cli, err := aliyun.NewAliyunClient("", "", options.AccessKey, options.Secret, options.Debug)
if err != nil {
return nil, err
}

View File

@@ -85,13 +85,7 @@ func newClient(options *BaseOptions) (*aws.SRegion, error) {
return nil, fmt.Errorf("Missing secret")
}
cli, err := aws.NewAwsClient(
aws.NewAwsClientConfig(
options.AccessUrl,
options.AccessKey,
options.Secret,
).Debug(options.Debug),
)
cli, err := aws.NewAwsClient("", "", options.AccessUrl, options.AccessKey, options.Secret, options.Debug)
if err != nil {
return nil, err
}

View File

@@ -100,17 +100,11 @@ func newClient(options *BaseOptions) (*azure.SRegion, error) {
return nil, fmt.Errorf("Missing Cloud Environment")
}
cli, err := azure.NewAzureClient(
azure.NewAzureClientConfig(
options.CloudEnv,
options.DirectoryID,
options.ApplicationID,
options.ApplicationKey,
).
SubscriptionId(options.SubscriptionID).
Debug(options.Debug),
)
cli, err := azure.NewAzureClient("", "", options.CloudEnv,
options.DirectoryID,
options.ApplicationID, options.ApplicationKey,
options.SubscriptionID,
options.Debug)
if err != nil {
return nil, err
}

View File

@@ -35,7 +35,6 @@ import (
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudnet"
_ "yunion.io/x/onecloud/cmd/climc/shell/etcd"
_ "yunion.io/x/onecloud/cmd/climc/shell/k8s"
_ "yunion.io/x/onecloud/cmd/climc/shell/monitor"
"yunion.io/x/onecloud/pkg/mcclient"
)

View File

@@ -1,42 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shell
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type BillTasksCreateOptions struct {
options.BaseListOptions
CloudaccountId string `help:"cloudaccount Id" required:"true"`
StartDay int `help:"start day of billing cycle, example: 20060102"`
EndDay int `help:"end day of billing cycle, example: 20060102"`
}
R(&BillTasksCreateOptions{}, "bill-tasks-create", "create bill task",
func(s *mcclient.ClientSession, args *BillTasksCreateOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.BillTasks.Create(s, params)
if err != nil {
return err
}
printObject(result)
return nil
})
}

View File

@@ -1,46 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shell
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type BucketOptionsVerifyOptions struct {
options.BaseListOptions
CloudaccountId string `help:"cloudaccount Id" required:"true"`
BillingReportBucket string `help:"S3 bucket that stores account billing report"`
BillingFilePrefix string `help:"prefix of billing file name"`
BillingBucketAccount string `help:"Id of cloudaccount that can access billing bucket"`
UsageReportBucket string `help:"S3 bucket that stores account usage report"`
UsageFilePrefix string `help:"prefix of usage file name"`
UsageBucketAccount string `help:"Id of cloudaccount that can access usage bucket"`
}
R(&BucketOptionsVerifyOptions{}, "bucket-options-verify", "billing bucket connection test",
func(s *mcclient.ClientSession, args *BucketOptionsVerifyOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.BucketOptions.PerformAction(s, args.CloudaccountId, "verify", params)
if err != nil {
return err
}
printObject(result)
return nil
})
}

View File

@@ -32,22 +32,12 @@ import (
func init() {
type BucketListOptions struct {
options.BaseListOptions
DistinctField string `help:"query specified distinct field"`
}
R(&BucketListOptions{}, "bucket-list", "List all buckets", func(s *mcclient.ClientSession, args *BucketListOptions) error {
params, err := options.ListStructToParams(args)
if err != nil {
return err
}
if len(args.DistinctField) > 0 {
params.Add(jsonutils.NewString(args.DistinctField), "extra_field")
result, err := modules.Buckets.Get(s, "distinct-field", params)
if err != nil {
return err
}
fmt.Println(result)
return nil
}
result, err := modules.Buckets.List(s, params)
if err != nil {
return err
@@ -56,10 +46,10 @@ func init() {
return nil
})
type BucketIdOptions struct {
type BucketShowOptions struct {
ID string `help:"ID or name of bucket"`
}
R(&BucketIdOptions{}, "bucket-show", "Id details of bucket", func(s *mcclient.ClientSession, args *BucketIdOptions) error {
R(&BucketShowOptions{}, "bucket-show", "Show details of bucket", func(s *mcclient.ClientSession, args *BucketShowOptions) error {
result, err := modules.Buckets.Get(s, args.ID, nil)
if err != nil {
return err
@@ -68,15 +58,6 @@ func init() {
return nil
})
R(&BucketIdOptions{}, "bucket-syncstatus", "Sync bucket statust", func(s *mcclient.ClientSession, args *BucketIdOptions) error {
result, err := modules.Buckets.PerformAction(s, args.ID, "syncstatus", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
type BucketUpdateOptions struct {
ID string `help:"ID or name of bucket" json:"-"`
Name string `help:"new name of bucket" json:"name"`

View File

@@ -26,36 +26,10 @@ 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 {
options.BaseListOptions
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
DistinctField string `help:"distinct field"`
ProxySetting string `help:"Proxy setting id or name"`
}
R(&CloudaccountListOptions{}, "cloud-account-list", "List cloud accounts", func(s *mcclient.ClientSession, args *CloudaccountListOptions) error {
var params *jsonutils.JSONDict
@@ -65,21 +39,6 @@ func init() {
if err != nil {
return err
}
if len(args.Capability) > 0 {
params.Add(jsonutils.NewStringArray(args.Capability), "capability")
}
if len(args.ProxySetting) > 0 {
params.Add(jsonutils.NewString(args.ProxySetting), "proxy_setting")
}
}
if len(args.DistinctField) > 0 {
params.Add(jsonutils.NewString(args.DistinctField), "extra_field")
result, err := modules.Cloudaccounts.Get(s, "distinct-field", params)
if err != nil {
return err
}
fmt.Println(result)
return nil
}
result, err := modules.Cloudaccounts.List(s, params)
if err != nil {
@@ -136,9 +95,6 @@ func init() {
if len(args.OptionsBillingBucketAccount) > 0 {
options.Add(jsonutils.NewString(args.OptionsBillingBucketAccount), "billing_bucket_account")
}
if len(args.OptionsBillingFilePrefix) > 0 {
options.Add(jsonutils.NewString(args.OptionsBillingFilePrefix), "billing_file_prefix")
}
if options.Size() > 0 {
params.(*jsonutils.JSONDict).Add(options, "options")
}
@@ -175,7 +131,11 @@ 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")
authParams, err := parseGcpCredential(args.GoogleJsonFile)
data, err := ioutil.ReadFile(args.GoogleJsonFile)
if err != nil {
return err
}
authParams, err := jsonutils.Parse(data)
if err != nil {
return err
}
@@ -200,8 +160,8 @@ func init() {
if len(args.OptionsBillingBucketAccount) > 0 {
options.Add(jsonutils.NewString(args.OptionsBillingBucketAccount), "billing_bucket_account")
}
if len(args.OptionsBillingFilePrefix) > 0 {
options.Add(jsonutils.NewString(args.OptionsBillingFilePrefix), "billing_file_prefix")
if len(args.OptionsBillingFileAccount) > 0 {
options.Add(jsonutils.NewString(args.OptionsBillingFileAccount), "billing_file_account")
}
if options.Size() > 0 {
params.Add(options, "options")
@@ -344,9 +304,6 @@ func init() {
if len(args.OptionsBillingBucketAccount) > 0 {
options.Add(jsonutils.NewString(args.OptionsBillingBucketAccount), "billing_bucket_account")
}
if len(args.OptionsBillingFilePrefix) > 0 {
options.Add(jsonutils.NewString(args.OptionsBillingFilePrefix), "billing_file_prefix")
}
if options.Size() > 0 {
params.Add(options, "options")
}
@@ -357,9 +314,6 @@ func init() {
if args.RemoveOptionsBillingBucketAccount {
removeOptions = append(removeOptions, "billing_bucket_account")
}
if args.RemoveOptionsBillingFilePrefix {
removeOptions = append(removeOptions, "billing_file_prefix")
}
if len(removeOptions) > 0 {
params.Add(jsonutils.NewStringArray(removeOptions), "remove_options")
}
@@ -414,19 +368,6 @@ func init() {
return nil
})
R(&options.SGoogleCloudAccountUpdateOptions{}, "cloud-account-update-google", "update a google cloud account", func(s *mcclient.ClientSession, args *options.SGoogleCloudAccountUpdateOptions) error {
params := jsonutils.Marshal(args).(*jsonutils.JSONDict)
if params.Size() == 0 {
return InvalidUpdateError()
}
result, err := modules.Cloudaccounts.Update(s, args.ID, params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SAWSCloudAccountUpdateOptions{}, "cloud-account-update-aws", "update an AWS cloud account", func(s *mcclient.ClientSession, args *options.SAWSCloudAccountUpdateOptions) error {
params := jsonutils.Marshal(args).(*jsonutils.JSONDict)
@@ -437,8 +378,8 @@ func init() {
if len(args.OptionsBillingBucketAccount) > 0 {
options.Add(jsonutils.NewString(args.OptionsBillingBucketAccount), "billing_bucket_account")
}
if len(args.OptionsBillingFilePrefix) > 0 {
options.Add(jsonutils.NewString(args.OptionsBillingFilePrefix), "billing_file_prefix")
if len(args.OptionsBillingFileAccount) > 0 {
options.Add(jsonutils.NewString(args.OptionsBillingFileAccount), "billing_file_account")
}
if options.Size() > 0 {
params.Add(options, "options")
@@ -450,8 +391,8 @@ func init() {
if args.RemoveOptionsBillingBucketAccount {
removeOptions = append(removeOptions, "billing_bucket_account")
}
if args.RemoveOptionsBillingFilePrefix {
removeOptions = append(removeOptions, "billing_file_prefix")
if args.RemoveOptionsBillingFileAccount {
removeOptions = append(removeOptions, "billing_file_account")
}
if len(removeOptions) > 0 {
params.Add(jsonutils.NewStringArray(removeOptions), "remove_options")
@@ -468,7 +409,7 @@ func init() {
return nil
})
R(&options.SOpenStackCloudAccountUpdateOptions{}, "cloud-account-update-openstack", "update an OpenStack cloud account", func(s *mcclient.ClientSession, args *options.SOpenStackCloudAccountUpdateOptions) error {
R(&options.SOpenStackCloudAccountUpdateOptions{}, "cloud-account-update-openstack", "update an AWS cloud account", func(s *mcclient.ClientSession, args *options.SOpenStackCloudAccountUpdateOptions) error {
params := jsonutils.Marshal(args).(*jsonutils.JSONDict)
if params.Size() == 0 {
return InvalidUpdateError()
@@ -720,19 +661,6 @@ func init() {
return nil
})
R(&options.SGoogleCloudAccountUpdateCredentialOptions{}, "cloud-account-update-credential-google", "Update credential of a Google cloud account", func(s *mcclient.ClientSession, args *options.SGoogleCloudAccountUpdateCredentialOptions) error {
params, err := parseGcpCredential(args.GoogleJsonFile)
if err != nil {
return err
}
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "update-credential", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SS3CloudAccountUpdateCredentialOptions{}, "cloud-account-update-credential-s3", "Update credential of a generic S3 cloud account", func(s *mcclient.ClientSession, args *options.SS3CloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "update-credential", params)
@@ -753,129 +681,6 @@ func init() {
return nil
})
R(&options.SVMwareCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-vmware", "Update credential of a VMware cloud account", func(s *mcclient.ClientSession, args *options.SVMwareCloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SAliyunCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-aliyun", "Update credential of an Aliyun cloud account", func(s *mcclient.ClientSession, args *options.SAliyunCloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SAzureCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-azure", "Update credential of an Azure cloud account", func(s *mcclient.ClientSession, args *options.SAzureCloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SQcloudCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-qcloud", "Update credential of a Qcloud cloud account", func(s *mcclient.ClientSession, args *options.SQcloudCloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SAWSCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-aws", "Update credential of an AWS cloud account", func(s *mcclient.ClientSession, args *options.SAWSCloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SOpenStackCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-openstack", "Update credential of an OpenStack cloud account", func(s *mcclient.ClientSession, args *options.SOpenStackCloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SHuaweiCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-huawei", "Update credential of an Huawei cloud account", func(s *mcclient.ClientSession, args *options.SHuaweiCloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SUcloudCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-ucloud", "Update credential of a Ucloud cloud account", func(s *mcclient.ClientSession, args *options.SUcloudCloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SZStackCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-zstack", "Update credential of a ZStack cloud account", func(s *mcclient.ClientSession, args *options.SZStackCloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SGoogleCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-google", "Update credential of a Google cloud account", func(s *mcclient.ClientSession, args *options.SGoogleCloudAccountUpdateCredentialOptions) error {
params, err := parseGcpCredential(args.GoogleJsonFile)
if err != nil {
return err
}
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SS3CloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-s3", "Update credential of a generic S3 cloud account", func(s *mcclient.ClientSession, args *options.SS3CloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.SCtyunCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-ctyun", "Update credential of an Ctyun cloud account", func(s *mcclient.ClientSession, args *options.SCtyunCloudAccountUpdateCredentialOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
if err != nil {
return err
}
printObject(result)
return nil
})
type CloudaccountSyncOptions struct {
ID string `help:"ID or Name of cloud account"`
Force bool `help:"Force sync no matter what"`
@@ -939,14 +744,10 @@ func init() {
})
type CloudaccountPublicOptions struct {
ID string `help:"ID or name of cloud account" json:"-"`
Scope string `help:"public_sccope" choices:"domain|system" json:"scope"`
SharedDomains []string `help:"shared domains" json:"shared_domains"`
ShareMode string `help:"share_mode" choices:"account_domain|provider_domain|system"`
ID string `help:"ID or name of cloud account"`
}
R(&CloudaccountPublicOptions{}, "cloud-account-public", "Mark this cloud account public ", func(s *mcclient.ClientSession, args *CloudaccountPublicOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "public", params)
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "public", nil)
if err != nil {
return err
}
@@ -1006,47 +807,4 @@ func init() {
printObject(result)
return nil
})
type ClouaccountChangeOwnerOptions struct {
ID string `help:"ID or name of cloudaccount" json:"-"`
ProjectDomain string `json:"project_domain" help:"target domain"`
}
R(&ClouaccountChangeOwnerOptions{}, "cloud-account-change-owner", "Change owner domain of cloudaccount", func(s *mcclient.ClientSession, args *ClouaccountChangeOwnerOptions) error {
if len(args.ProjectDomain) == 0 {
return fmt.Errorf("empty project_domain")
}
params := jsonutils.Marshal(args)
ret, err := modules.Cloudaccounts.PerformAction(s, args.ID, "change-owner", params)
if err != nil {
return err
}
printObject(ret)
return nil
})
type ClouaccountChangeProjectOptions struct {
ID string `help:"ID or name of cloudaccount" json:"-"`
PROJECT string `json:"project" help:"target domain"`
}
R(&ClouaccountChangeProjectOptions{}, "cloud-account-change-project", "Change domain/project of cloudaccount", func(s *mcclient.ClientSession, args *ClouaccountChangeProjectOptions) error {
if len(args.PROJECT) == 0 {
return fmt.Errorf("empty project")
}
params := jsonutils.Marshal(args)
ret, err := modules.Cloudaccounts.PerformAction(s, args.ID, "change-project", params)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&CloudaccountShowOptions{}, "cloud-account-change-owner-candidate-domains", "Show candiate domains of a cloud account changing project", func(s *mcclient.ClientSession, args *CloudaccountShowOptions) error {
result, err := modules.Cloudaccounts.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}

View File

@@ -24,9 +24,6 @@ func init() {
type CloudeventListOptions struct {
options.BaseListOptions
Since string `help:"since time"`
Until string `hlep:"until time"`
}
R(&CloudeventListOptions{}, "cloud-event-list", "List cloud events", func(s *mcclient.ClientSession, opts *CloudeventListOptions) error {
params, err := options.ListStructToParams(opts)

View File

@@ -22,7 +22,7 @@ import (
)
func init() {
R(&options.RouteCreateOptions{}, "router-route-create", "Create router route", func(s *mcclient.ClientSession, opts *options.RouteCreateOptions) error {
R(&options.RouteCreateOptions{}, "router-route-create", "Create router", func(s *mcclient.ClientSession, opts *options.RouteCreateOptions) error {
params, err := base_options.StructToParams(opts)
if err != nil {
return err
@@ -34,7 +34,7 @@ func init() {
printObject(router)
return nil
})
R(&options.RouteGetOptions{}, "router-route-show", "Show router route", func(s *mcclient.ClientSession, opts *options.RouteGetOptions) error {
R(&options.RouteGetOptions{}, "router-route-show", "Show router", func(s *mcclient.ClientSession, opts *options.RouteGetOptions) error {
router, err := modules.Routes.Get(s, opts.ID, nil)
if err != nil {
return err
@@ -42,7 +42,7 @@ func init() {
printObject(router)
return nil
})
R(&options.RouteListOptions{}, "router-route-list", "List router routes", func(s *mcclient.ClientSession, opts *options.RouteListOptions) error {
R(&options.RouteListOptions{}, "router-route-list", "List routers", func(s *mcclient.ClientSession, opts *options.RouteListOptions) error {
params, err := base_options.ListStructToParams(opts)
if err != nil {
return err
@@ -54,7 +54,7 @@ func init() {
printList(result, modules.Routes.GetColumns(s))
return nil
})
R(&options.RouteUpdateOptions{}, "router-route-update", "Update router route", func(s *mcclient.ClientSession, opts *options.RouteUpdateOptions) error {
R(&options.RouteUpdateOptions{}, "router-route-update", "Update router", func(s *mcclient.ClientSession, opts *options.RouteUpdateOptions) error {
params, err := base_options.StructToParams(opts)
router, err := modules.Routes.Update(s, opts.ID, params)
if err != nil {
@@ -63,7 +63,7 @@ func init() {
printObject(router)
return nil
})
R(&options.RouteDeleteOptions{}, "router-route-delete", "Delete router route", func(s *mcclient.ClientSession, opts *options.RouteDeleteOptions) error {
R(&options.RouteDeleteOptions{}, "router-route-delete", "Delete router", func(s *mcclient.ClientSession, opts *options.RouteDeleteOptions) error {
router, err := modules.Routes.Delete(s, opts.ID, nil)
if err != nil {
return err

View File

@@ -1,60 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shell
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type CloudproviderQuotaListOptions struct {
options.BaseListOptions
Cloudregion string `help:"ID or Name of Cloudregion"`
QuotaType string `help:"Quota type"`
QuotaRange string `help:"Quota range" choices:"cloudregion|cloudprovider"`
}
R(&CloudproviderQuotaListOptions{}, "cloud-provider-quota-list", "List cloudprovider quota", func(s *mcclient.ClientSession, args *CloudproviderQuotaListOptions) error {
params, err := args.Params()
if err != nil {
return err
}
if len(args.QuotaType) > 0 {
params.Add(jsonutils.NewString(args.QuotaType), "quota_type")
}
if len(args.QuotaRange) > 0 {
params.Add(jsonutils.NewString(args.QuotaRange), "quota_range")
}
if len(args.Cloudregion) > 0 {
params.Add(jsonutils.NewString(args.Cloudregion), "cloudregion")
}
result, err := modules.CloudproviderQuotas.List(s, params)
if err != nil {
return err
}
printList(result, modules.CloudproviderQuotas.GetColumns(s))
return nil
})
}

View File

@@ -27,8 +27,6 @@ func init() {
type CloudproviderRegionListOptions struct {
options.BaseListOptions
Region string `help:"ID or Name of Host"`
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
}
R(&CloudproviderRegionListOptions{}, "cloud-provider-region-list", "List cloudprovider region synchronization status", func(s *mcclient.ClientSession, args *CloudproviderRegionListOptions) error {
var params *jsonutils.JSONDict

View File

@@ -31,10 +31,8 @@ func init() {
Usable bool `help:"Vpc & Network usable"`
HasObjectStorage bool `help:"filter cloudproviders that has object storage"`
NoObjectStorage bool `help:"filter cloudproviders that has no object storage"`
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
Cloudregion string `help:"filter cloudproviders by cloudregion"`
HasObjectStorage bool `help:"filter cloudproviders that has object storage"`
NoObjectStorage bool `help:"filter cloudproviders that has no object storage"`
}
R(&CloudproviderListOptions{}, "cloud-provider-list", "List cloud providers", func(s *mcclient.ClientSession, args *CloudproviderListOptions) error {
var params *jsonutils.JSONDict
@@ -54,14 +52,6 @@ func init() {
} else if args.NoObjectStorage {
params.Add(jsonutils.JSONFalse, "has_object_storage")
}
if len(args.Capability) > 0 {
params.Add(jsonutils.NewStringArray(args.Capability), "capability")
}
if len(args.Cloudregion) > 0 {
params.Add(jsonutils.NewString(args.Cloudregion), "cloudregion")
}
}
result, err := modules.Cloudproviders.List(s, params)
if err != nil {
@@ -250,13 +240,4 @@ func init() {
printObject(result)
return nil
})
R(&CloudproviderShowOptions{}, "cloud-provider-change-owner-candidate-domains", "Show candiate domains of a cloud provider changing owner", func(s *mcclient.ClientSession, args *CloudproviderShowOptions) error {
result, err := modules.Cloudproviders.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}

View File

@@ -15,8 +15,6 @@
package shell
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
@@ -34,25 +32,12 @@ func init() {
Service string `help:"List regions which service has available skus" choices:"dbinstances|servers"`
City string `help:"List regions in the specified city"`
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
DistinctField string `help:"list the specified distinct field, e.g. city, region"`
}
R(&CloudregionListOptions{}, "cloud-region-list", "List cloud regions", func(s *mcclient.ClientSession, opts *CloudregionListOptions) error {
params, err := options.ListStructToParams(opts)
if err != nil {
return err
}
if len(opts.DistinctField) > 0 {
params.Add(jsonutils.NewString(opts.DistinctField), "extra_field")
result, err := modules.Cloudregions.Get(s, "distinct-field", params)
if err != nil {
return err
}
fmt.Println(result)
return nil
}
result, err := modules.Cloudregions.List(s, params)
if err != nil {
return err
@@ -64,7 +49,7 @@ func init() {
type CloudregionCityListOptions struct {
Manager string `help:"List objects belonging to the cloud provider"`
Account string `help:"List objects belonging to the cloud account"`
Provider string `help:"List objects from the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei|Openstack|Ucloud|ZStack|Google|Ctyun"`
Provider string `help:"List objects from the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei|Openstack|Ucloud|ZStack"`
City string `help:"List regions in the specified city"`
PublicCloud *bool `help:"List objects belonging to public cloud" json:"public_cloud"`

View File

@@ -29,11 +29,11 @@ func init() {
* 操作用户的通信地址(如果用户的通信地址不存在则进行添加;如果已存在则进行修改;如果设置空则进行删除。)
*/
type ContactsUpdateOptions struct {
UID string `help:"The user you wanna add contact to (Keystone User ID)"`
CONTACTTYPE string `help:"The contact type email|mobile" choices:"email|mobile|dingtalk"`
CONTACT string `help:"The contacts details mobile number or email address or dingtalk's userid, if set it the empty str means delete"`
Status string `help:"Enabled or disabled contact status" choices:"enable|disable"`
Pull []string `help:"pull some subcontacts(e.g., dingtalk, feishu, etc) related to mobile"`
UID string `help:"The user you wanna add contact to (Keystone User ID)"`
CONTACTTYPE string `help:"The contact type email|mobile" choices:"email|mobile|dingtalk"`
CONTACT string `help:"The contacts details mobile number or email address or dingtalk's userid, if set it the empty str means delete"`
Status string `help:"Enabled or disabled contact status" choices:"enable|disable"`
UpdateDingtalk bool `help:"if update dingtalk"`
}
R(&ContactsUpdateOptions{}, "contact-update", "Create, delete or update contact for user", func(s *mcclient.ClientSession, args *ContactsUpdateOptions) error {
arr := jsonutils.NewArray()
@@ -52,14 +52,12 @@ func init() {
params := jsonutils.NewDict()
params.Add(arr, "contacts")
pulls := jsonutils.NewArray()
for _, pull := range args.Pull {
pulls.Add(jsonutils.NewString(pull))
if args.UpdateDingtalk {
params.Add(jsonutils.JSONTrue, "update_dingtalk")
}
params.Add(pulls, "pull")
contact, err := modules.Contacts.CustomizedPerformAction(s, args.UID, "update-contact", params)
if err != nil {
return err
}
@@ -68,22 +66,6 @@ func init() {
return nil
})
type ContactsPullOptions struct {
UID string `help:"The user you wanna pull contact"`
CONTACTTYPE string `help:"The contact type"`
}
R(&ContactsPullOptions{}, "contact-pull", "Pull contact", func(s *mcclient.ClientSession, args *ContactsPullOptions) error {
params := jsonutils.NewDict()
params.Set("contacts", jsonutils.NewArray())
params.Set("pull", jsonutils.NewArray(jsonutils.NewString(args.CONTACTTYPE)))
contact, err := modules.Contacts.CustomizedPerformAction(s, args.UID, "update-contact", params)
if err != nil {
return err
}
printObject(contact)
return nil
})
type ContactsDeleteOptions struct {
UID string `help:"The user you wanna add contact to (Keystone User ID)"`
CONTACTTYPE string `help:"The contact type email|mobile|dingtalk" choices:"email|mobile|dingtalk"`

View File

@@ -15,14 +15,7 @@
package shell
import (
"bufio"
"bytes"
"encoding/base64"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
"path/filepath"
"yunion.io/x/jsonutils"
@@ -63,78 +56,4 @@ 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

@@ -38,11 +38,7 @@ func init() {
if err != nil {
return err
}
if len(opts.ExportFile) > 0 {
exportList(result, opts.ExportFile, opts.ExportKeys, opts.ExportTexts, modules.DBInstanceBackups.GetColumns(s))
} else {
printList(result, modules.DBInstanceBackups.GetColumns(s))
}
printList(result, modules.DBInstanceBackups.GetColumns(s))
return nil
})
@@ -84,15 +80,6 @@ func init() {
return nil
})
R(&DBInstanceBackupIdOptions{}, "dbinstance-backup-syncstatus", "Sync DB instance backup status", func(s *mcclient.ClientSession, opts *DBInstanceBackupIdOptions) error {
result, err := modules.DBInstanceBackups.PerformAction(s, opts.ID, "syncstatus", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&DBInstanceBackupIdOptions{}, "dbinstance-backup-delete", "Delete DB instance backup", func(s *mcclient.ClientSession, opts *DBInstanceBackupIdOptions) error {
result, err := modules.DBInstanceBackups.Delete(s, opts.ID, nil)
if err != nil {

View File

@@ -41,12 +41,7 @@ func init() {
if err != nil {
return err
}
if len(opts.ExportFile) > 0 {
exportList(result, opts.ExportFile, opts.ExportKeys, opts.ExportTexts, modules.DBInstance.GetColumns(s))
} else {
printList(result, modules.DBInstance.GetColumns(s))
}
printList(result, modules.DBInstance.GetColumns(s))
return nil
})
@@ -263,24 +258,6 @@ func init() {
return nil
})
R(&DBInstanceIdOptions{}, "dbinstance-syncstatus", "Sync status for DB instance", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
result, err := modules.DBInstance.PerformAction(s, opts.ID, "syncstatus", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&DBInstanceIdOptions{}, "dbinstance-sync", "Sync conf from cloud dbinstance", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
result, err := modules.DBInstance.PerformAction(s, opts.ID, "sync", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&DBInstanceIdOptions{}, "dbinstance-sync-status", "Sync status for DB instance", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
result, err := modules.DBInstance.PerformAction(s, opts.ID, "sync-status", nil)
if err != nil {

View File

@@ -107,7 +107,7 @@ func init() {
R(
&options.DevtoolTemplateBindingOptions{},
"devtooltemplate-unbind",
"UnBinding devtool template to a host/vm",
"Binding devtool template to a host/vm",
func(s *mcclient.ClientSession, opts *options.DevtoolTemplateBindingOptions) error {
params := jsonutils.NewDict()
params.Set("server_id", jsonutils.NewString(opts.ServerID))

View File

@@ -133,15 +133,6 @@ func init() {
return nil
})
R(&DiskDetailOptions{}, "disk-syncstatus", "Sync status for disk", func(s *mcclient.ClientSession, args *DiskDetailOptions) error {
ret, e := modules.Disks.PerformAction(s, args.ID, "syncstatus", nil)
if e != nil {
return e
}
printObject(ret)
return nil
})
type DiskUpdateOptions struct {
ID string `help:"ID or name of disk"`
Name string `help:"New name of disk"`
@@ -291,14 +282,4 @@ func init() {
printObject(srv)
return nil
})
R(&DiskDetailOptions{}, "disk-change-owner-candidate-domains", "Get change owner candidate domain list", func(s *mcclient.ClientSession, args *DiskDetailOptions) error {
result, err := modules.Disks.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}

View File

@@ -1,48 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shell
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
)
func init() {
type DistinctFieldOption struct {
MODULE string `help:"module name"`
FIELD string `help:"distinct field name to query"`
}
R(&DistinctFieldOption{}, "distinct-field", "Query values of a distinct field for a module", func(s *mcclient.ClientSession, args *DistinctFieldOption) error {
mod, err := modulebase.GetModule(s, args.MODULE)
if err != nil || mod == nil {
if err != nil {
return fmt.Errorf("module %s not found %s", args.MODULE, err)
}
return fmt.Errorf("No module %s found", args.MODULE)
}
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.FIELD), "extra_field")
result, err := mod.Get(s, "distinct-field", params)
if err != nil {
return err
}
fmt.Println(result)
return nil
})
}

View File

@@ -83,8 +83,6 @@ func init() {
Desc string `help:"Description"`
Enabled bool `help:"Set the domain enabled"`
Disabled bool `help:"Set the domain disabled"`
Displayname string `help:"display name"`
}
R(&DomainCreateOptions{}, "domain-create", "Create a new domain", func(s *mcclient.ClientSession, args *DomainCreateOptions) error {
params := jsonutils.NewDict()
@@ -97,9 +95,6 @@ func init() {
} else if !args.Enabled && args.Disabled {
params.Add(jsonutils.JSONFalse, "enabled")
}
if len(args.Displayname) > 0 {
params.Add(jsonutils.NewString(args.Displayname), "displayname")
}
result, err := modules.Domains.Create(s, params)
if err != nil {
return err
@@ -115,8 +110,6 @@ func init() {
Enabled bool `help:"Set the domain enabled"`
Disabled bool `help:"Set the domain disabled"`
Driver string `help:"Set the domain Driver"`
Displayname string `help:"display name"`
}
R(&DomainUpdateOptions{}, "domain-update", "Update a domain", func(s *mcclient.ClientSession, args *DomainUpdateOptions) error {
obj, err := modules.Domains.Get(s, args.ID, nil)
@@ -143,9 +136,6 @@ func init() {
} else if !args.Enabled && args.Disabled {
params.Add(jsonutils.JSONFalse, "enabled")
}
if len(args.Displayname) > 0 {
params.Add(jsonutils.NewString(args.Displayname), "displayname")
}
result, err := modules.Domains.Patch(s, objId, params)
if err != nil {
return err

View File

@@ -75,16 +75,6 @@ func init() {
return nil
})
R(&options.ElasticCacheIdOptions{}, "elastic-cache-syncstatus", "Sync elastisc cache instance status", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "syncstatus", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&options.ElasticCacheIdOptions{}, "elastic-cache-delete", "Delete elastisc cache instance", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
result, err := modules.ElasticCache.Delete(s, opts.ID, nil)
if err != nil {

View File

@@ -170,15 +170,6 @@ func init() {
return nil
})
R(&EipSingleOptions{}, "eip-syncstatus", "Synchronize status of an EIP", func(s *mcclient.ClientSession, args *EipSingleOptions) error {
result, err := modules.Elasticips.PerformAction(s, args.ID, "syncstatus", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
type ServerCreateEipOptions struct {
ID string `help:"server ID or name"`
BW int `help:"EIP bandwidth in Mbps"`

View File

@@ -64,15 +64,14 @@ func init() {
})
type EndpointCreateOptions struct {
SERVICE string `help:"Service ID or Name"`
REGION string `help:"Region"`
INTERFACE string `help:"Interface types" choices:"internal|public|admin|console"`
URL string `help:"URL"`
Zone string `help:"Zone"`
Name string `help:"Name"`
Enabled bool `help:"Enabled"`
Disabled bool `help:"Disabled"`
ServiceCertificate string `help:"Service certificate id or name"`
SERVICE string `help:"Service ID or Name"`
REGION string `help:"Region"`
INTERFACE string `help:"Interface types" choices:"internal|public|admin|console"`
URL string `help:"URL"`
Zone string `help:"Zone"`
Name string `help:"Name"`
Enabled bool `help:"Enabled"`
Disabled bool `help:"Disabled"`
}
R(&EndpointCreateOptions{}, "endpoint-create", "Create endpoint", func(s *mcclient.ClientSession, args *EndpointCreateOptions) error {
params := jsonutils.NewDict()
@@ -96,9 +95,6 @@ func init() {
} else if !args.Enabled && args.Disabled {
params.Add(jsonutils.JSONFalse, "enabled")
}
if len(args.ServiceCertificate) > 0 {
params.Add(jsonutils.NewString(args.ServiceCertificate), "service_certificate")
}
ep, err := modules.EndpointsV3.Create(s, params)
if err != nil {
return err
@@ -108,12 +104,11 @@ func init() {
})
type EndpointUpdateOptions struct {
ID string `help:"ID or name of endpoint"`
Url string `help:"URL"`
Name string `help:"Name"`
Enabled bool `help:"Enabled"`
Disabled bool `help:"Disabled"`
ServiceCertificate string `help:"Service certificate id or name"`
ID string `help:"ID or name of endpoint"`
Url string `help:"URL"`
Name string `help:"Name"`
Enabled bool `help:"Enabled"`
Disabled bool `help:"Disabled"`
}
R(&EndpointUpdateOptions{}, "endpoint-update", "Update a endpoint", func(s *mcclient.ClientSession, args *EndpointUpdateOptions) error {
params := jsonutils.NewDict()
@@ -128,9 +123,6 @@ func init() {
} else if !args.Enabled && args.Disabled {
params.Add(jsonutils.JSONFalse, "enabled")
}
if len(args.ServiceCertificate) > 0 {
params.Add(jsonutils.NewString(args.ServiceCertificate), "service_certificate")
}
ep, err := modules.EndpointsV3.Patch(s, args.ID, params)
if err != nil {
return err

View File

@@ -34,11 +34,8 @@ type BaseEventListOptions struct {
OrderBy string `help:"order by specific field"`
Action []string `help:"Log action"`
User string `help:"filter by operator user"`
Project string `help:"filter by operator user's project"`
OwnerProjectIds []string `help:"filter by owner project ids"`
OwnerDomainIds []string `help:"filter by owner domain ids"`
User []string `help:"filter by operator user"`
Project []string `help:"filter by owner project"`
PagingMarker string `help:"marker for pagination"`
}
@@ -102,20 +99,14 @@ func doEventList(man modulebase.ResourceManager, s *mcclient.ClientSession, args
params.Add(jsonutils.NewStringArray(args.Action), "action")
}
if len(args.User) > 0 {
params.Add(jsonutils.NewString(args.User), "user")
params.Add(jsonutils.NewStringArray(args.User), "user")
}
if len(args.Project) > 0 {
params.Add(jsonutils.NewString(args.Project), "project")
params.Add(jsonutils.NewStringArray(args.Project), "project")
}
if len(args.Scope) > 0 {
params.Add(jsonutils.NewString(args.Scope), "scope")
}
if len(args.OwnerProjectIds) > 0 {
params.Add(jsonutils.NewStringArray(args.OwnerProjectIds), "owner_project_ids")
}
if len(args.OwnerDomainIds) > 0 {
params.Add(jsonutils.NewStringArray(args.OwnerDomainIds), "owner_domain_ids")
}
if len(args.PagingMarker) > 0 {
params.Add(jsonutils.NewString(args.PagingMarker), "paging_marker")
}
@@ -225,11 +216,6 @@ func init() {
return doIdentityEventList(s, &nargs)
})
R(&TypeEventListOptions{}, "idp-event", "Show operation event logs of keystone identity provider", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"identity_provider"}}
return doIdentityEventList(s, &nargs)
})
R(&TypeEventListOptions{}, "project-event", "Show operation event logs of keystone projects", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"project"}}
return doIdentityEventList(s, &nargs)

View File

@@ -15,10 +15,6 @@
package shell
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
@@ -52,58 +48,4 @@ func init() {
printObject(result)
return nil
})
type GlobalVpcPublicOptions struct {
ID string `help:"ID or name of global vpc" json:"-"`
Scope string `help:"sharing scope" choices:"system|domain"`
SharedDomains []string `help:"share to domains"`
}
R(&GlobalVpcPublicOptions{}, "global-vpc-public", "Make global vpc public", func(s *mcclient.ClientSession, args *GlobalVpcPublicOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.GlobalVpcs.PerformAction(s, args.ID, "public", params)
if err != nil {
return err
}
printObject(result)
return nil
})
type GlobalVpcPrivateOptions struct {
ID string `help:"ID or name of global vpc" json:"-"`
}
R(&GlobalVpcPrivateOptions{}, "global-vpc-private", "Make global vpc private", func(s *mcclient.ClientSession, args *GlobalVpcPrivateOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.GlobalVpcs.PerformAction(s, args.ID, "private", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&GlobalVpcShowOptions{}, "global-vpc-change-owner-candidate-domains", "Show candiate domains of a global vpc for changing owner", func(s *mcclient.ClientSession, args *GlobalVpcShowOptions) error {
result, err := modules.GlobalVpcs.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
type GlobalVpcChangeOwnerOptions struct {
ID string `help:"ID or name of vpc" json:"-"`
ProjectDomain string `json:"project_domain" help:"target domain"`
}
R(&GlobalVpcChangeOwnerOptions{}, "global-vpc-change-owner", "Change owner domain of a global vpc", func(s *mcclient.ClientSession, args *GlobalVpcChangeOwnerOptions) error {
if len(args.ProjectDomain) == 0 {
return fmt.Errorf("empty project_domain")
}
params := jsonutils.Marshal(args)
ret, err := modules.GlobalVpcs.PerformAction(s, args.ID, "change-owner", params)
if err != nil {
return err
}
printObject(ret)
return nil
})
}

View File

@@ -79,7 +79,7 @@ func init() {
if err != nil {
return err
}
users, err := modules.Groups.GetUsers(s, grpId, nil)
users, err := modules.Groups.GetUsers(s, grpId)
if err != nil {
return err
}
@@ -224,29 +224,4 @@ func init() {
printObject(sp)
return nil
})
type GroupAddUsersOptions struct {
GROUP string `help:"group Id or Name" json:"-"`
USER []string `help:"list of user id or name" json:"user"`
}
R(&GroupAddUsersOptions{}, "group-add-users", "Add users into group",
func(s *mcclient.ClientSession, args *GroupAddUsersOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Groups.PerformAction(s, args.GROUP, "add-users", params)
if err != nil {
return err
}
printObject(result)
return nil
})
R(&GroupAddUsersOptions{}, "group-remove-users", "Add users into group",
func(s *mcclient.ClientSession, args *GroupAddUsersOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Groups.PerformAction(s, args.GROUP, "remove-users", params)
if err != nil {
return err
}
printObject(result)
return nil
})
}

View File

@@ -18,13 +18,11 @@ import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
"yunion.io/x/onecloud/pkg/util/fileutils2"
"yunion.io/x/onecloud/pkg/util/ssh"
)
func init() {
@@ -40,7 +38,7 @@ func init() {
Occupied bool `help:"show occupid host" json:"-"`
Enabled bool `help:"Show enabled host only" json:"-"`
Disabled bool `help:"Show disabled host only" json:"-"`
HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv|aliyun|azure|qcloud|aws|huawei|ucloud|google|ctyun"`
HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv|aliyun|azure|qcloud|aws|huawei|ucloud"`
AnyMac string `help:"Mac matches one of the host's interface"`
IsBaremetal *bool `help:"filter host list by is_baremetal=true|false"`
@@ -57,8 +55,6 @@ func init() {
CdromBoot *bool `help:"filter hosts list by cdrom_boot=true|false"`
Sn string `help:"find host by sn"`
options.BaseListOptions
}
R(&HostListOptions{}, "host-list", "List hosts", func(s *mcclient.ClientSession, opts *HostListOptions) error {
@@ -80,9 +76,6 @@ func init() {
if len(opts.Uuid) > 0 {
params.Add(jsonutils.NewString(opts.Uuid), "uuid")
}
if len(opts.Sn) > 0 {
params.Add(jsonutils.NewString(opts.Sn), "sn")
}
result, err := modules.Hosts.List(s, params)
if err != nil {
return err
@@ -203,36 +196,6 @@ func init() {
return nil
})
R(&HostListOptions{}, "host-node-count", "Get host node count", func(s *mcclient.ClientSession, opts *HostListOptions) error {
params, err := options.ListStructToParams(opts)
if err != nil {
return err
}
if opts.Empty {
params.Add(jsonutils.JSONTrue, "is_empty")
} else if opts.Occupied {
params.Add(jsonutils.JSONFalse, "is_empty")
}
if opts.Enabled {
params.Add(jsonutils.NewInt(1), "enabled")
} else if opts.Disabled {
params.Add(jsonutils.NewInt(0), "enabled")
}
if len(opts.Uuid) > 0 {
params.Add(jsonutils.NewString(opts.Uuid), "uuid")
}
if len(opts.Sn) > 0 {
params.Add(jsonutils.NewString(opts.Sn), "sn")
}
result, err := modules.Hosts.Get(s, "node-count", params)
if err != nil {
return err
}
printObject(result)
return nil
})
type HostUpdateOptions struct {
ID string `help:"ID or Name of Host"`
Name string `help:"New name of the host"`
@@ -696,123 +659,4 @@ func init() {
printObject(result)
return nil
})
type HostSSHLoginOptions struct {
ID string `help:"ID or name of host"`
Port int `help:"SSH service port" default:"22"`
}
R(&HostSSHLoginOptions{}, "host-ssh", "SSH login of a host", func(s *mcclient.ClientSession, args *HostSSHLoginOptions) error {
srvid, e := modules.Hosts.GetId(s, args.ID, nil)
if e != nil {
return e
}
i, e := modules.Hosts.GetLoginInfo(s, srvid, nil)
if e != nil {
return e
}
host, err := i.GetString("ip")
if err != nil {
return err
}
user, err := i.GetString("username")
if err != nil {
return err
}
passwd, err := i.GetString("password")
if err != nil {
return err
}
port := 22
if args.Port != 22 {
port = args.Port
}
sshCli, err := ssh.NewClient(host, port, user, passwd, "")
if err != nil {
return err
}
log.Infof("ssh %s:%d", host, port)
if err := sshCli.RunTerminal(); err != nil {
return err
}
return nil
})
type HostChangeOwnerOptions struct {
ID string `help:"ID or name of host" json:"-"`
ProjectDomain string `json:"project_domain" help:"target domain"`
}
R(&HostChangeOwnerOptions{}, "host-change-owner", "Change owner domain of host", func(s *mcclient.ClientSession, args *HostChangeOwnerOptions) error {
if len(args.ProjectDomain) == 0 {
return fmt.Errorf("empty project_domain")
}
params := jsonutils.Marshal(args)
ret, err := modules.Hosts.PerformAction(s, args.ID, "change-owner", params)
if err != nil {
return err
}
printObject(ret)
return nil
})
type HostPublicOptions struct {
ID string `help:"ID or name of host" json:"-"`
Scope string `help:"sharing scope" choices:"system|domain"`
SharedDomains []string `help:"share to domains"`
}
R(&HostPublicOptions{}, "host-public", "Make a host public", func(s *mcclient.ClientSession, args *HostPublicOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Hosts.PerformAction(s, args.ID, "public", params)
if err != nil {
return err
}
printObject(result)
return nil
})
type HostPrivateOptions struct {
ID string `help:"ID or name of host" json:"-"`
}
R(&HostPrivateOptions{}, "host-private", "Make a host private", func(s *mcclient.ClientSession, args *HostPrivateOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Hosts.PerformAction(s, args.ID, "private", params)
if err != nil {
return err
}
printObject(result)
return nil
})
type HostChangeOwnerCandidateDomainsOptions struct {
ID string `help:"ID or name of host"`
}
R(&HostChangeOwnerCandidateDomainsOptions{}, "host-change-owner-candidate-domains", "Get change owner candidate domain list", func(s *mcclient.ClientSession, args *HostChangeOwnerCandidateDomainsOptions) error {
result, err := modules.Hosts.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
type HostAutoMigrateOnHostDownOptions struct {
ID string `help:"ID or name of host"`
Enable bool `help:"enable auto migrate"`
Disable bool `help:"disable auto migrate"`
}
R(&HostAutoMigrateOnHostDownOptions{}, "host-auto-migrate-on-host-down", "Get change owner candidate domain list", func(s *mcclient.ClientSession, args *HostAutoMigrateOnHostDownOptions) error {
params := jsonutils.NewDict()
if args.Disable {
params.Set("auto_migrate_on_host_down", jsonutils.NewString("disable"))
} else if args.Enable {
params.Set("auto_migrate_on_host_down", jsonutils.NewString("enable"))
} else {
return fmt.Errorf("missing input enable or disable")
}
result, err := modules.Hosts.PerformAction(s, args.ID, "auto-migrate-on-host-down", params)
if err != nil {
return err
}
printObject(result)
return nil
})
}

View File

@@ -23,7 +23,6 @@ import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
func init() {
@@ -295,36 +294,4 @@ func init() {
return nil
})
type IdentityProviderConfigEditOptions struct {
IDP string `help:"identity provider name or ID"`
}
R(&IdentityProviderConfigEditOptions{}, "idp-config-edit", "Edit config yaml of an identity provider", func(s *mcclient.ClientSession, args *IdentityProviderConfigEditOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.JSONTrue, "sensitive")
conf, err := modules.IdentityProviders.GetSpecific(s, args.IDP, "config", params)
if err != nil {
return err
}
confJson, err := conf.Get("config")
if err != nil {
return err
}
content, err := shellutils.Edit(confJson.YAMLString())
if err != nil {
return err
}
yamlJson, err := jsonutils.ParseYAML(content)
if err != nil {
return err
}
config := jsonutils.NewDict()
config.Add(yamlJson, "config")
nconf, err := modules.IdentityProviders.PerformAction(s, args.IDP, "config", config)
if err != nil {
return err
}
fmt.Println(nconf.PrettyString())
return nil
})
}

View File

@@ -34,7 +34,6 @@ type ImageOptionalOptions struct {
Unprotected bool `help:"Allow image to be deleted"`
Standard bool `help:"Mark image as a standard image"`
Nonstandard bool `help:"Mark image as a non-standard image"`
Public bool `help:"make image public"`
MinDisk int64 `help:"Disk size after expanded, in MB" metavar:"MIN_DISK_SIZE_MB"`
MinRam int64 `help:"Minimal memory size required" metavar:"MIN_RAM_MB"`
VirtualSize int64 `help:"Disk size after expanded, in MB"`
@@ -51,14 +50,14 @@ type ImageOptionalOptions struct {
OsLang string `help:"OS Language" choices:"zh_CN|en_US"`
Preference int64 `help:"Disk preferences"`
Notes string `help:"Notes about the image"`
Hypervisor []string `help:"Prefer hypervisor type" choices:"kvm|esxi|baremetal|container|openstack|ctyun"`
Hypervisor []string `help:"Prefer hypervisor type" choices:"kvm|esxi|baremetal|container|openstack"`
DiskDriver string `help:"Perfer disk driver" choices:"virtio|scsi|pvscsi|ide|sata"`
NetDriver string `help:"Preferred network driver" choices:"virtio|e1000|vmxnet3"`
DisableUsbKbd bool `help:"Disable usb keyboard on this image(for hypervisor kvm)"`
}
func addImageOptionalOptions(s *mcclient.ClientSession, params *jsonutils.JSONDict, args ImageOptionalOptions) error {
if len(args.Format) > 0 {
params.Add(jsonutils.NewString("bare"), "container-format")
params.Add(jsonutils.NewString(args.Format), "disk-format")
}
if args.Protected && !args.Unprotected {
@@ -71,9 +70,6 @@ func addImageOptionalOptions(s *mcclient.ClientSession, params *jsonutils.JSONDi
} else if !args.Standard && args.Nonstandard {
params.Add(jsonutils.JSONFalse, "is_standard")
}
if args.Public {
params.Add(jsonutils.JSONTrue, "is_public")
}
if args.MinDisk > 0 {
params.Add(jsonutils.NewString(fmt.Sprintf("%d", args.MinDisk)), "min_disk")
}
@@ -132,9 +128,6 @@ func addImageOptionalOptions(s *mcclient.ClientSession, params *jsonutils.JSONDi
if len(args.Hypervisor) > 0 {
params.Add(jsonutils.NewString(strings.Join(args.Hypervisor, ",")), "properties", "hypervisor")
}
if args.DisableUsbKbd {
params.Add(jsonutils.NewString("true"), "properties", "disable_usb_kbd")
}
return nil
}
@@ -147,7 +140,6 @@ func init() {
Protected string `help:"filter images by protected" choices:"true|false"`
IsUefi bool `help:"list uefi image"`
Format []string `help:"Disk formats"`
SubFormats []string `help:"Sub formats"`
Name string `help:"Name filter"`
}
R(&ImageListOptions{}, "image-list", "List images", func(s *mcclient.ClientSession, args *ImageListOptions) error {
@@ -178,14 +170,15 @@ func init() {
params.Add(jsonutils.NewString(args.Name), "name")
}
if len(args.Format) > 0 {
fs := jsonutils.NewArray()
for _, f := range args.Format {
fs.Add(jsonutils.NewString(f))
if len(args.Format) == 1 {
params.Add(jsonutils.NewString(args.Format[0]), "disk_format")
} else {
fs := jsonutils.NewArray()
for _, f := range args.Format {
fs.Add(jsonutils.NewString(f))
}
params.Add(fs, "disk_formats")
}
params.Add(fs, "disk_formats")
}
if len(args.SubFormats) > 0 {
params.Add(jsonutils.Marshal(args.SubFormats), "sub_formats")
}
result, err := modules.Images.List(s, params)
if err != nil {
@@ -251,12 +244,28 @@ func init() {
return nil
})
type ImageMembershipOptions struct {
IMAGE string `help:"ID or name of image to share"`
PROJECT string `help:"ID or name of project to share image with"`
}
type ImageMembershipAddOptions struct {
ImageMembershipOptions
CanShare bool `help:"Indicating whether the project can share the image with others"`
}
R(&ImageMembershipAddOptions{}, "image-add-project", "Add a project to private image's membership list", func(s *mcclient.ClientSession, args *ImageMembershipAddOptions) error {
return modules.Images.AddMembership(s, args.IMAGE, args.PROJECT, args.CanShare)
})
R(&ImageMembershipOptions{}, "image-remove-project", "Remove a project from private image's membership list", func(s *mcclient.ClientSession, args *ImageMembershipOptions) error {
return modules.Images.RemoveMembership(s, args.IMAGE, args.PROJECT)
})
type ImageDetailOptions struct {
ID string `help:"Image ID or name"`
}
type ImageDeleteOptions struct {
ID []string `help:"Image ID or name" json:"-"`
ID []string `help:"Image ID or name"`
OverridePendingDelete *bool `help:"Delete image directly instead of pending delete" short-token:"f"`
}
R(&ImageDeleteOptions{}, "image-delete", "Delete a image", func(s *mcclient.ClientSession, args *ImageDeleteOptions) error {
@@ -269,6 +278,19 @@ func init() {
return nil
})
R(&ImageDetailOptions{}, "image-list-project", "List image members", func(s *mcclient.ClientSession, args *ImageDetailOptions) error {
imgId, e := modules.Images.GetId(s, args.ID, nil)
if e != nil {
return e
}
result, e := modules.Images.ListMemberProjects(s, imgId)
if e != nil {
return e
}
printList(result, modules.Projects.GetColumns(s))
return nil
})
type ImageCancelDeleteOptions struct {
ID string `help:"Image id or name" metavar:"IMAGE"`
}
@@ -394,12 +416,14 @@ func init() {
type ImagePublicOptions struct {
ID []string `help:"ID or name of image" json:"-"`
Scope string `help:"sharing scope" choices:"system|domain|project"`
SharedProjects []string `help:"Share to projects"`
SharedDomains []string `help:"Share to domains"`
Scope string `help:"sharing scope" choices:"system|domain"`
ShareToProject []string `help:"Share to prject"`
}
R(&ImagePublicOptions{}, "image-public", "Make a image public", func(s *mcclient.ClientSession, args *ImagePublicOptions) error {
params := jsonutils.Marshal(args)
params, err := options.StructToParams(args)
if err != nil {
return err
}
if len(args.ID) == 0 {
return fmt.Errorf("No image ID provided")
} else if len(args.ID) == 1 {

View File

@@ -68,7 +68,7 @@ func init() {
type HistoricProcessInstanceStaticticsOptions struct {
ID string `help:"ID of user"`
}
R(&HistoricProcessInstanceStaticticsOptions{}, "historic-process-instance-statistics", "Show statistics for historic process instance", func(s *mcclient.ClientSession, args *HistoricProcessInstanceStaticticsOptions) error {
R(&HistoricProcessInstanceStaticticsOptions{}, "historic-process-instance-statistics", "Delete all contacts for the user", func(s *mcclient.ClientSession, args *HistoricProcessInstanceStaticticsOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.ID), "user_id")

View File

@@ -205,70 +205,4 @@ func initKubeCluster() {
printObject(ret)
return nil
})
R(&o.IdentOptions{}, cmdN("components-status"), "Get cluster component status", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
ret, err := k8s.KubeClusters.GetSpecific(s, args.ID, "components-status", nil)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&o.ClusterComponentTypeOptions{}, cmdN("component-setting"), "Get cluster component setting", func(s *mcclient.ClientSession, args *o.ClusterComponentTypeOptions) error {
q := jsonutils.NewDict()
q.Add(jsonutils.NewString(args.TYPE), "type")
ret, err := k8s.KubeClusters.GetSpecific(s, args.ID, "component-setting", q)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&o.ClusterEnableComponentCephCSIOpt{}, cmdN("component-enable-ceph-csi"), "Enable cluster component", func(s *mcclient.ClientSession, args *o.ClusterEnableComponentCephCSIOpt) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "enable-component", params)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&o.ClusterDisableComponent{}, cmdN("component-disable"), "Enable cluster component", func(s *mcclient.ClientSession, args *o.ClusterDisableComponent) error {
params := args.Params()
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "disable-component", params)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&o.ClusterDisableComponent{}, cmdN("component-delete"), "Delete cluster component", func(s *mcclient.ClientSession, args *o.ClusterDisableComponent) error {
params := args.Params()
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "delete-component", params)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&o.ClusterUpdateComponentCephCSIOpt{}, cmdN("component-update-ceph-csi"), "Update cluster component", func(s *mcclient.ClientSession, args *o.ClusterUpdateComponentCephCSIOpt) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "update-component", params)
if err != nil {
return err
}
printObject(ret)
return nil
})
}

View File

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

View File

@@ -16,11 +16,6 @@ package k8s
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"github.com/ghodss/yaml"
"yunion.io/x/jsonutils"
@@ -62,7 +57,7 @@ func init() {
initPVC()
initJob()
initCronJob()
initEvent()
initRbac()
initApp()
@@ -222,71 +217,6 @@ 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{},
@@ -314,13 +244,11 @@ func NewK8sNsResourceDeleteCmd(cmdN CmdNameFactory, manager modulebase.Manager)
return deleteCmd
}
func initK8sNamespaceResource(kind string, manager k8s.IClusterResourceManager) *ShellCommands {
func initK8sNamespaceResource(kind string, manager modulebase.Manager) *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

@@ -40,40 +40,22 @@ func initSecret() {
})
secretCmd.AddR(listCmd)
registryCmd := NewCmdNameFactory("secret-registry")
registryCreateCmd := NewCommand(
registryCmd := initK8sNamespaceResource("registrysecret", k8s.RegistrySecrets)
createCmd := NewCommand(
&o.RegistrySecretCreateOptions{},
registryCmd.Do("create"),
"Create docker registry secret secret",
registryCmd.CommandNameFactory("create"),
"Create docker registry secret resource",
func(s *mcclient.ClientSession, args *o.RegistrySecretCreateOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := k8s.Secrets.Create(s, params)
ret, err := k8s.RegistrySecrets.Create(s, params)
if err != nil {
return err
}
printObject(ret)
return nil
})
cephCSICmd := NewCmdNameFactory("secret-ceph-csi")
cephCSICreateCmd := NewCommand(
&o.CephCSISecretCreateOptions{},
cephCSICmd.Do("create"),
"Create ceph csi user secret",
func(s *mcclient.ClientSession, args *o.CephCSISecretCreateOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := k8s.Secrets.Create(s, params)
if err != nil {
return err
}
printObject(ret)
return nil
})
secretCmd.AddR(cephCSICreateCmd, registryCreateCmd)
registryCmd.AddR(createCmd)
}

View File

@@ -15,70 +15,9 @@
package k8s
import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
o "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
)
func initStorageClass() {
cmdN := NewCmdNameFactory("storageclass")
scCmd := initK8sClusterResource("storageclass", k8s.Storageclass)
setDefaultCmd := NewCommand(
&o.ClusterResourceBaseOptions{},
cmdN.Do("set-default"),
"Set storageclass as default",
func(s *mcclient.ClientSession, args *o.ClusterResourceBaseOptions) error {
ret, err := k8s.Storageclass.PerformAction(s, args.NAME, "set-default", args.Params())
if err != nil {
return err
}
printObject(ret)
return nil
},
)
scCmd.AddR(setDefaultCmd)
addStorageClassCephCSI(scCmd)
}
func addStorageClassCephCSI(cmd *ShellCommands) {
rbdN := NewCmdNameFactory("storageclass-ceph-csi-rbd")
rbdCreateCmd := NewCommand(
&o.StorageClassCephCSIRBDCreateOptions{},
rbdN.Do("create"),
"Create ceph csi rbd",
func(s *mcclient.ClientSession, args *o.StorageClassCephCSIRBDCreateOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := k8s.Storageclass.Create(s, params)
if err != nil {
return err
}
printObject(ret)
return nil
},
)
testConnCmd := NewCommand(
&o.StorageClassCephCSIRBDTestOptions{},
rbdN.Do("connection-test"),
"Test storageclass connection",
func(s *mcclient.ClientSession, args *o.StorageClassCephCSIRBDTestOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := k8s.Storageclass.PerformClassAction(s, "connection-test", params)
if err != nil {
return err
}
printObject(ret)
return nil
},
)
cmd.AddR(rbdCreateCmd, testConnCmd)
initK8sClusterResource("storageclass", k8s.Storageclass)
}

View File

@@ -51,10 +51,9 @@ func init() {
})
type KeypairCreate struct {
NAME string `help:"Name of keypair to be created"`
Scheme string `help:"Scheme of keypair, default is RSA" choices:"RSA" default:"RSA"`
PublicKey string `help:"Publickey of keypair"`
Desc string `help:"Short description of keypair"`
NAME string `help:"Name of keypair to be created"`
Scheme string `help:"Scheme of keypair, default is RSA" choices:"RSA|DSA" default:"RSA"`
Desc string `help:"Short description of keypair"`
}
R(&KeypairCreate{}, "keypair-create", "Create a new keypair", func(s *mcclient.ClientSession, args *KeypairCreate) error {
@@ -64,10 +63,6 @@ func init() {
params.Add(jsonutils.NewString(args.Scheme), "scheme")
}
if len(args.PublicKey) > 0 {
params.Add(jsonutils.NewString(args.PublicKey), "public_key")
}
if len(args.Desc) > 0 {
params.Add(jsonutils.NewString(args.Desc), "description")
}

View File

@@ -65,7 +65,7 @@ func init() {
printList(result, modules.LoadbalancerClusters.GetColumns(s))
return nil
})
R(&options.LoadbalancerClusterDeleteOptions{}, "lbcluster-delete", "Delete lbcluster", func(s *mcclient.ClientSession, opts *options.LoadbalancerClusterDeleteOptions) error {
R(&options.LoadbalancerClusterDeleteOptions{}, "lbcluster-delete", "Show lbcluster", func(s *mcclient.ClientSession, opts *options.LoadbalancerClusterDeleteOptions) error {
lbagent, err := modules.LoadbalancerClusters.Delete(s, opts.ID, nil)
if err != nil {
return err

View File

@@ -99,13 +99,4 @@ func init() {
return nil
})
R(&options.LoadbalancerGetOptions{}, "lb-change-owner-candidate-domains", "Get change owner candidate domain list", func(s *mcclient.ClientSession, args *options.LoadbalancerGetOptions) error {
result, err := modules.Loadbalancers.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}

View File

@@ -16,7 +16,6 @@ package shell
import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
@@ -44,12 +43,7 @@ func init() {
if err != nil {
return err
}
listResult := modulebase.ListResult{}
err = result.Unmarshal(&listResult)
if err != nil {
return err
}
printList(&listResult, []string{})
printObject(result)
return nil
})

View File

@@ -1,116 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
import (
"fmt"
monitorapi "yunion.io/x/onecloud/pkg/apis/monitor"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
aN := cmdN("alert")
R(&options.AlertListOptions{}, aN("list"), "List all alerts",
func(s *mcclient.ClientSession, args *options.AlertListOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.Alerts.List(s, params)
if err != nil {
return err
}
printList(ret, monitor.Alerts.GetColumns(s))
return nil
})
R(&options.AlertCreateOptions{}, aN("create"), "Create alert rule",
func(s *mcclient.ClientSession, args *options.AlertCreateOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.Alerts.DoCreate(s, params)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.AlertShowOptions{}, aN("show"), "Show details of a alert rule",
func(s *mcclient.ClientSession, args *options.AlertShowOptions) error {
ret, err := monitor.Alerts.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.AlertUpdateOptions{}, aN("update"), "Update a alert rule",
func(s *mcclient.ClientSession, args *options.AlertUpdateOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.Alerts.Update(s, args.ID, params.JSON(params))
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.AlertDeleteOptions{}, aN("delete"), "Delete alerts",
func(s *mcclient.ClientSession, args *options.AlertDeleteOptions) error {
ret := monitor.Alerts.BatchDelete(s, args.ID, nil)
printBatchResults(ret, monitor.Alerts.GetColumns(s))
return nil
})
R(&options.AlertTestRunOptions{}, aN("test-run"), "Test run alert",
func(s *mcclient.ClientSession, args *options.AlertTestRunOptions) error {
data := new(monitorapi.AlertTestRunInput)
if args.Debug {
data.IsDebug = true
}
ret, err := monitor.Alerts.DoTestRun(s, args.ID, data)
if err != nil {
return err
}
fmt.Println(ret.JSON(ret).YAMLString())
return nil
})
R(&options.AlertPauseOptions{}, aN("pause"), "Pause or unpause alert",
func(s *mcclient.ClientSession, args *options.AlertPauseOptions) error {
data := new(monitorapi.AlertPauseInput)
if args.UnPause {
data.Paused = false
} else {
data.Paused = true
}
ret, err := monitor.Alerts.PerformAction(s, args.ID, "pause", data.JSON(data))
if err != nil {
return err
}
printObject(ret)
return nil
})
}

View File

@@ -1,74 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
import (
monitorapi "yunion.io/x/onecloud/pkg/apis/monitor"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
initAlertNotification()
}
func initAlertNotification() {
aN := cmdN("alert-notification")
R(&options.AlertNotificationListOptions{}, aN("list"), "List alert notification pairs",
func(s *mcclient.ClientSession, args *options.AlertNotificationListOptions) error {
params, err := args.Params()
if err != nil {
return err
}
var result *modulebase.ListResult
if len(args.Alert) > 0 {
result, err = monitor.Alertnotification.ListDescendent(s, args.Alert, params)
} else if len(args.Notification) > 0 {
result, err = monitor.Alertnotification.ListDescendent2(s, args.Notification, params)
} else {
result, err = monitor.Alertnotification.List(s, params)
}
if err != nil {
return err
}
printList(result, monitor.Alertnotification.GetColumns(s))
return nil
})
R(&options.AlertNotificationAttachOptions{}, aN("attach"), "Attach a notification to a alert",
func(s *mcclient.ClientSession, args *options.AlertNotificationAttachOptions) error {
input := &monitorapi.AlertnotificationCreateInput{
UsedBy: args.UsedBy,
}
ret, err := monitor.Alertnotification.Attach(s, args.ALERT, args.NOTIFICATION, input.JSON(input))
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.AlertNotificationAttachOptions{}, aN("detach"), "Detach a notification to a alert",
func(s *mcclient.ClientSession, args *options.AlertNotificationAttachOptions) error {
ret, err := monitor.Alertnotification.Detach(s, args.ALERT, args.NOTIFICATION, nil)
if err != nil {
return err
}
printObject(ret)
return nil
})
}

View File

@@ -1,27 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
import (
"yunion.io/x/onecloud/cmd/climc/shell"
"yunion.io/x/onecloud/pkg/util/printutils"
)
var (
R = shell.R
printList = printutils.PrintJSONList
printObject = printutils.PrintJSONObject
printBatchResults = printutils.PrintJSONBatchResults
)

View File

@@ -1,56 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
import (
"fmt"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func cmdN(suffix string) func(action string) string {
return func(action string) string {
return fmt.Sprintf("monitor-%s-%s", suffix, action)
}
}
func init() {
dsN := cmdN("datasource")
R(&options.DataSourceListOptions{}, dsN("list"), "List all monitor data source",
func(s *mcclient.ClientSession, args *options.DataSourceListOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.DataSources.List(s, params)
if err != nil {
return err
}
printList(ret, monitor.DataSources.GetColumns(s))
return nil
})
R(&options.DataSourceDeleteOptions{}, dsN("delete"), "Delete monitor data source",
func(s *mcclient.ClientSession, args *options.DataSourceDeleteOptions) error {
ret, err := monitor.DataSources.Delete(s, args.ID, nil)
if err != nil {
return err
}
printObject(ret)
return nil
})
}

View File

@@ -1,99 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
nN := cmdN("notification")
R(&options.NotificationListOptions{}, nN("list"), "List all alert notification",
func(s *mcclient.ClientSession, args *options.NotificationListOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.Notifications.List(s, params)
if err != nil {
return err
}
printList(ret, monitor.Notifications.GetColumns(s))
return nil
})
R(&options.NotificationDingDingCreateOptions{}, nN("create-dingding"),
"Create dingding alert notification",
func(s *mcclient.ClientSession, args *options.NotificationDingDingCreateOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.Notifications.Create(s, params.JSON(params))
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.NotificationFeishuCreateOptions{}, nN("create-feishu"),
"Create feishu alert notification",
func(s *mcclient.ClientSession, args *options.NotificationFeishuCreateOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.Notifications.Create(s, params.JSON(params))
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.NotificationShowOptions{}, nN("show"), "Show alert notification",
func(s *mcclient.ClientSession, args *options.NotificationShowOptions) error {
ret, err := monitor.Notifications.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.NotificationUpdateOptions{}, nN("update"), "Update alert notification",
func(s *mcclient.ClientSession, args *options.NotificationUpdateOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.Notifications.Update(s, args.ID, params.JSON(params))
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.NotificationDeleteOptions{}, nN("delete"), "Show delete notification",
func(s *mcclient.ClientSession, args *options.NotificationDeleteOptions) error {
ret := monitor.Notifications.BatchDelete(s, args.ID, nil)
printBatchResults(ret, monitor.Notifications.GetColumns(s))
return nil
})
}

View File

@@ -1,53 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
aN := cmdN("suggestsysalert")
R(&options.SuggestSysAlertListOptions{}, aN("list"), "List all suggestsysrules",
func(s *mcclient.ClientSession, args *options.SuggestSysAlertListOptions) error {
params, err := args.Params()
if err != nil {
return err
}
if len(args.Type) > 0 {
params.Add(jsonutils.NewString(args.Type), "type")
}
ret, err := monitor.SuggestSysAlertManager.List(s, params)
if err != nil {
return err
}
printList(ret, monitor.SuggestSysAlertManager.GetColumns(s))
return nil
})
R(&options.SSuggestAlertShowOptions{}, aN("show"), "Show details of a alert rule",
func(s *mcclient.ClientSession, args *options.SSuggestAlertShowOptions) error {
ret, err := monitor.SuggestSysAlertManager.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(ret)
return nil
})
}

View File

@@ -1,84 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
aN := cmdN("suggestsysrule")
R(&options.SuggestRuleListOptions{}, aN("list"), "List all suggestsysrules",
func(s *mcclient.ClientSession, args *options.SuggestRuleListOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.SuggestSysRuleManager.List(s, params)
if err != nil {
return err
}
printList(ret, monitor.SuggestSysRuleManager.GetColumns(s))
return nil
})
R(&options.SuggestRuleCreateOptions{}, aN("create"), "Create suggestsys rule",
func(s *mcclient.ClientSession, args *options.SuggestRuleCreateOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.SuggestSysRuleManager.Create(s, params)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.SuggestRuleShowOptions{}, aN("show"), "Show details of a alert rule",
func(s *mcclient.ClientSession, args *options.SuggestRuleShowOptions) error {
ret, err := monitor.SuggestSysRuleManager.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.SuggestRuleUpdateOptions{}, aN("update"), "Update a alert rule",
func(s *mcclient.ClientSession, args *options.SuggestRuleUpdateOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := monitor.SuggestSysRuleManager.Update(s, args.ID, params)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&options.SuggestRuleDeleteOptions{}, aN("delete"), "Delete alerts",
func(s *mcclient.ClientSession, args *options.SuggestRuleDeleteOptions) error {
ret := monitor.SuggestSysRuleManager.BatchDelete(s, args.ID, nil)
printBatchResults(ret, monitor.SuggestSysRuleManager.GetColumns(s))
return nil
})
}

View File

@@ -35,7 +35,7 @@ func init() {
return nil
})
R(&options.NatGatewayIdOptions{}, "natgateway-show", "Show a NAT gateway", func(s *mcclient.ClientSession, args *options.NatGatewayIdOptions) error {
R(&options.NatGatewayShowOptions{}, "natgateway-show", "Show a NAT gateway", func(s *mcclient.ClientSession, args *options.NatGatewayShowOptions) error {
results, err := modules.NatGateways.Get(s, args.ID, nil)
if err != nil {
return err
@@ -44,15 +44,6 @@ func init() {
return nil
})
R(&options.NatGatewayIdOptions{}, "natgateway-syncstatus", "Sync NAT gateway status", func(s *mcclient.ClientSession, args *options.NatGatewayIdOptions) error {
result, err := modules.NatGateways.PerformAction(s, args.ID, "syncstatus", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
type NatGatewayListEipOptions struct {
ID string `help:"ID"`
}

View File

@@ -38,7 +38,6 @@ func init() {
City string `help:"search networks belongs to a city"`
Usable *bool `help:"search usable networks"`
ServerType string `help:"search networks belongs to a ServerType" choices:"guest|baremetal|container|pxe|ipmi"`
Schedtag string `help:"filter networks by schedtag"`
Status string `help:"filter by network status"`
}
@@ -56,11 +55,7 @@ func init() {
if err != nil {
return err
}
if len(opts.ExportFile) > 0 {
exportList(result, opts.ExportFile, opts.ExportKeys, opts.ExportTexts, modules.Networks.GetColumns(s))
} else {
printList(result, modules.Networks.GetColumns(s))
}
printList(result, modules.Networks.GetColumns(s))
return nil
})
@@ -144,10 +139,10 @@ func init() {
return nil
})
type NetworkIdOptions struct {
type NetworkShowOptions struct {
ID string `help:"ID or Name of the zone to show"`
}
R(&NetworkIdOptions{}, "network-show", "Show network details", func(s *mcclient.ClientSession, args *NetworkIdOptions) error {
R(&NetworkShowOptions{}, "network-show", "Show network details", func(s *mcclient.ClientSession, args *NetworkShowOptions) error {
result, err := modules.Networks.Get(s, args.ID, nil)
if err != nil {
return err
@@ -156,7 +151,7 @@ func init() {
return nil
})
R(&NetworkIdOptions{}, "network-metadata", "Show metadata of a network", func(s *mcclient.ClientSession, args *NetworkIdOptions) error {
R(&NetworkShowOptions{}, "network-metadata", "Show metadata of a network", func(s *mcclient.ClientSession, args *NetworkShowOptions) error {
result, err := modules.Networks.GetMetadata(s, args.ID, nil)
if err != nil {
return err
@@ -165,7 +160,7 @@ func init() {
return nil
})
R(&NetworkIdOptions{}, "network-private", "Make a network private", func(s *mcclient.ClientSession, args *NetworkIdOptions) error {
R(&NetworkShowOptions{}, "network-private", "Make a network private", func(s *mcclient.ClientSession, args *NetworkShowOptions) error {
result, err := modules.Networks.PerformAction(s, args.ID, "private", nil)
if err != nil {
return err
@@ -174,23 +169,16 @@ func init() {
return nil
})
R(&NetworkIdOptions{}, "network-syncstatus", "Sync network status", func(s *mcclient.ClientSession, args *NetworkIdOptions) error {
result, err := modules.Networks.PerformAction(s, args.ID, "syncstatus", nil)
type NetworkShareOptions struct {
NetworkShowOptions
Scope string `help:"sharing scope" choices:"system|domain"`
ShareToProject []string `help:"Share to prject"`
}
R(&NetworkShareOptions{}, "network-public", "Make a network public", func(s *mcclient.ClientSession, args *NetworkShareOptions) error {
params, err := options.StructToParams(args)
if err != nil {
return err
}
printObject(result)
return nil
})
type NetworkShareOptions struct {
NetworkIdOptions
Scope string `help:"sharing scope" choices:"system|domain|project"`
SharedProjects []string `help:"Share to prjects"`
SharedDomains []string `help:"share to domains"`
}
R(&NetworkShareOptions{}, "network-public", "Make a network public", func(s *mcclient.ClientSession, args *NetworkShareOptions) error {
params := jsonutils.Marshal(args)
result, err := modules.Networks.PerformAction(s, args.ID, "public", params)
if err != nil {
return err
@@ -199,7 +187,7 @@ func init() {
return nil
})
R(&NetworkIdOptions{}, "network-delete", "Delete a network", func(s *mcclient.ClientSession, args *NetworkIdOptions) error {
R(&NetworkShowOptions{}, "network-delete", "Delete a network", func(s *mcclient.ClientSession, args *NetworkShowOptions) error {
result, err := modules.Networks.Delete(s, args.ID, nil)
if err != nil {
return err
@@ -208,7 +196,7 @@ func init() {
return nil
})
R(&NetworkIdOptions{}, "network-purge", "Purge a managed network, not delete the remote entity", func(s *mcclient.ClientSession, args *NetworkIdOptions) error {
R(&NetworkShowOptions{}, "network-purge", "Purge a managed network, not delete the remote entity", func(s *mcclient.ClientSession, args *NetworkShowOptions) error {
result, err := modules.Networks.PerformAction(s, args.ID, "purge", nil)
if err != nil {
return err
@@ -358,6 +346,77 @@ func init() {
return nil
})
type NetworkAddDnsUpdateTargetOptions struct {
ID string `help:"Network ID or name"`
DNS string `help:"DNS server address" metavar:"DNS_SERVER"`
KEY string `help:"DNS update key name" metavar:"DNS_UPDATE_KEY"`
SECRET string `help:"DNS update key secret" metavar:"DNS_UPDATE_SECRET"`
}
R(&NetworkAddDnsUpdateTargetOptions{}, "network-add-dns-update-target", "Add a dns update target to a network", func(s *mcclient.ClientSession, args *NetworkAddDnsUpdateTargetOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.DNS), "server")
params.Add(jsonutils.NewString(args.KEY), "key")
params.Add(jsonutils.NewString(args.SECRET), "secret")
result, err := modules.Networks.PerformAction(s, args.ID, "add-dns-update-target", params)
if err != nil {
return err
}
printObject(result)
return nil
})
type NetworkRemoveDnsUpdateTargetOptions struct {
ID string `help:"Network ID or name"`
DNS string `help:"DNS server address" metavar:"DNS_SERVER"`
KEY string `help:"DNS update key name" metavar:"DNS_UPDATE_KEY"`
}
R(&NetworkRemoveDnsUpdateTargetOptions{}, "network-remove-dns-update-target", "Remove a dns update target from a network", func(s *mcclient.ClientSession, args *NetworkRemoveDnsUpdateTargetOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.DNS), "server")
params.Add(jsonutils.NewString(args.KEY), "key")
result, err := modules.Networks.PerformAction(s, args.ID, "remove-dns-update-target", params)
if err != nil {
return err
}
printObject(result)
return nil
})
type NetworkSetDnsUpdateKeyOptions struct {
ID string `help:"ID of virtual network to update"`
KEY string `help:"Key name of secret" metavar:"KEYNAME"`
SECRET string `help:"Key secret"`
SERVER string `help:"Alternate DNS update server"`
}
R(&NetworkSetDnsUpdateKeyOptions{}, "network-set-dns-update-key", "Set DNS update key info for a virtual network", func(s *mcclient.ClientSession, args *NetworkSetDnsUpdateKeyOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.KEY), "dns_update_key_name")
params.Add(jsonutils.NewString(args.SECRET), "dns_update_key_secret")
params.Add(jsonutils.NewString(args.SERVER), "dns_update_server")
result, err := modules.Networks.PerformAction(s, args.ID, "metadata", params)
if err != nil {
return err
}
printObject(result)
return nil
})
type NetworkRemoveDnsUpdateKeyOptions struct {
ID string `help:"ID of virtual network"`
}
R(&NetworkRemoveDnsUpdateKeyOptions{}, "network-remove-dns-update-key", "Set DNS update key info for a virtual network", func(s *mcclient.ClientSession, args *NetworkRemoveDnsUpdateKeyOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.JSONNull, "dns_update_key_name")
params.Add(jsonutils.JSONNull, "dns_update_key_secret")
params.Add(jsonutils.JSONNull, "dns_update_server")
result, err := modules.Networks.PerformAction(s, args.ID, "metadata", params)
if err != nil {
return err
}
printObject(result)
return nil
})
type NetworkAddressOptions struct {
NETWORK string `help:"id or name of network to query"`
}
@@ -401,30 +460,4 @@ func init() {
printObject(result)
return nil
})
R(&NetworkIdOptions{}, "network-change-owner-candidate-domains", "Show candiate domains of a network for changing owner", func(s *mcclient.ClientSession, args *NetworkIdOptions) error {
result, err := modules.Networks.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
type NetworkChangeOwnerOptions struct {
ID string `help:"Network to change owner" json:"-"`
PROJECT string `help:"Project ID or change" json:"tenant"`
}
R(&NetworkChangeOwnerOptions{}, "network-change-owner", "Change owner project of a network", func(s *mcclient.ClientSession, args *NetworkChangeOwnerOptions) error {
params, err := options.StructToParams(args)
if err != nil {
return err
}
net, err := modules.Networks.PerformAction(s, args.ID, "change-owner", params)
if err != nil {
return err
}
printObject(net)
return nil
})
}

View File

@@ -59,18 +59,18 @@ func init() {
* 修改指定的报警规则
*/
type NodealertUpdateOptions struct {
ID string `help:"ID of the alert rule" required:"true" positional:"true"`
Type string `help:"Alert rule type" choices:"guest|host"`
Metric string `help:"Metric name, include measurement and field, such as vm_cpu.usage_active"`
NodeName string `help:"Name of the guest or host"`
NodeID string `help:"ID of the guest or host"`
Period string `help:"Specify the query time period for the data"`
Window string `help:"Specify the query interval for the data"`
Threshold *float64 `help:"Threshold value of the metric"`
Comparator string `help:"Comparison operator for join expressions" choices:">|<|>=|<=|=|!="`
Recipients string `help:"Comma separated recipient ID"`
Level string `help:"Alert level" choices:"normal|important|fatal"`
Channel string `help:"Ways to send an alarm" choices:"email|mobile"`
ID string `help:"ID of the alert rule" required:"true" positional:"true"`
Type string `help:"Alert rule type" choices:"guest|host"`
Metric string `help:"Metric name, include measurement and field, such as vm_cpu.usage_active"`
NodeName string `help:"Name of the guest or host"`
NodeID string `help:"ID of the guest or host"`
Period string `help:"Specify the query time period for the data"`
Window string `help:"Specify the query interval for the data"`
Threshold float64 `help:"Threshold value of the metric"`
Comparator string `help:"Comparison operator for join expressions" choices:">|<|>=|<=|=|!="`
Recipients string `help:"Comma separated recipient ID"`
Level string `help:"Alert level" choices:"normal|important|fatal"`
Channel string `help:"Ways to send an alarm" choices:"email|mobile"`
}
R(&NodealertUpdateOptions{}, "nodealert-update", "Update the node alert rule", func(s *mcclient.ClientSession, args *NodealertUpdateOptions) error {
params, err := options.StructToParams(args)
@@ -92,11 +92,14 @@ func init() {
* 删除指定ID的报警规则
*/
type NodealertDeleteOptions struct {
ID []string `help:"ID of node alert" required:"true" positional:"true"`
ID string `help:"ID of node alert" required:"true" positional:"true"`
}
R(&NodealertDeleteOptions{}, "nodealert-delete", "Delete a node alert", func(s *mcclient.ClientSession, args *NodealertDeleteOptions) error {
ret := modules.NodeAlert.BatchDelete(s, args.ID, nil)
printBatchResults(ret, modules.NodeAlert.GetColumns(s))
alarm, err := modules.NodeAlert.Delete(s, args.ID, nil)
if err != nil {
return err
}
printObject(alarm)
return nil
})

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