コード例 #1
0
ファイル: iscsi.py プロジェクト: tyws/test_-frerfhrebfd
def _start_lio(iqn, portal_port, device):
    try:
        storage = rtslib_fb.BlockStorageObject(name=iqn, dev=device)
        target = rtslib_fb.Target(rtslib_fb.FabricModule('iscsi'),
                                  iqn,
                                  mode='create')
        tpg = rtslib_fb.TPG(target, mode='create')
        # disable all authentication
        tpg.set_attribute('authentication', '0')
        tpg.set_attribute('demo_mode_write_protect', '0')
        tpg.set_attribute('generate_node_acls', '1')
        # lun=1 is hardcoded in ironic
        rtslib_fb.LUN(tpg, storage_object=storage, lun=1)
        tpg.enable = 1
    except rtslib_fb.utils.RTSLibError as exc:
        msg = 'Failed to create a target: {}'.format(exc)
        raise errors.ISCSIError(msg)

    try:
        # bind to the default port on all interfaces
        listen_ip = netutils.wrap_ipv6(netutils.get_wildcard_address())
        rtslib_fb.NetworkPortal(tpg, listen_ip, portal_port)
    except rtslib_fb.utils.RTSLibError as exc:
        msg = 'Failed to publish a target: {}'.format(exc)
        raise errors.ISCSIError(msg)
コード例 #2
0
def _start_lio(iqn, portal_port, device):
    try:
        storage = rtslib_fb.BlockStorageObject(name=iqn, dev=device)
        target = rtslib_fb.Target(rtslib_fb.FabricModule('iscsi'), iqn,
                                  mode='create')
        tpg = rtslib_fb.TPG(target, mode='create')
        # disable all authentication
        tpg.set_attribute('authentication', '0')
        tpg.set_attribute('demo_mode_write_protect', '0')
        tpg.set_attribute('generate_node_acls', '1')
        # lun=1 is hardcoded in ironic
        rtslib_fb.LUN(tpg, storage_object=storage, lun=1)
        tpg.enable = 1
    except rtslib_fb.utils.RTSLibError as exc:
        msg = 'Failed to create a target: {}'.format(exc)
        raise errors.ISCSIError(msg)

    try:
        # bind to the default port on all interfaces
        listen_ip = netutils.wrap_ipv6(netutils.get_wildcard_address())
        rtslib_fb.NetworkPortal(tpg, listen_ip, portal_port)
    except rtslib_fb.utils.RTSLibError as exc:
        msg = 'Failed to publish a target: {}'.format(exc)
        raise errors.ISCSIError(msg)
コード例 #3
0
 def _get_agent_url(self, advertise_address, advertise_protocol='http'):
     return '{}://{}:{}'.format(advertise_protocol,
                                netutils.wrap_ipv6(advertise_address[0]),
                                advertise_address[1])
コード例 #4
0
 def _get_agent_url(self, advertise_address):
     return 'http://{}:{}'.format(netutils.wrap_ipv6(advertise_address[0]),
                                  advertise_address[1])
コード例 #5
0
 def _get_agent_url(self, advertise_address):
     return 'http://{}:{}'.format(netutils.wrap_ipv6(advertise_address[0]),
                                  advertise_address[1])
コード例 #6
0
 def test_wrap_ipv6_with_ipv4(self):
     res = netutils.wrap_ipv6('1.2.3.4')
     self.assertEqual('1.2.3.4', res)
コード例 #7
0
 def test_wrap_ipv6(self):
     res = netutils.wrap_ipv6('1:2::3:4')
     self.assertEqual('[1:2::3:4]', res)
コード例 #8
0
 def test_wrap_ipv6_with_ipv4(self):
     res = netutils.wrap_ipv6('1.2.3.4')
     self.assertEqual('1.2.3.4', res)
コード例 #9
0
 def test_wrap_ipv6(self):
     res = netutils.wrap_ipv6('1:2::3:4')
     self.assertEqual('[1:2::3:4]', res)