mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-21 00:24:07 +08:00
Compare commits
545 Commits
release/3.
...
v3.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcabafc742 | ||
|
|
e19c91788c | ||
|
|
5b9a89d81b | ||
|
|
f685c1b391 | ||
|
|
089fa77540 | ||
|
|
bf6b6e3f2d | ||
|
|
a53e4d0220 | ||
|
|
fc7240469c | ||
|
|
f3e89cc91a | ||
|
|
ac14001b1d | ||
|
|
7451e9cadb | ||
|
|
b0774713a1 | ||
|
|
dde3fd44bf | ||
|
|
d08bb2700c | ||
|
|
517bca61c0 | ||
|
|
8465defe65 | ||
|
|
129c2195e9 | ||
|
|
cebee78ee5 | ||
|
|
c84f5730df | ||
|
|
0219383e8d | ||
|
|
f4cf25d3e5 | ||
|
|
28c5dbd1ab | ||
|
|
dcc7f2ba5c | ||
|
|
3c4e953843 | ||
|
|
bee1582654 | ||
|
|
f0a6c20c43 | ||
|
|
3dfce69dbc | ||
|
|
8c4f18b11f | ||
|
|
69c2de1fd9 | ||
|
|
c5ecdd6a42 | ||
|
|
a79aaaedc7 | ||
|
|
b58f78a0c9 | ||
|
|
8d9a76e3b3 | ||
|
|
173a8d6d4f | ||
|
|
08bf822d17 | ||
|
|
2bd5b61b61 | ||
|
|
41d61a77ce | ||
|
|
ce86a155f8 | ||
|
|
503b6f0a2a | ||
|
|
a5dc903c13 | ||
|
|
f8dcc93262 | ||
|
|
8085764f20 | ||
|
|
e8b342dfb2 | ||
|
|
1a58515573 | ||
|
|
439a02d9c8 | ||
|
|
8e767cc984 | ||
|
|
e444d5e797 | ||
|
|
6022e2da2e | ||
|
|
dc51ab2ee0 | ||
|
|
105c0a1714 | ||
|
|
69029c088a | ||
|
|
cd996659ac | ||
|
|
439e9c23f8 | ||
|
|
a259eb1112 | ||
|
|
c76ca51af5 | ||
|
|
286e001dac | ||
|
|
1eb3abf5a1 | ||
|
|
f51e7d0c7f | ||
|
|
b927fa5708 | ||
|
|
9211beb905 | ||
|
|
8d60b07d80 | ||
|
|
39b5d08f14 | ||
|
|
5b4ab09678 | ||
|
|
26802683ce | ||
|
|
25a537c743 | ||
|
|
4538ee2487 | ||
|
|
e2e33ef7af | ||
|
|
5e3270b7f4 | ||
|
|
f282022f9e | ||
|
|
d02dae88f2 | ||
|
|
650745ef1f | ||
|
|
40cdc198c8 | ||
|
|
a4ef41c5bb | ||
|
|
698fc0e1cb | ||
|
|
2c35de74c8 | ||
|
|
f70d781f0d | ||
|
|
a8ea730823 | ||
|
|
f4f34c1c3d | ||
|
|
05ea4797d8 | ||
|
|
494c540ac1 | ||
|
|
e0838efff8 | ||
|
|
f3f449f27a | ||
|
|
ce74310ca1 | ||
|
|
4ee1079d95 | ||
|
|
3dbaa6daba | ||
|
|
64b9bac4a9 | ||
|
|
75410934fe | ||
|
|
fae4cf63e2 | ||
|
|
0cd71ca469 | ||
|
|
2326f8e397 | ||
|
|
5e39414807 | ||
|
|
2c3340db6d | ||
|
|
54aff23fd2 | ||
|
|
c500036b1a | ||
|
|
51fdaed08c | ||
|
|
1e58907468 | ||
|
|
4e7202af40 | ||
|
|
444c2bc56e | ||
|
|
ae5f1e308b | ||
|
|
12ce1a0056 | ||
|
|
90008ff727 | ||
|
|
565696ca54 | ||
|
|
ae0de12280 | ||
|
|
bf4ca9c7f4 | ||
|
|
f50ffc31a7 | ||
|
|
9a7cad2507 | ||
|
|
4efe569446 | ||
|
|
ed512d2881 | ||
|
|
61d9bd3da9 | ||
|
|
8e9cd48302 | ||
|
|
897410d87f | ||
|
|
cf1ae4cac3 | ||
|
|
f8358cdde2 | ||
|
|
2e51e8d7e8 | ||
|
|
7b7d197939 | ||
|
|
d019dded59 | ||
|
|
6ee9a428d4 | ||
|
|
fe096bc117 | ||
|
|
bf9bcb191d | ||
|
|
cc0377dafb | ||
|
|
dce85ee9ee | ||
|
|
bc3ce3d2a1 | ||
|
|
27bb5eaa2b | ||
|
|
c630607066 | ||
|
|
e2762d75ca | ||
|
|
03f4cf19ed | ||
|
|
c4bbd519bc | ||
|
|
79b03d99c6 | ||
|
|
32da0918ba | ||
|
|
e6128db1a4 | ||
|
|
fe5a701849 | ||
|
|
9d2bf8556c | ||
|
|
90ee7c2934 | ||
|
|
bff54a22fd | ||
|
|
a166467f75 | ||
|
|
87377deee7 | ||
|
|
1ade0a645f | ||
|
|
ad79f8a557 | ||
|
|
4b1e038ac6 | ||
|
|
cf8426fad0 | ||
|
|
3cf9b22ae4 | ||
|
|
bb8b474b59 | ||
|
|
1a2826d37b | ||
|
|
02758cf5e2 | ||
|
|
5ebf23518d | ||
|
|
90a6b15c79 | ||
|
|
ac6a4169c3 | ||
|
|
9082f913c2 | ||
|
|
c05188ef50 | ||
|
|
b69f4b50fb | ||
|
|
b3b80fbeef | ||
|
|
9bd0d49baa | ||
|
|
23bfba422d | ||
|
|
6fa93c25ad | ||
|
|
12f3df951e | ||
|
|
eabed8d47d | ||
|
|
09e63478c6 | ||
|
|
3590253480 | ||
|
|
cd02610f23 | ||
|
|
d2d551e6cd | ||
|
|
0d5dbf62b8 | ||
|
|
de59d8895a | ||
|
|
f9573c4cbf | ||
|
|
b3d1bfea0c | ||
|
|
7667ed425e | ||
|
|
20ce2ca01f | ||
|
|
32cdc3e2cd | ||
|
|
9fb1f6c224 | ||
|
|
4d44569f40 | ||
|
|
5a14e40ba4 | ||
|
|
1081410846 | ||
|
|
942ff1d661 | ||
|
|
ef6e90f9cb | ||
|
|
8bdf8807de | ||
|
|
81eab50f3b | ||
|
|
8c21e3313e | ||
|
|
91d09aeba4 | ||
|
|
c040ed5d74 | ||
|
|
8b8f57e0f7 | ||
|
|
5c098c6445 | ||
|
|
f4673ee5fc | ||
|
|
410e575d8a | ||
|
|
16b053349b | ||
|
|
4937dec5f3 | ||
|
|
19b98799a0 | ||
|
|
ce44e085f8 | ||
|
|
349c26f39a | ||
|
|
76d40b0ceb | ||
|
|
095b70af37 | ||
|
|
d090073168 | ||
|
|
19fda5387f | ||
|
|
617cd67b1c | ||
|
|
ae63c797d4 | ||
|
|
51e2c1114a | ||
|
|
518405e0ca | ||
|
|
e75c0e0fbf | ||
|
|
0c8fc8cf77 | ||
|
|
5a2ecc2a1e | ||
|
|
8437d918de | ||
|
|
ad9f85ede8 | ||
|
|
e21994d9eb | ||
|
|
8eca54f6a7 | ||
|
|
7db5fe8ef7 | ||
|
|
320a233155 | ||
|
|
60861d4983 | ||
|
|
599345c5f0 | ||
|
|
9159eae068 | ||
|
|
8dc56cd712 | ||
|
|
06ef435ffc | ||
|
|
af4cab0d4e | ||
|
|
1d4ea408a5 | ||
|
|
b8f05c4ead | ||
|
|
5c587212bc | ||
|
|
133fe47634 | ||
|
|
8efe1c5b45 | ||
|
|
91ca20d540 | ||
|
|
4d320a22db | ||
|
|
16702ba2f6 | ||
|
|
e227380071 | ||
|
|
b5aa5f3682 | ||
|
|
7a56e6b74b | ||
|
|
4fd186a0c0 | ||
|
|
88e4de7b52 | ||
|
|
8bcbd08741 | ||
|
|
3dc838d47d | ||
|
|
abb954c6c9 | ||
|
|
b70a1e5a05 | ||
|
|
5afb250467 | ||
|
|
394a6f061c | ||
|
|
fa0cb45ea3 | ||
|
|
1113dfe17b | ||
|
|
81c31c8c1c | ||
|
|
8dfad23c2c | ||
|
|
019287b16a | ||
|
|
ff1dc42c47 | ||
|
|
a3faf13ce7 | ||
|
|
78d7317daa | ||
|
|
dc6eab6cd1 | ||
|
|
48008e1a41 | ||
|
|
8f971c9ce4 | ||
|
|
dbb4912325 | ||
|
|
9fdb7cf895 | ||
|
|
05465b9cbb | ||
|
|
e0ee61b94e | ||
|
|
6032301cb8 | ||
|
|
3894d23991 | ||
|
|
ae01139c37 | ||
|
|
cb9e156628 | ||
|
|
57c266e977 | ||
|
|
b1b9c08ea2 | ||
|
|
cc3f382cb8 | ||
|
|
f2380b293e | ||
|
|
46a7e670b2 | ||
|
|
af7aaff4c9 | ||
|
|
7c5f0727b3 | ||
|
|
c4f6199890 | ||
|
|
5f3faf8cb8 | ||
|
|
d7becf89e8 | ||
|
|
d35e6f8fea | ||
|
|
a3332344a0 | ||
|
|
5826a36de4 | ||
|
|
b61befef30 | ||
|
|
4bdf3e8404 | ||
|
|
00e1911d30 | ||
|
|
d26c428b68 | ||
|
|
dc634ad9d0 | ||
|
|
e691d63910 | ||
|
|
5c325bc6b7 | ||
|
|
00f07f128f | ||
|
|
fdc1bef92e | ||
|
|
181c1099fe | ||
|
|
e20a6a35df | ||
|
|
a4db9de855 | ||
|
|
4e9ca42347 | ||
|
|
10a04b0005 | ||
|
|
f36f275dc6 | ||
|
|
4f644f1d80 | ||
|
|
e1020530e2 | ||
|
|
a94f55ba91 | ||
|
|
b769399a79 | ||
|
|
0ba856004f | ||
|
|
afefb9464d | ||
|
|
039d7b43f6 | ||
|
|
6a4b39085c | ||
|
|
db75a24f73 | ||
|
|
ff0e50cce0 | ||
|
|
217670326b | ||
|
|
a655afbbde | ||
|
|
e276ba9582 | ||
|
|
93c5a79afa | ||
|
|
53f95f775d | ||
|
|
b9bab969cb | ||
|
|
7835ee1063 | ||
|
|
675f111084 | ||
|
|
9ccd97a236 | ||
|
|
2ea614d38d | ||
|
|
8028577a0b | ||
|
|
7c60fbf66c | ||
|
|
bd560a07b6 | ||
|
|
a4507e169a | ||
|
|
a71292cabc | ||
|
|
b8d93a0db7 | ||
|
|
352800c78d | ||
|
|
a5ace62220 | ||
|
|
7f20eed8ef | ||
|
|
e2b1b53e3e | ||
|
|
089652074e | ||
|
|
77494e5889 | ||
|
|
ba8142559c | ||
|
|
23515d0c87 | ||
|
|
3a853545ca | ||
|
|
45d1c3c7dd | ||
|
|
277a1066cd | ||
|
|
cb29e4f045 | ||
|
|
753566d3a9 | ||
|
|
4008c25b0a | ||
|
|
dad753aaf5 | ||
|
|
6672c2357e | ||
|
|
5865e393f5 | ||
|
|
3d6a14b89b | ||
|
|
3af6da558f | ||
|
|
1e1811c0de | ||
|
|
5b09a45437 | ||
|
|
c72322cd5b | ||
|
|
bf5f1f524e | ||
|
|
e910967798 | ||
|
|
aa27f4eeca | ||
|
|
232df7b869 | ||
|
|
88def49fcc | ||
|
|
fc3aa2acbf | ||
|
|
7bb8f0f968 | ||
|
|
79d8abd1ab | ||
|
|
101d5de95a | ||
|
|
11ccfdd5c9 | ||
|
|
05c85e898d | ||
|
|
30a4d16628 | ||
|
|
f9b9856768 | ||
|
|
60b0634e27 | ||
|
|
8f574c255d | ||
|
|
37ece22817 | ||
|
|
e25142ed70 | ||
|
|
e59189d0f5 | ||
|
|
5e166849ef | ||
|
|
f5af866b39 | ||
|
|
5773663e5d | ||
|
|
b65ab0361a | ||
|
|
eb30360856 | ||
|
|
08b7a96309 | ||
|
|
fe99ec0649 | ||
|
|
f885cfcc4a | ||
|
|
9b3491cc4e | ||
|
|
5317b43e13 | ||
|
|
633c2c9439 | ||
|
|
3f15fa2c58 | ||
|
|
b822c58fc2 | ||
|
|
5171eca046 | ||
|
|
bec1776d7e | ||
|
|
5ba580878d | ||
|
|
7ee21d12ce | ||
|
|
abef1a9f9b | ||
|
|
ccd187220c | ||
|
|
40a211144c | ||
|
|
7648c26d75 | ||
|
|
2ee7dca684 | ||
|
|
f764e5b394 | ||
|
|
c260d81610 | ||
|
|
ef813e062a | ||
|
|
2062489bec | ||
|
|
0ae98e64ea | ||
|
|
a1ccae2e23 | ||
|
|
0b4a141199 | ||
|
|
25f8c71d18 | ||
|
|
1a0df04c83 | ||
|
|
f5c534cb71 | ||
|
|
7d1174efad | ||
|
|
e3f654994a | ||
|
|
0dbd73b60b | ||
|
|
f75ef27fe0 | ||
|
|
dca8b8a9f5 | ||
|
|
9df932505c | ||
|
|
423777c775 | ||
|
|
52f2a1f3b4 | ||
|
|
dd0ced571d | ||
|
|
dbd959d040 | ||
|
|
9be50f0007 | ||
|
|
840b6e9a16 | ||
|
|
ec83f583c2 | ||
|
|
2983659c53 | ||
|
|
af20c84a50 | ||
|
|
5cee576fc4 | ||
|
|
ba89e19f3e | ||
|
|
73faf76bbb | ||
|
|
17bd125542 | ||
|
|
3b14136705 | ||
|
|
a968e3544c | ||
|
|
9d20a58a85 | ||
|
|
a719ad6d82 | ||
|
|
2f9e3f7da0 | ||
|
|
5f8758e5c4 | ||
|
|
ae2369befd | ||
|
|
a4a7d004c8 | ||
|
|
9a7d223311 | ||
|
|
d9910a0364 | ||
|
|
6ad8ff188d | ||
|
|
641cd05a9a | ||
|
|
570a6bbab7 | ||
|
|
01a466b989 | ||
|
|
4fd7e6fcf0 | ||
|
|
8a2841f672 | ||
|
|
0adccb5c8b | ||
|
|
a712df096a | ||
|
|
ed75a7262b | ||
|
|
adea5e3441 | ||
|
|
64f29934f0 | ||
|
|
6cc5c4d942 | ||
|
|
e817fb0920 | ||
|
|
2c412db6c8 | ||
|
|
d08761095c | ||
|
|
03cf19f1db | ||
|
|
3c77aa38ff | ||
|
|
d3a2ebeacb | ||
|
|
d868952b0d | ||
|
|
9ac505c907 | ||
|
|
05ee08e411 | ||
|
|
ef39ed3d0c | ||
|
|
85ac87b7c9 | ||
|
|
3b3480b29b | ||
|
|
6628f15ab0 | ||
|
|
9f55497161 | ||
|
|
9e96e4f7e4 | ||
|
|
12c87f630a | ||
|
|
5d2fb3bf56 | ||
|
|
af5b218377 | ||
|
|
802197f161 | ||
|
|
45f3ee7989 | ||
|
|
d9a43ae92a | ||
|
|
8ae4e5bcec | ||
|
|
67dd167835 | ||
|
|
2d1d8db96a | ||
|
|
9e42b83406 | ||
|
|
1a16fbd9cf | ||
|
|
77d19d2ec3 | ||
|
|
5391943537 | ||
|
|
5c1044a1f6 | ||
|
|
6e87e25b38 | ||
|
|
95565e4b6d | ||
|
|
6c0bdeac49 | ||
|
|
5100ced74c | ||
|
|
f022f4138e | ||
|
|
6ecf644277 | ||
|
|
ee34fbdafe | ||
|
|
61ff4ddbc8 | ||
|
|
ec7bc017dd | ||
|
|
a96d17efcc | ||
|
|
ac1d08d619 | ||
|
|
d032dccd91 | ||
|
|
987495c463 | ||
|
|
dc2fd237f0 | ||
|
|
03cca94b0c | ||
|
|
3365161fa5 | ||
|
|
e810d4567e | ||
|
|
954341e4ab | ||
|
|
becfe078d5 | ||
|
|
8915b934b1 | ||
|
|
b67da6996f | ||
|
|
ce40f6378f | ||
|
|
2c2b1544c6 | ||
|
|
44114e8d94 | ||
|
|
b9405e72e7 | ||
|
|
3a5b32fc60 | ||
|
|
9bbba1a3cc | ||
|
|
25277900d4 | ||
|
|
4cdf779700 | ||
|
|
dc09cb88c4 | ||
|
|
155ef44d8f | ||
|
|
e08b7ff91d | ||
|
|
fa544dbdc7 | ||
|
|
67f0dc3f8b | ||
|
|
d333e30d52 | ||
|
|
94068ce53e | ||
|
|
7a0b6fd2ee | ||
|
|
c0115d5a9c | ||
|
|
50ea8fc5a8 | ||
|
|
fec4cb1804 | ||
|
|
49b3bf2dce | ||
|
|
b89a445451 | ||
|
|
d3a0e345d9 | ||
|
|
0542deef75 | ||
|
|
0db77fc304 | ||
|
|
c6a8eae499 | ||
|
|
62f0a84a83 | ||
|
|
aa6e9a8107 | ||
|
|
8528410bf8 | ||
|
|
d2f33742a0 | ||
|
|
b4b1494e1c | ||
|
|
bb8c9d1b47 | ||
|
|
ab1d2c0c24 | ||
|
|
ef1b8f5245 | ||
|
|
8d1f755b4e | ||
|
|
ad32d9063a | ||
|
|
7ca467e35b | ||
|
|
8270238116 | ||
|
|
ac4f897510 | ||
|
|
0eef43bb0a | ||
|
|
5096ee9de3 | ||
|
|
34e0d8dd27 | ||
|
|
975154b98a | ||
|
|
1b23d6c755 | ||
|
|
cdbc49a1a8 | ||
|
|
86df323603 | ||
|
|
422dcf8020 | ||
|
|
a47bdf3566 | ||
|
|
275832f438 | ||
|
|
dbbe173e51 | ||
|
|
f0276d1a01 | ||
|
|
0cfb8dbd5a | ||
|
|
ad0ddf6dd9 | ||
|
|
3b1c4dc2e5 | ||
|
|
4d907584e2 | ||
|
|
2b9a995b13 | ||
|
|
6dc2ccee60 | ||
|
|
2bd77ec202 | ||
|
|
30fab89baa | ||
|
|
8d47608e4e | ||
|
|
eeeb81bf3f | ||
|
|
78d68a023b | ||
|
|
6534a7c6a5 | ||
|
|
9d60403817 | ||
|
|
6ba7cbbb37 | ||
|
|
047bf47534 | ||
|
|
243590995f | ||
|
|
53a9c010cb | ||
|
|
9a6d9df76d | ||
|
|
8870fe2d1f | ||
|
|
d2d8a7eeaa | ||
|
|
56be0bb3c5 | ||
|
|
d9956a9445 | ||
|
|
0702803b52 | ||
|
|
f12c77ca4c | ||
|
|
e0e72f4dc2 | ||
|
|
1cd4472073 | ||
|
|
71c877428e | ||
|
|
20a2dc5bf3 | ||
|
|
e00f4a1f7d | ||
|
|
72c489140d |
38
.circleci/Dockerfile
Normal file
38
.circleci/Dockerfile
Normal 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
|
||||
@@ -5,20 +5,20 @@ 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:
|
||||
command: |
|
||||
make -j3 check
|
||||
make check
|
||||
build:
|
||||
requires:
|
||||
- check
|
||||
docker:
|
||||
- image: yunionio/centos-build:1.0-1
|
||||
- image: yunionio/onecloud-ci:v1.0.2
|
||||
environment:
|
||||
ONECLOUD_CI_BUILD: "1"
|
||||
|
||||
@@ -26,24 +26,24 @@ 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)"
|
||||
echo $targets | tr ' ' '\n'
|
||||
make -j2 $targets
|
||||
make $targets
|
||||
ls -lh _output/bin/
|
||||
- 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,17 +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
|
||||
parallelism: 4
|
||||
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: |
|
||||
@@ -69,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
|
||||
|
||||
10
.github/pull_request_template.md
vendored
10
.github/pull_request_template.md
vendored
@@ -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
|
||||
-->
|
||||
|
||||
96
.github/workflows/docker.yml
vendored
96
.github/workflows/docker.yml
vendored
@@ -29,47 +29,17 @@ 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 cmd/cloudid
|
||||
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
|
||||
@@ -91,16 +61,6 @@ jobs:
|
||||
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 +91,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,6 +171,26 @@ jobs:
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.notify
|
||||
|
||||
- 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:
|
||||
@@ -211,16 +201,6 @@ jobs:
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.cloudevent
|
||||
|
||||
- name: Image cloudid
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
name: registry.cn-beijing.aliyuncs.com/yunionio/cloudid
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.cloudid
|
||||
|
||||
- name: Image devtool
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
@@ -230,13 +210,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
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -30,10 +30,7 @@ _output
|
||||
/relay
|
||||
/structargtest
|
||||
.idea
|
||||
.vscode
|
||||
GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
pkg/generated
|
||||
|
||||
*.orig
|
||||
|
||||
88
Makefile
88
Makefile
@@ -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')
|
||||
@@ -163,15 +162,9 @@ goimports-check:
|
||||
fi
|
||||
.PHONY: goimports-check
|
||||
|
||||
vet-check:
|
||||
./scripts/vet.sh gen
|
||||
./scripts/vet.sh chk
|
||||
.PHONY: vet-check
|
||||
|
||||
check: fmt-check
|
||||
check: gendocgo-check
|
||||
check: goimports-check
|
||||
check: vet-check
|
||||
.PHONY: check
|
||||
|
||||
|
||||
@@ -194,82 +187,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
|
||||
|
||||
@@ -297,15 +256,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 || \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Yunion OneCloud
|
||||
|
||||
[](https://circleci.com/gh/yunionio/onecloud)
|
||||
[](https://travis-ci.com/yunionio/onecloud/branches)
|
||||
[](https://travis-ci.org/yunionio/onecloud)
|
||||
[](https://goreportcard.com/report/github.com/yunionio/onecloud)
|
||||
|
||||
### [README in Chinese](./README-CN.md)
|
||||
@@ -40,7 +40,7 @@ Please refers to [install & deployment](https://docs.yunion.io/docs/setup/) (cur
|
||||
|
||||
- [Yunion OneCloud Documents](https://docs.yunion.io/)
|
||||
|
||||
- [Swagger API](https://docs.yunion.cn/apiv2/)
|
||||
- [Swagger API](https://docs.yunion.cn/api/)
|
||||
|
||||
## Architecture
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
DESCRIPTION="Yunion CloudId"
|
||||
@@ -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
|
||||
|
||||
@@ -1,12 +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
|
||||
# git, ca-certificates, for fetching ansible roles
|
||||
RUN set -x \
|
||||
&& apk update \
|
||||
&& apk add openssh-client \
|
||||
&& apk add ansible \
|
||||
&& apk add tzdata git 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
|
||||
ADD ./_output/bin/cloudid /opt/yunion/bin/cloudid
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-base:v0.2.0
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-base:v0.0.1
|
||||
|
||||
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
|
||||
|
||||
@@ -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:v0.0.2
|
||||
|
||||
MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
|
||||
ADD ./_output/bin/monitor /opt/yunion/bin/monitor
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/openvswitch:2.10.4-0
|
||||
|
||||
MAINTAINER "Yousong Zhou <zhouyousong@yunion.cn>"
|
||||
|
||||
RUN mkdir -p /opt/yunion/bin
|
||||
ADD ./_output/alpine-build/bin/vpcagent /opt/yunion/bin/vpcagent
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -1,2 +0,0 @@
|
||||
DESCRIPTION="Yunion Host Image Server"
|
||||
SERVICE="yes"
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
{{.os_type}} 镜像 {{.name}} 上传完成
|
||||
@@ -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>
|
||||
@@ -1 +0,0 @@
|
||||
镜像 {{.name}} 上传完成
|
||||
@@ -1 +0,0 @@
|
||||
Yunion Verify
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package entry
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -32,6 +32,9 @@ import (
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/promputils"
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
_ "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/pkg/mcclient"
|
||||
)
|
||||
|
||||
@@ -45,7 +48,7 @@ type BaseOptions struct {
|
||||
CertFile string `default:"$YUNION_CERT_FILE" help:"certificate file"`
|
||||
KeyFile string `default:"$YUNION_KEY_FILE" help:"private key file"`
|
||||
|
||||
Completion string `default:"" help:"Generate climc auto complete script" choices:"bash|zsh"`
|
||||
Completion string `default:"" help:"Generate climc auto complete script" choices:"bash"`
|
||||
UseCachedToken bool `default:"$YUNION_USE_CACHED_TOKEN|false" help:"Use cached token"`
|
||||
|
||||
OsUsername string `default:"$OS_USERNAME" help:"Username, defaults to env[OS_USERNAME]"`
|
||||
@@ -58,8 +61,6 @@ type BaseOptions struct {
|
||||
OsAccessKey string `default:"$OS_ACCESS_KEY" help:"ak/sk access key, defaults to env[OS_ACCESS_KEY]"`
|
||||
OsSecretKey string `default:"$OS_SECRET_KEY" help:"ak/s secret, defaults to env[OS_SECRET_KEY]"`
|
||||
|
||||
OsAuthToken string `default:"$OS_AUTH_TOKEN" help:"token authenticate, defaults to env[OS_AUTH_TOKEN]"`
|
||||
|
||||
OsAuthURL string `default:"$OS_AUTH_URL" help:"Defaults to env[OS_AUTH_URL]"`
|
||||
|
||||
OsRegionName string `default:"$OS_REGION_NAME" help:"Defaults to env[OS_REGION_NAME]"`
|
||||
@@ -71,13 +72,9 @@ type BaseOptions struct {
|
||||
}
|
||||
|
||||
func getSubcommandsParser() (*structarg.ArgumentParser, error) {
|
||||
var (
|
||||
prog = "climc"
|
||||
desc = `Command-line interface to the API server.`
|
||||
)
|
||||
parse, e := structarg.NewArgumentParser(&BaseOptions{},
|
||||
prog,
|
||||
desc,
|
||||
"climc",
|
||||
`Command-line interface to the API server.`,
|
||||
`See "climc help COMMAND" for help on a specific command.`)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
@@ -98,28 +95,26 @@ func getSubcommandsParser() (*structarg.ArgumentParser, error) {
|
||||
return nil
|
||||
}
|
||||
})
|
||||
|
||||
promptRootCmd := promputils.InitRootCmd(prog, desc, parse.GetOptArgs(), parse.GetPosArgs())
|
||||
for _, v := range shell.CommandTable {
|
||||
_par, e := subcmd.AddSubParser(v.Options, v.Command, v.Desc, v.Callback)
|
||||
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
promputils.AppendCommand(promptRootCmd, v.Command, v.Desc)
|
||||
promputils.AppendCommand(v.Command, v.Desc)
|
||||
cmd := v.Command
|
||||
|
||||
for _, v := range _par.GetOptArgs() {
|
||||
text := v.String()
|
||||
text = strings.TrimLeft(text, "[<")
|
||||
text = strings.TrimRight(text, "]>")
|
||||
promputils.AppendOpt(cmd, text, v.HelpString(""), v)
|
||||
promputils.AppendOpt(cmd, text, v.HelpString(""))
|
||||
}
|
||||
for _, v := range _par.GetPosArgs() {
|
||||
text := v.String()
|
||||
text = strings.TrimLeft(text, "[<")
|
||||
text = strings.TrimRight(text, "]>")
|
||||
promputils.AppendPos(cmd, text, v.HelpString(""), v)
|
||||
promputils.AppendPos(cmd, text, v.HelpString(""))
|
||||
}
|
||||
}
|
||||
return parse, nil
|
||||
@@ -135,8 +130,8 @@ func newClientSession(options *BaseOptions) (*mcclient.ClientSession, error) {
|
||||
if len(options.OsAuthURL) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_AUTH_URL")
|
||||
}
|
||||
if len(options.OsUsername) == 0 && len(options.OsAccessKey) == 0 && len(options.OsAuthToken) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_USERNAME or OS_ACCESS_KEY or OS_AUTH_TOKEN")
|
||||
if len(options.OsUsername) == 0 && len(options.OsAccessKey) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_USERNAME or OS_ACCESS_KEY")
|
||||
}
|
||||
if len(options.OsUsername) > 0 && len(options.OsPassword) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_PASSWORD")
|
||||
@@ -144,6 +139,9 @@ func newClientSession(options *BaseOptions) (*mcclient.ClientSession, error) {
|
||||
if len(options.OsAccessKey) > 0 && len(options.OsSecretKey) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_SECRET_KEY")
|
||||
}
|
||||
if len(options.OsRegionName) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_REGION_NAME")
|
||||
}
|
||||
|
||||
logLevel := "info"
|
||||
if options.Debug {
|
||||
@@ -186,11 +184,7 @@ func newClientSession(options *BaseOptions) (*mcclient.ClientSession, error) {
|
||||
if cacheToken == nil {
|
||||
var token mcclient.TokenCredential
|
||||
var err error
|
||||
if len(options.OsAuthToken) > 0 {
|
||||
token, err = client.AuthenticateToken(options.OsAuthToken, options.OsProjectName,
|
||||
options.OsProjectDomain,
|
||||
mcclient.AuthSourceCli)
|
||||
} else if len(options.OsAccessKey) > 0 {
|
||||
if len(options.OsAccessKey) > 0 {
|
||||
token, err = client.AuthenticateByAccessKey(options.OsAccessKey,
|
||||
options.OsSecretKey, mcclient.AuthSourceCli)
|
||||
} else {
|
||||
@@ -266,7 +260,7 @@ func executeSubcommand(
|
||||
}
|
||||
}
|
||||
|
||||
func ClimcMain() {
|
||||
func main() {
|
||||
parser, e := getSubcommandsParser()
|
||||
if e != nil {
|
||||
showErrorAndExit(e)
|
||||
@@ -275,7 +269,7 @@ func ClimcMain() {
|
||||
options := parser.Options().(*BaseOptions)
|
||||
|
||||
if len(options.Completion) > 0 {
|
||||
completeScript := promputils.GenerateAutoCompleteCmds(promputils.GetRootCmd(), options.Completion)
|
||||
completeScript := promputils.GenerateAutoCompleteCmds(options.Completion)
|
||||
if len(completeScript) > 0 {
|
||||
fmt.Printf("%s", completeScript)
|
||||
}
|
||||
@@ -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 main
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/entry"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/ansible"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudevent"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudid"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudnet"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/compute"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/etcd"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/events"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/identity"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/image"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/itsm"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/k8s"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/logger"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/meter"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/misc"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/monitor"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/notify"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/servicetree"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/yunionconf"
|
||||
)
|
||||
|
||||
func main() {
|
||||
entry.ClimcMain()
|
||||
}
|
||||
@@ -1,178 +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 promputils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"yunion.io/x/structarg"
|
||||
)
|
||||
|
||||
// ref: https://github.com/spf13/cobra/blob/master/zsh_completions.go
|
||||
|
||||
var (
|
||||
zshCompFuncMap = template.FuncMap{
|
||||
"genZshFuncName": zshCompGenFuncName,
|
||||
"extractFlags": zshCompExtractFlag,
|
||||
"genFlagEntryForZshArguments": zshCompGenFlagEntryForArguments,
|
||||
"extractArgsCompletions": zshCompExtractArgumentCompletionHintsForRendering,
|
||||
}
|
||||
zshCompletionText = `
|
||||
{{/* should accept Command (that contains subcommands) as parameter */}}
|
||||
{{define "argumentsC" -}}
|
||||
{{ $cmdPath := genZshFuncName .}}
|
||||
function {{$cmdPath}} {
|
||||
local -a commands
|
||||
_arguments -C \{{- range extractFlags .}}
|
||||
{{genFlagEntryForZshArguments .}} \{{- end}}
|
||||
"1: :->cmnds" \
|
||||
"*::arg:->args"
|
||||
|
||||
case $state in
|
||||
cmnds)
|
||||
commands=({{range .SubCmds}}
|
||||
"{{.Name}}:{{.Desc}}"{{end}}
|
||||
)
|
||||
_describe "command" commands
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$words[1]" in {{- range .SubCmds}}
|
||||
{{.Name}})
|
||||
{{$cmdPath}}_{{.Name}}
|
||||
;;{{end}}
|
||||
esac
|
||||
}
|
||||
{{range .SubCmds}}
|
||||
{{template "selectCmdTemplate" .}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
|
||||
{{/* should accept Command without subcommands as parameter */}}
|
||||
{{define "arguments" -}}
|
||||
function {{genZshFuncName .}} {
|
||||
{{" _arguments"}}{{range extractFlags .}} \
|
||||
{{genFlagEntryForZshArguments . -}}
|
||||
{{end}}{{range extractArgsCompletions .}} \
|
||||
{{.}}{{end}}
|
||||
}
|
||||
{{end}}
|
||||
|
||||
{{/* dispatcher for commands with or without subcommands */}}
|
||||
{{define "selectCmdTemplate" -}}
|
||||
{{if .SubCmds}}{{template "argumentsC" .}}{{else}}{{template "arguments" .}}{{end}}
|
||||
{{- end}}
|
||||
|
||||
{{/* template entry point */}}
|
||||
{{define "Main" -}}
|
||||
#compdef _{{.Name}} {{.Name}}
|
||||
|
||||
{{template "selectCmdTemplate" .}}
|
||||
compdef _{{.Name}} {{.Name}}
|
||||
{{end}}
|
||||
`
|
||||
)
|
||||
|
||||
func zshCompGenFuncName(c *Cmd) string {
|
||||
if c.ParentCmd != nil {
|
||||
return zshCompGenFuncName(c.ParentCmd) + "_" + c.Name
|
||||
}
|
||||
return "_" + c.Name
|
||||
}
|
||||
|
||||
func zshCompExtractFlag(c *Cmd) []structarg.Argument {
|
||||
return c.GetArguments()
|
||||
}
|
||||
|
||||
func zshCompGenFlagEntryForArguments(f structarg.Argument) string {
|
||||
// not process positional argument and single command
|
||||
if f.IsPositional() {
|
||||
return ""
|
||||
}
|
||||
if f.ShortToken() == "" {
|
||||
return zshCompGenFlagEntryForSingleOptionFlag(f)
|
||||
}
|
||||
return zshCompGenFlagEntryForMultiOptionFlag(f)
|
||||
}
|
||||
|
||||
func zshCompGenFlagEntryForSingleOptionFlag(f structarg.Argument) string {
|
||||
var option, multiMark, extras string
|
||||
if f.IsMulti() {
|
||||
multiMark = "*"
|
||||
}
|
||||
|
||||
option = "--" + f.Token()
|
||||
extras = zshCompGenFlagEntryExtras(f)
|
||||
return fmt.Sprintf(`'%s%s[%s]%s'`, multiMark, option, zshCompQuoteFlagDescription(f.HelpString("")), extras)
|
||||
}
|
||||
|
||||
func zshCompGenFlagEntryForMultiOptionFlag(f structarg.Argument) string {
|
||||
var options, parenMultiMark, curlyMultiMark, extras string
|
||||
if f.IsMulti() {
|
||||
parenMultiMark = "*"
|
||||
curlyMultiMark = "\\*"
|
||||
}
|
||||
|
||||
options = fmt.Sprintf(`'(%s-%s %s--%s)'{%s-%s,%s--%s}`,
|
||||
parenMultiMark, f.ShortToken(), parenMultiMark, f.Token(), curlyMultiMark, f.ShortToken(), curlyMultiMark, f.Token())
|
||||
extras = zshCompGenFlagEntryExtras(f)
|
||||
|
||||
return fmt.Sprintf(`%s'[%s]%s'`, options, zshCompQuoteFlagDescription(f.HelpString("")), extras)
|
||||
}
|
||||
|
||||
func zshCompGenFlagEntryExtras(f structarg.Argument) string {
|
||||
if !f.NeedData() {
|
||||
return ""
|
||||
}
|
||||
// allow options for flag
|
||||
extras := ":"
|
||||
|
||||
type iChoices interface {
|
||||
Choices() []string
|
||||
}
|
||||
if hasChoices, ok := f.(iChoices); ok {
|
||||
// process choices
|
||||
var words []string
|
||||
for _, w := range hasChoices.Choices() {
|
||||
words = append(words, fmt.Sprintf("%q", w))
|
||||
}
|
||||
if len(words) != 0 {
|
||||
extras = fmt.Sprintf("%s :(%s)", extras, strings.Join(words, " "))
|
||||
}
|
||||
}
|
||||
return extras
|
||||
}
|
||||
|
||||
func zshCompQuoteFlagDescription(s string) string {
|
||||
s = strings.Replace(s, "'", `'\''`, -1)
|
||||
s = strings.Replace(s, "[", `\[`, -1)
|
||||
s = strings.Replace(s, "]", `\]`, -1)
|
||||
return s
|
||||
}
|
||||
|
||||
func zshCompExtractArgumentCompletionHintsForRendering(c *Cmd) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cmd) GenZshCompletion(w io.Writer) error {
|
||||
tmpl, err := template.New("Main").Funcs(zshCompFuncMap).Parse(zshCompletionText)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating zsh completion template: %v", err)
|
||||
}
|
||||
return tmpl.Execute(w, c.Root())
|
||||
}
|
||||
@@ -75,3 +75,33 @@ _climc(){
|
||||
do
|
||||
line="${arr[$i]}"
|
||||
allopts[count]=${line%s`
|
||||
|
||||
const ZSH_COMPLETE_SCRIPT_2 = `%"#"*}
|
||||
subopts[count]=${line#*"#"}
|
||||
((count++))
|
||||
done
|
||||
_arguments \
|
||||
'1: :->commands'\
|
||||
'*: :->options'
|
||||
|
||||
case $state in
|
||||
commands)
|
||||
_arguments '1:Comm:(${allopts[*]})'
|
||||
;;
|
||||
*)
|
||||
item=1
|
||||
for key in ${allopts[*]}
|
||||
do
|
||||
case $words[2] in
|
||||
$key)
|
||||
compadd "$@"` + "`echo $subopts[item]`" + `
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
((item++))
|
||||
done
|
||||
esac
|
||||
}
|
||||
_climc "$@"
|
||||
`
|
||||
|
||||
@@ -15,118 +15,26 @@
|
||||
package promputils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
prompt "github.com/c-bata/go-prompt"
|
||||
|
||||
"yunion.io/x/structarg"
|
||||
)
|
||||
|
||||
var (
|
||||
subcmds = make(map[string]*Cmd)
|
||||
rootCmd *Cmd
|
||||
)
|
||||
type Cmd struct {
|
||||
desc string
|
||||
optArgs []prompt.Suggest
|
||||
posArgs []prompt.Suggest
|
||||
}
|
||||
|
||||
var cmds = make(map[string]*Cmd)
|
||||
|
||||
var optionHelp = []prompt.Suggest{
|
||||
{Text: "-h"},
|
||||
{Text: "--help"},
|
||||
}
|
||||
|
||||
type Cmd struct {
|
||||
Name string
|
||||
Desc string
|
||||
optArgs []CmdArgument
|
||||
posArgs []CmdArgument
|
||||
ParentCmd *Cmd
|
||||
SubCmds []*Cmd
|
||||
}
|
||||
|
||||
func InitRootCmd(name, desc string, optArgs, posArgs []structarg.Argument) *Cmd {
|
||||
rootCmd = NewCmd(name, desc)
|
||||
for _, optA := range optArgs {
|
||||
rootCmd.AddOptArgument(optA, optA.Token(), optA.HelpString(""))
|
||||
}
|
||||
for _, posA := range posArgs {
|
||||
rootCmd.AddPosArgument(posA, posA.Token(), posA.HelpString(""))
|
||||
}
|
||||
return rootCmd
|
||||
}
|
||||
|
||||
func GetRootCmd() *Cmd {
|
||||
return rootCmd
|
||||
}
|
||||
|
||||
func NewCmd(name, desc string) *Cmd {
|
||||
return &Cmd{
|
||||
Name: name,
|
||||
Desc: desc,
|
||||
optArgs: make([]CmdArgument, 0),
|
||||
posArgs: make([]CmdArgument, 0),
|
||||
SubCmds: make([]*Cmd, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (c Cmd) getPromptSuggests(args []CmdArgument) []prompt.Suggest {
|
||||
ret := make([]prompt.Suggest, 0)
|
||||
for _, arg := range args {
|
||||
ret = append(ret, arg.Suggest)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (c *Cmd) Root() *Cmd {
|
||||
if c.ParentCmd == nil {
|
||||
return c
|
||||
}
|
||||
return c.ParentCmd.Root()
|
||||
}
|
||||
|
||||
func (c Cmd) GetName() string {
|
||||
return c.Name
|
||||
}
|
||||
|
||||
func (c *Cmd) AddCmd(cmd *Cmd) {
|
||||
c.SubCmds = append(c.SubCmds, cmd)
|
||||
}
|
||||
|
||||
func (c Cmd) GetPromptOptSuggests() []prompt.Suggest {
|
||||
return c.getPromptSuggests(c.optArgs)
|
||||
}
|
||||
|
||||
func (c Cmd) GetPromptPosSuggests() []prompt.Suggest {
|
||||
return c.getPromptSuggests(c.posArgs)
|
||||
}
|
||||
|
||||
func (c Cmd) GetOptArguments() []structarg.Argument {
|
||||
return c.getArguments(c.optArgs)
|
||||
}
|
||||
|
||||
func (c Cmd) GetArguments() []structarg.Argument {
|
||||
ret := c.GetOptArguments()
|
||||
ret = append(ret, c.GetPosArguments()...)
|
||||
return ret
|
||||
}
|
||||
|
||||
func (c Cmd) GetPosArguments() []structarg.Argument {
|
||||
return c.getArguments(c.posArgs)
|
||||
}
|
||||
|
||||
func (c Cmd) getArguments(args []CmdArgument) []structarg.Argument {
|
||||
ret := make([]structarg.Argument, 0)
|
||||
for _, a := range args {
|
||||
ret = append(ret, a.Argument)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
type CmdArgument struct {
|
||||
Suggest prompt.Suggest
|
||||
Argument structarg.Argument
|
||||
}
|
||||
|
||||
func optionCompleter(args []string, long bool) []prompt.Suggest {
|
||||
l := len(args)
|
||||
if l == 0 {
|
||||
@@ -139,11 +47,11 @@ func optionCompleter(args []string, long bool) []prompt.Suggest {
|
||||
return optionHelp
|
||||
}
|
||||
|
||||
if subcmds[args[0]] == nil {
|
||||
if cmds[args[0]] == nil {
|
||||
return []prompt.Suggest{}
|
||||
}
|
||||
|
||||
_cmd := subcmds[args[0]].GetPromptOptSuggests()
|
||||
_cmd := cmds[args[0]].optArgs
|
||||
return prompt.FilterContains(_cmd, strings.TrimLeft(args[l-1], "-"), true)
|
||||
}
|
||||
|
||||
@@ -192,7 +100,7 @@ func argumentsCompleter(args []string) []prompt.Suggest {
|
||||
if len(args) == 1 {
|
||||
return prompt.FilterHasPrefix(commands, args[0], true)
|
||||
}
|
||||
_cmd, ok := subcmds[args[0]]
|
||||
_cmd, ok := cmds[args[0]]
|
||||
if !ok {
|
||||
return []prompt.Suggest{}
|
||||
}
|
||||
@@ -203,75 +111,48 @@ func argumentsCompleter(args []string) []prompt.Suggest {
|
||||
|
||||
prm := _cmd.posArgs[len(args)-2]
|
||||
subcommands := []prompt.Suggest{
|
||||
prm.Suggest,
|
||||
prm,
|
||||
}
|
||||
|
||||
return prompt.FilterHasPrefix(subcommands, args[len(args)-1], true)
|
||||
}
|
||||
|
||||
func AppendCommand(parentCmd *Cmd, text, desc string) {
|
||||
func AppendCommand(text, desc string) {
|
||||
commands = append(commands, prompt.Suggest{Text: text, Description: desc})
|
||||
cmd := &Cmd{
|
||||
Name: text,
|
||||
Desc: desc,
|
||||
posArgs: make([]CmdArgument, 0),
|
||||
optArgs: make([]CmdArgument, 0),
|
||||
ParentCmd: parentCmd,
|
||||
}
|
||||
subcmds[text] = cmd
|
||||
parentCmd.AddCmd(cmd)
|
||||
cmds[text] = &Cmd{}
|
||||
cmds[text].desc = desc
|
||||
cmds[text].posArgs = []prompt.Suggest{}
|
||||
cmds[text].optArgs = []prompt.Suggest{}
|
||||
}
|
||||
|
||||
func (c *Cmd) addArgument(target *[]CmdArgument, arg structarg.Argument, argStr string, desc string) {
|
||||
*target = append(*target, CmdArgument{
|
||||
Suggest: prompt.Suggest{
|
||||
Text: argStr,
|
||||
Description: desc,
|
||||
},
|
||||
Argument: arg,
|
||||
})
|
||||
func AppendPos(text, cmd, desc string) {
|
||||
var v = []prompt.Suggest{{Text: cmd, Description: desc}}
|
||||
cmds[text].posArgs = append(cmds[text].posArgs, v...)
|
||||
}
|
||||
|
||||
func (c *Cmd) AddPosArgument(arg structarg.Argument, argStr string, desc string) {
|
||||
c.addArgument(&c.posArgs, arg, argStr, desc)
|
||||
func AppendOpt(text, cmd, desc string) {
|
||||
var v = []prompt.Suggest{{Text: cmd, Description: desc}}
|
||||
cmds[text].optArgs = append(cmds[text].optArgs, v...)
|
||||
}
|
||||
|
||||
func (c *Cmd) AddOptArgument(arg structarg.Argument, argStr string, desc string) {
|
||||
c.addArgument(&c.optArgs, arg, argStr, desc)
|
||||
}
|
||||
|
||||
func AppendPos(text, cmd, desc string, arg structarg.Argument) {
|
||||
cmdObj := subcmds[text]
|
||||
cmdObj.AddPosArgument(arg, cmd, desc)
|
||||
}
|
||||
|
||||
func AppendOpt(text, cmd, desc string, arg structarg.Argument) {
|
||||
cmdObj := subcmds[text]
|
||||
cmdObj.AddOptArgument(arg, cmd, desc)
|
||||
}
|
||||
|
||||
func GenerateAutoCompleteCmds(rootCmd *Cmd, shell string) string {
|
||||
func GenerateAutoCompleteCmds(shell string) string {
|
||||
var ret = []string{}
|
||||
var i = 0
|
||||
if strings.ToLower(shell) == "zsh" {
|
||||
out := bytes.NewBufferString("")
|
||||
if err := rootCmd.GenZshCompletion(out); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return out.String()
|
||||
i = 1
|
||||
}
|
||||
for _, cmd := range subcmds {
|
||||
for cmd, options := range cmds {
|
||||
var (
|
||||
strPosArgs = []string{}
|
||||
strOptArgs = []string{}
|
||||
)
|
||||
for _, posArg := range cmd.GetPromptPosSuggests() {
|
||||
for _, posArg := range options.posArgs {
|
||||
strPosArgs = append(strPosArgs, posArg.Text)
|
||||
}
|
||||
for _, optArg := range cmd.GetPromptOptSuggests() {
|
||||
for _, optArg := range options.optArgs {
|
||||
strOptArgs = append(strOptArgs, strings.Split(optArg.Text, " ")[0])
|
||||
}
|
||||
ret = append(ret, fmt.Sprintf(`arr[%d]="%s# %s %s"`, i, cmd.Name,
|
||||
ret = append(ret, fmt.Sprintf(`arr[%d]="%s# %s %s"`, i, cmd,
|
||||
strings.Join(strPosArgs, " "), strings.Join(strOptArgs, " ")))
|
||||
i += 1
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package logger
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package servicetree
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package servicetree
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package servicetree
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package servicetree
|
||||
package shell
|
||||
|
||||
import (
|
||||
"strings"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ansible
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,32 +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 ansible
|
||||
|
||||
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
|
||||
|
||||
InvalidUpdateError = shell.InvalidUpdateError
|
||||
printObjectRecursive = printutils.PrintJSONObjectRecursive
|
||||
|
||||
exportList = shell.ExportList
|
||||
)
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ansible
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ansible
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -49,34 +49,4 @@ func init() {
|
||||
printList(apbs, modules.AnsiblePlaybooksV2.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
R(&AnsiblePlaybookV2IdOptions{}, "ansibleplaybookv2-run", "Run ansible playbook",
|
||||
func(s *mcclient.ClientSession, opts *AnsiblePlaybookV2IdOptions) error {
|
||||
apb, err := modules.AnsiblePlaybooksV2.PerformAction(s, opts.ID, "run", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(apb)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
R(&AnsiblePlaybookV2IdOptions{}, "ansibleplaybookv2-stop", "Stop ansible playbook",
|
||||
func(s *mcclient.ClientSession, opts *AnsiblePlaybookV2IdOptions) error {
|
||||
apb, err := modules.AnsiblePlaybooksV2.PerformAction(s, opts.ID, "stop", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(apb)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
R(&AnsiblePlaybookV2IdOptions{}, "ansibleplaybookv2-delete", "Delete ansible playbook",
|
||||
func(s *mcclient.ClientSession, opts *AnsiblePlaybookV2IdOptions) error {
|
||||
apb, err := modules.AnsiblePlaybooksV2.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(apb)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package logger
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -26,28 +26,18 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
"yunion.io/x/onecloud/pkg/multicloud/objectstore"
|
||||
objectshell "yunion.io/x/onecloud/pkg/multicloud/objectstore"
|
||||
)
|
||||
|
||||
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"`
|
||||
@@ -188,7 +169,7 @@ func init() {
|
||||
StorageClass string `help:"storage CLass"`
|
||||
Acl string `help:"object acl." choices:"private|public-read|public-read-write"`
|
||||
|
||||
objectstore.ObjectHeaderOptions
|
||||
objectshell.ObjectHeaderOptions
|
||||
}
|
||||
R(&BucketUploadObjectsOptions{}, "bucket-object-upload", "Upload an object into a bucket", func(s *mcclient.ClientSession, args *BucketUploadObjectsOptions) error {
|
||||
var body io.Reader
|
||||
@@ -325,7 +306,7 @@ func init() {
|
||||
|
||||
Key []string `help:"Optional object key" json:"key"`
|
||||
|
||||
objectstore.ObjectHeaderOptions
|
||||
objectshell.ObjectHeaderOptions
|
||||
}
|
||||
R(&BucketSetMetadataOptions{}, "bucket-set-metadata", "Set metadata of object", func(s *mcclient.ClientSession, args *BucketSetMetadataOptions) error {
|
||||
input := api.BucketMetadataInput{}
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -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 {
|
||||
@@ -125,22 +84,6 @@ func init() {
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
type SVMwareCloudAccountPrepareNetsOptions struct {
|
||||
Project string `help:"project for this account"`
|
||||
ProjectDomain string `help:"domain for this account"`
|
||||
NAME string `help:"name for this account"`
|
||||
options.SVMwareCredentialWithEnvironment
|
||||
}
|
||||
R(&SVMwareCloudAccountPrepareNetsOptions{}, "cloud-account-preparenets-vmware", "Prepare networks for a VMware cloud account before create this accout", func(s *mcclient.ClientSession, args *SVMwareCloudAccountPrepareNetsOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
params.(*jsonutils.JSONDict).Add(jsonutils.NewString("VMware"), "provider")
|
||||
result, err := modules.Cloudaccounts.PerformClassAction(s, "prepare-nets", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SAliyunCloudAccountCreateOptions{}, "cloud-account-create-aliyun", "Create an Aliyun cloud account", func(s *mcclient.ClientSession, args *options.SAliyunCloudAccountCreateOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
@@ -191,7 +134,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
|
||||
}
|
||||
@@ -430,19 +377,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)
|
||||
|
||||
@@ -484,7 +418,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()
|
||||
@@ -736,19 +670,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)
|
||||
@@ -769,129 +690,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"`
|
||||
@@ -955,14 +753,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
|
||||
}
|
||||
@@ -1022,47 +816,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
|
||||
})
|
||||
}
|
||||
@@ -1,25 +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 cloudevent
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/util/printutils"
|
||||
)
|
||||
|
||||
var (
|
||||
R = shell.R
|
||||
printList = printutils.PrintJSONList
|
||||
)
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudevent
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -1,168 +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 cloudid
|
||||
|
||||
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 CloudgroupListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
ClouduserId string `json:"clouduser_id"`
|
||||
CloudpolicyId string `json:"cloudpolicy_id"`
|
||||
Usable bool `json:"usable"`
|
||||
}
|
||||
R(&CloudgroupListOptions{}, "cloud-group-list", "List cloud groups", func(s *mcclient.ClientSession, opts *CloudgroupListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudgroups.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudgroups.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupCreateOptions struct {
|
||||
NAME string `json:"name"`
|
||||
PROVIDER string `json:"provider" choices:"Google|Aliyun|Aws|Huawei|Qcloud"`
|
||||
CloudpolicyIds []string `json:"cloudpolicy_ids"`
|
||||
Desc string `json:"description"`
|
||||
}
|
||||
|
||||
R(&CloudgroupCreateOptions{}, "cloud-group-create", "Create cloud group", func(s *mcclient.ClientSession, opts *CloudgroupCreateOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
result, err := modules.Cloudgroups.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupIdOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupIdOptions{}, "cloud-group-delete", "Delete cloud group", func(s *mcclient.ClientSession, opts *CloudgroupIdOptions) error {
|
||||
result, err := modules.Cloudgroups.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupIdOptions{}, "cloud-group-show", "Show cloud group", func(s *mcclient.ClientSession, opts *CloudgroupIdOptions) error {
|
||||
result, err := modules.Cloudgroups.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupIdOptions{}, "cloud-group-syncstatus", "Sync cloud group status", func(s *mcclient.ClientSession, opts *CloudgroupIdOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupPolicyOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
CLOUDPOLICY_ID string `help:"Cloudpolicy Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupPolicyOptions{}, "cloud-group-attach-policy", "Attach policy for cloud group", func(s *mcclient.ClientSession, opts *CloudgroupPolicyOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "attach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupPolicyOptions{}, "cloud-group-detach-policy", "Detach policy from cloud group", func(s *mcclient.ClientSession, opts *CloudgroupPolicyOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "detach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupUserOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
CLOUDUSER_ID string `help:"Clouduser Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupUserOptions{}, "cloud-group-add-user", "Add user to cloud group", func(s *mcclient.ClientSession, opts *CloudgroupUserOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "add-user", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupUserOptions{}, "cloud-group-remove-user", "Remove user from cloud group", func(s *mcclient.ClientSession, opts *CloudgroupUserOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "remove-user", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupPoliciesOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
CloudpolicyIds []string `json:"cloudpolicy_ids"`
|
||||
}
|
||||
|
||||
R(&CloudgroupPoliciesOptions{}, "cloud-group-set-policies", "Set cloudpolicies for cloud group", func(s *mcclient.ClientSession, opts *CloudgroupPoliciesOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "set-policies", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupUsersOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
ClouduserIds []string `json:"clouduser_ids"`
|
||||
}
|
||||
|
||||
R(&CloudgroupUsersOptions{}, "cloud-group-set-users", "Set users for cloud group", func(s *mcclient.ClientSession, opts *CloudgroupUsersOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "set-users", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,73 +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 cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudgroupcacheListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
CloudgroupId string `json:"cloudgroup_id"`
|
||||
}
|
||||
R(&CloudgroupcacheListOptions{}, "cloud-group-cache-list", "List cloud group caches", func(s *mcclient.ClientSession, opts *CloudgroupcacheListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudgroupcaches.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudgroupcaches.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupcacheIdOption struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupcacheIdOption{}, "cloud-group-cache-show", "Show cloud groupcache details", func(s *mcclient.ClientSession, opts *CloudgroupcacheIdOption) error {
|
||||
result, err := modules.Cloudgroupcaches.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupcacheIdOption{}, "cloud-group-cache-syncstatus", "Sync cloudgroupcache", func(s *mcclient.ClientSession, opts *CloudgroupcacheIdOption) error {
|
||||
result, err := modules.Cloudgroupcaches.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupcacheIdOption{}, "cloud-group-cache-delete", "Delete cloudgroupcache", func(s *mcclient.ClientSession, opts *CloudgroupcacheIdOption) error {
|
||||
result, err := modules.Cloudgroupcaches.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,72 +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 cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudgroupPolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
Cloudgroup string `help:"ID or Name of Cloudgroup"`
|
||||
Cloudpolicy string `help:"Policy ID or name"`
|
||||
}
|
||||
R(&CloudgroupPolicyListOptions{}, "cloud-group-policy-list", "List cloudgroup cloudpolicy pairs", func(s *mcclient.ClientSession, args *CloudgroupPolicyListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Cloudgroup) > 0 {
|
||||
result, err = modules.Cloudgrouppolicies.ListDescendent(s, args.Cloudgroup, params)
|
||||
} else if len(args.Cloudpolicy) > 0 {
|
||||
result, err = modules.Cloudgrouppolicies.ListDescendent2(s, args.Cloudpolicy, params)
|
||||
} else {
|
||||
result, err = modules.Cloudgrouppolicies.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudgrouppolicies.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupPolicyDetailOptions struct {
|
||||
CLOUDUSER string `help:"ID or Name of Cloudgroup"`
|
||||
CLOUDPOLICY string `help:"ID or Name of Cloudpolicy"`
|
||||
}
|
||||
R(&CloudgroupPolicyDetailOptions{}, "cloud-group-policy-show", "Show cloudgrouppolicy details", func(s *mcclient.ClientSession, args *CloudgroupPolicyDetailOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
result, err := modules.Cloudgrouppolicies.Get(s, args.CLOUDUSER, args.CLOUDPOLICY, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,72 +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 cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudgroupUserListOptions struct {
|
||||
options.BaseListOptions
|
||||
Cloudgroup string `help:"ID or Name of Cloudgroup"`
|
||||
Clouduser string `help:"User ID or name"`
|
||||
}
|
||||
R(&CloudgroupUserListOptions{}, "cloud-group-user-list", "List cloudgroup clouduser pairs", func(s *mcclient.ClientSession, args *CloudgroupUserListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Cloudgroup) > 0 {
|
||||
result, err = modules.Cloudgroupusers.ListDescendent(s, args.Cloudgroup, params)
|
||||
} else if len(args.Clouduser) > 0 {
|
||||
result, err = modules.Cloudgroupusers.ListDescendent2(s, args.Clouduser, params)
|
||||
} else {
|
||||
result, err = modules.Cloudgroupusers.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudgroupusers.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupUserDetailOptions struct {
|
||||
CLOUDUSER string `help:"ID or Name of Cloudgroup"`
|
||||
CLOUDPOLICY string `help:"ID or Name of Clouduser"`
|
||||
}
|
||||
R(&CloudgroupUserDetailOptions{}, "cloud-group-user-show", "Show cloudgroupuser details", func(s *mcclient.ClientSession, args *CloudgroupUserDetailOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
result, err := modules.Cloudgroupusers.Get(s, args.CLOUDUSER, args.CLOUDPOLICY, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,81 +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 cloudid
|
||||
|
||||
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 CloudpolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
ClouduserId string `json:"clouduser_id"`
|
||||
CloudgroupId string `json:"cloudgroup_id"`
|
||||
}
|
||||
R(&CloudpolicyListOptions{}, "cloud-policy-list", "List cloud policies", func(s *mcclient.ClientSession, opts *CloudpolicyListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudpolicies.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudpolicies.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudpolicyIdOptions struct {
|
||||
ID string `help:"Cloudpolicy Id"`
|
||||
}
|
||||
|
||||
R(&CloudpolicyIdOptions{}, "cloud-policy-show", "Sow cloud policiy details", func(s *mcclient.ClientSession, opts *CloudpolicyIdOptions) error {
|
||||
result, err := modules.Cloudpolicies.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudpolicyGroupOptions struct {
|
||||
ID string `help:"Cloudpolicy Id"`
|
||||
CLOUDGROUP_ID string `help:"Cloudgroup Id" json:"cloudgroup_id"`
|
||||
}
|
||||
|
||||
R(&CloudpolicyGroupOptions{}, "cloud-policy-assign-group", "Assign cloud policiy to group", func(s *mcclient.ClientSession, opts *CloudpolicyGroupOptions) error {
|
||||
result, err := modules.Cloudpolicies.PerformAction(s, opts.ID, "assign-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudpolicyGroupOptions{}, "cloud-policy-revoke-group", "Revoke cloud policiy from group", func(s *mcclient.ClientSession, opts *CloudpolicyGroupOptions) error {
|
||||
result, err := modules.Cloudpolicies.PerformAction(s, opts.ID, "revoke-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,72 +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 cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ClouduserPolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
Clouduser string `help:"ID or Name of Clouduser"`
|
||||
Cloudpolicy string `help:"Policy ID or name"`
|
||||
}
|
||||
R(&ClouduserPolicyListOptions{}, "cloud-user-policy-list", "List clouduser cloudpolicy pairs", func(s *mcclient.ClientSession, args *ClouduserPolicyListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Clouduser) > 0 {
|
||||
result, err = modules.Clouduserpolicies.ListDescendent(s, args.Clouduser, params)
|
||||
} else if len(args.Cloudpolicy) > 0 {
|
||||
result, err = modules.Clouduserpolicies.ListDescendent2(s, args.Cloudpolicy, params)
|
||||
} else {
|
||||
result, err = modules.Clouduserpolicies.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Clouduserpolicies.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserPolicyDetailOptions struct {
|
||||
CLOUDUSER string `help:"ID or Name of Clouduser"`
|
||||
CLOUDPOLICY string `help:"ID or Name of Cloudpolicy"`
|
||||
}
|
||||
R(&ClouduserPolicyDetailOptions{}, "cloud-user-policy-show", "Show clouduserpolicy details", func(s *mcclient.ClientSession, args *ClouduserPolicyDetailOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
result, err := modules.Clouduserpolicies.Get(s, args.CLOUDUSER, args.CLOUDPOLICY, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,197 +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 cloudid
|
||||
|
||||
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 ClouduserListOptions struct {
|
||||
options.BaseListOptions
|
||||
CloudaccountId string `help:"Cloudaccount Id"`
|
||||
CloudproviderId string `help:"Cloudprovider Id"`
|
||||
CloudpolicyId string `help:"filter cloudusers by cloudpolicy"`
|
||||
CloudgroupId string `help:"filter cloudusers by cloudgroup"`
|
||||
}
|
||||
R(&ClouduserListOptions{}, "cloud-user-list", "List cloud users", func(s *mcclient.ClientSession, opts *ClouduserListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudusers.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudusers.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserCreateOptions struct {
|
||||
Name string
|
||||
CloudaccountId string `help:"Cloudaccount Id"`
|
||||
CloudproviderId string `help:"Cloudprovider Id"`
|
||||
OwnerId string `help:"Owner Id"`
|
||||
CloudpolicyIds []string `help:"cloudpolicy ids"`
|
||||
CloudgroupIds []string `help:"cloudgroup ids"`
|
||||
Email string `help:"email address"`
|
||||
MobilePhone string `help:"phone number"`
|
||||
IsConsoleLogin *bool `help:"is console login"`
|
||||
Password string `help:"clouduser password"`
|
||||
}
|
||||
|
||||
R(&ClouduserCreateOptions{}, "cloud-user-create", "Create cloud user", func(s *mcclient.ClientSession, opts *ClouduserCreateOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
result, err := modules.Cloudusers.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserIdOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
}
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-delete", "Delete cloud user", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-logininfo", "Show cloud user login info", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.GetLoginInfo(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-show", "Show cloud user", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserSyncOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
PolicyOnly bool `help:"Ony sync clouduser policies for cloud"`
|
||||
}
|
||||
|
||||
R(&ClouduserSyncOptions{}, "cloud-user-sync", "Sync cloud user policies", func(s *mcclient.ClientSession, opts *ClouduserSyncOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "sync", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-syncstatus", "Sync cloud user status", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserPolicyOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
CLOUDPOLICY_ID string `help:"cloudpolicy Id"`
|
||||
}
|
||||
|
||||
R(&ClouduserPolicyOptions{}, "cloud-user-attach-policy", "Attach policy for cloud user", func(s *mcclient.ClientSession, opts *ClouduserPolicyOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "attach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserPolicyOptions{}, "cloud-user-detach-policy", "Detach policy from cloud user", func(s *mcclient.ClientSession, opts *ClouduserPolicyOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "detach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserPasswordOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
Password string `help:"clouduser password"`
|
||||
}
|
||||
|
||||
R(&ClouduserPasswordOptions{}, "cloud-user-reset-password", "Reset clouduser password", func(s *mcclient.ClientSession, opts *ClouduserPasswordOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "reset-password", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserChangeOwnerOptions struct {
|
||||
ID string `help:"clouduser id"`
|
||||
USER_ID string `help:"local user id"`
|
||||
}
|
||||
|
||||
R(&ClouduserChangeOwnerOptions{}, "cloud-user-change-owner", "Change clouduser owner", func(s *mcclient.ClientSession, opts *ClouduserChangeOwnerOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "change-owner", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserGroupOptions struct {
|
||||
ID string `help:"clouduser id"`
|
||||
CLOUDGROUP_ID string `help:"cloudgroup id" json:"cloudgroup_id"`
|
||||
}
|
||||
|
||||
R(&ClouduserGroupOptions{}, "cloud-user-join-group", "Join user to cloudgroup", func(s *mcclient.ClientSession, opts *ClouduserGroupOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "join-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserGroupOptions{}, "cloud-user-leave-group", "Leave from cloudgroup", func(s *mcclient.ClientSession, opts *ClouduserGroupOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "leave-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,26 +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 cloudid
|
||||
|
||||
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
|
||||
)
|
||||
@@ -15,19 +15,16 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/multicloud/zstack"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type QuotaListOptions struct {
|
||||
type CloudmetaOptions struct {
|
||||
PROVIDER_ID string `help:"provider_id"`
|
||||
REGION_ID string `help:"region_id"`
|
||||
ZONE_ID string `help:"zone_id"`
|
||||
}
|
||||
shellutils.R(&QuotaListOptions{}, "quota-list", "List quotas", func(cli *zstack.SRegion, args *QuotaListOptions) error {
|
||||
quotas, err := cli.GetQuotas()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(quotas, 0, 0, 0, nil)
|
||||
R(&CloudmetaOptions{}, "instance-type-list", "query backend service for its version", func(s *mcclient.ClientSession, args *CloudmetaOptions) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -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
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
@@ -12,11 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
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
|
||||
@@ -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 compute
|
||||
|
||||
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
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,34 +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 compute
|
||||
|
||||
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
|
||||
|
||||
InvalidUpdateError = shell.InvalidUpdateError
|
||||
printObjectRecursive = printutils.PrintJSONObjectRecursive
|
||||
|
||||
exportList = shell.ExportList
|
||||
|
||||
printObjectRecursiveEx = printutils.PrintJSONObjectRecursiveEx
|
||||
)
|
||||
@@ -1,109 +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 compute
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type GlobalVpcListOptions struct {
|
||||
options.BaseListOptions
|
||||
}
|
||||
R(&GlobalVpcListOptions{}, "global-vpc-list", "List global vpcs", func(s *mcclient.ClientSession, args *GlobalVpcListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.GlobalVpcs.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.GlobalVpcs.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type GlobalVpcShowOptions struct {
|
||||
ID string `help:"ID or Name of globalvpc"`
|
||||
}
|
||||
R(&GlobalVpcShowOptions{}, "global-vpc-show", "Show details of a global vpc", func(s *mcclient.ClientSession, args *GlobalVpcShowOptions) error {
|
||||
result, err := modules.GlobalVpcs.GetById(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
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
|
||||
})
|
||||
}
|
||||
@@ -1,62 +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 compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type PolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
}
|
||||
R(&PolicyListOptions{}, "policy-definition-list", "List policy definitions", func(s *mcclient.ClientSession, args *PolicyListOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.PolicyDefinition.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.PolicyDefinition.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type PolicyIdOptions struct {
|
||||
ID string `help:"policy definition name or id"`
|
||||
}
|
||||
|
||||
R(&PolicyIdOptions{}, "policy-definition-show", "Show policy definition", func(s *mcclient.ClientSession, args *PolicyIdOptions) error {
|
||||
result, err := modules.PolicyDefinition.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&PolicyIdOptions{}, "policy-definition-syncstatus", "Sync policy definition status", func(s *mcclient.ClientSession, args *PolicyIdOptions) error {
|
||||
result, err := modules.PolicyDefinition.PerformAction(s, args.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,101 +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 compute
|
||||
|
||||
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() {
|
||||
R(&options.ProxySettingCreateOptions{}, "proxysetting-create", "Create proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingCreateOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proxysetting, err := modules.ProxySettings.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(proxysetting)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingGetOptions{}, "proxysetting-show", "Show proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingGetOptions) error {
|
||||
proxysetting, err := modules.ProxySettings.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(proxysetting)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingListOptions{}, "proxysetting-list", "List proxysettings", func(s *mcclient.ClientSession, opts *options.ProxySettingListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ProxySettings.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.ProxySettings.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingUpdateOptions{}, "proxysetting-update", "Update proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingUpdateOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
proxysetting, err := modules.ProxySettings.Update(s, opts.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(proxysetting)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingDeleteOptions{}, "proxysetting-delete", "Delete proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingDeleteOptions) error {
|
||||
proxysetting, err := modules.ProxySettings.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(proxysetting)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingTestOptions{}, "proxysetting-test", "Test proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingTestOptions) error {
|
||||
proxysetting, err := modules.ProxySettings.PerformAction(s, opts.ID, "test", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(proxysetting)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingPublicOptions{}, "proxysetting-public", "Make proxysetting public", func(s *mcclient.ClientSession, opts *options.ProxySettingPublicOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
result, err := modules.ProxySettings.PerformAction(s, opts.ID, "public", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingPrivateOptions{}, "proxysetting-private", "Make proxysetting private", func(s *mcclient.ClientSession, opts *options.ProxySettingPrivateOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
result, err := modules.ProxySettings.PerformAction(s, opts.ID, "private", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,41 +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 compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ScalingActivityListOptions struct {
|
||||
options.BaseListOptions
|
||||
}
|
||||
R(&ScalingActivityListOptions{}, "scaling-activity-list", "List Scaling Activity",
|
||||
func(s *mcclient.ClientSession, args *ScalingActivityListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
list, err := modules.ScalingActivity.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(list, modules.ScalingActivity.GetColumns(s))
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -1,145 +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 compute
|
||||
|
||||
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 ScalingGroupListOptions struct {
|
||||
options.BaseListOptions
|
||||
Hypervisor string `help:"Hypervisor"`
|
||||
Cloudregion string `help:"Cloudregion"`
|
||||
Network string `help:"network"`
|
||||
}
|
||||
R(&ScalingGroupListOptions{}, "scaling-group-list", "List scaling group", func(s *mcclient.ClientSession, args *ScalingGroupListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ScalingGroup.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.ScalingGroup.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScalingGroupShowOptions struct {
|
||||
ID string
|
||||
}
|
||||
R(&ScalingGroupShowOptions{}, "scaling-group-show", "Show scaling group", func(s *mcclient.ClientSession,
|
||||
args *ScalingGroupShowOptions) error {
|
||||
result, err := modules.ScalingGroup.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScalingGroupCreateOptions struct {
|
||||
NAME string
|
||||
|
||||
Hypervisor string
|
||||
Cloudregion string
|
||||
Network string
|
||||
GuestTemplate string
|
||||
MinInstanceNumber string
|
||||
MaxInstanceNumber string
|
||||
DesireInstanceNumber string
|
||||
Loadbalance string
|
||||
}
|
||||
R(&ScalingGroupCreateOptions{}, "scaling-group-create", "Create scaling group", func(s *mcclient.ClientSession, args *ScalingGroupCreateOptions) error {
|
||||
params := jsonutils.Marshal(args).(*jsonutils.JSONDict)
|
||||
scalingGroup, err := modules.ScalingGroup.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(scalingGroup)
|
||||
return nil
|
||||
})
|
||||
type ScalingGroupDeleteOptions struct {
|
||||
ID string `help:"ScalingGroup ID or Name"`
|
||||
}
|
||||
R(&ScalingGroupDeleteOptions{}, "scaling-group-delete", "Delete Scaling Group", func(s *mcclient.ClientSession,
|
||||
args *ScalingGroupDeleteOptions) error {
|
||||
scalingGroup, err := modules.ScalingGroup.Delete(s, args.ID, jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(scalingGroup)
|
||||
return nil
|
||||
})
|
||||
type ScalingGroupListInstanceOptions struct {
|
||||
ID string `help:"ScalingGroup ID or Name"`
|
||||
}
|
||||
R(&ScalingGroupListInstanceOptions{}, "scaling-group-list-instance", "List all instance of Scaling Group",
|
||||
func(s *mcclient.ClientSession, args *ScalingGroupListInstanceOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("scaling_group", jsonutils.NewString(args.ID))
|
||||
servers, err := modules.Servers.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(servers, modules.Servers.GetColumns(s))
|
||||
return nil
|
||||
},
|
||||
)
|
||||
type ScalingGroupRemoveInstanceOptions struct {
|
||||
ID string `help:"ScalingGroup ID or Name"`
|
||||
SERVER string `help:"Server ID or Name"`
|
||||
Delete bool `help:"If delete the server"`
|
||||
}
|
||||
R(&ScalingGroupRemoveInstanceOptions{}, "scaling-group-remove-instance", "Remove instance of ScalingGroup",
|
||||
func(s *mcclient.ClientSession, args *ScalingGroupRemoveInstanceOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("scaling_group", jsonutils.NewString(args.ID))
|
||||
params.Set("delete_server", jsonutils.NewBool(args.Delete))
|
||||
server, err := modules.Servers.PerformAction(s, args.SERVER, "detach-scaling-group", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(server)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
type ScalingGroupEnableOptions struct {
|
||||
ID string `help:"ScalingGroup ID or Name"`
|
||||
}
|
||||
R(&ScalingGroupEnableOptions{}, "scaling-group-enable", "Enable ScalingGroup", func(s *mcclient.ClientSession,
|
||||
args *ScalingGroupEnableOptions) error {
|
||||
ret, err := modules.ScalingGroup.PerformAction(s, args.ID, "enable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
R(&ScalingGroupEnableOptions{}, "scaling-group-disable", "Disable ScalingGroup", func(s *mcclient.ClientSession,
|
||||
args *ScalingGroupEnableOptions) error {
|
||||
ret, err := modules.ScalingGroup.PerformAction(s, args.ID, "disable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,202 +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 compute
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
type Timer struct {
|
||||
TimingExecTime string `help:"Exectime for 'timing' type trigger, format:'2006-01-02 15:04:05'" json:"exec_time"`
|
||||
}
|
||||
|
||||
type CycleTimer struct {
|
||||
CycleCycleType string `help:"Cycle type for cycle timer" json:"cycle_type" choices:"day|week|month"`
|
||||
CycleMinute int `help:"Minute of cycle timer" json:"minute"`
|
||||
CycleHour int `help:"Hour of cycle timer" json:"hour"`
|
||||
CycleWeekdays []int `help:"Weekdays for cycle timer" json:"weekdays"`
|
||||
CycleMonthDays []int `help:"Month days for cycle timer" json:"month_days"`
|
||||
CycleStartTime string `help:"Start time for cycle timer, format:'2006-01-02 15:04:05'" json:"start_time"`
|
||||
CycleEndTime string `help:"End time for cycle timer, format:'2006-01-02 15:04:05'" json:"end_time"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
type ScalingPolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
ScalingGroup string `help:"ScalingGroup ID or Name"`
|
||||
TriggerType string `help:"Trigger type" choices:"alarm|timing|cycle"`
|
||||
}
|
||||
R(&ScalingPolicyListOptions{}, "scaling-policy-list", "List Scaling Policy", func(s *mcclient.ClientSession,
|
||||
args *ScalingPolicyListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
policies, err := modules.ScalingPolicy.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(policies, modules.ScalingPolicy.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScalingPolicyShowOptions struct {
|
||||
ID string `help:"ScalingPolicy ID or Name"`
|
||||
}
|
||||
R(&ScalingPolicyShowOptions{}, "scaling-policy-show", "Show Scaling Policy", func(s *mcclient.ClientSession,
|
||||
args *ScalingPolicyShowOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("details", jsonutils.JSONTrue)
|
||||
policy, err := modules.ScalingPolicy.Get(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(policy)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScalingAlarm struct {
|
||||
AlarmCumulate int `help:"Cumulate times alarm will trigger, for 'alarm' trigger" json:"cumulate"`
|
||||
AlarmCycle int `help:"Monitoring cycle for indicators, for 'alarm' trigger" json:"cycle"`
|
||||
AlarmIndicator string `help:"Indicator for 'alarm' trigger" json:"indicator"`
|
||||
AlarmWrapper string `help:"Wrapper for Indicators" choices:"max|min|average" json:"wrapper"`
|
||||
AlarmOperator string `help:"Operator between Indicator and Operator" json:"operator"`
|
||||
AlarmValue float64 `help:"Value of Indicator" json:"value"`
|
||||
}
|
||||
|
||||
type ScalingPolicyCreateOptions struct {
|
||||
NAME string `help:"ScalingPolicy Name" json:"name"`
|
||||
ScalingGroup string `help:"ScalingGroup ID or Name" json:"scaling_group"`
|
||||
TriggerType string `help:"Trigger type" choices:"alarm|timing|cycle" json:"trigger_type"`
|
||||
|
||||
Timer
|
||||
CycleTimer
|
||||
ScalingAlarm
|
||||
|
||||
Action string `help:"Action for scaling policy" choices:"add|remove|set" json:"action"`
|
||||
Number int `help:"Instance number for action" json:"number"`
|
||||
Unit string `help:"Unit for Number" choices:"s|%" json:"unit"`
|
||||
CoolingTime int `help:"Cooling time, unit: s" json:"cooling_time"`
|
||||
}
|
||||
|
||||
R(&ScalingPolicyCreateOptions{}, "scaling-policy-create", "Create Scaling Policy",
|
||||
func(s *mcclient.ClientSession, args *ScalingPolicyCreateOptions) error {
|
||||
formatStr := "2006-01-02 15:04:05"
|
||||
timingExecTime, err := time.Parse(formatStr, args.TimingExecTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'exec_time'")
|
||||
}
|
||||
cycleStarTime, err := time.Parse(formatStr, args.CycleStartTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'start_time'")
|
||||
}
|
||||
cycleEndTime, err := time.Parse(formatStr, args.CycleEndTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'end_time'")
|
||||
}
|
||||
spCreateInput := api.ScalingPolicyCreateInput{
|
||||
ScalingGroup: args.ScalingGroup,
|
||||
TriggerType: args.TriggerType,
|
||||
Timer: api.TimerCreateInput{
|
||||
ExecTime: timingExecTime,
|
||||
},
|
||||
CycleTimer: api.CycleTimerCreateInput{
|
||||
CycleType: args.CycleCycleType,
|
||||
Minute: args.CycleMinute,
|
||||
Hour: args.CycleHour,
|
||||
WeekDays: args.CycleWeekdays,
|
||||
MonthDays: args.CycleMonthDays,
|
||||
StartTime: cycleStarTime,
|
||||
EndTime: cycleEndTime,
|
||||
},
|
||||
Alarm: api.ScalingAlarmCreateInput{
|
||||
Cumulate: args.AlarmCumulate,
|
||||
Cycle: args.AlarmCycle,
|
||||
Indicator: args.AlarmIndicator,
|
||||
Wrapper: args.AlarmWrapper,
|
||||
Operator: args.AlarmOperator,
|
||||
Value: args.AlarmValue,
|
||||
},
|
||||
Action: args.Action,
|
||||
Number: args.Number,
|
||||
Unit: args.Unit,
|
||||
CoolingTime: args.CoolingTime,
|
||||
}
|
||||
spCreateInput.Name = args.NAME
|
||||
ret, err := modules.ScalingPolicy.Create(s, jsonutils.Marshal(spCreateInput))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScalingPolicyEnableOptions struct {
|
||||
ID string `help:"ScalingPolicy ID or Name"`
|
||||
}
|
||||
R(&ScalingPolicyEnableOptions{}, "scaling-policy-enable", "Enable ScalingPolicy", func(s *mcclient.ClientSession,
|
||||
args *ScalingPolicyEnableOptions) error {
|
||||
ret, err := modules.ScalingPolicy.PerformAction(s, args.ID, "enable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
R(&ScalingPolicyEnableOptions{}, "scaling-policy-disable", "Disable ScalingPolicy",
|
||||
func(s *mcclient.ClientSession, args *ScalingPolicyEnableOptions) error {
|
||||
ret, err := modules.ScalingPolicy.PerformAction(s, args.ID, "disable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScalingPolicyTriggerOptions struct {
|
||||
ID string `help:"ScalingPolicy ID or Name"`
|
||||
}
|
||||
R(&ScalingPolicyTriggerOptions{}, "scaling-policy-trigger", "Trigger ScalingPolicy's action",
|
||||
func(s *mcclient.ClientSession, args *ScalingPolicyTriggerOptions) error {
|
||||
ret, err := modules.ScalingPolicy.PerformAction(s, args.ID, "trigger", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScalingPolicyDeleteOptions struct {
|
||||
ID string `help:"ScalingPolicy ID or Name"`
|
||||
}
|
||||
R(&ScalingPolicyDeleteOptions{}, "scaling-policy-delete", "Delete SclaingPolicy",
|
||||
func(s *mcclient.ClientSession, args *ScalingPolicyDeleteOptions) error {
|
||||
ret, err := modules.ScalingPolicy.Delete(s, args.ID, jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -1,211 +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 compute
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
apis "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ScheduledTaskListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
ScheduledType string `help:"scheduled type" choices:"timing|cycle"`
|
||||
ResourceType string `help:"resource type"`
|
||||
Operation string `help:"operation"`
|
||||
}
|
||||
R(&ScheduledTaskListOptions{}, "scheduledtask-list", "list Scheduled Task", func(s *mcclient.ClientSession, args *ScheduledTaskListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
tasks, err := modules.ScheduledTask.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(tasks, modules.ScheduledTask.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScheduledTaskShowOptions struct {
|
||||
ID string `help:"ScheduledTask ID or Name"`
|
||||
}
|
||||
R(&ScheduledTaskShowOptions{}, "scheudled-task-show", "Show Scheduled Task", func(s *mcclient.ClientSession,
|
||||
args *ScheduledTaskShowOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("details", jsonutils.JSONTrue)
|
||||
task, err := modules.ScheduledTask.Get(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(task)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScheduledTaskCreateOptions struct {
|
||||
NAME string `help:"ScheduledTask Name" json:"name"`
|
||||
ScheduledType string `help:"Scheudled Type" choices:"timing|cycle" json:"scheduled_type"`
|
||||
|
||||
Timer
|
||||
CycleTimer
|
||||
|
||||
ResourceType string `help:"resource type"`
|
||||
Operation string `help:"operation"`
|
||||
LabelType string `help:"label type"`
|
||||
Labels []string `help:"labels"`
|
||||
}
|
||||
R(&ScheduledTaskCreateOptions{}, "scheduledtask-create", "Create Scheduled Task", func(s *mcclient.ClientSession, args *ScheduledTaskCreateOptions) error {
|
||||
formatStr := "2006-01-02 15:04:05"
|
||||
var exectime, starttime, endtime time.Time
|
||||
var err error
|
||||
if len(args.TimingExecTime) > 0 {
|
||||
exectime, err = time.Parse(formatStr, args.TimingExecTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'exec_time'")
|
||||
}
|
||||
}
|
||||
if len(args.CycleStartTime) > 0 {
|
||||
starttime, err = time.Parse(formatStr, args.CycleStartTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'start_time'")
|
||||
}
|
||||
}
|
||||
if len(args.CycleEndTime) > 0 {
|
||||
endtime, err = time.Parse(formatStr, args.CycleEndTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'end_time'")
|
||||
}
|
||||
}
|
||||
stCreateInput := apis.ScheduledTaskCreateInput{
|
||||
ScheduledType: args.ScheduledType,
|
||||
Timer: apis.TimerCreateInput{
|
||||
ExecTime: exectime,
|
||||
},
|
||||
CycleTimer: apis.CycleTimerCreateInput{
|
||||
CycleType: args.CycleCycleType,
|
||||
Minute: args.CycleMinute,
|
||||
Hour: args.CycleHour,
|
||||
WeekDays: args.CycleWeekdays,
|
||||
MonthDays: args.CycleMonthDays,
|
||||
StartTime: starttime,
|
||||
EndTime: endtime,
|
||||
},
|
||||
ResourceType: args.ResourceType,
|
||||
Operation: args.Operation,
|
||||
LabelType: args.LabelType,
|
||||
Labels: args.Labels,
|
||||
}
|
||||
stCreateInput.Name = args.NAME
|
||||
ret, err := modules.ScheduledTask.Create(s, jsonutils.Marshal(stCreateInput))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScheduledTaskEnableOptions struct {
|
||||
ID string `help:"ScheduledTask ID or Name"`
|
||||
}
|
||||
R(&ScheduledTaskEnableOptions{}, "scheduledtask-enable", "Enable ScheduledTask", func(s *mcclient.ClientSession,
|
||||
args *ScheduledTaskEnableOptions) error {
|
||||
ret, err := modules.ScheduledTask.PerformAction(s, args.ID, "enable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
R(&ScheduledTaskEnableOptions{}, "scheduledtask-disable", "Disable ScheduledTask",
|
||||
func(s *mcclient.ClientSession, args *ScheduledTaskEnableOptions) error {
|
||||
ret, err := modules.ScheduledTask.PerformAction(s, args.ID, "disable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScheduledTaskSetLabelsOptions struct {
|
||||
ID string `help:"ScheduledTask ID or Name"`
|
||||
Labels []string `help:"Label"`
|
||||
}
|
||||
R(&ScheduledTaskSetLabelsOptions{}, "scheduledtask-setlabels", "Trigger ScheduledTask's action",
|
||||
func(s *mcclient.ClientSession, args *ScheduledTaskSetLabelsOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("labels", jsonutils.Marshal(args.Labels))
|
||||
ret, err := modules.ScheduledTask.PerformAction(s, args.ID, "set-labels", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScheduledTaskTriggerOptions struct {
|
||||
ID string `help:"ScheduledTask ID or Name"`
|
||||
}
|
||||
R(&ScheduledTaskTriggerOptions{}, "scheduledtask-trigger", "Trigger ScheduledTask",
|
||||
func(s *mcclient.ClientSession, args *ScheduledTaskTriggerOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
ret, err := modules.ScheduledTask.PerformAction(s, args.ID, "trigger", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScheduledTaskDeleteOptions struct {
|
||||
ID string `help:"ScheduledTask ID or Name"`
|
||||
}
|
||||
R(&ScheduledTaskDeleteOptions{}, "scheduledtask-delete", "Delete ScheduledTask",
|
||||
func(s *mcclient.ClientSession, args *ScheduledTaskDeleteOptions) error {
|
||||
ret, err := modules.ScheduledTask.Delete(s, args.ID, jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScheduledTaskAvtivityListOptions struct {
|
||||
options.BaseListOptions
|
||||
ScheduledTask string `help:"Scheduled Task" json:"scheduled_task"`
|
||||
}
|
||||
R(&ScheduledTaskAvtivityListOptions{}, "scheduledtask-activity-list", "List Scheduled Task Activity",
|
||||
func(s *mcclient.ClientSession, args *ScheduledTaskAvtivityListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
list, err := modules.ScheduledTaskActivity.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(list, modules.ScheduledTaskActivity.GetColumns(s))
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -1,72 +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 compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ServerSecgroupListOptions struct {
|
||||
options.BaseListOptions
|
||||
Server string `help:"ID or Name of Server"`
|
||||
Secgroup string `help:"Secgroup ID or name"`
|
||||
}
|
||||
R(&ServerSecgroupListOptions{}, "server-secgroup-list", "List server secgroup pairs", func(s *mcclient.ClientSession, args *ServerSecgroupListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Server) > 0 {
|
||||
result, err = modules.Serversecgroups.ListDescendent(s, args.Server, params)
|
||||
} else if len(args.Secgroup) > 0 {
|
||||
result, err = modules.Serversecgroups.ListDescendent2(s, args.Secgroup, params)
|
||||
} else {
|
||||
result, err = modules.Serversecgroups.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Serversecgroups.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ServerSecgroupDetailOptions struct {
|
||||
SERVER string `help:"ID or Name of Server"`
|
||||
SECGROUP string `help:"ID or Name of Security Group"`
|
||||
}
|
||||
R(&ServerSecgroupDetailOptions{}, "server-secgroup-show", "Show server security group details", func(s *mcclient.ClientSession, args *ServerSecgroupDetailOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
result, err := modules.Serversecgroups.Get(s, args.SERVER, args.SECGROUP, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package notify
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package notify
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user