Skip to content

Commit db1ee73

Browse files
pujal0909zFernand0traeok
authored
Copy Refactor (backend) (#939)
* added ps to ps and pds to pds copy Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * updates Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * fixed overwrite Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * tests Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * update Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * udpate tests: Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * updates Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * dan's comment, fixed tests Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * changelog Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * changelog update Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * Update native/c/commands/ds.cpp Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> * tests Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * block size, lrecl, recfm edge cases Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * small change Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * small change Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * small fix Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * Update native/c/commands/ds.cpp Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> * Update native/c/zds.cpp Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> * Update native/c/zds.cpp Co-authored-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> * Update native/c/zds.cpp Co-authored-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> * Update native/c/zds.cpp Co-authored-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> * Update native/c/zds.cpp Co-authored-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> * Update native/c/zds.cpp Co-authored-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> * enhance failure message Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * changelog Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * middleware updates Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * update middleware Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * middleware Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * udpates: Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * Update native/c/zds.cpp Co-authored-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> * Update native/c/zds.cpp Co-authored-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> * changeglog Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * changeglog Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * added error for pds to pds using replace Signed-off-by: Pujal <pujal.gandhi@broadcom.com> * requests.hpp Signed-off-by: Pujal <pujal.gandhi@broadcom.com> --------- Signed-off-by: Pujal <pujal.gandhi@broadcom.com> Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Co-authored-by: Trae Yelovich <trae.yelovich@broadcom.com>
1 parent bc71beb commit db1ee73

13 files changed

Lines changed: 446 additions & 637 deletions

File tree

native/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
66

77
## Recent Changes
88

9-
- `c`: Fix spool read / dynalloc error via optimization assignments. [#945](https://github.com/zowe/zowex/issues/945)
9+
- **Breaking:** `c`: Refactored the backend for copying data sets to use Z/OS utilities IEBCOPY and IEBGENER. Removed `--delete-target-members` flag and added `--overwrite` flag for copying a partitioned data set to an existing partitioned data set. Removed duplicate `member_exists_in_pds` function. [#932] (https://github.com/zowe/zowex/issues/932)
10+
- `c`: Fix spool read / dynalloc error via optimization assignments. [#945](https://github.com/zowe/zowex/issues/945)
1011
- `c`: Updated `zut_read_input` so that all tests pass on `zowex`. Now there is no specific handling for line-based TTY input so that data is more consistently preserved.[#953](https://github.com/zowe/zowex/pull/953)
1112
- **Breaking:** `c`: Refactored the `zds_write` function to consolidate data set and DD write logic into a single entry point. [#908](https://github.com/zowe/zowe-native-proto/issues/908)
1213
- `c`: Changed `zowex --version` and `zowex -v` to return just the version number. [#925](https://github.com/zowe/zowex/pull/925)
@@ -246,3 +247,4 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
246247
## [Unreleased]
247248

248249
- Initial release
250+

native/c/commands/ds.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*
1010
*/
1111

12+
#include <cstdio>
1213
#ifndef _OPEN_SYS_FILE_EXT
1314
#define _OPEN_SYS_FILE_EXT 1
1415
#endif
@@ -976,8 +977,9 @@ int handle_data_set_copy(InvocationContext &context)
976977

977978
ZDS zds{};
978979
ZDSCopyOptions options;
980+
options.overwrite = context.get<bool>("overwrite", false);
979981
options.replace = context.get<bool>("replace", false);
980-
options.delete_target_members = context.get<bool>("delete-target-members", false);
982+
const auto result = obj();
981983

982984
int rc = zds_copy_dsn(&zds, source, target, &options);
983985

@@ -991,26 +993,32 @@ int handle_data_set_copy(InvocationContext &context)
991993
return RTNCD_FAILURE;
992994
}
993995

994-
if (options.target_created)
996+
if (!options.target_exists && !options.member_created)
995997
{
998+
result->set("targetCreated", boolean(true));
996999
context.output_stream() << "New data set '" << target << "' created and copied from '" << source << "'" << std::endl;
9971000
}
9981001
else if (options.member_created)
9991002
{
1003+
result->set("memberCreated", boolean(true));
10001004
context.output_stream() << "New member '" << target << "' created and copied from '" << source << "'" << std::endl;
10011005
}
1002-
else if (options.delete_target_members)
1006+
else if (options.overwrite)
10031007
{
1004-
context.output_stream() << "Target members deleted and data set '" << target << "' replaced with contents of '" << source << "'" << std::endl;
1008+
result->set("overwrite", boolean(true));
1009+
context.output_stream() << "Target data set '" << target << "' was overwritten with the attributes and contents of '" << source << "'" << std::endl;
10051010
}
10061011
else if (options.replace)
10071012
{
1013+
result->set("replace", boolean(true));
10081014
context.output_stream() << "Data set '" << target << "' has been updated with contents of '" << source << "'" << std::endl;
10091015
}
10101016
else
10111017
{
10121018
context.output_stream() << "Data set '" << source << "' copied to '" << target << "'" << std::endl;
10131019
}
1020+
1021+
context.set_object(result);
10141022
return RTNCD_SUCCESS;
10151023
}
10161024

@@ -1078,7 +1086,7 @@ void register_commands(parser::Command &root_command)
10781086
auto ds_create_member_cmd = command_ptr(new Command("create-member", "create member in data set"));
10791087
ds_create_member_cmd->add_alias("cre-m");
10801088
ds_create_member_cmd->add_positional_arg("dsn", "data set name with member specified", ArgType_Single, true);
1081-
ds_create_member_cmd->add_keyword_arg("overwrite", make_aliases("--overwrite", "--ow"), "overwrite existing member", ArgType_Flag, false, ArgValue(false));
1089+
ds_create_member_cmd->add_keyword_arg("overwrite", make_aliases("--ow"), "overwrite existing member", ArgType_Flag, false, ArgValue(false));
10821090
ds_create_member_cmd->set_handler(handle_data_set_create_member);
10831091
data_set_cmd->add_command(ds_create_member_cmd);
10841092

@@ -1176,11 +1184,11 @@ void register_commands(parser::Command &root_command)
11761184
auto ds_copy_cmd = command_ptr(new Command("copy", "copy data set (RECFM=U not supported)"));
11771185
ds_copy_cmd->add_positional_arg("source", "source data set to copy from", ArgType_Single, true);
11781186
ds_copy_cmd->add_positional_arg("target", "target data set to copy to", ArgType_Single, true);
1179-
ds_copy_cmd->add_keyword_arg("replace", make_aliases("--replace", "-r"),
1180-
"replace matching members in target PDS with source members (keeps non-matching target members)",
1187+
ds_copy_cmd->add_keyword_arg("overwrite", make_aliases("--ow"),
1188+
"Replace the entire target partitioned data set with the source data set. All members including like named members will be overwritten",
11811189
ArgType_Flag, false, ArgValue(false));
1182-
ds_copy_cmd->add_keyword_arg("delete-target-members", make_aliases("--delete-target-members", "-d"),
1183-
"delete all members from target PDS before copying (PDS-to-PDS copy only, makes target match source exactly)",
1190+
ds_copy_cmd->add_keyword_arg("replace", make_aliases("-r"),
1191+
"Replaces target sequential/member content with source content or replaces matching members in a partitioned data set with source members (keeps non-matching target members)",
11841192
ArgType_Flag, false, ArgValue(false));
11851193
ds_copy_cmd->set_handler(handle_data_set_copy);
11861194
data_set_cmd->add_command(ds_copy_cmd);

native/c/commands/ds.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ int handle_data_set_restore(InvocationContext &result);
2828
int handle_data_set_compress(InvocationContext &result);
2929
int handle_data_set_create_member(InvocationContext &result);
3030
int handle_data_set_rename(InvocationContext &result);
31+
int handle_data_set_copy(InvocationContext &result);
3132
int handle_rename_member(InvocationContext &result);
3233
void register_commands(parser::Command &root_command);
3334
} // namespace ds

native/c/server/rpc_commands.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ void register_ds_commands(CommandDispatcher &dispatcher)
8585
.handle_fifo("stream", "pipe-path", FifoMode::PUT));
8686
dispatcher.register_command("renameDataset", create_ds_builder(ds::handle_data_set_rename).validate<RenameDatasetRequest, RenameDatasetResponse>());
8787
dispatcher.register_command("renameMember", create_ds_builder(ds::handle_rename_member).validate<RenameMemberRequest, RenameMemberResponse>());
88+
dispatcher.register_command("copyDatasetOrMember",
89+
CommandBuilder(ds::handle_data_set_copy)
90+
.validate<CopyDatasetRequest, CopyDatasetResponse>());
8891
}
8992

9093
void register_job_commands(CommandDispatcher &dispatcher)

native/c/server/schemas/requests.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ ZJSON_SCHEMA(WriteDatasetRequest,
119119
FIELD_OPTIONAL(data, STRING)
120120
);
121121

122+
struct CopyDatasetRequest {};
123+
ZJSON_SCHEMA(CopyDatasetRequest,
124+
FIELD_REQUIRED(source, STRING),
125+
FIELD_REQUIRED(target, STRING),
126+
FIELD_OPTIONAL(replace, BOOL),
127+
FIELD_OPTIONAL(overwrite, BOOL)
128+
);
129+
122130
struct CancelJobRequest {};
123131
ZJSON_SCHEMA(CancelJobRequest,
124132
FIELD_REQUIRED(jobId, STRING)

native/c/server/schemas/responses.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ ZJSON_SCHEMA(WriteDatasetResponse,
170170
FIELD_OPTIONAL(truncationWarning, STRING)
171171
);
172172

173+
struct CopyDatasetResponse {};
174+
ZJSON_SCHEMA(CopyDatasetResponse,
175+
FIELD_REQUIRED(success, BOOL)
176+
);
177+
173178
struct CancelJobResponse {};
174179
ZJSON_SCHEMA(CancelJobResponse,
175180
FIELD_REQUIRED(success, BOOL)

0 commit comments

Comments
 (0)