|
1 | 1 |
|
2 | 2 | # coding: utf-8 |
3 | | -# OceanBase Deploy. |
4 | | -# Copyright (C) 2021 OceanBase |
| 3 | +# Copyright (c) 2025 OceanBase. |
5 | 4 | # |
6 | | -# This file is part of OceanBase Deploy. |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
7 | 8 | # |
8 | | -# OceanBase Deploy is free software: you can redistribute it and/or modify |
9 | | -# it under the terms of the GNU General Public License as published by |
10 | | -# the Free Software Foundation, either version 3 of the License, or |
11 | | -# (at your option) any later version. |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
12 | 10 | # |
13 | | -# OceanBase Deploy is distributed in the hope that it will be useful, |
14 | | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | -# GNU General Public License for more details. |
17 | | -# |
18 | | -# You should have received a copy of the GNU General Public License |
19 | | -# along with OceanBase Deploy. If not, see <https://www.gnu.org/licenses/>. |
20 | | - |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
21 | 16 |
|
22 | 17 | from __future__ import absolute_import, division, print_function |
23 | 18 |
|
@@ -198,7 +193,7 @@ def init_home(self): |
198 | 193 | version = version_fobj.read() |
199 | 194 | if not COMMAND_ENV.get(ENV.ENV_OBD_ID): |
200 | 195 | COMMAND_ENV.set(ENV.ENV_OBD_ID, uuid()) |
201 | | - if VERSION != version: |
| 196 | + if VERSION != version and BUILD_PLUGIN_LIST != '<B_PLUGIN_LIST>': |
202 | 197 | for part in ['workflows', 'plugins', 'config_parser', 'optimize', 'mirror/remote']: |
203 | 198 | obd_part_dir = os.path.join(self.OBD_PATH, part) |
204 | 199 | root_part_path = os.path.join(self.OBD_INSTALL_PATH, part) |
@@ -2200,6 +2195,103 @@ def _do_command(self, obd): |
2200 | 2195 | return obd.obdiag_offline_func("update_scene", self.opts) |
2201 | 2196 |
|
2202 | 2197 |
|
| 2198 | +class BinlogCommand(MajorCommand): |
| 2199 | + |
| 2200 | + def __init__(self): |
| 2201 | + super(BinlogCommand, self).__init__('binlog', 'binlog service tools') |
| 2202 | + self.register_command(BinlogCreateCommand()) |
| 2203 | + self.register_command(BinlogStartCommand()) |
| 2204 | + self.register_command(BinlogStopCommand()) |
| 2205 | + self.register_command(BinlogShowCommand()) |
| 2206 | + self.register_command(BinlogDropCommand()) |
| 2207 | + |
| 2208 | + |
| 2209 | +class BinlogCreateCommand(ObdCommand): |
| 2210 | + |
| 2211 | + def __init__(self): |
| 2212 | + super(BinlogCreateCommand, self).__init__('create', 'Apply binlog to create instance') |
| 2213 | + self.parser.add_option('--replicate-num', type='int', help="Number of copies", default=1) |
| 2214 | + self.parser.add_option('-d', '--obproxy-deployname', '--odp', type='string', help='Obproxy deploy name') |
| 2215 | + self.parser.add_option('-p', '--cdcro-password', type='string', help='Password of user `cdcro`.If user already been created manually, you need to enter the password here.') |
| 2216 | + |
| 2217 | + def init(self, cmd, args): |
| 2218 | + super(BinlogCreateCommand, self).init(cmd, args) |
| 2219 | + self.parser.set_usage('%s <binlog deploy name> <oceanbase deploy name> <ceanbase tenant name> [options]' % self.prev_cmd) |
| 2220 | + return self |
| 2221 | + |
| 2222 | + def _do_command(self, obd): |
| 2223 | + if len(self.cmds) == 3: |
| 2224 | + return obd.binlog_create_instance(self.cmds[0], self.cmds[1], self.cmds[2]) |
| 2225 | + else: |
| 2226 | + return self._show_help() |
| 2227 | + |
| 2228 | + |
| 2229 | +class BinlogShowCommand(ClusterMirrorCommand): |
| 2230 | + |
| 2231 | + def __init__(self): |
| 2232 | + super(BinlogShowCommand, self).__init__('show', 'Show the list of binlog instances') |
| 2233 | + self.parser.add_option('-d', '--deploy-name', type='str', help="Oceanbase deploy name, must be entered together with `--tenant-name`") |
| 2234 | + self.parser.add_option('-t', '-n', '--tenant-name', type='str', help='Tenant name, must be entered together with `--deploy-name`') |
| 2235 | + |
| 2236 | + def _do_command(self, obd): |
| 2237 | + if len(self.cmds) == 1: |
| 2238 | + return obd.show_binlog_instance(self.cmds[0]) |
| 2239 | + else: |
| 2240 | + return self._show_help() |
| 2241 | + |
| 2242 | + |
| 2243 | +class BinlogStartCommand(ObdCommand): |
| 2244 | + |
| 2245 | + def __init__(self): |
| 2246 | + super(BinlogStartCommand, self).__init__('start', 'Start binlog instance') |
| 2247 | + |
| 2248 | + def init(self, cmd, args): |
| 2249 | + super(BinlogStartCommand, self).init(cmd, args) |
| 2250 | + self.parser.set_usage('%s <binlog deploy name> <oceanbase deploy name> <ceanbase tenant name> [options]' % self.prev_cmd) |
| 2251 | + return self |
| 2252 | + |
| 2253 | + def _do_command(self, obd): |
| 2254 | + if len(self.cmds) == 3: |
| 2255 | + return obd.start_binlog_instances(self.cmds[0], self.cmds[1], self.cmds[2]) |
| 2256 | + else: |
| 2257 | + return self._show_help() |
| 2258 | + |
| 2259 | + |
| 2260 | +class BinlogStopCommand(ObdCommand): |
| 2261 | + |
| 2262 | + def __init__(self): |
| 2263 | + super(BinlogStopCommand, self).__init__('stop', 'Stop binlog instance') |
| 2264 | + |
| 2265 | + def init(self, cmd, args): |
| 2266 | + super(BinlogStopCommand, self).init(cmd, args) |
| 2267 | + self.parser.set_usage('%s <binlog deploy name> <oceanbase deploy name> <ceanbase tenant name> [options]' % self.prev_cmd) |
| 2268 | + return self |
| 2269 | + |
| 2270 | + def _do_command(self, obd): |
| 2271 | + if len(self.cmds) == 3: |
| 2272 | + return obd.stop_binlog_instances(self.cmds[0], self.cmds[1], self.cmds[2]) |
| 2273 | + else: |
| 2274 | + return self._show_help() |
| 2275 | + |
| 2276 | + |
| 2277 | +class BinlogDropCommand(ObdCommand): |
| 2278 | + |
| 2279 | + def __init__(self): |
| 2280 | + super(BinlogDropCommand, self).__init__('drop', 'Drop binlog instance') |
| 2281 | + |
| 2282 | + def init(self, cmd, args): |
| 2283 | + super(BinlogDropCommand, self).init(cmd, args) |
| 2284 | + self.parser.set_usage('%s <binlog deploy name> <oceanbase deploy name> <ceanbase tenant name> [options]' % self.prev_cmd) |
| 2285 | + return self |
| 2286 | + |
| 2287 | + def _do_command(self, obd): |
| 2288 | + if len(self.cmds) == 3: |
| 2289 | + return obd.drop_binlog_instances(self.cmds[0], self.cmds[1], self.cmds[2]) |
| 2290 | + else: |
| 2291 | + return self._show_help() |
| 2292 | + |
| 2293 | + |
| 2294 | + |
2203 | 2295 | class ToolListCommand(ObdCommand): |
2204 | 2296 |
|
2205 | 2297 | def __init__(self): |
@@ -2303,12 +2395,13 @@ def __init__(self): |
2303 | 2395 | self.register_command(TelemetryMajorCommand()) |
2304 | 2396 | self.register_command(ToolCommand()) |
2305 | 2397 | self.register_command(ObdiagCommand()) |
| 2398 | + self.register_command(BinlogCommand()) |
2306 | 2399 | self.parser.version = '''OceanBase Deploy: %s |
2307 | 2400 | REVISION: %s |
2308 | 2401 | BUILD_BRANCH: %s |
2309 | 2402 | BUILD_TIME: %s |
2310 | | -Copyright (C) 2021 OceanBase |
2311 | | -License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. |
| 2403 | +Copyright (C) 2025 OceanBase |
| 2404 | +License Apache 2.0: Apache version 2 or later <https://www.apache.org/licenses/LICENSE-2.0>. |
2312 | 2405 | This is free software: you are free to change and redistribute it. |
2313 | 2406 | There is NO WARRANTY, to the extent permitted by law.''' % (VERSION, REVISION, BUILD_BRANCH, BUILD_TIME) |
2314 | 2407 | self.parser._add_version_option() |
|
0 commit comments