Discussions
Categories
- 17.9K All Categories
- 3.4K Industry Applications
- 3.3K Intelligent Advisor
- 63 Insurance
- 535.7K On-Premises Infrastructure
- 138.1K Analytics Software
- 38.6K Application Development Software
- 5.6K Cloud Platform
- 109.3K Database Software
- 17.5K Enterprise Manager
- 8.8K Hardware
- 71K Infrastructure Software
- 105.2K Integration
- 41.5K Security Software
zfs cli scripting - how to change the properties of all LUN's

we want to create a simple cli script for changing the targetgroup of all available LUN's. for now we don't succeed. Can someone tell me how to change this script?
-------------------------
script
function getPools()
{
run('cd /');
run ('status');
run ('storage');
pools=list();
for (i=0; i < pools.length; i++)
{
var pool=pools[i];
getPoolStat(pool);
getProjects(pool);
}
run('done');
}
function getPoolStat(pool)
{
run('cd /');
run ('status');
run ('storage');
run ('select ' + pool);
printf("%-10s %-10s \n","Poolname: ",pool);
run('done');
}
function getProjects(pool)
{
run('cd /');
run('shares');
run('set pool=' + pool);
projects=list();
for (a=0; a < projects.length; a++)
{
var project = projects[a];
getLuns(project);
}
// run('done');
}
function getLuns(project)
{
run('select ' + project);
printf("%-10s %-10s \n","Projectname: ",project);
lns=run('list lun');
for (y=0; y < lns.length; y++)
{
var lun = lns[y];
run ('select ' + lun);
printf("%-10s %-10s \n","LUN : ",lun);
//run ('set targetgroup="PCA"');
//run ('commit');
run('done');
}
run('done'); // exit selected project
}
getPools();
---------------------------------------------
Answers
-
Hi.
What problem you have with script ? It got error or other problem ?
What mean available for LUN ? Is it unmapped LUN ?
Or you need change targetgroup for ALL Luns ?
Regards,
Nik
-
it was supposed to change all LUN's but in the mean while i found the solution! i can now execute the script successful!
-
Hi.
Example that can work :
scriptfunction getProjects() { run('cd /'); run('shares'); projects=list(); for (a=0; a < projects.length; a++) { printf("%-10s %-10s \n","Share: ",projects[a]); getLuns(projects[a]); } }function getLuns(project) { run('select ' + project); lns=list(); for (y=0; y < lns.length; y++) { printf("%-10s %-10s \n","LUN : ",lns[y]); run('select ' + lns[y]); try { props=get('volsize'); // printf("%-10s %-10s \n","props : ",props); run ('set targetgroup="PCA"'); run ('commit'); } catch (err) { printf("%-10s \n","not vol "); } run('done') } run('done'); // exit selected project }getProjects();.
Regards,
Nik