Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into pr/33
Browse files Browse the repository at this point in the history
  • Loading branch information
vigh-m committed Mar 6, 2024
2 parents bf6b5eb + 37726e7 commit 438c8f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion amazon-ec2-utils.spec
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Thu Jan 18 2024 Keith Gable <gablk@amazon.com> - 2.2.0-1
- Corrected issue where an ec2-metadata error was written to stdout
- Change ec2nvme-nsid to use Bash string manipulation to improve
performance and reliability

* Mon Jun 5 2023 Guillaume Delacour <delacoug@amazon.com> - 2.2.0-1
* Mon Jun 5 2023 Guillaume Delacour <delacoug@amazon.com> - 2.2.0-1
- Add `--quiet` option to `ec2-metadata --help` output
- Add `-R`/`--region` option to `ec2-metadata` to discover the EC2 instance's region

Expand Down
15 changes: 11 additions & 4 deletions ec2nvme-nsid
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
# for the specific language governing permissions and limitations under
# the License.

#Expected input if partition's kernel name like nvme0n1p2
if [ $# -eq 0 ] ; then
# Expected input is partition's kernel name like nvme0n1p2 or nvme0n1, output would be 1

if [[ $# -ne 1 ]]; then
exit 1
else
# extract ns id from partition's kernel name and export it
NSID=$(echo -n "$@" | cut -f 3 -d 'n' | cut -f 1 -d 'p')
kernel_name=$1

# Remove nvme prefix (also deals with any /dev that might accidentally get passed in)
prefix_removed=${kernel_name#*nvme*n}

# Remove partition suffix
NSID=${prefix_removed%p*}

echo "_NS_ID=${NSID}"
fi

0 comments on commit 438c8f3

Please sign in to comment.