def create_clone_group(self, name=None, src_lun=None): '''Create a clone group''' if src_lun == None: return False cmd = self._construct_base_command(create_clone_group_command(cg_name=name,src_lun_id=src_lun.id)) print cmd status = run_get_status(cmd) return (status == 0)
def create_mountpoint(self, src_lun=None, mount_name=None): cmd = self._construct_base_command(create_mountpoint_command(name=mount_name, src_lun_id=src_lun.id)) print cmd status = run_get_status(cmd) if status != 0: return None result = self.get_lun_by_name(lun_name=mount_name) if result.id > 0: return result
def host_attach(client=None, target_iqn=None): ''' Attach the lun to the local host, assumes no CHAP authentication. Returns the name of the local device that is the attachment This is VNX specific for our setup, see the iqn and IP Also assumes only a single lun, so always looks for LUN 1 for device ''' add_static_target = ['iscsiadm','-m','node','-T','iqn.1992-04.com.emc:cx.apm00121200804.a6', '-p','192.168.25.182', '-o', 'new'] scan_sessions = ['iscsiadm','-m','session','-R'] iscsi_info = ['iscsiadm','-m','session','-P','3'] processtools.run_get_status(add_static_target) processtools.run_get_status(scan_sessions) output = processtools.run_get_output(iscsi_info) parse_device_name(output,lun_id=1, target='iqn.1992-04.com.emc:cx.apm00121200804.a6') #TODO: finish this function local_device=None return local_device
def create_lun(self, lun_name=None, lun_size=None): ''' Creates lun and returns lun's ID''' if lun_name == None or lun_size == None: raise ValueError("Name and size must be specified") command = self._construct_base_command(create_lun_command(lun_name=lun_name,capacity=lun_size)) print command status = run_get_status(command) if status != 0: print "Error creating lun" return None get_command = self._construct_base_command(get_lun_by_name_command(lun_name=lun_name)) lun_output = run_get_output(get_command) return self._construct_lun(lun_output)
def start_migrate_lun(self, src_lun=None, dest_lun=None): cmd = self._construct_base_command(start_lun_migration_command(src_lun_id=src_lun.id,dest_lun_id=dest_lun.id)) print cmd status = run_get_status(cmd) return (status == 0)
def detach_snap(self, snap_name=None, mount_point=None): cmd = self._construct_base_command(detach_snapshot_mountpoint_command(snapshot=snap_name)) print cmd status = run_get_status(cmd) return (status == 0)
def delete_snapshot(self, snap_name=None): cmd = self._construct_base_command(delete_snapshot_command(name=snap_name)) print cmd status = run_get_status(cmd) return (status == 0)
def create_snapshot(self, src_lun=None, snap_name=None): cmd = self._construct_base_command(create_snapshot_command(name=snap_name,src_lun_id=src_lun.id)) print cmd status = run_get_status(cmd) return (status == 0)
def clone_group_exists(self, cg_name=None): print 'Checking for clone group ' + cg_name cmd = self._construct_base_command(get_clone_group_command(group_name=cg_name)) print cmd status = run_get_status(cmd) return (status == 0)
def delete_clone_group(self, cg_name=None): cmd = self._construct_base_command(delete_clone_group_command(group_name=cg_name)) print cmd status = run_get_status(cmd) return (status == 0)
def remove_clone_from_group(self, cg_name=None, clone_id=vnx_default_clone_id): cmd = self._construct_base_command(remove_clone_from_clonegroup_command(group_name=cg_name,clone_id=clone_id)) print cmd status = run_get_status(cmd) return (status == True)
def fracture_clone(self, cg_name=None, clone_id=vnx_default_clone_id): cmd = self._construct_base_command(fracture_clone_command(group_name=cg_name,clone_id=clone_id)) print cmd status = run_get_status(cmd) return (status == True)
def add_lun_to_clone_group(self,cg_name=None, lun=None): '''Adds a lun to a clonegroup as a clone, returns the clone id''' cmd = self._construct_base_command(add_lun_to_clone_group_command(group_name=cg_name, lun_id=lun.id)) print cmd status = run_get_status(cmd) return (status == 0)
def delete_lun_by_name(self, lun_name=None): '''Delete the lun using a name ref''' cmd = self._construct_base_command(delete_lun_by_name_command(lun_name=lun_name)) print cmd status = run_get_status(cmd) return (status == 0)
def delete_lun(self, lun=None): '''Delete the lun''' cmd = self._construct_base_command(delete_lun_by_id_command(lun_id=lun.id)) print cmd status = run_get_status(cmd) return (status == 0)