mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-21 00:24:07 +08:00
Compare commits
551 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
301006e213 | ||
|
|
950a2c29fb | ||
|
|
558872db27 | ||
|
|
6386391bf4 | ||
|
|
d298c75448 | ||
|
|
28cb75f41b | ||
|
|
560a68d379 | ||
|
|
9e597db90a | ||
|
|
9c9cb17d32 | ||
|
|
cc96c01c00 | ||
|
|
cb22077722 | ||
|
|
8e3c173373 | ||
|
|
45e092bd2d | ||
|
|
4b2d67de42 | ||
|
|
6677c30a5d | ||
|
|
64593fc882 | ||
|
|
0d7e1a2517 | ||
|
|
6fc835abb9 | ||
|
|
44a9cc5adb | ||
|
|
ff2b7eb345 | ||
|
|
7b5d822373 | ||
|
|
f5a45fc16e | ||
|
|
a583bbc74b | ||
|
|
ece82cce42 | ||
|
|
8042b9430c | ||
|
|
d1cbaead09 | ||
|
|
1768d1e7db | ||
|
|
ff34e93862 | ||
|
|
a891d1d876 | ||
|
|
c7d6bb7811 | ||
|
|
2076a75113 | ||
|
|
5d0d6d960b | ||
|
|
cf89e8a23a | ||
|
|
45994b59d5 | ||
|
|
d2d2934e80 | ||
|
|
0ec0c8e703 | ||
|
|
3347d6c1e1 | ||
|
|
dce9d5e4a1 | ||
|
|
ef9b64990e | ||
|
|
f19fe2178c | ||
|
|
2265c9422f | ||
|
|
cf3717557a | ||
|
|
0bbdcb9278 | ||
|
|
d72081770e | ||
|
|
0f874d8f07 | ||
|
|
dd5dd15a76 | ||
|
|
cb36572c1c | ||
|
|
2a210407a5 | ||
|
|
82c59154c5 | ||
|
|
041ee6f904 | ||
|
|
4317fac6da | ||
|
|
a022f99851 | ||
|
|
407251975e | ||
|
|
b7fd879e44 | ||
|
|
0a7ccbe958 | ||
|
|
7efb85ba04 | ||
|
|
84e8e4e6c8 | ||
|
|
3fe15d2675 | ||
|
|
d574a823ba | ||
|
|
a2c8ad13ab | ||
|
|
de8f57f625 | ||
|
|
658159b18e | ||
|
|
67cc7b8747 | ||
|
|
ce694ff638 | ||
|
|
98702c2470 | ||
|
|
9ac5265c07 | ||
|
|
896bec8f43 | ||
|
|
a8426482bf | ||
|
|
d7316b26aa | ||
|
|
d16affc9a6 | ||
|
|
2259fe1195 | ||
|
|
09e37de117 | ||
|
|
715db28e3e | ||
|
|
152ea54f36 | ||
|
|
865b433bb0 | ||
|
|
f04a37d0a3 | ||
|
|
7edcd151e3 | ||
|
|
df90d99bc5 | ||
|
|
552ce3b2ea | ||
|
|
91c852676a | ||
|
|
8528d79817 | ||
|
|
d2aacafa4c | ||
|
|
8714503087 | ||
|
|
d0d3d8e333 | ||
|
|
dee1aa26dc | ||
|
|
c973bf1632 | ||
|
|
1aa82ae950 | ||
|
|
488e7e56a6 | ||
|
|
6a2ebdc123 | ||
|
|
4105284718 | ||
|
|
ac5f29bc0c | ||
|
|
58d52d947c | ||
|
|
c5ef564d35 | ||
|
|
1cacf1068f | ||
|
|
63b0d0c071 | ||
|
|
39a45229af | ||
|
|
e82cf184f1 | ||
|
|
afa16944c0 | ||
|
|
8f953e41da | ||
|
|
6e0180656d | ||
|
|
718bf0d537 | ||
|
|
9fbd4f0599 | ||
|
|
078b1d635a | ||
|
|
b8e0599e3f | ||
|
|
27bd564d2d | ||
|
|
5b79ba5607 | ||
|
|
c9d20d13f1 | ||
|
|
779d4a9acf | ||
|
|
1bc4b3cb90 | ||
|
|
49887e540a | ||
|
|
7ce0d7b44b | ||
|
|
e8d737ff6c | ||
|
|
fd954efcf2 | ||
|
|
e9415ae49e | ||
|
|
5b0afbdc6b | ||
|
|
ec393a6e3c | ||
|
|
adccad3487 | ||
|
|
76f794d1a2 | ||
|
|
bba2cf23fd | ||
|
|
b8f8c3bae4 | ||
|
|
7f3c0103d0 | ||
|
|
499ddeba32 | ||
|
|
7e191a503c | ||
|
|
94eb72fb3c | ||
|
|
02bcce195c | ||
|
|
5c4423bcbe | ||
|
|
9b7fbf33b8 | ||
|
|
a7a8ad1931 | ||
|
|
6c8b30e1be | ||
|
|
8cdab93c15 | ||
|
|
8a28d26271 | ||
|
|
29fa258c6e | ||
|
|
7a61d77b06 | ||
|
|
552dd2bfd1 | ||
|
|
60c42975a8 | ||
|
|
ad53ddd84b | ||
|
|
e87d2c0e86 | ||
|
|
a9c95cf363 | ||
|
|
540f4631f4 | ||
|
|
6db3ec81ea | ||
|
|
abc2be7e5e | ||
|
|
b0e1d0de23 | ||
|
|
fba8349e84 | ||
|
|
9bd70e3cb6 | ||
|
|
f931deb41f | ||
|
|
324e7435ac | ||
|
|
1a1d7c70ad | ||
|
|
3a773f87d3 | ||
|
|
11ea89795a | ||
|
|
288b9e02af | ||
|
|
b88c114ba6 | ||
|
|
aa3ff8ac5b | ||
|
|
3b0ba2caa9 | ||
|
|
4dff79bdd0 | ||
|
|
a4d7b2b4b3 | ||
|
|
f2b0fa1911 | ||
|
|
c1a963801f | ||
|
|
95456e3e08 | ||
|
|
41c84ca8ec | ||
|
|
e6de7be7e1 | ||
|
|
3ddce26aa0 | ||
|
|
d94e55501a | ||
|
|
a9ca6e0a8a | ||
|
|
ad22483113 | ||
|
|
4e9af39d73 | ||
|
|
a05f50dbf0 | ||
|
|
adbe292f48 | ||
|
|
61cc180101 | ||
|
|
1fd043c99b | ||
|
|
82c0dcfb38 | ||
|
|
ea5fbef0c2 | ||
|
|
c1d66fc4e7 | ||
|
|
b7423baf1f | ||
|
|
0ca3349d58 | ||
|
|
8dde6a6ac4 | ||
|
|
0d2d5b0728 | ||
|
|
da8529a00a | ||
|
|
73aee11474 | ||
|
|
5229c06dfc | ||
|
|
37b2b30af5 | ||
|
|
7baaf23f84 | ||
|
|
1b6ac9bc48 | ||
|
|
1215d723af | ||
|
|
4586c82cb2 | ||
|
|
5460f22444 | ||
|
|
f5cf093e0f | ||
|
|
77865d894e | ||
|
|
454aabca75 | ||
|
|
c6d2149914 | ||
|
|
ebee608109 | ||
|
|
7e2e7ade19 | ||
|
|
5d39338d60 | ||
|
|
3903af786b | ||
|
|
91cac5c217 | ||
|
|
12ef953b70 | ||
|
|
d029dc22c0 | ||
|
|
0deb8ea928 | ||
|
|
1ffa6f5295 | ||
|
|
37b9a2e53d | ||
|
|
f6a620ac46 | ||
|
|
5f50314df6 | ||
|
|
9ded6e43f1 | ||
|
|
547b2960b1 | ||
|
|
116d347c88 | ||
|
|
e0c94daaf7 | ||
|
|
679ccb825a | ||
|
|
857e76ab78 | ||
|
|
0d05f9ee18 | ||
|
|
7e362cae3d | ||
|
|
54ee77db03 | ||
|
|
95b82d299d | ||
|
|
e4605d8c3b | ||
|
|
652eb65252 | ||
|
|
310baa266b | ||
|
|
5f2c771f73 | ||
|
|
d90b661f7e | ||
|
|
8d28bfc6d2 | ||
|
|
c7b8e84ffe | ||
|
|
b5088230bf | ||
|
|
4038bfb8a1 | ||
|
|
afb8924762 | ||
|
|
796c3d1d48 | ||
|
|
57a2258d94 | ||
|
|
365e555c98 | ||
|
|
63603359e7 | ||
|
|
fc3b794515 | ||
|
|
51020aac04 | ||
|
|
32470e2ad3 | ||
|
|
975e7fb1e8 | ||
|
|
1c786a034b | ||
|
|
2d5055c908 | ||
|
|
471e2b4f13 | ||
|
|
8da2d5ff7a | ||
|
|
043fdcfec2 | ||
|
|
09bebcf5f4 | ||
|
|
d917e8e386 | ||
|
|
7d163f63a1 | ||
|
|
8ce445487b | ||
|
|
6cff31add6 | ||
|
|
7698dcf506 | ||
|
|
a7e537f4df | ||
|
|
d23ffbb997 | ||
|
|
c38cb271f8 | ||
|
|
c4c07c4e9d | ||
|
|
682fa5e5bd | ||
|
|
cefe057dc8 | ||
|
|
1026b74e65 | ||
|
|
ccce0a4be5 | ||
|
|
9a04238b77 | ||
|
|
a7198dc21b | ||
|
|
78fc35d3a6 | ||
|
|
70fd9dfb70 | ||
|
|
572e45968d | ||
|
|
35842df1bd | ||
|
|
b32eddce03 | ||
|
|
8102e7ed00 | ||
|
|
f659ccd0d5 | ||
|
|
27fe6bc38d | ||
|
|
b118f341bc | ||
|
|
59a5e9201e | ||
|
|
430e9cd0fc | ||
|
|
5b6b5eeb7d | ||
|
|
384e866649 | ||
|
|
884e82a150 | ||
|
|
b3c235fe30 | ||
|
|
686df64ea9 | ||
|
|
d8fa8a49fb | ||
|
|
1afeca5687 | ||
|
|
304457a3b4 | ||
|
|
0bba6e63f0 | ||
|
|
bb3317cc32 | ||
|
|
becf92f6bf | ||
|
|
632ab6c2f9 | ||
|
|
cb0b0bea41 | ||
|
|
6f324b0ea1 | ||
|
|
0acbfc89f3 | ||
|
|
477d36f827 | ||
|
|
caa26b7567 | ||
|
|
d0bb0afa2d | ||
|
|
cb3884b1c5 | ||
|
|
10524ecc9a | ||
|
|
33fb33a589 | ||
|
|
a4b2af90c5 | ||
|
|
3f7155c39c | ||
|
|
b13d0f6035 | ||
|
|
62c0c11c30 | ||
|
|
6bff7caf9b | ||
|
|
27d0452faf | ||
|
|
b1a332fec1 | ||
|
|
bc066edc09 | ||
|
|
0b878134b6 | ||
|
|
986031fc97 | ||
|
|
8164854fd0 | ||
|
|
8dc1796768 | ||
|
|
a54d0e5920 | ||
|
|
822fae0095 | ||
|
|
23b9991a7b | ||
|
|
4fb45676a4 | ||
|
|
93e5f8ec97 | ||
|
|
29dde04145 | ||
|
|
b69d04ee20 | ||
|
|
d0af7f9b23 | ||
|
|
e444ab7a15 | ||
|
|
c4f4e7d30b | ||
|
|
5f35bba0d0 | ||
|
|
760ac9900f | ||
|
|
be00107c12 | ||
|
|
17cd333b64 | ||
|
|
346c8ec564 | ||
|
|
aecf977801 | ||
|
|
7a044d1ac1 | ||
|
|
5f9088d240 | ||
|
|
12bd187ec9 | ||
|
|
c1a0b8a8b5 | ||
|
|
1d7ffc704e | ||
|
|
ebdefa1f23 | ||
|
|
02dc68f20d | ||
|
|
9047c8de39 | ||
|
|
ae3073da48 | ||
|
|
ab2567d17d | ||
|
|
ba03954e50 | ||
|
|
6c6b7bb6fa | ||
|
|
b3f62ee186 | ||
|
|
bc66fd558a | ||
|
|
4164bf58c1 | ||
|
|
5593b88e98 | ||
|
|
785da09d62 | ||
|
|
585ef58332 | ||
|
|
8e0f47aa0c | ||
|
|
4487867f53 | ||
|
|
9b12c675d2 | ||
|
|
a2d7bd16a2 | ||
|
|
10625a4b26 | ||
|
|
e64ac81f87 | ||
|
|
e42afce6f3 | ||
|
|
ad0b9e3bd3 | ||
|
|
d4e2158caf | ||
|
|
a09932d8ac | ||
|
|
2a680f99a7 | ||
|
|
7601ca437a | ||
|
|
967d46bbf6 | ||
|
|
a475a7b416 | ||
|
|
0d798412e1 | ||
|
|
a1ba06a927 | ||
|
|
cc5e0cd7ca | ||
|
|
ada7352469 | ||
|
|
ef9dac1a86 | ||
|
|
f71d26d2b2 | ||
|
|
82e38b8f51 | ||
|
|
5c71349fe2 | ||
|
|
f24950da96 | ||
|
|
0308ce2882 | ||
|
|
cee07e7861 | ||
|
|
8eba2c369f | ||
|
|
5a10f9dd9c | ||
|
|
c542249c7c | ||
|
|
fa2d8723a6 | ||
|
|
523b0d132f | ||
|
|
6bfca36cb7 | ||
|
|
e41c29e6d0 | ||
|
|
6010b253f2 | ||
|
|
0a5ee4ca67 | ||
|
|
77f479ce60 | ||
|
|
f8b7d96c62 | ||
|
|
fda5c3aaa5 | ||
|
|
0e88ac81c3 | ||
|
|
6b5339900b | ||
|
|
60b1eddfd8 | ||
|
|
7cf5ad9133 | ||
|
|
8a0f940b38 | ||
|
|
a1c7a291d5 | ||
|
|
891b7223f1 | ||
|
|
9ef5a43513 | ||
|
|
490a0a7fe5 | ||
|
|
06c27791bb | ||
|
|
690c3b23a4 | ||
|
|
6bc6309253 | ||
|
|
7b67554dcc | ||
|
|
ce777855a2 | ||
|
|
9607420298 | ||
|
|
4e7e8a59dc | ||
|
|
2e93ee3d6d | ||
|
|
6a7cf0608d | ||
|
|
5f7734b0c3 | ||
|
|
413ba9ddd4 | ||
|
|
0048507211 | ||
|
|
d6d490af6c | ||
|
|
70297e3130 | ||
|
|
5576819f01 | ||
|
|
dc20313ef5 | ||
|
|
fb7b5d5a95 | ||
|
|
3f77c01e6b | ||
|
|
5ec2490be5 | ||
|
|
dba92d4b0b | ||
|
|
6f77c22573 | ||
|
|
f653b36733 | ||
|
|
aa26c6ec99 | ||
|
|
0e0df0999b | ||
|
|
5f0b86950b | ||
|
|
d1660c83a9 | ||
|
|
f302756eda | ||
|
|
90185c0074 | ||
|
|
55b2b29001 | ||
|
|
ac69f8a590 | ||
|
|
42faf34f15 | ||
|
|
3f8f9e6c56 | ||
|
|
6b340264e4 | ||
|
|
ef8768fcef | ||
|
|
9281c54294 | ||
|
|
2ad1a4afe5 | ||
|
|
1a323667ad | ||
|
|
0268d95853 | ||
|
|
025eca548f | ||
|
|
4cea5a1c9f | ||
|
|
cb1c8d7961 | ||
|
|
408f975f40 | ||
|
|
621c2796d6 | ||
|
|
d10adf22d7 | ||
|
|
3ef91f92e5 | ||
|
|
e75e5a9b95 | ||
|
|
348ca46a08 | ||
|
|
6000874b3c | ||
|
|
89980b6267 | ||
|
|
d086161a68 | ||
|
|
39fed764fe | ||
|
|
426699ada9 | ||
|
|
82d297eb77 | ||
|
|
92ecdb5f8d | ||
|
|
ada6c870d8 | ||
|
|
86dd4804a3 | ||
|
|
cecaa127ea | ||
|
|
4d68b5fb61 | ||
|
|
8a329b2b29 | ||
|
|
c50659a1e4 | ||
|
|
a30df54cb9 | ||
|
|
b192e949de | ||
|
|
a33a21f712 | ||
|
|
78f9db1ba0 | ||
|
|
72276d038d | ||
|
|
f1995a46d8 | ||
|
|
918dce80e8 | ||
|
|
12899ab007 | ||
|
|
e758c4aa97 | ||
|
|
623c71b143 | ||
|
|
f0faf07b61 | ||
|
|
8c4941ea70 | ||
|
|
4cd73c16ca | ||
|
|
0a79d1d23e | ||
|
|
d22676906c | ||
|
|
74b3bf2c6a | ||
|
|
c94a90398e | ||
|
|
b57bbc66c7 | ||
|
|
4f9c37239e | ||
|
|
8524fda7f8 | ||
|
|
bfa4ce38e0 | ||
|
|
70d790187e | ||
|
|
7095ea8f8b | ||
|
|
4edff8ae34 | ||
|
|
fd750e0a9c | ||
|
|
f0ae739747 | ||
|
|
7f5124bdf2 | ||
|
|
c5c2b4b699 | ||
|
|
29edf83293 | ||
|
|
1c3bbb70a3 | ||
|
|
390d6f07e1 | ||
|
|
41e2757973 | ||
|
|
a7160e7518 | ||
|
|
01f07c6044 | ||
|
|
24af17757d | ||
|
|
b4252c7c25 | ||
|
|
4853883947 | ||
|
|
82795f2daf | ||
|
|
cf056fe42a | ||
|
|
1aa16871eb | ||
|
|
4dfd459b14 | ||
|
|
3d1bce5f51 | ||
|
|
5ff14eb618 | ||
|
|
57c0706d9e | ||
|
|
4dfa6f8b19 | ||
|
|
0619da6f14 | ||
|
|
f62912dd5b | ||
|
|
29a3db9ff6 | ||
|
|
c50497090e | ||
|
|
47f5f9edc1 | ||
|
|
ff52e00448 | ||
|
|
7c6e053a08 | ||
|
|
8c6fdd1106 | ||
|
|
beee6e2c9f | ||
|
|
60412cf7e8 | ||
|
|
90b84e995b | ||
|
|
851b2d4bb7 | ||
|
|
ab02e166e9 | ||
|
|
10caff1d9c | ||
|
|
82b7e659ad | ||
|
|
9e1a7c5e12 | ||
|
|
5cc25ae10a | ||
|
|
cfd76b23a3 | ||
|
|
65ca3ace74 | ||
|
|
00265fedda | ||
|
|
976dbd7796 | ||
|
|
c050629ba2 | ||
|
|
949e2ebed9 | ||
|
|
dc19a10323 | ||
|
|
612ad9286b | ||
|
|
32bc9b45a1 | ||
|
|
03456eaaa9 | ||
|
|
d03fddcd7d | ||
|
|
893085a2c6 | ||
|
|
a85a1aecd4 | ||
|
|
c3d7168622 | ||
|
|
06c0ada74c | ||
|
|
6e5f5b2ea3 | ||
|
|
eb9d794fab | ||
|
|
20b949091e | ||
|
|
43ce3b5455 | ||
|
|
d95e64e593 | ||
|
|
06bd735f0b | ||
|
|
607e3d8fdc | ||
|
|
800dd26c60 | ||
|
|
77a5c1ff85 | ||
|
|
bde5e1b96a | ||
|
|
82942006b6 | ||
|
|
836151eee3 | ||
|
|
0566e1dec7 | ||
|
|
b03c8ce506 | ||
|
|
c914dafa75 | ||
|
|
6c30c1c789 | ||
|
|
adf8885a7a | ||
|
|
cca2267389 | ||
|
|
538bc873a0 | ||
|
|
9812864bce | ||
|
|
4af4bcb963 | ||
|
|
b85fb98297 | ||
|
|
19ba4b9755 | ||
|
|
438c1ced5f | ||
|
|
be5bf11ebe | ||
|
|
6cea2883ab | ||
|
|
5647a6842d | ||
|
|
fba76c6392 | ||
|
|
6ed3a48333 | ||
|
|
53a6c40a8a | ||
|
|
eee193165e | ||
|
|
5987b56297 | ||
|
|
8e83ab4768 | ||
|
|
b977641336 | ||
|
|
132c583790 | ||
|
|
557240155d | ||
|
|
3243e5a035 | ||
|
|
e3fe66e8eb | ||
|
|
de80f17053 | ||
|
|
aef249ea8e |
@@ -38,7 +38,7 @@ jobs:
|
||||
command: |
|
||||
targets="$(circleci tests glob "cmd/*" | grep -v cmd/host-image | circleci tests split)"
|
||||
echo $targets | tr ' ' '\n'
|
||||
make -j2 $targets
|
||||
make -j3 $targets
|
||||
ls -lh _output/bin/
|
||||
- save_cache:
|
||||
key: onecloud-build-cache-{{ checksum "go.mod" }}-{{ checksum "Makefile" }}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
_output/alpine-build/_cache
|
||||
pkg
|
||||
vendor
|
||||
cmd
|
||||
locales
|
||||
docs
|
||||
scripts
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,7 +31,6 @@ _output
|
||||
/structargtest
|
||||
.idea
|
||||
.vscode
|
||||
intellij.yaml
|
||||
GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
|
||||
6
Makefile
6
Makefile
@@ -9,7 +9,7 @@ BUILD_SCRIPT := $(ROOT_DIR)/build/build.sh
|
||||
|
||||
ifeq ($(ONECLOUD_CI_BUILD),)
|
||||
GIT_COMMIT := $(shell git rev-parse --short HEAD)
|
||||
GIT_BRANCH := $(shell git branch -r --contains | head -1 | sed -E -e "s%(HEAD ->|origin|upstream)/?%%g" | xargs)
|
||||
GIT_BRANCH := $(shell git name-rev --name-only HEAD)
|
||||
GIT_VERSION := $(shell git describe --always --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')
|
||||
@@ -199,7 +199,7 @@ mod:
|
||||
go mod vendor -v
|
||||
|
||||
|
||||
DOCKER_CENTOS_BUILD_IMAGE?=registry.cn-beijing.aliyuncs.com/yunionio/centos-build:1.1-3
|
||||
DOCKER_CENTOS_BUILD_IMAGE?=registry.cn-beijing.aliyuncs.com/yunionio/centos-build:1.1-1
|
||||
|
||||
define dockerCentOSBuildCmd
|
||||
set -o xtrace
|
||||
@@ -232,7 +232,7 @@ docker-centos-build-stop:
|
||||
.PHONY: docker-centos-build
|
||||
.PHONY: docker-centos-build-stop
|
||||
|
||||
DOCKER_ALPINE_BUILD_IMAGE?=registry.cn-beijing.aliyuncs.com/yunionio/alpine-build:1.0-5
|
||||
DOCKER_ALPINE_BUILD_IMAGE?=registry.cn-beijing.aliyuncs.com/yunionio/alpine-build:1.0-3
|
||||
|
||||
define dockerAlpineBuildCmd
|
||||
set -o xtrace
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
## 架构
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## 贡献
|
||||
|
||||
@@ -44,7 +44,7 @@ Please refers to [install & deployment](https://docs.yunion.io/docs/setup/) (cur
|
||||
|
||||
## Architecture
|
||||
|
||||

|
||||

|
||||
|
||||
## Contribution
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# rbac for project owner, not allow for delete
|
||||
roles:
|
||||
- domain_admin
|
||||
scope: domain
|
||||
policy:
|
||||
'*': allow
|
||||
@@ -1,10 +1,9 @@
|
||||
# rbac for normal user, not allow for delete
|
||||
scope: project
|
||||
policy:
|
||||
'*':
|
||||
'*':
|
||||
'*': allow
|
||||
create: deny
|
||||
update: deny
|
||||
delete: deny
|
||||
perform:
|
||||
purge: deny
|
||||
clone: deny
|
||||
'*': allow
|
||||
@@ -1,2 +0,0 @@
|
||||
policy:
|
||||
'*': allow
|
||||
@@ -0,0 +1,6 @@
|
||||
# rbac for project owner, not allow for delete
|
||||
roles:
|
||||
- project_owner
|
||||
scope: project
|
||||
policy:
|
||||
'*': allow
|
||||
8
build/climc/root/opt/yunion/scripts/rbac/sysadmin.yaml
Normal file
8
build/climc/root/opt/yunion/scripts/rbac/sysadmin.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
# rbac for sysadmin
|
||||
projects:
|
||||
- system
|
||||
roles:
|
||||
- admin
|
||||
scope: system
|
||||
policy:
|
||||
'*': allow
|
||||
@@ -1,6 +0,0 @@
|
||||
policy:
|
||||
'*':
|
||||
'*':
|
||||
get: allow
|
||||
list: allow
|
||||
'*': deny
|
||||
@@ -1,6 +0,0 @@
|
||||
公有云子账号创建成功
|
||||
主账号:{{ .account }}<br>
|
||||
名称:{{ .name }}<br>
|
||||
密码:{{ .password }}<br>
|
||||
登录地址: {{ .iam_login_url }}<br>
|
||||
资源ID: {{ .id }}<br>
|
||||
@@ -1,6 +0,0 @@
|
||||
Clouduser has been created successfully
|
||||
Root Account: {{ .account }}<br>
|
||||
Name:{{ .name }}<br>
|
||||
Password:{{ .password }}<br>
|
||||
IAM Login URL: {{ .iam_login_url }}<br>
|
||||
Resource ID: {{ .id }}<br>
|
||||
@@ -1 +0,0 @@
|
||||
公有云子账号 {{ .name }} 创建成功
|
||||
@@ -1 +0,0 @@
|
||||
The clouduser {{ .name }} created successfully
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:0.6
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:v0.5
|
||||
|
||||
MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com"
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/yunion-rootfs:v1.0
|
||||
|
||||
ADD ./_output/bin/telegraf-raid-plugin /opt/yunion/bin/telegraf-raid-plugin
|
||||
16
build/docker/multi-arch/Dockerfile.esxi-agent
Normal file
16
build/docker/multi-arch/Dockerfile.esxi-agent
Normal file
@@ -0,0 +1,16 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/alpine-build:1.0-3 as build
|
||||
ARG TARGETPLATFORM
|
||||
ARG BUILDPLATFORM
|
||||
RUN mkdir -p /root/go/src/yunion.io/x/onecloud
|
||||
COPY . /root/go/src/yunion.io/x/onecloud
|
||||
|
||||
WORKDIR /root/go/src/yunion.io/x/onecloud
|
||||
RUN make cmd/esxi-agent
|
||||
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.2
|
||||
|
||||
MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com"
|
||||
|
||||
RUN mkdir -p /opt/yunion/bin
|
||||
COPY --from=build /root/go/src/yunion.io/x/onecloud/build/esxi-agent/root/opt/ /opt/
|
||||
COPY --from=build /root/go/src/yunion.io/x/onecloud/_output/bin/esxi-agent /opt/yunion/bin/esxi-agent
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/alpine-build:1.0-5 as build
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/alpine-build:1.0-3 as build
|
||||
ARG TARGETPLATFORM
|
||||
ARG BUILDPLATFORM
|
||||
RUN mkdir -p /root/go/src/yunion.io/x/onecloud
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/alpine-build:1.0-5 as build
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/alpine-build:1.0-3 as build
|
||||
ARG TARGETPLATFORM
|
||||
ARG BUILDPLATFORM
|
||||
RUN mkdir -p /root/go/src/yunion.io/x/onecloud
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
## {{.title}}
|
||||
- 时间: {{.start_time}}
|
||||
- 级别: {{.level}}
|
||||
- 详情地址: {{.web_url}}/commonalerts
|
||||
|
||||
{{ range .matches}}
|
||||
- 指标: {{.metric}}
|
||||
- 触发值: {{html .value_str}}
|
||||
|
||||
### 触发条件:
|
||||
- {{html $.description}}
|
||||
|
||||
### 标签
|
||||
> 名称: {{ index .tags "name" }}
|
||||
> ip: {{ index .tags "ip" }}
|
||||
> 平台: {{ index .tags "brand" }}
|
||||
------
|
||||
{{- end}}
|
||||
@@ -92,7 +92,7 @@
|
||||
</table>
|
||||
<table class="table" style="padding-top: 6px; padding-bottom: 10px;">
|
||||
<tr>
|
||||
<td style="padding-left: 20px; font-size: 14px;">若要查看详情信息,<a class="link" target="_blank" href="{{.web_url}}
|
||||
<td style="padding-left: 20px; font-size: 14px;">若要查看详情信息,<a class="link" target="_blank" href="{{.web_url}}/commonalerts
|
||||
">请登录平台进行查看</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -0,0 +1,18 @@
|
||||
## {{.title}}
|
||||
- Time: {{.start_time}}
|
||||
- Level: {{.level}}
|
||||
- WebUrl: {{.web_url}}/commonalerts
|
||||
|
||||
{{ range .matches}}
|
||||
- Metric: {{.metric}}
|
||||
- Trigger value: {{html .value_str}}
|
||||
|
||||
### Trigger condition:
|
||||
- {{html $.description }}
|
||||
|
||||
### Label
|
||||
> Name: {{ index .tags "name" }}
|
||||
> IP: {{ index .tags "ip" }}
|
||||
> Brand: {{ index .tags "brand" }}
|
||||
------
|
||||
{{- end}}
|
||||
@@ -33,7 +33,7 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
.td {
|
||||
width: 120px;
|
||||
width: 80px;
|
||||
padding-left: 20px;
|
||||
height: 35px;
|
||||
font-weight: 400;
|
||||
@@ -92,8 +92,8 @@
|
||||
</table>
|
||||
<table class="table" style="padding-top: 6px; padding-bottom: 10px;">
|
||||
<tr>
|
||||
<td style="padding-left: 20px; font-size: 14px;">To view details,<a class="link" target="_blank" href="{{.web_url}}
|
||||
">Please login to the platform to view</a></td>
|
||||
<td style="padding-left: 20px; font-size: 14px;">To view details,<a class="link" target="_blank" href="{{.web_url}}/commonalerts
|
||||
">Please log in to the platform to view</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border="0" cellspacing="0" cellpadding="0" class="table pb-3">
|
||||
@@ -1,9 +0,0 @@
|
||||
{{.title}}
|
||||
策略名称: {{.name}}
|
||||
触发时间: {{.start_time}}
|
||||
报警级别: {{.level}}
|
||||
触发条件: {{.description | unescaped}}
|
||||
资源数量:{{len .matches}}
|
||||
资源名称:{{.resource_name}}
|
||||
|
||||
详情地址: {{.web_url}}
|
||||
@@ -1,9 +0,0 @@
|
||||
{{.title}}
|
||||
AlertName: {{.name}}
|
||||
Time: {{.start_time}}
|
||||
Level: {{.level}}
|
||||
TriggerCondition: {{.description | unescaped}}
|
||||
ResourceCount: {{len .matches}}
|
||||
ResourceName: {{.resource_name}}
|
||||
|
||||
WebUrl: {{.web_url}}
|
||||
@@ -47,7 +47,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-bottom: 10px;">您正在验证邮箱,请在验证码输入框中输入:{{.code}},以完成验证。</td>
|
||||
<td style="padding-bottom: 10px;">您正在验证邮箱,请在验证码输入框中输入:{{.code}},已完成验证。</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
@@ -1 +0,0 @@
|
||||
{{.os_type}} image {{.name}} upload completed
|
||||
@@ -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;">Product</a>
|
||||
</td>
|
||||
<td style="padding-left: 20px; padding-right: 20px;">
|
||||
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">Solution</a>
|
||||
</td>
|
||||
<td style="padding-left: 20px; padding-right: 20px;">
|
||||
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">Service</a>
|
||||
</td>
|
||||
<td style="padding-left: 20px; padding-right: 20px;">
|
||||
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">Help and Documentation</a>
|
||||
</td>
|
||||
<td style="padding-left: 20px; padding-right: 20px;">
|
||||
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">About</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: 13px;">
|
||||
Dear {{.name}}:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-bottom: 13px;">You are verifying your email, please enter the following code on the email verification page:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-bottom: 10px; font-size: large">{{.code}}</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;">If you are not operating by yourself, please log in to the platform in time and change your password to ensure the security of your account.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="background: #333; text-align: right; padding-right: 20px; font-size: 12px; color: #fff; height: 50px;">Copyrights © {{.copyright}}. All rights reserved.</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
Yunion Verify
|
||||
@@ -1 +0,0 @@
|
||||
{{.copyright}} Verify
|
||||
@@ -1 +0,0 @@
|
||||
Image {{.name}} upload completed
|
||||
@@ -1 +0,0 @@
|
||||
{{.copyright}} Verify
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
type BaseOptions struct {
|
||||
Debug bool `help:"debug mode"`
|
||||
Help bool `help:"Show help"`
|
||||
CloudEnv string `help:"Cloud environment" default:"$ALIYUN_CLOUD_ENV" choices:"InternationalCloud|FinanceCloud" metavar:"ALIYUN_CLOUD_ENV"`
|
||||
AccessKey string `help:"Access key" default:"$ALIYUN_ACCESS_KEY" metavar:"ALIYUN_ACCESS_KEY"`
|
||||
Secret string `help:"Secret" default:"$ALIYUN_SECRET" metavar:"ALIYUN_SECRET"`
|
||||
RegionId string `help:"RegionId" default:"$ALIYUN_REGION" metavar:"ALIYUN_REGION"`
|
||||
@@ -87,9 +86,7 @@ func newClient(options *BaseOptions) (*aliyun.SRegion, error) {
|
||||
|
||||
cli, err := aliyun.NewAliyunClient(
|
||||
aliyun.NewAliyunClientConfig(
|
||||
options.CloudEnv,
|
||||
options.AccessKey,
|
||||
options.Secret,
|
||||
options.AccessKey, options.Secret,
|
||||
).Debug(options.Debug),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,146 +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 (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"yunion.io/x/structarg"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud/apsara"
|
||||
_ "yunion.io/x/onecloud/pkg/multicloud/apsara/shell"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
)
|
||||
|
||||
type BaseOptions struct {
|
||||
Debug bool `help:"debug mode"`
|
||||
Help bool `help:"Show help"`
|
||||
AccessKey string `help:"Access key" default:"$APSARA_ACCESS_KEY" metavar:"APSARA_ACCESS_KEY"`
|
||||
Secret string `help:"Secret" default:"$APSARA_SECRET" metavar:"APSARA_SECRET"`
|
||||
cloudprovider.SApsaraEndpoints `help:"Endpoints for Apsara"`
|
||||
Endpoint string `help:"Apsara endpoint" default:"$APSARA_ENDPOINT" metavar:"APSARA_ENDPOINT"`
|
||||
RegionId string `help:"RegionId" default:"$APSARA_REGION" metavar:"APSARA_REGION"`
|
||||
SUBCOMMAND string `help:"apsaracli subcommand" subcommand:"true"`
|
||||
}
|
||||
|
||||
func getSubcommandParser() (*structarg.ArgumentParser, error) {
|
||||
parse, e := structarg.NewArgumentParser(&BaseOptions{},
|
||||
"apsaracli",
|
||||
"Command-line interface to apsara API.",
|
||||
`See "apsaracli help COMMAND" for help on a specific command.`)
|
||||
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
|
||||
subcmd := parse.GetSubcommand()
|
||||
if subcmd == nil {
|
||||
return nil, fmt.Errorf("No subcommand argument.")
|
||||
}
|
||||
type HelpOptions struct {
|
||||
SUBCOMMAND string `help:"sub-command name"`
|
||||
}
|
||||
shellutils.R(&HelpOptions{}, "help", "Show help of a subcommand", func(args *HelpOptions) error {
|
||||
helpstr, e := subcmd.SubHelpString(args.SUBCOMMAND)
|
||||
if e != nil {
|
||||
return e
|
||||
} else {
|
||||
fmt.Print(helpstr)
|
||||
return nil
|
||||
}
|
||||
})
|
||||
for _, v := range shellutils.CommandTable {
|
||||
_, e := subcmd.AddSubParser(v.Options, v.Command, v.Desc, v.Callback)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
}
|
||||
return parse, nil
|
||||
}
|
||||
|
||||
func showErrorAndExit(e error) {
|
||||
fmt.Fprintf(os.Stderr, "%s", e)
|
||||
fmt.Fprintln(os.Stderr)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func newClient(options *BaseOptions) (*apsara.SRegion, error) {
|
||||
if len(options.AccessKey) == 0 {
|
||||
return nil, fmt.Errorf("Missing accessKey")
|
||||
}
|
||||
|
||||
if len(options.Secret) == 0 {
|
||||
return nil, fmt.Errorf("Missing secret")
|
||||
}
|
||||
|
||||
cli, err := apsara.NewApsaraClient(
|
||||
apsara.NewApsaraClientConfig(
|
||||
options.AccessKey,
|
||||
options.Secret,
|
||||
options.Endpoint,
|
||||
options.SApsaraEndpoints,
|
||||
).Debug(options.Debug),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
region := cli.GetRegion(options.RegionId)
|
||||
if region == nil {
|
||||
return nil, fmt.Errorf("No such region %s", options.RegionId)
|
||||
}
|
||||
|
||||
return region, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
parser, e := getSubcommandParser()
|
||||
if e != nil {
|
||||
showErrorAndExit(e)
|
||||
}
|
||||
e = parser.ParseArgs(os.Args[1:], false)
|
||||
options := parser.Options().(*BaseOptions)
|
||||
|
||||
if options.Help {
|
||||
fmt.Print(parser.HelpString())
|
||||
return
|
||||
}
|
||||
subcmd := parser.GetSubcommand()
|
||||
subparser := subcmd.GetSubParser()
|
||||
if e != nil {
|
||||
if subparser != nil {
|
||||
fmt.Print(subparser.Usage())
|
||||
} else {
|
||||
fmt.Print(parser.Usage())
|
||||
}
|
||||
showErrorAndExit(e)
|
||||
}
|
||||
suboptions := subparser.Options()
|
||||
if options.SUBCOMMAND == "help" {
|
||||
e = subcmd.Invoke(suboptions)
|
||||
} else {
|
||||
var region *apsara.SRegion
|
||||
region, e = newClient(options)
|
||||
if e != nil {
|
||||
showErrorAndExit(e)
|
||||
}
|
||||
e = subcmd.Invoke(region, suboptions)
|
||||
}
|
||||
if e != nil {
|
||||
showErrorAndExit(e)
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,6 @@ import (
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/monitor"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/notifyv2"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/servicetree"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/suggestion"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/yunionconf"
|
||||
)
|
||||
|
||||
|
||||
@@ -17,22 +17,22 @@ package cloudid
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options/cloudid"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudgroups).WithKeyword("cloud-group")
|
||||
cmd.List(&cloudid.CloudgroupListOptions{})
|
||||
cmd.Create(&cloudid.CloudgroupCreateOptions{})
|
||||
cmd.Show(&cloudid.CloudgroupIdOptions{})
|
||||
cmd.Delete(&cloudid.CloudgroupIdOptions{})
|
||||
cmd.Perform("syncstatus", &cloudid.CloudgroupIdOptions{})
|
||||
cmd.Perform("attach-policy", &cloudid.CloudgroupPolicyOptions{})
|
||||
cmd.Perform("detach-policy", &cloudid.CloudgroupPolicyOptions{})
|
||||
cmd.Perform("add-user", &cloudid.CloudgroupUserOptions{})
|
||||
cmd.Perform("remove-user", &cloudid.CloudgroupUserOptions{})
|
||||
cmd.Perform("set-policies", &cloudid.CloudgroupPolicyOptions{})
|
||||
cmd.Perform("set-users", &cloudid.CloudgroupUserOptions{})
|
||||
cmd.Perform("public", &cloudid.CloudgroupPublicOptions{})
|
||||
cmd.Perform("private", &cloudid.CloudgroupIdOptions{})
|
||||
cmd.List(&options.CloudgroupListOptions{})
|
||||
cmd.Create(&options.CloudgroupCreateOptions{})
|
||||
cmd.Show(&options.CloudgroupIdOptions{})
|
||||
cmd.Delete(&options.CloudgroupIdOptions{})
|
||||
cmd.Perform("syncstatus", &options.CloudgroupIdOptions{})
|
||||
cmd.Perform("attach-policy", &options.CloudgroupPolicyOptions{})
|
||||
cmd.Perform("detach-policy", &options.CloudgroupPolicyOptions{})
|
||||
cmd.Perform("add-user", &options.CloudgroupUserOptions{})
|
||||
cmd.Perform("remove-user", &options.CloudgroupUserOptions{})
|
||||
cmd.Perform("set-policies", &options.CloudgroupPolicyOptions{})
|
||||
cmd.Perform("set-users", &options.CloudgroupUserOptions{})
|
||||
cmd.Perform("public", &options.CloudgroupPublicOptions{})
|
||||
cmd.Perform("private", &options.CloudgroupIdOptions{})
|
||||
}
|
||||
|
||||
@@ -15,15 +15,59 @@
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options/cloudid"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudgroupcaches).WithKeyword("cloud-group-cache")
|
||||
cmd.List(&cloudid.CloudgroupcacheListOptions{})
|
||||
cmd.Show(&cloudid.CloudgroupcacheIdOption{})
|
||||
cmd.Delete(&cloudid.CloudgroupcacheIdOption{})
|
||||
cmd.Perform("syncstatus", &cloudid.CloudgroupcacheIdOption{})
|
||||
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
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -15,12 +15,58 @@
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"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/cloudid"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudgrouppolicies).WithKeyword("cloud-group-policy").WithContextManager(&modules.Cloudgroups)
|
||||
cmd.List(&cloudid.CloudgroupPolicyListOptions{})
|
||||
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
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -15,12 +15,58 @@
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"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/cloudid"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudgroupusers).WithKeyword("cloud-group-user").WithContextManager(&modules.Cloudusers)
|
||||
cmd.List(&cloudid.CloudgroupUserListOptions{})
|
||||
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
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -17,18 +17,18 @@ package cloudid
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options/cloudid"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudpolicies).WithKeyword("cloud-policy")
|
||||
cmd.Create(&cloudid.CloudpolicyListOptions{})
|
||||
cmd.List(&cloudid.CloudpolicyListOptions{})
|
||||
cmd.Show(&cloudid.CloudpolicyIdOptions{})
|
||||
cmd.Update(&cloudid.CloudpolicyUpdateOption{})
|
||||
cmd.Perform("syncstauts", &cloudid.CloudpolicyIdOptions{})
|
||||
cmd.Perform("lock", &cloudid.CloudpolicyIdOptions{})
|
||||
cmd.Perform("unlock", &cloudid.CloudpolicyIdOptions{})
|
||||
cmd.Perform("assign-group", &cloudid.CloudpolicyGroupOptions{})
|
||||
cmd.Perform("revoke-group", &cloudid.CloudpolicyGroupOptions{})
|
||||
cmd.Create(&options.CloudpolicyListOptions{})
|
||||
cmd.List(&options.CloudpolicyListOptions{})
|
||||
cmd.Show(&options.CloudpolicyIdOptions{})
|
||||
cmd.Update(&options.CloudpolicyUpdateOption{})
|
||||
cmd.Perform("syncstauts", &options.CloudpolicyIdOptions{})
|
||||
cmd.Perform("lock", &options.CloudpolicyIdOptions{})
|
||||
cmd.Perform("unlock", &options.CloudpolicyIdOptions{})
|
||||
cmd.Perform("assign-group", &options.CloudpolicyGroupOptions{})
|
||||
cmd.Perform("revoke-group", &options.CloudpolicyGroupOptions{})
|
||||
}
|
||||
|
||||
@@ -15,12 +15,28 @@
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options/cloudid"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudpolicycaches).WithKeyword("cloud-policy-cache")
|
||||
cmd.List(&cloudid.CloudpolicycacheListOptions{})
|
||||
type CloudpolicycacheListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
CloudpolyId string
|
||||
CloudaccountId string
|
||||
}
|
||||
R(&CloudpolicycacheListOptions{}, "cloud-policy-cache-list", "List cloud policy caches", func(s *mcclient.ClientSession, opts *CloudpolicycacheListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudpolicycaches.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudpolicycaches.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,29 +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/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options/cloudid"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudroles).WithKeyword("cloud-role")
|
||||
cmd.List(&cloudid.CloudroleListOptions{})
|
||||
cmd.Delete(&cloudid.CloudroleIdOptions{})
|
||||
cmd.Show(&cloudid.CloudroleIdOptions{})
|
||||
cmd.Perform("purge", &cloudid.CloudroleIdOptions{})
|
||||
}
|
||||
@@ -15,12 +15,58 @@
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"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/cloudid"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Clouduserpolicies).WithKeyword("cloud-user-policy").WithContextManager(&modules.Cloudpolicies)
|
||||
cmd.List(&cloudid.ClouduserPolicyListOptions{})
|
||||
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
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -17,22 +17,22 @@ package cloudid
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options/cloudid"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudusers).WithKeyword("cloud-user")
|
||||
cmd.List(&cloudid.ClouduserListOptions{})
|
||||
cmd.Create(&cloudid.ClouduserCreateOptions{})
|
||||
cmd.Show(&cloudid.ClouduserIdOption{})
|
||||
cmd.Custom(shell.CustomActionGet, "login-info", &cloudid.ClouduserIdOption{})
|
||||
cmd.Delete(&cloudid.ClouduserIdOption{})
|
||||
cmd.Perform("sync", &cloudid.ClouduserSyncOptions{})
|
||||
cmd.Perform("syncstatus", &cloudid.ClouduserIdOption{})
|
||||
cmd.Perform("attach-policy", &cloudid.ClouduserPolicyOptions{})
|
||||
cmd.Perform("detach-policy", &cloudid.ClouduserPolicyOptions{})
|
||||
cmd.Perform("change-owner", &cloudid.ClouduserChangeOwnerOptions{})
|
||||
cmd.Perform("reset-password", &cloudid.ClouduserResetPasswordOptions{})
|
||||
cmd.Perform("cloud-user-join-group", &cloudid.ClouduserGroupOptions{})
|
||||
cmd.Perform("cloud-user-leave-group", &cloudid.ClouduserGroupOptions{})
|
||||
cmd.List(&options.ClouduserListOptions{})
|
||||
cmd.Create(&options.ClouduserCreateOptions{})
|
||||
cmd.Show(&options.ClouduserIdOption{})
|
||||
cmd.Custom(shell.CustomActionGet, "login-info", &options.ClouduserIdOption{})
|
||||
cmd.Delete(&options.ClouduserIdOption{})
|
||||
cmd.Perform("sync", &options.ClouduserSyncOptions{})
|
||||
cmd.Perform("syncstatus", &options.ClouduserIdOption{})
|
||||
cmd.Perform("attach-policy", &options.ClouduserPolicyOptions{})
|
||||
cmd.Perform("detach-policy", &options.ClouduserPolicyOptions{})
|
||||
cmd.Perform("change-owner", &options.ClouduserChangeOwnerOptions{})
|
||||
cmd.Perform("reset-password", &options.ClouduserResetPasswordOptions{})
|
||||
cmd.Perform("cloud-user-join-group", &options.ClouduserGroupOptions{})
|
||||
cmd.Perform("cloud-user-leave-group", &options.ClouduserGroupOptions{})
|
||||
}
|
||||
|
||||
@@ -1,29 +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/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options/cloudid"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.SAMLProviders).WithKeyword("saml-provider")
|
||||
cmd.List(&cloudid.SAMLProviderListOptions{})
|
||||
cmd.Create(&cloudid.SAMLProviderCreateOptions{})
|
||||
cmd.Show(&cloudid.SAMLProviderIdOptions{})
|
||||
cmd.Delete(&cloudid.SAMLProviderIdOptions{})
|
||||
}
|
||||
@@ -1,29 +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/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options/cloudid"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Samlusers).WithKeyword("saml-user")
|
||||
cmd.List(&cloudid.SamluserListOptions{})
|
||||
cmd.Create(&cloudid.SamluserCreateOptions{})
|
||||
cmd.Show(&cloudid.SamluserIdOptions{})
|
||||
cmd.Delete(&cloudid.SamluserIdOptions{})
|
||||
}
|
||||
@@ -342,209 +342,4 @@ func init() {
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketSetWebsiteOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
// 主页
|
||||
Index string `help:"main page"`
|
||||
// 错误时返回的文档
|
||||
ErrorDocument string `help:"error return"`
|
||||
// http或https
|
||||
Protocol string `help:"force https" choices:"http|https"`
|
||||
}
|
||||
R(&BucketSetWebsiteOption{}, "bucket-set-website", "Set bucket website", func(s *mcclient.ClientSession, args *BucketSetWebsiteOption) error {
|
||||
conf := api.BucketWebsiteConf{
|
||||
Index: args.Index,
|
||||
ErrorDocument: args.ErrorDocument,
|
||||
Protocol: args.Protocol,
|
||||
}
|
||||
result, err := modules.Buckets.PerformAction(s, args.ID, "set-website", jsonutils.Marshal(conf))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketGetWebsiteConfOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
}
|
||||
R(&BucketGetWebsiteConfOption{}, "bucket-get-website", "Get bucket website", func(s *mcclient.ClientSession, args *BucketGetWebsiteConfOption) error {
|
||||
result, err := modules.Buckets.GetSpecific(s, args.ID, "website", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketDeleteWebsiteConfOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
}
|
||||
R(&BucketDeleteWebsiteConfOption{}, "bucket-delete-website", "Delete bucket website", func(s *mcclient.ClientSession, args *BucketDeleteWebsiteConfOption) error {
|
||||
result, err := modules.Buckets.PerformAction(s, args.ID, "delete-website", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketSetCorsOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
AllowedMethods []string `help:"allowed http method" choices:"PUT|GET|POST|DELETE|HEAD"`
|
||||
// 允许的源站,可以设为*
|
||||
AllowedOrigins []string
|
||||
AllowedHeaders []string
|
||||
MaxAgeSeconds int
|
||||
ExposeHeaders []string
|
||||
RuleId string
|
||||
}
|
||||
R(&BucketSetCorsOption{}, "bucket-set-cors", "Set bucket cors", func(s *mcclient.ClientSession, args *BucketSetCorsOption) error {
|
||||
|
||||
rule := api.BucketCORSRule{
|
||||
AllowedOrigins: args.AllowedOrigins,
|
||||
AllowedMethods: args.AllowedMethods,
|
||||
AllowedHeaders: args.AllowedHeaders,
|
||||
MaxAgeSeconds: args.MaxAgeSeconds,
|
||||
ExposeHeaders: args.ExposeHeaders,
|
||||
Id: args.RuleId,
|
||||
}
|
||||
rules := api.BucketCORSRules{Data: []api.BucketCORSRule{rule}}
|
||||
result, err := modules.Buckets.PerformAction(s, args.ID, "set-cors", jsonutils.Marshal(rules))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketGetCorsOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
}
|
||||
R(&BucketGetCorsOption{}, "bucket-get-cors", "Get bucket cors", func(s *mcclient.ClientSession, args *BucketGetCorsOption) error {
|
||||
result, err := modules.Buckets.GetSpecific(s, args.ID, "cors", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketDeleteCorsOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
Id []string `"help:Id of rules to delete"`
|
||||
}
|
||||
R(&BucketDeleteCorsOption{}, "bucket-delete-cors", "Delete bucket cors", func(s *mcclient.ClientSession, args *BucketDeleteCorsOption) error {
|
||||
input := api.BucketCORSRuleDeleteInput{}
|
||||
input.Id = args.Id
|
||||
result, err := modules.Buckets.PerformAction(s, args.ID, "delete-cors", jsonutils.Marshal(input))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketSetRefererOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
// 域名列表
|
||||
DomainList []string
|
||||
// 是否允许空referer 访问
|
||||
AllowEmptyRefer bool `help:"all empty refer access"`
|
||||
}
|
||||
R(&BucketSetRefererOption{}, "bucket-set-referer", "Set bucket referer", func(s *mcclient.ClientSession, args *BucketSetRefererOption) error {
|
||||
conf := api.BucketRefererConf{
|
||||
WhiteList: args.DomainList,
|
||||
AllowEmptyRefer: args.AllowEmptyRefer,
|
||||
}
|
||||
result, err := modules.Buckets.PerformAction(s, args.ID, "set-referer", jsonutils.Marshal(conf))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketGetRefererOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
}
|
||||
R(&BucketGetRefererOption{}, "bucket-get-referer", "get bucket referer", func(s *mcclient.ClientSession, args *BucketGetRefererOption) error {
|
||||
result, err := modules.Buckets.GetSpecific(s, args.ID, "referer", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketGetCdnDomainOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
}
|
||||
R(&BucketGetRefererOption{}, "bucket-get-cdn-domain", "get bucket cdn domain", func(s *mcclient.ClientSession, args *BucketGetRefererOption) error {
|
||||
result, err := modules.Buckets.GetSpecific(s, args.ID, "cdn-domain", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketGetPolicyOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
}
|
||||
R(&BucketGetPolicyOption{}, "bucket-get-policy", "get bucket policy", func(s *mcclient.ClientSession, args *BucketGetPolicyOption) error {
|
||||
result, err := modules.Buckets.GetSpecific(s, args.ID, "policy", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketSetPolicyOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
// 格式主账号id:子账号id
|
||||
PrincipalId []string `help:"ext account id, accountId:subaccountId"`
|
||||
// Read|ReadWrite|FullControl
|
||||
CannedAction string `help:"authority action" choice:"Read|FullControl"`
|
||||
// Allow|Deny
|
||||
Effect string `help:"allow or deny" choice:"Allow|Deny"`
|
||||
// 被授权的资源地址
|
||||
ResourcePath []string
|
||||
// ip 条件
|
||||
IpEquals []string
|
||||
IpNotEquals []string
|
||||
}
|
||||
R(&BucketSetPolicyOption{}, "bucket-set-policy", "set bucket policy", func(s *mcclient.ClientSession, args *BucketSetPolicyOption) error {
|
||||
opts := api.BucketPolicyStatementInput{}
|
||||
opts.CannedAction = args.CannedAction
|
||||
opts.Effect = args.Effect
|
||||
opts.IpEquals = args.IpEquals
|
||||
opts.IpNotEquals = args.IpNotEquals
|
||||
opts.ResourcePath = args.ResourcePath
|
||||
opts.PrincipalId = args.PrincipalId
|
||||
|
||||
result, err := modules.Buckets.PerformAction(s, args.ID, "set-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketDeletePolicyOption struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
Id []string
|
||||
}
|
||||
R(&BucketDeletePolicyOption{}, "bucket-delete-policy", "delete bucket policy", func(s *mcclient.ClientSession, args *BucketDeletePolicyOption) error {
|
||||
input := api.BucketPolicyDeleteInput{}
|
||||
input.Id = args.Id
|
||||
result, err := modules.Buckets.PerformAction(s, args.ID, "delete-policy", jsonutils.Marshal(input))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ func init() {
|
||||
Zone string `help:"show images cached at zone"`
|
||||
|
||||
HostSchedtagId string `help:"filter cached image with host schedtag"`
|
||||
Valid *bool `help:"valid cachedimage"`
|
||||
}
|
||||
R(&CachedImageListOptions{}, "cached-image-list", "List cached images", func(s *mcclient.ClientSession, args *CachedImageListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -235,7 +235,7 @@ func init() {
|
||||
return err
|
||||
}
|
||||
for k, v := range rc {
|
||||
fmt.Printf(`export %s="%s"`+"\n", k, v)
|
||||
fmt.Printf("export %s='%s'\n", k, v)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
@@ -27,23 +26,6 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudregions).WithKeyword("cloud-region")
|
||||
cmd.PerformClass("sync-skus", &options.CloudregionSkuSyncOptions{})
|
||||
|
||||
R(&options.SkuTaskQueryOptions{}, "cloud-region-sync-task-show", "Show details of skus sync tasks", func(s *mcclient.ClientSession, args *options.SkuTaskQueryOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.Cloudregions.Get(s, "sync-tasks", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudregionListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
|
||||
@@ -15,15 +15,50 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.DBInstanceAccounts).WithKeyword("dbinstance-account")
|
||||
cmd.List(&options.DBInstanceAccountListOptions{})
|
||||
cmd.Update(&options.BaseUpdateOptions{})
|
||||
cmd.Show(&options.DBInstanceAccountIdOptions{})
|
||||
cmd.Delete(&options.DBInstanceAccountIdOptions{})
|
||||
type DBInstanceAccountListOptions struct {
|
||||
options.BaseListOptions
|
||||
DBInstance string `help:"ID or Name of DBInstance" json:"dbinstance"`
|
||||
}
|
||||
R(&DBInstanceAccountListOptions{}, "dbinstance-account-list", "List DB instance accounts", func(s *mcclient.ClientSession, opts *DBInstanceAccountListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.DBInstanceAccounts.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.DBInstanceAccounts.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceAccountIdOptions struct {
|
||||
ID string `help:"ID or Name of DBInstanceaccount"`
|
||||
}
|
||||
|
||||
R(&DBInstanceAccountIdOptions{}, "dbinstance-account-show", "Show DB instance account", func(s *mcclient.ClientSession, opts *DBInstanceAccountIdOptions) error {
|
||||
account, err := modules.DBInstanceAccounts.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(account)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&DBInstanceAccountIdOptions{}, "dbinstance-account-delete", "Delete DB instance account", func(s *mcclient.ClientSession, opts *DBInstanceAccountIdOptions) error {
|
||||
account, err := modules.DBInstanceAccounts.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(account)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -15,16 +15,60 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.DBInstanceDatabases).WithKeyword("dbinstance-database")
|
||||
cmd.List(&options.DBInstanceDatabaseListOptions{})
|
||||
cmd.Update(&options.BaseUpdateOptions{})
|
||||
cmd.Delete(&options.DBInstanceDatabaseIdOptions{})
|
||||
cmd.Show(&options.DBInstanceDatabaseIdOptions{})
|
||||
cmd.Create(&options.DBInstanceDatabaseCreateOptions{})
|
||||
type DBInstanceDatabaseListOptions struct {
|
||||
options.BaseListOptions
|
||||
DBInstance string `help:"ID or Name of DBInstance" json:"dbinstance"`
|
||||
}
|
||||
R(&DBInstanceDatabaseListOptions{}, "dbinstance-database-list", "List DB instance databases", func(s *mcclient.ClientSession, opts *DBInstanceDatabaseListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.DBInstanceDatabases.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.DBInstanceDatabases.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceDatabaseCreateOptions struct {
|
||||
NAME string
|
||||
DBINSTANCE string `help:"ID or Name of DBInstance" json:"dbinstance"`
|
||||
CharacterSet string `help:"CharacterSet for database"`
|
||||
}
|
||||
|
||||
R(&DBInstanceDatabaseCreateOptions{}, "dbinstance-database-create", "Create DB instance databases", func(s *mcclient.ClientSession, opts *DBInstanceDatabaseCreateOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.DBInstanceDatabases.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceDatabaseIdOptions struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
R(&DBInstanceDatabaseIdOptions{}, "dbinstance-database-delete", "Delete DB instance databases", func(s *mcclient.ClientSession, opts *DBInstanceDatabaseIdOptions) error {
|
||||
result, err := modules.DBInstanceDatabases.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -15,29 +15,44 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.DBInstanceSkus).WithKeyword("dbinstance-sku")
|
||||
cmd.List(&options.DBInstanceSkuListOption{})
|
||||
cmd.Show(&options.DBInstanceSkuIdOption{})
|
||||
cmd.PerformClass("sync-skus", &options.SkuSyncOptions{})
|
||||
|
||||
R(&options.SkuTaskQueryOptions{}, "dbinstance-sku-sync-task-show", "Show details of skus sync tasks", func(s *mcclient.ClientSession, args *options.SkuTaskQueryOptions) error {
|
||||
params, err := args.Params()
|
||||
type DBInstanceSkuListOption struct {
|
||||
options.BaseListOptions
|
||||
Engine string
|
||||
EngineVersion string
|
||||
Category string
|
||||
StorageType string
|
||||
Cloudregion string
|
||||
}
|
||||
R(&DBInstanceSkuListOption{}, "dbinstance-sku-list", "List dbinstance skus", func(s *mcclient.ClientSession, args *DBInstanceSkuListOption) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.DBInstanceSkus.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.DBInstanceSkus.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
result, err := modules.DBInstanceSkus.Get(s, "sync-tasks", params)
|
||||
type DBInstanceSkuIdOption struct {
|
||||
ID string `help:"DBInstance Id or name"`
|
||||
}
|
||||
|
||||
R(&DBInstanceSkuIdOption{}, "dbinstance-sku-show", "Show dbinstance sku details", func(s *mcclient.ClientSession, args *DBInstanceSkuIdOption) error {
|
||||
result, err := modules.DBInstanceSkus.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -15,34 +15,280 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options/compute"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.DBInstance) //.WithContextManager(&modules.Networks)
|
||||
cmd.List(&compute.DBInstanceListOptions{})
|
||||
cmd.Create(&compute.DBInstanceCreateOptions{})
|
||||
cmd.Update(&compute.DBInstanceUpdateOptions{})
|
||||
cmd.Show(&compute.DBInstanceIdOptions{})
|
||||
cmd.Delete(&compute.DBInstanceDeleteOptions{})
|
||||
cmd.Perform("renew", &compute.DBInstanceRenewOptions{})
|
||||
cmd.Perform("change-config", &compute.DBInstanceChangeConfigOptions{})
|
||||
cmd.Perform("public-connection", &compute.DBInstancePublicConnectionOptions{})
|
||||
cmd.Perform("recovery", &compute.DBInstanceRecoveryOptions{})
|
||||
cmd.Perform("reboot", &compute.DBInstanceIdOptions{})
|
||||
cmd.Perform("purge", &compute.DBInstanceIdOptions{})
|
||||
cmd.Perform("syncstatus", &compute.DBInstanceIdOptions{})
|
||||
cmd.Perform("sync", &compute.DBInstanceIdOptions{})
|
||||
cmd.Perform("change-owner", &compute.DBInstanceChangeOwnerOptions{})
|
||||
cmd.PerformWithKeyword("add-tag", "user-metadata", &options.ResourceMetadataOptions{})
|
||||
cmd.PerformWithKeyword("set-tag", "set-user-metadata", &options.ResourceMetadataOptions{})
|
||||
cmd.Perform("remote-update", &compute.DBInstanceRemoteUpdateOptions{})
|
||||
cmd.Perform("set-secgroup", &compute.DBInstanceSetSecgroupOptions{})
|
||||
type DBInstanceListOptions struct {
|
||||
options.BaseListOptions
|
||||
BillingType string `help:"billing type" choices:"postpaid|prepaid"`
|
||||
}
|
||||
R(&DBInstanceListOptions{}, "dbinstance-list", "List DB instance", func(s *mcclient.ClientSession, opts *DBInstanceListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.DBInstance.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(opts.ExportFile) > 0 {
|
||||
exportList(result, opts.ExportFile, opts.ExportKeys, opts.ExportTexts, modules.DBInstance.GetColumns(s))
|
||||
} else {
|
||||
printList(result, modules.DBInstance.GetColumns(s))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceCreateOptions struct {
|
||||
NAME string `help:"DBInstance Name"`
|
||||
InstanceType string `help:"InstanceType for DBInstance"`
|
||||
VcpuCount int `help:"Core of cpu for DBInstance"`
|
||||
VmemSizeMb int `help:"Memory size of DBInstance"`
|
||||
Port int `help:"Port of DBInstance"`
|
||||
Category string `help:"Category of DBInstance"`
|
||||
Network string `help:"Network of DBInstance"`
|
||||
Address string `help:"Address of DBInstance"`
|
||||
Engine string `help:"Engine of DBInstance"`
|
||||
EngineVersion string `help:"EngineVersion of DBInstance Engine"`
|
||||
StorageType string `help:"StorageTyep of DBInstance"`
|
||||
Secgroup string `help:"Secgroup name or Id for DBInstance"`
|
||||
Zone string `help:"ZoneId or name for DBInstance"`
|
||||
DiskSizeGB int `help:"Storage size for DBInstance"`
|
||||
Duration string `help:"Duration for DBInstance"`
|
||||
AllowDelete *bool `help:"not lock dbinstance" `
|
||||
}
|
||||
|
||||
R(&DBInstanceCreateOptions{}, "dbinstance-create", "Create DB instance", func(s *mcclient.ClientSession, opts *DBInstanceCreateOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if opts.AllowDelete != nil && *opts.AllowDelete {
|
||||
params.Add(jsonutils.JSONFalse, "disable_delete")
|
||||
}
|
||||
result, err := modules.DBInstance.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceRenewOptions struct {
|
||||
ID string `help:"ID or name of server to renew"`
|
||||
DURATION string `help:"Duration of renew, ADMIN only command"`
|
||||
}
|
||||
R(&DBInstanceRenewOptions{}, "dbinstance-renew", "Renew a dbinstance", func(s *mcclient.ClientSession, args *DBInstanceRenewOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.DURATION), "duration")
|
||||
result, err := modules.DBInstance.PerformAction(s, args.ID, "renew", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceUpdateOptions struct {
|
||||
ID string `help:"ID or name of server to renew"`
|
||||
Name string
|
||||
Description string
|
||||
Delete string `help:"Lock or not lock dbinstance" choices:"enable|disable"`
|
||||
}
|
||||
R(&DBInstanceUpdateOptions{}, "dbinstance-update", "Update a dbinstance", func(s *mcclient.ClientSession, args *DBInstanceUpdateOptions) error {
|
||||
params, err := options.StructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(args.Delete) > 0 {
|
||||
if args.Delete == "disable" {
|
||||
params.Add(jsonutils.JSONTrue, "disable_delete")
|
||||
} else {
|
||||
params.Add(jsonutils.JSONFalse, "disable_delete")
|
||||
}
|
||||
}
|
||||
result, err := modules.DBInstance.Update(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceChangeConfigOptions struct {
|
||||
ID string `help:"ID or name of server to renew"`
|
||||
DiskSizeGb int64 `help:"Change DBInstance storage size"`
|
||||
VcpuCount int64 `help:"Change DBInstance vcpu count"`
|
||||
VmemSizeMb int64 `help:"Change DBInstance vmem size mb"`
|
||||
InstanceType string `help:"Change DBInstance instanceType"`
|
||||
Category string `help:"Change DBInstance category"`
|
||||
}
|
||||
R(&DBInstanceChangeConfigOptions{}, "dbinstance-change-config", "ChangeConfig a dbinstance", func(s *mcclient.ClientSession, args *DBInstanceChangeConfigOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
if len(args.Category) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Category), "category")
|
||||
}
|
||||
if len(args.InstanceType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.InstanceType), "instance_type")
|
||||
}
|
||||
if args.DiskSizeGb > 0 {
|
||||
params.Add(jsonutils.NewInt(args.DiskSizeGb), "disk_size_gb")
|
||||
}
|
||||
if args.VcpuCount > 0 {
|
||||
params.Add(jsonutils.NewInt(args.VcpuCount), "vcpu_count")
|
||||
}
|
||||
if args.VmemSizeMb > 0 {
|
||||
params.Add(jsonutils.NewInt(args.VmemSizeMb), "vmeme_size_mb")
|
||||
}
|
||||
result, err := modules.DBInstance.PerformAction(s, args.ID, "change-config", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceIdOptions struct {
|
||||
ID string `help:"ID of dbinstance"`
|
||||
}
|
||||
|
||||
R(&DBInstanceIdOptions{}, "dbinstance-open-public-connection", "Open DB instance public connection", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.JSONTrue, "open")
|
||||
result, err := modules.DBInstance.PerformAction(s, opts.ID, "public-connection", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&DBInstanceIdOptions{}, "dbinstance-close-public-connection", "Close DB instance public connection", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.JSONFalse, "open")
|
||||
result, err := modules.DBInstance.PerformAction(s, opts.ID, "public-connection", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceRecoveryOptions struct {
|
||||
ID string
|
||||
BACKUP string
|
||||
Databases []string
|
||||
}
|
||||
|
||||
R(&DBInstanceRecoveryOptions{}, "dbinstance-recovery", "Recovery DB instance database from backup", func(s *mcclient.ClientSession, opts *DBInstanceRecoveryOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("dbinstancebackup", jsonutils.NewString(opts.BACKUP))
|
||||
dbs := jsonutils.NewDict()
|
||||
for _, database := range opts.Databases {
|
||||
if len(database) > 0 {
|
||||
dbInfo := strings.Split(database, ":")
|
||||
if len(dbInfo) == 1 {
|
||||
dbs.Add(jsonutils.NewString(dbInfo[0]), dbInfo[0])
|
||||
} else if len(dbInfo) == 2 {
|
||||
dbs.Add(jsonutils.NewString(dbInfo[1]), dbInfo[0])
|
||||
} else {
|
||||
return fmt.Errorf("Invalid dbinfo: %s", database)
|
||||
}
|
||||
}
|
||||
}
|
||||
if dbs.Length() > 0 {
|
||||
params.Add(dbs, "databases")
|
||||
}
|
||||
result, err := modules.DBInstance.PerformAction(s, opts.ID, "recovery", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&DBInstanceIdOptions{}, "dbinstance-show", "Show DB instance", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
|
||||
result, err := modules.DBInstance.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&DBInstanceIdOptions{}, "dbinstance-reboot", "Reboot DB instance", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
|
||||
result, err := modules.DBInstance.PerformAction(s, opts.ID, "reboot", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceDeleteOptions struct {
|
||||
ID string `help:"DBInstance Id or name"`
|
||||
KeepBackup bool `help:"Keep dbinstance manual backup after delete dbinstance"`
|
||||
}
|
||||
|
||||
R(&DBInstanceDeleteOptions{}, "dbinstance-delete", "Delete DB instance", func(s *mcclient.ClientSession, opts *DBInstanceDeleteOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
if opts.KeepBackup {
|
||||
params.Add(jsonutils.JSONTrue, "keep_backup")
|
||||
}
|
||||
result, err := modules.DBInstance.Delete(s, opts.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&DBInstanceIdOptions{}, "dbinstance-purge", "Purge DB instance", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
|
||||
result, err := modules.DBInstance.PerformAction(s, opts.ID, "purge", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&DBInstanceIdOptions{}, "dbinstance-syncstatus", "Sync status for DB instance", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
|
||||
result, err := modules.DBInstance.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&DBInstanceIdOptions{}, "dbinstance-sync", "Sync conf from cloud dbinstance", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
|
||||
result, err := modules.DBInstance.PerformAction(s, opts.ID, "sync", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&DBInstanceIdOptions{}, "dbinstance-sync-status", "Sync status for DB instance", func(s *mcclient.ClientSession, opts *DBInstanceIdOptions) error {
|
||||
result, err := modules.DBInstance.PerformAction(s, opts.ID, "sync-status", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceNetworkListOptions struct {
|
||||
options.BaseListOptions
|
||||
@@ -108,4 +354,21 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceChangeOwnerOptions struct {
|
||||
ID string `help:"DBInstance to change owner" json:"-"`
|
||||
PROJECT string `help:"Project ID or change" json:"tenant"`
|
||||
}
|
||||
R(&DBInstanceChangeOwnerOptions{}, "dbinstance-change-owner", "Change owner porject of a dbinstance", func(s *mcclient.ClientSession, opts *DBInstanceChangeOwnerOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.DBInstance.PerformAction(s, opts.ID, "change-owner", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -149,7 +149,6 @@ func init() {
|
||||
AutoDelete string `help:"enable/disable auto delete of disk" choices:"enable|disable"`
|
||||
AutoSnapshot string `help:"enable/disable auto snapshot of disk" choices:"enable|disable"`
|
||||
DiskType string `help:"Disk type" choices:"data|volume"`
|
||||
IsSsd *bool `help:"mark disk as ssd" negative:"no-is-ssd"`
|
||||
}
|
||||
R(&DiskUpdateOptions{}, "disk-update", "Update property of a virtual disk", func(s *mcclient.ClientSession, args *DiskUpdateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
@@ -176,13 +175,6 @@ func init() {
|
||||
if len(args.DiskType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.DiskType), "disk_type")
|
||||
}
|
||||
if args.IsSsd != nil {
|
||||
if *args.IsSsd {
|
||||
params.Add(jsonutils.JSONTrue, "is_ssd")
|
||||
} else {
|
||||
params.Add(jsonutils.JSONFalse, "is_ssd")
|
||||
}
|
||||
}
|
||||
if params.Size() == 0 {
|
||||
return InvalidUpdateError()
|
||||
}
|
||||
|
||||
@@ -19,16 +19,12 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.ElasticcacheSkus).WithKeyword("elastic-cache-sku")
|
||||
cmd.PerformClass("sync-skus", &options.SkuSyncOptions{})
|
||||
|
||||
R(&options.BaseListOptions{}, "elastic-cache-list", "List elastisc cache instance", func(s *mcclient.ClientSession, opts *options.BaseListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
@@ -45,15 +41,11 @@ func init() {
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheCreateOptions{}, "elastic-cache-create", "Create elastisc cache instance", func(s *mcclient.ClientSession, opts *options.ElasticCacheCreateOptions) error {
|
||||
params, err := opts.Params()
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(opts.SecgroupIds) > 0 {
|
||||
params.Set("secgroup_ids", jsonutils.NewStringArray(opts.SecgroupIds))
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCache.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -401,107 +393,4 @@ func init() {
|
||||
printList(result, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SkuTaskQueryOptions{}, "elastic-cache-sku-sync-task-show", "Show details of skus sync tasks", func(s *mcclient.ClientSession, args *options.SkuTaskQueryOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticcacheSkus.Get(s, "sync-tasks", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ResourceMetadataOptions{}, "elastic-cache-add-tag", "Set tag of a server", func(s *mcclient.ClientSession, opts *options.ResourceMetadataOptions) error {
|
||||
params, err := opts.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "user-metadata", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ResourceMetadataOptions{}, "elastic-cache-set-tag", "Set tag of a server", func(s *mcclient.ClientSession, opts *options.ResourceMetadataOptions) error {
|
||||
params, err := opts.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "set-user-metadata", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheRemoteUpdateOptions{}, "elastic-cache-remote-update", "Restore elastisc cache backup", func(s *mcclient.ClientSession, opts *options.ElasticCacheRemoteUpdateOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "remote-update", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheAutoRenewOptions{}, "elastic-cache-auto-renew", "Set elastisc cache auto renew", func(s *mcclient.ClientSession, opts *options.ElasticCacheAutoRenewOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "set-auto-renew", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheRenewOptions{}, "elastic-cache-renew", "Renew elastisc cache", func(s *mcclient.ClientSession, opts *options.ElasticCacheRenewOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "renew", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ElasticcacheSecgroupListOptions struct {
|
||||
options.BaseListOptions
|
||||
Elasticcache string `help:"ID or Name of elastic cache" json:"elasticcache"`
|
||||
Secgroup string `help:"Secgroup ID or name"`
|
||||
}
|
||||
|
||||
R(&ElasticcacheSecgroupListOptions{}, "elastic-cache-secgroup-list", "List elastisc cache secgroups", func(s *mcclient.ClientSession, opts *ElasticcacheSecgroupListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCacheSecgroup.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(result, nil)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -50,9 +50,8 @@ func init() {
|
||||
Manager string `help:"cloud provider"`
|
||||
Region string `help:"cloud region in which EIP is allocated"`
|
||||
Bandwidth int `help:"Bandwidth in Mbps"`
|
||||
IpAddr string `help:"IP address of the EIP" json:"ip_addr"`
|
||||
Ip string `help:"IP address of the EIP"`
|
||||
Network string `help:"Network of the EIP"`
|
||||
BgpType string `help:"BgpType of the EIP" positional:"false"`
|
||||
ChargeType string `help:"bandwidth charge type" choices:"traffic|bandwidth"`
|
||||
}
|
||||
R(&EipCreateOptions{}, "eip-create", "Create an EIP", func(s *mcclient.ClientSession, args *EipCreateOptions) error {
|
||||
@@ -75,12 +74,9 @@ func init() {
|
||||
if len(args.Network) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Network), "network")
|
||||
}
|
||||
if len(args.BgpType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.BgpType), "bgp_type")
|
||||
}
|
||||
|
||||
if len(args.IpAddr) > 0 {
|
||||
params.Add(jsonutils.NewString(args.IpAddr), "ip_addr")
|
||||
if len(args.Ip) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Ip), "ip")
|
||||
}
|
||||
|
||||
result, err := modules.Elasticips.Create(s, params)
|
||||
@@ -190,16 +186,12 @@ func init() {
|
||||
type ServerCreateEipOptions struct {
|
||||
ID string `help:"server ID or name"`
|
||||
BW int `help:"EIP bandwidth in Mbps"`
|
||||
BgpType string `help:"desired BGP type"`
|
||||
ChargeType string `help:"bandwidth charge type" choices:"traffic|bandwidth"`
|
||||
}
|
||||
R(&ServerCreateEipOptions{}, "server-create-eip", "allocate an EIP and associate EIP to server", func(s *mcclient.ClientSession, args *ServerCreateEipOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewInt(int64(args.BW)), "bandwidth")
|
||||
|
||||
if args.BgpType != "" {
|
||||
params.Add(jsonutils.NewString(args.BgpType), "bgp_type")
|
||||
}
|
||||
if len(args.ChargeType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.ChargeType), "charge_type")
|
||||
}
|
||||
|
||||
@@ -407,14 +407,12 @@ func init() {
|
||||
})
|
||||
|
||||
type HostAddNetIfOptions struct {
|
||||
ID string `help:"ID or Name of host"`
|
||||
WIRE string `help:"ID or Name of wire to attach"`
|
||||
MAC string `help:"Mac address of NIC"`
|
||||
INDEX int64 `help:"nic index"`
|
||||
Type string `help:"Nic type" choices:"admin|ipmi"`
|
||||
IpAddr string `help:"IP address"`
|
||||
Bridge string `help:"Bridge of hostwire"`
|
||||
Interface string `help:"Interface name, eg:eth0, en0"`
|
||||
ID string `help:"ID or Name of host"`
|
||||
WIRE string `help:"ID or Name of wire to attach"`
|
||||
MAC string `help:"Mac address of NIC"`
|
||||
INDEX int64 `help:"nic index"`
|
||||
Type string `help:"Nic type" choices:"admin|ipmi"`
|
||||
IpAddr string `help:"IP address"`
|
||||
}
|
||||
R(&HostAddNetIfOptions{}, "host-add-netif", "Host add a NIC", func(s *mcclient.ClientSession, args *HostAddNetIfOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
@@ -428,12 +426,6 @@ func init() {
|
||||
if len(args.IpAddr) > 0 {
|
||||
params.Add(jsonutils.NewString(args.IpAddr), "ip_addr")
|
||||
}
|
||||
if len(args.Bridge) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Bridge), "bridge")
|
||||
}
|
||||
if len(args.Interface) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Interface), "interface")
|
||||
}
|
||||
result, err := modules.Hosts.PerformAction(s, args.ID, "add-netif", params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -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 compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.InterVpcNetworks).WithKeyword("inter-vpc-network")
|
||||
cmd.List(&options.InterVpcNetworkListOPtions{})
|
||||
cmd.Show(&options.InterVpcNetworkIdOPtions{})
|
||||
cmd.Create(&options.InterVpcNetworkCreateOPtions{})
|
||||
cmd.Delete(&options.InterVpcNetworkIdOPtions{})
|
||||
cmd.Perform("syncstatus", &options.InterVpcNetworkIdOPtions{})
|
||||
cmd.Perform("addvpc", &options.InterVpcNetworkAddVpcOPtions{})
|
||||
cmd.Perform("removevpc", &options.InterVpcNetworkRemoveVpcOPtions{})
|
||||
}
|
||||
@@ -1,29 +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/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.InterVpcNetworkRouteSets).WithKeyword("inter-vpc-network-routeset")
|
||||
cmd.List(&options.InterVpcNetworkRouteListOptions{})
|
||||
cmd.Show(&options.InterVpcNetworkRouteIdptions{})
|
||||
cmd.Perform("enable", &options.InterVpcNetworkRouteIdptions{})
|
||||
cmd.Perform("disable", &options.InterVpcNetworkRouteIdptions{})
|
||||
}
|
||||
@@ -137,21 +137,4 @@ func init() {
|
||||
printLbAcl(lbacl)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerAclPublicOptions{}, "lbacl-public", "Public lbacl", func(s *mcclient.ClientSession, opts *options.LoadbalancerAclPublicOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
lbacl, err := modules.LoadbalancerAcls.PerformAction(s, opts.ID, "public", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printLbAcl(lbacl)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerAclPrivateOptions{}, "lbacl-private", "Private lbacl", func(s *mcclient.ClientSession, opts *options.LoadbalancerAclPrivateOptions) error {
|
||||
lbacl, err := modules.LoadbalancerAcls.PerformAction(s, opts.ID, "private", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printLbAcl(lbacl)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
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"
|
||||
@@ -83,21 +81,4 @@ func init() {
|
||||
printObject(lbcert)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerCertificatePublicOptions{}, "lbcert-public", "Public lbcert", func(s *mcclient.ClientSession, opts *options.LoadbalancerCertificatePublicOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
lbcert, err := modules.LoadbalancerCertificates.PerformAction(s, opts.ID, "public", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(lbcert)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerCertificatePrivateOptions{}, "lbcert-private", "Private lbcert", func(s *mcclient.ClientSession, opts *options.LoadbalancerCertificatePrivateOptions) error {
|
||||
lbcert, err := modules.LoadbalancerCertificates.PerformAction(s, opts.ID, "private", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(lbcert)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,44 +15,92 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Loadbalancers).WithKeyword("lb")
|
||||
cmd.Create(&options.LoadbalancerCreateOptions{})
|
||||
cmd.Show(&options.LoadbalancerIdOptions{})
|
||||
cmd.List(&options.LoadbalancerListOptions{})
|
||||
cmd.Update(&options.LoadbalancerUpdateOptions{})
|
||||
cmd.Delete(&options.LoadbalancerIdOptions{})
|
||||
cmd.Perform("purge", &options.LoadbalancerIdOptions{})
|
||||
cmd.Perform("status", &options.LoadbalancerActionStatusOptions{})
|
||||
cmd.Perform("syncstatus", &options.LoadbalancerIdOptions{})
|
||||
cmd.Perform("remote-update", &options.LoadbalancerRemoteUpdateOptions{})
|
||||
cmd.Get("change-owner-candidate-domains", &options.LoadbalancerIdOptions{})
|
||||
|
||||
R(&options.ResourceMetadataOptions{}, "lb-add-tag", "Set tag of a lb", func(s *mcclient.ClientSession, opts *options.ResourceMetadataOptions) error {
|
||||
params, err := opts.Params()
|
||||
R(&options.LoadbalancerCreateOptions{}, "lb-create", "Create lb", func(s *mcclient.ClientSession, opts *options.LoadbalancerCreateOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Loadbalancers.PerformAction(s, opts.ID, "user-metadata", params)
|
||||
lb, err := modules.Loadbalancers.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
printObject(lb)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerGetOptions{}, "lb-show", "Show lb", func(s *mcclient.ClientSession, opts *options.LoadbalancerGetOptions) error {
|
||||
lb, err := modules.Loadbalancers.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(lb)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerListOptions{}, "lb-list", "List lbs", func(s *mcclient.ClientSession, opts *options.LoadbalancerListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Loadbalancers.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Loadbalancers.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerUpdateOptions{}, "lb-update", "Update lb", func(s *mcclient.ClientSession, opts *options.LoadbalancerUpdateOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
lb, err := modules.Loadbalancers.Update(s, opts.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(lb)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerDeleteOptions{}, "lb-delete", "Delete lb", func(s *mcclient.ClientSession, opts *options.LoadbalancerDeleteOptions) error {
|
||||
lb, err := modules.Loadbalancers.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(lb)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerPurgeOptions{}, "lb-purge", "Purge lb", func(s *mcclient.ClientSession, opts *options.LoadbalancerPurgeOptions) error {
|
||||
lb, err := modules.Loadbalancers.PerformAction(s, opts.ID, "purge", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(lb)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerActionStatusOptions{}, "lb-status", "Change lb status", func(s *mcclient.ClientSession, opts *options.LoadbalancerActionStatusOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lb, err := modules.Loadbalancers.PerformAction(s, opts.ID, "status", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(lb)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerActionSyncStatusOptions{}, "lb-syncstatus", "Sync lb status", func(s *mcclient.ClientSession, opts *options.LoadbalancerActionSyncStatusOptions) error {
|
||||
lb, err := modules.Loadbalancers.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(lb)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ResourceMetadataOptions{}, "lb-set-tag", "Set tag of a lb", func(s *mcclient.ClientSession, opts *options.ResourceMetadataOptions) error {
|
||||
params, err := opts.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Loadbalancers.PerformAction(s, opts.ID, "set-user-metadata", params)
|
||||
R(&options.LoadbalancerGetOptions{}, "lb-change-owner-candidate-domains", "Get change owner candidate domain list", func(s *mcclient.ClientSession, args *options.LoadbalancerGetOptions) error {
|
||||
result, err := modules.Loadbalancers.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,29 +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/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.NetworkAddresses).WithContextManager(&modules.Wires)
|
||||
cmd.BatchCreate(&options.NetworkAddressCreateOptions{})
|
||||
cmd.List(&options.NetworkAddressListOptions{})
|
||||
cmd.Show(&options.NetworkAddressIdOptions{})
|
||||
cmd.Delete(&options.NetworkAddressIdOptions{})
|
||||
}
|
||||
@@ -69,7 +69,6 @@ func init() {
|
||||
AllocPolicy string `help:"Address allocation policy" choices:"none|stepdown|stepup|random"`
|
||||
ServerType string `help:"Server type" choices:"baremetal|container|eip|guest|ipmi|pxe"`
|
||||
IsAutoAlloc *bool `help:"Auto allocation IP pool"`
|
||||
BgpType string `help:"Internet service provider name" positional:"false"`
|
||||
Desc string `help:"Description" metavar:"DESCRIPTION"`
|
||||
}
|
||||
R(&NetworkCreateOptions{}, "network-create", "Create a virtual network", func(s *mcclient.ClientSession, args *NetworkCreateOptions) error {
|
||||
@@ -96,9 +95,6 @@ func init() {
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
if len(args.BgpType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.BgpType), "bgp_type")
|
||||
}
|
||||
if args.IsAutoAlloc != nil {
|
||||
params.Add(jsonutils.NewBool(*args.IsAutoAlloc), "is_auto_alloc")
|
||||
}
|
||||
@@ -111,21 +107,17 @@ func init() {
|
||||
})
|
||||
|
||||
type NetworkCreateOptions2 struct {
|
||||
Wire string `help:"ID or Name of wire in which the network is created"`
|
||||
Vpc string `help:"ID or Name of vpc in which the network is created"`
|
||||
Zone string `help:"ID or Name of zone in which the network is created"`
|
||||
NAME string `help:"Name of new network"`
|
||||
PREFIX string `help:"Start of IPv4 address range"`
|
||||
BgpType string `help:"Internet service provider name" positional:"false"`
|
||||
Desc string `help:"Description" metavar:"DESCRIPTION"`
|
||||
Wire string `help:"ID or Name of wire in which the network is created"`
|
||||
Vpc string `help:"ID or Name of vpc in which the network is created"`
|
||||
Zone string `help:"ID or Name of zone in which the network is created"`
|
||||
NAME string `help:"Name of new network"`
|
||||
PREFIX string `help:"Start of IPv4 address range"`
|
||||
Desc string `help:"Description" metavar:"DESCRIPTION"`
|
||||
}
|
||||
R(&NetworkCreateOptions2{}, "network-create2", "Create a virtual network", func(s *mcclient.ClientSession, args *NetworkCreateOptions2) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.NAME), "name")
|
||||
params.Add(jsonutils.NewString(args.PREFIX), "guest_ip_prefix")
|
||||
if len(args.BgpType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.BgpType), "bgp_type")
|
||||
}
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
@@ -261,20 +253,4 @@ func init() {
|
||||
printObject(net)
|
||||
return nil
|
||||
})
|
||||
type NetworkSetBgpTypeOptions struct {
|
||||
ID string `help:"Network to set BgpType" json:"-"`
|
||||
BgpType *string `help:"new BgpType name"`
|
||||
}
|
||||
R(&NetworkSetBgpTypeOptions{}, "network-set-bgp-type", "Set BgpType of a network", func(s *mcclient.ClientSession, args *NetworkSetBgpTypeOptions) error {
|
||||
params, err := options.StructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
net, err := modules.Networks.PerformAction(s, args.ID, "set-bgp-type", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(net)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -58,8 +58,7 @@ type RegionQuotaOptions struct {
|
||||
|
||||
Eip int64 `help:"Elastic IP count" json:"eip,omitzero"`
|
||||
|
||||
Snapshot int64 `help:"Snapshot count" json:"snapshot,omitzero"`
|
||||
InstanceSnapshot int64 `help:"Instance snapshot count" json:"instance_snapshot,omitzero"`
|
||||
Snapshot int64 `help:"Snapshot count" json:"snapshot,omitzero"`
|
||||
|
||||
Bucket int64 `help:"bucket count" json:"bucket,omitzero"`
|
||||
ObjectGB int64 `help:"object size in GB" json:"object_gb,omitzero"`
|
||||
@@ -317,7 +316,7 @@ func init() {
|
||||
QuotaSetBaseOptions
|
||||
IdentityQuotaOptions
|
||||
}
|
||||
R(&IdentityQuotaSetOptions{}, "identity-quota-set", "Set identity quota for domain", func(s *mcclient.ClientSession, args *IdentityQuotaSetOptions) error {
|
||||
R(&IdentityQuotaSetOptions{}, "identity-quota-set", "Set identity quota for domain", func(s *mcclient.ClientSession, args *InfrasQuotaSetOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
quotas, e := modules.IdentityQuotas.DoQuotaSet(s, params)
|
||||
if e != nil {
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.RouteTableRouteAssociations).WithKeyword("routetable-association")
|
||||
cmd.List(&options.RouteTableAssociationListOptions{})
|
||||
cmd.Show(&options.RouteTableAssociationIdOptions{})
|
||||
}
|
||||
@@ -1,30 +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/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.RouteTableRouteSets).WithKeyword("routetable-routeset")
|
||||
cmd.List(&options.RouteTableRouteSetListOptions{})
|
||||
cmd.Show(&options.RouteTableRouteSetIdOptions{})
|
||||
cmd.Create(&options.RouteTableRouteSetCreateOptions{})
|
||||
cmd.Update(&options.RouteTableRouteSetUpdateOptions{})
|
||||
cmd.Delete(&options.RouteTableRouteSetIdOptions{})
|
||||
}
|
||||
@@ -15,20 +15,126 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"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() {
|
||||
cmd := shell.NewResourceCmd(&modules.RouteTables).WithKeyword("routetable")
|
||||
cmd.List(&options.RouteTableListOptions{})
|
||||
cmd.Show(&options.RouteTableIdOptions{})
|
||||
cmd.Create(&options.RouteTableCreateOptions{})
|
||||
cmd.Update(&options.RouteTableUpdateOptions{})
|
||||
cmd.Delete(&options.RouteTableIdOptions{})
|
||||
cmd.Perform("syncstatus", &options.RouteTableIdOptions{})
|
||||
cmd.Perform("add-routes", &options.RouteTableAddRoutesOptions{})
|
||||
cmd.Perform("del-routes", &options.RouteTableDelRoutesOptions{})
|
||||
cmd.Perform("purge", &options.RouteTableIdOptions{})
|
||||
printRouteTableList := func(list *modulebase.ListResult, columns []string) {
|
||||
data := list.Data
|
||||
for _, jsonObj := range data {
|
||||
jd := jsonObj.(*jsonutils.JSONDict)
|
||||
routesObj, err := jd.GetArray("routes")
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
routes := []string{}
|
||||
for _, routeObj := range routesObj {
|
||||
typ, _ := routeObj.GetString("type")
|
||||
cidr, _ := routeObj.GetString("cidr")
|
||||
next_hop_type, _ := routeObj.GetString("next_hop_type")
|
||||
next_hop_id, _ := routeObj.GetString("next_hop_id")
|
||||
route := fmt.Sprintf("%8s: %18s %s", typ, cidr, next_hop_type)
|
||||
if next_hop_id != "" {
|
||||
route += fmt.Sprintf(":%s", next_hop_id)
|
||||
}
|
||||
routes = append(routes, route)
|
||||
}
|
||||
s := strings.Join(routes, "\n")
|
||||
jd.Set("routes", jsonutils.NewString(s))
|
||||
}
|
||||
printList(list, columns)
|
||||
}
|
||||
|
||||
R(&options.RouteTableCreateOptions{}, "routetable-create", "Create routetable", func(s *mcclient.ClientSession, opts *options.RouteTableCreateOptions) error {
|
||||
params, err := opts.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
routetable, err := modules.RouteTables.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectRecursive(routetable)
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteTableGetOptions{}, "routetable-show", "Show routetable", func(s *mcclient.ClientSession, opts *options.RouteTableGetOptions) error {
|
||||
routetable, err := modules.RouteTables.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectRecursive(routetable)
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteTableListOptions{}, "routetable-list", "List routetables", func(s *mcclient.ClientSession, opts *options.RouteTableListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.RouteTables.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printRouteTableList(result, modules.RouteTables.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteTableUpdateOptions{}, "routetable-update", "Update routetable", func(s *mcclient.ClientSession, opts *options.RouteTableUpdateOptions) error {
|
||||
params, err := opts.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
routetable, err := modules.RouteTables.Update(s, opts.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectRecursive(routetable)
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteTableAddRoutesOptions{}, "routetable-add-routes", "Add routes to routetable", func(s *mcclient.ClientSession, opts *options.RouteTableAddRoutesOptions) error {
|
||||
params, err := opts.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
routetable, err := modules.RouteTables.PerformAction(s, opts.ID, "add-routes", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectRecursive(routetable)
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteTableDelRoutesOptions{}, "routetable-del-routes", "Del routes to routetable", func(s *mcclient.ClientSession, opts *options.RouteTableDelRoutesOptions) error {
|
||||
params, err := opts.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
routetable, err := modules.RouteTables.PerformAction(s, opts.ID, "del-routes", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectRecursive(routetable)
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteTableDeleteOptions{}, "routetable-delete", "Delete routetable", func(s *mcclient.ClientSession, opts *options.RouteTableDeleteOptions) error {
|
||||
routetable, err := modules.RouteTables.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectRecursive(routetable)
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteTablePurgeOptions{}, "routetable-purge", "Purge routetable", func(s *mcclient.ClientSession, opts *options.RouteTablePurgeOptions) error {
|
||||
routetable, err := modules.RouteTables.PerformAction(s, opts.ID, "purge", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectRecursive(routetable)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -123,8 +123,5 @@ func init() {
|
||||
modules.Schedtaghosts,
|
||||
modules.Schedtagstorages,
|
||||
modules.Schedtagnetworks,
|
||||
modules.Schedtagcloudproviders,
|
||||
modules.Schedtagcloudregions,
|
||||
modules.Schedtagzones,
|
||||
).register()
|
||||
}
|
||||
|
||||
@@ -15,20 +15,142 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"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() {
|
||||
cmd := shell.NewResourceCmd(&modules.Schedtags)
|
||||
type SchedtagListOptions struct {
|
||||
options.BaseListOptions
|
||||
Type string `help:"Filter by resource type"`
|
||||
}
|
||||
R(&SchedtagListOptions{}, "schedtag-list", "List schedule tags", func(s *mcclient.ClientSession, args *SchedtagListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
cmd.List(new(options.SchedtagListOptions))
|
||||
cmd.Show(new(options.SchedtagShowOptions))
|
||||
cmd.Delete(new(options.SchedtagShowOptions))
|
||||
cmd.Create(new(options.SchedtagCreateOptions))
|
||||
cmd.Update(new(options.SchedtagUpdateOptions))
|
||||
cmd.BatchPerform("set-scope", new(options.SchedtagSetScopeOptions))
|
||||
cmd.PerformWithKeyword("set-user-metadata", "user-metadata", new(options.ResourceMetadataOptions))
|
||||
cmd.Perform("set-resource", new(options.SchedtagSetResource))
|
||||
}
|
||||
}
|
||||
if len(args.Type) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Type), "resource_type")
|
||||
}
|
||||
result, err := modules.Schedtags.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Schedtags.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type SchedtagShowOptions struct {
|
||||
ID string `help:"ID or Name of the scheduler tag to show"`
|
||||
}
|
||||
R(&SchedtagShowOptions{}, "schedtag-show", "Show scheduler tag details", func(s *mcclient.ClientSession, args *SchedtagShowOptions) error {
|
||||
result, err := modules.Schedtags.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&SchedtagShowOptions{}, "schedtag-delete", "Delete a scheduler tag", func(s *mcclient.ClientSession, args *SchedtagShowOptions) error {
|
||||
result, err := modules.Schedtags.Delete(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type SchedtagCreateOptions struct {
|
||||
NAME string `help:"Name of new schedtag"`
|
||||
Strategy string `help:"Policy" choices:"require|exclude|prefer|avoid"`
|
||||
Desc string `help:"Description"`
|
||||
Scope string `help:"Resource scope" choices:"system|domain|project"`
|
||||
Type string `help:"Resource type" choices:"hosts|storages|networks"`
|
||||
}
|
||||
R(&SchedtagCreateOptions{}, "schedtag-create", "Create a schedule tag", func(s *mcclient.ClientSession, args *SchedtagCreateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.NAME), "name")
|
||||
if len(args.Strategy) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Strategy), "default_strategy")
|
||||
}
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
if len(args.Type) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Type), "resource_type")
|
||||
}
|
||||
if len(args.Scope) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Scope), "scope")
|
||||
}
|
||||
schedtag, err := modules.Schedtags.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(schedtag)
|
||||
return nil
|
||||
})
|
||||
|
||||
type SchedtagUpdateOptions struct {
|
||||
ID string `help:"ID or Name of schetag"`
|
||||
Name string `help:"New name of schedtag"`
|
||||
Strategy string `help:"Policy" choices:"require|exclude|prefer|avoid"`
|
||||
Desc string `help:"Description"`
|
||||
ClearStrategy bool `help:"Clear default schedule policy"`
|
||||
}
|
||||
R(&SchedtagUpdateOptions{}, "schedtag-update", "Update a schedule tag", func(s *mcclient.ClientSession, args *SchedtagUpdateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
if len(args.Name) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Name), "name")
|
||||
}
|
||||
if len(args.Strategy) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Strategy), "default_strategy")
|
||||
}
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
if args.ClearStrategy {
|
||||
params.Add(jsonutils.NewString(""), "default_strategy")
|
||||
}
|
||||
if params.Size() == 0 {
|
||||
return fmt.Errorf("No valid data to update")
|
||||
}
|
||||
schedtag, err := modules.Schedtags.Update(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(schedtag)
|
||||
return nil
|
||||
})
|
||||
|
||||
type SetScopeOptions struct {
|
||||
ID []string `help:"ID or Name of schetag"`
|
||||
Project string `help:"ID or Name of project"`
|
||||
Domain string `help:"ID or Name of domain"`
|
||||
System bool `help:"Set to system scope"`
|
||||
}
|
||||
R(&SetScopeOptions{}, "schedtag-set-scope", "Set schedtag scope", func(s *mcclient.ClientSession, args *SetScopeOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
domainId := args.Domain
|
||||
projectId := args.Project
|
||||
if args.System {
|
||||
domainId = ""
|
||||
projectId = ""
|
||||
}
|
||||
params.Add(jsonutils.NewString(domainId), "domain")
|
||||
params.Add(jsonutils.NewString(projectId), "project")
|
||||
ret := modules.Schedtags.BatchPerformAction(s, args.ID, "set-scope", params)
|
||||
printBatchResults(ret, modules.Schedtags.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -123,10 +123,9 @@ func init() {
|
||||
})
|
||||
|
||||
type SchedulerHistoryListOptions struct {
|
||||
Limit int `default:"50" help:"Page limit"`
|
||||
Offset int `default:"0" help:"Page offset"`
|
||||
All bool `help:"Show all histories, including scheduler-test"`
|
||||
IsSuggestion bool `help:"Only show forcast suggestion history"`
|
||||
Limit int `default:"50" help:"Page limit"`
|
||||
Offset int `default:"0" help:"Page offset"`
|
||||
All bool `help:"Show all histories, including scheduler-test"`
|
||||
}
|
||||
R(&SchedulerHistoryListOptions{}, "scheduler-history-list", "Show scheduler history list",
|
||||
func(s *mcclient.ClientSession, args *SchedulerHistoryListOptions) error {
|
||||
@@ -139,14 +138,17 @@ func init() {
|
||||
if args.Offset > 0 {
|
||||
params.Add(jsonutils.NewInt(int64(args.Offset)), "offset")
|
||||
}
|
||||
params.Add(jsonutils.NewBool(args.All), "all")
|
||||
params.Add(jsonutils.NewBool(args.IsSuggestion), "is_suggestion")
|
||||
if args.All {
|
||||
params.Add(jsonutils.JSONTrue, "all")
|
||||
} else {
|
||||
params.Add(jsonutils.JSONFalse, "all")
|
||||
}
|
||||
result, err := modules.SchedManager.HistoryList(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(modulebase.JSON2ListResult(result), []string{
|
||||
"session_id", "time", "status", "consuming", "is_suggestion",
|
||||
"session_id", "time", "status", "consuming",
|
||||
})
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -34,6 +34,4 @@ func init() {
|
||||
cmd.Perform("cache-secgroup", &options.SecurityGroupCacheOptions{})
|
||||
cmd.Perform("uncache-secgroup", &options.SecurityGroupUncacheSecurityGroup{})
|
||||
cmd.Perform("purge", &options.SecgroupIdOptions{})
|
||||
cmd.Perform("change-owner", &options.SecgroupChangeOwnerOptions{})
|
||||
cmd.Perform("import-rules", &options.SecgroupImportRulesOptions{})
|
||||
}
|
||||
|
||||
@@ -83,7 +83,6 @@ func init() {
|
||||
cmd.Perform("publicip-to-eip", new(options.ServerPublicipToEip))
|
||||
cmd.Perform("set-auto-renew", new(options.ServerSetAutoRenew))
|
||||
cmd.Perform("save-template", new(options.ServerSaveImageOptions))
|
||||
cmd.Perform("remote-update", new(options.ServerRemoteUpdateOptions))
|
||||
|
||||
cmd.Get("vnc", new(options.ServerIdOptions))
|
||||
cmd.Get("desc", new(options.ServerIdOptions))
|
||||
@@ -728,7 +727,6 @@ func init() {
|
||||
type ServerRollBackSnapshot struct {
|
||||
ID string `help:"ID or name of VM" json:"-"`
|
||||
InstanceSnapshot string `help:"Instance snapshot id or name" json:"instance_snapshot"`
|
||||
AutoStart bool `help:"Auto start VM"`
|
||||
}
|
||||
R(&ServerRollBackSnapshot{}, "instance-snapshot-reset", "reset instance snapshot", func(s *mcclient.ClientSession, opts *ServerRollBackSnapshot) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
|
||||
@@ -15,31 +15,194 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"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() {
|
||||
cmd := shell.NewResourceCmd(&modules.ServerSkus).WithKeyword("server-sku")
|
||||
cmd.List(&options.ServerSkusListOptions{})
|
||||
cmd.Show(&options.ServerSkusIdOptions{})
|
||||
cmd.Delete(&options.ServerSkusIdOptions{})
|
||||
cmd.Perform("enable", &options.ServerSkusIdOptions{})
|
||||
cmd.Perform("disable", &options.ServerSkusIdOptions{})
|
||||
cmd.Create(&options.ServerSkusCreateOptions{})
|
||||
cmd.Update(&options.ServerSkusUpdateOptions{})
|
||||
cmd.ClassShow(&options.ServerSkusListOptions{})
|
||||
cmd.PerformClass("sync-skus", &options.SkuSyncOptions{})
|
||||
type ServerSkusListOptions struct {
|
||||
options.BaseListOptions
|
||||
Cloudregion string `help:"region Id or name"`
|
||||
Usable bool `help:"Filter usable sku"`
|
||||
Zone string `help:"zone Id or name"`
|
||||
City *string `help:"city name,eg. BeiJing"`
|
||||
Cpu *int `help:"Cpu core count" json:"cpu_core_count"`
|
||||
Mem *int `help:"Memory size in MB" json:"memory_size_mb"`
|
||||
Name string `help:"Name of Sku"`
|
||||
PostpaidStatus string `help:"Postpaid status" choices:"soldout|available"`
|
||||
PrepaidStatus string `help:"Prepaid status" choices:"soldout|available"`
|
||||
}
|
||||
|
||||
R(&options.SkuTaskQueryOptions{}, "server-sku-sync-task-show", "Show details of skus sync tasks", func(s *mcclient.ClientSession, args *options.SkuTaskQueryOptions) error {
|
||||
params, err := args.Params()
|
||||
R(&ServerSkusListOptions{}, "server-sku-list", "List all avaiable Server SKU", func(s *mcclient.ClientSession, args *ServerSkusListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
results, err := modules.ServerSkus.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(results, modules.ServerSkus.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
result, err := modules.ServerSkus.Get(s, "sync-tasks", params)
|
||||
type ServerSkusIdOptions struct {
|
||||
ID string `help:"ID or Name of SKU to show"`
|
||||
}
|
||||
R(&ServerSkusIdOptions{}, "server-sku-show", "show details of a avaiable Server SKU", func(s *mcclient.ClientSession, args *ServerSkusIdOptions) error {
|
||||
result, err := modules.ServerSkus.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ServerSkusIdOptions{}, "server-sku-enable", "Enable Server SKU", func(s *mcclient.ClientSession, args *ServerSkusIdOptions) error {
|
||||
result, err := modules.ServerSkus.PerformAction(s, args.ID, "enable", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ServerSkusIdOptions{}, "server-sku-disable", "Disable Server SKU", func(s *mcclient.ClientSession, args *ServerSkusIdOptions) error {
|
||||
result, err := modules.ServerSkus.PerformAction(s, args.ID, "disable", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ServerSkusCacheOptions struct {
|
||||
REGION string `help:"Private cloud region"`
|
||||
ID string `help:"ServerSku Id"`
|
||||
}
|
||||
|
||||
R(&ServerSkusCacheOptions{}, "server-sku-cache", "Cache Server SKU for private cloud", func(s *mcclient.ClientSession, args *ServerSkusCacheOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.REGION), "cloudregion")
|
||||
result, err := modules.ServerSkus.PerformAction(s, args.ID, "cache-sku", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ServerSkusCreateOptions struct {
|
||||
Name string `help:"ServerSku name"`
|
||||
CpuCoreCount int `help:"Cpu Count" required:"true" positional:"true"`
|
||||
MemorySizeMB int `help:"Memory MB" required:"true" positional:"true"`
|
||||
|
||||
OsName *string `help:"OS name/type" choices:"Linux|Windows|Any" default:"Any"`
|
||||
InstanceTypeCategory *string `help:"instance type category" choices:"general_purpose|compute_optimized|memory_optimized|storage_optimized|hardware_accelerated|high_memory|high_storage"`
|
||||
|
||||
SysDiskResizable *bool `help:"system disk is resizable"`
|
||||
SysDiskType *string `help:"system disk type" default:"local" choices:"local"`
|
||||
SysDiskMaxSizeGB *int `help:"system disk maximal size in gb"`
|
||||
|
||||
AttachedDiskType *string `help:"attached data disk type"`
|
||||
AttachedDiskSizeGB *int `help:"attached data disk size in GB"`
|
||||
AttachedDiskCount *int `help:"attached data disk count"`
|
||||
|
||||
MaxDataDiskCount *int `help:"maximal allowed data disk count"`
|
||||
|
||||
NicType *string `help:"nic type"`
|
||||
MaxNicCount *int `help:"maximal nic count"`
|
||||
|
||||
GPUSpec *string `help:"GPU spec"`
|
||||
GPUCount *int `help:"GPU count"`
|
||||
GPUAttachable *bool `help:"Allow attach GPU"`
|
||||
|
||||
Zone *string `help:"Zone ID or name"`
|
||||
Cloudregion *string `help:"Cloudregion ID or name"`
|
||||
Provider string `help:"provider"`
|
||||
Brand string `help:"brand"`
|
||||
}
|
||||
R(&ServerSkusCreateOptions{}, "server-sku-create", "Create a server sku record", func(s *mcclient.ClientSession, args *ServerSkusCreateOptions) error {
|
||||
params, err := options.StructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ServerSkus.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ServerSkusUpdateOptions struct {
|
||||
ID string `help:"Name or ID of SKU" json:"-"`
|
||||
|
||||
PostpaidStatus *string `help:"skus available status for postpaid instance" choices:"available|soldout"`
|
||||
PrepaidStatus *string `help:"skus available status for prepaid instance" choices:"available|soldout"`
|
||||
CpuCoreCount *int `help:"Cpu Count"`
|
||||
MemorySizeMB *int `help:"Memory MB"`
|
||||
|
||||
InstanceTypeCategory *string `help:"instance type category" choices:"general_purpose|compute_optimized|memory_optimized|storage_optimized|hardware_accelerated|high_memory|high_storage"`
|
||||
|
||||
SysDiskResizable *bool `help:"system disk is resizable"`
|
||||
SysDiskMaxSizeGB *int `help:"system disk maximal size in gb"`
|
||||
|
||||
AttachedDiskType *string `help:"attached data disk type"`
|
||||
AttachedDiskSizeGB *int `help:"attached data disk size in GB"`
|
||||
AttachedDiskCount *int `help:"attached data disk count"`
|
||||
|
||||
MaxDataDiskCount *int `help:"maximal allowed data disk count"`
|
||||
|
||||
NicType *string `help:"nic type"`
|
||||
MaxNicCount *int `help:"maximal nic count"`
|
||||
|
||||
GPUSpec *string `help:"GPU spec"`
|
||||
GPUCount *int `help:"GPU count"`
|
||||
GPUAttachable *bool `help:"Allow attach GPU"`
|
||||
|
||||
Zone *string `help:"Zone ID or name"`
|
||||
Region *string `help:"Region ID or name"`
|
||||
}
|
||||
R(&ServerSkusUpdateOptions{}, "server-sku-update", "Update server sku attributes", func(s *mcclient.ClientSession, args *ServerSkusUpdateOptions) error {
|
||||
params, err := options.StructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ServerSkus.Update(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ServerSkusDeleteOptions struct {
|
||||
ID string `help:"Id or name of server sku"`
|
||||
Purge bool `help:"purge sku"`
|
||||
}
|
||||
R(&ServerSkusDeleteOptions{}, "server-sku-delete", "Delete a server sku", func(s *mcclient.ClientSession, args *ServerSkusDeleteOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
if args.Purge {
|
||||
params.Add(jsonutils.JSONTrue, "purge")
|
||||
}
|
||||
result, err := modules.ServerSkus.Delete(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ServerSkusListOptions{}, "server-sku-specs-list", "List all avaiable Server SKU specifications", func(s *mcclient.ClientSession, args *ServerSkusListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ServerSkus.Get(s, "instance-specs", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -61,14 +61,13 @@ func init() {
|
||||
ID string `help:"ID or Name of storage to update"`
|
||||
Name string `help:"New Name of storage"`
|
||||
Desc string `help:"Description"`
|
||||
CommitBound float64 `help:"Upper bound of storage overcommit rate" json:"cmtbound"`
|
||||
CommitBound float64 `help:"Upper bound of storage overcommit rate"`
|
||||
MediumType string `help:"Medium type" choices:"ssd|rotate"`
|
||||
RbdRadosMonOpTimeout int64 `help:"ceph rados_mon_op_timeout"`
|
||||
RbdRadosOsdOpTimeout int64 `help:"ceph rados_osd_op_timeout"`
|
||||
RbdClientMountTimeout int64 `help:"ceph client_mount_timeout"`
|
||||
RbdKey string `help:"ceph rbd key"`
|
||||
Reserved string `help:"Reserved storage space"`
|
||||
Capacity int `help:"Capacity for storage"`
|
||||
}
|
||||
R(&StorageUpdateOptions{}, "storage-update", "Update a storage", func(s *mcclient.ClientSession, args *StorageUpdateOptions) error {
|
||||
params, err := options.StructToParams(args)
|
||||
|
||||
@@ -1,31 +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/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.VpcPeeringConnections).WithKeyword("vpc-peering-connection")
|
||||
cmd.List(&options.VpcPeeringConnectionListOptions{})
|
||||
cmd.Show(&options.VpcPeeringConnectionIdOptions{})
|
||||
cmd.Create(&options.VpcPeeringConnectionCreateOptions{})
|
||||
cmd.Delete(&options.VpcPeeringConnectionIdOptions{})
|
||||
cmd.Perform("sync", &options.VpcPeeringConnectionIdOptions{})
|
||||
cmd.Perform("syncstatus", &options.VpcPeeringConnectionIdOptions{})
|
||||
}
|
||||
@@ -16,7 +16,6 @@ package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -36,17 +35,4 @@ func init() {
|
||||
cmd.Perform("public", &options.BasePublicOptions{})
|
||||
cmd.Perform("change-owner", &options.VpcChangeOwnerOptions{})
|
||||
cmd.Get("vpc-change-owner-candidate-domains", &options.VpcIdOptions{})
|
||||
|
||||
R(&options.ResourceMetadataOptions{}, "vpc-set-user-metadata", "Set metadata of a vpc", func(s *mcclient.ClientSession, opts *options.ResourceMetadataOptions) error {
|
||||
params, err := opts.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Vpcs.PerformAction(s, opts.ID, "user-metadata", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -42,24 +42,34 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp := &webconsole_api.ServerRemoteConsoleResponse{}
|
||||
if err := obj.Unmarshal(resp); err != nil {
|
||||
connParams, err := obj.GetString("connect_params")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
connectParams := resp.GetConnectParams()
|
||||
if protocol, err := resp.GetConnectProtocol(); err != nil {
|
||||
return err
|
||||
} else if !utils.IsInStringArray(protocol, []string{
|
||||
if decodeStr, err := base64.StdEncoding.DecodeString(connParams); err == nil {
|
||||
connParams = string(decodeStr)
|
||||
}
|
||||
var query url.Values
|
||||
connUrl, err := url.ParseRequestURI(connParams)
|
||||
if err == nil {
|
||||
query = connUrl.Query()
|
||||
} else {
|
||||
query, err = url.ParseQuery(connParams)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
protocol := query.Get("protocol")
|
||||
if !utils.IsInStringArray(protocol, []string{
|
||||
command.PROTOCOL_TTY, webconsole_api.VNC,
|
||||
webconsole_api.SPICE, webconsole_api.WMKS,
|
||||
}) {
|
||||
fmt.Println(connectParams)
|
||||
fmt.Println(connParams)
|
||||
return nil
|
||||
}
|
||||
|
||||
newQuery := url.Values{}
|
||||
newQuery.Set("data", base64.StdEncoding.EncodeToString([]byte(connectParams)))
|
||||
newQuery := url.Values(make(map[string][]string))
|
||||
newQuery.Set("data", base64.StdEncoding.EncodeToString([]byte(connParams)))
|
||||
u.RawQuery = newQuery.Encode()
|
||||
fmt.Println(u.String())
|
||||
return nil
|
||||
|
||||
@@ -1,70 +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 events
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type EventSplitableOptions struct {
|
||||
Service string `help:"service" choices:"compute|identity|image" default:"compute"`
|
||||
}
|
||||
R(&EventSplitableOptions{}, "logs-splitable", "Show splitable info of event table", func(s *mcclient.ClientSession, args *EventSplitableOptions) error {
|
||||
var results jsonutils.JSONObject
|
||||
var err error
|
||||
switch args.Service {
|
||||
case "identity":
|
||||
results, err = modules.IdentityLogs.Get(s, "splitable", nil)
|
||||
case "image":
|
||||
results, err = modules.ImageLogs.Get(s, "splitable", nil)
|
||||
default:
|
||||
results, err = modules.Logs.Get(s, "splitable", nil)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tables, err := results.GetArray()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listResult := &modulebase.ListResult{
|
||||
Data: tables,
|
||||
}
|
||||
printList(listResult, nil)
|
||||
return nil
|
||||
})
|
||||
R(&EventSplitableOptions{}, "logs-purge", "Purge obsolete splitable of event table", func(s *mcclient.ClientSession, args *EventSplitableOptions) error {
|
||||
var results jsonutils.JSONObject
|
||||
var err error
|
||||
switch args.Service {
|
||||
case "identity":
|
||||
results, err = modules.IdentityLogs.PerformClassAction(s, "purge-splitable", nil)
|
||||
case "image":
|
||||
results, err = modules.ImageLogs.PerformClassAction(s, "purge-splitable", nil)
|
||||
default:
|
||||
results, err = modules.Logs.PerformClassAction(s, "purge-splitable", nil)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(results)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -78,11 +78,6 @@ type ICreateOpt interface {
|
||||
IOpt
|
||||
}
|
||||
|
||||
type IBatchCreateOpt interface {
|
||||
IOpt
|
||||
GetCountParam() int
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) RunWithDesc(action, desc string, args interface{}, callback interface{}) {
|
||||
man := cmd.manager
|
||||
prefix := cmd.prefix
|
||||
@@ -139,48 +134,20 @@ func (cmd ResourceCmd) List(args IListOpt) {
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) Create(args ICreateOpt) {
|
||||
cmd.CreateWithKeyword("create", args)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) CreateWithKeyword(keyword string, args ICreateOpt) {
|
||||
cmd.Run(keyword, args, cmd.create)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) create(s *mcclient.ClientSession, args ICreateOpt) error {
|
||||
man := cmd.manager
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
callback := func(s *mcclient.ClientSession, args ICreateOpt) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := man.(modulebase.Manager).Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
ret, err := man.(modulebase.Manager).Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) BatchCreate(args IBatchCreateOpt) {
|
||||
cmd.BatchCreateWithKeyword("create", args)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) BatchCreateWithKeyword(keyword string, args IBatchCreateOpt) {
|
||||
cmd.Run(keyword, args, cmd.batchCreate)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) batchCreate(s *mcclient.ClientSession, args IBatchCreateOpt) error {
|
||||
man := cmd.manager.(modulebase.Manager)
|
||||
count := args.GetCountParam()
|
||||
if count <= 1 {
|
||||
return cmd.create(s, args)
|
||||
}
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rets := man.BatchCreate(s, params, count)
|
||||
printBatchResults(rets, man.GetColumns(s))
|
||||
return nil
|
||||
cmd.Run("create", args, callback)
|
||||
}
|
||||
|
||||
type IIdOpt interface {
|
||||
@@ -314,7 +281,7 @@ type IPerformOpt interface {
|
||||
IIdOpt
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) PerformWithKeyword(keyword, action string, args IPerformOpt) {
|
||||
func (cmd ResourceCmd) Perform(action string, args IPerformOpt) {
|
||||
man := cmd.manager
|
||||
callback := func(s *mcclient.ClientSession, args IPerformOpt) error {
|
||||
params, err := args.Params()
|
||||
@@ -328,28 +295,7 @@ func (cmd ResourceCmd) PerformWithKeyword(keyword, action string, args IPerformO
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.Run(keyword, args, callback)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) PerformClassWithKeyword(keyword, action string, args IOpt) {
|
||||
man := cmd.manager
|
||||
callback := func(s *mcclient.ClientSession, args IOpt) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := man.(modulebase.Manager).PerformClassAction(s, action, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.Run(keyword, args, callback)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) Perform(action string, args IPerformOpt) {
|
||||
cmd.PerformWithKeyword(action, action, args)
|
||||
cmd.Run(action, args, callback)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) PerformClass(action string, args IOpt) {
|
||||
@@ -415,18 +361,13 @@ type IUpdateOpt interface {
|
||||
IIdOpt
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) UpdateWithKeyword(keyword string, args IUpdateOpt) {
|
||||
func (cmd ResourceCmd) Update(args IUpdateOpt) {
|
||||
man := cmd.manager
|
||||
callback := func(s *mcclient.ClientSession, args IUpdateOpt) error {
|
||||
_params, err := args.Params()
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
params := _params.(*jsonutils.JSONDict)
|
||||
params.Remove("id")
|
||||
if params.Length() == 0 {
|
||||
return InvalidUpdateError()
|
||||
}
|
||||
ret, err := man.(modulebase.Manager).Update(s, args.GetId(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -434,11 +375,7 @@ func (cmd ResourceCmd) UpdateWithKeyword(keyword string, args IUpdateOpt) {
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.Run(keyword, args, callback)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) Update(args IUpdateOpt) {
|
||||
cmd.UpdateWithKeyword("update", args)
|
||||
cmd.Run("update", args, callback)
|
||||
}
|
||||
|
||||
type IMetadataOpt interface {
|
||||
@@ -551,7 +488,7 @@ func (cmd JointCmd) List(args IJointListOpt) {
|
||||
if len(args.GetMasterOpt()) > 0 {
|
||||
result, err = man.ListDescendent(s, args.GetMasterOpt(), params)
|
||||
} else if len(args.GetSlaveOpt()) > 0 {
|
||||
result, err = man.ListDescendent2(s, args.GetSlaveOpt(), params)
|
||||
result, err = man.ListDescendent2(s, args.GetMasterOpt(), params)
|
||||
} else {
|
||||
result, err = man.List(s, params)
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ import (
|
||||
func init() {
|
||||
type DomainListOptions struct {
|
||||
options.BaseListOptions
|
||||
IdpId string `help:"filter by idp_id"`
|
||||
IdpEntityId string `help:"filter by idp_entity_id"`
|
||||
IdpId string `help:"filter by idp_id"`
|
||||
}
|
||||
R(&DomainListOptions{}, "domain-list", "List domains", func(s *mcclient.ClientSession, args *DomainListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
@@ -156,16 +155,4 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type DomainUnlinkIdpOptions struct {
|
||||
DOMAIN string `help:"ID or name of domain to operate" json:"-"`
|
||||
}
|
||||
R(&DomainUnlinkIdpOptions{}, "domain-unlink-idp", "Unlink domain from an entity in the speicified identity provider", func(s *mcclient.ClientSession, args *DomainUnlinkIdpOptions) error {
|
||||
result, err := modules.Domains.PerformAction(s, args.DOMAIN, "unlink-idp", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -265,12 +265,9 @@ func init() {
|
||||
type IdentityProviderCreateCASOptions struct {
|
||||
NAME string `help:"name of identity provider" json:"-"`
|
||||
|
||||
AutoCreateProject bool `help:"automatically create a project if the default_project not exists" json:"-"`
|
||||
AutoCreateProject bool `help:"automatically create a default project when importing domain" json:"-"`
|
||||
NoAutoCreateProject bool `help:"do not create default project when importing domain" json:"-"`
|
||||
|
||||
AutoCreateUser bool `help:"automatically create a user" json:"-"`
|
||||
NoAutoCreateUser bool `help:"do not automatically create a user" json:"-"`
|
||||
|
||||
TargetDomain string `help:"target domain without creating new domain" json:"-"`
|
||||
|
||||
api.SCASIdpConfigOptions
|
||||
@@ -287,11 +284,6 @@ func init() {
|
||||
} else if args.NoAutoCreateProject {
|
||||
params.Add(jsonutils.JSONFalse, "auto_create_project")
|
||||
}
|
||||
if args.AutoCreateUser {
|
||||
params.Add(jsonutils.JSONTrue, "auto_create_user")
|
||||
} else if args.NoAutoCreateUser {
|
||||
params.Add(jsonutils.JSONFalse, "auto_create_user")
|
||||
}
|
||||
|
||||
params.Add(jsonutils.NewString("cas"), "driver")
|
||||
params.Add(jsonutils.Marshal(args), "config", "cas")
|
||||
@@ -472,9 +464,6 @@ func init() {
|
||||
AutoCreateProject bool `help:"automatically create a default project when importing domain" json:"-"`
|
||||
NoAutoCreateProject bool `help:"do not create default project when importing domain" json:"-"`
|
||||
|
||||
AutoCreateUser bool `help:"automatically create a user" json:"-"`
|
||||
NoAutoCreateUser bool `help:"do not automatically create a user" json:"-"`
|
||||
|
||||
TargetDomain string `help:"target domain without creating new domain" json:"-"`
|
||||
|
||||
api.SOIDCIdpConfigOptions
|
||||
@@ -491,11 +480,6 @@ func init() {
|
||||
} else if args.NoAutoCreateProject {
|
||||
params.Add(jsonutils.JSONFalse, "auto_create_project")
|
||||
}
|
||||
if args.AutoCreateUser {
|
||||
params.Add(jsonutils.JSONTrue, "auto_create_user")
|
||||
} else if args.NoAutoCreateUser {
|
||||
params.Add(jsonutils.JSONFalse, "auto_create_user")
|
||||
}
|
||||
|
||||
params.Add(jsonutils.NewString("oidc"), "driver")
|
||||
params.Add(jsonutils.Marshal(args), "config", "oidc")
|
||||
@@ -722,18 +706,4 @@ func init() {
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type IdpSetDefaultSsoOptions struct {
|
||||
ID string `help:"id or name of idp to set default Sso" json:"-"`
|
||||
|
||||
api.PerformDefaultSsoInput
|
||||
}
|
||||
R(&IdpSetDefaultSsoOptions{}, "idp-default-sso", "Enable/disable default SSO", func(s *mcclient.ClientSession, args *IdpSetDefaultSsoOptions) error {
|
||||
result, err := modules.IdentityProviders.PerformAction(s, args.ID, "default-sso", jsonutils.Marshal(args))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -24,14 +24,12 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/identity"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/policy"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
"yunion.io/x/onecloud/pkg/util/fileutils2"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
)
|
||||
@@ -40,7 +38,6 @@ func init() {
|
||||
type PolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
Type string `help:"filter by type"`
|
||||
IsSystem *bool `help:"filter by is_system" negative:"is_no_system"`
|
||||
Format string `help:"policy format, default to yaml" default:"yaml" choices:"yaml|json"`
|
||||
OrderByDomain string `help:"order by domain name" choices:"asc|desc"`
|
||||
}
|
||||
@@ -64,8 +61,6 @@ func init() {
|
||||
Enabled bool `help:"create policy enabled"`
|
||||
Disabled bool `help:"create policy disabled"`
|
||||
Desc string `help:"policy description"`
|
||||
Scope string `help:"scope of policy"`
|
||||
IsSystem *bool `help:"create system policy" negative:"no-system"`
|
||||
}
|
||||
R(&PolicyCreateOptions{}, "policy-create", "Create a new policy", func(s *mcclient.ClientSession, args *PolicyCreateOptions) error {
|
||||
policyBytes, err := ioutil.ReadFile(args.FILE)
|
||||
@@ -87,16 +82,6 @@ func init() {
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
if len(args.Scope) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Scope), "scope")
|
||||
}
|
||||
if args.IsSystem != nil {
|
||||
if *args.IsSystem {
|
||||
params.Add(jsonutils.JSONTrue, "is_system")
|
||||
} else {
|
||||
params.Add(jsonutils.JSONFalse, "is_system")
|
||||
}
|
||||
}
|
||||
|
||||
result, err := modules.Policies.Create(s, params)
|
||||
if err != nil {
|
||||
@@ -115,7 +100,6 @@ func init() {
|
||||
Enabled bool `help:"update policy enabled"`
|
||||
Disabled bool `help:"update policy disabled"`
|
||||
Desc string `help:"Description"`
|
||||
IsSystem *bool `help:"is_system"`
|
||||
}
|
||||
updateFunc := func(s *mcclient.ClientSession, args *PolicyPatchOptions) error {
|
||||
policyId, err := modules.Policies.GetId(s, args.ID, nil)
|
||||
@@ -141,13 +125,6 @@ func init() {
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
if args.IsSystem != nil {
|
||||
if *args.IsSystem {
|
||||
params.Add(jsonutils.JSONTrue, "is_system")
|
||||
} else {
|
||||
params.Add(jsonutils.JSONFalse, "is_system")
|
||||
}
|
||||
}
|
||||
result, err := modules.Policies.Patch(s, policyId, params)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -206,7 +183,6 @@ func init() {
|
||||
type PolicyShowOptions struct {
|
||||
ID string `help:"ID of policy"`
|
||||
Format string `help:"policy format, default yaml" default:"yaml" choices:"yaml|json"`
|
||||
Save string `help:"save policy data into a file"`
|
||||
}
|
||||
R(&PolicyShowOptions{}, "policy-show", "Show policy", func(s *mcclient.ClientSession, args *PolicyShowOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
@@ -216,15 +192,6 @@ func init() {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
if len(args.Save) > 0 {
|
||||
if args.Format == "yaml" {
|
||||
yaml, _ := result.GetString("policy")
|
||||
fileutils2.FilePutContents(args.Save, yaml, false)
|
||||
} else {
|
||||
p, _ := result.Get("policy")
|
||||
fileutils2.FilePutContents(args.Save, p.PrettyString(), false)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -264,32 +231,16 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type PolicyBindRoleOptions struct {
|
||||
POLICY string `json:"-" help:"policy Id or name"`
|
||||
api.PolicyBindRoleInput
|
||||
}
|
||||
R(&PolicyBindRoleOptions{}, "policy-bind-role", "Policy bind role", func(s *mcclient.ClientSession, args *PolicyBindRoleOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
log.Debugf("params: %s", params)
|
||||
result, err := modules.Policies.PerformAction(s, args.POLICY, "bind-role", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type PolicyAdminCapableOptions struct {
|
||||
User string `help:"For user"`
|
||||
UserDomain string `help:"Domain for user"`
|
||||
Project string `help:"Role assignments for project"`
|
||||
ProjectDomain string `help:"Domain for project"`
|
||||
Role []string `help:"Role name list"`
|
||||
RoleId []string `help:"Role Id list"`
|
||||
Role []string `help:"Roles"`
|
||||
}
|
||||
R(&PolicyAdminCapableOptions{}, "policy-admin-capable", "Check admin capable", func(s *mcclient.ClientSession, args *PolicyAdminCapableOptions) error {
|
||||
auth.InitFromClientSession(s)
|
||||
policy.EnableGlobalRbac(15*time.Second, false)
|
||||
policy.EnableGlobalRbac(15*time.Second, 15*time.Second, false)
|
||||
|
||||
var token mcclient.TokenCredential
|
||||
if len(args.User) > 0 {
|
||||
@@ -299,7 +250,6 @@ func init() {
|
||||
Project: args.Project,
|
||||
ProjectDomain: args.ProjectDomain,
|
||||
Roles: strings.Join(args.Role, ","),
|
||||
RoleIds: strings.Join(args.RoleId, ","),
|
||||
}
|
||||
} else {
|
||||
token = s.GetToken()
|
||||
@@ -327,7 +277,6 @@ func init() {
|
||||
UserDomain string `help:"Domain for user"`
|
||||
Project string `help:"Role assignments for project"`
|
||||
Role []string `help:"Roles"`
|
||||
RoleId []string `help:"Role Id list"`
|
||||
Request []string `help:"explain request, in format of key:scope:service:resource:action:extra"`
|
||||
Name string `help:"policy name"`
|
||||
Debug bool `help:"enable RBAC debug"`
|
||||
@@ -343,11 +292,26 @@ func init() {
|
||||
rbacutils.ShowMatchRuleDebug = true
|
||||
}
|
||||
auth.InitFromClientSession(s)
|
||||
policy.EnableGlobalRbac(15*time.Second, false)
|
||||
policy.EnableGlobalRbac(15*time.Second, 15*time.Second, false)
|
||||
if args.Debug {
|
||||
consts.EnableRbacDebug()
|
||||
}
|
||||
|
||||
findPolicy := false
|
||||
for !findPolicy {
|
||||
all := policy.PolicyManager.AllPolicies()
|
||||
for _, allP := range all {
|
||||
if len(allP) > 0 {
|
||||
findPolicy = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if findPolicy {
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
req := jsonutils.NewDict()
|
||||
for i := 0; i < len(args.Request); i += 1 {
|
||||
parts := strings.Split(args.Request[i], ":")
|
||||
@@ -410,7 +374,6 @@ func init() {
|
||||
ProjectDomain: projDom,
|
||||
ProjectDomainId: projDomId,
|
||||
Roles: strings.Join(args.Role, ","),
|
||||
RoleIds: strings.Join(args.RoleId, ","),
|
||||
Context: mcclient.SAuthContext{
|
||||
Ip: args.Ip,
|
||||
},
|
||||
@@ -426,7 +389,7 @@ func init() {
|
||||
}
|
||||
printObject(result)
|
||||
|
||||
/*for _, r := range args.Role {
|
||||
for _, r := range args.Role {
|
||||
fmt.Println("role", r, "matched policies:", policy.PolicyManager.RoleMatchPolicies(r))
|
||||
}
|
||||
|
||||
@@ -442,7 +405,7 @@ func init() {
|
||||
fmt.Println("matched", scope, "policies:", m)
|
||||
}
|
||||
|
||||
fmt.Println("all_policies", policy.PolicyManager.AllPolicies())*/
|
||||
fmt.Println("all_policies", policy.PolicyManager.AllPolicies())
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,88 +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 identity
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/identity"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type RolePolicyListOptions struct {
|
||||
api.RolePolicyListInput
|
||||
}
|
||||
R(&RolePolicyListOptions{}, "role-policy-list", "List associated policies of a role", func(s *mcclient.ClientSession, args *RolePolicyListOptions) error {
|
||||
results, err := modules.RolePolicies.List(s, jsonutils.Marshal(args))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(results, modules.RolePolicies.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type RoleAddPolicyOptions struct {
|
||||
ID string `json:"-" help:"role id or name to add policy"`
|
||||
api.RolePerformAddPolicyInput
|
||||
}
|
||||
R(&RoleAddPolicyOptions{}, "role-add-policy", "Add policy to a role", func(s *mcclient.ClientSession, args *RoleAddPolicyOptions) error {
|
||||
result, err := modules.RolesV3.PerformAction(s, args.ID, "add-policy", jsonutils.Marshal(args))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type RoleRemovePolicyOptions struct {
|
||||
ID string `json:"-" help:"role id or name to remove policy"`
|
||||
api.RolePerformRemovePolicyInput
|
||||
}
|
||||
R(&RoleRemovePolicyOptions{}, "role-remove-policy", "Remove policy from a role", func(s *mcclient.ClientSession, args *RoleRemovePolicyOptions) error {
|
||||
result, err := modules.RolesV3.PerformAction(s, args.ID, "remove-policy", jsonutils.Marshal(args))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type RoleSetPolicyOptions struct {
|
||||
ID string `json:"-" help:"role id or name to set policies"`
|
||||
api.RolePerformSetPoliciesInput
|
||||
}
|
||||
R(&RoleSetPolicyOptions{}, "role-set-policies", "Set policies for a role", func(s *mcclient.ClientSession, args *RoleSetPolicyOptions) error {
|
||||
result, err := modules.RolesV3.PerformAction(s, args.ID, "set-policies", jsonutils.Marshal(args))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type RolePolicyDeleteOptions struct {
|
||||
ID string `json:"-" help:"id or role policy binding"`
|
||||
}
|
||||
R(&RolePolicyDeleteOptions{}, "role-policy-delete", "Delete role policy binding", func(s *mcclient.ClientSession, args *RolePolicyDeleteOptions) error {
|
||||
result, err := modules.RolePolicies.Delete(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -31,7 +31,6 @@ func init() {
|
||||
OrderByDomain string `help:"order by domain name" choices:"asc|desc"`
|
||||
Role string `help:"Filter by role"`
|
||||
IdpId string `help:"filter by idp_id"`
|
||||
IdpEntityId string `help:"filter by idp_entity_id"`
|
||||
}
|
||||
R(&UserListOptions{}, "user-list", "List users", func(s *mcclient.ClientSession, args *UserListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
@@ -174,8 +173,6 @@ func init() {
|
||||
|
||||
IdpId string `help:"Id of identity provider to link with"`
|
||||
IdpEntityId string `help:"Entity id of identity provider to link with"`
|
||||
|
||||
Lang string `help:"user default language"`
|
||||
}
|
||||
R(&UserCreateOptions{}, "user-create", "Create a user", func(s *mcclient.ClientSession, args *UserCreateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
@@ -226,10 +223,6 @@ func init() {
|
||||
params.Add(jsonutils.NewString(args.IdpEntityId), "idp_entity_id")
|
||||
}
|
||||
|
||||
if len(args.Lang) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Lang), "lang")
|
||||
}
|
||||
|
||||
/*if len(args.DefaultProject) > 0 {
|
||||
projId, err := modules.Projects.GetId(s, args.DefaultProject, nil)
|
||||
if err != nil {
|
||||
@@ -271,8 +264,6 @@ func init() {
|
||||
// Option []string `help:"User options"`
|
||||
|
||||
SkipPasswordComplexityCheck bool `help:"skip_password_complexity_check"`
|
||||
|
||||
Lang string `help:"update user language"`
|
||||
}
|
||||
R(&UserUpdateOptions{}, "user-update", "Update a user", func(s *mcclient.ClientSession, args *UserUpdateOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
@@ -329,9 +320,6 @@ func init() {
|
||||
} else if args.DisableMfa {
|
||||
params.Add(jsonutils.JSONFalse, "enable_mfa")
|
||||
}
|
||||
if len(args.Lang) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Lang), "lang")
|
||||
}
|
||||
// if len(args.DefaultProject) > 0 {
|
||||
// projId, err := modules.Projects.GetId(s, args.DefaultProject, nil)
|
||||
// if err != nil {
|
||||
|
||||
@@ -29,7 +29,6 @@ func init() {
|
||||
DetachCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
SyncCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
Sync(new(options.FedResourceIdOptions)).
|
||||
Update(new(options.FedResourceUpdateOptions)).
|
||||
ShowEvent()
|
||||
|
||||
cmd.ClassShow(new(options.FedApiResourecesOptions))
|
||||
|
||||
@@ -29,6 +29,5 @@ func init() {
|
||||
DetachCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
SyncCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
Sync(new(options.FedResourceIdOptions)).
|
||||
Update(new(options.FedResourceUpdateOptions)).
|
||||
ShowEvent()
|
||||
}
|
||||
|
||||
@@ -15,15 +15,7 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
@@ -77,51 +69,3 @@ func (c *fedResourceCmd) Sync(args shell.IPerformOpt) *fedResourceCmd {
|
||||
c.K8sResourceCmd.Perform("sync", args)
|
||||
return c
|
||||
}
|
||||
|
||||
type iFedResUpdateOpt interface {
|
||||
shell.IShowOpt
|
||||
GetUpdateFields() []string
|
||||
}
|
||||
|
||||
func (c *fedResourceCmd) Update(args iFedResUpdateOpt) *fedResourceCmd {
|
||||
man := c.manager
|
||||
fields := args.GetUpdateFields()
|
||||
callback := func(s *mcclient.ClientSession, args iFedResUpdateOpt) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := man.(modulebase.Manager).Get(s, args.GetId(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
updateData := jsonutils.NewDict()
|
||||
for _, field := range fields {
|
||||
up, err := ret.Get(field)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "get update field %s", field)
|
||||
}
|
||||
updateData.Add(up, field)
|
||||
}
|
||||
content, err := FileTempEdit(args.GetId(), "yaml", updateData.YAMLString())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "edit tempfile")
|
||||
}
|
||||
jsonBytes, err := yaml.YAMLToJSON([]byte(content))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "yaml to json")
|
||||
}
|
||||
updateBody, err := jsonutils.Parse(jsonBytes)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parse json bytes")
|
||||
}
|
||||
ret, err = man.(modulebase.Manager).Update(s, args.GetId(), updateBody)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
c.RunWithDesc("update", fmt.Sprintf("Update %s of a %s", fields, man.GetKeyword()), args, callback)
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -30,6 +30,5 @@ func init() {
|
||||
DetachCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
SyncCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
Sync(new(options.IdentOptions)).
|
||||
Update(new(options.FedResourceUpdateOptions)).
|
||||
ShowEvent()
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ func init() {
|
||||
DetachCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
SyncCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
Sync(new(options.IdentOptions)).
|
||||
Update(new(options.FedResourceUpdateOptions)).
|
||||
ShowEvent()
|
||||
|
||||
cmd.ClassShow(new(options.FedApiResourecesOptions))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user