-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
277 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# encoding: utf-8 | ||
from __future__ import unicode_literals | ||
|
||
from .service import Service | ||
from .service import PrimaryMasterService | ||
|
||
|
||
def add_command(subparsers): | ||
Service(subparsers, 'ce') | ||
PrimaryMasterService(subparsers, 'ce') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# encoding: utf-8 | ||
from __future__ import unicode_literals | ||
|
||
from lib import consts | ||
from lib.ocboot import KEY_TARGET_EDITION | ||
|
||
from .service import PrimaryMasterService | ||
|
||
|
||
def add_command(subparsers): | ||
SwitchEditionService(subparsers) | ||
|
||
|
||
class SwitchEditionService(PrimaryMasterService): | ||
|
||
def __init__(self, subparsers): | ||
super().__init__(subparsers, 'switch-edition') | ||
|
||
def inject_options(self, parser): | ||
super().inject_options(parser) | ||
parser.add_argument('edition', | ||
metavar='EDITION', | ||
choices=consts.EDITIONS, | ||
help=f"choice edition from {consts.EDITIONS}") | ||
|
||
def get_ansible_vars(self, args, cluster, primary_master_host): | ||
vars = super().get_ansible_vars(args, cluster, primary_master_host) | ||
vars[KEY_TARGET_EDITION] = args.edition | ||
return vars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
- hosts: all | ||
roles: | ||
- { role: utils/ce-services } | ||
- role: switch-edition | ||
vars: | ||
TARGET_EDITION: ce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
- hosts: all | ||
roles: | ||
- { role: utils/ee-services } | ||
- role: switch-edition | ||
vars: | ||
TARGET_EDITION: ee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- name: detect os | ||
include_role: | ||
name: utils/detect-os | ||
|
||
- name: "switch to edition {{ TARGET_EDITION }}" | ||
include_role: | ||
name: utils/switch-edition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,36 @@ | ||
--- | ||
- name: switch to CE | ||
environment: | ||
KUBECONFIG: "{{ ENV_KUBECONFIG }}" | ||
PATH: /opt/yunion/bin:{{ ansible_env.PATH }} | ||
shell: | | ||
source <(/opt/yunion/bin/ocadm cluster rcadmin) | ||
ocadm cluster update --use-ce --wait | ||
{{ K3S_CMDLINE_PREFIX }} kubectl -n onecloud patch onecloudcluster default --type='json' -p="[{'op': 'replace', 'path': '/spec/web/imageName', 'value': 'web'}]" | ||
{{ K3S_CMDLINE_PREFIX }} kubectl delete configmap -n onecloud default-web | ||
{{ K3S_CMDLINE_PREFIX }} kubectl rollout restart deployment -n onecloud default-web | ||
sleep 3 | ||
while true; do | ||
pod=$(kubectl -n onecloud get pods |grep -v '^NAME' |grep -vi run |awk '{print $1}') | ||
if [ -z "$pod" ]; then | ||
echo all running | ||
break | ||
else | ||
echo "still updating" | ||
fi | ||
sleep 3 | ||
done | ||
climc-ee infos-update \ | ||
--name " " \ | ||
--name-en " " \ | ||
--copyright "OneCloud" \ | ||
--copyright-en "OneCloud" | ||
args: | ||
executable: /bin/bash | ||
include_role: | ||
name: utils/switch-edition | ||
vars: | ||
TARGET_EDITION: ce | ||
|
||
# - name: switch to CE | ||
# environment: | ||
# KUBECONFIG: "{{ ENV_KUBECONFIG }}" | ||
# PATH: /opt/yunion/bin:{{ ansible_env.PATH }} | ||
# shell: | | ||
# # source <(/opt/yunion/bin/ocadm cluster rcadmin) | ||
# # ocadm cluster update --use-ce --wait | ||
# {{ K3S_CMDLINE_PREFIX }} kubectl -n onecloud annotate onecloudcluster default onecloud.yunion.io/edition='ce' | ||
# {{ K3S_CMDLINE_PREFIX }} kubectl -n onecloud patch onecloudcluster default --type='json' -p="[{'op': 'replace', 'path': '/spec/web/imageName', 'value': 'web'}]" | ||
# {{ K3S_CMDLINE_PREFIX }} kubectl delete configmap -n onecloud default-web | ||
# {{ K3S_CMDLINE_PREFIX }} kubectl rollout restart deployment -n onecloud default-web | ||
# sleep 3 | ||
# while true; do | ||
# pod=$(kubectl -n onecloud get pods |grep -v '^NAME' |grep -vi run |awk '{print $1}') | ||
# if [ -z "$pod" ]; then | ||
# echo all running | ||
# break | ||
# else | ||
# echo "still updating" | ||
# fi | ||
# sleep 3 | ||
# done | ||
# # climc-ee infos-update \ | ||
# # --name " " \ | ||
# # --name-en " " \ | ||
# # --copyright "OneCloud" \ | ||
# # --copyright-en "OneCloud" | ||
# args: | ||
# executable: /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- name: Copy switch edition script to /opt/yunion/bin/onecloud-switch-edition.sh | ||
template: | ||
src: "onecloud-switch-edition.sh.j2" | ||
dest: "/opt/yunion/bin/onecloud-switch-edition.sh" | ||
mode: '0755' | ||
|
||
- name: "Execute `/opt/yunion/bin/onecloud-switch-edition.sh`, checking log at /tmp/onecloud-switch-edition.log" | ||
shell: "set -o pipefail && bash /opt/yunion/bin/onecloud-switch-edition.sh 2>&1 | tee /tmp/onecloud-switch-edition.log" | ||
args: | ||
executable: /bin/bash |
Oops, something went wrong.