예제 #1
0
    def _login_target_portal(self, target_portal):
        (target_address,
         target_port) = utils.parse_server_string(target_portal)

        output = self.execute('iscsicli.exe', 'ListTargetPortals')
        pattern = r'Address and Socket *: (.*)'
        portals = [addr.split() for addr in re.findall(pattern, output)]
        LOG.debug("Ensuring connection to portal: %s" % target_portal)
        if [target_address, str(target_port)] in portals:
            self.execute('iscsicli.exe', 'RefreshTargetPortal', target_address,
                         target_port)
        else:
            # Adding target portal to iscsi initiator. Sending targets
            self.execute('iscsicli.exe', 'AddTargetPortal', target_address,
                         target_port, '*', '*', '*', '*', '*', '*', '*', '*',
                         '*', '*', '*', '*', '*')
예제 #2
0
    def _login_target_portal(self, target_portal):
        (target_address,
         target_port) = utils.parse_server_string(target_portal)

        # Checking if the portal is already connected.
        portal = self._conn_storage.query("SELECT * FROM "
                                          "MSFT_iSCSITargetPortal "
                                          "WHERE TargetPortalAddress='%s' "
                                          "AND TargetPortalPortNumber='%s'" %
                                          (target_address, target_port))
        if portal:
            portal[0].Update()
        else:
            # Adding target portal to iscsi initiator. Sending targets
            portal = self._conn_storage.MSFT_iSCSITargetPortal
            portal.New(TargetPortalAddress=target_address,
                       TargetPortalPortNumber=target_port)
예제 #3
0
    def _login_target_portal(self, target_portal):
        (target_address,
         target_port) = utils.parse_server_string(target_portal)

        # Checking if the portal is already connected.
        portal = self._conn_storage.query("SELECT * FROM "
                                          "MSFT_iSCSITargetPortal "
                                          "WHERE TargetPortalAddress='%s' "
                                          "AND TargetPortalPortNumber='%s'"
                                          % (target_address, target_port))
        if portal:
            portal[0].Update()
        else:
            # Adding target portal to iscsi initiator. Sending targets
            portal = self._conn_storage.MSFT_iSCSITargetPortal
            portal.New(TargetPortalAddress=target_address,
                       TargetPortalPortNumber=target_port)
예제 #4
0
 def test_parse_server_string(self):
     result = utils.parse_server_string('::1')
     self.assertEqual(('::1', ''), result)
     result = utils.parse_server_string('[::1]:8773')
     self.assertEqual(('::1', '8773'), result)
     result = utils.parse_server_string('2001:db8::192.168.1.1')
     self.assertEqual(('2001:db8::192.168.1.1', ''), result)
     result = utils.parse_server_string('[2001:db8::192.168.1.1]:8773')
     self.assertEqual(('2001:db8::192.168.1.1', '8773'), result)
     result = utils.parse_server_string('192.168.1.1')
     self.assertEqual(('192.168.1.1', ''), result)
     result = utils.parse_server_string('192.168.1.2:8773')
     self.assertEqual(('192.168.1.2', '8773'), result)
     result = utils.parse_server_string('192.168.1.3')
     self.assertEqual(('192.168.1.3', ''), result)
     result = utils.parse_server_string('www.example.com:8443')
     self.assertEqual(('www.example.com', '8443'), result)
     result = utils.parse_server_string('www.example.com')
     self.assertEqual(('www.example.com', ''), result)
     # error case
     result = utils.parse_server_string('www.exa:mple.com:8443')
     self.assertEqual(('', ''), result)
     result = utils.parse_server_string('')
     self.assertEqual(('', ''), result)
예제 #5
0
 def test_parse_server_string(self):
     result = utils.parse_server_string('::1')
     self.assertEqual(('::1', ''), result)
     result = utils.parse_server_string('[::1]:8773')
     self.assertEqual(('::1', '8773'), result)
     result = utils.parse_server_string('2001:db8::192.168.1.1')
     self.assertEqual(('2001:db8::192.168.1.1', ''), result)
     result = utils.parse_server_string('[2001:db8::192.168.1.1]:8773')
     self.assertEqual(('2001:db8::192.168.1.1', '8773'), result)
     result = utils.parse_server_string('192.168.1.1')
     self.assertEqual(('192.168.1.1', ''), result)
     result = utils.parse_server_string('192.168.1.2:8773')
     self.assertEqual(('192.168.1.2', '8773'), result)
     result = utils.parse_server_string('192.168.1.3')
     self.assertEqual(('192.168.1.3', ''), result)
     result = utils.parse_server_string('www.example.com:8443')
     self.assertEqual(('www.example.com', '8443'), result)
     result = utils.parse_server_string('www.example.com')
     self.assertEqual(('www.example.com', ''), result)
     # error case
     result = utils.parse_server_string('www.exa:mple.com:8443')
     self.assertEqual(('', ''), result)
     result = utils.parse_server_string('')
     self.assertEqual(('', ''), result)