|
1 | 1 | # |
2 | | -# Copyright (c) 2020-2023 by Delphix. All rights reserved. |
| 2 | +# Copyright (c) 2020-2024 by Delphix. All rights reserved. |
3 | 3 | # |
4 | 4 |
|
5 | 5 | ############################################################################## |
@@ -195,6 +195,9 @@ def run_os_command(self, os_command, **kwargs): |
195 | 195 | stdout, stderr, exit_code = utilities.execute_bash( |
196 | 196 | self.connection, command |
197 | 197 | ) |
| 198 | + logger.debug(f"os_command stdout: {stdout}") |
| 199 | + logger.debug(f"os_command stderr: {stderr}") |
| 200 | + logger.debug(f"os_command exit_code: {exit_code}") |
198 | 201 | return [stdout, stderr, exit_code] |
199 | 202 |
|
200 | 203 | def restart_couchbase(self, provision=False): |
@@ -430,6 +433,53 @@ def make_directory(self, directory_path, force_env_user=False): |
430 | 433 |
|
431 | 434 | logger.debug("Changed the permission of directory") |
432 | 435 |
|
| 436 | + def check_stale_mountpoint(self, path): |
| 437 | + |
| 438 | + output, stderr, exit_code = self.run_os_command( |
| 439 | + os_command="df", path=path |
| 440 | + ) |
| 441 | + if exit_code != 0: |
| 442 | + if "No such file or directory" in stderr: |
| 443 | + # this is actually OK |
| 444 | + return False |
| 445 | + else: |
| 446 | + logger.error( |
| 447 | + "df retured error - stale mount point or other error" |
| 448 | + ) |
| 449 | + logger.error( |
| 450 | + "stdout: {} stderr: {} exit_code: {}".format( |
| 451 | + output, stderr, exit_code |
| 452 | + ) |
| 453 | + ) |
| 454 | + return True |
| 455 | + else: |
| 456 | + return False |
| 457 | + |
| 458 | + def get_db_size(self, path: str) -> str: |
| 459 | + """ |
| 460 | + Get the size of the dataset. |
| 461 | +
|
| 462 | + :param connection: Staging connection. |
| 463 | + :param path: Mount location corresponding to dataset |
| 464 | +
|
| 465 | + :return: du command output. |
| 466 | +
|
| 467 | + """ |
| 468 | + logger.debug("Started db sizing") |
| 469 | + du_std, du_stderr, du_exit_code = self.run_os_command( |
| 470 | + os_command="du", mount_path=path |
| 471 | + ) |
| 472 | + if du_exit_code != 0: |
| 473 | + logger.error("Unable to calculate the dataset size") |
| 474 | + logger.error(f"stderr: {du_stderr}") |
| 475 | + raise UserError( |
| 476 | + "Problem with measuring mounted file system", |
| 477 | + "Ask OS admin to check mount", |
| 478 | + du_stderr, |
| 479 | + ) |
| 480 | + logger.debug(f"Completed db sizing {du_std}") |
| 481 | + return du_std |
| 482 | + |
433 | 483 | def create_config_dir(self): |
434 | 484 | """create and return the hidden folder directory with name 'delphix'""" |
435 | 485 |
|
@@ -494,8 +544,9 @@ def source_bucket_list(self): |
494 | 544 |
|
495 | 545 | def get_backup_date(self, x): |
496 | 546 | w = x.replace( |
497 | | - "{}/{}".format( |
| 547 | + "{}/{}/{}".format( |
498 | 548 | self.parameters.couchbase_bak_loc, |
| 549 | + self.parameters.archive_name, |
499 | 550 | self.parameters.couchbase_bak_repo, |
500 | 551 | ), |
501 | 552 | "", |
@@ -1018,11 +1069,11 @@ def delete_config_folder(self): |
1018 | 1069 | srcname=config_directory_path, |
1019 | 1070 | trgname=target_folder, |
1020 | 1071 | ) |
1021 | | - logger.debug( |
1022 | | - f"mv directory >> command_output=={command_output}" |
1023 | | - f" , command_stderr=={command_stderr} , " |
1024 | | - f"command_exit_code=={command_exit_code}" |
1025 | | - ) |
| 1072 | + # logger.debug( |
| 1073 | + # f"mv directory >> command_output=={command_output}" |
| 1074 | + # f" , command_stderr=={command_stderr} , " |
| 1075 | + # f"command_exit_code=={command_exit_code}" |
| 1076 | + # ) |
1026 | 1077 |
|
1027 | 1078 | def delete_xdcr_config(self): |
1028 | 1079 | if self.parameters.d_source_type == "XDCR": |
|
0 commit comments