auto generate hostnqn file on installation
Sagi Grimberg
maintainercover auto generate hostnqn file on installation
Not sure if it's the best way to do this as my packeging understanding is very limited, hence the RFC. the debian part is tested (don't have access to rpm distros at the moment).
Sagi Grimberg (2):
debain: generate hostnqn file on install and remove on uninstall nvme.spec: generate hostnqn file on install and remove on uninstall
debian/postinst | 22 ++++++++++++++++++++++ debian/prerm | 5 +++++ nvme.spec.in | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 debian/postinst create mode 100644 debian/prerm
Signature · 1 line
2.7.4
Sagi Grimberg
maintainerRFC PATCH 1/2 debain: generate hostnqn file on install and remove on uninstall
--- debian/postinst | 22 ++++++++++++++++++++++ debian/prerm | 5 +++++ 2 files changed, 27 insertions(+) create mode 100644 debian/postinst create mode 100644 debian/prerm
debian/postinst new file +22 -0
@@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +case "$1" in + configure|install) + if [ ! -f /etc/nvme/hostnqn ]; then + install -D /dev/null /etc/nvme/hostnqn + year_month=$(date | awk '{print $6"-"$3}') + uuid=$(cat /proc/sys/kernel/random/uuid) + echo "nqn.$year_month.org.nvmexpress:NVMf:uuid:$uuid" > /etc/nvme/hostnqn + fi + ;; + + upgrade|abort-upgrade) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 0 + ;; +esac +exit 0
debian/prerm new file +5 -0
@@ -0,0 +1,5 @@ +#!/bin/sh + +if [ "$1" = "remove" ]; then + rm -rf /etc/nvme +fi
Signature · 1 line
2.7.4
Christoph Hellwig
maintainerRFC PATCH 1/2 debain: generate hostnqn file on install and remove on uninstall
I think the subject should read "debian" :)
debian/prerm line 5
Quoted 11 lines
debian/prerm new file +5
-0@@ -0,0 +1,5 @@ +#!/bin/sh + +if [ "$1" = "remove" ]; then + rm -rf /etc/nvme +fi
Shouldn't we only do that for a purge?
Sagi Grimberg
maintainerRFC PATCH 1/2 debain: generate hostnqn file on install and remove on uninstall
Quoted 1 line
I think the subject should read "debian" :)
Probably :)
Quoted 5 lines
Quoted 5 lines
debian/prerm new file +0
-0
Quoted 8 lines
debian/prerm line 5
Quoted 6 lines
debian/prerm new file +5
-0@@ -0,0 +1,5 @@ +#!/bin/sh + +if [ "$1" = "remove" ]; then + rm -rf /etc/nvme +fiShouldn't we only do that for a purge?
I haven't given it much thought, it really was a 15 minute thing that I thought I'd through out here so people can tell suggest how to do it better...
I know rpms have .rpmsave for these sort of files but not sure what are the rules for debian.
RFC PATCH 1/2 debain: generate hostnqn file on install and remove on uninstall
Quoted 18 lines · Sagi Grimberg
Quoted 1 line
I think the subject should read "debian" :)
Probably :)
Quoted 5 lines
Quoted 5 lines
debian/prerm new file +0
-0Quoted 8 lines
debian/prerm line 5
Quoted 6 lines
debian/prerm new file +5
-0@@ -0,0 +1,5 @@ +#!/bin/sh + +if [ "$1" = "remove" ]; then + rm -rf /etc/nvme +fiShouldn't we only do that for a purge?
Quoted 4 lines
I haven't given it much thought, it really was a 15 minute thing that I thought I'd through out here so people can tell suggest how to do it better...
I think you need to use postrm and only do it for purge.
https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#s-mscriptsinstact
https://www.debian.org/doc/debian-policy/ap-pkg-conffiles.html#sE.2
Signature · 1 line
Gabriel Krisman Bertazi
Sagi Grimberg
maintainerRFC PATCH 2/2 nvme.spec: generate hostnqn file on install and remove on uninstall
In reply to Sagi Grimberg--- nvme.spec.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
nvme.spec.in +14 -0
@@ -33,6 +33,20 @@ make install DESTDIR=%{buildroot} PREFIX=/usr %clean rm -rf $RPM_BUILD_ROOT +%post +if [ $1 = 1 ]; then # 1 : This package is being installed for the first time + if [ ! -f /etc/nvme/hostnqn ]; then + install -D /dev/null /etc/nvme/hostnqn + year_month=$(date | awk '{print $6"-"$3}') + uuid=$(cat /proc/sys/kernel/random/uuid) + echo "nqn.$year_month.org.nvmexpress:NVMf:uuid:$uuid" > /etc/nvme/hostnqn + fi +fi + +%preun +if [ "$1" = "remove" ]; then + rm -rf /etc/nvme +fi %changelog * Thu Oct 15 2015 Keith Busch <keith.busch at intel.com> - Initial RPM spec
Signature · 1 line
2.7.4
RFC PATCH 2/2 nvme.spec: generate hostnqn file on install and remove on uninstall
Hi Sagi,
Quoted 10 lines · Sagi Grimberg
Signed-off-by Sagi Grimberg <sagi at grimberg.me>--- nvme.spec.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+)nvme.spec.in +0
-0
nvme.spec.in make install DESTDIR=%{buildroot} PREFIX=/usr · line 40
Quoted 8 lines
nvme.spec.in +5
-0@@ -33,6 +33,20 @@ make install DESTDIR=%{buildroot} PREFIX=/usr %clean rm -rf $RPM_BUILD_ROOT +%post +if [ $1 = 1 ]; then # 1 : This package is being installed for the first time + if [ ! -f /etc/nvme/hostnqn ]; then + install -D /dev/null /etc/nvme/hostnqn + year_month=$(date | awk '{print $6"-"$3}')
Two things, a) are you sure this is correct? I interpret $year_month as year and month, not year and day (date | awk '{print $6"-"$3}' evaluates to 2016-7 here) and b) 'date +"%Y-%m"' saves you a 2nd process.
Byte,
Johannes
Sagi Grimberg
maintainerRFC PATCH 2/2 nvme.spec: generate hostnqn file on install and remove on uninstall
Quoted 4 lines
Two things, a) are you sure this is correct? I interpret $year_month as year and month, not year and day (date | awk '{print $6"-"$3}' evaluates to 2016-7 here) and b) 'date +"%Y-%m"' saves you a 2nd process.
Thanks for the tip... I'm moving it to nvme utility though.
Cheers,
Sagi.
RFC PATCH 2/2 nvme.spec: generate hostnqn file on install and remove on uninstall
Quoted 6 lines · Sagi Grimberg
Quoted 4 lines
Two things, a) are you sure this is correct? I interpret $year_month as year and month, not year and day (date | awk '{print $6"-"$3}' evaluates to 2016-7 here) and b) 'date +"%Y-%m"' saves you a 2nd process.
Thanks for the tip... I'm moving it to nvme utility though.
Yes that's probably better.
Byte,
Johannes
Signature · 6 lines
Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
RFC PATCH 2/2 nvme.spec: generate hostnqn file on install and remove on uninstall
In reply to Sagi GrimbergQuoted 16 lines · Sagi Grimberg
Signed-off-by Sagi Grimberg <sagi at grimberg.me>---
?nvme.spec.in | 14 ++++++++++++++
?1 file changed, 14 insertions(+)nvme.spec.in +0
-0@@ -33,6 +33,20 @@ make install DESTDIR=%{buildroot} PREFIX=/usr?%clean
?rm -rf $RPM_BUILD_ROOT
?
+%post
+if [ $1 = 1 ]; then # 1 : This package is being installed for the first time
nvme.spec.in make install DESTDIR=%{buildroot} PREFIX=/usr · line 40
Quoted 3 lines
nvme.spec.in +3
-0+ if [ ! -f /etc/nvme/hostnqn ]; then + install -D /dev/null /etc/nvme/hostnqn + year_month=$(date | awk '{print $6"-"$3}')
Hey Sagi,
7.9 of the base NVMe spec makes it clear on unique names that the "2nd format", which is what is being assembled here, uses a fixed date "2014-08" in it's name, which is exactly what the NVMe Host driver does as its default:
fabrics.c: ?"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id);
I would just do what the NVMe host is doing already and make it easier on yourself ;-).
Sagi Grimberg
maintainerRFC PATCH 2/2 nvme.spec: generate hostnqn file on install and remove on uninstall
Quoted 8 lines
Hey Sagi,
7.9 of the base NVMe spec makes it clear on unique names that the "2nd format", which is what is being assembled here, uses a fixed date "2014-08" in it's name, which is exactly what the NVMe Host driver does as its default:
Quoted 4 lines
fabrics.c: "nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb",&host->id);I would just do what the NVMe host is doing already and make it easier on yourself ;-).
I'm fine with that...
Christoph Hellwig
maintainercover auto generate hostnqn file on installation
In reply to Sagi GrimbergQuoted 3 lines · Sagi Grimberg
Not sure if it's the best way to do this as my packeging understanding is very limited, hence the RFC. the debian part is tested (don't have access to rpm distros at the moment).
My idea was to add a command to generate an automatic hostnqn to the nvme tool instead, what would you think about that? The install scripts could then call that.
Sagi Grimberg
maintainercover auto generate hostnqn file on installation
Quoted 7 lines
Quoted 4 lines
Not sure if it's the best way to do this as my packeging understanding is very limited, hence the RFC. the debian part is tested (don't have access to rpm distros at the moment).
My idea was to add a command to generate an automatic hostnqn to the nvme tool instead, what would you think about that?
I'm fine with that too.
Quoted 1 line
The install scripts could then call that.
Sounds fine.
cover auto generate hostnqn file on installation
Quoted 8 lines · Sagi Grimberg
Quoted 8 lines
Quoted 7 lines
Not sure if it's the best way to do this as my packeging understanding is
very limited, hence the RFC. the debian part is tested (don't have
access to rpm distros at the moment).
Quoted 4 lines
Quoted 2 lines
My idea was to add a command to generate an automatic hostnqn to the nvme tool instead, what would you think about that?
I'm fine with that too.
How about an extra tweak to that tool proposal? ?Have the tool have the option to do both NQN supported formats:
A. the first format that uses a date code in which I think that is what patch 2 in this series was trying to do
and
B. The second format the NVMe Host driver is already does in fabrics.c?
Quoted 5 lines
Quoted 3 lines
The install scripts could then call that.
Sounds fine.
Sagi Grimberg
maintainercover auto generate hostnqn file on installation
Quoted 10 lines
How about an extra tweak to that tool proposal? Have the tool have the option to do both NQN supported formats:
A. the first format that uses a date code in which I think that is what patch 2 in this series was trying to do
and
B. The second format the NVMe Host driver is already does in
fabrics.c
Lets not over-complicate this, perhaps just do (A)?
cover auto generate hostnqn file on installation
Quoted 9 lines · Sagi Grimberg
Quoted 9 lines
How about an extra tweak to that tool proposal???Have the tool have the
option to do both NQN supported formats:A. the first format that uses a date code in which I think that is what
patch 2 in this series was trying to do
Quoted 6 lines
Quoted 4 lines
and
B. The second format the NVMe Host driver is already does in
fabrics.cLets not over-complicate this, perhaps just do (A)?
I'd do B. and be consistent with the NVMe Host driver.