﻿/* Command class */
function Cmd(/*String*/cmd, /*Function*/handler, /*Int*/writeNeeded) {
	/*String*/this.cmd = cmd;
	/*Function*/this.handler = handler;
	/*Need or not "write" configuration to flash (startup-config.conf)*/
	/*Int*/this.writeNeeded = writeNeeded;
}

var READ = 0;
var WRITE = 1;

/* Command definitions */
var cmdPool = {
	// User/Group management commands
	getAllUsers: new Cmd('configure terminal ip smb show alluser username asc %s %s', getAllUsers, READ),
	getQueryUsers: new Cmd('configure terminal ip smb show alluser username asc %s %s %s all "%s"', getAllUsers, READ),
	getOneUserInfo: new Cmd('configure terminal ip smb show user "%s"', getOneUserInfo, READ),
	getOneDomainUserInfo: new Cmd('configure terminal ip smb show domuser "%s"', getOneUserInfo, READ),
	getUsersFast: new Cmd('configure terminal ip smb show user fast', getUsersFast, READ),
	getDomainUsersFast: new Cmd('configure terminal ip smb show domuser fast', getDomainUsersFast, READ),
	getTotalUserNumber: new Cmd('configure terminal ip smb show alluser count', getTotalUserNumber, READ),
	getQueryUserNumber: new Cmd('configure terminal ip smb show alluser query_count %s all "%s"', getTotalUserNumber, READ),
	getUsersSelectList: new Cmd( 'configure terminal ip smb show user fast', getUsersSelectList, READ ),
	addUserAccount: new Cmd( 'configure terminal ip smb user add "%s"', null,WRITE),
	setUserDesc: new Cmd( 'description "%s"', null,WRITE),
	setUserEmail: new Cmd( 'email "%s"', null,WRITE),
	sendBatchUserEmail: new Cmd('mail password %s "%s" "%s" %s', null, READ),
	addUserToGroup: new Cmd('configure terminal ip smb user addgroup "%s" "%s"', null, WRITE),
	//after executing addUserAccount, the zysh prompt remains under "config_user" level of commands
	//that's why this command can simply be 'type' instead of 'configure terminal ip smb user type'
	//and exit is necessary to leave this level
	addUserSetUserType1: new Cmd( 'type %s', null,WRITE),
	addUserQuota: new Cmd( 'quota "%s" %s', null, READ),
	whoami: new Cmd("whoami", getSelf, READ),
	domainami: new Cmd("domainami", domainami, READ),
	exit: new Cmd( 'exit', null,WRITE ),
	//userName newPassword
	addUserPassword: new Cmd('configure terminal ip smb password add "%s" "%s"', null,WRITE),
	modifyUserPassword: new Cmd('configure terminal ip smb password modify "%s" "%s"', null,WRITE),
	modifyAnyUsersPassword3: new Cmd('configure terminal ip smb password modify "%s" "%s" "%s"',null,WRITE),
	modifyUserAccount: new Cmd( 'configure terminal ip smb user modify "%s"', null,WRITE),
	modifyUserName: new Cmd( 'name "%s"', null,WRITE),
	modifyDomUserQuota : new Cmd('configure terminal ip smb domain quota "%s" "%s" %s', null, READ),
	deleteUser1: new Cmd('configure terminal ip smb user delete "%s"', null,WRITE),
	/* Share command definitions */
	getAllInternalShares: new Cmd('configure terminal ip smb show share internal-all', getAllInternalShareInfo, READ),
	getAllExternalShares: new Cmd('configure terminal ip smb show share external-all', getAllExternalShareInfo, READ),
	getShare: new Cmd('configure terminal ip smb show share "%s"', getShare, READ),
	getShareUserPermissions: new Cmd('configure terminal ip smb show share permission user "%s"', getShareUserPermissions, READ),
	getShareDomainUserPermissions: new Cmd('configure terminal ip smb show share permission domuser "%s"', getShareDomainUserPermissions, READ),
	getShareGroupPermissions: new Cmd('configure terminal ip smb show share permission group "%s"', getShareGroupPermissions, READ),
	getShareDomainGroupPermissions: new Cmd('configure terminal ip smb show share permission domgroup "%s"', getShareDomainGroupPermissions, READ),
	getShareByVolume1: new Cmd('configure terminal ip smb show share by_mount_point "%s"', getShareByVolume1, READ),
	addShare2: new Cmd('configure terminal ip smb share add "%s" path "%s"', null,WRITE),
	addShareOwner1: new Cmd('owner "%s"', null,WRITE),
	addShareAccessFlag1: new Cmd('access-flag %s',null,WRITE),
	enableActionLog: new Cmd('action-log', null,WRITE),
	disableActionLog: new Cmd('no action-log', null,WRITE),
	enableShare: new Cmd('enable', null,WRITE),
	disableShare: new Cmd('disable', null,WRITE),
	enableRecycleBin: new Cmd('recycle-bin', null,WRITE),
	disableRecycleBin: new Cmd('no recycle-bin', null,WRITE),
	cleanAllRecycleBin: new Cmd('configure terminal ip smb share recycle-bin do_purge-all', null, READ),
	setRecycleBinExpiryDays: new Cmd('configure terminal ip smb share recycle-bin expireday %s', null,WRITE),
	queryRecycleBinExpiryDays: new Cmd('configure terminal ip smb show share recycle-bin expireday', queryRecycleBinExpiryDays, READ),
	detectUnsharedFolders: new Cmd('configure terminal ip smb share add unshared', null,WRITE),
	//permission format ""user1" "user2" "user3""
	addShareValidUsers: new Cmd('valid-users "%ls "', null,WRITE),
	addShareLongValidUsers: new Cmd('add valid-users "%ls "', null,WRITE),
	addShareReadOnlyUsers: new Cmd('read-list "%ls "', null,WRITE),
	addShareLongReadOnlyUsers: new Cmd('add read-list "%ls "', null,WRITE),
	addShareDenyUsers: new Cmd('deny-list "%ls "', null,WRITE),
	addShareLongDenyUsers: new Cmd('add deny-list "%ls "', null,WRITE),
	addShareValidDomainUsers: new Cmd('domvalid-users "%ls "', null,WRITE),
	addShareLongValidDomainUsers: new Cmd('add domvalid-users "%ls "', null,WRITE),
	addShareReadOnlyDomainUsers: new Cmd('domread-list "%ls "', null,WRITE),
	addShareLongReadOnlyDomainUsers: new Cmd('add domread-list "%ls "', null,WRITE),
	addShareDenyDomainUsers: new Cmd('domdeny-list "%ls "', null,WRITE),
	addShareLongDenyDomainUsers: new Cmd('add domdeny-list "%ls "', null,WRITE),
	addShareValidGroups: new Cmd('valid-groups "%ls "', null,WRITE),
	addShareLongValidGroups: new Cmd('add valid-groups "%ls "', null,WRITE),
	addShareReadOnlyGroups: new Cmd('read-groups "%ls "', null,WRITE),
	addShareLongReadOnlyGroups: new Cmd('add read-groups "%ls "', null,WRITE),
	addShareDenyGroups: new Cmd('deny-groups "%ls "', null,WRITE),
	addShareLongDenyGroups: new Cmd('add deny-groups "%ls "', null,WRITE),
	addShareValidDomainGroups: new Cmd('domvalid-groups "%ls "', null,WRITE),
	addShareLongValidDomainGroups: new Cmd('add domvalid-groups "%ls "', null,WRITE),
	addShareReadOnlyDomainGroups: new Cmd('domread-groups "%ls "', null,WRITE),
	addShareLongReadOnlyDomainGroups: new Cmd('add domread-groups "%ls "', null,WRITE),
	addShareDenyDomainGroups: new Cmd('domdeny-groups "%ls "', null,WRITE),
	addShareLongDenyDomainGroups: new Cmd('add domdeny-groups "%ls "', null,WRITE),
	modifyShare: new Cmd('configure terminal ip smb share modify "%s"', null,WRITE),
	modifyShareOwner: new Cmd('owner "%s"', null,WRITE),
	modifyShareAccessFlag: new Cmd('access-flag %s',null,WRITE),
	//note that valid-users IS NOT the same as "Full" access users but contains both "full" and "readonly" users
	modifyShareValidUsers1: new Cmd('valid-users "%s"', null,WRITE),
	modifyShareReadOnlyUsers1: new Cmd('read-list "%s"', null,WRITE),
	modifyShareName: new Cmd('name "%s"', null,WRITE),
	deleteShareOnly1: new Cmd('configure terminal ip smb share delete "%s"', null,WRITE),
	deleteShareAndFolder1: new Cmd('configure terminal ip smb share delete "%s" deletecontent', null,WRITE),
	getUserShares: new Cmd('configure terminal ip smb show share-user', getUserShares, READ),
	getInternalShares: new Cmd('configure terminal ip smb show share internal', getInternalShares, READ),
	getExternalShares: new Cmd('configure terminal ip smb show share external', getExternalShares, READ),

	DfsAddLinks3: new Cmd('configure terminal ip smb share add "%s" path "%s" dfs-link "%s"', null,WRITE),
	DfsModifyLinks1: new Cmd('dfs-link "%s"', null,WRITE),
	DfsQueryLinkByShare1: new Cmd('configure terminal ip smb show share "%s" dfs-link', DfsQueryLinkByShare1, READ),

	//SslCreateCertificate10: new Cmd('configure terminal ca generate x509 name "%s" cname "%s" country "%s" state  "%s" locality "%s" org "%s" ounit "%s" email "%s" key-type "%s" key-len "%s"', null),
	SslCreateCertificate10: new Cmd('configure terminal ca generate x509 name "%s" cname "%s" country "%s" state  "%s" locality "%s" org "%s" ounit "%s" email "%s" key-type %s key-len %s', null, READ),
	SslCreateCSR10: new Cmd('configure terminal ca generate pkcs10 name "%s" cname "%s" country "%s" state  "%s" locality "%s" org "%s" ounit "%s" email "%s" key-type %s key-len %s', null, READ),
	SslImport1: new Cmd('configure terminal ca import category local name "%s"', null, READ),
	SslInstall: new Cmd('configure terminal ca "%s" ', null, READ),
	SslDownloadCertificate: new Cmd('configure terminal ca "%s" ', null, READ),
	SslDownloadCSR: new Cmd('configure terminal ca "%s" ', null, READ),
	SslQuerySelfSignedCertificate: new Cmd('configure terminal show ca category local', SslQuerySelfSignedCertificate, READ),
	SslCheckIfCsrExist: new Cmd('configure terminal show ca category local', SslCheckIfCsrExist, READ),
	SslShowRawData1: new Cmd('configure terminal show ca raw "%s"', SslShowRawData1, READ),
	SslEnableForceHttps: new Cmd('configure terminal ssl set_force_https on', null, READ),
	SslDisableForceHttps: new Cmd('configure terminal ssl set_force_https off', null, READ),
	SslSetStartup1: new Cmd('configure terminal ssl set_startup %s ', null,WRITE),
	SslShowForceHttpsStatus: new Cmd('configure terminal ssl show_forcehttps_status', SslShowForceHttpsStatus, READ),
	sslRestartHttpd: new Cmd('configure terminal ssl restart_httpd', null, READ),

	/*new Cmd('configure terminal ip smb show subshare "%s";*/
	browseShare2: new Cmd('browse share "%s" "%s"', browseShare, READ),
	browseShareAdmin: new Cmd('browse shareadmin "%s" "%s"', browseShare, READ),
	/*new Cmd('configure terminal ip smb share delete "+ link_arg(arg[0])+" deletecontent" ;
	new Cmd('configure terminal ip smb share udelete "+ link_arg(arg[0])+" deletecontent" ;
	new Cmd('exit', null),
	new Cmd('browse share "%s" + link_arg(arg[1]);*/
	createFolder2: new Cmd('configure terminal add folder "%s" "%s"', null, READ),
	deleteFolder: new Cmd('delete folder "%s" "%s"', null, READ),
	deleteFile: new Cmd('delete file "%s" "%s"', null, READ),
	browseFolderComboBox1: new Cmd('configure terminal browse folder "%s"', browseFolderComboBox1, READ),
	/* ACL command difinitions */
	getACLNodesInfo: new Cmd('configure terminal acl show list "%s"', getACLNodesInfo, READ),
	getACLSelfPermission: new Cmd('configure terminal acl show acl "%s" self', getACLSelfPermission, READ),
	getACLInheritPermission: new Cmd('configure terminal acl show acl "%s" inherit', getACLInheritPermission, READ),
	getACLStatus: new Cmd('configure terminal browse acl "%s"', getACLStatus, READ),
	enterACLModifyMode: new Cmd('configure terminal acl modify "%s"', null, READ),
	addACLSetting: new Cmd('add %s "%ls " %s', null, READ),
	recursiveACLSetting: new Cmd('recursive %s', null, READ),
	inheritACLSetting: new Cmd('inherit %s', null, READ),
	/* Groups command definitions */
	getAllGroups: new Cmd('configure terminal ip smb show allgroup groupname asc %s %s', getAllGroups, READ),
	getQueryGroups: new Cmd('configure terminal ip smb show allgroup groupname asc %s %s %s "%s"', getAllGroups, READ),
	getTotalGroupNumber: new Cmd('configure terminal ip smb show allgroup count', getTotalGroupNumber, READ),
	getQueryGroupNumber: new Cmd('configure terminal ip smb show allgroup query_count %s "%s"', getTotalGroupNumber, READ),
	getLocalGroups: new Cmd('configure terminal ip smb show group', getLocalGroups, READ),
	getDomainGroups: new Cmd('configure terminal ip smb show domgroup', getDomainGroups, READ),
	addGroup: new Cmd('configure terminal ip smb group add "%s"', null,WRITE),
	modifyGroup: new Cmd('configure terminal ip smb group modify "%s" "%s" "%s"', null,WRITE),
	deleteGroup: new Cmd('configure terminal ip smb group delete "%s"', null,WRITE),
	setGroupDesc: new Cmd('configure terminal ip smb group modify description "%s" "%s"', null, WRITE),
	write: new Cmd( 'write', null,WRITE ),
	/* CIFS command definitions */
	getServerName: new Cmd('show system hostname', getServerName, READ),
	getServerDescription: new Cmd('show description', getServerDescription, READ),
	getServerWorkgroup: new Cmd('show system workgroupname', getServerWorkgroup, READ),
	setServerName1: new Cmd("configure terminal hostname %s", null,WRITE),
	setServerDescription1: new Cmd("configure terminal description \"%s\"", null,WRITE),
	setServerWorkgroup1: new Cmd("configure terminal workgroupname %s", null,WRITE),
	setNoServerDescription: new Cmd("configure terminal no description", null,WRITE),
	setLeaveDomain3: new Cmd('configure terminal ip smb domain seq leavest "%s" %s "%s"', null,READ),
	setJoinDomainType : new Cmd('configure terminal ip smb domain type %s', null,READ),
	setJoinDomain4: new Cmd('configure terminal ip smb domain seq joinst "%s" "%s" "%s"', null,READ),
	getDomainStatus: new Cmd('configure terminal ip smb show domain', getDomainStatus, READ),
	importDomainInfor: new Cmd('configure terminal ip smb domain seq importst', null, READ),
	getImportDomainProgress: new Cmd('configure terminal ip smb domain seq getimpprogress', getImportDomainProgress, READ),
	getImportDomainFailMsg: new Cmd('configure terminal ip smb domain seq importend st', null, READ),
	testDomainStatus:new Cmd('configure terminal ip smb domain test', testDomainStatus, READ),
	getJoinDomainProgress: new Cmd('configure terminal ip smb domain seq getprogress', getJoinDomainProgress, WRITE),
	getLeaveDomainProgress: new Cmd('configure terminal ip smb domain seq getlvprogress', getJoinDomainProgress, WRITE),
	getJoinErrorMsg: new Cmd("configure terminal ip smb domain seq joinend st", null, READ),
	getLeaveErrorMsg: new Cmd("configure terminal ip smb domain seq leaveend st", null, READ),
	/* Storage command definitions */
	//Internal Storage
	ejectIDisk: new Cmd('storage ejectIDisk %s %s', null, READ),
	getIDisk: new Cmd("storage getIDiskInfo", getIDisk, READ),
	getIDiskHealth:new Cmd('configure terminal smart showDiskHealth %s', getIDiskHealth, READ),
	getIDiskTemperature:new Cmd('configure terminal smart showDiskTemperature %s', getIDiskTemperature, READ),
	getIDiskPerformance:new Cmd('configure terminal smart showDiskPerformance %s', getIDiskPerformance, READ),
	getIDiskInfo:new Cmd('configure terminal smart showDiskInfo %s', getIDiskInfo, READ),
	getIDiskAttribute:new Cmd('configure terminal smart showAttribute %s', getIDiskAttribute, READ),
	getIDiskBriefList: new Cmd("storage getIDiskInfo", getIDiskBriefList, READ),
	getIRaid: new Cmd("storage showMDInfo", getIRaid, READ),
	getIRaidCapacity: new Cmd("storage showVGInfo", getIRaidCapacity, READ),
	getIRaidFreeSpace: new Cmd("storage showVGInfo %s", getIRaidFreeSpace, READ),
	getDefaultIRaidLabel : new Cmd('storage getDefaultVGLabel %s %s', getDefaultIRaidLabel, READ),
	getIFreeDisk : new Cmd("storage showFreeDisks", getIFreeDisk, READ),
	getAvailableConfig: new Cmd('storage showAvailableConfig', getAvailableConfig, READ ),
	createIRaid: new Cmd('storage createVG "%s" %s %s', null, READ ),
	getCreateIRaidProgress: new Cmd('storage showVGCreatingProgress', getProgress, READ ),
	renameIRaid: new Cmd('storage relabelMD %s "%s"',null, READ ),
	deleteIRaid: new Cmd('storage deleteVG %s %s', null, READ),
	repairRaid: new Cmd('storage repairMD %s %s', null, READ ),
	getResyncSpeed:new Cmd('storage showResyncSpeed %s', getResyncSpeed, READ ),
	modifyResyncSpeed: new Cmd('storage modifyResyncSpeed %s %s', null, READ ),
	getRemoveSpareDisk:new Cmd('storage showIDiskSpare %s', getRemoveSpareDisk, READ ),
	removeSpare: new Cmd('storage removespare %s %s', null, READ ),
	expandJBOD: new Cmd('storage jbodAddDisk %s %s', null, READ ),
	getExpandJBODProgress: new Cmd('storage show_expandMDpro', getProgress, READ ),
	reshapeRAID5: new Cmd('storage raid5Reshape %s %s', null, READ ),
	getReshapeRaid5Progress: new Cmd('storage show_raid5ReshapeMDpro', getProgress, READ ),
	addHotSpare: new Cmd('storage addspare %s %s', null, READ ),
	getIVolume: new Cmd('storage showLVInfo', getIVolume, READ),
	getSpecificIVolume: new Cmd('storage showLVInfo %s', getIVolume, READ),
	getIVolumeSelectList: new Cmd('storage showLVInfo', getIVolumeSelectList, READ),
	getIVolumeList: new Cmd('storage showLVlist', getIVolumeList, READ),
	createNorIVol:new Cmd('storage createLVNormal "%s" %s %s', null, READ ),
	createCryPasIVol:new Cmd('storage createLVCryPasswd "%s" %s %s "%s" "%s"', null, READ ),
	createCryUsbIVol:new Cmd('storage createLVCryUSB "%s" %s %s %s', null, READ ),
	getCreateCryIVolProgress:new Cmd('storage showLVCryCreatingPro', getProgress, READ ),
	getCreateNorIVolProgress:new Cmd('storage showLVNorCreatingPro', getProgress, READ ),
	createUsbKey:new Cmd('storage createEKey "%s" %s', null, READ ),
	createDuplicateUsbKey:new Cmd('storage duplicateEKey "%s" %s', null, READ ),
	renameIVol: new Cmd('storage renameLV %s "%s"', null, READ ),
	expandIVol: new Cmd('storage expandLV %s %s', null, READ ),
	getExpandIVolProgress:new Cmd('storage show_expandLVpro', getProgress, READ ),
	modifyCryIVolPassword:new Cmd('storage changeLVPass %s "%s" "%s"', null, READ ),
	modifyCryIVolPrompt:new Cmd('storage changeLVPassPrompt  %s "%s"', null, READ ),
	lockVolume:new Cmd('storage lockLV %s', null, READ),
	unlockVolume:new Cmd('storage unlockLV %s "%s"', null, READ),
	getDefaultIVolName : new Cmd('storage getDefaultVolName', getDefaultIVolName, READ),
	getIPasswordPrompt:new Cmd('storage showLVPrompt %s', getPasswordPrompt, READ),
	deleteIVolList: new Cmd('storage batchDeleteVolAddList %s', null, READ),
	deleteIVolListRun: new Cmd('storage batchDeleteVolRun', null, READ),
	deleteIVol: new Cmd('storage deleteLV %s', null, READ),
	//External Storage
	getEDisk: new Cmd("storage getEDisksInfo", getEDisk, READ),
	getEDiskSelectList: new Cmd("storage getEDisksInfo", getEDiskSelectList, READ),
	getAssignEDisk: new Cmd("storage getEDisksInfo %s", getEDisk, READ),
	getEVolume: new Cmd("storage getEVolumeInfo", getEVolume, READ),
	ejectEDisk: new Cmd('storage ejectEDisk %s %s', null, READ),
	getEPasswordPrompt:new Cmd('storage showEXTPrompt %s', getPasswordPrompt, READ),
	getEVolumeSelectList: new Cmd('storage getEVolumeInfo', getEVolumeSelectList, READ),
	getCreateEVolProgress: new Cmd('storage showEVolumeProgress', getProgress, READ),
	locateEDisk: new Cmd('storage locateEDisk %s %s', null, READ ),
	getDefaultEVolName : new Cmd('storage getExtVolName %s', getDefaultEVolName, READ),
	getDefaultFileSystem : new Cmd('storage showDefaultFS', getDefaultFileSystem, READ),
	createNorEVol:new Cmd('storage createEVolume "%s" %s %s', null, READ ),
	createCryPasEVol:new Cmd('storage createECryPasswd "%s" %s "%s" "%s"', null, READ ),
	createCryUsbEVol:new Cmd('storage createECryUSB "%s" %s %s', null, READ ),
	renameEVol: new Cmd('storage renameEVolume %s "%s"',null, READ ),
	modifyCryEVolPassword:new Cmd('storage changeEXTPass %s "%s" "%s"', null, READ ),
	modifyCryEVolPrompt:new Cmd('storage changeEXTPassPrompt %s "%s"', null, READ ),
	lockEVolume:new Cmd('storage lockEXT %s', null, READ),
	unlockEVolume:new Cmd('storage unlockEXT %s "%s"', null, READ),
	//volName devNode AutoFix(y or n)
	scanIVolume: new Cmd('storage scanLV %s %s', null, READ ),
	scanIVolumeCancel: new Cmd('storage scanLVCancel %s', null, READ ),
	scanIVolumeProgress: new Cmd('storage scanLVProgress', getScanVolProgress, READ ),
	scanEVolume: new Cmd( 'storage scanEVolume "%s" %s %s',null, READ ),
	scanEVolumeCancel: new Cmd('storage scanEVolumeCancel "%s" %s', null, READ ),
	scanEVolumeProgress: new Cmd('storage scanEVolumeProgress', getScanVolProgress, READ),
	scanInfo: new Cmd('storage showScanInfo', getScanInfo, READ ),
	getSysVolume: new Cmd('storage showSysvol', getSysVolume, READ),
	/* System command definitions */
	getModelName: new Cmd("show system modelname", getModelName, READ),
	reboot: new Cmd("reboot", null, READ),
	shutdown: new Cmd("shutdown", null, READ),
	getFirmwareVersion: new Cmd("show system fwversion", getFirmwareVersion, READ),
	getIDiskSleepTime : new Cmd("configure terminal dsuspd getSuspdTime", getIDiskSleepTime, READ),
	setIDiskSleepTime : new Cmd("configure terminal dsuspd setSuspdTime %s", null,WRITE),
	getRomChecksum: new Cmd("mrd show romfilechecksum", getRomChecksum, READ),
	getZLDChecksum: new Cmd("mrd show zldchecksum", getZLDChecksum, READ),
	getCoreChecksum: new Cmd("mrd show corechecksum", getCoreChecksum, READ),
	getActiveSession: new Cmd("show session", getActiveSession, READ),
	getFirmwarePercentage: new Cmd("show firmware percentage", getFirmwarePercentage, READ),
	loadDefault:new Cmd("load default", null,WRITE),
	getCpuUsageInfo: new Cmd("configure terminal show cpu status", getCpuUsageInfo, READ),
	getCpuTemperatureInfo: new Cmd("configure terminal show cpu temperature", getCpuTemperatureInfo, READ),
	getFanSpeedInfo: new Cmd("configure terminal show fan-speed", getFanSpeedInfo, READ),
	getMemoryUsageInfo: new Cmd("show mem status", getMemoryUsageInfo, READ),
	getUPSInfo : new Cmd("configure terminal apc showPowerCapacity", getUPSInfo, READ),
	getUpsShutdownCapacity : new Cmd("configure terminal apc getShutdownCapacity", getUpsShutdownCapacity, READ),
	setUpsShutdownCapacity : new Cmd("configure terminal apc setShutdownCapacity %s", null,WRITE),
	/* Printer server command definitions */
	printerGetStatus: new Cmd("configure terminal printer query", printerGetStatus, READ),
	printerCancelJob1: new Cmd("configure terminal printer canceljob %s", null, READ),
	printerModifyName2: new Cmd("configure terminal printer modify %s %s", null,WRITE),
	printerDelete1: new Cmd("configure terminal printer delete %s", null,WRITE),
	/*NFS command definitions*/
	getNFSStatus: new Cmd("nfs status", getNFSStatus, READ),
	showAllNfsShare: new Cmd("nfs showall", showAllNfsShare, READ),
	showFilter: new Cmd('nfs showfilter "%s"', showFilter, READ),
	isPathCreated:new Cmd('nfs exported "%s"', isPathCreated, READ),
	showNfsSession:new Cmd('nfs showsession', showNfsSession, READ),
	addNfsShare: new Cmd('nfs exports "%s" %s %s %s "%s"', null,WRITE),
	addNfsShareFilter: new Cmd('nfs append "%s" %s %s %s', null,WRITE),
	delNfsShare: new Cmd('nfs remove "%s"', null,WRITE),
	delNfsShareFile: new Cmd('nfs delete_files "%s"', null,WRITE),
	enableNFS: new Cmd("nfs enable", null,WRITE),
	disableNFS: new Cmd("nfs disable", null,WRITE),
	/* Networking command definitions */
	systemStop: new Cmd("configure terminal system stop", null, READ),
	systemStart: new Cmd("configure terminal system start", null, READ),
	networkShowEther: new Cmd("show interface ethernet", networkShowEther, READ),
	networkShowInterface1: new Cmd("show interface ge1", networkShowInterface1, READ),
	networkShowInterface2: new Cmd("show interface ge2", networkShowInterface2, READ),
	networkShowBond0: new Cmd("show interface bond0", networkShowBond0, READ),
	networkConfigIp3: new Cmd("configure terminal interface %s ip address %s %s", null,WRITE),
	networkConfigGateWay3: new Cmd("configure terminal interface %s ip gateway %s metric %s", null,WRITE),
	networkConfigMtu: new Cmd("configure terminal interface %s mtu %s", null,WRITE),
	networkEnableDhcp2: new Cmd("configure terminal interface %s ip address dhcp metric %s", null,WRITE),
	networkDisableDhcp1: new Cmd("configure terminal interface %s no ip address dhcp", null,WRITE),
	networkDisableStatic1: new Cmd("configure terminal interface bond0 no ip address %s %s", null,WRITE),
	networkDisableStatic2: new Cmd("configure terminal interface bond0 no ip gateway", null,WRITE),
	networkConfigNoMtu: new Cmd("configure terminal interface bond0 no mtu", null,WRITE),
	networkConfigExit1: new Cmd("configure terminal interface %s exit", null,WRITE),
	networkShowBondingConfig: new Cmd("show bonding config", networkMode, READ),
	networkEnableBonding :new Cmd("configure terminal bonding activate", null,WRITE),
	networkDisableBonding : new Cmd("configure terminal no bonding activate", null,WRITE),
	networkBondingMode1 : new Cmd("configure terminal bonding mode %s", null,WRITE),
	networkBondingNoMode : new Cmd("configure terminal no bonding mode", null,WRITE),
	networkInterfaceShutdown1: new Cmd("configure terminal interface %s shutdown", null,WRITE),
	networkInterfaceNoShutdown1: new Cmd("configure terminal interface %s no shutdown", null,WRITE),
	networkShowAllInterface: new Cmd("show interface all", networkShowAllInterface, READ),
	networkShowGe1Status1: new Cmd("show interface ge1 link", networkShowGe1Status1, READ),
	networkShowGe2Status1: new Cmd("show interface ge2 link", networkShowGe2Status1, READ),
	ping: new Cmd("ping %s", null, READ),
	//networkIP3: new Cmd("%s ip address %s %s", networkIP3),
	//networkGateWay1: new Cmd("%s ip gateway", networkGateWay1),
	//networkInterface1: new Cmd("interface %s", networkInterface1),
	//networkExit: new Cmd("exit", null),
	/* DNS command definitions */
	dnsShowNameServer: new Cmd("show ip name-server", dnsShowNameServer, READ),
	dnsConfigNameServer2: new Cmd("configure terminal ip name-server %s %s", null,WRITE),
	dnsConfigNameServerDynamic1: new Cmd("configure terminal %s name-server dynamic", null,WRITE),
	//dnsConfigNoNameServer: new Cmd("configure terminal no ip name-server", null),
	dnsConfigNameServerAuto: new Cmd("configure terminal ip name-server fetch auto", null,WRITE),
	dnsConfigNameServerManually: new Cmd("configure terminal ip name-server fetch manually", null,WRITE),
	/* FTP command definitions */
	ftpShowServerStatus: new Cmd("show ip ftp server status", ftpShowServerStatus, READ),
	ftpEnableServer: new Cmd("configure terminal ip ftp server", null,WRITE),
	ftpDisableServer: new Cmd("configure terminal no ip ftp server", null,WRITE),
	ftpEnableServerAnonymous: new Cmd("configure terminal ip ftp server anonymous", null,WRITE),
	ftpDisableServerAnonymous: new Cmd("configure terminal no ip ftp server anonymous", null,WRITE),
	ftpConfigConnLimit1: new Cmd("configure terminal ip ftp server conn-limit %s", null,WRITE),
	ftpConfigServerTimeout1: new Cmd("configure terminal ip ftp server timeout %s", null,WRITE),
	ftpConfigCharSet1: new Cmd("configure terminal ip ftp server charset client %s", null,WRITE),
	/* Logging command definitions */
	VlogShowAllEntriesAmount: new Cmd('configure terminal show logging disk entries query_count', VlogEntriesAmount, READ),
	VlogNormalQueryEntriesAmount: new Cmd('configure terminal show logging disk entries query_op and %s query_count', VlogEntriesAmount, READ),
	VlogQuicklyShowAllEntries: new Cmd('show querylog firstpage', VlogShowAllEntries, READ),
	VlogShowAllEntries: new Cmd('configure terminal show logging disk entries uusn %s begin %s end %s', VlogShowAllEntries, READ),
	VlogNormalQueryEntries: new Cmd('configure terminal show logging disk entries uusn %s query_op and %s begin %s end %s', VlogShowAllEntries, READ),
	VlogShowDBStatus: new Cmd('configure terminal show logging status disk', VlogShowDBStatus, READ),
	VlogSetSavePath: new Cmd('configure terminal logging disk save-path "/%s"', null,WRITE),
	VlogSetKeepMonths: new Cmd('configure terminal logging disk save-period %s', null,WRITE),
	VlogClearBuffer: new Cmd('clear logging system-log buffer', null, READ),
	VlogEnableMailLog: new Cmd('configure terminal logging mail %s', null,WRITE),
	VlogDisableMailLog: new Cmd('configure terminal no logging mail %s', null,WRITE),
	VlogMailLogTo: new Cmd('configure terminal logging mail %s send-log-to %s', null,WRITE),
	VlogNoMailLogTo: new Cmd('configure terminal no logging mail %s send-log-to', null,WRITE),
	VlogMailAlertTo: new Cmd('configure terminal logging mail %s send-alerts-to %s', null,WRITE),
	VlogNoMailAlertTo: new Cmd('configure terminal no logging mail %s send-alerts-to', null,WRITE),
	VlogMailFrom: new Cmd('configure terminal logging mail %s from %s', null,WRITE),
	VlogNoMailFrom: new Cmd('configure terminal no logging mail %s from', null,WRITE),
	VlogMailServer: new Cmd('configure terminal logging mail %s address %s', null,WRITE),
	VlogNoMailServer: new Cmd('configure terminal no logging mail %s address', null,WRITE),
	VlogSetMailSubject: new Cmd('configure terminal logging mail %s subject %s', null,WRITE),
	VlogNoSetMailSubject: new Cmd('configure terminal no logging mail %s subject', null,WRITE),
	VlogSetMailFormat: new Cmd('configure terminal logging mail %s format %s', null,WRITE),
	VlogEnableSMTP: new Cmd('configure terminal logging mail %s authentication', null,WRITE),
	VlogSetSMTPInfo: new Cmd('configure terminal logging mail %s authentication username %s password "%s"', null,WRITE),
	VlogUnsetSMTPInfo: new Cmd('configure terminal no logging mail %s authentication username', null,WRITE),
	VlogMailLogByCategory: new Cmd('configure terminal logging mail %s category %s level %s', null,WRITE),
	VlogNoMailLogByCategory: new Cmd('configure terminal no logging mail %s category %s level %s', null,WRITE),
	VlogSetMailSchedule: new Cmd('configure terminal logging mail %s schedule %s %s', null,WRITE),
	VlogQueryMailReportSetting: new Cmd('configure terminal show logging status mail', VlogQueryMailReportSetting, READ),
	VlogQuerySyslogServer: new Cmd('configure terminal show logging status syslog', VlogQuerySyslogServer, READ),
	VlogSyslogByCategory: new Cmd('configure terminal logging syslog %s category %s level normal', null,WRITE),
	VlogNoSyslogByCategory: new Cmd('configure terminal no logging syslog %s category %s', null,WRITE),
	VlogSyslogServerAddress: new Cmd('configure terminal logging syslog %s address %s', null,WRITE),
	VlogNoSyslogServerAddress: new Cmd('configure terminal no logging syslog %s address', null,WRITE),
	VlogEnableSyslog: new Cmd('configure terminal logging syslog %s', null,WRITE),
	VlogDisableSyslog: new Cmd('configure terminal no logging syslog %s', null,WRITE),
	VlogSendTestMail: new Cmd('configure terminal logging mail test server %s from %s to %s', VlogSendTestMail, READ),
	VlogSendTestMailSMTPWithPassword: new Cmd('configure terminal logging mail test server %s from %s to %s user %s passwd "%s"', VlogSendTestMail, READ),
	VlogSendTestMailSMTPWithoutPassword: new Cmd('configure terminal logging mail test server %s from %s to %s user %s', VlogSendTestMail, READ),
	getQueryLogProgress: new Cmd("show querylog progress uusn %s", getProgress, READ),
	getQueryLogResult: new Cmd("show querylog result uusn %s", VlogShowAllEntries, READ),
	/* Date/Time command definitions */
	clockShowTime: new Cmd("show clock time", clockShowTime, READ),
	clockShowDate: new Cmd("show clock date", clockShowDate, READ),
	clockNTPShowServer: new Cmd("show ntp server", clockNTPShowServer, READ),
	clockNTPEnable1: new Cmd("configure terminal ntp server %s", null,WRITE),
	clockNTPEnable: new Cmd("configure terminal ntp", null,WRITE),
	clockNTPSync: new Cmd("configure terminal ntp sync", null, READ),
	clockNTPDisable: new Cmd("configure terminal no ntp", null,WRITE),
	clockDlsShowStatus: new Cmd("show clock status", clockDlsShowStatus, READ),
	clockDlsEnable: new Cmd("configure terminal clock daylight-saving", null,WRITE),
	clockDlsDisable: new Cmd("configure terminal no clock daylight-saving", null,WRITE),
	clockConfigTimeZone1: new Cmd("configure terminal clock time-zone %s", null,WRITE),
	clockConfigClock2: new Cmd("configure terminal clock date %s time %s", null, READ),
	clockConfigDls9: new Cmd("configure terminal clock saving-interval begin %s %s %s %s end %s %s %s %s %s", null,WRITE),
	/* copy button setting*/
	setCopyBtn: new Cmd('configure terminal config btncpy set %s "%s"', null,WRITE),
	delCopyBtn: new Cmd("configure terminal config btncpy delete", null, READ),
	showCopyBtn: new Cmd("configure terminal config btncpy show", showCopyBtn, READ),
	/* File copy & move command definitions */
	fileCopy4: new Cmd('file cp 0 "%s" "%s" "%s" "%s"', null, READ),
	fileMove4: new Cmd('file mv 0 "%s" "%s" "%s" "%s"', null, READ),
	fileGetStatus: new Cmd('file query status', fileGetStatus, READ),
	/* Backup Restoring */
	//restore by job
	queryRestoringJobInfo: new Cmd('job_controller query_progress restore "%s"', queryRestoringJobInfo, READ),
	queryRestoringRunTimeByJob: new Cmd('job_controller query restore runs "%s"', queryRestoringRunTimeByJob, READ),
	queryRestoringFolderByJob: new Cmd('job_controller query restore folders "%s" "%s" "%s"', queryRestoringFolderByJob, READ),
	restoreByJobGo: new Cmd('job_controller run restore joblist go "%s" "%s" "%s" "%s"', null, READ),
	restoreByTargetGo5: new Cmd('job_controller run restore target go "%s" "%s" "%s" "%s" "%s"', null, READ),
	restoreByJobGo5: new Cmd('job_controller run restore joblist go "%s" "%s" "%s" "%s" "%s"', null, READ),

	testRemoteConnection4: new Cmd('test_connection "%s" "%s" "%s" "%s"', testRemoteConnection4, READ),
	mountRemoteShare: new Cmd('connect_remote_share "%s" "%s" "%s" "%s"', mountRemoteShare, READ),
	umountRemoteShare: new Cmd('disconnect_remote_share "%s"', null, READ),
	queryRestoringRemoteJobName: new Cmd('job_controller query restore remote t_jobs "%s"', queryRestoringRemoteJobName, READ),
	queryRestoringRemoteRuntime: new Cmd('job_controller query restore remote t_runs "%s" "%s"', queryRestoringRemoteRuntime, READ),
	queryRestoringLocalRuntime: new Cmd('job_controller query restore local t_runs "%s"', queryRestoringLocalRuntime, READ),
	queryRestoringRemoteFolder: new Cmd('job_controller query restore remote t_folders "%s" "%s" "%s" "%s"', queryRestoringRemoteFolder, READ),
	queryRestoringLocalFolder: new Cmd('job_controller query restore local t_folders "%s" "%s" "%s"', queryRestoringLocalFolder, READ),

	restoreSetNecessaryData1: new Cmd('job_controller run restore src_info "%s"', null, READ),

	/*Backup*/
	backupSetNecessaryData2: new Cmd('job_controller run source src_info "%s" "%ls:"', null, READ),

	backupCreateFullLocal10: new Cmd('job_controller add backup full_local "%s" "%s" %s "%s" "%s" "%s" %s %s "%s" %s', null, READ),
	backupCreateFullRemote13: new Cmd('job_controller add backup full_remote "%s" "%s" %s "%s" "%s" "%s" "%s" "%s" "%s" %s %s "%s" %s ', null, READ),
	backupCreateIncreLocal11: new Cmd('job_controller add backup incre_local "%s" "%s" %s "%s" "%s" "%s" %s %s %s "%s" %s', null, READ),
	backupCreateIncreRemote14: new Cmd('job_controller add backup incre_remote "%s" "%s" %s "%s" "%s" "%s" "%s" "%s" "%s" %s %s %s "%s" %s', null, READ),
	backupCreateMirrorLocal6: new Cmd('job_controller add backup mirror_local "%s" "%s" %s "%s" "%s" "%s"', null, READ),
	backupCreateMirrorRemote11: new Cmd('job_controller add backup mirror_remote "%s" "%s" %s "%s" "%s" "%s" "%s" "%s" "%s" %s %s', null, READ),
	backupCreatePublishLocal6: new Cmd('job_controller add backup sync_local "%s" "%s" %s "%s" "%s" "%s"', null, READ),
	backupCreatePublishRemote11: new Cmd('job_controller add backup sync_remote "%s" "%s" %s "%s" "%s" "%s" "%s" "%s" "%s" %s %s', null, READ),

	backupEditSingleJob4: new Cmd('job_controller modify backup "%s" "%s" %s %s', null, READ),
	backupQueryAll: new Cmd('job_controller display backup', backupQueryAll, READ),
	backupQuerySyncRemote4: new Cmd('show_zysync_server_contents "%s" "%s" "%s" "%s"', backupQuerySyncRemote4, READ),
	backupRunSingleJob2: new Cmd('job_controller run backup "%s" %s', backupRunSingleJob2, READ),
	backupDeleteSingleJob2: new Cmd('job_controller delete backup "%s" "%s"', backupDeleteSingleJob2, READ),
	backupAbortSingleJob2: new Cmd('job_controller cancel backup "%s" %s', backupAbortSingleJob2, READ),
	backupQueryProgress1: new Cmd('job_controller query_progress backup "%s"', backupQueryProgress1, READ),
	backupQueryRemoteShare1: new Cmd('show_remote_smb_shares "%s"', backupQueryRemoteShare1, READ),
	backupQueryRestoreProgress1: new Cmd('job_controller query_progress restore "%s"', backupQueryRestoreProgress1, READ),
	//show_remote_smb_shares
	/*Scheduler*/
	schedulerAddHourly4: new Cmd('job_controller add schedule hourly "%s" %s "%s" "%s"', null, READ),
	schedulerAddDaily4: new Cmd('job_controller add schedule daily "%s" %s "%s" "%s"', null, READ),
	schedulerQuerySingleJob1: new Cmd('job_controller query schedule "%s" %s', schedulerQuerySingleJob1, READ),
	schedulerAddWeekly5: new Cmd('job_controller add schedule weekly "%s" %s "%s" "%s" "%s"', null, READ),
	schedulerAddMonthlyRegular5: new Cmd('job_controller add schedule monthly_day "%s" %s "%s" "%s" "%s"', null, READ),
	schedulerAddMonthlyManual6: new Cmd('job_controller add schedule monthly_week "%s" %s "%s" "%s" "%s" "%s"', null, READ),

	schedulerEditSingleJob8: new Cmd('job_controller modify schedule "%s" %s "%s" "%s" "%s" "%s" "%s" "%s"', null, READ),
	/*Snapshot*/
	createSnapshot : new Cmd('job_controller add snapshot "%s" "%s" %s', null, READ),
	modifySnapshotJob: new Cmd('job_controller modify snapshot "%s" %s', null, READ),
	deleteSnapshotJob: new Cmd('job_controller delete snapshot "%s" "%s"', backupDeleteSingleJob2, READ),
	getSnapshotJob : new Cmd("job_controller display snapshot", getSnapshotJob, READ),
	getSnapshotAll : new Cmd("storage querySnapAll", getSnapshotAll, READ),
	getSnapshotByVol : new Cmd("storage querySnapLV %s", getSnapshotAll, READ),
	deleteSnapshotList: new Cmd('storage batchDeleteSnapAddList %s', null, READ),
	deleteSnapshotListRun: new Cmd('storage batchDeleteSnapRun', null, READ),
	deleteSnapshot: new Cmd('storage deleteSnap %s', null, READ),
	getSnapshotShareStatus : new Cmd("storage snapShareStatus", getSnapshotShareStatus, READ),
	enableSnapshotShare: new Cmd('storage enableSnapShare', null,WRITE),
	disableSnapshotShare: new Cmd('storage disableSnapShare', null,WRITE),
	getSnapshotCapacity: new Cmd('storage querySnapUsageSum', getSnapshotCapacity, READ),
	/*Buzzer*/
	getBuzzerStatus : new Cmd('configure terminal show logging buzzer', getBuzzerStatus, READ),
	getMyNsaBuzzerStatus : new Cmd('show logging buzzer', getBuzzerStatus, READ),
	showBuzzerAllEntries : new Cmd('configure terminal show logging buzzer entries', VlogShowAllEntries, READ),
	showBuzzerAllEntriesAmount : new Cmd('configure terminal show logging buzzer entries query_count', showBuzzerAllEntriesAmount, READ),
	stopSoundingBuzzer :new Cmd('configure terminal logging buzzer stop', null, READ),
	disableBuzzer :new Cmd('configure terminal no logging buzzer', null, WRITE),
	setBuzzerPriority :new Cmd('configure terminal logging buzzer priority %s', null, WRITE),
	showSystemStatus : new Cmd('show system state', showSystemStatus, READ),
	setSystemStatus : new Cmd('configure terminal state set %s', null, WRITE),
	powerOnStatus : new Cmd('pwron status', powerOnStatus, READ),
	setPowerOnStatus : new Cmd('pwron %s', null, WRITE),
	/*powerOff/On reboot Schedule*/
	showPowerSchStatus : new Cmd('job_controller pwr_schedule get', showPowerSchStatus, READ),
	setPowerSchStatus : new Cmd('job_controller pwr_schedule set %s', null, WRITE),
	showPwrSchList : new Cmd('job_controller display pwr_schedule', showPwrSchList, READ),
	delAllPwrSch : new Cmd('job_controller pwr_schedule clearall', null, WRITE)
	//job_controller modify schedule
	/*other*/
};

/* Action definitions */
var actionPool = {
	getServerInfo: ["getServerName", "getServerDescription", "getServerWorkgroup"],
	getStorageInfo: ["getIDisk","getEDisk","getEVolume","getIVolume"],
	addUser: ["addUserAccount","addUserQuota", "exit", "exit", "addUserPassword"]
};

