mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-21 00:24:07 +08:00
Compare commits
260 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fc93016dd | ||
|
|
3b29ecb087 | ||
|
|
4a04405b5d | ||
|
|
ff27373bb2 | ||
|
|
9bad7f3485 | ||
|
|
0eb4468c79 | ||
|
|
d8b614bbdf | ||
|
|
776438f682 | ||
|
|
321e54def0 | ||
|
|
0f0bb35170 | ||
|
|
7b0ceddd6b | ||
|
|
e2fafe2b46 | ||
|
|
f396592d2e | ||
|
|
18fca8d90b | ||
|
|
7c85b20733 | ||
|
|
48c0c536fc | ||
|
|
188662cd51 | ||
|
|
dd01e8cf49 | ||
|
|
ca7f5495fe | ||
|
|
34b7d1e9c3 | ||
|
|
13a3e1c778 | ||
|
|
603b3f8b8e | ||
|
|
2c1e0a4fe2 | ||
|
|
f9a9f92003 | ||
|
|
8d1c0ba9c9 | ||
|
|
845ba285fc | ||
|
|
72f1e58833 | ||
|
|
1cc1ff7213 | ||
|
|
6c15c80abb | ||
|
|
7869e3d134 | ||
|
|
2e0efc6c4a | ||
|
|
1d440b57ce | ||
|
|
e3c564bd56 | ||
|
|
45e04c4d50 | ||
|
|
ee0f6de3b0 | ||
|
|
608be69260 | ||
|
|
88fa459aac | ||
|
|
b4bb5d902f | ||
|
|
7f467ab3a7 | ||
|
|
5c1714d11d | ||
|
|
5f36cbb31c | ||
|
|
850544ee4d | ||
|
|
7ff8935abc | ||
|
|
874cf21b00 | ||
|
|
231fefed1f | ||
|
|
5dd591f1bb | ||
|
|
ab32057ab1 | ||
|
|
84fec885e8 | ||
|
|
8057b95ac2 | ||
|
|
9adac58590 | ||
|
|
f409fca66b | ||
|
|
edd7136d3e | ||
|
|
b1c80010cc | ||
|
|
5ff255d622 | ||
|
|
fb531b4d68 | ||
|
|
03cd5dc63a | ||
|
|
fa48381bd7 | ||
|
|
38a6decc25 | ||
|
|
627495d200 | ||
|
|
37b823a43c | ||
|
|
112eb0d7ae | ||
|
|
bee314a0e6 | ||
|
|
60ef016f42 | ||
|
|
da235de896 | ||
|
|
68a425ebd5 | ||
|
|
15f6b94bec | ||
|
|
d8dd372cb0 | ||
|
|
e14a596d9f | ||
|
|
a0ab40dbb8 | ||
|
|
75e49ac8c6 | ||
|
|
590ec32860 | ||
|
|
57fd313b43 | ||
|
|
86e4df54d9 | ||
|
|
a9f60a7b1a | ||
|
|
087de62171 | ||
|
|
8577cb096e | ||
|
|
2110057bac | ||
|
|
3c09ce17d0 | ||
|
|
dc870afaed | ||
|
|
fcb8bba00c | ||
|
|
7996a02a80 | ||
|
|
3349dc46c5 | ||
|
|
a85fd307d3 | ||
|
|
37f1906f72 | ||
|
|
d5096ad4ee | ||
|
|
24da237790 | ||
|
|
d34b00ddc4 | ||
|
|
2f47d93215 | ||
|
|
1bbf79528b | ||
|
|
0c0c4fc94d | ||
|
|
01de80ed09 | ||
|
|
3861bb6bc1 | ||
|
|
681fee1317 | ||
|
|
2496a12833 | ||
|
|
c76062406d | ||
|
|
df94352e00 | ||
|
|
5b9c7ba9f2 | ||
|
|
e8dc05084a | ||
|
|
0774a2ded0 | ||
|
|
50421b06b9 | ||
|
|
7e7825a681 | ||
|
|
45b8a7afd9 | ||
|
|
4ec1fc58d9 | ||
|
|
69564365b9 | ||
|
|
54caca2d04 | ||
|
|
ce3241d046 | ||
|
|
40773180fa | ||
|
|
32411bf2ec | ||
|
|
c99265e743 | ||
|
|
2d4cff4ef1 | ||
|
|
bb90b5e8a1 | ||
|
|
b1c4bc276f | ||
|
|
1923e36740 | ||
|
|
7bec5e6f7e | ||
|
|
b40be2608b | ||
|
|
46d2f6efb7 | ||
|
|
d55f1db7ff | ||
|
|
0bcc19d7c1 | ||
|
|
b395dc8cee | ||
|
|
c908e0c19a | ||
|
|
ce5a95607f | ||
|
|
d4ba5ca52e | ||
|
|
92129824c0 | ||
|
|
7326b1fb0d | ||
|
|
1b5756fe1c | ||
|
|
08f8ce1f7c | ||
|
|
2c5234b97e | ||
|
|
37049bd5f3 | ||
|
|
177ba6cf2c | ||
|
|
bf2bb9878f | ||
|
|
530b2a1422 | ||
|
|
1eba8b8a7e | ||
|
|
4829e0d285 | ||
|
|
b29d6d4f4e | ||
|
|
d41c3bfea7 | ||
|
|
907058464a | ||
|
|
c727334bc4 | ||
|
|
b7e2c462cb | ||
|
|
1efc0fe07b | ||
|
|
9d1b407c40 | ||
|
|
67c2435f4f | ||
|
|
c11c79ef71 | ||
|
|
c245013e59 | ||
|
|
83b4916646 | ||
|
|
f6d1ea7b25 | ||
|
|
c988fd1b1f | ||
|
|
f6df6d34e0 | ||
|
|
44183902f7 | ||
|
|
64fda24e76 | ||
|
|
0701512da9 | ||
|
|
71499e7e1b | ||
|
|
6f6cf7cd64 | ||
|
|
8f175ec326 | ||
|
|
c0c26c7c40 | ||
|
|
42cd5b1435 | ||
|
|
4fafb8ae75 | ||
|
|
8349dcbba3 | ||
|
|
85a792d2b1 | ||
|
|
71fee70283 | ||
|
|
456c5fb50e | ||
|
|
b706356ba9 | ||
|
|
ed2bba3dd5 | ||
|
|
b6e701a6b2 | ||
|
|
c21636b521 | ||
|
|
2e0f424c73 | ||
|
|
a2f30806cf | ||
|
|
0c0b4b43aa | ||
|
|
209bee4181 | ||
|
|
ba265a7b83 | ||
|
|
1a8f8dcb93 | ||
|
|
2a01c86428 | ||
|
|
dc75d93414 | ||
|
|
fe44564bf7 | ||
|
|
8cd23304ae | ||
|
|
4b8e13f171 | ||
|
|
b6739ba7e8 | ||
|
|
3db7b0c962 | ||
|
|
0d6480723d | ||
|
|
9a91bf244c | ||
|
|
b1a641ca4d | ||
|
|
c65e1e0855 | ||
|
|
d8fc57b217 | ||
|
|
f9a47d94c7 | ||
|
|
ac2c3697bf | ||
|
|
b1048baef3 | ||
|
|
bfc1f0125f | ||
|
|
4b6d0107b0 | ||
|
|
1948c12012 | ||
|
|
6345086c5b | ||
|
|
08d412669d | ||
|
|
c85a8d354e | ||
|
|
03be58f39a | ||
|
|
60cb619043 | ||
|
|
91c39cf8cd | ||
|
|
f73ac4844f | ||
|
|
e681f66aad | ||
|
|
d7bf41e173 | ||
|
|
ea3247eaba | ||
|
|
d91dbf5f47 | ||
|
|
52129c544b | ||
|
|
a3b3e9c627 | ||
|
|
04c73b189d | ||
|
|
f75dbefbfd | ||
|
|
a2e4490613 | ||
|
|
2c32832946 | ||
|
|
18239e30cc | ||
|
|
77d6e24ae7 | ||
|
|
d5f6473d57 | ||
|
|
f7d927cbdd | ||
|
|
56a3d9c05d | ||
|
|
a4b76036c5 | ||
|
|
9e20cce793 | ||
|
|
f7b3b0c1a0 | ||
|
|
6404e3c2a0 | ||
|
|
9a1b040933 | ||
|
|
b5468ca840 | ||
|
|
77bbb2bda8 | ||
|
|
562498da68 | ||
|
|
b91c19bcb5 | ||
|
|
e48c4d0bb2 | ||
|
|
8c3872000a | ||
|
|
7fde85b83f | ||
|
|
262096d99d | ||
|
|
60ba83b40f | ||
|
|
5834ec297e | ||
|
|
8701c6172e | ||
|
|
d912e29772 | ||
|
|
bf0adeb0e2 | ||
|
|
8857a6281e | ||
|
|
5537648dc7 | ||
|
|
158750373b | ||
|
|
8a719ffe1f | ||
|
|
c1278bf088 | ||
|
|
86d6a224cd | ||
|
|
6b6a15e6b8 | ||
|
|
4a2b10e842 | ||
|
|
38557f8bcd | ||
|
|
8739393e52 | ||
|
|
fdad1303bc | ||
|
|
bd2d11f964 | ||
|
|
01c962f1c6 | ||
|
|
d5ec862e26 | ||
|
|
1e04ddfe5e | ||
|
|
67a6f9687d | ||
|
|
9bfb6c0c8e | ||
|
|
b4fff49236 | ||
|
|
8536166426 | ||
|
|
4bd9051ae4 | ||
|
|
74c272cfae | ||
|
|
38aed0ca4a | ||
|
|
06eea75674 | ||
|
|
ad73aa590a | ||
|
|
4322981be4 | ||
|
|
655d3632fa | ||
|
|
cd34e0db95 | ||
|
|
aae5d0dc33 | ||
|
|
51b2f4d3af | ||
|
|
f7987dbf61 | ||
|
|
f1282345f1 | ||
|
|
9046117e00 |
@@ -13,7 +13,7 @@ jobs:
|
||||
- checkout
|
||||
- run:
|
||||
command: |
|
||||
make -j3 check
|
||||
make check
|
||||
build:
|
||||
requires:
|
||||
- check
|
||||
@@ -38,7 +38,7 @@ jobs:
|
||||
command: |
|
||||
targets="$(circleci tests glob "cmd/*" | grep -v cmd/host-image | circleci tests split)"
|
||||
echo $targets | tr ' ' '\n'
|
||||
make -j3 $targets
|
||||
make $targets
|
||||
ls -lh _output/bin/
|
||||
- save_cache:
|
||||
key: onecloud-build-cache-{{ checksum "go.mod" }}-{{ checksum "Makefile" }}
|
||||
@@ -55,7 +55,6 @@ jobs:
|
||||
environment:
|
||||
GO111MODULE: "on"
|
||||
working_directory: /root/go/onecloud
|
||||
parallelism: 4
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
||||
10
.github/pull_request_template.md
vendored
10
.github/pull_request_template.md
vendored
@@ -1,15 +1,9 @@
|
||||
**这个 PR 实现什么功能/修复什么问题**:
|
||||
|
||||
<!--
|
||||
- [ ] 功能、bugfix描述
|
||||
- [ ] 冒烟测试
|
||||
- [ ] 单元测试编写
|
||||
-->
|
||||
|
||||
**是否需要 backport 到之前的 release 分支**:
|
||||
|
||||
<!--
|
||||
如果不需要,填写 "NONE".
|
||||
如果需要,就以下面 item 的格式写 release 分支名,并提交对应的 cherry-pick PR:
|
||||
- release/3.1
|
||||
- release/2.8.0
|
||||
- release/2.6.0
|
||||
-->
|
||||
|
||||
84
.github/workflows/docker.yml
vendored
84
.github/workflows/docker.yml
vendored
@@ -36,40 +36,10 @@ jobs:
|
||||
make cmd/ansibleserver cmd/cloudnet cmd/notify
|
||||
make cmd/host-deployer && ./scripts/bundle_libraries.sh _output/bin/bundles/host-deployer _output/bin/host-deployer
|
||||
make cmd/baremetal-agent && ./scripts/bundle_libraries.sh _output/bin/bundles/baremetal-agent _output/bin/baremetal-agent
|
||||
make cmd/cloudevent cmd/devtool cmd/cloudid
|
||||
make cmd/cloudevent cmd/devtool
|
||||
make cmd/*cli
|
||||
make cmd/esxi-agent
|
||||
make docker-alpine-build F='-j4 cmd/host cmd/vpcagent cmd/region-dns'
|
||||
|
||||
- name: Image region
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
name: registry.cn-beijing.aliyuncs.com/yunionio/region
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.region
|
||||
|
||||
- name: Image host
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
name: registry.cn-beijing.aliyuncs.com/yunionio/host
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.host
|
||||
|
||||
- name: Image host-deployer
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
name: registry.cn-beijing.aliyuncs.com/yunionio/host-deployer
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.host-deployer
|
||||
make docker-alpine-build F='-j4 cmd/host cmd/vpcagent'
|
||||
|
||||
- name: Image baremetal-agent
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
@@ -131,6 +101,16 @@ jobs:
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.logger
|
||||
|
||||
- name: Image region
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
name: registry.cn-beijing.aliyuncs.com/yunionio/region
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.region
|
||||
|
||||
- name: Image scheduler
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
@@ -201,6 +181,26 @@ jobs:
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.notify
|
||||
|
||||
- name: Image host
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
name: registry.cn-beijing.aliyuncs.com/yunionio/host
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.host
|
||||
|
||||
- name: Image host-deployer
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
name: registry.cn-beijing.aliyuncs.com/yunionio/host-deployer
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.host-deployer
|
||||
|
||||
- name: Image cloudevent
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
@@ -211,16 +211,6 @@ jobs:
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.cloudevent
|
||||
|
||||
- name: Image cloudid
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
name: registry.cn-beijing.aliyuncs.com/yunionio/cloudid
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.cloudid
|
||||
|
||||
- name: Image devtool
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
@@ -230,13 +220,3 @@ jobs:
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.devtool
|
||||
|
||||
- name: Image region DNS
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
name: registry.cn-beijing.aliyuncs.com/yunionio/region-dns
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
snapshot: true
|
||||
dockerfile: build/docker/Dockerfile.region-dns
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -30,10 +30,7 @@ _output
|
||||
/relay
|
||||
/structargtest
|
||||
.idea
|
||||
.vscode
|
||||
GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
pkg/generated
|
||||
|
||||
*.orig
|
||||
|
||||
24
Makefile
24
Makefile
@@ -10,7 +10,7 @@ BUILD_SCRIPT := $(ROOT_DIR)/build/build.sh
|
||||
ifeq ($(ONECLOUD_CI_BUILD),)
|
||||
GIT_COMMIT := $(shell git rev-parse --short HEAD)
|
||||
GIT_BRANCH := $(shell git name-rev --name-only HEAD)
|
||||
GIT_VERSION := $(shell git describe --always --tags --abbrev=14 $(GIT_COMMIT)^{commit})
|
||||
GIT_VERSION := $(shell git describe --tags --abbrev=14 $(GIT_COMMIT)^{commit})
|
||||
GIT_TREE_STATE := $(shell s=`git status --porcelain 2>/dev/null`; if [ -z "$$s" ]; then echo "clean"; else echo "dirty"; fi)
|
||||
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
else
|
||||
@@ -51,7 +51,6 @@ ifdef LIBQEMUIO_PATH
|
||||
X_CGO_LDFLAGS := ${CGO_LDFLAGS_ENV} -laio -lqemuio -lpthread -L ${LIBQEMUIO_PATH}/src
|
||||
endif
|
||||
|
||||
export GOOS ?= linux
|
||||
export GO111MODULE:=on
|
||||
export CGO_CFLAGS = ${X_CGO_CFLAGS}
|
||||
export CGO_LDFLAGS = ${X_CGO_LDFLAGS}
|
||||
@@ -76,7 +75,7 @@ install: prepare_dir
|
||||
|
||||
|
||||
gencopyright:
|
||||
@bash scripts/gencopyright.sh pkg cmd
|
||||
@sh scripts/gencopyright.sh pkg cmd
|
||||
|
||||
test:
|
||||
@go test $(GO_BUILD_FLAGS) $(shell go list ./... | egrep -v 'host-image|hostimage')
|
||||
@@ -163,15 +162,9 @@ goimports-check:
|
||||
fi
|
||||
.PHONY: goimports-check
|
||||
|
||||
vet-check:
|
||||
./scripts/vet.sh gen
|
||||
./scripts/vet.sh chk
|
||||
.PHONY: vet-check
|
||||
|
||||
check: fmt-check
|
||||
check: gendocgo-check
|
||||
check: goimports-check
|
||||
check: vet-check
|
||||
.PHONY: check
|
||||
|
||||
|
||||
@@ -194,7 +187,7 @@ dep:
|
||||
@$(MAKE) mod
|
||||
|
||||
mod:
|
||||
go get -d $(patsubst %,%@master,$(shell GO111MODULE=on go mod edit -print | sed -n -e 's|.*\(yunion.io/x/[a-z].*\) v.*|\1|p'))
|
||||
go get $(patsubst %,%@master,$(shell GO111MODULE=on go mod edit -print | sed -n -e 's|.*\(yunion.io/x/[a-z].*\) v.*|\1|p'))
|
||||
go mod tidy
|
||||
go mod vendor -v
|
||||
|
||||
@@ -218,7 +211,6 @@ docker-centos-build:
|
||||
--name onecloud-ci-build \
|
||||
--rm \
|
||||
--volume $(CURDIR):/root/onecloud \
|
||||
--volume $(CURDIR)/_output/_cache:/root/.cache \
|
||||
registry.cn-beijing.aliyuncs.com/yunionio/centos-build:$(DOCKER_BUILD_IMAGE_VERSION) \
|
||||
/bin/bash -c "$$dockerCentOSBuildCmd"
|
||||
chown -R $$(id -u):$$(id -g) _output
|
||||
@@ -249,7 +241,6 @@ docker-alpine-build:
|
||||
--name onecloud-docker-alpine-build \
|
||||
-v $(CURDIR):/root/go/src/yunion.io/x/onecloud \
|
||||
-v $(CURDIR)/_output/alpine-build:/root/go/src/yunion.io/x/onecloud/_output \
|
||||
-v $(CURDIR)/_output/alpine-build/_cache:/root/.cache \
|
||||
registry.cn-beijing.aliyuncs.com/yunionio/alpine-build:1.0-1 \
|
||||
/bin/sh -c "$$dockerAlpineBuildCmd"
|
||||
ls -lh _output/alpine-build/bin
|
||||
@@ -297,15 +288,10 @@ gen-swagger: gen-swagger-check
|
||||
$(ROOT_DIR)/scripts/codegen.py swagger-code
|
||||
$(ROOT_DIR)/scripts/codegen.py swagger-yaml
|
||||
|
||||
swagger-serve-only:
|
||||
swagger-serve: gen-swagger
|
||||
$(ROOT_DIR)/scripts/codegen.py swagger-serve
|
||||
|
||||
swagger-serve: gen-model-api gen-swagger swagger-serve-only
|
||||
|
||||
swagger-site: gen-model-api gen-swagger
|
||||
$(ROOT_DIR)/scripts/codegen.py swagger-site
|
||||
|
||||
.PHONY: gen-model-api-check gen-model-api gen-swagger-check gen-swagger swagger-serve swagger-site
|
||||
.PHONY: gen-model-api-check gen-model-api gen-swagger-check gen-swagger swagger-serve
|
||||
|
||||
REGISTRY ?= "registry.cn-beijing.aliyuncs.com/yunionio"
|
||||
VERSION ?= $(shell git describe --exact-match 2> /dev/null || \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Yunion OneCloud
|
||||
|
||||
[](https://circleci.com/gh/yunionio/onecloud)
|
||||
[](https://travis-ci.com/yunionio/onecloud/branches)
|
||||
[](https://travis-ci.org/yunionio/onecloud)
|
||||
[](https://goreportcard.com/report/github.com/yunionio/onecloud)
|
||||
|
||||
### [README in Chinese](./README-CN.md)
|
||||
@@ -40,7 +40,7 @@ Please refers to [install & deployment](https://docs.yunion.io/docs/setup/) (cur
|
||||
|
||||
- [Yunion OneCloud Documents](https://docs.yunion.io/)
|
||||
|
||||
- [Swagger API](https://docs.yunion.cn/apiv2/)
|
||||
- [Swagger API](https://docs.yunion.cn/api/)
|
||||
|
||||
## Architecture
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
DESCRIPTION="Yunion CloudId"
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/ansibleserver-base:1.0.0
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/ansibleserver-base:latest
|
||||
|
||||
ADD ./_output/alpine-build/bin/ansibleserver /opt/yunion/bin/ansibleserver
|
||||
ADD ./_output/bin/ansibleserver /opt/yunion/bin/ansibleserver
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
FROM alpine:3.11.6
|
||||
FROM frolvlad/alpine-glibc:glibc-2.28
|
||||
|
||||
MAINTAINER "Yousong Zhou <zhouyousong@yunionyun.com>"
|
||||
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
|
||||
|
||||
# openssh-client, for ansible ssh connection
|
||||
# git, ca-certificates, for fetching ansible roles
|
||||
RUN set -x \
|
||||
&& apk update \
|
||||
&& apk add openssh-client \
|
||||
&& apk add ansible \
|
||||
&& apk add tzdata git ca-certificates \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
ENV TZ Asia/Shanghai
|
||||
|
||||
RUN mkdir -p /opt/yunion/bin
|
||||
|
||||
RUN apk update && \
|
||||
apk add --no-cache tzdata ansible ca-certificates && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
ADD ./_output/bin/apigateway /opt/yunion/bin/apigateway
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
ADD ./_output/bin/cloudevent /opt/yunion/bin/cloudevent
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
|
||||
ADD ./_output/bin/cloudid /opt/yunion/bin/cloudid
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
ADD ./_output/bin/cloudnet /opt/yunion/bin/cloudnet
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
ADD ./_output/bin/devtool /opt/yunion/bin/devtool
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
COPY ./build/esxi-agent/root/opt/ /opt/
|
||||
ADD ./_output/bin/esxi-agent /opt/yunion/bin/esxi-agent
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-base:v0.2.0
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-base:v0.1.0
|
||||
|
||||
MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:v0.0.3
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:v0.0.2
|
||||
|
||||
MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com"
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
ADD ./_output/bin/keystone /opt/yunion/bin/keystone
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
ADD ./_output/bin/logger /opt/yunion/bin/logger
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
ADD ./_output/bin/monitor /opt/yunion/bin/monitor
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
COPY ./build/notify/root/opt/ /opt/
|
||||
ADD ./_output/bin/notify /opt/yunion/bin/notify
|
||||
|
||||
@@ -7,7 +7,7 @@ ENV TZ Asia/Shanghai
|
||||
RUN mkdir -p /opt/yunion/bin
|
||||
|
||||
RUN apk update && \
|
||||
apk add --no-cache tzdata curl busybox-extras tcpdump strace ca-certificates && \
|
||||
apk add --no-cache tzdata ca-certificates && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
COPY ./build/region/root/opt/ /opt/
|
||||
ADD ./_output/bin/region /opt/yunion/bin/region
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
FROM alpine:3.11.3
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
RUN mkdir -p /opt/yunion/bin
|
||||
ADD ./_output/alpine-build/bin/region-dns /opt/yunion/bin/region-dns
|
||||
ADD ./_output/bin/region-dns /opt/yunion/bin/region-dns
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
ADD ./_output/bin/s3gateway /opt/yunion/bin/s3gateway
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
ADD ./_output/bin/scheduler /opt/yunion/bin/scheduler
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/openvswitch:2.10.4-0
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/openvswitch:2.9.6-1
|
||||
|
||||
MAINTAINER "Yousong Zhou <zhouyousong@yunion.cn>"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:v0.1
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/onecloud-base:latest
|
||||
|
||||
ADD ./_output/bin/yunionconf /opt/yunion/bin/yunionconf
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
{{.os_type}} 镜像 {{.name}} 上传完成
|
||||
@@ -1,66 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<table style="width: 650px; margin-bottom: 20px;" border="0" cellpadding="0" cellspacing="0" align="center">
|
||||
<tr style="height: 50px; background: #333; overflow: hidden;">
|
||||
<td>
|
||||
<table style="margin-left: 20px;">
|
||||
<tr>
|
||||
<td>
|
||||
<img src="data:{{.login_logo_format}};base64,{{.login_logo}}" alt="" style="color: #fff; height: 32px; vertical-align: middle;">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table style="float: right;">
|
||||
<tr>
|
||||
<td style="padding-left: 20px; padding-right: 20px;">
|
||||
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">产品</a>
|
||||
</td>
|
||||
<td style="padding-left: 20px; padding-right: 20px;">
|
||||
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">解决方案</a>
|
||||
</td>
|
||||
<td style="padding-left: 20px; padding-right: 20px;">
|
||||
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">服务</a>
|
||||
</td>
|
||||
<td style="padding-left: 20px; padding-right: 20px;">
|
||||
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">帮助与文档</a>
|
||||
</td>
|
||||
<td style="padding-left: 20px; padding-right: 20px;">
|
||||
<a href="" style="text-decoration: none; color: #20A0FF; font-size: 12px; display: none;">关于我们</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 100%;" colspan="2">
|
||||
<table style="padding: 20px 10px; width: 100%;">
|
||||
<tr>
|
||||
<td style="padding-bottom: 20px;">
|
||||
尊敬的{{.name}},您好:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-bottom: 10px;">请点击下面的链接,完成用户邮箱的激活:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-bottom: 30px;"><a href="{{.link}}">{{.link}}</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="width: 96%;">
|
||||
<td colspan="2" style="border-top: 1px dashed #ccc; color: #333; font-size: 12px; padding-bottom: 10px; font-weight: 100;">*为了确保您的帐号安全,该链接仅48小时内访问有效,请勿直接回复此邮件。</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="background: #333; text-align: right; padding-right: 20px; font-size: 12px; color: #fff; height: 50px;">版权所有 © {{.copyright}} 保留一切权利</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +0,0 @@
|
||||
镜像 {{.name}} 上传完成
|
||||
@@ -1 +0,0 @@
|
||||
Yunion Verify
|
||||
@@ -84,11 +84,7 @@ func newClient(options *BaseOptions) (*aliyun.SRegion, error) {
|
||||
return nil, fmt.Errorf("Missing secret")
|
||||
}
|
||||
|
||||
cli, err := aliyun.NewAliyunClient(
|
||||
aliyun.NewAliyunClientConfig(
|
||||
options.AccessKey, options.Secret,
|
||||
).Debug(options.Debug),
|
||||
)
|
||||
cli, err := aliyun.NewAliyunClient("", "", options.AccessKey, options.Secret, options.Debug)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -85,13 +85,7 @@ func newClient(options *BaseOptions) (*aws.SRegion, error) {
|
||||
return nil, fmt.Errorf("Missing secret")
|
||||
}
|
||||
|
||||
cli, err := aws.NewAwsClient(
|
||||
aws.NewAwsClientConfig(
|
||||
options.AccessUrl,
|
||||
options.AccessKey,
|
||||
options.Secret,
|
||||
).Debug(options.Debug),
|
||||
)
|
||||
cli, err := aws.NewAwsClient("", "", options.AccessUrl, options.AccessKey, options.Secret, options.Debug)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -100,17 +100,11 @@ func newClient(options *BaseOptions) (*azure.SRegion, error) {
|
||||
return nil, fmt.Errorf("Missing Cloud Environment")
|
||||
}
|
||||
|
||||
cli, err := azure.NewAzureClient(
|
||||
azure.NewAzureClientConfig(
|
||||
options.CloudEnv,
|
||||
options.DirectoryID,
|
||||
options.ApplicationID,
|
||||
options.ApplicationKey,
|
||||
).
|
||||
SubscriptionId(options.SubscriptionID).
|
||||
Debug(options.Debug),
|
||||
)
|
||||
|
||||
cli, err := azure.NewAzureClient("", "", options.CloudEnv,
|
||||
options.DirectoryID,
|
||||
options.ApplicationID, options.ApplicationKey,
|
||||
options.SubscriptionID,
|
||||
options.Debug)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package entry
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -32,6 +32,10 @@ import (
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/promputils"
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudnet"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/etcd"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/k8s"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/monitor"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
@@ -45,7 +49,7 @@ type BaseOptions struct {
|
||||
CertFile string `default:"$YUNION_CERT_FILE" help:"certificate file"`
|
||||
KeyFile string `default:"$YUNION_KEY_FILE" help:"private key file"`
|
||||
|
||||
Completion string `default:"" help:"Generate climc auto complete script" choices:"bash|zsh"`
|
||||
Completion string `default:"" help:"Generate climc auto complete script" choices:"bash"`
|
||||
UseCachedToken bool `default:"$YUNION_USE_CACHED_TOKEN|false" help:"Use cached token"`
|
||||
|
||||
OsUsername string `default:"$OS_USERNAME" help:"Username, defaults to env[OS_USERNAME]"`
|
||||
@@ -58,8 +62,6 @@ type BaseOptions struct {
|
||||
OsAccessKey string `default:"$OS_ACCESS_KEY" help:"ak/sk access key, defaults to env[OS_ACCESS_KEY]"`
|
||||
OsSecretKey string `default:"$OS_SECRET_KEY" help:"ak/s secret, defaults to env[OS_SECRET_KEY]"`
|
||||
|
||||
OsAuthToken string `default:"$OS_AUTH_TOKEN" help:"token authenticate, defaults to env[OS_AUTH_TOKEN]"`
|
||||
|
||||
OsAuthURL string `default:"$OS_AUTH_URL" help:"Defaults to env[OS_AUTH_URL]"`
|
||||
|
||||
OsRegionName string `default:"$OS_REGION_NAME" help:"Defaults to env[OS_REGION_NAME]"`
|
||||
@@ -71,13 +73,9 @@ type BaseOptions struct {
|
||||
}
|
||||
|
||||
func getSubcommandsParser() (*structarg.ArgumentParser, error) {
|
||||
var (
|
||||
prog = "climc"
|
||||
desc = `Command-line interface to the API server.`
|
||||
)
|
||||
parse, e := structarg.NewArgumentParser(&BaseOptions{},
|
||||
prog,
|
||||
desc,
|
||||
"climc",
|
||||
`Command-line interface to the API server.`,
|
||||
`See "climc help COMMAND" for help on a specific command.`)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
@@ -98,28 +96,26 @@ func getSubcommandsParser() (*structarg.ArgumentParser, error) {
|
||||
return nil
|
||||
}
|
||||
})
|
||||
|
||||
promptRootCmd := promputils.InitRootCmd(prog, desc, parse.GetOptArgs(), parse.GetPosArgs())
|
||||
for _, v := range shell.CommandTable {
|
||||
_par, e := subcmd.AddSubParser(v.Options, v.Command, v.Desc, v.Callback)
|
||||
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
promputils.AppendCommand(promptRootCmd, v.Command, v.Desc)
|
||||
promputils.AppendCommand(v.Command, v.Desc)
|
||||
cmd := v.Command
|
||||
|
||||
for _, v := range _par.GetOptArgs() {
|
||||
text := v.String()
|
||||
text = strings.TrimLeft(text, "[<")
|
||||
text = strings.TrimRight(text, "]>")
|
||||
promputils.AppendOpt(cmd, text, v.HelpString(""), v)
|
||||
promputils.AppendOpt(cmd, text, v.HelpString(""))
|
||||
}
|
||||
for _, v := range _par.GetPosArgs() {
|
||||
text := v.String()
|
||||
text = strings.TrimLeft(text, "[<")
|
||||
text = strings.TrimRight(text, "]>")
|
||||
promputils.AppendPos(cmd, text, v.HelpString(""), v)
|
||||
promputils.AppendPos(cmd, text, v.HelpString(""))
|
||||
}
|
||||
}
|
||||
return parse, nil
|
||||
@@ -135,8 +131,8 @@ func newClientSession(options *BaseOptions) (*mcclient.ClientSession, error) {
|
||||
if len(options.OsAuthURL) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_AUTH_URL")
|
||||
}
|
||||
if len(options.OsUsername) == 0 && len(options.OsAccessKey) == 0 && len(options.OsAuthToken) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_USERNAME or OS_ACCESS_KEY or OS_AUTH_TOKEN")
|
||||
if len(options.OsUsername) == 0 && len(options.OsAccessKey) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_USERNAME or OS_ACCESS_KEY")
|
||||
}
|
||||
if len(options.OsUsername) > 0 && len(options.OsPassword) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_PASSWORD")
|
||||
@@ -144,6 +140,9 @@ func newClientSession(options *BaseOptions) (*mcclient.ClientSession, error) {
|
||||
if len(options.OsAccessKey) > 0 && len(options.OsSecretKey) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_SECRET_KEY")
|
||||
}
|
||||
if len(options.OsRegionName) == 0 {
|
||||
return nil, fmt.Errorf("Missing OS_REGION_NAME")
|
||||
}
|
||||
|
||||
logLevel := "info"
|
||||
if options.Debug {
|
||||
@@ -186,11 +185,7 @@ func newClientSession(options *BaseOptions) (*mcclient.ClientSession, error) {
|
||||
if cacheToken == nil {
|
||||
var token mcclient.TokenCredential
|
||||
var err error
|
||||
if len(options.OsAuthToken) > 0 {
|
||||
token, err = client.AuthenticateToken(options.OsAuthToken, options.OsProjectName,
|
||||
options.OsProjectDomain,
|
||||
mcclient.AuthSourceCli)
|
||||
} else if len(options.OsAccessKey) > 0 {
|
||||
if len(options.OsAccessKey) > 0 {
|
||||
token, err = client.AuthenticateByAccessKey(options.OsAccessKey,
|
||||
options.OsSecretKey, mcclient.AuthSourceCli)
|
||||
} else {
|
||||
@@ -266,7 +261,7 @@ func executeSubcommand(
|
||||
}
|
||||
}
|
||||
|
||||
func ClimcMain() {
|
||||
func main() {
|
||||
parser, e := getSubcommandsParser()
|
||||
if e != nil {
|
||||
showErrorAndExit(e)
|
||||
@@ -275,7 +270,7 @@ func ClimcMain() {
|
||||
options := parser.Options().(*BaseOptions)
|
||||
|
||||
if len(options.Completion) > 0 {
|
||||
completeScript := promputils.GenerateAutoCompleteCmds(promputils.GetRootCmd(), options.Completion)
|
||||
completeScript := promputils.GenerateAutoCompleteCmds(options.Completion)
|
||||
if len(completeScript) > 0 {
|
||||
fmt.Printf("%s", completeScript)
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/entry"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/ansible"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudevent"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudid"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudnet"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/compute"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/etcd"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/events"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/identity"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/image"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/itsm"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/k8s"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/logger"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/meter"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/misc"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/monitor"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/notify"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/servicetree"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/yunionconf"
|
||||
)
|
||||
|
||||
func main() {
|
||||
entry.ClimcMain()
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package promputils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"yunion.io/x/structarg"
|
||||
)
|
||||
|
||||
// ref: https://github.com/spf13/cobra/blob/master/zsh_completions.go
|
||||
|
||||
var (
|
||||
zshCompFuncMap = template.FuncMap{
|
||||
"genZshFuncName": zshCompGenFuncName,
|
||||
"extractFlags": zshCompExtractFlag,
|
||||
"genFlagEntryForZshArguments": zshCompGenFlagEntryForArguments,
|
||||
"extractArgsCompletions": zshCompExtractArgumentCompletionHintsForRendering,
|
||||
}
|
||||
zshCompletionText = `
|
||||
{{/* should accept Command (that contains subcommands) as parameter */}}
|
||||
{{define "argumentsC" -}}
|
||||
{{ $cmdPath := genZshFuncName .}}
|
||||
function {{$cmdPath}} {
|
||||
local -a commands
|
||||
_arguments -C \{{- range extractFlags .}}
|
||||
{{genFlagEntryForZshArguments .}} \{{- end}}
|
||||
"1: :->cmnds" \
|
||||
"*::arg:->args"
|
||||
|
||||
case $state in
|
||||
cmnds)
|
||||
commands=({{range .SubCmds}}
|
||||
"{{.Name}}:{{.Desc}}"{{end}}
|
||||
)
|
||||
_describe "command" commands
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$words[1]" in {{- range .SubCmds}}
|
||||
{{.Name}})
|
||||
{{$cmdPath}}_{{.Name}}
|
||||
;;{{end}}
|
||||
esac
|
||||
}
|
||||
{{range .SubCmds}}
|
||||
{{template "selectCmdTemplate" .}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
|
||||
{{/* should accept Command without subcommands as parameter */}}
|
||||
{{define "arguments" -}}
|
||||
function {{genZshFuncName .}} {
|
||||
{{" _arguments"}}{{range extractFlags .}} \
|
||||
{{genFlagEntryForZshArguments . -}}
|
||||
{{end}}{{range extractArgsCompletions .}} \
|
||||
{{.}}{{end}}
|
||||
}
|
||||
{{end}}
|
||||
|
||||
{{/* dispatcher for commands with or without subcommands */}}
|
||||
{{define "selectCmdTemplate" -}}
|
||||
{{if .SubCmds}}{{template "argumentsC" .}}{{else}}{{template "arguments" .}}{{end}}
|
||||
{{- end}}
|
||||
|
||||
{{/* template entry point */}}
|
||||
{{define "Main" -}}
|
||||
#compdef _{{.Name}} {{.Name}}
|
||||
|
||||
{{template "selectCmdTemplate" .}}
|
||||
compdef _{{.Name}} {{.Name}}
|
||||
{{end}}
|
||||
`
|
||||
)
|
||||
|
||||
func zshCompGenFuncName(c *Cmd) string {
|
||||
if c.ParentCmd != nil {
|
||||
return zshCompGenFuncName(c.ParentCmd) + "_" + c.Name
|
||||
}
|
||||
return "_" + c.Name
|
||||
}
|
||||
|
||||
func zshCompExtractFlag(c *Cmd) []structarg.Argument {
|
||||
return c.GetArguments()
|
||||
}
|
||||
|
||||
func zshCompGenFlagEntryForArguments(f structarg.Argument) string {
|
||||
// not process positional argument and single command
|
||||
if f.IsPositional() {
|
||||
return ""
|
||||
}
|
||||
if f.ShortToken() == "" {
|
||||
return zshCompGenFlagEntryForSingleOptionFlag(f)
|
||||
}
|
||||
return zshCompGenFlagEntryForMultiOptionFlag(f)
|
||||
}
|
||||
|
||||
func zshCompGenFlagEntryForSingleOptionFlag(f structarg.Argument) string {
|
||||
var option, multiMark, extras string
|
||||
if f.IsMulti() {
|
||||
multiMark = "*"
|
||||
}
|
||||
|
||||
option = "--" + f.Token()
|
||||
extras = zshCompGenFlagEntryExtras(f)
|
||||
return fmt.Sprintf(`'%s%s[%s]%s'`, multiMark, option, zshCompQuoteFlagDescription(f.HelpString("")), extras)
|
||||
}
|
||||
|
||||
func zshCompGenFlagEntryForMultiOptionFlag(f structarg.Argument) string {
|
||||
var options, parenMultiMark, curlyMultiMark, extras string
|
||||
if f.IsMulti() {
|
||||
parenMultiMark = "*"
|
||||
curlyMultiMark = "\\*"
|
||||
}
|
||||
|
||||
options = fmt.Sprintf(`'(%s-%s %s--%s)'{%s-%s,%s--%s}`,
|
||||
parenMultiMark, f.ShortToken(), parenMultiMark, f.Token(), curlyMultiMark, f.ShortToken(), curlyMultiMark, f.Token())
|
||||
extras = zshCompGenFlagEntryExtras(f)
|
||||
|
||||
return fmt.Sprintf(`%s'[%s]%s'`, options, zshCompQuoteFlagDescription(f.HelpString("")), extras)
|
||||
}
|
||||
|
||||
func zshCompGenFlagEntryExtras(f structarg.Argument) string {
|
||||
if !f.NeedData() {
|
||||
return ""
|
||||
}
|
||||
// allow options for flag
|
||||
extras := ":"
|
||||
|
||||
type iChoices interface {
|
||||
Choices() []string
|
||||
}
|
||||
if hasChoices, ok := f.(iChoices); ok {
|
||||
// process choices
|
||||
var words []string
|
||||
for _, w := range hasChoices.Choices() {
|
||||
words = append(words, fmt.Sprintf("%q", w))
|
||||
}
|
||||
if len(words) != 0 {
|
||||
extras = fmt.Sprintf("%s :(%s)", extras, strings.Join(words, " "))
|
||||
}
|
||||
}
|
||||
return extras
|
||||
}
|
||||
|
||||
func zshCompQuoteFlagDescription(s string) string {
|
||||
s = strings.Replace(s, "'", `'\''`, -1)
|
||||
s = strings.Replace(s, "[", `\[`, -1)
|
||||
s = strings.Replace(s, "]", `\]`, -1)
|
||||
return s
|
||||
}
|
||||
|
||||
func zshCompExtractArgumentCompletionHintsForRendering(c *Cmd) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cmd) GenZshCompletion(w io.Writer) error {
|
||||
tmpl, err := template.New("Main").Funcs(zshCompFuncMap).Parse(zshCompletionText)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating zsh completion template: %v", err)
|
||||
}
|
||||
return tmpl.Execute(w, c.Root())
|
||||
}
|
||||
@@ -75,3 +75,33 @@ _climc(){
|
||||
do
|
||||
line="${arr[$i]}"
|
||||
allopts[count]=${line%s`
|
||||
|
||||
const ZSH_COMPLETE_SCRIPT_2 = `%"#"*}
|
||||
subopts[count]=${line#*"#"}
|
||||
((count++))
|
||||
done
|
||||
_arguments \
|
||||
'1: :->commands'\
|
||||
'*: :->options'
|
||||
|
||||
case $state in
|
||||
commands)
|
||||
_arguments '1:Comm:(${allopts[*]})'
|
||||
;;
|
||||
*)
|
||||
item=1
|
||||
for key in ${allopts[*]}
|
||||
do
|
||||
case $words[2] in
|
||||
$key)
|
||||
compadd "$@"` + "`echo $subopts[item]`" + `
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
((item++))
|
||||
done
|
||||
esac
|
||||
}
|
||||
_climc "$@"
|
||||
`
|
||||
|
||||
@@ -15,118 +15,26 @@
|
||||
package promputils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
prompt "github.com/c-bata/go-prompt"
|
||||
|
||||
"yunion.io/x/structarg"
|
||||
)
|
||||
|
||||
var (
|
||||
subcmds = make(map[string]*Cmd)
|
||||
rootCmd *Cmd
|
||||
)
|
||||
type Cmd struct {
|
||||
desc string
|
||||
optArgs []prompt.Suggest
|
||||
posArgs []prompt.Suggest
|
||||
}
|
||||
|
||||
var cmds = make(map[string]*Cmd)
|
||||
|
||||
var optionHelp = []prompt.Suggest{
|
||||
{Text: "-h"},
|
||||
{Text: "--help"},
|
||||
}
|
||||
|
||||
type Cmd struct {
|
||||
Name string
|
||||
Desc string
|
||||
optArgs []CmdArgument
|
||||
posArgs []CmdArgument
|
||||
ParentCmd *Cmd
|
||||
SubCmds []*Cmd
|
||||
}
|
||||
|
||||
func InitRootCmd(name, desc string, optArgs, posArgs []structarg.Argument) *Cmd {
|
||||
rootCmd = NewCmd(name, desc)
|
||||
for _, optA := range optArgs {
|
||||
rootCmd.AddOptArgument(optA, optA.Token(), optA.HelpString(""))
|
||||
}
|
||||
for _, posA := range posArgs {
|
||||
rootCmd.AddPosArgument(posA, posA.Token(), posA.HelpString(""))
|
||||
}
|
||||
return rootCmd
|
||||
}
|
||||
|
||||
func GetRootCmd() *Cmd {
|
||||
return rootCmd
|
||||
}
|
||||
|
||||
func NewCmd(name, desc string) *Cmd {
|
||||
return &Cmd{
|
||||
Name: name,
|
||||
Desc: desc,
|
||||
optArgs: make([]CmdArgument, 0),
|
||||
posArgs: make([]CmdArgument, 0),
|
||||
SubCmds: make([]*Cmd, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (c Cmd) getPromptSuggests(args []CmdArgument) []prompt.Suggest {
|
||||
ret := make([]prompt.Suggest, 0)
|
||||
for _, arg := range args {
|
||||
ret = append(ret, arg.Suggest)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (c *Cmd) Root() *Cmd {
|
||||
if c.ParentCmd == nil {
|
||||
return c
|
||||
}
|
||||
return c.ParentCmd.Root()
|
||||
}
|
||||
|
||||
func (c Cmd) GetName() string {
|
||||
return c.Name
|
||||
}
|
||||
|
||||
func (c *Cmd) AddCmd(cmd *Cmd) {
|
||||
c.SubCmds = append(c.SubCmds, cmd)
|
||||
}
|
||||
|
||||
func (c Cmd) GetPromptOptSuggests() []prompt.Suggest {
|
||||
return c.getPromptSuggests(c.optArgs)
|
||||
}
|
||||
|
||||
func (c Cmd) GetPromptPosSuggests() []prompt.Suggest {
|
||||
return c.getPromptSuggests(c.posArgs)
|
||||
}
|
||||
|
||||
func (c Cmd) GetOptArguments() []structarg.Argument {
|
||||
return c.getArguments(c.optArgs)
|
||||
}
|
||||
|
||||
func (c Cmd) GetArguments() []structarg.Argument {
|
||||
ret := c.GetOptArguments()
|
||||
ret = append(ret, c.GetPosArguments()...)
|
||||
return ret
|
||||
}
|
||||
|
||||
func (c Cmd) GetPosArguments() []structarg.Argument {
|
||||
return c.getArguments(c.posArgs)
|
||||
}
|
||||
|
||||
func (c Cmd) getArguments(args []CmdArgument) []structarg.Argument {
|
||||
ret := make([]structarg.Argument, 0)
|
||||
for _, a := range args {
|
||||
ret = append(ret, a.Argument)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
type CmdArgument struct {
|
||||
Suggest prompt.Suggest
|
||||
Argument structarg.Argument
|
||||
}
|
||||
|
||||
func optionCompleter(args []string, long bool) []prompt.Suggest {
|
||||
l := len(args)
|
||||
if l == 0 {
|
||||
@@ -139,11 +47,11 @@ func optionCompleter(args []string, long bool) []prompt.Suggest {
|
||||
return optionHelp
|
||||
}
|
||||
|
||||
if subcmds[args[0]] == nil {
|
||||
if cmds[args[0]] == nil {
|
||||
return []prompt.Suggest{}
|
||||
}
|
||||
|
||||
_cmd := subcmds[args[0]].GetPromptOptSuggests()
|
||||
_cmd := cmds[args[0]].optArgs
|
||||
return prompt.FilterContains(_cmd, strings.TrimLeft(args[l-1], "-"), true)
|
||||
}
|
||||
|
||||
@@ -192,7 +100,7 @@ func argumentsCompleter(args []string) []prompt.Suggest {
|
||||
if len(args) == 1 {
|
||||
return prompt.FilterHasPrefix(commands, args[0], true)
|
||||
}
|
||||
_cmd, ok := subcmds[args[0]]
|
||||
_cmd, ok := cmds[args[0]]
|
||||
if !ok {
|
||||
return []prompt.Suggest{}
|
||||
}
|
||||
@@ -203,75 +111,48 @@ func argumentsCompleter(args []string) []prompt.Suggest {
|
||||
|
||||
prm := _cmd.posArgs[len(args)-2]
|
||||
subcommands := []prompt.Suggest{
|
||||
prm.Suggest,
|
||||
prm,
|
||||
}
|
||||
|
||||
return prompt.FilterHasPrefix(subcommands, args[len(args)-1], true)
|
||||
}
|
||||
|
||||
func AppendCommand(parentCmd *Cmd, text, desc string) {
|
||||
func AppendCommand(text, desc string) {
|
||||
commands = append(commands, prompt.Suggest{Text: text, Description: desc})
|
||||
cmd := &Cmd{
|
||||
Name: text,
|
||||
Desc: desc,
|
||||
posArgs: make([]CmdArgument, 0),
|
||||
optArgs: make([]CmdArgument, 0),
|
||||
ParentCmd: parentCmd,
|
||||
}
|
||||
subcmds[text] = cmd
|
||||
parentCmd.AddCmd(cmd)
|
||||
cmds[text] = &Cmd{}
|
||||
cmds[text].desc = desc
|
||||
cmds[text].posArgs = []prompt.Suggest{}
|
||||
cmds[text].optArgs = []prompt.Suggest{}
|
||||
}
|
||||
|
||||
func (c *Cmd) addArgument(target *[]CmdArgument, arg structarg.Argument, argStr string, desc string) {
|
||||
*target = append(*target, CmdArgument{
|
||||
Suggest: prompt.Suggest{
|
||||
Text: argStr,
|
||||
Description: desc,
|
||||
},
|
||||
Argument: arg,
|
||||
})
|
||||
func AppendPos(text, cmd, desc string) {
|
||||
var v = []prompt.Suggest{{Text: cmd, Description: desc}}
|
||||
cmds[text].posArgs = append(cmds[text].posArgs, v...)
|
||||
}
|
||||
|
||||
func (c *Cmd) AddPosArgument(arg structarg.Argument, argStr string, desc string) {
|
||||
c.addArgument(&c.posArgs, arg, argStr, desc)
|
||||
func AppendOpt(text, cmd, desc string) {
|
||||
var v = []prompt.Suggest{{Text: cmd, Description: desc}}
|
||||
cmds[text].optArgs = append(cmds[text].optArgs, v...)
|
||||
}
|
||||
|
||||
func (c *Cmd) AddOptArgument(arg structarg.Argument, argStr string, desc string) {
|
||||
c.addArgument(&c.optArgs, arg, argStr, desc)
|
||||
}
|
||||
|
||||
func AppendPos(text, cmd, desc string, arg structarg.Argument) {
|
||||
cmdObj := subcmds[text]
|
||||
cmdObj.AddPosArgument(arg, cmd, desc)
|
||||
}
|
||||
|
||||
func AppendOpt(text, cmd, desc string, arg structarg.Argument) {
|
||||
cmdObj := subcmds[text]
|
||||
cmdObj.AddOptArgument(arg, cmd, desc)
|
||||
}
|
||||
|
||||
func GenerateAutoCompleteCmds(rootCmd *Cmd, shell string) string {
|
||||
func GenerateAutoCompleteCmds(shell string) string {
|
||||
var ret = []string{}
|
||||
var i = 0
|
||||
if strings.ToLower(shell) == "zsh" {
|
||||
out := bytes.NewBufferString("")
|
||||
if err := rootCmd.GenZshCompletion(out); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return out.String()
|
||||
i = 1
|
||||
}
|
||||
for _, cmd := range subcmds {
|
||||
for cmd, options := range cmds {
|
||||
var (
|
||||
strPosArgs = []string{}
|
||||
strOptArgs = []string{}
|
||||
)
|
||||
for _, posArg := range cmd.GetPromptPosSuggests() {
|
||||
for _, posArg := range options.posArgs {
|
||||
strPosArgs = append(strPosArgs, posArg.Text)
|
||||
}
|
||||
for _, optArg := range cmd.GetPromptOptSuggests() {
|
||||
for _, optArg := range options.optArgs {
|
||||
strOptArgs = append(strOptArgs, strings.Split(optArg.Text, " ")[0])
|
||||
}
|
||||
ret = append(ret, fmt.Sprintf(`arr[%d]="%s# %s %s"`, i, cmd.Name,
|
||||
ret = append(ret, fmt.Sprintf(`arr[%d]="%s# %s %s"`, i, cmd,
|
||||
strings.Join(strPosArgs, " "), strings.Join(strOptArgs, " ")))
|
||||
i += 1
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package logger
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package servicetree
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package servicetree
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package servicetree
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package servicetree
|
||||
package shell
|
||||
|
||||
import (
|
||||
"strings"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ansible
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,32 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ansible
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/util/printutils"
|
||||
)
|
||||
|
||||
var (
|
||||
R = shell.R
|
||||
printList = printutils.PrintJSONList
|
||||
printObject = printutils.PrintJSONObject
|
||||
printBatchResults = printutils.PrintJSONBatchResults
|
||||
|
||||
InvalidUpdateError = shell.InvalidUpdateError
|
||||
printObjectRecursive = printutils.PrintJSONObjectRecursive
|
||||
|
||||
exportList = shell.ExportList
|
||||
)
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ansible
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ansible
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -49,34 +49,4 @@ func init() {
|
||||
printList(apbs, modules.AnsiblePlaybooksV2.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
R(&AnsiblePlaybookV2IdOptions{}, "ansibleplaybookv2-run", "Run ansible playbook",
|
||||
func(s *mcclient.ClientSession, opts *AnsiblePlaybookV2IdOptions) error {
|
||||
apb, err := modules.AnsiblePlaybooksV2.PerformAction(s, opts.ID, "run", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(apb)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
R(&AnsiblePlaybookV2IdOptions{}, "ansibleplaybookv2-stop", "Stop ansible playbook",
|
||||
func(s *mcclient.ClientSession, opts *AnsiblePlaybookV2IdOptions) error {
|
||||
apb, err := modules.AnsiblePlaybooksV2.PerformAction(s, opts.ID, "stop", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(apb)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
R(&AnsiblePlaybookV2IdOptions{}, "ansibleplaybookv2-delete", "Delete ansible playbook",
|
||||
func(s *mcclient.ClientSession, opts *AnsiblePlaybookV2IdOptions) error {
|
||||
apb, err := modules.AnsiblePlaybooksV2.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(apb)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package logger
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -26,28 +26,18 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
"yunion.io/x/onecloud/pkg/multicloud/objectstore"
|
||||
objectshell "yunion.io/x/onecloud/pkg/multicloud/objectstore"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type BucketListOptions struct {
|
||||
options.BaseListOptions
|
||||
DistinctField string `help:"query specified distinct field"`
|
||||
}
|
||||
R(&BucketListOptions{}, "bucket-list", "List all buckets", func(s *mcclient.ClientSession, args *BucketListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(args.DistinctField) > 0 {
|
||||
params.Add(jsonutils.NewString(args.DistinctField), "extra_field")
|
||||
result, err := modules.Buckets.Get(s, "distinct-field", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(result)
|
||||
return nil
|
||||
}
|
||||
result, err := modules.Buckets.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -56,10 +46,10 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketIdOptions struct {
|
||||
type BucketShowOptions struct {
|
||||
ID string `help:"ID or name of bucket"`
|
||||
}
|
||||
R(&BucketIdOptions{}, "bucket-show", "Id details of bucket", func(s *mcclient.ClientSession, args *BucketIdOptions) error {
|
||||
R(&BucketShowOptions{}, "bucket-show", "Show details of bucket", func(s *mcclient.ClientSession, args *BucketShowOptions) error {
|
||||
result, err := modules.Buckets.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -68,15 +58,6 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&BucketIdOptions{}, "bucket-syncstatus", "Sync bucket statust", func(s *mcclient.ClientSession, args *BucketIdOptions) error {
|
||||
result, err := modules.Buckets.PerformAction(s, args.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type BucketUpdateOptions struct {
|
||||
ID string `help:"ID or name of bucket" json:"-"`
|
||||
Name string `help:"new name of bucket" json:"name"`
|
||||
@@ -188,7 +169,7 @@ func init() {
|
||||
StorageClass string `help:"storage CLass"`
|
||||
Acl string `help:"object acl." choices:"private|public-read|public-read-write"`
|
||||
|
||||
objectstore.ObjectHeaderOptions
|
||||
objectshell.ObjectHeaderOptions
|
||||
}
|
||||
R(&BucketUploadObjectsOptions{}, "bucket-object-upload", "Upload an object into a bucket", func(s *mcclient.ClientSession, args *BucketUploadObjectsOptions) error {
|
||||
var body io.Reader
|
||||
@@ -325,7 +306,7 @@ func init() {
|
||||
|
||||
Key []string `help:"Optional object key" json:"key"`
|
||||
|
||||
objectstore.ObjectHeaderOptions
|
||||
objectshell.ObjectHeaderOptions
|
||||
}
|
||||
R(&BucketSetMetadataOptions{}, "bucket-set-metadata", "Set metadata of object", func(s *mcclient.ClientSession, args *BucketSetMetadataOptions) error {
|
||||
input := api.BucketMetadataInput{}
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package meter
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -26,36 +26,11 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func parseGcpCredential(filename string) (jsonutils.JSONObject, error) {
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
authParams, err := jsonutils.Parse(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := jsonutils.NewDict()
|
||||
for _, k := range []string{
|
||||
"client_email",
|
||||
"project_id",
|
||||
"private_key_id",
|
||||
"private_key",
|
||||
} {
|
||||
v, _ := authParams.Get(k)
|
||||
ret.Add(v, fmt.Sprintf("gcp_%s", k))
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
type CloudaccountListOptions struct {
|
||||
options.BaseListOptions
|
||||
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
|
||||
|
||||
DistinctField string `help:"distinct field"`
|
||||
ProxySetting string `help:"Proxy setting id or name"`
|
||||
}
|
||||
R(&CloudaccountListOptions{}, "cloud-account-list", "List cloud accounts", func(s *mcclient.ClientSession, args *CloudaccountListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
@@ -68,18 +43,6 @@ func init() {
|
||||
if len(args.Capability) > 0 {
|
||||
params.Add(jsonutils.NewStringArray(args.Capability), "capability")
|
||||
}
|
||||
if len(args.ProxySetting) > 0 {
|
||||
params.Add(jsonutils.NewString(args.ProxySetting), "proxy_setting")
|
||||
}
|
||||
}
|
||||
if len(args.DistinctField) > 0 {
|
||||
params.Add(jsonutils.NewString(args.DistinctField), "extra_field")
|
||||
result, err := modules.Cloudaccounts.Get(s, "distinct-field", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(result)
|
||||
return nil
|
||||
}
|
||||
result, err := modules.Cloudaccounts.List(s, params)
|
||||
if err != nil {
|
||||
@@ -125,22 +88,6 @@ func init() {
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
type SVMwareCloudAccountPrepareNetsOptions struct {
|
||||
Project string `help:"project for this account"`
|
||||
ProjectDomain string `help:"domain for this account"`
|
||||
NAME string `help:"name for this account"`
|
||||
options.SVMwareCredentialWithEnvironment
|
||||
}
|
||||
R(&SVMwareCloudAccountPrepareNetsOptions{}, "cloud-account-preparenets-vmware", "Prepare networks for a VMware cloud account before create this accout", func(s *mcclient.ClientSession, args *SVMwareCloudAccountPrepareNetsOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
params.(*jsonutils.JSONDict).Add(jsonutils.NewString("VMware"), "provider")
|
||||
result, err := modules.Cloudaccounts.PerformClassAction(s, "prepare-nets", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SAliyunCloudAccountCreateOptions{}, "cloud-account-create-aliyun", "Create an Aliyun cloud account", func(s *mcclient.ClientSession, args *options.SAliyunCloudAccountCreateOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
@@ -191,7 +138,11 @@ func init() {
|
||||
R(&options.SGoogleCloudAccountCreateOptions{}, "cloud-account-create-google", "Create a Google cloud account", func(s *mcclient.ClientSession, args *options.SGoogleCloudAccountCreateOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Google"), "provider")
|
||||
authParams, err := parseGcpCredential(args.GoogleJsonFile)
|
||||
data, err := ioutil.ReadFile(args.GoogleJsonFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
authParams, err := jsonutils.Parse(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -430,19 +381,6 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SGoogleCloudAccountUpdateOptions{}, "cloud-account-update-google", "update a google cloud account", func(s *mcclient.ClientSession, args *options.SGoogleCloudAccountUpdateOptions) error {
|
||||
params := jsonutils.Marshal(args).(*jsonutils.JSONDict)
|
||||
if params.Size() == 0 {
|
||||
return InvalidUpdateError()
|
||||
}
|
||||
result, err := modules.Cloudaccounts.Update(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SAWSCloudAccountUpdateOptions{}, "cloud-account-update-aws", "update an AWS cloud account", func(s *mcclient.ClientSession, args *options.SAWSCloudAccountUpdateOptions) error {
|
||||
params := jsonutils.Marshal(args).(*jsonutils.JSONDict)
|
||||
|
||||
@@ -484,7 +422,7 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SOpenStackCloudAccountUpdateOptions{}, "cloud-account-update-openstack", "update an OpenStack cloud account", func(s *mcclient.ClientSession, args *options.SOpenStackCloudAccountUpdateOptions) error {
|
||||
R(&options.SOpenStackCloudAccountUpdateOptions{}, "cloud-account-update-openstack", "update an AWS cloud account", func(s *mcclient.ClientSession, args *options.SOpenStackCloudAccountUpdateOptions) error {
|
||||
params := jsonutils.Marshal(args).(*jsonutils.JSONDict)
|
||||
if params.Size() == 0 {
|
||||
return InvalidUpdateError()
|
||||
@@ -737,7 +675,11 @@ func init() {
|
||||
})
|
||||
|
||||
R(&options.SGoogleCloudAccountUpdateCredentialOptions{}, "cloud-account-update-credential-google", "Update credential of a Google cloud account", func(s *mcclient.ClientSession, args *options.SGoogleCloudAccountUpdateCredentialOptions) error {
|
||||
params, err := parseGcpCredential(args.GoogleJsonFile)
|
||||
data, err := ioutil.ReadFile(args.GoogleJsonFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
params, err := jsonutils.Parse(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -769,129 +711,6 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SVMwareCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-vmware", "Update credential of a VMware cloud account", func(s *mcclient.ClientSession, args *options.SVMwareCloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SAliyunCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-aliyun", "Update credential of an Aliyun cloud account", func(s *mcclient.ClientSession, args *options.SAliyunCloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SAzureCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-azure", "Update credential of an Azure cloud account", func(s *mcclient.ClientSession, args *options.SAzureCloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SQcloudCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-qcloud", "Update credential of a Qcloud cloud account", func(s *mcclient.ClientSession, args *options.SQcloudCloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SAWSCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-aws", "Update credential of an AWS cloud account", func(s *mcclient.ClientSession, args *options.SAWSCloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SOpenStackCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-openstack", "Update credential of an OpenStack cloud account", func(s *mcclient.ClientSession, args *options.SOpenStackCloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SHuaweiCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-huawei", "Update credential of an Huawei cloud account", func(s *mcclient.ClientSession, args *options.SHuaweiCloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SUcloudCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-ucloud", "Update credential of a Ucloud cloud account", func(s *mcclient.ClientSession, args *options.SUcloudCloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SZStackCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-zstack", "Update credential of a ZStack cloud account", func(s *mcclient.ClientSession, args *options.SZStackCloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SGoogleCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-google", "Update credential of a Google cloud account", func(s *mcclient.ClientSession, args *options.SGoogleCloudAccountUpdateCredentialOptions) error {
|
||||
params, err := parseGcpCredential(args.GoogleJsonFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SS3CloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-s3", "Update credential of a generic S3 cloud account", func(s *mcclient.ClientSession, args *options.SS3CloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SCtyunCloudAccountUpdateCredentialOptions{}, "cloud-account-test-connectivity-ctyun", "Update credential of an Ctyun cloud account", func(s *mcclient.ClientSession, args *options.SCtyunCloudAccountUpdateCredentialOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "test-connectivity", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudaccountSyncOptions struct {
|
||||
ID string `help:"ID or Name of cloud account"`
|
||||
Force bool `help:"Force sync no matter what"`
|
||||
@@ -955,14 +774,10 @@ func init() {
|
||||
})
|
||||
|
||||
type CloudaccountPublicOptions struct {
|
||||
ID string `help:"ID or name of cloud account" json:"-"`
|
||||
Scope string `help:"public_sccope" choices:"domain|system" json:"scope"`
|
||||
SharedDomains []string `help:"shared domains" json:"shared_domains"`
|
||||
ShareMode string `help:"share_mode" choices:"account_domain|provider_domain|system"`
|
||||
ID string `help:"ID or name of cloud account"`
|
||||
}
|
||||
R(&CloudaccountPublicOptions{}, "cloud-account-public", "Mark this cloud account public ", func(s *mcclient.ClientSession, args *CloudaccountPublicOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "public", params)
|
||||
result, err := modules.Cloudaccounts.PerformAction(s, args.ID, "public", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1022,47 +837,4 @@ func init() {
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouaccountChangeOwnerOptions struct {
|
||||
ID string `help:"ID or name of cloudaccount" json:"-"`
|
||||
ProjectDomain string `json:"project_domain" help:"target domain"`
|
||||
}
|
||||
R(&ClouaccountChangeOwnerOptions{}, "cloud-account-change-owner", "Change owner domain of cloudaccount", func(s *mcclient.ClientSession, args *ClouaccountChangeOwnerOptions) error {
|
||||
if len(args.ProjectDomain) == 0 {
|
||||
return fmt.Errorf("empty project_domain")
|
||||
}
|
||||
params := jsonutils.Marshal(args)
|
||||
ret, err := modules.Cloudaccounts.PerformAction(s, args.ID, "change-owner", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouaccountChangeProjectOptions struct {
|
||||
ID string `help:"ID or name of cloudaccount" json:"-"`
|
||||
PROJECT string `json:"project" help:"target domain"`
|
||||
}
|
||||
R(&ClouaccountChangeProjectOptions{}, "cloud-account-change-project", "Change domain/project of cloudaccount", func(s *mcclient.ClientSession, args *ClouaccountChangeProjectOptions) error {
|
||||
if len(args.PROJECT) == 0 {
|
||||
return fmt.Errorf("empty project")
|
||||
}
|
||||
params := jsonutils.Marshal(args)
|
||||
ret, err := modules.Cloudaccounts.PerformAction(s, args.ID, "change-project", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudaccountShowOptions{}, "cloud-account-change-owner-candidate-domains", "Show candiate domains of a cloud account changing project", func(s *mcclient.ClientSession, args *CloudaccountShowOptions) error {
|
||||
result, err := modules.Cloudaccounts.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudevent
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/util/printutils"
|
||||
)
|
||||
|
||||
var (
|
||||
R = shell.R
|
||||
printList = printutils.PrintJSONList
|
||||
)
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudevent
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -1,168 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudgroupListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
ClouduserId string `json:"clouduser_id"`
|
||||
CloudpolicyId string `json:"cloudpolicy_id"`
|
||||
Usable bool `json:"usable"`
|
||||
}
|
||||
R(&CloudgroupListOptions{}, "cloud-group-list", "List cloud groups", func(s *mcclient.ClientSession, opts *CloudgroupListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudgroups.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudgroups.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupCreateOptions struct {
|
||||
NAME string `json:"name"`
|
||||
PROVIDER string `json:"provider" choices:"Google|Aliyun|Aws|Huawei|Qcloud"`
|
||||
CloudpolicyIds []string `json:"cloudpolicy_ids"`
|
||||
Desc string `json:"description"`
|
||||
}
|
||||
|
||||
R(&CloudgroupCreateOptions{}, "cloud-group-create", "Create cloud group", func(s *mcclient.ClientSession, opts *CloudgroupCreateOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
result, err := modules.Cloudgroups.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupIdOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupIdOptions{}, "cloud-group-delete", "Delete cloud group", func(s *mcclient.ClientSession, opts *CloudgroupIdOptions) error {
|
||||
result, err := modules.Cloudgroups.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupIdOptions{}, "cloud-group-show", "Show cloud group", func(s *mcclient.ClientSession, opts *CloudgroupIdOptions) error {
|
||||
result, err := modules.Cloudgroups.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupIdOptions{}, "cloud-group-syncstatus", "Sync cloud group status", func(s *mcclient.ClientSession, opts *CloudgroupIdOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupPolicyOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
CLOUDPOLICY_ID string `help:"Cloudpolicy Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupPolicyOptions{}, "cloud-group-attach-policy", "Attach policy for cloud group", func(s *mcclient.ClientSession, opts *CloudgroupPolicyOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "attach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupPolicyOptions{}, "cloud-group-detach-policy", "Detach policy from cloud group", func(s *mcclient.ClientSession, opts *CloudgroupPolicyOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "detach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupUserOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
CLOUDUSER_ID string `help:"Clouduser Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupUserOptions{}, "cloud-group-add-user", "Add user to cloud group", func(s *mcclient.ClientSession, opts *CloudgroupUserOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "add-user", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupUserOptions{}, "cloud-group-remove-user", "Remove user from cloud group", func(s *mcclient.ClientSession, opts *CloudgroupUserOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "remove-user", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupPoliciesOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
CloudpolicyIds []string `json:"cloudpolicy_ids"`
|
||||
}
|
||||
|
||||
R(&CloudgroupPoliciesOptions{}, "cloud-group-set-policies", "Set cloudpolicies for cloud group", func(s *mcclient.ClientSession, opts *CloudgroupPoliciesOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "set-policies", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupUsersOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
ClouduserIds []string `json:"clouduser_ids"`
|
||||
}
|
||||
|
||||
R(&CloudgroupUsersOptions{}, "cloud-group-set-users", "Set users for cloud group", func(s *mcclient.ClientSession, opts *CloudgroupUsersOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "set-users", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudgroupcacheListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
CloudgroupId string `json:"cloudgroup_id"`
|
||||
}
|
||||
R(&CloudgroupcacheListOptions{}, "cloud-group-cache-list", "List cloud group caches", func(s *mcclient.ClientSession, opts *CloudgroupcacheListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudgroupcaches.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudgroupcaches.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupcacheIdOption struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupcacheIdOption{}, "cloud-group-cache-show", "Show cloud groupcache details", func(s *mcclient.ClientSession, opts *CloudgroupcacheIdOption) error {
|
||||
result, err := modules.Cloudgroupcaches.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupcacheIdOption{}, "cloud-group-cache-syncstatus", "Sync cloudgroupcache", func(s *mcclient.ClientSession, opts *CloudgroupcacheIdOption) error {
|
||||
result, err := modules.Cloudgroupcaches.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupcacheIdOption{}, "cloud-group-cache-delete", "Delete cloudgroupcache", func(s *mcclient.ClientSession, opts *CloudgroupcacheIdOption) error {
|
||||
result, err := modules.Cloudgroupcaches.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudgroupPolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
Cloudgroup string `help:"ID or Name of Cloudgroup"`
|
||||
Cloudpolicy string `help:"Policy ID or name"`
|
||||
}
|
||||
R(&CloudgroupPolicyListOptions{}, "cloud-group-policy-list", "List cloudgroup cloudpolicy pairs", func(s *mcclient.ClientSession, args *CloudgroupPolicyListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Cloudgroup) > 0 {
|
||||
result, err = modules.Cloudgrouppolicies.ListDescendent(s, args.Cloudgroup, params)
|
||||
} else if len(args.Cloudpolicy) > 0 {
|
||||
result, err = modules.Cloudgrouppolicies.ListDescendent2(s, args.Cloudpolicy, params)
|
||||
} else {
|
||||
result, err = modules.Cloudgrouppolicies.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudgrouppolicies.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupPolicyDetailOptions struct {
|
||||
CLOUDUSER string `help:"ID or Name of Cloudgroup"`
|
||||
CLOUDPOLICY string `help:"ID or Name of Cloudpolicy"`
|
||||
}
|
||||
R(&CloudgroupPolicyDetailOptions{}, "cloud-group-policy-show", "Show cloudgrouppolicy details", func(s *mcclient.ClientSession, args *CloudgroupPolicyDetailOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
result, err := modules.Cloudgrouppolicies.Get(s, args.CLOUDUSER, args.CLOUDPOLICY, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudgroupUserListOptions struct {
|
||||
options.BaseListOptions
|
||||
Cloudgroup string `help:"ID or Name of Cloudgroup"`
|
||||
Clouduser string `help:"User ID or name"`
|
||||
}
|
||||
R(&CloudgroupUserListOptions{}, "cloud-group-user-list", "List cloudgroup clouduser pairs", func(s *mcclient.ClientSession, args *CloudgroupUserListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Cloudgroup) > 0 {
|
||||
result, err = modules.Cloudgroupusers.ListDescendent(s, args.Cloudgroup, params)
|
||||
} else if len(args.Clouduser) > 0 {
|
||||
result, err = modules.Cloudgroupusers.ListDescendent2(s, args.Clouduser, params)
|
||||
} else {
|
||||
result, err = modules.Cloudgroupusers.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudgroupusers.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupUserDetailOptions struct {
|
||||
CLOUDUSER string `help:"ID or Name of Cloudgroup"`
|
||||
CLOUDPOLICY string `help:"ID or Name of Clouduser"`
|
||||
}
|
||||
R(&CloudgroupUserDetailOptions{}, "cloud-group-user-show", "Show cloudgroupuser details", func(s *mcclient.ClientSession, args *CloudgroupUserDetailOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
result, err := modules.Cloudgroupusers.Get(s, args.CLOUDUSER, args.CLOUDPOLICY, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudpolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
ClouduserId string `json:"clouduser_id"`
|
||||
CloudgroupId string `json:"cloudgroup_id"`
|
||||
}
|
||||
R(&CloudpolicyListOptions{}, "cloud-policy-list", "List cloud policies", func(s *mcclient.ClientSession, opts *CloudpolicyListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudpolicies.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudpolicies.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudpolicyIdOptions struct {
|
||||
ID string `help:"Cloudpolicy Id"`
|
||||
}
|
||||
|
||||
R(&CloudpolicyIdOptions{}, "cloud-policy-show", "Sow cloud policiy details", func(s *mcclient.ClientSession, opts *CloudpolicyIdOptions) error {
|
||||
result, err := modules.Cloudpolicies.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudpolicyGroupOptions struct {
|
||||
ID string `help:"Cloudpolicy Id"`
|
||||
CLOUDGROUP_ID string `help:"Cloudgroup Id" json:"cloudgroup_id"`
|
||||
}
|
||||
|
||||
R(&CloudpolicyGroupOptions{}, "cloud-policy-assign-group", "Assign cloud policiy to group", func(s *mcclient.ClientSession, opts *CloudpolicyGroupOptions) error {
|
||||
result, err := modules.Cloudpolicies.PerformAction(s, opts.ID, "assign-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudpolicyGroupOptions{}, "cloud-policy-revoke-group", "Revoke cloud policiy from group", func(s *mcclient.ClientSession, opts *CloudpolicyGroupOptions) error {
|
||||
result, err := modules.Cloudpolicies.PerformAction(s, opts.ID, "revoke-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ClouduserPolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
Clouduser string `help:"ID or Name of Clouduser"`
|
||||
Cloudpolicy string `help:"Policy ID or name"`
|
||||
}
|
||||
R(&ClouduserPolicyListOptions{}, "cloud-user-policy-list", "List clouduser cloudpolicy pairs", func(s *mcclient.ClientSession, args *ClouduserPolicyListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Clouduser) > 0 {
|
||||
result, err = modules.Clouduserpolicies.ListDescendent(s, args.Clouduser, params)
|
||||
} else if len(args.Cloudpolicy) > 0 {
|
||||
result, err = modules.Clouduserpolicies.ListDescendent2(s, args.Cloudpolicy, params)
|
||||
} else {
|
||||
result, err = modules.Clouduserpolicies.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Clouduserpolicies.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserPolicyDetailOptions struct {
|
||||
CLOUDUSER string `help:"ID or Name of Clouduser"`
|
||||
CLOUDPOLICY string `help:"ID or Name of Cloudpolicy"`
|
||||
}
|
||||
R(&ClouduserPolicyDetailOptions{}, "cloud-user-policy-show", "Show clouduserpolicy details", func(s *mcclient.ClientSession, args *ClouduserPolicyDetailOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
result, err := modules.Clouduserpolicies.Get(s, args.CLOUDUSER, args.CLOUDPOLICY, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ClouduserListOptions struct {
|
||||
options.BaseListOptions
|
||||
CloudaccountId string `help:"Cloudaccount Id"`
|
||||
CloudproviderId string `help:"Cloudprovider Id"`
|
||||
CloudpolicyId string `help:"filter cloudusers by cloudpolicy"`
|
||||
CloudgroupId string `help:"filter cloudusers by cloudgroup"`
|
||||
}
|
||||
R(&ClouduserListOptions{}, "cloud-user-list", "List cloud users", func(s *mcclient.ClientSession, opts *ClouduserListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudusers.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudusers.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserCreateOptions struct {
|
||||
Name string
|
||||
CloudaccountId string `help:"Cloudaccount Id"`
|
||||
CloudproviderId string `help:"Cloudprovider Id"`
|
||||
OwnerId string `help:"Owner Id"`
|
||||
CloudpolicyIds []string `help:"cloudpolicy ids"`
|
||||
CloudgroupIds []string `help:"cloudgroup ids"`
|
||||
Email string `help:"email address"`
|
||||
MobilePhone string `help:"phone number"`
|
||||
IsConsoleLogin *bool `help:"is console login"`
|
||||
Password string `help:"clouduser password"`
|
||||
}
|
||||
|
||||
R(&ClouduserCreateOptions{}, "cloud-user-create", "Create cloud user", func(s *mcclient.ClientSession, opts *ClouduserCreateOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
result, err := modules.Cloudusers.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserIdOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
}
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-delete", "Delete cloud user", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-logininfo", "Show cloud user login info", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.GetLoginInfo(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-show", "Show cloud user", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserSyncOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
PolicyOnly bool `help:"Ony sync clouduser policies for cloud"`
|
||||
}
|
||||
|
||||
R(&ClouduserSyncOptions{}, "cloud-user-sync", "Sync cloud user policies", func(s *mcclient.ClientSession, opts *ClouduserSyncOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "sync", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-syncstatus", "Sync cloud user status", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserPolicyOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
CLOUDPOLICY_ID string `help:"cloudpolicy Id"`
|
||||
}
|
||||
|
||||
R(&ClouduserPolicyOptions{}, "cloud-user-attach-policy", "Attach policy for cloud user", func(s *mcclient.ClientSession, opts *ClouduserPolicyOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "attach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserPolicyOptions{}, "cloud-user-detach-policy", "Detach policy from cloud user", func(s *mcclient.ClientSession, opts *ClouduserPolicyOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "detach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserPasswordOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
Password string `help:"clouduser password"`
|
||||
}
|
||||
|
||||
R(&ClouduserPasswordOptions{}, "cloud-user-reset-password", "Reset clouduser password", func(s *mcclient.ClientSession, opts *ClouduserPasswordOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "reset-password", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserChangeOwnerOptions struct {
|
||||
ID string `help:"clouduser id"`
|
||||
USER_ID string `help:"local user id"`
|
||||
}
|
||||
|
||||
R(&ClouduserChangeOwnerOptions{}, "cloud-user-change-owner", "Change clouduser owner", func(s *mcclient.ClientSession, opts *ClouduserChangeOwnerOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "change-owner", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserGroupOptions struct {
|
||||
ID string `help:"clouduser id"`
|
||||
CLOUDGROUP_ID string `help:"cloudgroup id" json:"cloudgroup_id"`
|
||||
}
|
||||
|
||||
R(&ClouduserGroupOptions{}, "cloud-user-join-group", "Join user to cloudgroup", func(s *mcclient.ClientSession, opts *ClouduserGroupOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "join-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserGroupOptions{}, "cloud-user-leave-group", "Leave from cloudgroup", func(s *mcclient.ClientSession, opts *ClouduserGroupOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "leave-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/util/printutils"
|
||||
)
|
||||
|
||||
var (
|
||||
R = shell.R
|
||||
printList = printutils.PrintJSONList
|
||||
printObject = printutils.PrintJSONObject
|
||||
)
|
||||
@@ -15,19 +15,16 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/multicloud/zstack"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type QuotaListOptions struct {
|
||||
type CloudmetaOptions struct {
|
||||
PROVIDER_ID string `help:"provider_id"`
|
||||
REGION_ID string `help:"region_id"`
|
||||
ZONE_ID string `help:"zone_id"`
|
||||
}
|
||||
shellutils.R(&QuotaListOptions{}, "quota-list", "List quotas", func(cli *zstack.SRegion, args *QuotaListOptions) error {
|
||||
quotas, err := cli.GetQuotas()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(quotas, 0, 0, 0, nil)
|
||||
R(&CloudmetaOptions{}, "instance-type-list", "query backend service for its version", func(s *mcclient.ClientSession, args *CloudmetaOptions) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
R(&options.RouteCreateOptions{}, "router-route-create", "Create router route", func(s *mcclient.ClientSession, opts *options.RouteCreateOptions) error {
|
||||
R(&options.RouteCreateOptions{}, "router-route-create", "Create router", func(s *mcclient.ClientSession, opts *options.RouteCreateOptions) error {
|
||||
params, err := base_options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -34,7 +34,7 @@ func init() {
|
||||
printObject(router)
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteGetOptions{}, "router-route-show", "Show router route", func(s *mcclient.ClientSession, opts *options.RouteGetOptions) error {
|
||||
R(&options.RouteGetOptions{}, "router-route-show", "Show router", func(s *mcclient.ClientSession, opts *options.RouteGetOptions) error {
|
||||
router, err := modules.Routes.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -42,7 +42,7 @@ func init() {
|
||||
printObject(router)
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteListOptions{}, "router-route-list", "List router routes", func(s *mcclient.ClientSession, opts *options.RouteListOptions) error {
|
||||
R(&options.RouteListOptions{}, "router-route-list", "List routers", func(s *mcclient.ClientSession, opts *options.RouteListOptions) error {
|
||||
params, err := base_options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -54,7 +54,7 @@ func init() {
|
||||
printList(result, modules.Routes.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteUpdateOptions{}, "router-route-update", "Update router route", func(s *mcclient.ClientSession, opts *options.RouteUpdateOptions) error {
|
||||
R(&options.RouteUpdateOptions{}, "router-route-update", "Update router", func(s *mcclient.ClientSession, opts *options.RouteUpdateOptions) error {
|
||||
params, err := base_options.StructToParams(opts)
|
||||
router, err := modules.Routes.Update(s, opts.ID, params)
|
||||
if err != nil {
|
||||
@@ -63,7 +63,7 @@ func init() {
|
||||
printObject(router)
|
||||
return nil
|
||||
})
|
||||
R(&options.RouteDeleteOptions{}, "router-route-delete", "Delete router route", func(s *mcclient.ClientSession, opts *options.RouteDeleteOptions) error {
|
||||
R(&options.RouteDeleteOptions{}, "router-route-delete", "Delete router", func(s *mcclient.ClientSession, opts *options.RouteDeleteOptions) error {
|
||||
router, err := modules.Routes.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -27,8 +27,6 @@ func init() {
|
||||
type CloudproviderRegionListOptions struct {
|
||||
options.BaseListOptions
|
||||
Region string `help:"ID or Name of Host"`
|
||||
|
||||
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
|
||||
}
|
||||
R(&CloudproviderRegionListOptions{}, "cloud-provider-region-list", "List cloudprovider region synchronization status", func(s *mcclient.ClientSession, args *CloudproviderRegionListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -34,7 +34,6 @@ func init() {
|
||||
HasObjectStorage bool `help:"filter cloudproviders that has object storage"`
|
||||
NoObjectStorage bool `help:"filter cloudproviders that has no object storage"`
|
||||
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
|
||||
Cloudregion string `help:"filter cloudproviders by cloudregion"`
|
||||
}
|
||||
R(&CloudproviderListOptions{}, "cloud-provider-list", "List cloud providers", func(s *mcclient.ClientSession, args *CloudproviderListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
@@ -58,10 +57,6 @@ func init() {
|
||||
if len(args.Capability) > 0 {
|
||||
params.Add(jsonutils.NewStringArray(args.Capability), "capability")
|
||||
}
|
||||
|
||||
if len(args.Cloudregion) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Cloudregion), "cloudregion")
|
||||
}
|
||||
}
|
||||
result, err := modules.Cloudproviders.List(s, params)
|
||||
if err != nil {
|
||||
@@ -250,13 +245,4 @@ func init() {
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudproviderShowOptions{}, "cloud-provider-change-owner-candidate-domains", "Show candiate domains of a cloud provider changing owner", func(s *mcclient.ClientSession, args *CloudproviderShowOptions) error {
|
||||
result, err := modules.Cloudproviders.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -12,11 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -34,25 +32,12 @@ func init() {
|
||||
Service string `help:"List regions which service has available skus" choices:"dbinstances|servers"`
|
||||
|
||||
City string `help:"List regions in the specified city"`
|
||||
|
||||
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
|
||||
|
||||
DistinctField string `help:"list the specified distinct field, e.g. city, region"`
|
||||
}
|
||||
R(&CloudregionListOptions{}, "cloud-region-list", "List cloud regions", func(s *mcclient.ClientSession, opts *CloudregionListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(opts.DistinctField) > 0 {
|
||||
params.Add(jsonutils.NewString(opts.DistinctField), "extra_field")
|
||||
result, err := modules.Cloudregions.Get(s, "distinct-field", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(result)
|
||||
return nil
|
||||
}
|
||||
result, err := modules.Cloudregions.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1,60 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudproviderQuotaListOptions struct {
|
||||
options.BaseListOptions
|
||||
Cloudregion string `help:"ID or Name of Cloudregion"`
|
||||
QuotaType string `help:"Quota type"`
|
||||
QuotaRange string `help:"Quota range" choices:"cloudregion|cloudprovider"`
|
||||
}
|
||||
|
||||
R(&CloudproviderQuotaListOptions{}, "cloud-provider-quota-list", "List cloudprovider quota", func(s *mcclient.ClientSession, args *CloudproviderQuotaListOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(args.QuotaType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.QuotaType), "quota_type")
|
||||
}
|
||||
|
||||
if len(args.QuotaRange) > 0 {
|
||||
params.Add(jsonutils.NewString(args.QuotaRange), "quota_range")
|
||||
}
|
||||
|
||||
if len(args.Cloudregion) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Cloudregion), "cloudregion")
|
||||
}
|
||||
|
||||
result, err := modules.CloudproviderQuotas.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(result, modules.CloudproviderQuotas.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/util/printutils"
|
||||
)
|
||||
|
||||
var (
|
||||
R = shell.R
|
||||
printList = printutils.PrintJSONList
|
||||
printObject = printutils.PrintJSONObject
|
||||
printBatchResults = printutils.PrintJSONBatchResults
|
||||
|
||||
InvalidUpdateError = shell.InvalidUpdateError
|
||||
printObjectRecursive = printutils.PrintJSONObjectRecursive
|
||||
|
||||
exportList = shell.ExportList
|
||||
|
||||
printObjectRecursiveEx = printutils.PrintJSONObjectRecursiveEx
|
||||
)
|
||||
@@ -1,109 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type GlobalVpcListOptions struct {
|
||||
options.BaseListOptions
|
||||
}
|
||||
R(&GlobalVpcListOptions{}, "global-vpc-list", "List global vpcs", func(s *mcclient.ClientSession, args *GlobalVpcListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.GlobalVpcs.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.GlobalVpcs.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type GlobalVpcShowOptions struct {
|
||||
ID string `help:"ID or Name of globalvpc"`
|
||||
}
|
||||
R(&GlobalVpcShowOptions{}, "global-vpc-show", "Show details of a global vpc", func(s *mcclient.ClientSession, args *GlobalVpcShowOptions) error {
|
||||
result, err := modules.GlobalVpcs.GetById(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type GlobalVpcPublicOptions struct {
|
||||
ID string `help:"ID or name of global vpc" json:"-"`
|
||||
Scope string `help:"sharing scope" choices:"system|domain"`
|
||||
SharedDomains []string `help:"share to domains"`
|
||||
}
|
||||
R(&GlobalVpcPublicOptions{}, "global-vpc-public", "Make global vpc public", func(s *mcclient.ClientSession, args *GlobalVpcPublicOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.GlobalVpcs.PerformAction(s, args.ID, "public", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type GlobalVpcPrivateOptions struct {
|
||||
ID string `help:"ID or name of global vpc" json:"-"`
|
||||
}
|
||||
R(&GlobalVpcPrivateOptions{}, "global-vpc-private", "Make global vpc private", func(s *mcclient.ClientSession, args *GlobalVpcPrivateOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
result, err := modules.GlobalVpcs.PerformAction(s, args.ID, "private", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&GlobalVpcShowOptions{}, "global-vpc-change-owner-candidate-domains", "Show candiate domains of a global vpc for changing owner", func(s *mcclient.ClientSession, args *GlobalVpcShowOptions) error {
|
||||
result, err := modules.GlobalVpcs.GetSpecific(s, args.ID, "change-owner-candidate-domains", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type GlobalVpcChangeOwnerOptions struct {
|
||||
ID string `help:"ID or name of vpc" json:"-"`
|
||||
ProjectDomain string `json:"project_domain" help:"target domain"`
|
||||
}
|
||||
R(&GlobalVpcChangeOwnerOptions{}, "global-vpc-change-owner", "Change owner domain of a global vpc", func(s *mcclient.ClientSession, args *GlobalVpcChangeOwnerOptions) error {
|
||||
if len(args.ProjectDomain) == 0 {
|
||||
return fmt.Errorf("empty project_domain")
|
||||
}
|
||||
params := jsonutils.Marshal(args)
|
||||
ret, err := modules.GlobalVpcs.PerformAction(s, args.ID, "change-owner", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type PolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
}
|
||||
R(&PolicyListOptions{}, "policy-definition-list", "List policy definitions", func(s *mcclient.ClientSession, args *PolicyListOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.PolicyDefinition.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.PolicyDefinition.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type PolicyIdOptions struct {
|
||||
ID string `help:"policy definition name or id"`
|
||||
}
|
||||
|
||||
R(&PolicyIdOptions{}, "policy-definition-show", "Show policy definition", func(s *mcclient.ClientSession, args *PolicyIdOptions) error {
|
||||
result, err := modules.PolicyDefinition.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&PolicyIdOptions{}, "policy-definition-syncstatus", "Sync policy definition status", func(s *mcclient.ClientSession, args *PolicyIdOptions) error {
|
||||
result, err := modules.PolicyDefinition.PerformAction(s, args.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
R(&options.ProxySettingCreateOptions{}, "proxysetting-create", "Create proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingCreateOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proxysetting, err := modules.ProxySettings.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(proxysetting)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingGetOptions{}, "proxysetting-show", "Show proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingGetOptions) error {
|
||||
proxysetting, err := modules.ProxySettings.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(proxysetting)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingListOptions{}, "proxysetting-list", "List proxysettings", func(s *mcclient.ClientSession, opts *options.ProxySettingListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ProxySettings.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.ProxySettings.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingUpdateOptions{}, "proxysetting-update", "Update proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingUpdateOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
proxysetting, err := modules.ProxySettings.Update(s, opts.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(proxysetting)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingDeleteOptions{}, "proxysetting-delete", "Delete proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingDeleteOptions) error {
|
||||
proxysetting, err := modules.ProxySettings.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(proxysetting)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingTestOptions{}, "proxysetting-test", "Test proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingTestOptions) error {
|
||||
proxysetting, err := modules.ProxySettings.PerformAction(s, opts.ID, "test", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(proxysetting)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingPublicOptions{}, "proxysetting-public", "Make proxysetting public", func(s *mcclient.ClientSession, opts *options.ProxySettingPublicOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
result, err := modules.ProxySettings.PerformAction(s, opts.ID, "public", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
R(&options.ProxySettingPrivateOptions{}, "proxysetting-private", "Make proxysetting private", func(s *mcclient.ClientSession, opts *options.ProxySettingPrivateOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
result, err := modules.ProxySettings.PerformAction(s, opts.ID, "private", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ScalingActivityListOptions struct {
|
||||
options.BaseListOptions
|
||||
}
|
||||
R(&ScalingActivityListOptions{}, "scaling-activity-list", "List Scaling Activity",
|
||||
func(s *mcclient.ClientSession, args *ScalingActivityListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
list, err := modules.ScalingActivity.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(list, modules.ScalingActivity.GetColumns(s))
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ScalingGroupListOptions struct {
|
||||
options.BaseListOptions
|
||||
Hypervisor string `help:"Hypervisor"`
|
||||
Cloudregion string `help:"Cloudregion"`
|
||||
Network string `help:"network"`
|
||||
}
|
||||
R(&ScalingGroupListOptions{}, "scaling-group-list", "List scaling group", func(s *mcclient.ClientSession, args *ScalingGroupListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.ScalingGroup.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.ScalingGroup.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScalingGroupShowOptions struct {
|
||||
ID string
|
||||
}
|
||||
R(&ScalingGroupShowOptions{}, "scaling-group-show", "Show scaling group", func(s *mcclient.ClientSession,
|
||||
args *ScalingGroupShowOptions) error {
|
||||
result, err := modules.ScalingGroup.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScalingGroupCreateOptions struct {
|
||||
NAME string
|
||||
|
||||
Hypervisor string
|
||||
Cloudregion string
|
||||
Network string
|
||||
GuestTemplate string
|
||||
MinInstanceNumber string
|
||||
MaxInstanceNumber string
|
||||
DesireInstanceNumber string
|
||||
Loadbalance string
|
||||
}
|
||||
R(&ScalingGroupCreateOptions{}, "scaling-group-create", "Create scaling group", func(s *mcclient.ClientSession, args *ScalingGroupCreateOptions) error {
|
||||
params := jsonutils.Marshal(args).(*jsonutils.JSONDict)
|
||||
scalingGroup, err := modules.ScalingGroup.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(scalingGroup)
|
||||
return nil
|
||||
})
|
||||
type ScalingGroupDeleteOptions struct {
|
||||
ID string `help:"ScalingGroup ID or Name"`
|
||||
}
|
||||
R(&ScalingGroupDeleteOptions{}, "scaling-group-delete", "Delete Scaling Group", func(s *mcclient.ClientSession,
|
||||
args *ScalingGroupDeleteOptions) error {
|
||||
scalingGroup, err := modules.ScalingGroup.Delete(s, args.ID, jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(scalingGroup)
|
||||
return nil
|
||||
})
|
||||
type ScalingGroupListInstanceOptions struct {
|
||||
ID string `help:"ScalingGroup ID or Name"`
|
||||
}
|
||||
R(&ScalingGroupListInstanceOptions{}, "scaling-group-list-instance", "List all instance of Scaling Group",
|
||||
func(s *mcclient.ClientSession, args *ScalingGroupListInstanceOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("scaling_group", jsonutils.NewString(args.ID))
|
||||
servers, err := modules.Servers.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(servers, modules.Servers.GetColumns(s))
|
||||
return nil
|
||||
},
|
||||
)
|
||||
type ScalingGroupRemoveInstanceOptions struct {
|
||||
ID string `help:"ScalingGroup ID or Name"`
|
||||
SERVER string `help:"Server ID or Name"`
|
||||
Delete bool `help:"If delete the server"`
|
||||
}
|
||||
R(&ScalingGroupRemoveInstanceOptions{}, "scaling-group-remove-instance", "Remove instance of ScalingGroup",
|
||||
func(s *mcclient.ClientSession, args *ScalingGroupRemoveInstanceOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("scaling_group", jsonutils.NewString(args.ID))
|
||||
params.Set("delete_server", jsonutils.NewBool(args.Delete))
|
||||
server, err := modules.Servers.PerformAction(s, args.SERVER, "detach-scaling-group", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(server)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
type ScalingGroupEnableOptions struct {
|
||||
ID string `help:"ScalingGroup ID or Name"`
|
||||
}
|
||||
R(&ScalingGroupEnableOptions{}, "scaling-group-enable", "Enable ScalingGroup", func(s *mcclient.ClientSession,
|
||||
args *ScalingGroupEnableOptions) error {
|
||||
ret, err := modules.ScalingGroup.PerformAction(s, args.ID, "enable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
R(&ScalingGroupEnableOptions{}, "scaling-group-disable", "Disable ScalingGroup", func(s *mcclient.ClientSession,
|
||||
args *ScalingGroupEnableOptions) error {
|
||||
ret, err := modules.ScalingGroup.PerformAction(s, args.ID, "disable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
type Timer struct {
|
||||
TimingExecTime string `help:"Exectime for 'timing' type trigger, format:'2006-01-02 15:04:05'" json:"exec_time"`
|
||||
}
|
||||
|
||||
type CycleTimer struct {
|
||||
CycleCycleType string `help:"Cycle type for cycle timer" json:"cycle_type" choices:"day|week|month"`
|
||||
CycleMinute int `help:"Minute of cycle timer" json:"minute"`
|
||||
CycleHour int `help:"Hour of cycle timer" json:"hour"`
|
||||
CycleWeekdays []int `help:"Weekdays for cycle timer" json:"weekdays"`
|
||||
CycleMonthDays []int `help:"Month days for cycle timer" json:"month_days"`
|
||||
CycleStartTime string `help:"Start time for cycle timer, format:'2006-01-02 15:04:05'" json:"start_time"`
|
||||
CycleEndTime string `help:"End time for cycle timer, format:'2006-01-02 15:04:05'" json:"end_time"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
type ScalingPolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
ScalingGroup string `help:"ScalingGroup ID or Name"`
|
||||
TriggerType string `help:"Trigger type" choices:"alarm|timing|cycle"`
|
||||
}
|
||||
R(&ScalingPolicyListOptions{}, "scaling-policy-list", "List Scaling Policy", func(s *mcclient.ClientSession,
|
||||
args *ScalingPolicyListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
policies, err := modules.ScalingPolicy.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(policies, modules.ScalingPolicy.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScalingPolicyShowOptions struct {
|
||||
ID string `help:"ScalingPolicy ID or Name"`
|
||||
}
|
||||
R(&ScalingPolicyShowOptions{}, "scaling-policy-show", "Show Scaling Policy", func(s *mcclient.ClientSession,
|
||||
args *ScalingPolicyShowOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("details", jsonutils.JSONTrue)
|
||||
policy, err := modules.ScalingPolicy.Get(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(policy)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScalingAlarm struct {
|
||||
AlarmCumulate int `help:"Cumulate times alarm will trigger, for 'alarm' trigger" json:"cumulate"`
|
||||
AlarmCycle int `help:"Monitoring cycle for indicators, for 'alarm' trigger" json:"cycle"`
|
||||
AlarmIndicator string `help:"Indicator for 'alarm' trigger" json:"indicator"`
|
||||
AlarmWrapper string `help:"Wrapper for Indicators" choices:"max|min|average" json:"wrapper"`
|
||||
AlarmOperator string `help:"Operator between Indicator and Operator" json:"operator"`
|
||||
AlarmValue float64 `help:"Value of Indicator" json:"value"`
|
||||
}
|
||||
|
||||
type ScalingPolicyCreateOptions struct {
|
||||
NAME string `help:"ScalingPolicy Name" json:"name"`
|
||||
ScalingGroup string `help:"ScalingGroup ID or Name" json:"scaling_group"`
|
||||
TriggerType string `help:"Trigger type" choices:"alarm|timing|cycle" json:"trigger_type"`
|
||||
|
||||
Timer
|
||||
CycleTimer
|
||||
ScalingAlarm
|
||||
|
||||
Action string `help:"Action for scaling policy" choices:"add|remove|set" json:"action"`
|
||||
Number int `help:"Instance number for action" json:"number"`
|
||||
Unit string `help:"Unit for Number" choices:"s|%" json:"unit"`
|
||||
CoolingTime int `help:"Cooling time, unit: s" json:"cooling_time"`
|
||||
}
|
||||
|
||||
R(&ScalingPolicyCreateOptions{}, "scaling-policy-create", "Create Scaling Policy",
|
||||
func(s *mcclient.ClientSession, args *ScalingPolicyCreateOptions) error {
|
||||
formatStr := "2006-01-02 15:04:05"
|
||||
timingExecTime, err := time.Parse(formatStr, args.TimingExecTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'exec_time'")
|
||||
}
|
||||
cycleStarTime, err := time.Parse(formatStr, args.CycleStartTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'start_time'")
|
||||
}
|
||||
cycleEndTime, err := time.Parse(formatStr, args.CycleEndTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'end_time'")
|
||||
}
|
||||
spCreateInput := api.ScalingPolicyCreateInput{
|
||||
ScalingGroup: args.ScalingGroup,
|
||||
TriggerType: args.TriggerType,
|
||||
Timer: api.TimerCreateInput{
|
||||
ExecTime: timingExecTime,
|
||||
},
|
||||
CycleTimer: api.CycleTimerCreateInput{
|
||||
CycleType: args.CycleCycleType,
|
||||
Minute: args.CycleMinute,
|
||||
Hour: args.CycleHour,
|
||||
WeekDays: args.CycleWeekdays,
|
||||
MonthDays: args.CycleMonthDays,
|
||||
StartTime: cycleStarTime,
|
||||
EndTime: cycleEndTime,
|
||||
},
|
||||
Alarm: api.ScalingAlarmCreateInput{
|
||||
Cumulate: args.AlarmCumulate,
|
||||
Cycle: args.AlarmCycle,
|
||||
Indicator: args.AlarmIndicator,
|
||||
Wrapper: args.AlarmWrapper,
|
||||
Operator: args.AlarmOperator,
|
||||
Value: args.AlarmValue,
|
||||
},
|
||||
Action: args.Action,
|
||||
Number: args.Number,
|
||||
Unit: args.Unit,
|
||||
CoolingTime: args.CoolingTime,
|
||||
}
|
||||
spCreateInput.Name = args.NAME
|
||||
ret, err := modules.ScalingPolicy.Create(s, jsonutils.Marshal(spCreateInput))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScalingPolicyEnableOptions struct {
|
||||
ID string `help:"ScalingPolicy ID or Name"`
|
||||
}
|
||||
R(&ScalingPolicyEnableOptions{}, "scaling-policy-enable", "Enable ScalingPolicy", func(s *mcclient.ClientSession,
|
||||
args *ScalingPolicyEnableOptions) error {
|
||||
ret, err := modules.ScalingPolicy.PerformAction(s, args.ID, "enable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
R(&ScalingPolicyEnableOptions{}, "scaling-policy-disable", "Disable ScalingPolicy",
|
||||
func(s *mcclient.ClientSession, args *ScalingPolicyEnableOptions) error {
|
||||
ret, err := modules.ScalingPolicy.PerformAction(s, args.ID, "disable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScalingPolicyTriggerOptions struct {
|
||||
ID string `help:"ScalingPolicy ID or Name"`
|
||||
}
|
||||
R(&ScalingPolicyTriggerOptions{}, "scaling-policy-trigger", "Trigger ScalingPolicy's action",
|
||||
func(s *mcclient.ClientSession, args *ScalingPolicyTriggerOptions) error {
|
||||
ret, err := modules.ScalingPolicy.PerformAction(s, args.ID, "trigger", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScalingPolicyDeleteOptions struct {
|
||||
ID string `help:"ScalingPolicy ID or Name"`
|
||||
}
|
||||
R(&ScalingPolicyDeleteOptions{}, "scaling-policy-delete", "Delete SclaingPolicy",
|
||||
func(s *mcclient.ClientSession, args *ScalingPolicyDeleteOptions) error {
|
||||
ret, err := modules.ScalingPolicy.Delete(s, args.ID, jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
apis "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ScheduledTaskListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
ScheduledType string `help:"scheduled type" choices:"timing|cycle"`
|
||||
ResourceType string `help:"resource type"`
|
||||
Operation string `help:"operation"`
|
||||
}
|
||||
R(&ScheduledTaskListOptions{}, "scheduledtask-list", "list Scheduled Task", func(s *mcclient.ClientSession, args *ScheduledTaskListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
tasks, err := modules.ScheduledTask.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(tasks, modules.ScheduledTask.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScheduledTaskShowOptions struct {
|
||||
ID string `help:"ScheduledTask ID or Name"`
|
||||
}
|
||||
R(&ScheduledTaskShowOptions{}, "scheudled-task-show", "Show Scheduled Task", func(s *mcclient.ClientSession,
|
||||
args *ScheduledTaskShowOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("details", jsonutils.JSONTrue)
|
||||
task, err := modules.ScheduledTask.Get(s, args.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(task)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScheduledTaskCreateOptions struct {
|
||||
NAME string `help:"ScheduledTask Name" json:"name"`
|
||||
ScheduledType string `help:"Scheudled Type" choices:"timing|cycle" json:"scheduled_type"`
|
||||
|
||||
Timer
|
||||
CycleTimer
|
||||
|
||||
ResourceType string `help:"resource type"`
|
||||
Operation string `help:"operation"`
|
||||
LabelType string `help:"label type"`
|
||||
Labels []string `help:"labels"`
|
||||
}
|
||||
R(&ScheduledTaskCreateOptions{}, "scheduledtask-create", "Create Scheduled Task", func(s *mcclient.ClientSession, args *ScheduledTaskCreateOptions) error {
|
||||
formatStr := "2006-01-02 15:04:05"
|
||||
var exectime, starttime, endtime time.Time
|
||||
var err error
|
||||
if len(args.TimingExecTime) > 0 {
|
||||
exectime, err = time.Parse(formatStr, args.TimingExecTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'exec_time'")
|
||||
}
|
||||
}
|
||||
if len(args.CycleStartTime) > 0 {
|
||||
starttime, err = time.Parse(formatStr, args.CycleStartTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'start_time'")
|
||||
}
|
||||
}
|
||||
if len(args.CycleEndTime) > 0 {
|
||||
endtime, err = time.Parse(formatStr, args.CycleEndTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for 'end_time'")
|
||||
}
|
||||
}
|
||||
stCreateInput := apis.ScheduledTaskCreateInput{
|
||||
ScheduledType: args.ScheduledType,
|
||||
Timer: apis.TimerCreateInput{
|
||||
ExecTime: exectime,
|
||||
},
|
||||
CycleTimer: apis.CycleTimerCreateInput{
|
||||
CycleType: args.CycleCycleType,
|
||||
Minute: args.CycleMinute,
|
||||
Hour: args.CycleHour,
|
||||
WeekDays: args.CycleWeekdays,
|
||||
MonthDays: args.CycleMonthDays,
|
||||
StartTime: starttime,
|
||||
EndTime: endtime,
|
||||
},
|
||||
ResourceType: args.ResourceType,
|
||||
Operation: args.Operation,
|
||||
LabelType: args.LabelType,
|
||||
Labels: args.Labels,
|
||||
}
|
||||
stCreateInput.Name = args.NAME
|
||||
ret, err := modules.ScheduledTask.Create(s, jsonutils.Marshal(stCreateInput))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ScheduledTaskEnableOptions struct {
|
||||
ID string `help:"ScheduledTask ID or Name"`
|
||||
}
|
||||
R(&ScheduledTaskEnableOptions{}, "scheduledtask-enable", "Enable ScheduledTask", func(s *mcclient.ClientSession,
|
||||
args *ScheduledTaskEnableOptions) error {
|
||||
ret, err := modules.ScheduledTask.PerformAction(s, args.ID, "enable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
R(&ScheduledTaskEnableOptions{}, "scheduledtask-disable", "Disable ScheduledTask",
|
||||
func(s *mcclient.ClientSession, args *ScheduledTaskEnableOptions) error {
|
||||
ret, err := modules.ScheduledTask.PerformAction(s, args.ID, "disable", jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScheduledTaskSetLabelsOptions struct {
|
||||
ID string `help:"ScheduledTask ID or Name"`
|
||||
Labels []string `help:"Label"`
|
||||
}
|
||||
R(&ScheduledTaskSetLabelsOptions{}, "scheduledtask-setlabels", "Trigger ScheduledTask's action",
|
||||
func(s *mcclient.ClientSession, args *ScheduledTaskSetLabelsOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("labels", jsonutils.Marshal(args.Labels))
|
||||
ret, err := modules.ScheduledTask.PerformAction(s, args.ID, "set-labels", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScheduledTaskTriggerOptions struct {
|
||||
ID string `help:"ScheduledTask ID or Name"`
|
||||
}
|
||||
R(&ScheduledTaskTriggerOptions{}, "scheduledtask-trigger", "Trigger ScheduledTask",
|
||||
func(s *mcclient.ClientSession, args *ScheduledTaskTriggerOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
ret, err := modules.ScheduledTask.PerformAction(s, args.ID, "trigger", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScheduledTaskDeleteOptions struct {
|
||||
ID string `help:"ScheduledTask ID or Name"`
|
||||
}
|
||||
R(&ScheduledTaskDeleteOptions{}, "scheduledtask-delete", "Delete ScheduledTask",
|
||||
func(s *mcclient.ClientSession, args *ScheduledTaskDeleteOptions) error {
|
||||
ret, err := modules.ScheduledTask.Delete(s, args.ID, jsonutils.NewDict())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
type ScheduledTaskAvtivityListOptions struct {
|
||||
options.BaseListOptions
|
||||
ScheduledTask string `help:"Scheduled Task" json:"scheduled_task"`
|
||||
}
|
||||
R(&ScheduledTaskAvtivityListOptions{}, "scheduledtask-activity-list", "List Scheduled Task Activity",
|
||||
func(s *mcclient.ClientSession, args *ScheduledTaskAvtivityListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
list, err := modules.ScheduledTaskActivity.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(list, modules.ScheduledTaskActivity.GetColumns(s))
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ServerSecgroupListOptions struct {
|
||||
options.BaseListOptions
|
||||
Server string `help:"ID or Name of Server"`
|
||||
Secgroup string `help:"Secgroup ID or name"`
|
||||
}
|
||||
R(&ServerSecgroupListOptions{}, "server-secgroup-list", "List server secgroup pairs", func(s *mcclient.ClientSession, args *ServerSecgroupListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Server) > 0 {
|
||||
result, err = modules.Serversecgroups.ListDescendent(s, args.Server, params)
|
||||
} else if len(args.Secgroup) > 0 {
|
||||
result, err = modules.Serversecgroups.ListDescendent2(s, args.Secgroup, params)
|
||||
} else {
|
||||
result, err = modules.Serversecgroups.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Serversecgroups.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ServerSecgroupDetailOptions struct {
|
||||
SERVER string `help:"ID or Name of Server"`
|
||||
SECGROUP string `help:"ID or Name of Security Group"`
|
||||
}
|
||||
R(&ServerSecgroupDetailOptions{}, "server-secgroup-show", "Show server security group details", func(s *mcclient.ClientSession, args *ServerSecgroupDetailOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
result, err := modules.Serversecgroups.Get(s, args.SERVER, args.SECGROUP, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package notify
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package notify
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -29,11 +29,11 @@ func init() {
|
||||
* 操作用户的通信地址(如果用户的通信地址不存在则进行添加;如果已存在则进行修改;如果设置空则进行删除。)
|
||||
*/
|
||||
type ContactsUpdateOptions struct {
|
||||
UID string `help:"The user you wanna add contact to (Keystone User ID)"`
|
||||
CONTACTTYPE string `help:"The contact type email|mobile" choices:"email|mobile|dingtalk"`
|
||||
CONTACT string `help:"The contacts details mobile number or email address or dingtalk's userid, if set it the empty str means delete"`
|
||||
Status string `help:"Enabled or disabled contact status" choices:"enable|disable"`
|
||||
Pull []string `help:"pull some subcontacts(e.g., dingtalk, feishu, etc) related to mobile"`
|
||||
UID string `help:"The user you wanna add contact to (Keystone User ID)"`
|
||||
CONTACTTYPE string `help:"The contact type email|mobile" choices:"email|mobile|dingtalk"`
|
||||
CONTACT string `help:"The contacts details mobile number or email address or dingtalk's userid, if set it the empty str means delete"`
|
||||
Status string `help:"Enabled or disabled contact status" choices:"enable|disable"`
|
||||
Pull string `help:"pull some subcontacts(e.g., dingtalk, feishu, etc) related to mobile"`
|
||||
}
|
||||
R(&ContactsUpdateOptions{}, "contact-update", "Create, delete or update contact for user", func(s *mcclient.ClientSession, args *ContactsUpdateOptions) error {
|
||||
arr := jsonutils.NewArray()
|
||||
@@ -53,13 +53,7 @@ func init() {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(arr, "contacts")
|
||||
|
||||
pulls := jsonutils.NewArray()
|
||||
for _, pull := range args.Pull {
|
||||
pulls.Add(jsonutils.NewString(pull))
|
||||
}
|
||||
params.Add(pulls, "pull")
|
||||
|
||||
contact, err := modules.Contacts.CustomizedPerformAction(s, args.UID, "update-contact", params)
|
||||
contact, err := modules.Contacts.CustomizedPerformAction(s, args.UID, "update-contact", args.Pull, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -75,8 +69,7 @@ func init() {
|
||||
R(&ContactsPullOptions{}, "contact-pull", "Pull contact", func(s *mcclient.ClientSession, args *ContactsPullOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("contacts", jsonutils.NewArray())
|
||||
params.Set("pull", jsonutils.NewArray(jsonutils.NewString(args.CONTACTTYPE)))
|
||||
contact, err := modules.Contacts.CustomizedPerformAction(s, args.UID, "update-contact", params)
|
||||
contact, err := modules.Contacts.CustomizedPerformAction(s, args.UID, "update-contact", args.CONTACTTYPE, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -96,7 +89,7 @@ func init() {
|
||||
arr.Add(tmpObj)
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(arr, "contacts")
|
||||
contact, err := modules.Contacts.CustomizedPerformAction(s, args.UID, "update-contact", params)
|
||||
contact, err := modules.Contacts.CustomizedPerformAction(s, args.UID, "update-contact", "", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -187,7 +180,7 @@ func init() {
|
||||
tmpDict := jsonutils.NewDict()
|
||||
tmpDict.Add(jsonutils.NewString(args.CONTACT_TYPE), "contact_type")
|
||||
tmpDict.Add(jsonutils.NewString(args.CONTACT), "contact")
|
||||
_, err := modules.Contacts.CustomizedPerformAction(s, args.UID, "verify", tmpDict)
|
||||
_, err := modules.Contacts.CustomizedPerformAction(s, args.UID, "verify", "", tmpDict)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
59
cmd/climc/shell/copyright.go
Normal file
59
cmd/climc/shell/copyright.go
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CopyrightUpdateOptions struct {
|
||||
Copyright string `help:"The copyright"`
|
||||
Email string `help:"The Email"`
|
||||
Docs *string `help:"the Docs website address"`
|
||||
}
|
||||
|
||||
R(&CopyrightUpdateOptions{}, "copyright-update", "update copyright", func(s *mcclient.ClientSession, args *CopyrightUpdateOptions) error {
|
||||
if !s.HasSystemAdminPrivilege() {
|
||||
return fmt.Errorf("require admin privilege")
|
||||
}
|
||||
|
||||
params := jsonutils.NewDict()
|
||||
if args.Docs != nil {
|
||||
params.Add(jsonutils.NewString(*args.Docs), "docs")
|
||||
}
|
||||
|
||||
if len(args.Copyright) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Copyright), "copyright")
|
||||
}
|
||||
|
||||
if len(args.Email) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Email), "email")
|
||||
}
|
||||
|
||||
r, err := modules.Copyright.Update(s, "copyright", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(r)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package identity
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package misc
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package compute
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -38,11 +38,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(opts.ExportFile) > 0 {
|
||||
exportList(result, opts.ExportFile, opts.ExportKeys, opts.ExportTexts, modules.DBInstanceBackups.GetColumns(s))
|
||||
} else {
|
||||
printList(result, modules.DBInstanceBackups.GetColumns(s))
|
||||
}
|
||||
printList(result, modules.DBInstanceBackups.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -84,15 +80,6 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&DBInstanceBackupIdOptions{}, "dbinstance-backup-syncstatus", "Sync DB instance backup status", func(s *mcclient.ClientSession, opts *DBInstanceBackupIdOptions) error {
|
||||
result, err := modules.DBInstanceBackups.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&DBInstanceBackupIdOptions{}, "dbinstance-backup-delete", "Delete DB instance backup", func(s *mcclient.ClientSession, opts *DBInstanceBackupIdOptions) error {
|
||||
result, err := modules.DBInstanceBackups.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user