コード例 #1
0
 def _enable_iscsiid(self):
     HostSession.host_cmd_output(self, 'systemctl enable iscsid iscsi')
     HostSession.host_cmd_output(self, 'systemctl start iscsid iscsi')
     output = HostSession.host_cmd_output(
         self, 'systemctl status iscsid iscsi -l')
     if not re.findall(r'Active: active', output):
         ShellSession.test_error(self, 'Failed to start iscsid server.')
コード例 #2
0
 def _enable_iscsi_target_server(self):
     cmd = 'iptables -F'
     ShellSession.cmd_output(self, cmd)
     cmd = 'systemctl start target'
     ShellSession.cmd_output(self, cmd)
     cmd = 'systemctl enable target'
     ShellSession.cmd_output(self, cmd)
     output = ShellSession.cmd_output(self, 'systemctl status target -l')
     if not re.findall(r'Active: active', output):
         ShellSession.test_error(self, 'Failed to start target server.')
コード例 #3
0
 def create_lun(self,
                iqn,
                backend_name,
                fileio_mode=False,
                block_mode=False):
     if not fileio_mode and not block_mode:
         ShellSession.test_error(
             self, 'Please specify fileio '
             '| block mode for lun.')
     elif fileio_mode:
         cmd = 'echo \"iscsi/%s/tpg1/luns/ create /backstores/fileio/%s\" ' \
               '| targetcli' % (iqn, backend_name)
     elif block_mode:
         cmd = 'echo \"iscsi/%s/tpg1/luns/ create /backstores/block/%s\" ' \
               '| targetcli' % (iqn, backend_name)
     ShellSession.cmd_output(self, cmd)
コード例 #4
0
 def create_backstore(self,
                      file_or_dev,
                      backend_name,
                      size,
                      write_back='false'):
     if re.findall(r'/', file_or_dev):
         path = '/'
         for p in file_or_dev.split('/')[0:-1]:
             path = os.path.join(path, p)
         self._create_fileio_file(path)
     else:
         ShellSession.test_error(self,
                                 'Please specify a path for backstore.')
     cmd = "echo \"backstores/fileio/ create file_or_dev=%s name=%s size=%s " \
           "write_back=%s\" | targetcli" \
           % (file_or_dev, backend_name, size, write_back)
     output = ShellSession.cmd_output(self, cmd)
     if 'Storage object fileio/%s exists' % backend_name in output:
         cmd = "echo \"backstores/fileio/ delete %s\" | targetcli" % backend_name
         ShellSession.cmd_output(self, cmd)
         cmd = "echo \"backstores/fileio/ create file_or_dev=%s name=%s size=%s " \
               "write_back=%s\" | targetcli" % (
               file_or_dev, backend_name, size, write_back)
         ShellSession.cmd_output(self, cmd)
コード例 #5
0
 def create_iscsi_target_portal(self, iqn):
     self.delete_iscsi_target_portal(iqn)
     if 'This Target already exists in configFS' \
             in ShellSession.cmd_output(
         self, 'echo \"iscsi/ create %s\" | targetcli' % iqn):
         ShellSession.test_error(self, 'Failed to create target %s' % iqn)
コード例 #6
0
 def _install_iscsi_target_tool(self):
     cmd = 'yum install -y targetcli'
     status, output = ShellSession.cmd_status_output(self, cmd)
     if status:
         ShellSession.test_error(self, 'Failed to install targetcli')