def create_dev(self, address=None, lun_size=None, pool_name=None, lu=None, lun_name=None, lun_type="NonThin"): """ Create LUN on specific pool :param address: address of storage :param lun_size: size of lun in GB (ex: 50GB) :param pool_name: pool name :param lu: LUN ID on pool :param lun_name: Name of LUN :param lun_type: Type of LUN (Default: NonThin) :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ create_dev_cmd = "{0} -h {1} lun -create -type {6} -capacity {2} " \ "-sq gb -poolName \'{3}\' -aa 1 -l \'{4}\' " \ "-name \'{5}\'".format( self.naviseccli_path, address, lun_size, pool_name, lu, lun_name, lun_type ) create_dev_cmd_out = runsub.cmd(create_dev_cmd, shell=True) return create_dev_cmd_out
def mapping_dev(self, stggroup='None', hlu='None', alu='None'): """ Add (Mapping) of LUN to Storage Group Name :param stggroup: Storage Group Name :param hlu: HLU to be used on Storage Group Name :param alu: LUN ID (lu) :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ mapping_dev_cmd = "{0} -h {1} -user {2} -password {3} -scope {4} " \ "storagegroup -addhlu -gname \'{5}\' -hlu {6} " \ "-alu {7}" \ .format( self.naviseccli_path, self.fst_address, self.user, self.password, self.scope, stggroup, hlu, alu) mapping_dev_cmd_out = runsub.cmd(mapping_dev_cmd, shell=True) return mapping_dev_cmd_out
def get_luns(self, pool_name='None'): """Get all LUNs IDs used by pool sorted. :param pool_name: the pool name see pool_list() :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ list_luns_cmd = "{0} -h {1} storagepool -list -name \'{2}\'".format( self.naviseccli_path, self.fst_address, pool_name) list_luns_out = runsub.cmd(list_luns_cmd, shell=True) luns_ids = [] if list_luns_out[0] == 0: for line in list_luns_out[1].split('\n'): if line.startswith('LUNs:'): luns_id_nf = line.split('LUNs: ')[1].strip() for id_lines in luns_id_nf.split(','): luns_ids.append(id_lines.strip()) luns_ids.sort(key=int) if len(luns_ids) == 0: return 1, 'No LUNs founds in Storage Pool \'{0}\''.format( pool_name) else: return 0, luns_ids
def create_dev(self, address=None, lun_size=None, pool_name=None, lu=None, lun_name=None, lun_type="NonThin"): """Create LUN on specific pool :param address: address of storage :param lun_size: size of lun in GB (ex: 50GB) :param pool_name: pool name :param lu: LUN ID on pool :param lun_name: Name of LUN :param lun_type: Type of LUN (Default: NonThin) :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ create_dev_cmd = "{0} -h {1} lun -create -type {6} -capacity {2} " \ "-sq gb -poolName {3} -aa 1 -l {4} -name " \ "{5}".format(self.naviseccli_path, address, lun_size, pool_name, lu, lun_name, lun_type) create_dev_cmd_out = runsub.cmd(create_dev_cmd, shell=True) return create_dev_cmd_out
def mapping_dev(self, stggroup='None', hlu='None', alu='None'): """Add (Mapping) of LUN to Storage Group Name :param stggroup: Storage Group Name :param hlu: HLU to be used on Storage Group Name :param alu: LUN ID (lu) :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ mapping_dev_cmd = "{0} -h {1} -user {2} -password {3} -scope {4} " \ "storagegroup -addhlu -gname {5} -hlu {6} -alu " \ "{7}".format(self.naviseccli_path, self.fst_address, self.user, self.password, self.scope, stggroup, hlu, alu) mapping_dev_cmd_out = runsub.cmd(mapping_dev_cmd, shell=True) return mapping_dev_cmd_out
def get_luns(self, pool_name='None'): """ Get all LUNs IDs used by pool sorted. :param pool_name: the pool name see pool_list() :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ list_luns_cmd = "{0} -h {1} storagepool -list -name \'{2}\'".format( self.naviseccli_path, self.fst_address, pool_name) list_luns_out = runsub.cmd(list_luns_cmd, shell=True) luns_ids =[] if list_luns_out[0] == 0: for line in list_luns_out[1].split('\n'): if line.startswith('LUNs:'): luns_id_nf = line.split('LUNs: ')[1].strip() for id_lines in luns_id_nf.split(','): luns_ids.append(id_lines.strip()) luns_ids.sort(key=int) if len(luns_ids) == 0: return 1, 'No LUNs founds in Storage Pool \'{0}\''.format(pool_name) else: return 0, luns_ids
def list(self): """Get informations about all available Storages :return: the return code and list of storages """ symcfg_list_cmd = '{0}/symcfg list'.format(self.symcli_path) symcfg_list_out = runsub.cmd(symcfg_list_cmd) return symcfg_list_out
def list(self): """ Get informations about all available Storages :return: the return code and list of storages """ symcfg_list_cmd = '{0}/symcfg list'.format(self.symcli_path) symcfg_list_out = runsub.cmd(symcfg_list_cmd) return symcfg_list_out
def lsextpool(self, args=''): """ Get the available pools on DS. :param args: use to pass some arguments such as -l . :return: array as [return code, output]. """ lsextpool_cmd = '{0} lsextpool {1}'.format(self.base_cmd, args) lsextpool_out = runsub.cmd(lsextpool_cmd) return lsextpool_out
def _init_vnx(self): """ Initialize the VNX session adding user security scope auth for the shell session/user. """ init_1ip_cmd = '{0} -h {1} -addusersecurity -user {2} ' \ '-password {3} -scope {4}'.format(self.naviseccli_path, self.fst_address, self.user, self.password, self.scope) init_2ip_cmd = '{0} -h {1} -addusersecurity -user {2} ' \ '-password {3} -scope {4}'.format(self.naviseccli_path, self.sec_address, self.user, self.password, self.scope) runsub.cmd(init_1ip_cmd) runsub.cmd(init_2ip_cmd)
def _init_vnx(self): """Initialize the VNX session. Initialize the VNX session adding user security scope auth for the shell session/user. """ init_1ip_cmd = '{0} -h {1} -addusersecurity -user {2} ' \ '-password {3} -scope {4}'.format(self.naviseccli_path, self.fst_address, self.user, self.password, self.scope) init_2ip_cmd = '{0} -h {1} -addusersecurity -user {2} ' \ '-password {3} -scope {4}'.format(self.naviseccli_path, self.sec_address, self.user, self.password, self.scope) runsub.cmd(init_1ip_cmd) runsub.cmd(init_2ip_cmd)
def port_list_all(self): """List all port (servers/hosts) from VNX configured. :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ port_list_cmd = '{0} -h {1} port -list'.format(self.naviseccli_path, self.fst_address) port_list_out = runsub.cmd(port_list_cmd) return port_list_out
def mvn(self, sid='', ign=''): """Get the Mask View Names informations by the Initiator Group Name. :param sid: Identification of VMAX (SID). :param ign: Initiator Group Name. check get_ign() or ign(). :return: the return code and full Mask View Name informations. """ mvn_cmd = "{0}/symaccess -sid {1} -type init show {2}".format( self.symcli_path, sid, ign) mvn_out = runsub.cmd(mvn_cmd) return mvn_out
def chvolgrp(self, vol_address, vol_group): """Add a volume in another volume group. :param vol_address: volume addres from the LUN :param vol_group: volume group ID :return: array as [return code, output]. """ chvolgrp_cmd = '{0} chvolgrp -action add -volume {1} {2}' \ .format(self.base_cmd, vol_address, vol_group) chvolgrp_out = runsub.cmd(chvolgrp_cmd) return chvolgrp_out
def mvn(self, sid='', ign=''): """ Get the Mask View Names with full informations using the Initiator Group Name. :param sid: Identification of VMAX (SID). :param ign: Initiator Group Name. check get_ign() or ign(). :return: the return code and full Mask View Name informations. """ mvn_cmd = "{0}/symaccess -sid {1} -type init show {2}".format( self.symcli_path, sid, ign) mvn_out = runsub.cmd(mvn_cmd) return mvn_out
def chvolgrp(self, vol_address, vol_group): """ Add a volume in another volume group. :param vol_address: volume addres from the LUN :param vol_group: volume group ID :return: array as [return code, output]. """ chvolgrp_cmd = '{0} chvolgrp -action add -volume {1} -volgrp {2}' \ .format(self.base_cmd, vol_address, vol_group) chvolgrp_out = runsub.cmd(chvolgrp_cmd) return chvolgrp_out
def pools(self): """List all storage pools from VNX :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ self._init_vnx() pools_cmd = '{0} -h {1} storagepool -list'.format( self.naviseccli_path, self.fst_address) pools_out = runsub.cmd(pools_cmd) return pools_out
def ign(self, sid='', wwn=''): """ Get Initial Group Name (IGN) full output by the WWN. :param sid: Identification of VMAX (SID). :param wwn: wwn client. :return: array with return code and full output of IGN. """ self.validate_args() ign_cmd = "{0}/symaccess -sid {1} -type init list -wwn {2}".format( self.symcli_path, sid, wwn) ign_out = runsub.cmd(ign_cmd) return ign_out
def show_lun(self, lun_id): """Get information about specific LUN ID. :param lun_id: LUN ID (string) :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ show_lun_cmd = "{0} -h {1} lun -list -l {2}".format( self.naviseccli_path, self.fst_address, lun_id) show_lun_out = runsub.cmd(show_lun_cmd) return show_lun_out
def ign(self, sid='', wwn=''): """Get Initial Group Name (IGN) full output by the WWN. :param sid: Identification of VMAX (SID). :param wwn: wwn client. :return: array with return code and full output of IGN. """ self.validate_args() ign_cmd = "{0}/symaccess -sid {1} -type init list -wwn {2}".format( self.symcli_path, sid, wwn) ign_out = runsub.cmd(ign_cmd) return ign_out
def port_list_all(self): """ List all port (servers/hosts) from VNX configured. :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ port_list_cmd = '{0} -h {1} port -list'.format( self.naviseccli_path, self.fst_address ) port_list_out = runsub.cmd(port_list_cmd) return port_list_out
def sgn(self, sid='', mvn=''): """ Get the Storage Group Name by the Mask View Name. :param sid: Identification of VMAX (SID). :param mvn: Mask View Name check mvn() or get_mvn(). :return: the return code and full output Storage Group Name. """ self.validate_args() sgn_cmd = '{0}/symaccess -sid {1} show view {2}'.format( self.symcli_path, sid, mvn) sgn_out = runsub.cmd(sgn_cmd) return sgn_out
def sgn(self, sid='', mvn=''): """Get the Storage Group Name by the Mask View Name. :param sid: Identification of VMAX (SID). :param mvn: Mask View Name check mvn() or get_mvn(). :return: the return code and full output Storage Group Name. """ self.validate_args() sgn_cmd = '{0}/symaccess -sid {1} show view {2}'.format( self.symcli_path, sid, mvn) sgn_out = runsub.cmd(sgn_cmd) return sgn_out
def show_stggroup(self, stggroup_name): """Get all informations about the specific storage group name. :param stggroup_name: Storage Group Name :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ show_stggroup_cmd = "{0} -h {1} storagegroup " \ "-list -gname \'{2}\'".format(self.naviseccli_path, self.fst_address, stggroup_name) show_stggroup_out = runsub.cmd(show_stggroup_cmd, shell=True) return show_stggroup_out
def lshostconnect(self, wwpn=None): """ Get the list of hosts. If used with WWPN return informations from specified WWPN host. :param wwpn: optional :return: array as [return code, output]. """ if wwpn is None: lshostconnect_cmd = '{0} lshostconnect'.format( self.base_cmd) else: lshostconnect_cmd = '{0} lshostconnect -wwpn {1}'.format( self.base_cmd, wwpn) lshostconnect_out = runsub.cmd(lshostconnect_cmd) return lshostconnect_out
def pools(self): """ List all storage pools from VNX :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ self._init_vnx() pools_cmd = '{0} -h {1} storagepool -list'.format( self.naviseccli_path, self.fst_address ) pools_out = runsub.cmd(pools_cmd) return pools_out
def lspools(self, sid='', args=''): """List all available pools on VMAX. :param sid: Identification of VMAX (SID) :param args: is optional. You can use parameters such as -thin :return: the return code and pools without legend. """ self.validate_args() lspools_cmd = '{0}/symcfg -sid {1} list -pool {2}'.format( self.symcli_path, sid, args) lspools_out = runsub.cmd(lspools_cmd) if lspools_out[0] == 0: return lspools_out[0], lspools_out[1].split('Legend:')[0] else: return lspools_out
def show_stggroup(self, stggroup_name): """ Get all informations about the specific storage group name. :param stggroup_name: Storage Group Name :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ show_stggroup_cmd = "{0} -h {1} storagegroup " \ "-list -gname \'{2}\'".format(self.naviseccli_path, self.fst_address, stggroup_name) show_stggroup_out = runsub.cmd(show_stggroup_cmd, shell=True) return show_stggroup_out
def lspools(self, sid='', args=''): """ List all available pools on VMAX. :param sid: Identification of VMAX (SID) :param args: is optional. You can use parameters such as -thin :return: the return code and pools without legend. """ self.validate_args() lspools_cmd = '{0}/symcfg -sid {1} list -pool {2}'.format( self.symcli_path, sid, args) lspools_out = runsub.cmd(lspools_cmd) if lspools_out[0] == 0: return lspools_out[0], lspools_out[1].split('Legend:')[0] else: return lspools_out
def mkfbvol(self, pool=None, size=None, prefix=None, vol_group=None, address=None): """ Create the fbvol(s) and allocate to the Volume Group. :param pool: the extpool option :param size: the size in GB (without GB) :param prefix: the prefix used for LUN :param vol_group: the volume group to be allocated :param address: the address for the LUNS (LSS) :return: array as [return code, output]. """ mkfbvol_cmd = '{0} mkfbvol -extpool {1} -cap {2} -name {3}_#h -eam' \ ' rotateexts -sam ese -volgrp {4} {5}' \ .format(self.base_cmd, pool, size, prefix, vol_group, address) mkfbvol_out = runsub.cmd(mkfbvol_cmd) return mkfbvol_out
def show_lun(self, lun_id): """ Get information about specific LUN ID. :param lun_id: LUN ID (string) :return: default return If command is OK: [return code, output] If command is not OK: [return code, error, output] """ show_lun_cmd = "{0} -h {1} lun -list -l {2}".format( self.naviseccli_path, self.fst_address, lun_id ) show_lun_out = runsub.cmd(show_lun_cmd) return show_lun_out
def lsfbvol(self, args=''): """List all fixed block volumes in a storage. Arguments can be used IBM.DS8K.lsfbvol('args') Suggestions: - To get all volumes for a specificl Volume Group use: IBM.DS8K.lsfbvol('-volgrp VOL_GROUP_ID') - To get all volumes with IDs that contain the specified logical subsystem ID use: IBM.DS8K.lsfbvol('-lss LSS_ID' :param args: optional parameters could be passed here :return: array as [return code, output]. """ lsfbvol_cmd = '{0} lsfbvol {1}'.format(self.base_cmd, args) lsfbvol_out = runsub.cmd(lsfbvol_cmd) return lsfbvol_out
def lsfbvol(self, args=''): """ List all fixed block volumes in a storage. Arguments can be used IBM.DS8K.lsfbvol('args') Suggestions: - To get all volumes for a specificl Volume Group use: IBM.DS8K.lsfbvol('-volgrp VOL_GROUP_ID') - To get all volumes with IDs that contain the specified logical subsystem ID use: IBM.DS8K.lsfbvol('-lss LSS_ID' :param args: optional parameters could be passed here :return: array as [return code, output]. """ lsfbvol_cmd = '{0} lsfbvol {1}'.format(self.base_cmd, args) lsfbvol_out = runsub.cmd(lsfbvol_cmd) return lsfbvol_out
def create_dev(self, sid='', count=0, lun_size=0, member_size=0, lun_type='', pool='', sgn='', action='prepare'): """ Create device(s) for Storage Group Name. :param sid: Identification of VMAX (SID) :param count: number of devices :param lun_size: the size of LUN (GB) Ex: 100 :param member_size: Member size (only for lun_type=meta) :param lun_type: meta or regular :param pool: the pool for allocation (use lspools() to check) :param sgn: Storage Group Name :param action: strings 'prepare'(default) or 'commit' :return: returns the return code and output of allocation """ # convert size GB to CYL lun_size = calc.gb2cyl(int(lun_size)) member_size = calc.gb2cyl(int(member_size)) # args validation self.validate_args() if (action != 'prepare') and (action != 'commit'): return [1, 'The parameter action need to be prepare or commit.'] if lun_type == 'meta': create_dev_cmd = '{0}/symconfigure -sid {1} -cmd \"' \ 'create dev count={2}, size={3} CYL, ' \ 'emulation=FBA, config=TDEV, ' \ 'meta_member_size={4} CYL, ' \ 'meta_config=striped, binding to pool={5}, ' \ 'sg={6} ;\" {7} -v -nop' \ .format(self.symcli_path, sid, count, lun_size, member_size, pool, sgn, action) elif lun_type == 'regular': create_dev_cmd = '{0}/symconfigure -sid {1} -cmd \"' \ 'create dev count={2}, size={3} CYL, ' \ 'emulation=FBA , config=TDEV , ' \ 'binding to pool={4}, sg={5} ;\" {6} -v -nop' \ .format(self.symcli_path, sid, count, lun_size, pool, sgn, action) else: return [1, 'argument dev_type is not valid. use: meta or regular'] create_dev_out = runsub.cmd(create_dev_cmd, True) return create_dev_out
def create_dev(self, sid='', count=0, lun_size=0, member_size=0, lun_type='', pool='', sgn='', action='prepare'): """Create device(s) for Storage Group Name. :param sid: Identification of VMAX (SID) :param count: number of devices :param lun_size: the size of LUN (GB) Ex: 100 :param member_size: Member size (only for lun_type=meta) :param lun_type: meta or regular :param pool: the pool for allocation (use lspools() to check) :param sgn: Storage Group Name :param action: strings 'prepare'(default) or 'commit' :return: returns the return code and output of allocation """ # convert size GB to CYL lun_size = calc.gb2cyl(int(lun_size)) member_size = calc.gb2cyl(int(member_size)) # args validation self.validate_args() if (action != 'prepare') and (action != 'commit'): return [1, 'The parameter action need to be prepare or commit.'] if lun_type == 'meta': create_dev_cmd = '{0}/symconfigure -sid {1} -cmd \"' \ 'create dev count={2}, size={3} CYL, ' \ 'emulation=FBA, config=TDEV, ' \ 'meta_member_size={4} CYL, ' \ 'meta_config=striped, binding to pool={5}, ' \ 'sg={6} ;\" {7} -v -nop' \ .format(self.symcli_path, sid, count, lun_size, member_size, pool, sgn, action) elif lun_type == 'regular': create_dev_cmd = '{0}/symconfigure -sid {1} -cmd \"' \ 'create dev count={2}, size={3} CYL, ' \ 'emulation=FBA , config=TDEV , ' \ 'binding to pool={4}, sg={5} ;\" {6} -v -nop' \ .format(self.symcli_path, sid, count, lun_size, pool, sgn, action) else: return [1, 'argument dev_type is not valid. use: meta or regular'] create_dev_out = runsub.cmd(create_dev_cmd, True) return create_dev_out