-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: YLShiJustFly <[email protected]>
- Loading branch information
1 parent
e04c5fb
commit 7466b1e
Showing
14 changed files
with
720 additions
and
11 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
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
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,79 @@ | ||
/* | ||
* Copyright (c) 2021 NetEase Inc. | ||
* | ||
* 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. | ||
*/ | ||
|
||
/* | ||
* Project: CurveAdm | ||
* Created Date: 2022-02-08 | ||
* Author: Jingli Chen (Wine93) | ||
*/ | ||
|
||
package scripts | ||
|
||
/* | ||
* Usage: target USER VOLUME CREATE SIZE | ||
* Example: target curve test true 10 | ||
* See Also: https://linux.die.net/man/8/tgtadm | ||
*/ | ||
|
||
var ADD__SPDK_TARGET = ` | ||
#!/usr/bin/env bash | ||
g_sockname=$1 | ||
g_volume=$2 | ||
g_originbdev=$3 | ||
g_curvebdev=$4 | ||
g_rpcpath=$5 | ||
g_blocksize=$6 | ||
g_cdbpath=$7 | ||
g_isexclusive=$8 | ||
g_targetip=$9 | ||
g_targetport=$10 | ||
g_initiatorip=$11 | ||
g_initiatormask=$12 | ||
g_user=$13 | ||
g_create=$14 | ||
g_size=%15 | ||
g_volumename=%16 | ||
mkdir -p /curvebs/nebd/data/lock | ||
touch /etc/curve/curvetab | ||
mkdir -p /curvebs/nebd/data/lock | ||
touch /etc/curve/curvetab | ||
if [ $g_create == "true" ]; then | ||
output=$(curve_ops_tool create -userName=$g_user -fileName=$g_volume -fileLength=$g_size) | ||
if [ $? -ne 0 ]; then | ||
if [ "$output" != "CreateFile fail with errCode: 101" ]; then | ||
exit 1 | ||
fi | ||
fi | ||
fi | ||
if ${g_rpcpath} -s ${g_sockname} iscsi_get_target_nodes >/dev/null | grep "$g_curvebdev" | grep name >/dev/null; then | ||
echo "spdk target is already created, please try anther name" | ||
exit 1 | ||
fi | ||
${g_rpcpath} -s ${g_sockname} bdev_aio_create ${g_volume} ${g_originbdev} 512 >/dev/null | ||
${g_rpcpath} -s ${g_sockname} bdev_cdb_create -b ${g_curvebdev} --cbd ${g_cbdpath} --exclusive=${g_isexclusive} --blocksize=${g_blocksize} >/dev/null | ||
${g_rpcpath} -s ${g_sockname} bdev_ocf_create bdev_ocf_create myocf wb ${g_originbdev} > /dev/null | ||
${g_rpcpath} -s ${g_sockname} iscsi_create_portal_group 1 ${g_targetip}:${g_targetport} > /dev/null | ||
${g_rpcpath} -s ${g_sockname} iscsi_create_initiator_group 2 ANY ${g_initiatorip}/${g_initiatormask} > /dev/null | ||
${g_rpcpath} -s ${g_sockname} iscsi_create_target_node ${g_volumename} "Data Disk1" "myocf:0 ${g_originbdev}:1" 1:2 64 -d > /dev/null | ||
exit 0 | ||
` |
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,76 @@ | ||
/* | ||
* Copyright (c) 2021 NetEase Inc. | ||
* | ||
* 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. | ||
*/ | ||
|
||
/* | ||
* Project: CurveAdm | ||
* Created Date: 2022-02-08 | ||
* Author: Jingli Chen (Wine93) | ||
*/ | ||
|
||
package scripts | ||
|
||
/* | ||
* Usage: target USER VOLUME CREATE SIZE | ||
* Example: target curve test true 10 | ||
* See Also: https://linux.die.net/man/8/tgtadm | ||
*/ | ||
|
||
var SPDK_TARGET = ` | ||
#!/usr/bin/env bash | ||
g_binarypath=$1 | ||
g_cpumask=$2 | ||
g_sockname=$3 | ||
g_iscsi_log=$4 | ||
mkdir -p /curvebs/nebd/data/lock | ||
touch /etc/curve/curvetab | ||
process_name="iscsi_tgt" | ||
if ps aux | grep -v grep | grep "$process_name" >/dev/null; then | ||
echo "spdk iscsi_tgt has already been started, now exit!" | ||
exit 1 | ||
fi | ||
nohup ${g_binarypath} -m ${g_cpumask} -r ${g_sockname} > ${g_iscsi_log} 2>&1 & | ||
i=1 | ||
while true | ||
do | ||
result=$(cat $VSDK_LOG_FILE | grep "please run rpc") | ||
if [[ "$result" != "" ]]; then | ||
i=0 | ||
break | ||
else | ||
sleep 0.1 | ||
i++ | ||
fi | ||
if [ "$i" -ge 50 ]; then | ||
break | ||
fi | ||
done | ||
if [ "$i" -eq 0]; then | ||
echo "spdk iscsi_tgt started success!" | ||
else | ||
echo "wait for 5s, spdk iscsi_tgt has not launched, please try again!" | ||
exit 1 | ||
fi | ||
exit 0 | ||
` |
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
Oops, something went wrong.