コード例 #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 disable_acl(self, iqn):
     cmd = 'echo \"iscsi/%s/tpg1/ set attribute authentication=0\"' \
           '| targetcli' % iqn
     ShellSession.cmd_output(self, cmd)
     cmd = 'echo \"iscsi/%s/tpg1/ set attribute demo_mode_write_protect=0\"' \
           '| targetcli' % iqn
     ShellSession.cmd_output(self, cmd)
     cmd = 'echo \"iscsi/%s/tpg1/ set attribute generate_node_acls=1\"' \
           '| targetcli' % iqn
     ShellSession.cmd_output(self, cmd)
コード例 #5
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)
コード例 #6
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)
コード例 #7
0
 def delete_iscsi_target_portal(self, iqn):
     return ShellSession.cmd_output(
         self, 'echo \"iscsi/ delete %s\" | targetcli' % iqn)
コード例 #8
0
 def _create_fileio_file(self, path):
     self._fileio_path = path
     if os.path.exists(path):
         pass
     else:
         ShellSession.cmd_output(self, 'mkdir -p %s' % path)
コード例 #9
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')
コード例 #10
0
 def _check_iscsi_target_tool(self):
     cmd = 'yum list installed | grep targetcli'
     ShellSession.cmd_output_safe(self, cmd)
コード例 #11
0
ファイル: utils_guest.py プロジェクト: jingzhao84/ipa
 def guest_cmd_output(self, cmd, timeout=300, verbose=True):
     return ShellSession.cmd_output(self, cmd, timeout, verbose)