mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
Compare commits
432 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
2
Makefile
2
Makefile
@@ -314,7 +314,7 @@ VERSION ?= $(shell git describe --exact-match 2> /dev/null || \
|
||||
git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)
|
||||
|
||||
image:
|
||||
TAG=$(VERSION) REGISTRY=$(REGISTRY) $(ROOT_DIR)/scripts/docker_push.sh $(filter-out $@,$(MAKECMDGOALS))
|
||||
DEBUG=$(DEBUG) ARCH=$(ARCH) TAG=$(VERSION) REGISTRY=$(REGISTRY) $(ROOT_DIR)/scripts/docker_push.sh $(filter-out $@,$(MAKECMDGOALS))
|
||||
|
||||
.PHONY: image
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/baremetal-base:v0.0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/baremetal-base:v0.2
|
||||
|
||||
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
|
||||
|
||||
|
||||
@@ -5,13 +5,16 @@ MAINTAINER "Yaoqi Wan <wanyaoqi@yunionyun.com>"
|
||||
RUN mkdir -p /opt/yunion/bin
|
||||
|
||||
RUN apk update && \
|
||||
apk add --no-cache ipmitool ethtool tzdata ca-certificates && \
|
||||
apk add --no-cache ipmitool ethtool tzdata ca-certificates cdrkit coreutils && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
RUN mkdir -p /opt/cloud/yunion/baremetal
|
||||
|
||||
# udpate latest pci.ids
|
||||
RUN wget -O /opt/cloud/yunion/baremetal/pci.ids http://pci-ids.ucw.cz/v2.2/pci.ids
|
||||
|
||||
# download baremetal-pxerom-*.x86_64.rpm and unpack rpm in current directory
|
||||
COPY ./opt/cloud/yunion/baremetal/bootia32.efi /opt/cloud/yunion/baremetal
|
||||
COPY ./opt/cloud/yunion/baremetal/bootx64.efi /opt/cloud/yunion/baremetal
|
||||
@@ -27,13 +30,3 @@ COPY ./opt/cloud/yunion/baremetal/libutil.c32 /opt/cloud/yunion/baremetal
|
||||
COPY ./opt/cloud/yunion/baremetal/lpxelinux.0 /opt/cloud/yunion/baremetal
|
||||
COPY ./opt/cloud/yunion/baremetal/menu.c32 /opt/cloud/yunion/baremetal
|
||||
COPY ./opt/cloud/yunion/baremetal/pxelinux.0 /opt/cloud/yunion/baremetal
|
||||
|
||||
# add mkisofs with bundles libraries
|
||||
ADD ./mkisofs /bin/mkisofs
|
||||
ADD ./.mkisofs.bin /bin/.mkisofs.bin
|
||||
ADD ./bundles/mkisofs /bin/bundles/mkisofs
|
||||
# use GNU timeout command replace busybox timeout command
|
||||
RUN rm /usr/bin/timeout
|
||||
ADD ./timeout /bin/timeout
|
||||
ADD ./.timeout.bin /bin/.timeout.bin
|
||||
ADD ./bundles/timeout /bin/bundles/timeout
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:v0.2
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:v0.4
|
||||
|
||||
MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com"
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.2
|
||||
|
||||
COPY ./build/monitor/root/opt/ /opt/
|
||||
ADD ./_output/alpine-build/bin/monitor /opt/yunion/bin/monitor
|
||||
@@ -7,7 +7,7 @@ COPY . /root/go/src/yunion.io/x/onecloud
|
||||
WORKDIR /root/go/src/yunion.io/x/onecloud
|
||||
RUN make cmd/esxi-agent
|
||||
|
||||
FROM FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.2
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.2
|
||||
|
||||
MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com"
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
## {{.title}}
|
||||
- 时间: {{.start_time}}
|
||||
- 级别: {{.level}}
|
||||
|
||||
{{ range .matches}}
|
||||
- 指标: {{.metric}}
|
||||
- 触发值: {{html .value_str}}
|
||||
|
||||
### 触发条件:
|
||||
- {{html $.description}}
|
||||
|
||||
### 标签
|
||||
> 名称: {{ index .tags "name" }}
|
||||
> ip: {{ index .tags "ip" }}
|
||||
> 平台: {{ index .tags "brand" }}
|
||||
------
|
||||
{{- end}}
|
||||
@@ -0,0 +1,138 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>{{.Title}}</title>
|
||||
</head>
|
||||
<style>
|
||||
.title {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
width: 960px;
|
||||
background-color: #4da1ff;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.table {
|
||||
width: 960px;
|
||||
margin: 0 auto;
|
||||
padding: 10px 30px 0px 30px;
|
||||
font-family:'微软雅黑',Helvetica,Arial,sans-serif;
|
||||
font-size:14px;
|
||||
background-color: #fbfbfb;
|
||||
}
|
||||
.tr-title {
|
||||
height: 10px;
|
||||
border-left: 5px solid #4da1ff;
|
||||
margin-left: 10px;
|
||||
padding: 3px 8px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.td {
|
||||
width: 80px;
|
||||
padding-left: 20px;
|
||||
height: 35px;
|
||||
font-weight: 400;
|
||||
}
|
||||
.link {
|
||||
text-decoration: none;
|
||||
color: #3591FF;
|
||||
}
|
||||
.thead-tr td {
|
||||
border-left: 1px solid #d7d7d7;
|
||||
border-top: 1px solid #d7d7d7;
|
||||
height: 32px;
|
||||
font-size: 14px;
|
||||
background-color: #d7d7d7;
|
||||
text-align: center;
|
||||
}
|
||||
.tbody-tr td {
|
||||
border-left: 1px solid #d7d7d7;
|
||||
border-top: 1px solid #d7d7d7;
|
||||
height: 32px;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
text-align: center;
|
||||
}
|
||||
.pb-3 {
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
.resouce-table {
|
||||
width: 98%;
|
||||
color: #717171;
|
||||
border-right: 1px solid #d7d7d7;
|
||||
border-bottom: 1px solid #d7d7d7;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<h3 class="title">报警提醒</h3>
|
||||
<table border="0" cellspacing="0" cellpadding="0" class="table">
|
||||
<tr><td colspan="4" class="tr-title">报警信息</td></tr>
|
||||
<tr><td style="height: 10px;"></td></tr>
|
||||
<tr>
|
||||
<td class="td">报警策略:</td>
|
||||
<td>{{.name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">报警级别:</td>
|
||||
<td>{{.level}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">报警时间:</td>
|
||||
<td>{{.start_time}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">策略详情:</td>
|
||||
<td>{{.description}}</td>
|
||||
</tr>
|
||||
</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}}/commonalerts
|
||||
">请登录平台进行查看</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border="0" cellspacing="0" cellpadding="0" class="table pb-3">
|
||||
<tr><td colspan="4" class="tr-title">报警资源</td></tr>
|
||||
<tr><td style="height: 10px;"></td></tr>
|
||||
<tr>
|
||||
<td colspan="4" style="padding: 10px 0 0 20px;">
|
||||
<table cellspacing="0" cellpadding="0" class="resouce-table">
|
||||
<thead>
|
||||
<tr class="thead-tr">
|
||||
|
||||
<td>名称</td>
|
||||
<td>IP</td>
|
||||
<td>平台</td>
|
||||
<td>触发值</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{- range $i, $Matche := .matches}}
|
||||
<tr class="tbody-tr">
|
||||
|
||||
<td>
|
||||
{{- index .tags "name"}}
|
||||
</td>
|
||||
<td>
|
||||
{{ index .tags "ip" }}
|
||||
</td>
|
||||
<td>
|
||||
{{ index .tags "brand" }}
|
||||
</td>
|
||||
<td>{{$Matche.value_str}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td style="height: 10px;"></td></tr>
|
||||
</table>
|
||||
<p style="width: 960px; height: 40px; line-height: 40px; margin: 0 auto; background-color: #4da1ff; color: #fff; font-size: 12px; text-align: center; ">本邮件由系统自动发送,请勿直接回复!</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,17 @@
|
||||
## {{.title}}
|
||||
- Time: {{.start_time}}
|
||||
- Level: {{.level}}
|
||||
|
||||
{{ 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}}
|
||||
@@ -0,0 +1,145 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>{{.Title}}</title>
|
||||
</head>
|
||||
<style>
|
||||
.title {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
width: 960px;
|
||||
background-color: #4da1ff;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.table {
|
||||
width: 960px;
|
||||
margin: 0 auto;
|
||||
padding: 10px 30px 0px 30px;
|
||||
font-family:'微软雅黑',Helvetica,Arial,sans-serif;
|
||||
font-size:14px;
|
||||
background-color: #fbfbfb;
|
||||
}
|
||||
.tr-title {
|
||||
height: 10px;
|
||||
border-left: 5px solid #4da1ff;
|
||||
margin-left: 10px;
|
||||
padding: 3px 8px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.td {
|
||||
width: 80px;
|
||||
padding-left: 20px;
|
||||
height: 35px;
|
||||
font-weight: 400;
|
||||
}
|
||||
.link {
|
||||
text-decoration: none;
|
||||
color: #3591FF;
|
||||
}
|
||||
.thead-tr td {
|
||||
border-left: 1px solid #d7d7d7;
|
||||
border-top: 1px solid #d7d7d7;
|
||||
height: 32px;
|
||||
font-size: 14px;
|
||||
background-color: #d7d7d7;
|
||||
text-align: center;
|
||||
}
|
||||
.tbody-tr td {
|
||||
border-left: 1px solid #d7d7d7;
|
||||
border-top: 1px solid #d7d7d7;
|
||||
height: 32px;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
text-align: center;
|
||||
}
|
||||
.pb-3 {
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
.resouce-table {
|
||||
width: 98%;
|
||||
color: #717171;
|
||||
border-right: 1px solid #d7d7d7;
|
||||
border-bottom: 1px solid #d7d7d7;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<h3 class="title">Alert</h3>
|
||||
<table border="0" cellspacing="0" cellpadding="0" class="table">
|
||||
<tr><td colspan="4" class="tr-title">Alert info</td></tr>
|
||||
<tr><td style="height: 10px;"></td></tr>
|
||||
<tr>
|
||||
<td class="td">Alarm strategy:</td>
|
||||
<td>{{.name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">Alarm level:</td>
|
||||
<td>{{.level}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">Alarm time:</td>
|
||||
<td>{{.start_time}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">Strategy details:</td>
|
||||
<td>{{.description}}</td>
|
||||
</tr>
|
||||
</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}}/commonalerts
|
||||
">Please log in to the platform to view</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border="0" cellspacing="0" cellpadding="0" class="table pb-3">
|
||||
<tr><td colspan="4" class="tr-title">Alarm resources</td></tr>
|
||||
<tr><td style="height: 10px;"></td></tr>
|
||||
<tr>
|
||||
<td colspan="4" style="padding: 10px 0 0 20px;">
|
||||
<table cellspacing="0" cellpadding="0" class="resouce-table">
|
||||
<thead>
|
||||
<tr class="thead-tr">
|
||||
|
||||
<td>Name</td>
|
||||
<td>IP</td>
|
||||
<td>Brand</td>
|
||||
<td>Trigger value</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{- range $i, $Matche := .matches}}
|
||||
<tr class="tbody-tr">
|
||||
|
||||
<td>
|
||||
{{- index .tags "name"}}
|
||||
</td>
|
||||
<td>
|
||||
{{ index .tags "ip" }}
|
||||
</td>
|
||||
<td>
|
||||
{{ index .tags "brand" }}
|
||||
</td>
|
||||
<td>{{$Matche.value_str}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td style="height: 10px;"></td></tr>
|
||||
</table>
|
||||
<p style="width: 960px; height: 40px; line-height: 40px; margin: 0 auto; background-color: #4da1ff; color: #fff; font-size: 12px; text-align: center; ">This email is sent automatically by the system. Please do not reply directly!</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{{.title}}
|
||||
@@ -0,0 +1 @@
|
||||
{{.title}}
|
||||
@@ -0,0 +1 @@
|
||||
{{.title}}
|
||||
@@ -0,0 +1 @@
|
||||
{{.title}}
|
||||
@@ -1 +0,0 @@
|
||||
您的{{ .brand }}主机{{ .name }}的套餐类型已经更改为 CPU:{{ index .flavor_info "cpu" }}核,内存:{{ index .flavor_info "memory" }}M,数据盘:{{ index .flavor_info "datadisk" }}G,带宽: {{ index .flavor_info "ebw" }}M。
|
||||
@@ -1 +0,0 @@
|
||||
您的{{ .brand }}主机{{ .name }}已经创建成功,服务器IP地址为{{ .ips }},{{ if .account }}初始帐号为{{ .account }},{{ end }}{{ if .keypair }}访问ssh密钥为{{ .keypair }},{{ end }}{{ if .password }}初始密码为{{ .password }},{{ end }}请使用{{ if .windows }}远程桌面连接器(RDC){{ else }}SSH{{ end }}或控制面板控制台访问云主机。
|
||||
@@ -1 +0,0 @@
|
||||
项目{{ .tenant }}的{{ .brand }}主机{{ .name }}已经创建成功。
|
||||
@@ -1 +0,0 @@
|
||||
您的{{ .brand }}主机{{ .name }}已经删除。
|
||||
@@ -1 +0,0 @@
|
||||
项目{{ .tenant }}的{{ .brand }}主机{{ .name }}已经删除。
|
||||
@@ -1 +0,0 @@
|
||||
您的{{ .brand }}主机{{ .name }}系统崩溃了: {{ .reason }}
|
||||
@@ -1 +0,0 @@
|
||||
您的{{ .brand }}主机{{ .name }}重装系统成功,{{ if .account }}初始帐号为{{ .account }},{{ end }}{{ if .keypair }}访问密钥为{{ .keypair }},{{ end }}{{ if .password }}初始密码为{{ .password }},{{ end }}请使用{{ if .windows }}远程桌面连接器(RDC){{ else }}SSH{{ end }}或控制面板控制台访问云主机。
|
||||
@@ -0,0 +1 @@
|
||||
您的{{ .brand }}虚拟机{{ .name }}的套餐类型已经更改为 CPU:{{ index .flavor_info "cpu" }}核,内存:{{ index .flavor_info "memory" }}M,数据盘:{{ index .flavor_info "datadisk" }}G,带宽: {{ index .flavor_info "ebw" }}M。
|
||||
@@ -0,0 +1 @@
|
||||
您的{{ .brand }}虚拟机{{ .name }}已经创建成功,虚拟机IP地址为{{ .ips }},{{ if .account }}初始帐号为{{ .account }},{{ end }}{{ if .keypair }}访问ssh密钥为{{ .keypair }},{{ end }}{{ if .password }}初始密码为{{ .password }},{{ end }}请使用{{ if .windows }}远程桌面连接器(RDC){{ else }}SSH{{ end }}或控制面板控制台访问虚拟机。
|
||||
@@ -0,0 +1 @@
|
||||
项目{{ .tenant }}的{{ .brand }}虚拟机{{ .name }}已经创建成功。
|
||||
@@ -0,0 +1 @@
|
||||
您的{{ .brand }}虚拟机{{ .name }}已经删除。
|
||||
@@ -0,0 +1 @@
|
||||
项目{{ .tenant }}的{{ .brand }}虚拟机{{ .name }}已经删除。
|
||||
@@ -0,0 +1 @@
|
||||
您的{{ .brand }}虚拟机{{ .name }}系统崩溃了: {{ .reason }}
|
||||
@@ -0,0 +1 @@
|
||||
您的{{ .brand }}虚拟机{{ .name }}重装系统成功,{{ if .account }}初始帐号为{{ .account }},{{ end }}{{ if .keypair }}访问密钥为{{ .keypair }},{{ end }}{{ if .password }}初始密码为{{ .password }},{{ end }}请使用{{ if .windows }}远程桌面连接器(RDC){{ else }}SSH{{ end }}或控制面板控制台访问虚拟机。
|
||||
@@ -0,0 +1 @@
|
||||
The instance type of your {{ .brand }} virtual machine {{ .name }} has been changed to: {{ index .flavor_info "cpu" }}-core CPU, {{ index .flavor_info "memory" }}M memory, {{ index .flavor_info "datadisk" }}G data disk, {{ index .flavor_info "ebw" }}M bandwidth.
|
||||
@@ -0,0 +1 @@
|
||||
Your {{ .brand }} virtual machine {{ .name }} has been created successfully. The VM's IP address is {{ .ips }}, {{ if .account }}initial account is {{ .account }}, {{ end }}{{ if .keypair }}the access ssh key is {{ .keypair }}, {{ end }}{{ if .password }}the initial password is {{ .password }}, {{ end }}and please use {{ if .windows }}Remote Desktop Connector (RDC){{ else }}SSH{{ end }} or the control panel console to access the VM.
|
||||
@@ -0,0 +1 @@
|
||||
The {{ .brand }} virtual machine {{ .name }} of the project {{ .tenant }} has been created successfully.
|
||||
@@ -0,0 +1 @@
|
||||
Your {{ .brand }} virtual machine {{ .name }} has been deleted.
|
||||
@@ -0,0 +1 @@
|
||||
The {{ .brand }} virtual machine {{ .name }} of the project {{ .tenant }} has been deleted.
|
||||
@@ -0,0 +1 @@
|
||||
Your {{ .brand }} virtual machine {{ .name }} system crashed: {{ .reason }}
|
||||
@@ -0,0 +1 @@
|
||||
Your {{ .brand }} virtual machine {{ .name }} is successfully reinstalled. The VM's {{ if .account }}initial account is {{ .account }}, {{ end }}{{ if .keypair }}the access key is {{ .keypair }}, {{ end }}{{ if .password }}the initial password is {{ .password }}, {{ end }}and please use {{ if .windows }}remote desktop connection (RDC){{ else }}SSH{{ end }} or the control panel console to access the virtual machine.
|
||||
@@ -0,0 +1,6 @@
|
||||
System error message
|
||||
Resource: {{ .name}}
|
||||
Resource ID: {{ .id }}
|
||||
Event: {{ .event }}
|
||||
Reason: {{ .reason }}
|
||||
Time: {{ .created }}
|
||||
@@ -0,0 +1,6 @@
|
||||
System warning message
|
||||
Resource: {{ .name}}
|
||||
Resource ID: {{ .id }}
|
||||
Event: {{ .event }}
|
||||
Reason: {{ .reason }}
|
||||
Time: {{ .created }}
|
||||
@@ -1 +0,0 @@
|
||||
您的{{ .brand }}主机{{ .name }}的套餐类型已经更改为 CPU:{{ index .flavor_info "cpu" }}核,内存:{{ index .flavor_info "memory" }}M,数据盘:{{ index .flavor_info "datadisk" }}G,带宽: {{ index .flavor_info "ebw" }}M。
|
||||
@@ -1 +0,0 @@
|
||||
{{ .brand }}主机{{ .Name }}创建成功
|
||||
@@ -1 +0,0 @@
|
||||
项目{{ .tenant }}的{{ .brand }}主机{{ .name }}已经创建成功
|
||||
@@ -1 +0,0 @@
|
||||
{{ .brand }}主机{{ .name }}删除通知
|
||||
@@ -1 +0,0 @@
|
||||
项目{{ .tenant }}的{{ .brand }}主机{{ .name }}已经删除
|
||||
@@ -1 +0,0 @@
|
||||
您的{{ .brand }}主机{{ .name }}系统崩溃了
|
||||
@@ -1 +0,0 @@
|
||||
{{ .brand }}主机{{ .name }}重装系统成功
|
||||
@@ -0,0 +1 @@
|
||||
您的{{ .brand }}虚拟机{{ .name }}的套餐类型已经更改为 CPU:{{ index .flavor_info "cpu" }}核,内存:{{ index .flavor_info "memory" }}M,数据盘:{{ index .flavor_info "datadisk" }}G,带宽: {{ index .flavor_info "ebw" }}M。
|
||||
@@ -0,0 +1 @@
|
||||
{{ .brand }}虚拟机{{ .Name }}创建成功
|
||||
@@ -0,0 +1 @@
|
||||
项目{{ .tenant }}的{{ .brand }}虚拟机{{ .name }}已经创建成功
|
||||
@@ -0,0 +1 @@
|
||||
{{ .brand }}虚拟机{{ .name }}删除通知
|
||||
@@ -0,0 +1 @@
|
||||
项目{{ .tenant }}的{{ .brand }}虚拟机{{ .name }}已经删除
|
||||
@@ -0,0 +1 @@
|
||||
您的{{ .brand }}虚拟机{{ .name }}系统崩溃了
|
||||
@@ -0,0 +1 @@
|
||||
{{ .brand }}虚拟机{{ .name }}重装系统成功
|
||||
@@ -0,0 +1 @@
|
||||
The instance type of your {{ .brand }} virtual machine {{ .name }} has been changed to: {{ index .flavor_info "cpu" }}-core CPU, {{ index .flavor_info "memory" }}M memory, {{ index .flavor_info "datadisk" }}G data disk, {{ index .flavor_info "ebw" }}M bandwidth
|
||||
@@ -0,0 +1 @@
|
||||
The {{ .brand }} virtual machine {{ .Name }} created successfully
|
||||
@@ -0,0 +1 @@
|
||||
The {{ .brand }} virtual machine {{ .name }} of the project {{ .tenant }} has been created successfully
|
||||
@@ -0,0 +1 @@
|
||||
The {{ .brand }} virtual machine {{ .name }} has been deleted
|
||||
@@ -0,0 +1 @@
|
||||
The {{ .brand }} virtual machine {{ .name }} of the project {{ .tenant }} has been deleted
|
||||
@@ -0,0 +1 @@
|
||||
Your {{ .brand }} virtual machine {{ .name }} system crashed
|
||||
@@ -0,0 +1 @@
|
||||
The {{ .brand }} virtual machine {{ .name }} successfully reinstalled the system
|
||||
@@ -0,0 +1 @@
|
||||
System error message {{ .name }} {{ .event }}
|
||||
@@ -0,0 +1 @@
|
||||
System warning message {{ .name }} {{ .event }}
|
||||
@@ -32,6 +32,7 @@ func init() {
|
||||
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{})
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ func init() {
|
||||
NoObjectStorage bool `help:"filter cloudproviders that has no object storage"`
|
||||
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
|
||||
Cloudregion string `help:"filter cloudproviders by cloudregion"`
|
||||
|
||||
HostSchedtagId string `help:"filter by host schedtag"`
|
||||
}
|
||||
R(&CloudproviderListOptions{}, "cloud-provider-list", "List cloud providers", func(s *mcclient.ClientSession, args *CloudproviderListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
@@ -62,6 +64,10 @@ func init() {
|
||||
if len(args.Cloudregion) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Cloudregion), "cloudregion")
|
||||
}
|
||||
|
||||
if len(args.HostSchedtagId) > 0 {
|
||||
params.Add(jsonutils.NewString(args.HostSchedtagId), "host_schedtag_id")
|
||||
}
|
||||
}
|
||||
result, err := modules.Cloudproviders.List(s, params)
|
||||
if err != nil {
|
||||
|
||||
33
cmd/climc/shell/compute/dnsrecordsets.go
Normal file
33
cmd/climc/shell/compute/dnsrecordsets.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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.DnsRecordSets).WithKeyword("dns-recordset")
|
||||
cmd.List(&options.DnsRecordSetListOptions{})
|
||||
cmd.Create(&options.DnsRecordSetCreateOptions{})
|
||||
cmd.Update(&options.DnsRecordSetUpdateOptions{})
|
||||
cmd.Show(&options.DnsRecordSetIdOptions{})
|
||||
cmd.Delete(&options.DnsRecordSetIdOptions{})
|
||||
cmd.Perform("enable", &options.DnsRecordSetIdOptions{})
|
||||
cmd.Perform("disable", &options.DnsRecordSetIdOptions{})
|
||||
cmd.Perform("set-traffic-policies", &options.DnsRecordSetTrafficPolicyOptions{})
|
||||
}
|
||||
27
cmd/climc/shell/compute/dnstrafficpolicy.go
Normal file
27
cmd/climc/shell/compute/dnstrafficpolicy.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// 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.DnsTrafficPolicies).WithKeyword("dns-trafficpolicy")
|
||||
cmd.List(&options.DnsTrafficPolicyListOptions{})
|
||||
cmd.Create(&options.DnsTrafficPolicyCreateOptions{})
|
||||
}
|
||||
37
cmd/climc/shell/compute/dnszone.go
Normal file
37
cmd/climc/shell/compute/dnszone.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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.DnsZones).WithKeyword("dns-zone")
|
||||
cmd.List(&options.SDnsZoneListOptions{})
|
||||
cmd.Show(&options.SDnsZoneIdOptions{})
|
||||
cmd.ClassShow(&options.DnsZoneCapabilitiesOptions{})
|
||||
cmd.Delete(&options.SDnsZoneIdOptions{})
|
||||
cmd.Create(&options.DnsZoneCreateOptions{})
|
||||
cmd.Perform("syncstatus", &options.SDnsZoneIdOptions{})
|
||||
cmd.Perform("sync-recordsets", &options.SDnsZoneIdOptions{})
|
||||
cmd.Perform("cache", &options.DnsZoneCacheOptions{})
|
||||
cmd.Perform("uncache", &options.DnsZoneUncacheOptions{})
|
||||
cmd.Perform("purge", &options.SDnsZoneIdOptions{})
|
||||
cmd.Perform("add-vpcs", &options.DnsZoneAddVpcsOptions{})
|
||||
cmd.Perform("remove-vpcs", &options.DnsZoneRemoveVpcsOptions{})
|
||||
}
|
||||
28
cmd/climc/shell/compute/dnszonecache.go
Normal file
28
cmd/climc/shell/compute/dnszonecache.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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.DnsZoneCaches).WithKeyword("dns-zone-cache")
|
||||
cmd.List(&options.DnsZoneCacheListOptions{})
|
||||
cmd.Show(&options.DnsZoneCacheIdOptions{})
|
||||
cmd.Delete(&options.DnsZoneCacheIdOptions{})
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
@@ -203,15 +204,18 @@ func init() {
|
||||
|
||||
type NetworkAddressOptions struct {
|
||||
NETWORK string `help:"id or name of network to query"`
|
||||
|
||||
api.GetNetworkAddressesInput
|
||||
}
|
||||
R(&NetworkAddressOptions{}, "network-addresses", "Query used addresses of network", func(s *mcclient.ClientSession, args *NetworkAddressOptions) error {
|
||||
result, err := modules.Networks.GetSpecific(s, args.NETWORK, "addresses", nil)
|
||||
result, err := modules.Networks.GetSpecific(s, args.NETWORK, "addresses", jsonutils.Marshal(args.GetNetworkAddressesInput))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
addrList, err := result.GetArray("addresses")
|
||||
if err != nil {
|
||||
return err
|
||||
addrList, _ := result.GetArray("addresses")
|
||||
if addrList == nil {
|
||||
fmt.Println("no result")
|
||||
return nil
|
||||
}
|
||||
listResult := modulebase.ListResult{Data: addrList}
|
||||
printList(&listResult, nil)
|
||||
|
||||
@@ -15,194 +15,23 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type SecGroupsListOptions struct {
|
||||
Equals string `help:"Secgroup ID or Name, filter secgroups whose rules equals the specified one"`
|
||||
Server string `help:"Filter secgroups bound to specified server"`
|
||||
options.BaseListOptions
|
||||
Ip string `help:"Filter secgroup by ip"`
|
||||
Ports string `help:"Filter secgroup by ports"`
|
||||
Direction string `help:"Filter secgroup by ports" choices:"all|in|out"`
|
||||
}
|
||||
|
||||
R(&SecGroupsListOptions{}, "secgroup-list", "List all security group", func(s *mcclient.ClientSession, args *SecGroupsListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.SecGroups.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.SecGroups.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type SecGroupsCreateOptions struct {
|
||||
NAME string `help:"Name of security group to create"`
|
||||
RULES []string `help:"security rule to create"`
|
||||
Desc string `help:"Description"`
|
||||
}
|
||||
|
||||
R(&SecGroupsCreateOptions{}, "secgroup-create", "Create a security group", func(s *mcclient.ClientSession, args *SecGroupsCreateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.NAME), "name")
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
for i, a := range args.RULES {
|
||||
params.Add(jsonutils.NewString(a), fmt.Sprintf("rule.%d", i))
|
||||
}
|
||||
secgroups, err := modules.SecGroups.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(secgroups)
|
||||
return nil
|
||||
|
||||
})
|
||||
|
||||
type SecGroupsUnionOptions struct {
|
||||
ID string `help:"ID or Name of security group destination"`
|
||||
SECGROUPS []string `help:"source IDs or Names of secgroup"`
|
||||
}
|
||||
|
||||
R(&SecGroupsUnionOptions{}, "secgroup-union", "Union secgroups to one secgroup", func(s *mcclient.ClientSession, args *SecGroupsUnionOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
secgroups := jsonutils.NewArray()
|
||||
for i := 0; i < len(args.SECGROUPS); i++ {
|
||||
secgroups.Add(jsonutils.NewString(args.SECGROUPS[i]))
|
||||
}
|
||||
params.Add(secgroups, "secgroups")
|
||||
secgroup, err := modules.SecGroups.PerformAction(s, args.ID, "union", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(secgroup)
|
||||
return nil
|
||||
|
||||
})
|
||||
|
||||
type SecGroupsDetailOptions struct {
|
||||
ID string `help:"ID or Name of security group"`
|
||||
}
|
||||
R(&SecGroupsDetailOptions{}, "secgroup-show", "Show details of a security group", func(s *mcclient.ClientSession, args *SecGroupsDetailOptions) error {
|
||||
result, err := modules.SecGroups.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
R(&SecGroupsDetailOptions{}, "secgroup-delete", "Delete a security group", func(s *mcclient.ClientSession, args *SecGroupsDetailOptions) error {
|
||||
secgroups, err := modules.SecGroups.Delete(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(secgroups)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&SecGroupsDetailOptions{}, "secgroup-public", "Make a security group publicly available", func(s *mcclient.ClientSession, args *SecGroupsDetailOptions) error {
|
||||
result, err := modules.SecGroups.PerformAction(s, args.ID, "public", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&SecGroupsDetailOptions{}, "secgroup-private", "Make a security group private", func(s *mcclient.ClientSession, args *SecGroupsDetailOptions) error {
|
||||
result, err := modules.SecGroups.PerformAction(s, args.ID, "private", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type SecGroupsUpdateOptions struct {
|
||||
ID string `help:"ID of security group"`
|
||||
Name string `help:"Name of security group to update"`
|
||||
Desc string `help:"Description of security groups"`
|
||||
}
|
||||
|
||||
R(&SecGroupsUpdateOptions{}, "secgroup-update", "Update details of a security group", func(s *mcclient.ClientSession, args *SecGroupsUpdateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
if len(args.Name) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Name), "name")
|
||||
}
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
secgroups, err := modules.SecGroups.Update(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(secgroups)
|
||||
return nil
|
||||
})
|
||||
|
||||
type SecGroupsAddRuleOptions struct {
|
||||
ID string `help:"ID or Name of security group"`
|
||||
DIRECTION string `help:"Direction of rule" choices:"in|out"`
|
||||
PROTOCOL string `help:"Protocol of rule" choices:"any|tcp|udp|icmp"`
|
||||
ACTION string `help:"Actin of rule" choices:"allow|deny"`
|
||||
PRIORITY int `help:"Priority for rule, range 1 ~ 100"`
|
||||
Cidr string `help:"IP or CIRD for rule"`
|
||||
Description string `help:"Desciption for rule"`
|
||||
Ports string `help:"Port for rule"`
|
||||
}
|
||||
|
||||
R(&SecGroupsAddRuleOptions{}, "secgroup-add-rule", "Add rule for a security group", func(s *mcclient.ClientSession, args *SecGroupsAddRuleOptions) error {
|
||||
params, err := options.StructToParams(args)
|
||||
secgroups, err := modules.SecGroups.PerformAction(s, args.ID, "add-rule", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(secgroups)
|
||||
return nil
|
||||
})
|
||||
|
||||
type SecurityGroupCacheSecurityGroup struct {
|
||||
ID string `help:"ID or Name of security group"`
|
||||
VPC string `help:"ID or Name of vpc"`
|
||||
Classic *bool `help:"Is classic vpc"`
|
||||
}
|
||||
|
||||
R(&SecurityGroupCacheSecurityGroup{}, "secgroup-cache-secgroup", "Cache security group for special vpc", func(s *mcclient.ClientSession, args *SecurityGroupCacheSecurityGroup) error {
|
||||
params, err := options.StructToParams(args)
|
||||
secgroups, err := modules.SecGroups.PerformAction(s, args.ID, "cache-secgroup", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(secgroups)
|
||||
return nil
|
||||
})
|
||||
|
||||
type SecurityGroupUncacheSecurityGroup struct {
|
||||
ID string `help:"ID or Name of security group"`
|
||||
CACHE string `help:"ID of secgroup cache"`
|
||||
}
|
||||
|
||||
R(&SecurityGroupUncacheSecurityGroup{}, "secgroup-uncache-secgroup", "Unache special secgroup cache", func(s *mcclient.ClientSession, args *SecurityGroupUncacheSecurityGroup) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.CACHE), "secgroupcache")
|
||||
secgroups, err := modules.SecGroups.PerformAction(s, args.ID, "uncache-secgroup", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(secgroups)
|
||||
return nil
|
||||
})
|
||||
|
||||
cmd := shell.NewResourceCmd(&modules.SecGroups)
|
||||
cmd.List(&options.SecgroupListOptions{})
|
||||
cmd.Create(&options.SecgroupCreateOptions{})
|
||||
cmd.Show(&options.SecgroupIdOptions{})
|
||||
cmd.Update(&options.BaseUpdateOptions{})
|
||||
cmd.Delete(&options.SecgroupIdOptions{})
|
||||
cmd.Perform("merge", &options.SecgroupMergeOptions{})
|
||||
cmd.Perform("public", &options.SecgroupIdOptions{})
|
||||
cmd.Perform("private", &options.SecgroupIdOptions{})
|
||||
cmd.Perform("add-rule", &options.SecgroupsAddRuleOptions{})
|
||||
cmd.Perform("cache-secgroup", &options.SecurityGroupCacheOptions{})
|
||||
cmd.Perform("uncache-secgroup", &options.SecurityGroupUncacheSecurityGroup{})
|
||||
cmd.Perform("purge", &options.SecgroupIdOptions{})
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ func init() {
|
||||
Local *bool `help:"Show local snapshots"`
|
||||
Share *bool `help:"Show shared snapshots"`
|
||||
DiskType string `help:"Filter by disk type" choices:"sys|data"`
|
||||
Server string `help:"Filter by server" json:"server_id"`
|
||||
}
|
||||
R(&SnapshotsListOptions{}, "snapshot-list", "Show snapshots", func(s *mcclient.ClientSession, args *SnapshotsListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
|
||||
@@ -70,13 +70,15 @@ func init() {
|
||||
|
||||
type HostsQueryOptions struct {
|
||||
options.BaseListOptions
|
||||
HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv"`
|
||||
Ncpu int64 `help:"#CPU count of host" metavar:"<CPU_COUNT>"`
|
||||
MemSize int64 `help:"Memory MB size"`
|
||||
DiskSpec []string `help:"Disk spec string, like 'Linux_adapter0_HDD_111Gx4'"`
|
||||
Nic int64 `help:"#Nics count of host" metavar:"<NIC_COUNT>"`
|
||||
GpuModel []string `help:"GPU model, like 'GeForce GTX 1050 Ti'"`
|
||||
Occupied bool `help:"show occupid host" json:"-"`
|
||||
HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv"`
|
||||
Ncpu int64 `help:"#CPU count of host" metavar:"<CPU_COUNT>"`
|
||||
MemSize int64 `help:"Memory MB size"`
|
||||
DiskSpec []string `help:"Disk spec string, like 'Linux_adapter0_HDD_111Gx4'"`
|
||||
Nic int64 `help:"#Nics count of host" metavar:"<NIC_COUNT>"`
|
||||
GpuModel []string `help:"GPU model, like 'GeForce GTX 1050 Ti'"`
|
||||
Occupied bool `help:"Show occupid host" json:"-"`
|
||||
Manufacture string `help:"Manufacture of host"`
|
||||
Model string `help:"Model of host"`
|
||||
}
|
||||
R(&HostsQueryOptions{}, "spec-hosts-list", "List hosts according by specs", func(s *mcclient.ClientSession, args *HostsQueryOptions) error {
|
||||
newHostSpecKeys := func() []string {
|
||||
@@ -90,6 +92,12 @@ func init() {
|
||||
if args.Nic > 0 {
|
||||
keys = append(keys, fmt.Sprintf("nic:%d", args.Nic))
|
||||
}
|
||||
if args.Manufacture != "" {
|
||||
keys = append(keys, fmt.Sprintf("manufacture:%s", args.Manufacture))
|
||||
}
|
||||
if args.Model != "" {
|
||||
keys = append(keys, fmt.Sprintf("model:%s", args.Model))
|
||||
}
|
||||
for _, gm := range args.GpuModel {
|
||||
keys = append(keys, fmt.Sprintf("gpu_model:%s", gm))
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ func init() {
|
||||
Zone string `help:"List storages in zone" json:"-"`
|
||||
Region string `help:"List storages in region"`
|
||||
Schedtag string `help:"filter storage by schedtag"`
|
||||
|
||||
HostSchedtagId string `help:"filter storage by host schedtag"`
|
||||
}
|
||||
R(&StorageListOptions{}, "storage-list", "List storages", func(s *mcclient.ClientSession, opts *StorageListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
|
||||
@@ -15,235 +15,24 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type VpcListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
Usable *bool `help:"Filter usable vpcs"`
|
||||
Region string `help:"ID or Name of region" json:"-"`
|
||||
Globalvpc string `help:"Filter by globalvpc"`
|
||||
ExternalAccessMode string `help:"Filter by external access mode" choices:"distgw|eip|eip-distgw"`
|
||||
}
|
||||
R(&VpcListOptions{}, "vpc-list", "List VPCs", func(s *mcclient.ClientSession, opts *VpcListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var result *modulebase.ListResult
|
||||
if len(opts.Region) > 0 {
|
||||
result, err = modules.Vpcs.ListInContext(s, params, &modules.Cloudregions, opts.Region)
|
||||
} else {
|
||||
result, err = modules.Vpcs.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(opts.ExportFile) > 0 {
|
||||
exportList(result, opts.ExportFile, opts.ExportKeys, opts.ExportTexts, modules.Vpcs.GetColumns(s))
|
||||
} else {
|
||||
printList(result, modules.Vpcs.GetColumns(s))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
type VpcCreateOptions struct {
|
||||
REGION string `help:"ID or name of the region where the VPC is created"`
|
||||
Id string `help:"ID of the new VPC"`
|
||||
NAME string `help:"Name of the VPC"`
|
||||
CIDR string `help:"CIDR block"`
|
||||
Default bool `help:"default VPC for the region" default:"false"`
|
||||
Desc string `help:"Description of the VPC"`
|
||||
Manager string `help:"ID or Name of Cloud provider"`
|
||||
ExternalAccessMode string `help:"Filter by external access mode" choices:"distgw|eip|eip-distgw" default:"eip-distgw"`
|
||||
}
|
||||
R(&VpcCreateOptions{}, "vpc-create", "Create a VPC", func(s *mcclient.ClientSession, args *VpcCreateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.NAME), "name")
|
||||
params.Add(jsonutils.NewString(args.CIDR), "cidr_block")
|
||||
if len(args.Id) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Id), "id")
|
||||
}
|
||||
if len(args.ExternalAccessMode) > 0 {
|
||||
params.Add(jsonutils.NewString(args.ExternalAccessMode), "external_access_mode")
|
||||
}
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
if args.Default {
|
||||
params.Add(jsonutils.JSONTrue, "is_default")
|
||||
}
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
results, err := modules.Vpcs.CreateInContext(s, params, &modules.Cloudregions, args.REGION)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(results)
|
||||
return nil
|
||||
})
|
||||
|
||||
type VpcShowOptions struct {
|
||||
ID string `help:"ID or name of the region"`
|
||||
}
|
||||
R(&VpcShowOptions{}, "vpc-show", "Show a VPC", func(s *mcclient.ClientSession, args *VpcShowOptions) error {
|
||||
results, err := modules.Vpcs.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(results)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&VpcShowOptions{}, "vpc-delete", "Delete a VPC", func(s *mcclient.ClientSession, args *VpcShowOptions) error {
|
||||
results, err := modules.Vpcs.Delete(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(results)
|
||||
return nil
|
||||
})
|
||||
|
||||
type VpcUpdateOptions struct {
|
||||
ID string `help:"ID or name of the VPC"`
|
||||
Name string `help:"New name of the VPC"`
|
||||
Desc string `help:"Description of the VPC"`
|
||||
ExternalAccessMode string `help:"Filter by external access mode" choices:"distgw|eip|eip-distgw"`
|
||||
}
|
||||
R(&VpcUpdateOptions{}, "vpc-update", "Update a VPC", func(s *mcclient.ClientSession, args *VpcUpdateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
if len(args.Name) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Name), "name")
|
||||
}
|
||||
if len(args.ExternalAccessMode) > 0 {
|
||||
params.Add(jsonutils.NewString(args.ExternalAccessMode), "external_access_mode")
|
||||
}
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
results, err := modules.Vpcs.Update(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(results)
|
||||
return nil
|
||||
})
|
||||
|
||||
type VpcUpdateStatusOptions struct {
|
||||
ID string `help:"ID or name of the VPC"`
|
||||
}
|
||||
R(&VpcUpdateStatusOptions{}, "vpc-available", "Make vpc status available", func(s *mcclient.ClientSession, args *VpcUpdateStatusOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString("available"), "status")
|
||||
result, err := modules.Vpcs.PerformAction(s, args.ID, "status", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&VpcUpdateStatusOptions{}, "vpc-pending", "Make vpc status pending", func(s *mcclient.ClientSession, args *VpcUpdateStatusOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString("pending"), "status")
|
||||
result, err := modules.Vpcs.PerformAction(s, args.ID, "status", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&VpcUpdateStatusOptions{}, "vpc-purge", "Purge a managed VPC, not delete the remote entity", func(s *mcclient.ClientSession, args *VpcUpdateStatusOptions) error {
|
||||
result, err := modules.Vpcs.PerformAction(s, args.ID, "purge", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&VpcUpdateStatusOptions{}, "vpc-sync", "Synchronize the status of a vpc", func(s *mcclient.ClientSession, args *VpcUpdateStatusOptions) error {
|
||||
result, err := modules.Vpcs.PerformAction(s, args.ID, "sync", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&VpcUpdateStatusOptions{}, "vpc-syncstatus", "Sync the status of a vpc", func(s *mcclient.ClientSession, args *VpcUpdateStatusOptions) error {
|
||||
result, err := modules.Vpcs.PerformAction(s, args.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type VpcPublicOptions struct {
|
||||
ID string `help:"ID or name of vpc" json:"-"`
|
||||
Scope string `help:"sharing scope" choices:"system|domain"`
|
||||
SharedDomains []string `help:"share to domains"`
|
||||
}
|
||||
R(&VpcPublicOptions{}, "vpc-public", "Make vpc public", func(s *mcclient.ClientSession, args *VpcPublicOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Vpcs.PerformAction(s, args.ID, "public", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type VpcPrivateOptions struct {
|
||||
ID string `help:"ID or name of vpc" json:"-"`
|
||||
}
|
||||
R(&VpcPrivateOptions{}, "vpc-private", "Make vpc private", func(s *mcclient.ClientSession, args *VpcPrivateOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Vpcs.PerformAction(s, args.ID, "private", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&VpcShowOptions{}, "vpc-change-owner-candidate-domains", "Show candiate domains of a vpc for changing owner", func(s *mcclient.ClientSession, args *VpcShowOptions) error {
|
||||
result, err := modules.Vpcs.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type VpcChangeOwnerOptions struct {
|
||||
ID string `help:"ID or name of vpc" json:"-"`
|
||||
ProjectDomain string `json:"project_domain" help:"target domain"`
|
||||
}
|
||||
R(&VpcChangeOwnerOptions{}, "vpc-change-owner", "Change owner domain of vpc", func(s *mcclient.ClientSession, args *VpcChangeOwnerOptions) error {
|
||||
if len(args.ProjectDomain) == 0 {
|
||||
return fmt.Errorf("empty project_domain")
|
||||
}
|
||||
params := jsonutils.Marshal(args)
|
||||
ret, err := modules.Vpcs.PerformAction(s, args.ID, "change-owner", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
cmd := shell.NewResourceCmd(&modules.Vpcs).WithContextManager(&modules.Cloudregions)
|
||||
cmd.List(&options.VpcListOptions{})
|
||||
cmd.Create(&options.VpcCreateOptions{})
|
||||
cmd.Show(&options.VpcIdOptions{})
|
||||
cmd.Delete(&options.VpcIdOptions{})
|
||||
cmd.Update(&options.VpcUpdateOptions{})
|
||||
cmd.Perform("status", &options.VpcStatusOptions{})
|
||||
cmd.Perform("purge", &options.VpcIdOptions{})
|
||||
cmd.Perform("sync", &options.VpcIdOptions{})
|
||||
cmd.Perform("syncstatus", &options.VpcIdOptions{})
|
||||
cmd.Perform("private", &options.VpcIdOptions{})
|
||||
cmd.Perform("public", &options.BasePublicOptions{})
|
||||
cmd.Perform("change-owner", &options.VpcChangeOwnerOptions{})
|
||||
cmd.Get("vpc-change-owner-candidate-domains", &options.VpcIdOptions{})
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
)
|
||||
|
||||
type BaseEventListOptions struct {
|
||||
@@ -54,23 +53,19 @@ type TypeEventListOptions struct {
|
||||
ID string `help:"" metavar:"OBJ_ID"`
|
||||
}
|
||||
|
||||
func doK8sEventList(s *mcclient.ClientSession, args *EventListOptions) error {
|
||||
return doEventList(*k8s.Logs.ResourceManager, s, args)
|
||||
}
|
||||
|
||||
func doComputeEventList(s *mcclient.ClientSession, args *EventListOptions) error {
|
||||
return doEventList(modules.Logs, s, args)
|
||||
return DoEventList(modules.Logs, s, args)
|
||||
}
|
||||
|
||||
func doImageEventList(s *mcclient.ClientSession, args *EventListOptions) error {
|
||||
return doEventList(modules.ImageLogs, s, args)
|
||||
return DoEventList(modules.ImageLogs, s, args)
|
||||
}
|
||||
|
||||
func doIdentityEventList(s *mcclient.ClientSession, args *EventListOptions) error {
|
||||
return doEventList(modules.IdentityLogs, s, args)
|
||||
return DoEventList(modules.IdentityLogs, s, args)
|
||||
}
|
||||
|
||||
func doEventList(man modulebase.ResourceManager, s *mcclient.ClientSession, args *EventListOptions) error {
|
||||
func DoEventList(man modulebase.ResourceManager, s *mcclient.ClientSession, args *EventListOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
if len(args.Type) > 0 {
|
||||
params.Add(jsonutils.NewStringArray(args.Type), "obj_type")
|
||||
@@ -190,16 +185,6 @@ func init() {
|
||||
return doComputeEventList(s, &nargs)
|
||||
})
|
||||
|
||||
R(&TypeEventListOptions{}, "kubecluster-event", "Show operation event logs of kubernetes cluster", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
|
||||
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"kubecluster"}}
|
||||
return doK8sEventList(s, &nargs)
|
||||
})
|
||||
|
||||
R(&TypeEventListOptions{}, "kubemachine-event", "Show operation event logs of kubernetes machine", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
|
||||
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"kubemachine"}}
|
||||
return doK8sEventList(s, &nargs)
|
||||
})
|
||||
|
||||
R(&TypeEventListOptions{}, "image-event", "Show operation event logs of glance images", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
|
||||
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"image"}}
|
||||
return doImageEventList(s, &nargs)
|
||||
|
||||
@@ -78,7 +78,7 @@ type ICreateOpt interface {
|
||||
IOpt
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) runWithDesc(action, desc string, args interface{}, callback interface{}) {
|
||||
func (cmd ResourceCmd) RunWithDesc(action, desc string, args interface{}, callback interface{}) {
|
||||
man := cmd.manager
|
||||
prefix := cmd.prefix
|
||||
if prefix != "" {
|
||||
@@ -98,8 +98,8 @@ func (cmd ResourceCmd) runWithDesc(action, desc string, args interface{}, callba
|
||||
R(args, fmt.Sprintf("%s%s-%s", prefix, cmd.keyword, action), desc, callback)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) run(action string, args interface{}, callback interface{}) {
|
||||
cmd.runWithDesc(action, "", args, callback)
|
||||
func (cmd ResourceCmd) Run(action string, args interface{}, callback interface{}) {
|
||||
cmd.RunWithDesc(action, "", args, callback)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) List(args IListOpt) {
|
||||
@@ -130,7 +130,7 @@ func (cmd ResourceCmd) List(args IListOpt) {
|
||||
printList(result, man.GetColumns(s))
|
||||
return nil
|
||||
}
|
||||
cmd.run("list", args, callback)
|
||||
cmd.Run("list", args, callback)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) Create(args ICreateOpt) {
|
||||
@@ -147,7 +147,7 @@ func (cmd ResourceCmd) Create(args ICreateOpt) {
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.run("create", args, callback)
|
||||
cmd.Run("create", args, callback)
|
||||
}
|
||||
|
||||
type IIdOpt interface {
|
||||
@@ -177,7 +177,24 @@ func (cmd ResourceCmd) Show(args IShowOpt) {
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.runWithDesc("show", fmt.Sprintf("Show details of a %s", man.GetKeyword()), args, callback)
|
||||
cmd.RunWithDesc("show", fmt.Sprintf("Show details of a %s", man.GetKeyword()), args, callback)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) ClassShow(args IShowOpt) {
|
||||
man := cmd.manager
|
||||
callback := func(s *mcclient.ClientSession, args IShowOpt) 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
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.RunWithDesc(args.GetId(), fmt.Sprintf("Show %s of a %s", args.GetId(), man.GetKeyword()), args, callback)
|
||||
}
|
||||
|
||||
type IGetActionOpt interface {
|
||||
@@ -230,7 +247,7 @@ func (cmd ResourceCmd) Custom(action TCustomAction, funcname string, args IGetAc
|
||||
}
|
||||
return nil
|
||||
}
|
||||
cmd.runWithDesc(funcname, fmt.Sprintf("Get %s of a %s", funcname, man.GetKeyword()), args, callback)
|
||||
cmd.RunWithDesc(funcname, fmt.Sprintf("Get %s of a %s", funcname, man.GetKeyword()), args, callback)
|
||||
}
|
||||
|
||||
type IDeleteOpt interface {
|
||||
@@ -252,7 +269,7 @@ func (cmd ResourceCmd) Delete(args IDeleteOpt) {
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.runWithDesc("delete", fmt.Sprintf("Delete %s", man.GetKeyword()), args, callback)
|
||||
cmd.RunWithDesc("delete", fmt.Sprintf("Delete %s", man.GetKeyword()), args, callback)
|
||||
}
|
||||
|
||||
type IWithDescOpt interface {
|
||||
@@ -278,7 +295,7 @@ func (cmd ResourceCmd) Perform(action string, args IPerformOpt) {
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.run(action, args, callback)
|
||||
cmd.Run(action, args, callback)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) PerformClass(action string, args IOpt) {
|
||||
@@ -295,7 +312,7 @@ func (cmd ResourceCmd) PerformClass(action string, args IOpt) {
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.run(action, args, callback)
|
||||
cmd.Run(action, args, callback)
|
||||
}
|
||||
|
||||
type IBatchPerformOpt interface {
|
||||
@@ -314,7 +331,7 @@ func (cmd ResourceCmd) BatchPerform(action string, args IBatchPerformOpt) {
|
||||
printBatchResults(ret, man.GetColumns(s))
|
||||
return nil
|
||||
}
|
||||
cmd.run(action, args, callback)
|
||||
cmd.Run(action, args, callback)
|
||||
}
|
||||
|
||||
type IGetOpt interface {
|
||||
@@ -336,7 +353,7 @@ func (cmd ResourceCmd) Get(specific string, args IGetOpt) {
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.runWithDesc(specific, fmt.Sprintf("Get %s of a %s", specific, man.GetKeyword()), args, callback)
|
||||
cmd.RunWithDesc(specific, fmt.Sprintf("Get %s of a %s", specific, man.GetKeyword()), args, callback)
|
||||
}
|
||||
|
||||
type IUpdateOpt interface {
|
||||
@@ -358,7 +375,7 @@ func (cmd ResourceCmd) Update(args IUpdateOpt) {
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.run("update", args, callback)
|
||||
cmd.Run("update", args, callback)
|
||||
}
|
||||
|
||||
type IMetadataOpt interface {
|
||||
@@ -380,7 +397,7 @@ func (cmd ResourceCmd) GetMetadata(args IMetadataOpt) {
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.runWithDesc("metadata", fmt.Sprintf("Show metadata of a %s", man.GetKeyword()), args, callback)
|
||||
cmd.RunWithDesc("metadata", fmt.Sprintf("Show metadata of a %s", man.GetKeyword()), args, callback)
|
||||
}
|
||||
|
||||
type IBatchDeleteOpt interface {
|
||||
@@ -399,7 +416,7 @@ func (cmd ResourceCmd) BatchDelete(args IBatchDeleteOpt) {
|
||||
printBatchResults(ret, man.GetColumns(s))
|
||||
return nil
|
||||
}
|
||||
cmd.run("delete", args, callback)
|
||||
cmd.Run("delete", args, callback)
|
||||
}
|
||||
|
||||
type IBatchDeleteWithParamOpt interface {
|
||||
@@ -422,7 +439,7 @@ func (cmd ResourceCmd) BatchDeleteWithParam(args IBatchDeleteWithParamOpt) {
|
||||
printBatchResults(ret, man.GetColumns(s))
|
||||
return nil
|
||||
}
|
||||
cmd.run("delete", args, callback)
|
||||
cmd.Run("delete", args, callback)
|
||||
}
|
||||
|
||||
type IBatchPutOpt interface {
|
||||
@@ -441,7 +458,7 @@ func (cmd ResourceCmd) BatchPut(args IBatchPutOpt) {
|
||||
printBatchResults(ret, man.GetColumns(s))
|
||||
return nil
|
||||
}
|
||||
cmd.run("update", args, callback)
|
||||
cmd.Run("update", args, callback)
|
||||
}
|
||||
|
||||
type JointCmd struct {
|
||||
@@ -481,7 +498,7 @@ func (cmd JointCmd) List(args IJointListOpt) {
|
||||
printList(result, man.GetColumns(s))
|
||||
return nil
|
||||
}
|
||||
cmd.runWithDesc("list", fmt.Sprintf("list %s %s pairs", man.MasterManager().KeyString(), man.SlaveManager().KeyString()), args, callback)
|
||||
cmd.RunWithDesc("list", fmt.Sprintf("list %s %s pairs", man.MasterManager().KeyString(), man.SlaveManager().KeyString()), args, callback)
|
||||
}
|
||||
|
||||
type IJointShowOpt interface {
|
||||
@@ -504,5 +521,5 @@ func (cmd JointCmd) Show(args IJointShowOpt) {
|
||||
printObject(result)
|
||||
return nil
|
||||
}
|
||||
cmd.run("show", args, callback)
|
||||
cmd.Run("show", args, callback)
|
||||
}
|
||||
|
||||
@@ -23,20 +23,25 @@ import (
|
||||
|
||||
func init() {
|
||||
type RoleAssignmentsOptions struct {
|
||||
Effective bool `help:"Include role assignment of group members"`
|
||||
System bool `help:"Include system user account"`
|
||||
Policy bool `help:"Show matched policies"`
|
||||
Domain string `help:"Role assignments for domain"`
|
||||
User string `help:"For user"`
|
||||
UserDomain string `help:"Domain for user"`
|
||||
Group string `help:"For group"`
|
||||
GroupDomain string `help:"Domain for group"`
|
||||
Project string `help:"Role assignments for project"`
|
||||
ProjectDomain string `help:"Domain for project"`
|
||||
Role string `help:"Role assignments for role"`
|
||||
RoleDomain string `help:"Domain for role"`
|
||||
Limit int64 `help:"maximal returned number of rows"`
|
||||
Offset int64 `help:"offset index of returned results"`
|
||||
Effective bool `help:"Include role assignment of group members"`
|
||||
System bool `help:"Include system user account"`
|
||||
Policy bool `help:"Show matched policies"`
|
||||
Domain string `help:"Role assignments for domain"`
|
||||
User string `help:"For user"`
|
||||
UserDomain string `help:"Domain for user"`
|
||||
Group string `help:"For group"`
|
||||
GroupDomain string `help:"Domain for group"`
|
||||
Project string `help:"Role assignments for project"`
|
||||
ProjectDomain string `help:"Domain for project"`
|
||||
Role string `help:"Role assignments for role"`
|
||||
RoleDomain string `help:"Domain for role"`
|
||||
Limit int64 `help:"maximal returned number of rows"`
|
||||
Offset int64 `help:"offset index of returned results"`
|
||||
Users []string `help:"fitler by users id or name"`
|
||||
Groups []string `help:"fitler by users id or name"`
|
||||
Roles []string `help:"fitler by users id or name"`
|
||||
Projects []string `help:"fitler by users id or name"`
|
||||
Domains []string `help:"fitler by users id or name"`
|
||||
}
|
||||
R(&RoleAssignmentsOptions{}, "role-assignments", "List all role assignments", func(s *mcclient.ClientSession, args *RoleAssignmentsOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
@@ -85,6 +90,21 @@ func init() {
|
||||
}
|
||||
query.Add(jsonutils.NewString(rid), "role", "id")
|
||||
}
|
||||
if len(args.Users) > 0 {
|
||||
query.Add(jsonutils.NewStringArray(args.Users), "users")
|
||||
}
|
||||
if len(args.Groups) > 0 {
|
||||
query.Add(jsonutils.NewStringArray(args.Groups), "groups")
|
||||
}
|
||||
if len(args.Roles) > 0 {
|
||||
query.Add(jsonutils.NewStringArray(args.Roles), "roles")
|
||||
}
|
||||
if len(args.Projects) > 0 {
|
||||
query.Add(jsonutils.NewStringArray(args.Projects), "projects")
|
||||
}
|
||||
if len(args.Domains) > 0 {
|
||||
query.Add(jsonutils.NewStringArray(args.Domains), "domains")
|
||||
}
|
||||
if args.Limit > 0 {
|
||||
query.Add(jsonutils.NewInt(args.Limit), "limit")
|
||||
}
|
||||
|
||||
@@ -262,6 +262,8 @@ func init() {
|
||||
|
||||
// DefaultProject string `help:"Default project"`
|
||||
// Option []string `help:"User options"`
|
||||
|
||||
SkipPasswordComplexityCheck bool `help:"skip_password_complexity_check"`
|
||||
}
|
||||
R(&UserUpdateOptions{}, "user-update", "Update a user", func(s *mcclient.ClientSession, args *UserUpdateOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
@@ -282,6 +284,9 @@ func init() {
|
||||
}
|
||||
if args.Password != nil {
|
||||
params.Add(jsonutils.NewString(*args.Password), "password")
|
||||
if args.SkipPasswordComplexityCheck {
|
||||
params.Add(jsonutils.JSONTrue, "skip_password_complexity_check")
|
||||
}
|
||||
}
|
||||
if len(args.Displayname) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Displayname), "displayname")
|
||||
|
||||
@@ -15,27 +15,11 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
o "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func initKubeCerts() {
|
||||
cmdN := func(action string) string {
|
||||
return fmt.Sprintf("kubecert-%s", action)
|
||||
}
|
||||
R(&o.CertListOptions{}, cmdN("list"), "List k8s cluster certificates key pairs", func(s *mcclient.ClientSession, args *o.CertListOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := k8s.KubeCerts.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(ret, k8s.KubeCerts.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
cmd := NewK8sResourceCmd(k8s.KubeCerts)
|
||||
cmd.List(new(o.CertListOptions))
|
||||
}
|
||||
|
||||
@@ -26,38 +26,24 @@ import (
|
||||
|
||||
func initKubeCluster() {
|
||||
cmdN := func(action string) string {
|
||||
return fmt.Sprintf("kubecluster-%s", action)
|
||||
return fmt.Sprintf("k8s-cluster-%s", action)
|
||||
}
|
||||
R(&o.ClusterListOptions{}, cmdN("list"), "List k8s clusters", func(s *mcclient.ClientSession, args *o.ClusterListOptions) error {
|
||||
result, err := k8s.KubeClusters.List(s, args.Params())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, k8s.KubeClusters.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentOptions{}, cmdN("show"), "Show details of a cluster", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
|
||||
result, err := k8s.KubeClusters.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.KubeClusterCreateOptions{}, cmdN("create"), "Create k8s cluster", func(s *mcclient.ClientSession, args *o.KubeClusterCreateOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cluster, err := k8s.KubeClusters.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(cluster)
|
||||
return nil
|
||||
})
|
||||
cmd := NewK8sResourceCmd(k8s.KubeClusters)
|
||||
cmd.SetKeyword("cluster")
|
||||
cmd.ShowEvent()
|
||||
cmd.List(new(o.ClusterListOptions))
|
||||
cmd.Show(new(o.IdentOptions))
|
||||
cmd.Create(new(o.KubeClusterCreateOptions))
|
||||
cmd.Perform("sync", new(o.ClusterSyncOptions))
|
||||
cmd.Perform("syncstatus", new(o.IdentOptions))
|
||||
cmd.Get("components-status", new(o.IdentOptions))
|
||||
cmd.Get("api-resources", new(o.IdentOptions))
|
||||
cmd.Get("cluster-users", new(o.IdentOptions))
|
||||
cmd.Get("cluster-user-groups", new(o.IdentOptions))
|
||||
cmd.Perform("purge", new(o.ClusterPurgeOptions))
|
||||
cmd.Perform("delete-machines", new(o.KubeClusterDeleteMachinesOptions))
|
||||
cmd.Perform("add-machines", new(o.KubeClusterAddMachinesOptions))
|
||||
cmd.PerformClass("gc", new(o.ClusterGCOpts))
|
||||
|
||||
R(&o.KubeClusterImportOptions{}, cmdN("import"), "Import k8s cluster", func(s *mcclient.ClientSession, args *o.KubeClusterImportOptions) error {
|
||||
params, err := args.Params()
|
||||
@@ -78,41 +64,6 @@ func initKubeCluster() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.KubeClusterAddMachinesOptions{}, cmdN("add-machines"), "Add machines to cluster", func(s *mcclient.ClientSession, args *o.KubeClusterAddMachinesOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "add-machines", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.KubeClusterDeleteMachinesOptions{}, cmdN("delete-machines"), "Delete machines in cluster", func(s *mcclient.ClientSession, args *o.KubeClusterDeleteMachinesOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "delete-machines", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentOptions{}, cmdN("terminate"), "Terminate cluster", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
|
||||
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "terminate", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentOptions{}, cmdN("kubeconfig"), "Generate kubeconfig of a cluster", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
|
||||
ret, err := k8s.KubeClusters.GetSpecific(s, args.ID, "kubeconfig", nil)
|
||||
if err != nil {
|
||||
@@ -179,55 +130,6 @@ func initKubeCluster() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentOptions{}, cmdN("syncstatus"), "Sync cluster status", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
|
||||
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.ClusterSyncOptions{}, cmdN("sync"), "Sync cluster k8s resources", func(s *mcclient.ClientSession, args *o.ClusterSyncOptions) error {
|
||||
param, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "sync", param)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentOptions{}, cmdN("public"), "Make cluster public", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
|
||||
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "public", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentOptions{}, cmdN("private"), "Make cluster private", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
|
||||
ret, err := k8s.KubeClusters.PerformAction(s, args.ID, "private", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentOptions{}, cmdN("components-status"), "Get cluster component status", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
|
||||
ret, err := k8s.KubeClusters.GetSpecific(s, args.ID, "components-status", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.ClusterComponentTypeOptions{}, cmdN("component-setting"), "Get cluster component setting", func(s *mcclient.ClientSession, args *o.ClusterComponentTypeOptions) error {
|
||||
q := jsonutils.NewDict()
|
||||
q.Add(jsonutils.NewString(args.TYPE), "type")
|
||||
|
||||
@@ -16,8 +16,11 @@ package k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
o "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func initConfigMap() {
|
||||
initK8sNamespaceResource("configmap", k8s.ConfigMaps)
|
||||
cmd := NewK8sResourceCmd(k8s.ConfigMaps)
|
||||
cmd.Create(&o.ConfigMapCreateOptions{})
|
||||
}
|
||||
|
||||
@@ -15,30 +15,11 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
o "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func initCronJob() {
|
||||
cmd := initK8sNamespaceResource("cronjob", k8s.CronJobs)
|
||||
cmdN := cmd.CommandNameFactory
|
||||
createCmd := NewCommand(
|
||||
&o.CronJobCreateOptions{},
|
||||
cmdN("create"),
|
||||
"Create cronjob resource",
|
||||
func(s *mcclient.ClientSession, args *o.CronJobCreateOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := k8s.CronJobs.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
cmd.AddR(createCmd)
|
||||
cmd.Create(new(o.CronJobCreateOptions))
|
||||
}
|
||||
|
||||
@@ -15,48 +15,12 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
o "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func initDeployment() {
|
||||
cmd := initK8sNamespaceResource("deployment", k8s.Deployments)
|
||||
cmdN := cmd.CommandNameFactory
|
||||
|
||||
createCmd := NewCommand(
|
||||
&o.DeploymentCreateOptions{},
|
||||
cmdN("create"),
|
||||
"Create deployment resource",
|
||||
func(s *mcclient.ClientSession, args *o.DeploymentCreateOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := k8s.Deployments.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
updateCmd := NewCommand(
|
||||
&o.DeploymentUpdateOptions{},
|
||||
cmdN("update"),
|
||||
"Update deployment resource",
|
||||
func(s *mcclient.ClientSession, args *o.DeploymentUpdateOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := k8s.Deployments.Update(s, args.NAME, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectYAML(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
cmd.AddR(createCmd, updateCmd)
|
||||
cmd.Create(new(o.DeploymentCreateOptions))
|
||||
cmd.Update(new(o.DeploymentUpdateOptions))
|
||||
}
|
||||
|
||||
37
cmd/climc/shell/k8s/fed_clusterrole.go
Normal file
37
cmd/climc/shell/k8s/fed_clusterrole.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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 k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := newFedResourceCmd(k8s.FederatedClusterRoles)
|
||||
cmd.Create(new(options.FedClusterRoleCreateOptions)).
|
||||
List(new(options.FedResourceListOptions)).
|
||||
Show(new(options.IdentOptions)).
|
||||
Delete(new(options.IdentOptions)).
|
||||
AttachCluster(new(options.FedResourceJointClusterAttachOptions)).
|
||||
DetachCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
SyncCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
Sync(new(options.FedResourceIdOptions)).
|
||||
ShowEvent()
|
||||
|
||||
cmd.ClassShow(new(options.FedApiResourecesOptions))
|
||||
cmd.ClassShow(new(options.FedClusterUsersOptions))
|
||||
cmd.ClassShow(new(options.FedClusterUserGroupsOptions))
|
||||
}
|
||||
27
cmd/climc/shell/k8s/fed_clusterrole_cluster.go
Normal file
27
cmd/climc/shell/k8s/fed_clusterrole_cluster.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// 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 k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := NewK8sJointCmd(&k8s.FederatedClusterRoleClusters)
|
||||
|
||||
cmd.List(new(options.FedJointClusterBaseListOptions))
|
||||
cmd.Show(new(options.FedResourceJointClusterShowOptions))
|
||||
}
|
||||
33
cmd/climc/shell/k8s/fed_clusterrolebinding.go
Normal file
33
cmd/climc/shell/k8s/fed_clusterrolebinding.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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 k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := newFedResourceCmd(k8s.FederatedClusterRoleBindings)
|
||||
cmd.Create(new(options.FedClusterRoleBindingCreatOpt)).
|
||||
List(new(options.FedResourceListOptions)).
|
||||
Show(new(options.IdentOptions)).
|
||||
Delete(new(options.IdentOptions)).
|
||||
AttachCluster(new(options.FedResourceJointClusterAttachOptions)).
|
||||
DetachCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
SyncCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
Sync(new(options.FedResourceIdOptions)).
|
||||
ShowEvent()
|
||||
}
|
||||
71
cmd/climc/shell/k8s/fed_helper.go
Normal file
71
cmd/climc/shell/k8s/fed_helper.go
Normal file
@@ -0,0 +1,71 @@
|
||||
// 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 k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
type fedResourceCmd struct {
|
||||
*K8sResourceCmd
|
||||
}
|
||||
|
||||
func newFedResourceCmd(manager modulebase.IBaseManager) *fedResourceCmd {
|
||||
cmd := NewK8sResourceCmd(manager)
|
||||
return &fedResourceCmd{
|
||||
K8sResourceCmd: cmd,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *fedResourceCmd) List(args shell.IListOpt) *fedResourceCmd {
|
||||
c.K8sResourceCmd.List(args)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *fedResourceCmd) Show(args shell.IShowOpt) *fedResourceCmd {
|
||||
c.K8sResourceCmd.Show(args)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *fedResourceCmd) Create(args shell.ICreateOpt) *fedResourceCmd {
|
||||
c.K8sResourceCmd.Create(args)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *fedResourceCmd) Delete(args shell.IDeleteOpt) *fedResourceCmd {
|
||||
c.K8sResourceCmd.Delete(args)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *fedResourceCmd) AttachCluster(args shell.IPerformOpt) *fedResourceCmd {
|
||||
c.K8sResourceCmd.Perform("attach-cluster", args)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *fedResourceCmd) DetachCluster(args shell.IPerformOpt) *fedResourceCmd {
|
||||
c.K8sResourceCmd.Perform("detach-cluster", args)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *fedResourceCmd) SyncCluster(args shell.IPerformOpt) *fedResourceCmd {
|
||||
c.K8sResourceCmd.Perform("sync-cluster", args)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *fedResourceCmd) Sync(args shell.IPerformOpt) *fedResourceCmd {
|
||||
c.K8sResourceCmd.Perform("sync", args)
|
||||
return c
|
||||
}
|
||||
34
cmd/climc/shell/k8s/fed_namespace.go
Normal file
34
cmd/climc/shell/k8s/fed_namespace.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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 k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := newFedResourceCmd(k8s.FederatedNamespaces)
|
||||
|
||||
cmd.List(new(options.FedNamespaceListOptions)).
|
||||
Show(new(options.IdentOptions)).
|
||||
Create(new(options.FedNamespaceCreateOptions)).
|
||||
Delete(new(options.IdentOptions)).
|
||||
AttachCluster(new(options.FedResourceJointClusterAttachOptions)).
|
||||
DetachCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
SyncCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
Sync(new(options.IdentOptions)).
|
||||
ShowEvent()
|
||||
}
|
||||
27
cmd/climc/shell/k8s/fed_namespace_cluster.go
Normal file
27
cmd/climc/shell/k8s/fed_namespace_cluster.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// 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 k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := NewK8sJointCmd(&k8s.FederatedNamespaceClusters)
|
||||
|
||||
cmd.List(new(options.FedNamespaceClusterListOptions))
|
||||
cmd.Show(new(options.FedResourceJointClusterShowOptions))
|
||||
}
|
||||
37
cmd/climc/shell/k8s/fed_role.go
Normal file
37
cmd/climc/shell/k8s/fed_role.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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 k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := newFedResourceCmd(k8s.FederatedRoles)
|
||||
cmd.Create(new(options.FedRoleCreateOptions)).
|
||||
List(new(options.FedRoleListOptions)).
|
||||
Show(new(options.IdentOptions)).
|
||||
Delete(new(options.IdentOptions)).
|
||||
AttachCluster(new(options.FedResourceJointClusterAttachOptions)).
|
||||
DetachCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
SyncCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
Sync(new(options.IdentOptions)).
|
||||
ShowEvent()
|
||||
|
||||
cmd.ClassShow(new(options.FedApiResourecesOptions))
|
||||
cmd.ClassShow(new(options.FedClusterUsersOptions))
|
||||
cmd.ClassShow(new(options.FedClusterUserGroupsOptions))
|
||||
}
|
||||
27
cmd/climc/shell/k8s/fed_role_cluster.go
Normal file
27
cmd/climc/shell/k8s/fed_role_cluster.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// 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 k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := NewK8sJointCmd(&k8s.FederatedRoleClusters)
|
||||
|
||||
cmd.List(new(options.FedNamespaceJointClusterListOpt))
|
||||
cmd.Show(new(options.FedResourceJointClusterShowOptions))
|
||||
}
|
||||
34
cmd/climc/shell/k8s/fed_rolebinding.go
Normal file
34
cmd/climc/shell/k8s/fed_rolebinding.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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 k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := newFedResourceCmd(k8s.FederatedRoleBindings)
|
||||
|
||||
cmd.Create(new(options.FedRoleBindingCreateOpt)).
|
||||
List(new(options.FedNamespaceResourceListOptions)).
|
||||
Show(new(options.IdentOptions)).
|
||||
Delete(new(options.IdentOptions)).
|
||||
AttachCluster(new(options.FedResourceJointClusterAttachOptions)).
|
||||
DetachCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
SyncCluster(new(options.FedResourceJointClusterDetachOptions)).
|
||||
Sync(new(options.IdentOptions)).
|
||||
ShowEvent()
|
||||
}
|
||||
136
cmd/climc/shell/k8s/helper.go
Normal file
136
cmd/climc/shell/k8s/helper.go
Normal file
@@ -0,0 +1,136 @@
|
||||
// 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 k8s
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/cmd/climc/shell/events"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
)
|
||||
|
||||
type K8sResourceCmd struct {
|
||||
*shell.ResourceCmd
|
||||
manager modulebase.IBaseManager
|
||||
}
|
||||
|
||||
func NewK8sResourceCmd(manager modulebase.IBaseManager) *K8sResourceCmd {
|
||||
cmd := new(K8sResourceCmd)
|
||||
cmd.ResourceCmd = shell.NewResourceCmd(manager).SetPrefix("k8s")
|
||||
cmd.manager = manager
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (cmd *K8sResourceCmd) GetClusterResManager() k8s.IClusterResourceManager {
|
||||
return cmd.manager.(k8s.IClusterResourceManager)
|
||||
}
|
||||
|
||||
func (cmd *K8sResourceCmd) ShowEvent() *K8sResourceCmd {
|
||||
callback := func(s *mcclient.ClientSession, opt *events.TypeEventListOptions) error {
|
||||
args := &events.EventListOptions{BaseEventListOptions: opt.BaseEventListOptions, Id: opt.ID, Type: []string{cmd.manager.GetKeyword()}}
|
||||
return events.DoEventList(*k8s.Logs.ResourceManager, s, args)
|
||||
}
|
||||
cmd.RunWithDesc("event", fmt.Sprintf("Show operation event logs of k8s %s", cmd.manager.GetKeyword()), new(events.TypeEventListOptions), callback)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (cmd *K8sResourceCmd) EditRaw(opt shell.IGetOpt) *K8sResourceCmd {
|
||||
man := cmd.GetClusterResManager()
|
||||
callback := func(s *mcclient.ClientSession, args shell.IGetOpt) error {
|
||||
params, err := opt.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rawData, err := man.GetRaw(s, args.GetId(), params.(*jsonutils.JSONDict))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
yamlBytes := rawData.YAMLString()
|
||||
tempfile, err := ioutil.TempFile("", fmt.Sprintf("k8s-%s*.yaml", args.GetId()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.Remove(tempfile.Name())
|
||||
if _, err := tempfile.Write([]byte(yamlBytes)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tempfile.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd := exec.Command("vim", tempfile.Name())
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
content, err := ioutil.ReadFile(tempfile.Name())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jsonBytes, err := yaml.YAMLToJSON(content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
body, err := jsonutils.Parse(jsonBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
params, err = args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := man.UpdateRaw(s, args.GetId(), params.(*jsonutils.JSONDict), body.(*jsonutils.JSONDict)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
cmd.RunWithDesc("edit-raw", fmt.Sprintf("Edit and update k8s %s by raw data", man.GetKeyword()), opt, callback)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (cmd *K8sResourceCmd) ShowRaw(args shell.IGetOpt) *K8sResourceCmd {
|
||||
man := cmd.GetClusterResManager()
|
||||
callback := func(s *mcclient.ClientSession, args shell.IGetOpt) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := man.GetRaw(s, args.GetId(), params.(*jsonutils.JSONDict))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectYAML(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.RunWithDesc("show-raw", fmt.Sprintf("Show k8s %s raw data", man.GetKeyword()), args, callback)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func NewK8sJointCmd(manager modulebase.JointManager) *shell.JointCmd {
|
||||
cmd := shell.NewJointCmd(manager)
|
||||
cmd.SetPrefix("k8s")
|
||||
return cmd
|
||||
}
|
||||
@@ -15,25 +15,11 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
o "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func initIngress() {
|
||||
cmdN := initK8sNamespaceResource("ingress", k8s.Ingresses)
|
||||
createCmd := NewCommand(
|
||||
&o.IngressCreateOptions{},
|
||||
cmdN.CommandNameFactory("create"),
|
||||
"Create ingress rules to service",
|
||||
func(s *mcclient.ClientSession, args *o.IngressCreateOptions) error {
|
||||
spec := args.Params()
|
||||
ret, err := k8s.Ingresses.Create(s, spec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
cmdN.AddR(createCmd)
|
||||
cmd := initK8sNamespaceResource("ingress", k8s.Ingresses)
|
||||
cmd.Create(new(o.IngressCreateOptions))
|
||||
}
|
||||
|
||||
@@ -15,31 +15,12 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
o "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func initJob() {
|
||||
cmd := initK8sNamespaceResource("job", k8s.Jobs)
|
||||
cmdN := cmd.CommandNameFactory
|
||||
|
||||
createCmd := NewCommand(
|
||||
&o.JobCreateOptions{},
|
||||
cmdN("create"),
|
||||
"Create job resource",
|
||||
func(s *mcclient.ClientSession, args *o.JobCreateOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := k8s.Jobs.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
cmd.AddR(createCmd)
|
||||
cmd.Create(new(o.JobCreateOptions))
|
||||
}
|
||||
|
||||
@@ -16,16 +16,10 @@ package k8s
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
|
||||
"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/k8s"
|
||||
o "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
@@ -78,10 +72,6 @@ func resourceCmdN(prefix, suffix string) string {
|
||||
return fmt.Sprintf("k8s-%s-%s", prefix, suffix)
|
||||
}
|
||||
|
||||
func kubeResourceCmdN(prefix, suffix string) string {
|
||||
return fmt.Sprintf("kube-%s-%s", prefix, suffix)
|
||||
}
|
||||
|
||||
func clusterContext(clusterId string) modulebase.ManagerContext {
|
||||
return modulebase.ManagerContext{
|
||||
InstanceManager: k8s.KubeClusters,
|
||||
@@ -93,241 +83,24 @@ func printObjectYAML(obj jsonutils.JSONObject) {
|
||||
fmt.Println(obj.YAMLString())
|
||||
}
|
||||
|
||||
type Cmd struct {
|
||||
Options interface{}
|
||||
Command string
|
||||
Desc string
|
||||
Callback interface{}
|
||||
func initK8sClusterResource(kind string, manager modulebase.Manager) *K8sResourceCmd {
|
||||
cmd := NewK8sResourceCmd(manager)
|
||||
cmd.SetKeyword(kind)
|
||||
cmd.List(new(o.ResourceListOptions))
|
||||
cmd.Show(new(o.ResourceGetOptions))
|
||||
cmd.BatchDeleteWithParam(new(o.ResourceDeleteOptions))
|
||||
cmd.ShowEvent()
|
||||
return cmd
|
||||
}
|
||||
|
||||
func NewCommand(options interface{}, command string, desc string, callback interface{}) *Cmd {
|
||||
return &Cmd{
|
||||
Options: options,
|
||||
Command: command,
|
||||
Desc: desc,
|
||||
Callback: callback,
|
||||
}
|
||||
}
|
||||
|
||||
func (c Cmd) R() {
|
||||
R(c.Options, c.Command, c.Desc, c.Callback)
|
||||
}
|
||||
|
||||
type ShellCommands struct {
|
||||
Commands []*Cmd
|
||||
CommandNameFactory func(suffix string) string
|
||||
}
|
||||
|
||||
func NewShellCommands(cmdN func(suffix string) string) *ShellCommands {
|
||||
c := &ShellCommands{
|
||||
CommandNameFactory: cmdN,
|
||||
}
|
||||
c.Commands = make([]*Cmd, 0)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *ShellCommands) AddR(rs ...*Cmd) *ShellCommands {
|
||||
for _, r := range rs {
|
||||
r.R()
|
||||
c.Commands = append(c.Commands, r)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func initK8sClusterResource(kind string, manager modulebase.Manager) *ShellCommands {
|
||||
cmdN := NewCmdNameFactory(kind)
|
||||
return NewShellCommands(cmdN.Do).AddR(
|
||||
NewK8sResourceListCmd(cmdN, manager),
|
||||
NewK8sResourceGetCmd(cmdN, manager),
|
||||
NewK8sResourceDeleteCmd(cmdN, manager),
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sResourceListCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.ResourceListOptions{},
|
||||
cmdN.Do("list"),
|
||||
fmt.Sprintf("List k8s %s", cmdN.Kind),
|
||||
func(s *mcclient.ClientSession, args *o.ResourceListOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := manager.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
PrintListResultTable(ret, manager.(k8s.ListPrinter), s)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
type CmdNameFactory struct {
|
||||
Kind string
|
||||
Do func(string) string
|
||||
}
|
||||
|
||||
func NewCmdNameFactory(kind string) CmdNameFactory {
|
||||
return CmdNameFactory{
|
||||
Kind: kind,
|
||||
Do: func(suffix string) string {
|
||||
return resourceCmdN(kind, suffix)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewK8sNsResourceListCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.NamespaceResourceListOptions{},
|
||||
cmdN.Do("list"),
|
||||
fmt.Sprintf("List k8s %s", cmdN.Kind),
|
||||
func(s *mcclient.ClientSession, args *o.NamespaceResourceListOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := manager.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
PrintListResultTable(ret, manager.(k8s.ListPrinter), s)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sResourceGetCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.ResourceGetOptions{},
|
||||
cmdN.Do("show"),
|
||||
fmt.Sprintf("Show k8s %s", cmdN.Kind),
|
||||
func(s *mcclient.ClientSession, args *o.ResourceGetOptions) error {
|
||||
ret, err := manager.Get(s, args.NAME, args.Params())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectYAML(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sNsResourceGetCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.NamespaceResourceGetOptions{},
|
||||
cmdN.Do("show"),
|
||||
fmt.Sprintf("Show k8s %s", cmdN.Kind),
|
||||
func(s *mcclient.ClientSession, args *o.NamespaceResourceGetOptions) error {
|
||||
ret, err := manager.Get(s, args.NAME, args.Params())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectYAML(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sNsResourceGetRawCmd(cmdN CmdNameFactory, manager k8s.IClusterResourceManager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.NamespaceResourceGetOptions{},
|
||||
cmdN.Do("show-raw"),
|
||||
fmt.Sprintf("Show k8s %s raw data", cmdN.Kind),
|
||||
func(s *mcclient.ClientSession, args *o.NamespaceResourceGetOptions) error {
|
||||
ret, err := manager.GetRaw(s, args.NAME, args.Params())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectYAML(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sResourceEditRawCmd(cmdN CmdNameFactory, manager k8s.IClusterResourceManager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.NamespaceResourceGetOptions{},
|
||||
cmdN.Do("edit-raw"),
|
||||
fmt.Sprintf("Edit and update k8s %s raw data", cmdN.Kind),
|
||||
func(s *mcclient.ClientSession, args *o.NamespaceResourceGetOptions) error {
|
||||
rawData, err := manager.GetRaw(s, args.NAME, args.Params())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
yamlBytes := rawData.YAMLString()
|
||||
tempfile, err := ioutil.TempFile("", fmt.Sprintf("k8s-%s-%s*.yaml", cmdN.Kind, args.NAME))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.Remove(tempfile.Name())
|
||||
if _, err := tempfile.Write([]byte(yamlBytes)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tempfile.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd := exec.Command("vim", tempfile.Name())
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
content, err := ioutil.ReadFile(tempfile.Name())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jsonBytes, err := yaml.YAMLToJSON(content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
body, err := jsonutils.Parse(jsonBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := manager.UpdateRaw(s, args.NAME, args.Params(), body.(*jsonutils.JSONDict)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sResourceDeleteCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.ResourceDeleteOptions{},
|
||||
cmdN.Do("delete"),
|
||||
fmt.Sprintf("Delete k8s %s", cmdN.Kind),
|
||||
func(s *mcclient.ClientSession, args *o.ResourceDeleteOptions) error {
|
||||
ret := manager.BatchDelete(s, args.NAME, args.Params())
|
||||
printBatchResults(ret, manager.GetColumns(s))
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sNsResourceDeleteCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
deleteCmd := NewCommand(
|
||||
&o.NamespaceResourceDeleteOptions{},
|
||||
cmdN.Do("delete"),
|
||||
fmt.Sprintf("Delete k8s %s", cmdN.Kind),
|
||||
func(s *mcclient.ClientSession, args *o.NamespaceResourceDeleteOptions) error {
|
||||
ret := manager.BatchDelete(s, args.NAME, args.Params())
|
||||
printBatchResults(ret, manager.GetColumns(s))
|
||||
return nil
|
||||
},
|
||||
)
|
||||
return deleteCmd
|
||||
}
|
||||
|
||||
func initK8sNamespaceResource(kind string, manager k8s.IClusterResourceManager) *ShellCommands {
|
||||
cmdN := NewCmdNameFactory(kind)
|
||||
return NewShellCommands(cmdN.Do).AddR(
|
||||
NewK8sNsResourceListCmd(cmdN, manager),
|
||||
NewK8sNsResourceGetCmd(cmdN, manager),
|
||||
NewK8sNsResourceDeleteCmd(cmdN, manager),
|
||||
NewK8sNsResourceGetRawCmd(cmdN, manager),
|
||||
NewK8sResourceEditRawCmd(cmdN, manager),
|
||||
)
|
||||
func initK8sNamespaceResource(kind string, manager k8s.IClusterResourceManager) *K8sResourceCmd {
|
||||
cmd := NewK8sResourceCmd(manager)
|
||||
cmd.SetKeyword(kind)
|
||||
cmd.List(new(o.NamespaceResourceListOptions))
|
||||
cmd.Show(new(o.NamespaceResourceGetOptions))
|
||||
cmd.BatchDeleteWithParam(new(o.NamespaceResourceDeleteOptions))
|
||||
cmd.ShowRaw(new(o.NamespaceResourceGetOptions))
|
||||
cmd.EditRaw(new(o.NamespaceResourceGetOptions))
|
||||
cmd.ShowEvent()
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -15,73 +15,18 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
o "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func initKubeMachine() {
|
||||
cmdN := func(action string) string {
|
||||
return fmt.Sprintf("kubemachine-%s", action)
|
||||
}
|
||||
R(&o.MachineListOptions{}, cmdN("list"), "List k8s node machines", func(s *mcclient.ClientSession, args *o.MachineListOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := k8s.KubeMachines.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, k8s.KubeMachines.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.MachineCreateOptions{}, cmdN("create"), "Create k8s machine", func(s *mcclient.ClientSession, args *o.MachineCreateOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
node, err := k8s.KubeMachines.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(node)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentOptions{}, cmdN("show"), "Show details of a machine", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
|
||||
result, err := k8s.KubeMachines.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentsOptions{}, cmdN("delete"), "Delete machine", func(s *mcclient.ClientSession, args *o.IdentsOptions) error {
|
||||
ret := k8s.KubeMachines.BatchDelete(s, args.ID, nil)
|
||||
printBatchResults(ret, k8s.KubeMachines.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentOptions{}, cmdN("recreate"), "Re-Create machine when create fail", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
|
||||
ret, err := k8s.KubeMachines.PerformAction(s, args.ID, "recreate", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&o.IdentOptions{}, cmdN("terminate"), "Terminate a machine", func(s *mcclient.ClientSession, args *o.IdentOptions) error {
|
||||
ret, err := k8s.KubeMachines.PerformAction(s, args.ID, "terminate", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
cmd := NewK8sResourceCmd(k8s.KubeMachines)
|
||||
cmd.SetKeyword("machine")
|
||||
cmd.ShowEvent()
|
||||
cmd.List(new(o.MachineListOptions))
|
||||
cmd.Create(new(o.MachineCreateOptions))
|
||||
cmd.Show(new(o.IdentOptions))
|
||||
cmd.BatchDelete(new(o.IdentsOptions))
|
||||
cmd.Perform("recreate", new(o.IdentOptions))
|
||||
cmd.Perform("terminate", new(o.IdentOptions))
|
||||
}
|
||||
|
||||
@@ -16,8 +16,12 @@ package k8s
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
)
|
||||
|
||||
func initNamespace() {
|
||||
initK8sClusterResource("namespace", k8s.Namespaces)
|
||||
|
||||
cmd := NewK8sResourceCmd(k8s.Namespaces)
|
||||
cmd.Create(new(options.NamespaceCreateOptions))
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user