Hi All,
Just wondering if there is any documentation on automating the creation of LUNs/iScsi targets on qnap devices - i'm hoping to achieve this via an API or command line tools rather than going via the web user interface. Is this possible? Any pointers will be greatly appreciated,
Many Thanks,
Stu
Automating iScsi and LUN creation with ansible / API
-
- New here
- Posts: 6
- Joined: Sat Oct 26, 2013 1:06 pm
- storageman
- Ask me anything
- Posts: 5506
- Joined: Thu Sep 22, 2011 10:57 pm
Re: Automating iScsi and LUN creation with ansible / API
Some basic stuff at bottom of page
https://www.qnap.com/en-au/how-to/tutor ... -qnap-nas/
https://www.qnap.com/en-au/how-to/tutor ... -qnap-nas/
-
- New here
- Posts: 6
- Joined: Sat Oct 26, 2013 1:06 pm
Re: Automating iScsi and LUN creation with ansible / API
This article https://www.qnap.com/en-au/how-to/tutor ... -qnap-nas/ is more from the client side that wants to use the disk. I'm trying to automate the provisioning of a system whereby I could create an iSCSI Target, and create a number of LUNs beneath that target - but ideally I would like to do this via a script rather than via the web gui (which although functional is a little bit cumbersome). Happy to ssh into the qnap appliance in order to do this. I need to be able to create 50+ LUNs (hence why the web GUI isn't great)
Some API in the back end must be doing something similar to the following:
CreateLUN(): Name, Storage Pool, Size, Allocation, Allocation Type (thick/thin), Sector Size
MapLUN(): LunName, iScsiTargetName
Some API in the back end must be doing something similar to the following:
CreateLUN(): Name, Storage Pool, Size, Allocation, Allocation Type (thick/thin), Sector Size
MapLUN(): LunName, iScsiTargetName
-
- New here
- Posts: 6
- Joined: Sat Oct 26, 2013 1:06 pm
Re: Automating iScsi and LUN creation with ansible / API
Just to update this thread...
So you can ssh into the NAS and use a number of utilities in sbin for this... For example:
So you can ssh into the NAS and use a number of utilities in sbin for this... For example:
Code: Select all
qcli -l user=admin pw=admin
Authentication success!
sid is AAAAAA
qcli_iscsi -C Alias=mytarget Name=mytarget sid=AAAAAA
qcli_iscsi -c Name=lun1 Allocation=Instant Capacity=10 SectorSize=512 LUNType=Block poolID=2 sid=AAAAAA
qcli_iscsi -m lunID=1 targetID=3 sid=AAAAAA
- storageman
- Ask me anything
- Posts: 5506
- Joined: Thu Sep 22, 2011 10:57 pm
Re: Automating iScsi and LUN creation with ansible / API
Nice, cheersswinchester wrote: ↑Wed Nov 27, 2019 10:55 pm Just to update this thread...
So you can ssh into the NAS and use a number of utilities in sbin for this... For example:
Code: Select all
qcli -l user=admin pw=admin Authentication success! sid is AAAAAA qcli_iscsi -C Alias=mytarget Name=mytarget sid=AAAAAA qcli_iscsi -c Name=lun1 Allocation=Instant Capacity=10 SectorSize=512 LUNType=Block poolID=2 sid=AAAAAA qcli_iscsi -m lunID=1 targetID=3 sid=AAAAAA
Qnap keeps that one hidden!
-
- New here
- Posts: 6
- Joined: Sat Oct 26, 2013 1:06 pm
Re: Automating iScsi and LUN creation with ansible / API
I didn't find anything on google about it..! Anyway, I've created a quick and dirty ansible playbook which create a new iSCSI target and a bunch of LUNs attached to it based on the variables in a yaml file. For the interested it's at:
https://github.com/welshstew/create-qnap-luns
https://github.com/welshstew/create-qnap-luns