Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given snippet: <|code_start|> @mock.patch('os_brick.remotefs.remotefs.RemoteFsClient._check_nfs_options')
def test_init_nfs_calls_check_nfs_options(self, mock_check_nfs_options):
remotefs.RemoteFsClient("nfs", root_helper='true',
nfs_mount_point_base='/fake')
mock_check_nfs_options.assert_called_once_with()
class VZStorageRemoteFSClientTestVase(RemoteFsClientTestCase):
@mock.patch.object(remotefs.RemoteFsClient, '_read_mounts',
return_value=[])
def test_vzstorage_by_cluster_name(self, mock_read_mounts):
client = remotefs.VZStorageRemoteFSClient(
"vzstorage", root_helper='true', vzstorage_mount_point_base='/mnt')
share = 'qwe'
cluster_name = share
mount_point = client.get_mount_point(share)
client.mount(share)
calls = [mock.call('mkdir', '-p', mount_point, check_exit_code=0),
mock.call('pstorage-mount', '-c', cluster_name, mount_point,
root_helper='true', check_exit_code=0,
run_as_root=True)]
self.mock_execute.assert_has_calls(calls)
@mock.patch.object(remotefs.RemoteFsClient, '_read_mounts',
return_value=[])
def test_vzstorage_with_auth(self, mock_read_mounts):
client = remotefs.VZStorageRemoteFSClient(
"vzstorage", root_helper='true', vzstorage_mount_point_base='/mnt')
cluster_name = 'qwe'
password = '123456'
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import os
import tempfile
from unittest import mock
from oslo_concurrency import processutils as putils
from os_brick import exception
from os_brick.privileged import rootwrap as priv_rootwrap
from os_brick.remotefs import remotefs
from os_brick.tests import base
and context:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/privileged/rootwrap.py
# LOG = logging.getLogger(__name__)
# def custom_execute(*cmd, **kwargs):
# def on_timeout(proc):
# def on_execute(proc):
# def on_completion(proc):
# def execute(*cmd, **kwargs):
# def execute_root(*cmd, **kwargs):
# def unlink_root(*links, **kwargs):
#
# Path: os_brick/remotefs/remotefs.py
# LOG = logging.getLogger(__name__)
# class RemoteFsClient(executor.Executor):
# class ScalityRemoteFsClient(RemoteFsClient):
# class VZStorageRemoteFSClient(RemoteFsClient):
# def __init__(self, mount_type, root_helper,
# execute=None, *args, **kwargs):
# def get_mount_base(self):
# def _get_hash_str(self, base_str):
# def get_mount_point(self, device_name: str):
# def _read_mounts(self):
# def mount(self, share, flags=None):
# def _do_mount(self, mount_type, share, mount_path, mount_options=None,
# flags=None):
# def _mount_nfs(self, nfs_share, mount_path, flags=None):
# def _check_nfs_options(self):
# def _option_exists(self, options, opt_pattern):
# def _update_option(self, options, option, value=None):
# def __init__(self, mount_type, root_helper,
# execute=None, *args, **kwargs):
# def get_mount_point(self, device_name):
# def mount(self, share, flags=None):
# def _vzstorage_write_mds_list(self, cluster_name, mdss):
# def _do_mount(self, mount_type, vz_share, mount_path,
# mount_options=None, flags=None):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
which might include code, classes, or functions. Output only the next line. | share = '%s:%s' % (cluster_name, password) |
Given snippet: <|code_start|>
@mock.patch.object(remotefs.RemoteFsClient, '_read_mounts',
return_value=[])
def test_cifs(self, mock_read_mounts):
client = remotefs.RemoteFsClient("cifs", root_helper='true',
smbfs_mount_point_base='/mnt')
share = '10.0.0.1:/qwe'
mount_point = client.get_mount_point(share)
client.mount(share)
calls = [mock.call('mkdir', '-p', mount_point, check_exit_code=0),
mock.call('mount', '-t', 'cifs', share, mount_point,
run_as_root=True, root_helper='true',
check_exit_code=0)]
self.mock_execute.assert_has_calls(calls)
@mock.patch.object(remotefs.RemoteFsClient, '_read_mounts',
return_value=[])
def test_nfs(self, mock_read_mounts):
client = remotefs.RemoteFsClient("nfs", root_helper='true',
nfs_mount_point_base='/mnt')
share = '10.0.0.1:/qwe'
mount_point = client.get_mount_point(share)
client.mount(share)
calls = [mock.call('mkdir', '-p', mount_point, check_exit_code=0),
mock.call('mount', '-t', 'nfs', '-o', 'vers=4,minorversion=1',
share, mount_point, check_exit_code=0,
run_as_root=True, root_helper='true')]
self.mock_execute.assert_has_calls(calls)
def test_read_mounts(self):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import os
import tempfile
from unittest import mock
from oslo_concurrency import processutils as putils
from os_brick import exception
from os_brick.privileged import rootwrap as priv_rootwrap
from os_brick.remotefs import remotefs
from os_brick.tests import base
and context:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/privileged/rootwrap.py
# LOG = logging.getLogger(__name__)
# def custom_execute(*cmd, **kwargs):
# def on_timeout(proc):
# def on_execute(proc):
# def on_completion(proc):
# def execute(*cmd, **kwargs):
# def execute_root(*cmd, **kwargs):
# def unlink_root(*links, **kwargs):
#
# Path: os_brick/remotefs/remotefs.py
# LOG = logging.getLogger(__name__)
# class RemoteFsClient(executor.Executor):
# class ScalityRemoteFsClient(RemoteFsClient):
# class VZStorageRemoteFSClient(RemoteFsClient):
# def __init__(self, mount_type, root_helper,
# execute=None, *args, **kwargs):
# def get_mount_base(self):
# def _get_hash_str(self, base_str):
# def get_mount_point(self, device_name: str):
# def _read_mounts(self):
# def mount(self, share, flags=None):
# def _do_mount(self, mount_type, share, mount_path, mount_options=None,
# flags=None):
# def _mount_nfs(self, nfs_share, mount_path, flags=None):
# def _check_nfs_options(self):
# def _option_exists(self, options, opt_pattern):
# def _update_option(self, options, option, value=None):
# def __init__(self, mount_type, root_helper,
# execute=None, *args, **kwargs):
# def get_mount_point(self, device_name):
# def mount(self, share, flags=None):
# def _vzstorage_write_mds_list(self, cluster_name, mdss):
# def _do_mount(self, mount_type, vz_share, mount_path,
# mount_options=None, flags=None):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
which might include code, classes, or functions. Output only the next line. | mounts = """device1 mnt_point1 ext4 rw,seclabel,relatime 0 0 |
Using the snippet: <|code_start|>
self._conn = base_rbd.RBDConnectorMixin()
@ddt.data((['192.168.1.1', '192.168.1.2'],
['192.168.1.1', '192.168.1.2']),
(['3ffe:1900:4545:3:200:f8ff:fe21:67cf',
'fe80:0:0:0:200:f8ff:fe21:67cf'],
['[3ffe:1900:4545:3:200:f8ff:fe21:67cf]',
'[fe80:0:0:0:200:f8ff:fe21:67cf]']),
(['foobar', 'fizzbuzz'], ['foobar', 'fizzbuzz']),
(['192.168.1.1',
'3ffe:1900:4545:3:200:f8ff:fe21:67cf',
'hello, world!'],
['192.168.1.1',
'[3ffe:1900:4545:3:200:f8ff:fe21:67cf]',
'hello, world!']))
@ddt.unpack
def test_sanitize_mon_host(self, hosts_in, hosts_out):
self.assertEqual(hosts_out, self._conn._sanitize_mon_hosts(hosts_in))
def test_get_rbd_args(self):
res = self._conn._get_rbd_args(self.connection_properties, None)
expected = ['--id', self.user,
'--mon_host', self.hosts[0] + ':' + self.ports[0]]
self.assertEqual(expected, res)
def test_get_rbd_args_with_conf(self):
res = self._conn._get_rbd_args(self.connection_properties,
mock.sentinel.conf_path)
expected = ['--id', self.user,
<|code_end|>
, determine the next line of code. You have imports:
from unittest import mock
from os_brick.initiator.connectors import base_rbd
from os_brick.tests import base
import ddt
and context (class names, function names, or code) available:
# Path: os_brick/initiator/connectors/base_rbd.py
# LOG = logging.getLogger(__name__)
# class RBDConnectorMixin(object):
# def _sanitize_mon_hosts(hosts):
# def _sanitize_host(host):
# def _get_rbd_args(cls, connection_properties, conf=None):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | '--mon_host', self.hosts[0] + ':' + self.ports[0], |
Using the snippet: <|code_start|>#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# Both Linux and Windows tests are using those mocks.
class RBDConnectorTestMixin(object):
def setUp(self):
super(RBDConnectorTestMixin, self).setUp()
self.user = 'fake_user'
self.pool = 'fake_pool'
self.volume = 'fake_volume'
self.clustername = 'fake_ceph'
self.hosts = ['192.168.10.2']
self.ports = ['6789']
self.keyring = "[client.cinder]\n key = test\n"
self.image_name = '%s/%s' % (self.pool, self.volume)
self.connection_properties = {
'auth_username': self.user,
'name': self.image_name,
<|code_end|>
, determine the next line of code. You have imports:
from unittest import mock
from os_brick.initiator.connectors import base_rbd
from os_brick.tests import base
import ddt
and context (class names, function names, or code) available:
# Path: os_brick/initiator/connectors/base_rbd.py
# LOG = logging.getLogger(__name__)
# class RBDConnectorMixin(object):
# def _sanitize_mon_hosts(hosts):
# def _sanitize_host(host):
# def _get_rbd_args(cls, connection_properties, conf=None):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | 'cluster_name': self.clustername, |
Next line prediction: <|code_start|># Copyright (c) 2016 VMware, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
try:
except ImportError:
vim_util = None
<|code_end|>
. Use current file imports:
(import os
import tempfile
from oslo_log import log as logging
from oslo_utils import fileutils
from oslo_vmware import api
from oslo_vmware import exceptions as oslo_vmw_exceptions
from oslo_vmware import image_transfer
from oslo_vmware.objects import datastore
from oslo_vmware import rw_handles
from oslo_vmware import vim_util
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator import initiator_connector)
and context including class names, function names, or small code snippets from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/initiator_connector.py
# class InitiatorConnector(executor.Executor, metaclass=abc.ABCMeta):
# def __init__(self, root_helper, driver=None, execute=None,
# device_scan_attempts=initiator.DEVICE_SCAN_ATTEMPTS_DEFAULT,
# *args, **kwargs):
# def set_driver(self, driver):
# def get_connector_properties(root_helper, *args, **kwargs):
# def check_valid_device(self, path, run_as_root=True):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
# def get_search_path(self):
# def extend_volume(self, connection_properties):
# def get_all_available_volumes(self, connection_properties=None):
# def check_IO_handle_valid(self, handle, data_type, protocol):
. Output only the next line. | LOG = logging.getLogger(__name__) |
Predict the next line after this snippet: <|code_start|># Copyright (c) 2016 VMware, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
try:
except ImportError:
vim_util = None
<|code_end|>
using the current file's imports:
import os
import tempfile
from oslo_log import log as logging
from oslo_utils import fileutils
from oslo_vmware import api
from oslo_vmware import exceptions as oslo_vmw_exceptions
from oslo_vmware import image_transfer
from oslo_vmware.objects import datastore
from oslo_vmware import rw_handles
from oslo_vmware import vim_util
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator import initiator_connector
and any relevant context from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/initiator_connector.py
# class InitiatorConnector(executor.Executor, metaclass=abc.ABCMeta):
# def __init__(self, root_helper, driver=None, execute=None,
# device_scan_attempts=initiator.DEVICE_SCAN_ATTEMPTS_DEFAULT,
# *args, **kwargs):
# def set_driver(self, driver):
# def get_connector_properties(root_helper, *args, **kwargs):
# def check_valid_device(self, path, run_as_root=True):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
# def get_search_path(self):
# def extend_volume(self, connection_properties):
# def get_all_available_volumes(self, connection_properties=None):
# def check_IO_handle_valid(self, handle, data_type, protocol):
. Output only the next line. | LOG = logging.getLogger(__name__) |
Given snippet: <|code_start|># Copyright 2016 Cloudbase Solutions Srl
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
LOG = logging.getLogger(__name__)
class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
base_iscsi.BaseISCSIConnector):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from os_win import exceptions as os_win_exc
from os_win import utilsfactory
from oslo_log import log as logging
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator.connectors import base_iscsi
from os_brick.initiator.windows import base as win_conn_base
from os_brick import utils
and context:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/connectors/base_iscsi.py
# class BaseISCSIConnector(initiator_connector.InitiatorConnector):
# def _iterate_all_targets(self, connection_properties):
# def _get_luns(con_props, iqns=None):
# def _get_all_targets(self, connection_properties):
#
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
which might include code, classes, or functions. Output only the next line. | def __init__(self, *args, **kwargs): |
Continue the code snippet: <|code_start|># Copyright 2016 Cloudbase Solutions Srl
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
LOG = logging.getLogger(__name__)
class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
base_iscsi.BaseISCSIConnector):
def __init__(self, *args, **kwargs):
super(WindowsISCSIConnector, self).__init__(*args, **kwargs)
<|code_end|>
. Use current file imports:
from os_win import exceptions as os_win_exc
from os_win import utilsfactory
from oslo_log import log as logging
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator.connectors import base_iscsi
from os_brick.initiator.windows import base as win_conn_base
from os_brick import utils
and context (classes, functions, or code) from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/connectors/base_iscsi.py
# class BaseISCSIConnector(initiator_connector.InitiatorConnector):
# def _iterate_all_targets(self, connection_properties):
# def _get_luns(con_props, iqns=None):
# def _get_all_targets(self, connection_properties):
#
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | self.use_multipath = kwargs.pop('use_multipath', False) |
Given the code snippet: <|code_start|># Copyright 2016 Cloudbase Solutions Srl
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
LOG = logging.getLogger(__name__)
class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
base_iscsi.BaseISCSIConnector):
def __init__(self, *args, **kwargs):
super(WindowsISCSIConnector, self).__init__(*args, **kwargs)
<|code_end|>
, generate the next line using the imports in this file:
from os_win import exceptions as os_win_exc
from os_win import utilsfactory
from oslo_log import log as logging
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator.connectors import base_iscsi
from os_brick.initiator.windows import base as win_conn_base
from os_brick import utils
and context (functions, classes, or occasionally code) from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/connectors/base_iscsi.py
# class BaseISCSIConnector(initiator_connector.InitiatorConnector):
# def _iterate_all_targets(self, connection_properties):
# def _get_luns(con_props, iqns=None):
# def _get_all_targets(self, connection_properties):
#
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | self.use_multipath = kwargs.pop('use_multipath', False) |
Given snippet: <|code_start|># Copyright 2016 Cloudbase Solutions Srl
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
LOG = logging.getLogger(__name__)
class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
base_iscsi.BaseISCSIConnector):
def __init__(self, *args, **kwargs):
super(WindowsISCSIConnector, self).__init__(*args, **kwargs)
self.use_multipath = kwargs.pop('use_multipath', False)
self.initiator_list = kwargs.pop('initiator_list', [])
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from os_win import exceptions as os_win_exc
from os_win import utilsfactory
from oslo_log import log as logging
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator.connectors import base_iscsi
from os_brick.initiator.windows import base as win_conn_base
from os_brick import utils
and context:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/connectors/base_iscsi.py
# class BaseISCSIConnector(initiator_connector.InitiatorConnector):
# def _iterate_all_targets(self, connection_properties):
# def _get_luns(con_props, iqns=None):
# def _get_all_targets(self, connection_properties):
#
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
which might include code, classes, or functions. Output only the next line. | self._iscsi_utils = utilsfactory.get_iscsi_initiator_utils() |
Predict the next line after this snippet: <|code_start|># Copyright 2016 Cloudbase Solutions Srl
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
LOG = logging.getLogger(__name__)
class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
base_iscsi.BaseISCSIConnector):
def __init__(self, *args, **kwargs):
super(WindowsISCSIConnector, self).__init__(*args, **kwargs)
self.use_multipath = kwargs.pop('use_multipath', False)
self.initiator_list = kwargs.pop('initiator_list', [])
self._iscsi_utils = utilsfactory.get_iscsi_initiator_utils()
<|code_end|>
using the current file's imports:
from os_win import exceptions as os_win_exc
from os_win import utilsfactory
from oslo_log import log as logging
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator.connectors import base_iscsi
from os_brick.initiator.windows import base as win_conn_base
from os_brick import utils
and any relevant context from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/connectors/base_iscsi.py
# class BaseISCSIConnector(initiator_connector.InitiatorConnector):
# def _iterate_all_targets(self, connection_properties):
# def _get_luns(con_props, iqns=None):
# def _get_all_targets(self, connection_properties):
#
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | self.validate_initiators() |
Based on the snippet: <|code_start|>
if feature_available or not enforce_multipath:
multipath_support = check_mpio(
enforce_multipath=enforce_multipath)
self.assertEqual(feature_available, multipath_support)
else:
self.assertRaises(exception.BrickException,
check_mpio,
enforce_multipath=enforce_multipath)
mock_hostutils.check_server_feature.assert_called_once_with(
mock_hostutils.FEATURE_MPIO)
@ddt.data({}, {'mpio_requested': False}, {'mpio_available': True})
@mock.patch.object(base_win_conn.BaseWindowsConnector,
'check_multipath_support')
@ddt.unpack
def test_get_connector_properties(self, mock_check_mpio,
mpio_requested=True,
mpio_available=True):
mock_check_mpio.return_value = mpio_available
enforce_multipath = False
props = base_win_conn.BaseWindowsConnector.get_connector_properties(
multipath=mpio_requested,
enforce_multipath=enforce_multipath)
self.assertEqual(mpio_requested and mpio_available,
props['multipath'])
if mpio_requested:
mock_check_mpio.assert_called_once_with(enforce_multipath)
<|code_end|>
, predict the immediate next line with the help of imports:
from unittest import mock
from os_brick import exception
from os_brick.initiator.windows import base as base_win_conn
from os_brick.tests.windows import fake_win_conn
from os_brick.tests.windows import test_base
import ddt
and context (classes, functions, sometimes code) from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/tests/windows/fake_win_conn.py
# class FakeWindowsConnector(win_conn_base.BaseWindowsConnector):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
# def get_search_path(self):
# def get_all_available_volumes(self, connection_properties=None):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | def test_get_scsi_wwn(self): |
Next line prediction: <|code_start|>#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
@ddt.ddt
class BaseWindowsConnectorTestCase(test_base.WindowsConnectorTestBase):
def setUp(self):
super(BaseWindowsConnectorTestCase, self).setUp()
self._diskutils = mock.Mock()
self._connector = fake_win_conn.FakeWindowsConnector()
self._connector._diskutils = self._diskutils
@ddt.data({},
{'feature_available': True},
{'feature_available': False, 'enforce_multipath': True})
@ddt.unpack
@mock.patch.object(base_win_conn.utilsfactory, 'get_hostutils')
def test_check_multipath_support(self, mock_get_hostutils,
feature_available=True,
<|code_end|>
. Use current file imports:
(from unittest import mock
from os_brick import exception
from os_brick.initiator.windows import base as base_win_conn
from os_brick.tests.windows import fake_win_conn
from os_brick.tests.windows import test_base
import ddt)
and context including class names, function names, or small code snippets from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/tests/windows/fake_win_conn.py
# class FakeWindowsConnector(win_conn_base.BaseWindowsConnector):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
# def get_search_path(self):
# def get_all_available_volumes(self, connection_properties=None):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | enforce_multipath=False): |
Here is a snippet: <|code_start|> self.assertRaises(exception.BrickException,
check_mpio,
enforce_multipath=enforce_multipath)
mock_hostutils.check_server_feature.assert_called_once_with(
mock_hostutils.FEATURE_MPIO)
@ddt.data({}, {'mpio_requested': False}, {'mpio_available': True})
@mock.patch.object(base_win_conn.BaseWindowsConnector,
'check_multipath_support')
@ddt.unpack
def test_get_connector_properties(self, mock_check_mpio,
mpio_requested=True,
mpio_available=True):
mock_check_mpio.return_value = mpio_available
enforce_multipath = False
props = base_win_conn.BaseWindowsConnector.get_connector_properties(
multipath=mpio_requested,
enforce_multipath=enforce_multipath)
self.assertEqual(mpio_requested and mpio_available,
props['multipath'])
if mpio_requested:
mock_check_mpio.assert_called_once_with(enforce_multipath)
def test_get_scsi_wwn(self):
mock_get_uid_and_type = self._diskutils.get_disk_uid_and_uid_type
mock_get_uid_and_type.return_value = (mock.sentinel.disk_uid,
mock.sentinel.uid_type)
scsi_wwn = self._connector._get_scsi_wwn(mock.sentinel.dev_num)
<|code_end|>
. Write the next line using the current file imports:
from unittest import mock
from os_brick import exception
from os_brick.initiator.windows import base as base_win_conn
from os_brick.tests.windows import fake_win_conn
from os_brick.tests.windows import test_base
import ddt
and context from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/tests/windows/fake_win_conn.py
# class FakeWindowsConnector(win_conn_base.BaseWindowsConnector):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
# def get_search_path(self):
# def get_all_available_volumes(self, connection_properties=None):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
, which may include functions, classes, or code. Output only the next line. | expected_wwn = '%s%s' % (mock.sentinel.uid_type, |
Predict the next line after this snippet: <|code_start|> mock_hostutils.check_server_feature.return_value = feature_available
check_mpio = base_win_conn.BaseWindowsConnector.check_multipath_support
if feature_available or not enforce_multipath:
multipath_support = check_mpio(
enforce_multipath=enforce_multipath)
self.assertEqual(feature_available, multipath_support)
else:
self.assertRaises(exception.BrickException,
check_mpio,
enforce_multipath=enforce_multipath)
mock_hostutils.check_server_feature.assert_called_once_with(
mock_hostutils.FEATURE_MPIO)
@ddt.data({}, {'mpio_requested': False}, {'mpio_available': True})
@mock.patch.object(base_win_conn.BaseWindowsConnector,
'check_multipath_support')
@ddt.unpack
def test_get_connector_properties(self, mock_check_mpio,
mpio_requested=True,
mpio_available=True):
mock_check_mpio.return_value = mpio_available
enforce_multipath = False
props = base_win_conn.BaseWindowsConnector.get_connector_properties(
multipath=mpio_requested,
enforce_multipath=enforce_multipath)
self.assertEqual(mpio_requested and mpio_available,
props['multipath'])
if mpio_requested:
<|code_end|>
using the current file's imports:
from unittest import mock
from os_brick import exception
from os_brick.initiator.windows import base as base_win_conn
from os_brick.tests.windows import fake_win_conn
from os_brick.tests.windows import test_base
import ddt
and any relevant context from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/tests/windows/fake_win_conn.py
# class FakeWindowsConnector(win_conn_base.BaseWindowsConnector):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
# def get_search_path(self):
# def get_all_available_volumes(self, connection_properties=None):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | mock_check_mpio.assert_called_once_with(enforce_multipath) |
Continue the code snippet: <|code_start|># Copyright (C) 2016-2022 Lightbits Labs Ltd.
# Copyright (C) 2020 Intel Corporation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
DEVICE_SCAN_ATTEMPTS_DEFAULT = 5
DISCOVERY_CLIENT_PORT = 6060
LOG = logging.getLogger(__name__)
synchronized = lockutils.synchronized_with_prefix('os-brick-')
<|code_end|>
. Use current file imports:
import glob
import http.client
import os
import re
import tempfile
import time
import traceback
from oslo_concurrency import lockutils
from oslo_concurrency import processutils as putils
from oslo_log import log as logging
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator.connectors import base
from os_brick.privileged import lightos as priv_lightos
from os_brick import utils
and context (classes, functions, or code) from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/connectors/base.py
# LOG = logging.getLogger(__name__)
# class BaseLinuxConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper: str, driver=None, execute=None,
# *args, **kwargs):
# def get_connector_properties(root_helper: str, *args, **kwargs) -> dict:
# def check_valid_device(self, path: str, run_as_root: bool = True) -> bool:
# def get_all_available_volumes(self, connection_properties=None):
# def _discover_mpath_device(self,
# device_wwn: str,
# connection_properties: dict,
# device_name: str) -> tuple:
#
# Path: os_brick/privileged/lightos.py
# def delete_dsc_file(file_name):
# def move_dsc_file(src, dst):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | nvmec_pattern = ".*nvme[0-9]+[cp][0-9]+.*" |
Using the snippet: <|code_start|># Copyright (C) 2016-2022 Lightbits Labs Ltd.
# Copyright (C) 2020 Intel Corporation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
DEVICE_SCAN_ATTEMPTS_DEFAULT = 5
DISCOVERY_CLIENT_PORT = 6060
LOG = logging.getLogger(__name__)
synchronized = lockutils.synchronized_with_prefix('os-brick-')
nvmec_pattern = ".*nvme[0-9]+[cp][0-9]+.*"
<|code_end|>
, determine the next line of code. You have imports:
import glob
import http.client
import os
import re
import tempfile
import time
import traceback
from oslo_concurrency import lockutils
from oslo_concurrency import processutils as putils
from oslo_log import log as logging
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator.connectors import base
from os_brick.privileged import lightos as priv_lightos
from os_brick import utils
and context (class names, function names, or code) available:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/connectors/base.py
# LOG = logging.getLogger(__name__)
# class BaseLinuxConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper: str, driver=None, execute=None,
# *args, **kwargs):
# def get_connector_properties(root_helper: str, *args, **kwargs) -> dict:
# def check_valid_device(self, path: str, run_as_root: bool = True) -> bool:
# def get_all_available_volumes(self, connection_properties=None):
# def _discover_mpath_device(self,
# device_wwn: str,
# connection_properties: dict,
# device_name: str) -> tuple:
#
# Path: os_brick/privileged/lightos.py
# def delete_dsc_file(file_name):
# def move_dsc_file(src, dst):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | nvmec_match = re.compile(nvmec_pattern) |
Given the following code snippet before the placeholder: <|code_start|> '/sys/class/fc_transport/target6:*/port_name',
shell=True),
mock.call('grep -Gil "514f0c50023f6c01" '
'/sys/class/fc_transport/target6:*/port_name',
shell=True),
]
execute_mock.assert_has_calls(expected_cmds)
expected = ([['0', '1', 1], ['0', '2', 7]], set())
self.assertEqual(expected, res)
def test__get_hba_channel_scsi_target_lun_zone_manager(self):
execute_results = ('/sys/class/fc_transport/target6:0:1/port_name\n',
'')
hbas, con_props = self.__get_rescan_info(zone_manager=True)
with mock.patch.object(self.lfc, '_execute',
return_value=execute_results) as execute_mock:
res = self.lfc._get_hba_channel_scsi_target_lun(hbas[0], con_props)
execute_mock.assert_called_once_with(
'grep -Gil "514f0c50023f6c00" '
'/sys/class/fc_transport/target6:*/port_name',
shell=True)
expected = ([['0', '1', 1]], set())
self.assertEqual(expected, res)
def test__get_hba_channel_scsi_target_lun_not_found(self):
hbas, con_props = self.__get_rescan_info(zone_manager=True)
with mock.patch.object(self.lfc, '_execute',
return_value=('', '')) as execute_mock:
res = self.lfc._get_hba_channel_scsi_target_lun(hbas[0], con_props)
<|code_end|>
, predict the next line using imports from the current file:
import os.path
from unittest import mock
from os_brick.initiator import linuxfc
from os_brick.tests import base
and context including class names, function names, and sometimes code from other files:
# Path: os_brick/initiator/linuxfc.py
# LOG = logging.getLogger(__name__)
# FC_HOST_SYSFS_PATH = '/sys/class/fc_host'
# class LinuxFibreChannel(linuxscsi.LinuxSCSI):
# class LinuxFibreChannelS390X(LinuxFibreChannel):
# def has_fc_support(self):
# def _get_hba_channel_scsi_target_lun(self, hba, conn_props):
# def rescan_hosts(self, hbas, connection_properties):
# def get_fc_hbas(self):
# def get_fc_hbas_info(self):
# def get_fc_wwpns(self):
# def get_fc_wwnns(self):
# def get_fc_hbas_info(self):
# def configure_scsi_device(self, device_number, target_wwn, lun):
# def deconfigure_scsi_device(self, device_number, target_wwn, lun):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | execute_mock.assert_called_once_with( |
Using the snippet: <|code_start|> self.assertEqual(expected, res)
def test__get_hba_channel_scsi_target_lun_multiple_wwpn(self):
execute_results = [
['/sys/class/fc_transport/target6:0:1/port_name\n', ''],
['/sys/class/fc_transport/target6:0:2/port_name\n', ''],
]
hbas, con_props = self.__get_rescan_info()
with mock.patch.object(self.lfc, '_execute',
side_effect=execute_results) as execute_mock:
res = self.lfc._get_hba_channel_scsi_target_lun(hbas[0], con_props)
expected_cmds = [
mock.call('grep -Gil "514f0c50023f6c00" '
'/sys/class/fc_transport/target6:*/port_name',
shell=True),
mock.call('grep -Gil "514f0c50023f6c01" '
'/sys/class/fc_transport/target6:*/port_name',
shell=True),
]
execute_mock.assert_has_calls(expected_cmds)
expected = ([['0', '1', 1], ['0', '2', 1]], set())
self.assertEqual(expected, res)
def test__get_hba_channel_scsi_target_lun_multiple_wwpn_and_luns(self):
execute_results = [
['/sys/class/fc_transport/target6:0:1/port_name\n', ''],
['/sys/class/fc_transport/target6:0:2/port_name\n', ''],
]
hbas, con_props = self.__get_rescan_info()
<|code_end|>
, determine the next line of code. You have imports:
import os.path
from unittest import mock
from os_brick.initiator import linuxfc
from os_brick.tests import base
and context (class names, function names, or code) available:
# Path: os_brick/initiator/linuxfc.py
# LOG = logging.getLogger(__name__)
# FC_HOST_SYSFS_PATH = '/sys/class/fc_host'
# class LinuxFibreChannel(linuxscsi.LinuxSCSI):
# class LinuxFibreChannelS390X(LinuxFibreChannel):
# def has_fc_support(self):
# def _get_hba_channel_scsi_target_lun(self, hba, conn_props):
# def rescan_hosts(self, hbas, connection_properties):
# def get_fc_hbas(self):
# def get_fc_hbas_info(self):
# def get_fc_wwpns(self):
# def get_fc_wwnns(self):
# def get_fc_hbas_info(self):
# def configure_scsi_device(self, device_number, target_wwn, lun):
# def deconfigure_scsi_device(self, device_number, target_wwn, lun):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | con_props['target_lun'] = [1, 7] |
Predict the next line for this snippet: <|code_start|># distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class BrickExceptionTestCase(base.TestCase):
def test_default_error_msg(self):
class FakeBrickException(exception.BrickException):
message = "default message"
exc = FakeBrickException()
self.assertEqual(str(exc), 'default message')
def test_error_msg(self):
self.assertEqual(str(exception.BrickException('test')),
'test')
def test_default_error_msg_with_kwargs(self):
class FakeBrickException(exception.BrickException):
message = "default message: %(code)s"
exc = FakeBrickException(code=500)
self.assertEqual(str(exc), 'default message: 500')
def test_error_msg_exception_with_kwargs(self):
class FakeBrickException(exception.BrickException):
message = "default message: %(mispelled_code)s"
<|code_end|>
with the help of current file imports:
from os_brick import exception
from os_brick.tests import base
and context from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
, which may contain function names, class names, or code. Output only the next line. | exc = FakeBrickException(code=500) |
Next line prediction: <|code_start|>#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class BrickExceptionTestCase(base.TestCase):
def test_default_error_msg(self):
class FakeBrickException(exception.BrickException):
message = "default message"
exc = FakeBrickException()
self.assertEqual(str(exc), 'default message')
def test_error_msg(self):
self.assertEqual(str(exception.BrickException('test')),
'test')
def test_default_error_msg_with_kwargs(self):
class FakeBrickException(exception.BrickException):
message = "default message: %(code)s"
exc = FakeBrickException(code=500)
self.assertEqual(str(exc), 'default message: 500')
def test_error_msg_exception_with_kwargs(self):
class FakeBrickException(exception.BrickException):
<|code_end|>
. Use current file imports:
(from os_brick import exception
from os_brick.tests import base)
and context including class names, function names, or small code snippets from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | message = "default message: %(mispelled_code)s" |
Predict the next line for this snippet: <|code_start|> if volume != detached:
raise Exception(
'Mismatched volumes on a MockStorPool request removal')
elif detached not in self.attached:
raise Exception('MockStorPool request not attached yet')
del self.attached[detached]
def volumeName(self, vid):
return volumeNameExt(vid)
spopenstack = mock.Mock()
spopenstack.AttachDB = MockStorPoolADB
connector.spopenstack = spopenstack
class StorPoolConnectorTestCase(test_connector.ConnectorTestCase):
def volumeName(self, vid):
return volumeNameExt(vid)
def get_fake_size(self):
return self.fakeSize
def execute(self, *cmd, **kwargs):
if cmd[0] == 'blockdev':
self.assertEqual(len(cmd), 3)
self.assertEqual(cmd[1], '--getsize64')
self.assertEqual(cmd[2], '/dev/storpool/' +
self.volumeName(self.fakeProp['volume']))
return (str(self.get_fake_size()) + '\n', None)
<|code_end|>
with the help of current file imports:
from unittest import mock
from os_brick import exception
from os_brick.initiator.connectors import storpool as connector
from os_brick.tests.initiator import test_connector
and context from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/connectors/storpool.py
# LOG = logging.getLogger(__name__)
# class StorPoolConnector(base.BaseLinuxConnector):
# def __init__(self, root_helper, driver=None,
# *args, **kwargs):
# def get_connector_properties(root_helper, *args, **kwargs):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def get_search_path(self):
# def get_volume_paths(self, connection_properties):
# def get_all_available_volumes(self, connection_properties=None):
# def _get_device_size(self, device):
# def extend_volume(self, connection_properties):
#
# Path: os_brick/tests/initiator/test_connector.py
# MY_IP = '10.0.0.1'
# FAKE_SCSI_WWN = '1234567890'
# class ZeroIntervalLoopingCall(loopingcall.FixedIntervalLoopingCall):
# class ConnectorUtilsTestCase(test_base.TestCase):
# class ConnectorTestCase(test_base.TestCase):
# def start(self, interval, initial_delay=None, stop_on_exception=True):
# def _test_brick_get_connector_properties(self, multipath,
# enforce_multipath,
# multipath_result,
# mock_wwnns, mock_wwpns,
# mock_initiator,
# mock_nqn,
# mock_hostuuid,
# mock_sysuuid,
# host='fakehost'):
# def test_brick_get_connector_properties_connectors_called(self):
# def test_brick_get_connector_properties(self):
# def test_brick_get_connector_properties_multipath(self, mock_execute,
# mock_custom_execute):
# def test_brick_get_connector_properties_fallback(self, mock_execute,
# mock_custom_execute):
# def test_brick_get_connector_properties_raise(self, mock_execute):
# def test_brick_connector_properties_override_hostname(self):
# def setUp(self):
# def fake_execute(self, *cmd, **kwargs):
# def fake_connection(self):
# def test_connect_volume(self):
# def test_disconnect_volume(self):
# def test_get_connector_properties(self):
# def test_get_connector_mapping_win32(self):
# def test_get_connector_mapping(self, mock_platform_machine):
# def test_factory(self):
# def test_check_valid_device_with_wrong_path(self):
# def test_check_valid_device(self):
# def test_check_valid_device_with_cmd_error(self):
# def raise_except(*args, **kwargs):
, which may contain function names, class names, or code. Output only the next line. | raise Exception("Unrecognized command passed to " + |
Using the snippet: <|code_start|>
def test_get_share_name(self):
resulted_name = self._remotefs.get_share_name(self._FAKE_SHARE)
self.assertEqual(self._FAKE_SHARE_NAME, resulted_name)
@ddt.data(True, False)
@mock.patch.object(windows_remotefs.WindowsRemoteFsClient,
'_create_mount_point')
def test_mount(self, is_local_share,
mock_create_mount_point):
flags = '-o pass=password'
self._remotefs._mount_options = '-o user=username,randomopt'
self._remotefs._local_path_for_loopback = True
self._smbutils.check_smb_mapping.return_value = False
self._smbutils.is_local_share.return_value = is_local_share
self._remotefs.mount(self._FAKE_SHARE, flags)
if is_local_share:
self.assertFalse(self._smbutils.check_smb_mapping.called)
self.assertFalse(self._smbutils.mount_smb_share.called)
else:
self._smbutils.check_smb_mapping.assert_called_once_with(
self._FAKE_SHARE)
self._smbutils.mount_smb_share.assert_called_once_with(
self._FAKE_SHARE,
username='username',
password='password')
<|code_end|>
, determine the next line of code. You have imports:
from unittest import mock
from os_brick import exception
from os_brick.remotefs import windows_remotefs
from os_brick.tests import base
import ddt
and context (class names, function names, or code) available:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/remotefs/windows_remotefs.py
# LOG = logging.getLogger(__name__)
# class WindowsRemoteFsClient(remotefs.RemoteFsClient):
# def __init__(self, mount_type, root_helper=None,
# execute=None, *args, **kwargs):
# def get_local_share_path(self, share, expect_existing=True):
# def _get_share_norm_path(self, share):
# def get_share_name(self, share):
# def get_share_subdir(self, share):
# def mount(self, share, flags=None):
# def unmount(self, share):
# def _create_mount_point(self, share, use_local_path):
# def _parse_credentials(self, opts_str):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | mock_create_mount_point.assert_called_once_with(self._FAKE_SHARE, |
Given the following code snippet before the placeholder: <|code_start|> self._smbutils.check_smb_mapping.return_value = False
self._smbutils.is_local_share.return_value = is_local_share
self._remotefs.mount(self._FAKE_SHARE, flags)
if is_local_share:
self.assertFalse(self._smbutils.check_smb_mapping.called)
self.assertFalse(self._smbutils.mount_smb_share.called)
else:
self._smbutils.check_smb_mapping.assert_called_once_with(
self._FAKE_SHARE)
self._smbutils.mount_smb_share.assert_called_once_with(
self._FAKE_SHARE,
username='username',
password='password')
mock_create_mount_point.assert_called_once_with(self._FAKE_SHARE,
is_local_share)
def test_unmount(self):
self._remotefs.unmount(self._FAKE_SHARE)
self._smbutils.unmount_smb_share.assert_called_once_with(
self._FAKE_SHARE)
@ddt.data({'use_local_path': True},
{'path_exists': True, 'is_symlink': True},
{'path_exists': True})
@mock.patch.object(windows_remotefs.WindowsRemoteFsClient,
'get_local_share_path')
@mock.patch.object(windows_remotefs.WindowsRemoteFsClient,
<|code_end|>
, predict the next line using imports from the current file:
from unittest import mock
from os_brick import exception
from os_brick.remotefs import windows_remotefs
from os_brick.tests import base
import ddt
and context including class names, function names, and sometimes code from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/remotefs/windows_remotefs.py
# LOG = logging.getLogger(__name__)
# class WindowsRemoteFsClient(remotefs.RemoteFsClient):
# def __init__(self, mount_type, root_helper=None,
# execute=None, *args, **kwargs):
# def get_local_share_path(self, share, expect_existing=True):
# def _get_share_norm_path(self, share):
# def get_share_name(self, share):
# def get_share_subdir(self, share):
# def mount(self, share, flags=None):
# def unmount(self, share):
# def _create_mount_point(self, share, use_local_path):
# def _parse_credentials(self, opts_str):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | 'get_mount_point') |
Predict the next line for this snippet: <|code_start|> self._remotefs.mount(self._FAKE_SHARE, flags)
if is_local_share:
self.assertFalse(self._smbutils.check_smb_mapping.called)
self.assertFalse(self._smbutils.mount_smb_share.called)
else:
self._smbutils.check_smb_mapping.assert_called_once_with(
self._FAKE_SHARE)
self._smbutils.mount_smb_share.assert_called_once_with(
self._FAKE_SHARE,
username='username',
password='password')
mock_create_mount_point.assert_called_once_with(self._FAKE_SHARE,
is_local_share)
def test_unmount(self):
self._remotefs.unmount(self._FAKE_SHARE)
self._smbutils.unmount_smb_share.assert_called_once_with(
self._FAKE_SHARE)
@ddt.data({'use_local_path': True},
{'path_exists': True, 'is_symlink': True},
{'path_exists': True})
@mock.patch.object(windows_remotefs.WindowsRemoteFsClient,
'get_local_share_path')
@mock.patch.object(windows_remotefs.WindowsRemoteFsClient,
'get_mount_point')
@mock.patch.object(windows_remotefs, 'os')
@ddt.unpack
<|code_end|>
with the help of current file imports:
from unittest import mock
from os_brick import exception
from os_brick.remotefs import windows_remotefs
from os_brick.tests import base
import ddt
and context from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/remotefs/windows_remotefs.py
# LOG = logging.getLogger(__name__)
# class WindowsRemoteFsClient(remotefs.RemoteFsClient):
# def __init__(self, mount_type, root_helper=None,
# execute=None, *args, **kwargs):
# def get_local_share_path(self, share, expect_existing=True):
# def _get_share_norm_path(self, share):
# def get_share_name(self, share):
# def get_share_subdir(self, share):
# def mount(self, share, flags=None):
# def unmount(self, share):
# def _create_mount_point(self, share, use_local_path):
# def _parse_credentials(self, opts_str):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
, which may contain function names, class names, or code. Output only the next line. | def test_create_mount_point(self, mock_os, mock_get_mount_point, |
Given the following code snippet before the placeholder: <|code_start|># Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
try:
except ImportError:
nvmeof_agent = None
<|code_end|>
, predict the next line using imports from the current file:
import errno
import glob
import json
import os.path
import re
import time
from oslo_concurrency import lockutils
from oslo_concurrency import processutils as putils
from oslo_log import log as logging
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator.connectors import base
from os_brick.initiator.connectors import nvmeof_agent
from os_brick.privileged import rootwrap as priv_rootwrap
from os_brick import utils
and context including class names, function names, and sometimes code from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/connectors/base.py
# LOG = logging.getLogger(__name__)
# class BaseLinuxConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper: str, driver=None, execute=None,
# *args, **kwargs):
# def get_connector_properties(root_helper: str, *args, **kwargs) -> dict:
# def check_valid_device(self, path: str, run_as_root: bool = True) -> bool:
# def get_all_available_volumes(self, connection_properties=None):
# def _discover_mpath_device(self,
# device_wwn: str,
# connection_properties: dict,
# device_name: str) -> tuple:
#
# Path: os_brick/privileged/rootwrap.py
# LOG = logging.getLogger(__name__)
# def custom_execute(*cmd, **kwargs):
# def on_timeout(proc):
# def on_execute(proc):
# def on_completion(proc):
# def execute(*cmd, **kwargs):
# def execute_root(*cmd, **kwargs):
# def unlink_root(*links, **kwargs):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | DEV_SEARCH_PATH = '/dev/' |
Continue the code snippet: <|code_start|># Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
try:
except ImportError:
nvmeof_agent = None
DEV_SEARCH_PATH = '/dev/'
DEVICE_SCAN_ATTEMPTS_DEFAULT = 5
<|code_end|>
. Use current file imports:
import errno
import glob
import json
import os.path
import re
import time
from oslo_concurrency import lockutils
from oslo_concurrency import processutils as putils
from oslo_log import log as logging
from os_brick import exception
from os_brick.i18n import _
from os_brick.initiator.connectors import base
from os_brick.initiator.connectors import nvmeof_agent
from os_brick.privileged import rootwrap as priv_rootwrap
from os_brick import utils
and context (classes, functions, or code) from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/i18n.py
# DOMAIN = 'os-brick'
#
# Path: os_brick/initiator/connectors/base.py
# LOG = logging.getLogger(__name__)
# class BaseLinuxConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper: str, driver=None, execute=None,
# *args, **kwargs):
# def get_connector_properties(root_helper: str, *args, **kwargs) -> dict:
# def check_valid_device(self, path: str, run_as_root: bool = True) -> bool:
# def get_all_available_volumes(self, connection_properties=None):
# def _discover_mpath_device(self,
# device_wwn: str,
# connection_properties: dict,
# device_name: str) -> tuple:
#
# Path: os_brick/privileged/rootwrap.py
# LOG = logging.getLogger(__name__)
# def custom_execute(*cmd, **kwargs):
# def on_timeout(proc):
# def on_execute(proc):
# def on_completion(proc):
# def execute(*cmd, **kwargs):
# def execute_root(*cmd, **kwargs):
# def unlink_root(*links, **kwargs):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | synchronized = lockutils.synchronized_with_prefix('os-brick-') |
Given snippet: <|code_start|># Copyright 2016 Cloudbase Solutions Srl
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class WindowsConnectorTestBase(base.TestCase):
@mock.patch('sys.platform', 'win32')
def setUp(self):
super(WindowsConnectorTestBase, self).setUp()
# All the Windows connectors use os_win.utilsfactory to fetch Windows
# specific utils. During init, those will run methods that will fail
# on other platforms. To make testing easier and avoid checking the
# platform in the code, we can simply mock this factory method.
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from unittest import mock
from os_win import utilsfactory
from os_brick.tests import base
and context:
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
which might include code, classes, or functions. Output only the next line. | utilsfactory_patcher = mock.patch.object( |
Given snippet: <|code_start|># a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class HostDriverTestCase(base.TestCase):
def test_get_all_block_devices(self):
fake_dev = ['device1', 'device2']
expected = ['/dev/disk/by-path/' + dev for dev in fake_dev]
driver = host_driver.HostDriver()
with mock.patch('os.listdir', return_value=fake_dev):
actual = driver.get_all_block_devices()
self.assertEqual(expected, actual)
def test_get_all_block_devices_when_oserror_is_enoent(self):
driver = host_driver.HostDriver()
oserror = OSError(errno.ENOENT, "")
with mock.patch('os.listdir', side_effect=oserror):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import errno
from unittest import mock
from os_brick.initiator import host_driver
from os_brick.tests import base
and context:
# Path: os_brick/initiator/host_driver.py
# class HostDriver(object):
# def get_all_block_devices(self):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
which might include code, classes, or functions. Output only the next line. | block_devices = driver.get_all_block_devices() |
Given the code snippet: <|code_start|> mock_configure_scsi_device.assert_called_with(3, 5,
"0x0002000000000000")
self.assertEqual(3, len(devices))
device_path = "/dev/disk/by-path/ccw-3-zfcp-5:0x0002000000000000"
self.assertEqual(devices[0], device_path)
device_path = "/dev/disk/by-path/ccw-3-fc-5-lun-2"
self.assertEqual(devices[1], device_path)
device_path = "/dev/disk/by-path/ccw-3-fc-5-lun-0x0002000000000000"
self.assertEqual(devices[2], device_path)
def test_get_lun_string(self):
lun = 1
lunstring = self.connector._get_lun_string(lun)
self.assertEqual(lunstring, "0x0001000000000000")
lun = 0xff
lunstring = self.connector._get_lun_string(lun)
self.assertEqual(lunstring, "0x00ff000000000000")
lun = 0x101
lunstring = self.connector._get_lun_string(lun)
self.assertEqual(lunstring, "0x0101000000000000")
lun = 0x4020400a
lunstring = self.connector._get_lun_string(lun)
self.assertEqual(lunstring, "0x4020400a00000000")
@mock.patch.object(fibre_channel_s390x.FibreChannelConnectorS390X,
'_get_possible_devices', return_value=[('', 3, 5, 2), ])
@mock.patch.object(linuxfc.LinuxFibreChannelS390X, 'get_fc_hbas_info',
return_value=[])
@mock.patch.object(linuxfc.LinuxFibreChannelS390X,
'deconfigure_scsi_device')
<|code_end|>
, generate the next line using the imports in this file:
from unittest import mock
from os_brick.initiator.connectors import fibre_channel_s390x
from os_brick.initiator import linuxfc
from os_brick.tests.initiator import test_connector
and context (functions, classes, or occasionally code) from other files:
# Path: os_brick/initiator/connectors/fibre_channel_s390x.py
# LOG = logging.getLogger(__name__)
# class FibreChannelConnectorS390X(fibre_channel.FibreChannelConnector):
# def __init__(self, root_helper, driver=None,
# execute=None, use_multipath=False,
# device_scan_attempts=initiator.DEVICE_SCAN_ATTEMPTS_DEFAULT,
# *args, **kwargs):
# def set_execute(self, execute):
# def _get_host_devices(self, possible_devs):
# def _get_lun_string(self, lun):
# def _get_device_file_path(self, pci_num, target_wwn, lun):
# def _remove_devices(self, connection_properties, devices, device_info):
#
# Path: os_brick/initiator/linuxfc.py
# LOG = logging.getLogger(__name__)
# FC_HOST_SYSFS_PATH = '/sys/class/fc_host'
# class LinuxFibreChannel(linuxscsi.LinuxSCSI):
# class LinuxFibreChannelS390X(LinuxFibreChannel):
# def has_fc_support(self):
# def _get_hba_channel_scsi_target_lun(self, hba, conn_props):
# def rescan_hosts(self, hbas, connection_properties):
# def get_fc_hbas(self):
# def get_fc_hbas_info(self):
# def get_fc_wwpns(self):
# def get_fc_wwnns(self):
# def get_fc_hbas_info(self):
# def configure_scsi_device(self, device_number, target_wwn, lun):
# def deconfigure_scsi_device(self, device_number, target_wwn, lun):
#
# Path: os_brick/tests/initiator/test_connector.py
# MY_IP = '10.0.0.1'
# FAKE_SCSI_WWN = '1234567890'
# class ZeroIntervalLoopingCall(loopingcall.FixedIntervalLoopingCall):
# class ConnectorUtilsTestCase(test_base.TestCase):
# class ConnectorTestCase(test_base.TestCase):
# def start(self, interval, initial_delay=None, stop_on_exception=True):
# def _test_brick_get_connector_properties(self, multipath,
# enforce_multipath,
# multipath_result,
# mock_wwnns, mock_wwpns,
# mock_initiator,
# mock_nqn,
# mock_hostuuid,
# mock_sysuuid,
# host='fakehost'):
# def test_brick_get_connector_properties_connectors_called(self):
# def test_brick_get_connector_properties(self):
# def test_brick_get_connector_properties_multipath(self, mock_execute,
# mock_custom_execute):
# def test_brick_get_connector_properties_fallback(self, mock_execute,
# mock_custom_execute):
# def test_brick_get_connector_properties_raise(self, mock_execute):
# def test_brick_connector_properties_override_hostname(self):
# def setUp(self):
# def fake_execute(self, *cmd, **kwargs):
# def fake_connection(self):
# def test_connect_volume(self):
# def test_disconnect_volume(self):
# def test_get_connector_properties(self):
# def test_get_connector_mapping_win32(self):
# def test_get_connector_mapping(self, mock_platform_machine):
# def test_factory(self):
# def test_check_valid_device_with_wrong_path(self):
# def test_check_valid_device(self):
# def test_check_valid_device_with_cmd_error(self):
# def raise_except(*args, **kwargs):
. Output only the next line. | def test_remove_devices(self, mock_deconfigure_scsi_device, |
Here is a snippet: <|code_start|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class FibreChannelConnectorS390XTestCase(test_connector.ConnectorTestCase):
def setUp(self):
super(FibreChannelConnectorS390XTestCase, self).setUp()
self.connector = fibre_channel_s390x.FibreChannelConnectorS390X(
None, execute=self.fake_execute, use_multipath=False)
self.assertIsNotNone(self.connector)
self.assertIsNotNone(self.connector._linuxfc)
self.assertEqual(self.connector._linuxfc.__class__.__name__,
"LinuxFibreChannelS390X")
self.assertIsNotNone(self.connector._linuxscsi)
@mock.patch.object(linuxfc.LinuxFibreChannelS390X, 'configure_scsi_device')
def test_get_host_devices(self, mock_configure_scsi_device):
possible_devs = [(3, 5, 2), ]
<|code_end|>
. Write the next line using the current file imports:
from unittest import mock
from os_brick.initiator.connectors import fibre_channel_s390x
from os_brick.initiator import linuxfc
from os_brick.tests.initiator import test_connector
and context from other files:
# Path: os_brick/initiator/connectors/fibre_channel_s390x.py
# LOG = logging.getLogger(__name__)
# class FibreChannelConnectorS390X(fibre_channel.FibreChannelConnector):
# def __init__(self, root_helper, driver=None,
# execute=None, use_multipath=False,
# device_scan_attempts=initiator.DEVICE_SCAN_ATTEMPTS_DEFAULT,
# *args, **kwargs):
# def set_execute(self, execute):
# def _get_host_devices(self, possible_devs):
# def _get_lun_string(self, lun):
# def _get_device_file_path(self, pci_num, target_wwn, lun):
# def _remove_devices(self, connection_properties, devices, device_info):
#
# Path: os_brick/initiator/linuxfc.py
# LOG = logging.getLogger(__name__)
# FC_HOST_SYSFS_PATH = '/sys/class/fc_host'
# class LinuxFibreChannel(linuxscsi.LinuxSCSI):
# class LinuxFibreChannelS390X(LinuxFibreChannel):
# def has_fc_support(self):
# def _get_hba_channel_scsi_target_lun(self, hba, conn_props):
# def rescan_hosts(self, hbas, connection_properties):
# def get_fc_hbas(self):
# def get_fc_hbas_info(self):
# def get_fc_wwpns(self):
# def get_fc_wwnns(self):
# def get_fc_hbas_info(self):
# def configure_scsi_device(self, device_number, target_wwn, lun):
# def deconfigure_scsi_device(self, device_number, target_wwn, lun):
#
# Path: os_brick/tests/initiator/test_connector.py
# MY_IP = '10.0.0.1'
# FAKE_SCSI_WWN = '1234567890'
# class ZeroIntervalLoopingCall(loopingcall.FixedIntervalLoopingCall):
# class ConnectorUtilsTestCase(test_base.TestCase):
# class ConnectorTestCase(test_base.TestCase):
# def start(self, interval, initial_delay=None, stop_on_exception=True):
# def _test_brick_get_connector_properties(self, multipath,
# enforce_multipath,
# multipath_result,
# mock_wwnns, mock_wwpns,
# mock_initiator,
# mock_nqn,
# mock_hostuuid,
# mock_sysuuid,
# host='fakehost'):
# def test_brick_get_connector_properties_connectors_called(self):
# def test_brick_get_connector_properties(self):
# def test_brick_get_connector_properties_multipath(self, mock_execute,
# mock_custom_execute):
# def test_brick_get_connector_properties_fallback(self, mock_execute,
# mock_custom_execute):
# def test_brick_get_connector_properties_raise(self, mock_execute):
# def test_brick_connector_properties_override_hostname(self):
# def setUp(self):
# def fake_execute(self, *cmd, **kwargs):
# def fake_connection(self):
# def test_connect_volume(self):
# def test_disconnect_volume(self):
# def test_get_connector_properties(self):
# def test_get_connector_mapping_win32(self):
# def test_get_connector_mapping(self, mock_platform_machine):
# def test_factory(self):
# def test_check_valid_device_with_wrong_path(self):
# def test_check_valid_device(self):
# def test_check_valid_device_with_cmd_error(self):
# def raise_except(*args, **kwargs):
, which may include functions, classes, or code. Output only the next line. | devices = self.connector._get_host_devices(possible_devs) |
Predict the next line for this snippet: <|code_start|># a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class FibreChannelConnectorS390XTestCase(test_connector.ConnectorTestCase):
def setUp(self):
super(FibreChannelConnectorS390XTestCase, self).setUp()
self.connector = fibre_channel_s390x.FibreChannelConnectorS390X(
None, execute=self.fake_execute, use_multipath=False)
self.assertIsNotNone(self.connector)
self.assertIsNotNone(self.connector._linuxfc)
self.assertEqual(self.connector._linuxfc.__class__.__name__,
"LinuxFibreChannelS390X")
self.assertIsNotNone(self.connector._linuxscsi)
@mock.patch.object(linuxfc.LinuxFibreChannelS390X, 'configure_scsi_device')
def test_get_host_devices(self, mock_configure_scsi_device):
possible_devs = [(3, 5, 2), ]
devices = self.connector._get_host_devices(possible_devs)
mock_configure_scsi_device.assert_called_with(3, 5,
"0x0002000000000000")
<|code_end|>
with the help of current file imports:
from unittest import mock
from os_brick.initiator.connectors import fibre_channel_s390x
from os_brick.initiator import linuxfc
from os_brick.tests.initiator import test_connector
and context from other files:
# Path: os_brick/initiator/connectors/fibre_channel_s390x.py
# LOG = logging.getLogger(__name__)
# class FibreChannelConnectorS390X(fibre_channel.FibreChannelConnector):
# def __init__(self, root_helper, driver=None,
# execute=None, use_multipath=False,
# device_scan_attempts=initiator.DEVICE_SCAN_ATTEMPTS_DEFAULT,
# *args, **kwargs):
# def set_execute(self, execute):
# def _get_host_devices(self, possible_devs):
# def _get_lun_string(self, lun):
# def _get_device_file_path(self, pci_num, target_wwn, lun):
# def _remove_devices(self, connection_properties, devices, device_info):
#
# Path: os_brick/initiator/linuxfc.py
# LOG = logging.getLogger(__name__)
# FC_HOST_SYSFS_PATH = '/sys/class/fc_host'
# class LinuxFibreChannel(linuxscsi.LinuxSCSI):
# class LinuxFibreChannelS390X(LinuxFibreChannel):
# def has_fc_support(self):
# def _get_hba_channel_scsi_target_lun(self, hba, conn_props):
# def rescan_hosts(self, hbas, connection_properties):
# def get_fc_hbas(self):
# def get_fc_hbas_info(self):
# def get_fc_wwpns(self):
# def get_fc_wwnns(self):
# def get_fc_hbas_info(self):
# def configure_scsi_device(self, device_number, target_wwn, lun):
# def deconfigure_scsi_device(self, device_number, target_wwn, lun):
#
# Path: os_brick/tests/initiator/test_connector.py
# MY_IP = '10.0.0.1'
# FAKE_SCSI_WWN = '1234567890'
# class ZeroIntervalLoopingCall(loopingcall.FixedIntervalLoopingCall):
# class ConnectorUtilsTestCase(test_base.TestCase):
# class ConnectorTestCase(test_base.TestCase):
# def start(self, interval, initial_delay=None, stop_on_exception=True):
# def _test_brick_get_connector_properties(self, multipath,
# enforce_multipath,
# multipath_result,
# mock_wwnns, mock_wwpns,
# mock_initiator,
# mock_nqn,
# mock_hostuuid,
# mock_sysuuid,
# host='fakehost'):
# def test_brick_get_connector_properties_connectors_called(self):
# def test_brick_get_connector_properties(self):
# def test_brick_get_connector_properties_multipath(self, mock_execute,
# mock_custom_execute):
# def test_brick_get_connector_properties_fallback(self, mock_execute,
# mock_custom_execute):
# def test_brick_get_connector_properties_raise(self, mock_execute):
# def test_brick_connector_properties_override_hostname(self):
# def setUp(self):
# def fake_execute(self, *cmd, **kwargs):
# def fake_connection(self):
# def test_connect_volume(self):
# def test_disconnect_volume(self):
# def test_get_connector_properties(self):
# def test_get_connector_mapping_win32(self):
# def test_get_connector_mapping(self, mock_platform_machine):
# def test_factory(self):
# def test_check_valid_device_with_wrong_path(self):
# def test_check_valid_device(self):
# def test_check_valid_device_with_cmd_error(self):
# def raise_except(*args, **kwargs):
, which may contain function names, class names, or code. Output only the next line. | self.assertEqual(3, len(devices)) |
Given the code snippet: <|code_start|># Copyright (c) 2013 The Johns Hopkins University/Applied Physics Laboratory
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class NoOpEncryptorTestCase(test_base.VolumeEncryptorTestCase):
def _create(self):
return nop.NoOpEncryptor(root_helper=self.root_helper,
connection_info=self.connection_info,
keymgr=self.keymgr)
<|code_end|>
, generate the next line using the imports in this file:
from os_brick.encryptors import nop
from os_brick.tests.encryptors import test_base
and context (functions, classes, or occasionally code) from other files:
# Path: os_brick/encryptors/nop.py
# class NoOpEncryptor(base.VolumeEncryptor):
# def __init__(self, root_helper,
# connection_info,
# keymgr,
# execute=None,
# *args, **kwargs):
# def attach_volume(self, context, **kwargs):
# def detach_volume(self, **kwargs):
#
# Path: os_brick/tests/encryptors/test_base.py
# class VolumeEncryptorTestCase(base.TestCase):
# class BaseEncryptorTestCase(VolumeEncryptorTestCase):
# def _create(self):
# def setUp(self):
# def _test_get_encryptor(self, provider, expected_provider_class):
# def test_get_encryptors(self):
# def test_get_error_encryptors(self):
# def test_error_log(self, log):
# def test_get_missing_out_of_tree_encryptor_log(self, log):
# def test_get_direct_encryptor_log(self, log):
. Output only the next line. | def test_attach_volume(self): |
Given the code snippet: <|code_start|># Copyright (c) 2013 The Johns Hopkins University/Applied Physics Laboratory
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class NoOpEncryptorTestCase(test_base.VolumeEncryptorTestCase):
def _create(self):
return nop.NoOpEncryptor(root_helper=self.root_helper,
connection_info=self.connection_info,
keymgr=self.keymgr)
def test_attach_volume(self):
test_args = {
'control_location': 'front-end',
<|code_end|>
, generate the next line using the imports in this file:
from os_brick.encryptors import nop
from os_brick.tests.encryptors import test_base
and context (functions, classes, or occasionally code) from other files:
# Path: os_brick/encryptors/nop.py
# class NoOpEncryptor(base.VolumeEncryptor):
# def __init__(self, root_helper,
# connection_info,
# keymgr,
# execute=None,
# *args, **kwargs):
# def attach_volume(self, context, **kwargs):
# def detach_volume(self, **kwargs):
#
# Path: os_brick/tests/encryptors/test_base.py
# class VolumeEncryptorTestCase(base.TestCase):
# class BaseEncryptorTestCase(VolumeEncryptorTestCase):
# def _create(self):
# def setUp(self):
# def _test_get_encryptor(self, provider, expected_provider_class):
# def test_get_encryptors(self):
# def test_get_error_encryptors(self):
# def test_error_log(self, log):
# def test_get_missing_out_of_tree_encryptor_log(self, log):
# def test_get_direct_encryptor_log(self, log):
. Output only the next line. | 'provider': 'NoOpEncryptor', |
Here is a snippet: <|code_start|>#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class PrivRBDTestCase(base.TestCase):
def setUp(self):
super(PrivRBDTestCase, self).setUp()
# Disable privsep server/client mode
privsep_brick.default.set_client_mode(False)
self.addCleanup(privsep_brick.default.set_client_mode, True)
@mock.patch('oslo_utils.importutils.import_class')
def test__get_rbd_class(self, mock_import):
self.assertIsNone(privsep_rbd.RBDConnector)
self.assertIs(privsep_rbd._get_rbd_class, privsep_rbd.get_rbd_class)
self.addCleanup(setattr, privsep_rbd, 'RBDConnector', None)
self.addCleanup(setattr, privsep_rbd, 'get_rbd_class',
privsep_rbd._get_rbd_class)
privsep_rbd._get_rbd_class()
<|code_end|>
. Write the next line using the current file imports:
from unittest import mock
from os_brick.tests import base
import os_brick.privileged as privsep_brick
import os_brick.privileged.rbd as privsep_rbd
and context from other files:
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
, which may include functions, classes, or code. Output only the next line. | mock_import.assert_called_once_with( |
Given the code snippet: <|code_start|> os_win_exc.OSWinException, None, None]
self._iscsi_utils.get_device_number_and_path.return_value = (
mock.sentinel.device_number, mock.sentinel.device_path)
self._connector.use_multipath = use_multipath
device_info = self._connector.connect_volume(fake_conn_props)
expected_device_info = dict(type='block',
path=mock.sentinel.device_path,
number=mock.sentinel.device_number,
scsi_wwn=mock_get_scsi_wwn.return_value)
self.assertEqual(expected_device_info, device_info)
mock_get_all_paths.assert_called_once_with(fake_conn_props)
expected_login_attempts = 3 if use_multipath else 2
self._iscsi_utils.login_storage_target.assert_has_calls(
[mock.call(target_lun=mock.sentinel.target_lun,
target_iqn=mock.sentinel.target_iqn,
target_portal=mock.sentinel.target_portal,
auth_username=mock.sentinel.auth_username,
auth_password=mock.sentinel.auth_password,
mpio_enabled=use_multipath,
initiator_name=mock.sentinel.initiator_name,
ensure_lun_available=False)] *
expected_login_attempts)
self._iscsi_utils.get_device_number_and_path.assert_called_once_with(
mock.sentinel.target_iqn, mock.sentinel.target_lun,
retry_attempts=self._connector.device_scan_attempts,
retry_interval=self._connector.device_scan_interval,
rescan_disks=True,
<|code_end|>
, generate the next line using the imports in this file:
from unittest import mock
from os_win import exceptions as os_win_exc
from os_brick import exception
from os_brick.initiator.windows import iscsi
from os_brick.tests.windows import test_base
import ddt
and context (functions, classes, or occasionally code) from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/iscsi.py
# LOG = logging.getLogger(__name__)
# class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
# base_iscsi.BaseISCSIConnector):
# def __init__(self, *args, **kwargs):
# def validate_initiators(self):
# def get_initiator(self):
# def get_connector_properties(*args, **kwargs):
# def _get_all_paths(self, connection_properties):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info=None,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | ensure_mpio_claimed=use_multipath) |
Given the following code snippet before the placeholder: <|code_start|># Copyright 2016 Cloudbase Solutions Srl
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
@ddt.ddt
class WindowsISCSIConnectorTestCase(test_base.WindowsConnectorTestBase):
@mock.patch.object(iscsi.WindowsISCSIConnector, 'validate_initiators')
def setUp(self, mock_validate_connectors):
super(WindowsISCSIConnectorTestCase, self).setUp()
self._diskutils = mock.Mock()
self._iscsi_utils = mock.Mock()
self._connector = iscsi.WindowsISCSIConnector(
<|code_end|>
, predict the next line using imports from the current file:
from unittest import mock
from os_win import exceptions as os_win_exc
from os_brick import exception
from os_brick.initiator.windows import iscsi
from os_brick.tests.windows import test_base
import ddt
and context including class names, function names, and sometimes code from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/iscsi.py
# LOG = logging.getLogger(__name__)
# class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
# base_iscsi.BaseISCSIConnector):
# def __init__(self, *args, **kwargs):
# def validate_initiators(self):
# def get_initiator(self):
# def get_connector_properties(*args, **kwargs):
# def _get_all_paths(self, connection_properties):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info=None,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | device_scan_interval=mock.sentinel.rescan_interval) |
Next line prediction: <|code_start|>
self.assertRaises(exception.BrickException,
self._connector.connect_volume,
connection_properties={})
@mock.patch.object(iscsi.WindowsISCSIConnector, '_get_all_targets')
def test_disconnect_volume(self, mock_get_all_targets):
targets = [
(mock.sentinel.portal_0, mock.sentinel.tg_0, mock.sentinel.lun_0),
(mock.sentinel.portal_1, mock.sentinel.tg_1, mock.sentinel.lun_1)]
mock_get_all_targets.return_value = targets
self._iscsi_utils.get_target_luns.return_value = [mock.sentinel.lun_0]
self._connector.disconnect_volume(mock.sentinel.conn_props,
mock.sentinel.dev_info)
self._diskutils.rescan_disks.assert_called_once_with()
mock_get_all_targets.assert_called_once_with(mock.sentinel.conn_props)
self._iscsi_utils.logout_storage_target.assert_called_once_with(
mock.sentinel.tg_0)
self._iscsi_utils.get_target_luns.assert_has_calls(
[mock.call(mock.sentinel.tg_0), mock.call(mock.sentinel.tg_1)])
@mock.patch.object(iscsi.WindowsISCSIConnector, '_get_all_targets')
@mock.patch.object(iscsi.WindowsISCSIConnector, '_check_device_paths')
def test_get_volume_paths(self, mock_check_dev_paths,
mock_get_all_targets):
targets = [
(mock.sentinel.portal_0, mock.sentinel.tg_0, mock.sentinel.lun_0),
<|code_end|>
. Use current file imports:
(from unittest import mock
from os_win import exceptions as os_win_exc
from os_brick import exception
from os_brick.initiator.windows import iscsi
from os_brick.tests.windows import test_base
import ddt)
and context including class names, function names, or small code snippets from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/iscsi.py
# LOG = logging.getLogger(__name__)
# class WindowsISCSIConnector(win_conn_base.BaseWindowsConnector,
# base_iscsi.BaseISCSIConnector):
# def __init__(self, *args, **kwargs):
# def validate_initiators(self):
# def get_initiator(self):
# def get_connector_properties(*args, **kwargs):
# def _get_all_paths(self, connection_properties):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info=None,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | (mock.sentinel.portal_1, mock.sentinel.tg_1, mock.sentinel.lun_1)] |
Predict the next line after this snippet: <|code_start|> disk_path = self._get_disk_path(connection_properties)
if self._expect_raw_disk:
# The caller expects a direct accessible raw disk. We'll
# mount the image and bring the new disk offline, which will
# allow direct IO, while ensuring that any partiton residing
# on it will be unmounted.
read_only = connection_properties.get('access_mode') == 'ro'
self._vhdutils.attach_virtual_disk(disk_path, read_only=read_only)
raw_disk_path = self._vhdutils.get_virtual_disk_physical_path(
disk_path)
dev_num = self._diskutils.get_device_number_from_device_name(
raw_disk_path)
self._diskutils.set_disk_offline(dev_num)
else:
raw_disk_path = None
device_info = {'type': 'file',
'path': raw_disk_path if self._expect_raw_disk
else disk_path}
return device_info
@utils.trace
def disconnect_volume(self, connection_properties, device_info=None,
force=False, ignore_errors=False):
export_path = self._get_export_path(connection_properties)
disk_path = self._get_disk_path(connection_properties)
# The detach method will silently continue if the disk is
# not attached.
<|code_end|>
using the current file's imports:
import os
from os_win import utilsfactory
from os_brick.initiator.windows import base as win_conn_base
from os_brick.remotefs import windows_remotefs as remotefs
from os_brick import utils
and any relevant context from other files:
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/remotefs/windows_remotefs.py
# LOG = logging.getLogger(__name__)
# class WindowsRemoteFsClient(remotefs.RemoteFsClient):
# def __init__(self, mount_type, root_helper=None,
# execute=None, *args, **kwargs):
# def get_local_share_path(self, share, expect_existing=True):
# def _get_share_norm_path(self, share):
# def get_share_name(self, share):
# def get_share_subdir(self, share):
# def mount(self, share, flags=None):
# def unmount(self, share):
# def _create_mount_point(self, share, use_local_path):
# def _parse_credentials(self, opts_str):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | self._vhdutils.detach_virtual_disk(disk_path) |
Predict the next line for this snippet: <|code_start|># Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# The Windows SMBFS connector expects to receive VHD/x images stored on SMB
# shares, exposed by the Cinder SMBFS driver.
class WindowsSMBFSConnector(win_conn_base.BaseWindowsConnector):
def __init__(self, *args, **kwargs):
super(WindowsSMBFSConnector, self).__init__(*args, **kwargs)
# If this flag is set, we use the local paths in case of local
# shares. This is in fact mandatory in some cases, for example
# for the Hyper-C scenario.
self._local_path_for_loopback = kwargs.get('local_path_for_loopback',
True)
self._expect_raw_disk = kwargs.get('expect_raw_disk', False)
self._remotefsclient = remotefs.WindowsRemoteFsClient(
mount_type='smbfs',
*args, **kwargs)
self._smbutils = utilsfactory.get_smbutils()
self._vhdutils = utilsfactory.get_vhdutils()
self._diskutils = utilsfactory.get_diskutils()
@staticmethod
<|code_end|>
with the help of current file imports:
import os
from os_win import utilsfactory
from os_brick.initiator.windows import base as win_conn_base
from os_brick.remotefs import windows_remotefs as remotefs
from os_brick import utils
and context from other files:
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/remotefs/windows_remotefs.py
# LOG = logging.getLogger(__name__)
# class WindowsRemoteFsClient(remotefs.RemoteFsClient):
# def __init__(self, mount_type, root_helper=None,
# execute=None, *args, **kwargs):
# def get_local_share_path(self, share, expect_existing=True):
# def _get_share_norm_path(self, share):
# def get_share_name(self, share):
# def get_share_subdir(self, share):
# def mount(self, share, flags=None):
# def unmount(self, share):
# def _create_mount_point(self, share, use_local_path):
# def _parse_credentials(self, opts_str):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
, which may contain function names, class names, or code. Output only the next line. | def get_connector_properties(*args, **kwargs): |
Using the snippet: <|code_start|># Copyright 2016 Cloudbase Solutions Srl
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# The Windows SMBFS connector expects to receive VHD/x images stored on SMB
# shares, exposed by the Cinder SMBFS driver.
class WindowsSMBFSConnector(win_conn_base.BaseWindowsConnector):
def __init__(self, *args, **kwargs):
super(WindowsSMBFSConnector, self).__init__(*args, **kwargs)
# If this flag is set, we use the local paths in case of local
# shares. This is in fact mandatory in some cases, for example
# for the Hyper-C scenario.
self._local_path_for_loopback = kwargs.get('local_path_for_loopback',
<|code_end|>
, determine the next line of code. You have imports:
import os
from os_win import utilsfactory
from os_brick.initiator.windows import base as win_conn_base
from os_brick.remotefs import windows_remotefs as remotefs
from os_brick import utils
and context (class names, function names, or code) available:
# Path: os_brick/initiator/windows/base.py
# LOG = logging.getLogger(__name__)
# DEFAULT_DEVICE_SCAN_INTERVAL = 2
# class BaseWindowsConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper=None, *args, **kwargs):
# def check_multipath_support(enforce_multipath):
# def get_connector_properties(*args, **kwargs):
# def _get_scsi_wwn(self, device_number):
# def check_valid_device(self, path, *args, **kwargs):
# def get_all_available_volumes(self):
# def _check_device_paths(self, device_paths):
# def extend_volume(self, connection_properties):
# def get_search_path(self):
#
# Path: os_brick/remotefs/windows_remotefs.py
# LOG = logging.getLogger(__name__)
# class WindowsRemoteFsClient(remotefs.RemoteFsClient):
# def __init__(self, mount_type, root_helper=None,
# execute=None, *args, **kwargs):
# def get_local_share_path(self, share, expect_existing=True):
# def _get_share_norm_path(self, share):
# def get_share_name(self, share):
# def get_share_subdir(self, share):
# def mount(self, share, flags=None):
# def unmount(self, share):
# def _create_mount_point(self, share, use_local_path):
# def _parse_credentials(self, opts_str):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | True) |
Given snippet: <|code_start|> fake_disk_name = 'fake_disk.vhdx'
fake_conn_props = dict(name=fake_disk_name,
export=fake_export_path)
self._remotefs.get_mount_base.return_value = mount_base
self._remotefs.get_mount_point.return_value = fake_mount_point
self._remotefs.get_local_share_path.return_value = (
fake_local_share_path)
self._remotefs.get_share_name.return_value = fake_share_name
self._connector._local_path_for_loopback = local_path_for_loopbk
self._connector._smbutils.is_local_share.return_value = is_local_share
expecting_local = local_path_for_loopbk and is_local_share
if mount_base:
expected_export_path = fake_mount_point
elif expecting_local:
# In this case, we expect the local share export path to be
# used directly.
expected_export_path = fake_local_share_path
else:
expected_export_path = fake_export_path
expected_disk_path = os.path.join(expected_export_path,
fake_disk_name)
disk_path = self._connector._get_disk_path(fake_conn_props)
self.assertEqual(expected_disk_path, disk_path)
if mount_base:
self._remotefs.get_mount_point.assert_called_once_with(
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import os
import ddt
from unittest import mock
from os_brick.initiator.windows import smbfs
from os_brick.remotefs import windows_remotefs
from os_brick.tests.windows import test_base
and context:
# Path: os_brick/initiator/windows/smbfs.py
# class WindowsSMBFSConnector(win_conn_base.BaseWindowsConnector):
# def __init__(self, *args, **kwargs):
# def get_connector_properties(*args, **kwargs):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info=None,
# force=False, ignore_errors=False):
# def _get_export_path(self, connection_properties):
# def _get_disk_path(self, connection_properties):
# def get_search_path(self):
# def get_volume_paths(self, connection_properties):
# def ensure_share_mounted(self, connection_properties):
# def extend_volume(self, connection_properties):
#
# Path: os_brick/remotefs/windows_remotefs.py
# LOG = logging.getLogger(__name__)
# class WindowsRemoteFsClient(remotefs.RemoteFsClient):
# def __init__(self, mount_type, root_helper=None,
# execute=None, *args, **kwargs):
# def get_local_share_path(self, share, expect_existing=True):
# def _get_share_norm_path(self, share):
# def get_share_name(self, share):
# def get_share_subdir(self, share):
# def mount(self, share, flags=None):
# def unmount(self, share):
# def _create_mount_point(self, share, use_local_path):
# def _parse_credentials(self, opts_str):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
which might include code, classes, or functions. Output only the next line. | fake_export_path) |
Using the snippet: <|code_start|> self._load_connector()
@mock.patch.object(windows_remotefs, 'WindowsRemoteFsClient')
def _load_connector(self, mock_remotefs_cls, *args, **kwargs):
self._connector = smbfs.WindowsSMBFSConnector(*args, **kwargs)
self._remotefs = mock_remotefs_cls.return_value
self._vhdutils = self._connector._vhdutils
self._diskutils = self._connector._diskutils
@mock.patch.object(smbfs.WindowsSMBFSConnector, '_get_disk_path')
@mock.patch.object(smbfs.WindowsSMBFSConnector, 'ensure_share_mounted')
def test_connect_volume(self, mock_ensure_mounted,
mock_get_disk_path):
device_info = self._connector.connect_volume(mock.sentinel.conn_props)
expected_info = dict(type='file',
path=mock_get_disk_path.return_value)
self.assertEqual(expected_info, device_info)
mock_ensure_mounted.assert_called_once_with(mock.sentinel.conn_props)
mock_get_disk_path.assert_called_once_with(mock.sentinel.conn_props)
@ddt.data(True, False)
@mock.patch.object(smbfs.WindowsSMBFSConnector, '_get_disk_path')
@mock.patch.object(smbfs.WindowsSMBFSConnector, 'ensure_share_mounted')
def test_connect_and_mount_volume(self, read_only,
mock_ensure_mounted,
mock_get_disk_path):
self._load_connector(expect_raw_disk=True)
<|code_end|>
, determine the next line of code. You have imports:
import os
import ddt
from unittest import mock
from os_brick.initiator.windows import smbfs
from os_brick.remotefs import windows_remotefs
from os_brick.tests.windows import test_base
and context (class names, function names, or code) available:
# Path: os_brick/initiator/windows/smbfs.py
# class WindowsSMBFSConnector(win_conn_base.BaseWindowsConnector):
# def __init__(self, *args, **kwargs):
# def get_connector_properties(*args, **kwargs):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info=None,
# force=False, ignore_errors=False):
# def _get_export_path(self, connection_properties):
# def _get_disk_path(self, connection_properties):
# def get_search_path(self):
# def get_volume_paths(self, connection_properties):
# def ensure_share_mounted(self, connection_properties):
# def extend_volume(self, connection_properties):
#
# Path: os_brick/remotefs/windows_remotefs.py
# LOG = logging.getLogger(__name__)
# class WindowsRemoteFsClient(remotefs.RemoteFsClient):
# def __init__(self, mount_type, root_helper=None,
# execute=None, *args, **kwargs):
# def get_local_share_path(self, share, expect_existing=True):
# def _get_share_norm_path(self, share):
# def get_share_name(self, share):
# def get_share_subdir(self, share):
# def mount(self, share, flags=None):
# def unmount(self, share):
# def _create_mount_point(self, share, use_local_path):
# def _parse_credentials(self, opts_str):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | fake_conn_props = dict(access_mode='ro' if read_only else 'rw') |
Here is a snippet: <|code_start|># License for the specific language governing permissions and limitations
# under the License.
@ddt.ddt
class WindowsSMBFSConnectorTestCase(test_base.WindowsConnectorTestBase):
def setUp(self):
super(WindowsSMBFSConnectorTestCase, self).setUp()
self._load_connector()
@mock.patch.object(windows_remotefs, 'WindowsRemoteFsClient')
def _load_connector(self, mock_remotefs_cls, *args, **kwargs):
self._connector = smbfs.WindowsSMBFSConnector(*args, **kwargs)
self._remotefs = mock_remotefs_cls.return_value
self._vhdutils = self._connector._vhdutils
self._diskutils = self._connector._diskutils
@mock.patch.object(smbfs.WindowsSMBFSConnector, '_get_disk_path')
@mock.patch.object(smbfs.WindowsSMBFSConnector, 'ensure_share_mounted')
def test_connect_volume(self, mock_ensure_mounted,
mock_get_disk_path):
device_info = self._connector.connect_volume(mock.sentinel.conn_props)
expected_info = dict(type='file',
path=mock_get_disk_path.return_value)
<|code_end|>
. Write the next line using the current file imports:
import os
import ddt
from unittest import mock
from os_brick.initiator.windows import smbfs
from os_brick.remotefs import windows_remotefs
from os_brick.tests.windows import test_base
and context from other files:
# Path: os_brick/initiator/windows/smbfs.py
# class WindowsSMBFSConnector(win_conn_base.BaseWindowsConnector):
# def __init__(self, *args, **kwargs):
# def get_connector_properties(*args, **kwargs):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info=None,
# force=False, ignore_errors=False):
# def _get_export_path(self, connection_properties):
# def _get_disk_path(self, connection_properties):
# def get_search_path(self):
# def get_volume_paths(self, connection_properties):
# def ensure_share_mounted(self, connection_properties):
# def extend_volume(self, connection_properties):
#
# Path: os_brick/remotefs/windows_remotefs.py
# LOG = logging.getLogger(__name__)
# class WindowsRemoteFsClient(remotefs.RemoteFsClient):
# def __init__(self, mount_type, root_helper=None,
# execute=None, *args, **kwargs):
# def get_local_share_path(self, share, expect_existing=True):
# def _get_share_norm_path(self, share):
# def get_share_name(self, share):
# def get_share_subdir(self, share):
# def mount(self, share, flags=None):
# def unmount(self, share):
# def _create_mount_point(self, share, use_local_path):
# def _parse_credentials(self, opts_str):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
, which may include functions, classes, or code. Output only the next line. | self.assertEqual(expected_info, device_info) |
Continue the code snippet: <|code_start|>
@mock.patch('os_brick.executor.Executor._execute')
def test__close_volume(self, mock_execute):
self.encryptor.detach_volume()
mock_execute.assert_has_calls([
mock.call('cryptsetup', 'remove', self.dev_name,
root_helper=self.root_helper,
run_as_root=True, check_exit_code=[0, 4]),
])
@mock.patch('os_brick.executor.Executor._execute')
def test_detach_volume(self, mock_execute):
self.encryptor.detach_volume()
mock_execute.assert_has_calls([
mock.call('cryptsetup', 'remove', self.dev_name,
root_helper=self.root_helper,
run_as_root=True, check_exit_code=[0, 4]),
])
def test_init_volume_encryption_not_supported(self):
# Tests that creating a CryptsetupEncryptor fails if there is no
# device_path key.
type = 'unencryptable'
data = dict(volume_id='a194699b-aa07-4433-a945-a5d23802043e')
connection_info = dict(driver_volume_type=type, data=data)
exc = self.assertRaises(exception.VolumeEncryptionNotSupported,
cryptsetup.CryptsetupEncryptor,
root_helper=self.root_helper,
<|code_end|>
. Use current file imports:
import binascii
import copy
from unittest import mock
from castellan.common.objects import symmetric_key as key
from castellan.tests.unit.key_manager import fake
from os_brick.encryptors import cryptsetup
from os_brick import exception
from os_brick.tests.encryptors import test_base
and context (classes, functions, or code) from other files:
# Path: os_brick/encryptors/cryptsetup.py
# LOG = logging.getLogger(__name__)
# class CryptsetupEncryptor(base.VolumeEncryptor):
# def __init__(self, root_helper,
# connection_info,
# keymgr,
# execute=None,
# *args, **kwargs):
# def _is_crypt_device_available(self, dev_name):
# def _get_passphrase(self, key):
# def _open_volume(self, passphrase, **kwargs):
# def attach_volume(self, context, **kwargs):
# def _close_volume(self, **kwargs):
# def detach_volume(self, **kwargs):
#
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/tests/encryptors/test_base.py
# class VolumeEncryptorTestCase(base.TestCase):
# class BaseEncryptorTestCase(VolumeEncryptorTestCase):
# def _create(self):
# def setUp(self):
# def _test_get_encryptor(self, provider, expected_provider_class):
# def test_get_encryptors(self):
# def test_get_error_encryptors(self):
# def test_error_log(self, log):
# def test_get_missing_out_of_tree_encryptor_log(self, log):
# def test_get_direct_encryptor_log(self, log):
. Output only the next line. | connection_info=connection_info, |
Predict the next line for this snippet: <|code_start|>def fake__get_key(context, passphrase):
raw = bytes(binascii.unhexlify(passphrase))
symmetric_key = key.SymmetricKey('AES', len(raw) * 8, raw)
return symmetric_key
class CryptsetupEncryptorTestCase(test_base.VolumeEncryptorTestCase):
@mock.patch('os.path.exists', return_value=False)
def _create(self, mock_exists):
return cryptsetup.CryptsetupEncryptor(
connection_info=self.connection_info,
root_helper=self.root_helper,
keymgr=self.keymgr)
def setUp(self):
super(CryptsetupEncryptorTestCase, self).setUp()
self.dev_path = self.connection_info['data']['device_path']
self.dev_name = 'crypt-%s' % self.dev_path.split('/')[-1]
self.symlink_path = self.dev_path
@mock.patch('os_brick.executor.Executor._execute')
def test__open_volume(self, mock_execute):
self.encryptor._open_volume("passphrase")
mock_execute.assert_has_calls([
mock.call('cryptsetup', 'create', '--key-file=-', self.dev_name,
self.dev_path, process_input='passphrase',
<|code_end|>
with the help of current file imports:
import binascii
import copy
from unittest import mock
from castellan.common.objects import symmetric_key as key
from castellan.tests.unit.key_manager import fake
from os_brick.encryptors import cryptsetup
from os_brick import exception
from os_brick.tests.encryptors import test_base
and context from other files:
# Path: os_brick/encryptors/cryptsetup.py
# LOG = logging.getLogger(__name__)
# class CryptsetupEncryptor(base.VolumeEncryptor):
# def __init__(self, root_helper,
# connection_info,
# keymgr,
# execute=None,
# *args, **kwargs):
# def _is_crypt_device_available(self, dev_name):
# def _get_passphrase(self, key):
# def _open_volume(self, passphrase, **kwargs):
# def attach_volume(self, context, **kwargs):
# def _close_volume(self, **kwargs):
# def detach_volume(self, **kwargs):
#
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/tests/encryptors/test_base.py
# class VolumeEncryptorTestCase(base.TestCase):
# class BaseEncryptorTestCase(VolumeEncryptorTestCase):
# def _create(self):
# def setUp(self):
# def _test_get_encryptor(self, provider, expected_provider_class):
# def test_get_encryptors(self):
# def test_get_error_encryptors(self):
# def test_error_log(self, log):
# def test_get_missing_out_of_tree_encryptor_log(self, log):
# def test_get_direct_encryptor_log(self, log):
, which may contain function names, class names, or code. Output only the next line. | run_as_root=True, |
Continue the code snippet: <|code_start|> self.symlink_path = self.dev_path
@mock.patch('os_brick.executor.Executor._execute')
def test__open_volume(self, mock_execute):
self.encryptor._open_volume("passphrase")
mock_execute.assert_has_calls([
mock.call('cryptsetup', 'create', '--key-file=-', self.dev_name,
self.dev_path, process_input='passphrase',
run_as_root=True,
root_helper=self.root_helper,
check_exit_code=True),
])
@mock.patch('os_brick.executor.Executor._execute')
def test_attach_volume(self, mock_execute):
fake_key = 'e8b76872e3b04c18b3b6656bbf6f5089'
self.encryptor._get_key = mock.MagicMock()
self.encryptor._get_key.return_value = fake__get_key(None, fake_key)
self.encryptor.attach_volume(None)
mock_execute.assert_has_calls([
mock.call('cryptsetup', 'create', '--key-file=-', self.dev_name,
self.dev_path, process_input=fake_key,
root_helper=self.root_helper,
run_as_root=True, check_exit_code=True),
mock.call('ln', '--symbolic', '--force',
'/dev/mapper/%s' % self.dev_name, self.symlink_path,
root_helper=self.root_helper,
<|code_end|>
. Use current file imports:
import binascii
import copy
from unittest import mock
from castellan.common.objects import symmetric_key as key
from castellan.tests.unit.key_manager import fake
from os_brick.encryptors import cryptsetup
from os_brick import exception
from os_brick.tests.encryptors import test_base
and context (classes, functions, or code) from other files:
# Path: os_brick/encryptors/cryptsetup.py
# LOG = logging.getLogger(__name__)
# class CryptsetupEncryptor(base.VolumeEncryptor):
# def __init__(self, root_helper,
# connection_info,
# keymgr,
# execute=None,
# *args, **kwargs):
# def _is_crypt_device_available(self, dev_name):
# def _get_passphrase(self, key):
# def _open_volume(self, passphrase, **kwargs):
# def attach_volume(self, context, **kwargs):
# def _close_volume(self, **kwargs):
# def detach_volume(self, **kwargs):
#
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/tests/encryptors/test_base.py
# class VolumeEncryptorTestCase(base.TestCase):
# class BaseEncryptorTestCase(VolumeEncryptorTestCase):
# def _create(self):
# def setUp(self):
# def _test_get_encryptor(self, provider, expected_provider_class):
# def test_get_encryptors(self):
# def test_get_error_encryptors(self):
# def test_error_log(self, log):
# def test_get_missing_out_of_tree_encryptor_log(self, log):
# def test_get_direct_encryptor_log(self, log):
. Output only the next line. | run_as_root=True, check_exit_code=True), |
Predict the next line after this snippet: <|code_start|># Copyright 2018 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class InitiatorUtilsTestCase(base.TestCase):
@mock.patch('os.name', 'nt')
def test_check_manual_scan_windows(self):
self.assertFalse(utils.check_manual_scan())
@mock.patch('os.name', 'posix')
@mock.patch('oslo_concurrency.processutils.execute')
<|code_end|>
using the current file's imports:
from unittest import mock
from os_brick.initiator import utils
from os_brick.tests import base
and any relevant context from other files:
# Path: os_brick/initiator/utils.py
# def check_manual_scan():
# def guard_connection(device):
# ISCSI_SUPPORTS_MANUAL_SCAN = check_manual_scan()
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | def test_check_manual_scan_supported(self, mock_exec): |
Based on the snippet: <|code_start|> def test_check_manual_scan_windows(self):
self.assertFalse(utils.check_manual_scan())
@mock.patch('os.name', 'posix')
@mock.patch('oslo_concurrency.processutils.execute')
def test_check_manual_scan_supported(self, mock_exec):
self.assertTrue(utils.check_manual_scan())
mock_exec.assert_called_once_with('grep', '-F', 'node.session.scan',
'/sbin/iscsiadm')
@mock.patch('os.name', 'posix')
@mock.patch('oslo_concurrency.processutils.execute',
side_effect=utils.putils.ProcessExecutionError)
def test_check_manual_scan_not_supported(self, mock_exec):
self.assertFalse(utils.check_manual_scan())
mock_exec.assert_called_once_with('grep', '-F', 'node.session.scan',
'/sbin/iscsiadm')
@mock.patch('oslo_concurrency.lockutils.lock')
def test_guard_connection_manual_scan_support(self, mock_lock):
utils.ISCSI_SUPPORTS_MANUAL_SCAN = True
# We confirm that shared_targets is ignored
with utils.guard_connection({'shared_targets': True}):
mock_lock.assert_not_called()
@mock.patch('oslo_concurrency.lockutils.lock')
def test_guard_connection_manual_scan_unsupported_not_shared(self,
mock_lock):
utils.ISCSI_SUPPORTS_MANUAL_SCAN = False
with utils.guard_connection({'shared_targets': False}):
<|code_end|>
, predict the immediate next line with the help of imports:
from unittest import mock
from os_brick.initiator import utils
from os_brick.tests import base
and context (classes, functions, sometimes code) from other files:
# Path: os_brick/initiator/utils.py
# def check_manual_scan():
# def guard_connection(device):
# ISCSI_SUPPORTS_MANUAL_SCAN = check_manual_scan()
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | mock_lock.assert_not_called() |
Based on the snippet: <|code_start|> @mock.patch.object(base_iscsi.BaseISCSIConnector, '_get_all_targets')
def test_iterate_all_targets(self, mock_get_all_targets):
# extra_property cannot be a sentinel, a copied sentinel will not
# identical to the original one.
connection_properties = {
'target_portals': mock.sentinel.target_portals,
'target_iqns': mock.sentinel.target_iqns,
'target_luns': mock.sentinel.target_luns,
'extra_property': 'extra_property'}
mock_get_all_targets.return_value = [(
mock.sentinel.portal, mock.sentinel.iqn, mock.sentinel.lun)]
# method is a generator, and it yields dictionaries. list() will
# iterate over all of the method's items.
list_props = list(
self.connector._iterate_all_targets(connection_properties))
mock_get_all_targets.assert_called_once_with(connection_properties)
self.assertEqual(1, len(list_props))
expected_props = {'target_portal': mock.sentinel.portal,
'target_iqn': mock.sentinel.iqn,
'target_lun': mock.sentinel.lun,
'extra_property': 'extra_property'}
self.assertEqual(expected_props, list_props[0])
def test_get_all_targets(self):
portals = [mock.sentinel.portals1, mock.sentinel.portals2]
iqns = [mock.sentinel.iqns1, mock.sentinel.iqns2]
luns = [mock.sentinel.luns1, mock.sentinel.luns2]
<|code_end|>
, predict the immediate next line with the help of imports:
from unittest import mock
from os_brick.initiator.connectors import base_iscsi
from os_brick.initiator.connectors import fake
from os_brick.tests import base as test_base
and context (classes, functions, sometimes code) from other files:
# Path: os_brick/initiator/connectors/base_iscsi.py
# class BaseISCSIConnector(initiator_connector.InitiatorConnector):
# def _iterate_all_targets(self, connection_properties):
# def _get_luns(con_props, iqns=None):
# def _get_all_targets(self, connection_properties):
#
# Path: os_brick/initiator/connectors/fake.py
# class FakeConnector(base.BaseLinuxConnector):
# class FakeBaseISCSIConnector(FakeConnector, base_iscsi.BaseISCSIConnector):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
# def get_search_path(self):
# def extend_volume(self, connection_properties):
# def get_all_available_volumes(self, connection_properties=None):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | connection_properties = {'target_portals': portals, |
Using the snippet: <|code_start|># (c) Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class BaseISCSIConnectorTestCase(test_base.TestCase):
def setUp(self):
super(BaseISCSIConnectorTestCase, self).setUp()
self.connector = fake.FakeBaseISCSIConnector(None)
@mock.patch.object(base_iscsi.BaseISCSIConnector, '_get_all_targets')
def test_iterate_all_targets(self, mock_get_all_targets):
# extra_property cannot be a sentinel, a copied sentinel will not
# identical to the original one.
connection_properties = {
'target_portals': mock.sentinel.target_portals,
'target_iqns': mock.sentinel.target_iqns,
<|code_end|>
, determine the next line of code. You have imports:
from unittest import mock
from os_brick.initiator.connectors import base_iscsi
from os_brick.initiator.connectors import fake
from os_brick.tests import base as test_base
and context (class names, function names, or code) available:
# Path: os_brick/initiator/connectors/base_iscsi.py
# class BaseISCSIConnector(initiator_connector.InitiatorConnector):
# def _iterate_all_targets(self, connection_properties):
# def _get_luns(con_props, iqns=None):
# def _get_all_targets(self, connection_properties):
#
# Path: os_brick/initiator/connectors/fake.py
# class FakeConnector(base.BaseLinuxConnector):
# class FakeBaseISCSIConnector(FakeConnector, base_iscsi.BaseISCSIConnector):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
# def get_search_path(self):
# def extend_volume(self, connection_properties):
# def get_all_available_volumes(self, connection_properties=None):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
. Output only the next line. | 'target_luns': mock.sentinel.target_luns, |
Here is a snippet: <|code_start|> mock_get_all_targets.assert_called_once_with(connection_properties)
self.assertEqual(1, len(list_props))
expected_props = {'target_portal': mock.sentinel.portal,
'target_iqn': mock.sentinel.iqn,
'target_lun': mock.sentinel.lun,
'extra_property': 'extra_property'}
self.assertEqual(expected_props, list_props[0])
def test_get_all_targets(self):
portals = [mock.sentinel.portals1, mock.sentinel.portals2]
iqns = [mock.sentinel.iqns1, mock.sentinel.iqns2]
luns = [mock.sentinel.luns1, mock.sentinel.luns2]
connection_properties = {'target_portals': portals,
'target_iqns': iqns,
'target_luns': luns}
all_targets = self.connector._get_all_targets(connection_properties)
expected_targets = zip(portals, iqns, luns)
self.assertEqual(list(expected_targets), list(all_targets))
def test_get_all_targets_no_target_luns(self):
portals = [mock.sentinel.portals1, mock.sentinel.portals2]
iqns = [mock.sentinel.iqns1, mock.sentinel.iqns2]
lun = mock.sentinel.luns
connection_properties = {'target_portals': portals,
'target_iqns': iqns,
'target_lun': lun}
<|code_end|>
. Write the next line using the current file imports:
from unittest import mock
from os_brick.initiator.connectors import base_iscsi
from os_brick.initiator.connectors import fake
from os_brick.tests import base as test_base
and context from other files:
# Path: os_brick/initiator/connectors/base_iscsi.py
# class BaseISCSIConnector(initiator_connector.InitiatorConnector):
# def _iterate_all_targets(self, connection_properties):
# def _get_luns(con_props, iqns=None):
# def _get_all_targets(self, connection_properties):
#
# Path: os_brick/initiator/connectors/fake.py
# class FakeConnector(base.BaseLinuxConnector):
# class FakeBaseISCSIConnector(FakeConnector, base_iscsi.BaseISCSIConnector):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def get_volume_paths(self, connection_properties):
# def get_search_path(self):
# def extend_volume(self, connection_properties):
# def get_all_available_volumes(self, connection_properties=None):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
, which may include functions, classes, or code. Output only the next line. | all_targets = self.connector._get_all_targets(connection_properties) |
Continue the code snippet: <|code_start|># (c) Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class GPFSConnectorTestCase(test_local.LocalConnectorTestCase):
def setUp(self):
super(GPFSConnectorTestCase, self).setUp()
self.connection_properties = {'name': 'foo',
'device_path': '/tmp/bar'}
self.connector = gpfs.GPFSConnector(None)
def test_connect_volume(self):
cprops = self.connection_properties
dev_info = self.connector.connect_volume(cprops)
<|code_end|>
. Use current file imports:
from os_brick.initiator.connectors import gpfs
from os_brick.tests.initiator.connectors import test_local
and context (classes, functions, or code) from other files:
# Path: os_brick/initiator/connectors/gpfs.py
# class GPFSConnector(local.LocalConnector):
# def connect_volume(self, connection_properties):
#
# Path: os_brick/tests/initiator/connectors/test_local.py
# class LocalConnectorTestCase(test_connector.ConnectorTestCase):
# def setUp(self):
# def test_get_connector_properties(self):
# def test_get_search_path(self):
# def test_get_volume_paths(self):
# def test_connect_volume(self):
# def test_connect_volume_with_invalid_connection_data(self):
# def test_extend_volume(self):
. Output only the next line. | self.assertEqual(dev_info['type'], 'gpfs') |
Next line prediction: <|code_start|># (c) Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class GPFSConnectorTestCase(test_local.LocalConnectorTestCase):
def setUp(self):
super(GPFSConnectorTestCase, self).setUp()
self.connection_properties = {'name': 'foo',
'device_path': '/tmp/bar'}
self.connector = gpfs.GPFSConnector(None)
def test_connect_volume(self):
cprops = self.connection_properties
dev_info = self.connector.connect_volume(cprops)
<|code_end|>
. Use current file imports:
(from os_brick.initiator.connectors import gpfs
from os_brick.tests.initiator.connectors import test_local)
and context including class names, function names, or small code snippets from other files:
# Path: os_brick/initiator/connectors/gpfs.py
# class GPFSConnector(local.LocalConnector):
# def connect_volume(self, connection_properties):
#
# Path: os_brick/tests/initiator/connectors/test_local.py
# class LocalConnectorTestCase(test_connector.ConnectorTestCase):
# def setUp(self):
# def test_get_connector_properties(self):
# def test_get_search_path(self):
# def test_get_volume_paths(self):
# def test_connect_volume(self):
# def test_connect_volume_with_invalid_connection_data(self):
# def test_extend_volume(self):
. Output only the next line. | self.assertEqual(dev_info['type'], 'gpfs') |
Continue the code snippet: <|code_start|># WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class FakeConnector(base.BaseLinuxConnector):
fake_path = '/dev/vdFAKE'
def connect_volume(self, connection_properties):
fake_device_info = {'type': 'fake',
'path': self.fake_path}
return fake_device_info
def disconnect_volume(self, connection_properties, device_info,
force=False, ignore_errors=False):
pass
def get_volume_paths(self, connection_properties):
return [self.fake_path]
def get_search_path(self):
return '/dev/disk/by-path'
def extend_volume(self, connection_properties):
return None
def get_all_available_volumes(self, connection_properties=None):
<|code_end|>
. Use current file imports:
from os_brick.initiator.connectors import base
from os_brick.initiator.connectors import base_iscsi
and context (classes, functions, or code) from other files:
# Path: os_brick/initiator/connectors/base.py
# LOG = logging.getLogger(__name__)
# class BaseLinuxConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper: str, driver=None, execute=None,
# *args, **kwargs):
# def get_connector_properties(root_helper: str, *args, **kwargs) -> dict:
# def check_valid_device(self, path: str, run_as_root: bool = True) -> bool:
# def get_all_available_volumes(self, connection_properties=None):
# def _discover_mpath_device(self,
# device_wwn: str,
# connection_properties: dict,
# device_name: str) -> tuple:
#
# Path: os_brick/initiator/connectors/base_iscsi.py
# class BaseISCSIConnector(initiator_connector.InitiatorConnector):
# def _iterate_all_targets(self, connection_properties):
# def _get_luns(con_props, iqns=None):
# def _get_all_targets(self, connection_properties):
. Output only the next line. | return ['/dev/disk/by-path/fake-volume-1', |
Given snippet: <|code_start|># http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class FakeConnector(base.BaseLinuxConnector):
fake_path = '/dev/vdFAKE'
def connect_volume(self, connection_properties):
fake_device_info = {'type': 'fake',
'path': self.fake_path}
return fake_device_info
def disconnect_volume(self, connection_properties, device_info,
force=False, ignore_errors=False):
pass
def get_volume_paths(self, connection_properties):
return [self.fake_path]
def get_search_path(self):
return '/dev/disk/by-path'
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from os_brick.initiator.connectors import base
from os_brick.initiator.connectors import base_iscsi
and context:
# Path: os_brick/initiator/connectors/base.py
# LOG = logging.getLogger(__name__)
# class BaseLinuxConnector(initiator_connector.InitiatorConnector):
# def __init__(self, root_helper: str, driver=None, execute=None,
# *args, **kwargs):
# def get_connector_properties(root_helper: str, *args, **kwargs) -> dict:
# def check_valid_device(self, path: str, run_as_root: bool = True) -> bool:
# def get_all_available_volumes(self, connection_properties=None):
# def _discover_mpath_device(self,
# device_wwn: str,
# connection_properties: dict,
# device_name: str) -> tuple:
#
# Path: os_brick/initiator/connectors/base_iscsi.py
# class BaseISCSIConnector(initiator_connector.InitiatorConnector):
# def _iterate_all_targets(self, connection_properties):
# def _get_luns(con_props, iqns=None):
# def _get_all_targets(self, connection_properties):
which might include code, classes, or functions. Output only the next line. | def extend_volume(self, connection_properties): |
Using the snippet: <|code_start|># distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class LocalConnectorTestCase(test_connector.ConnectorTestCase):
def setUp(self):
super(LocalConnectorTestCase, self).setUp()
self.connection_properties = {'name': 'foo',
'device_path': '/tmp/bar'}
self.connector = local.LocalConnector(None)
def test_get_connector_properties(self):
props = local.LocalConnector.get_connector_properties(
'sudo', multipath=True, enforce_multipath=True)
expected_props = {}
self.assertEqual(expected_props, props)
def test_get_search_path(self):
actual = self.connector.get_search_path()
self.assertIsNone(actual)
def test_get_volume_paths(self):
expected = [self.connection_properties['device_path']]
actual = self.connector.get_volume_paths(
self.connection_properties)
<|code_end|>
, determine the next line of code. You have imports:
from os_brick.initiator.connectors import local
from os_brick.tests.initiator import test_connector
and context (class names, function names, or code) available:
# Path: os_brick/initiator/connectors/local.py
# class LocalConnector(base.BaseLinuxConnector):
# def __init__(self, root_helper, driver=None,
# *args, **kwargs):
# def get_connector_properties(root_helper, *args, **kwargs):
# def get_volume_paths(self, connection_properties):
# def get_search_path(self):
# def get_all_available_volumes(self, connection_properties=None):
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info,
# force=False, ignore_errors=False):
# def extend_volume(self, connection_properties):
#
# Path: os_brick/tests/initiator/test_connector.py
# MY_IP = '10.0.0.1'
# FAKE_SCSI_WWN = '1234567890'
# class ZeroIntervalLoopingCall(loopingcall.FixedIntervalLoopingCall):
# class ConnectorUtilsTestCase(test_base.TestCase):
# class ConnectorTestCase(test_base.TestCase):
# def start(self, interval, initial_delay=None, stop_on_exception=True):
# def _test_brick_get_connector_properties(self, multipath,
# enforce_multipath,
# multipath_result,
# mock_wwnns, mock_wwpns,
# mock_initiator,
# mock_nqn,
# mock_hostuuid,
# mock_sysuuid,
# host='fakehost'):
# def test_brick_get_connector_properties_connectors_called(self):
# def test_brick_get_connector_properties(self):
# def test_brick_get_connector_properties_multipath(self, mock_execute,
# mock_custom_execute):
# def test_brick_get_connector_properties_fallback(self, mock_execute,
# mock_custom_execute):
# def test_brick_get_connector_properties_raise(self, mock_execute):
# def test_brick_connector_properties_override_hostname(self):
# def setUp(self):
# def fake_execute(self, *cmd, **kwargs):
# def fake_connection(self):
# def test_connect_volume(self):
# def test_disconnect_volume(self):
# def test_get_connector_properties(self):
# def test_get_connector_mapping_win32(self):
# def test_get_connector_mapping(self, mock_platform_machine):
# def test_factory(self):
# def test_check_valid_device_with_wrong_path(self):
# def test_check_valid_device(self):
# def test_check_valid_device_with_cmd_error(self):
# def raise_except(*args, **kwargs):
. Output only the next line. | self.assertEqual(expected, actual) |
Continue the code snippet: <|code_start|> self._execute.assert_any_call(*expected_cmd)
@mock.patch.object(rbd.WindowsRBDConnector, 'get_device_name')
def test_get_volume_paths(self, mock_get_dev_name):
vol_paths = self._conn.get_volume_paths(mock.sentinel.conn_props)
self.assertEqual([mock_get_dev_name.return_value], vol_paths)
mock_get_dev_name.assert_called_once_with(mock.sentinel.conn_props)
@ddt.data(True, False)
@mock.patch.object(rbd.WindowsRBDConnector, 'get_device_name')
@mock.patch('oslo_utils.eventletutils.EventletEvent.wait')
def test_wait_for_volume(self, device_found, mock_wait, mock_get_dev_name):
mock_open = mock.mock_open()
if device_found:
mock_get_dev_name.return_value = mock.sentinel.dev_name
else:
# First call fails to locate the device, the following ones can't
# open it.
mock_get_dev_name.side_effect = (
[None] +
[mock.sentinel.dev_name] * self._conn.device_scan_attempts)
mock_open.side_effect = FileNotFoundError
with mock.patch.object(rbd, 'open', mock_open,
create=True):
if device_found:
dev_name = self._conn._wait_for_volume(
self.connection_properties)
self.assertEqual(mock.sentinel.dev_name, dev_name)
<|code_end|>
. Use current file imports:
from unittest import mock
from oslo_concurrency import processutils
from os_brick import exception
from os_brick.initiator.windows import rbd
from os_brick.tests.initiator.connectors import test_base_rbd
from os_brick.tests.windows import test_base
import ddt
and context (classes, functions, or code) from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/rbd.py
# LOG = logging.getLogger(__name__)
# class WindowsRBDConnector(base_rbd.RBDConnectorMixin,
# win_conn_base.BaseWindowsConnector):
# def __init__(self, *args, **kwargs):
# def _check_rbd(self):
# def _ensure_rbd_available(self):
# def get_volume_paths(self, connection_properties):
# def _show_rbd_mapping(self, connection_properties):
# def get_device_name(self, connection_properties, expect=True):
# def _wait_for_volume(self, connection_properties):
# def _check_rbd_device():
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info=None,
# force=False, ignore_errors=False):
#
# Path: os_brick/tests/initiator/connectors/test_base_rbd.py
# class RBDConnectorTestMixin(object):
# class TestRBDConnectorMixin(RBDConnectorTestMixin, base.TestCase):
# def setUp(self):
# def setUp(self):
# def test_sanitize_mon_host(self, hosts_in, hosts_out):
# def test_get_rbd_args(self):
# def test_get_rbd_args_with_conf(self):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | else: |
Predict the next line after this snippet: <|code_start|>
mock_get_dev_name.assert_called_once_with(mock.sentinel.conn_props)
@ddt.data(True, False)
@mock.patch.object(rbd.WindowsRBDConnector, 'get_device_name')
@mock.patch('oslo_utils.eventletutils.EventletEvent.wait')
def test_wait_for_volume(self, device_found, mock_wait, mock_get_dev_name):
mock_open = mock.mock_open()
if device_found:
mock_get_dev_name.return_value = mock.sentinel.dev_name
else:
# First call fails to locate the device, the following ones can't
# open it.
mock_get_dev_name.side_effect = (
[None] +
[mock.sentinel.dev_name] * self._conn.device_scan_attempts)
mock_open.side_effect = FileNotFoundError
with mock.patch.object(rbd, 'open', mock_open,
create=True):
if device_found:
dev_name = self._conn._wait_for_volume(
self.connection_properties)
self.assertEqual(mock.sentinel.dev_name, dev_name)
else:
self.assertRaises(exception.VolumeDeviceNotFound,
self._conn._wait_for_volume,
self.connection_properties)
mock_open.assert_any_call(mock.sentinel.dev_name, 'rb')
<|code_end|>
using the current file's imports:
from unittest import mock
from oslo_concurrency import processutils
from os_brick import exception
from os_brick.initiator.windows import rbd
from os_brick.tests.initiator.connectors import test_base_rbd
from os_brick.tests.windows import test_base
import ddt
and any relevant context from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/rbd.py
# LOG = logging.getLogger(__name__)
# class WindowsRBDConnector(base_rbd.RBDConnectorMixin,
# win_conn_base.BaseWindowsConnector):
# def __init__(self, *args, **kwargs):
# def _check_rbd(self):
# def _ensure_rbd_available(self):
# def get_volume_paths(self, connection_properties):
# def _show_rbd_mapping(self, connection_properties):
# def get_device_name(self, connection_properties, expect=True):
# def _wait_for_volume(self, connection_properties):
# def _check_rbd_device():
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info=None,
# force=False, ignore_errors=False):
#
# Path: os_brick/tests/initiator/connectors/test_base_rbd.py
# class RBDConnectorTestMixin(object):
# class TestRBDConnectorMixin(RBDConnectorTestMixin, base.TestCase):
# def setUp(self):
# def setUp(self):
# def test_sanitize_mon_host(self, hosts_in, hosts_out):
# def test_get_rbd_args(self):
# def test_get_rbd_args_with_conf(self):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | mock_get_dev_name.assert_any_call(self.connection_properties, |
Using the snippet: <|code_start|> expected_cmd = ['where.exe', 'rbd']
self._execute.assert_any_call(*expected_cmd)
@mock.patch.object(rbd.WindowsRBDConnector, 'get_device_name')
def test_get_volume_paths(self, mock_get_dev_name):
vol_paths = self._conn.get_volume_paths(mock.sentinel.conn_props)
self.assertEqual([mock_get_dev_name.return_value], vol_paths)
mock_get_dev_name.assert_called_once_with(mock.sentinel.conn_props)
@ddt.data(True, False)
@mock.patch.object(rbd.WindowsRBDConnector, 'get_device_name')
@mock.patch('oslo_utils.eventletutils.EventletEvent.wait')
def test_wait_for_volume(self, device_found, mock_wait, mock_get_dev_name):
mock_open = mock.mock_open()
if device_found:
mock_get_dev_name.return_value = mock.sentinel.dev_name
else:
# First call fails to locate the device, the following ones can't
# open it.
mock_get_dev_name.side_effect = (
[None] +
[mock.sentinel.dev_name] * self._conn.device_scan_attempts)
mock_open.side_effect = FileNotFoundError
with mock.patch.object(rbd, 'open', mock_open,
create=True):
if device_found:
dev_name = self._conn._wait_for_volume(
self.connection_properties)
<|code_end|>
, determine the next line of code. You have imports:
from unittest import mock
from oslo_concurrency import processutils
from os_brick import exception
from os_brick.initiator.windows import rbd
from os_brick.tests.initiator.connectors import test_base_rbd
from os_brick.tests.windows import test_base
import ddt
and context (class names, function names, or code) available:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/rbd.py
# LOG = logging.getLogger(__name__)
# class WindowsRBDConnector(base_rbd.RBDConnectorMixin,
# win_conn_base.BaseWindowsConnector):
# def __init__(self, *args, **kwargs):
# def _check_rbd(self):
# def _ensure_rbd_available(self):
# def get_volume_paths(self, connection_properties):
# def _show_rbd_mapping(self, connection_properties):
# def get_device_name(self, connection_properties, expect=True):
# def _wait_for_volume(self, connection_properties):
# def _check_rbd_device():
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info=None,
# force=False, ignore_errors=False):
#
# Path: os_brick/tests/initiator/connectors/test_base_rbd.py
# class RBDConnectorTestMixin(object):
# class TestRBDConnectorMixin(RBDConnectorTestMixin, base.TestCase):
# def setUp(self):
# def setUp(self):
# def test_sanitize_mon_host(self, hosts_in, hosts_out):
# def test_get_rbd_args(self):
# def test_get_rbd_args_with_conf(self):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | self.assertEqual(mock.sentinel.dev_name, dev_name) |
Given the following code snippet before the placeholder: <|code_start|># Copyright 2020 Cloudbase Solutions Srl
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
@ddt.ddt
class WindowsRBDConnectorTestCase(test_base_rbd.RBDConnectorTestMixin,
test_base.WindowsConnectorTestBase):
<|code_end|>
, predict the next line using imports from the current file:
from unittest import mock
from oslo_concurrency import processutils
from os_brick import exception
from os_brick.initiator.windows import rbd
from os_brick.tests.initiator.connectors import test_base_rbd
from os_brick.tests.windows import test_base
import ddt
and context including class names, function names, and sometimes code from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/windows/rbd.py
# LOG = logging.getLogger(__name__)
# class WindowsRBDConnector(base_rbd.RBDConnectorMixin,
# win_conn_base.BaseWindowsConnector):
# def __init__(self, *args, **kwargs):
# def _check_rbd(self):
# def _ensure_rbd_available(self):
# def get_volume_paths(self, connection_properties):
# def _show_rbd_mapping(self, connection_properties):
# def get_device_name(self, connection_properties, expect=True):
# def _wait_for_volume(self, connection_properties):
# def _check_rbd_device():
# def connect_volume(self, connection_properties):
# def disconnect_volume(self, connection_properties, device_info=None,
# force=False, ignore_errors=False):
#
# Path: os_brick/tests/initiator/connectors/test_base_rbd.py
# class RBDConnectorTestMixin(object):
# class TestRBDConnectorMixin(RBDConnectorTestMixin, base.TestCase):
# def setUp(self):
# def setUp(self):
# def test_sanitize_mon_host(self, hosts_in, hosts_out):
# def test_get_rbd_args(self):
# def test_get_rbd_args_with_conf(self):
#
# Path: os_brick/tests/windows/test_base.py
# class WindowsConnectorTestBase(base.TestCase):
# def setUp(self):
. Output only the next line. | def setUp(self): |
Predict the next line for this snippet: <|code_start|> 1, mock_rados.Rados.return_value.connect.call_count)
mock_rados.Rados.return_value.open_ioctx.assert_called_once_with(
utils.convert_str('test_pool'))
self.assertEqual(1, mock_rados.Rados.return_value.shutdown.call_count)
@mock.patch.object(MockRados.Rados, 'connect', side_effect=MockRados.Error)
def test_with_client_error(self, _):
linuxrbd.rados = MockRados
linuxrbd.rados.Error = MockRados.Error
def test():
with linuxrbd.RBDClient('test_user', 'test_pool'):
pass
self.assertRaises(exception.BrickException, test)
class RBDVolumeIOWrapperTestCase(base.TestCase):
def setUp(self):
super(RBDVolumeIOWrapperTestCase, self).setUp()
self.mock_volume = mock.Mock()
self.mock_volume_wrapper = \
linuxrbd.RBDVolumeIOWrapper(self.mock_volume)
self.data_length = 1024
self.full_data = 'abcd' * 256
def test_init(self):
self.assertEqual(self.mock_volume,
<|code_end|>
with the help of current file imports:
from unittest import mock
from os_brick import exception
from os_brick.initiator import linuxrbd
from os_brick.tests import base
from os_brick import utils
and context from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/linuxrbd.py
# LOG = logging.getLogger(__name__)
# class RBDClient(object):
# class RBDVolume(object):
# class RBDImageMetadata(object):
# class RBDVolumeIOWrapper(io.RawIOBase):
# def __init__(self, user, pool, *args, **kwargs):
# def __enter__(self):
# def __exit__(self, type_, value, traceback):
# def connect(self):
# def disconnect(self):
# def __init__(self, client, name, snapshot=None, read_only=False):
# def close(self):
# def __enter__(self):
# def __exit__(self, type_, value, traceback):
# def __getattr__(self, attrib):
# def __init__(self, image, pool, user, conf):
# def __init__(self, rbd_volume):
# def _inc_offset(self, length):
# def rbd_image(self):
# def rbd_user(self):
# def rbd_pool(self):
# def rbd_conf(self):
# def read(self, length=None):
# def write(self, data):
# def seekable(self):
# def seek(self, offset, whence=0):
# def tell(self):
# def flush(self):
# def fileno(self):
# def close(self):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
, which may contain function names, class names, or code. Output only the next line. | self.mock_volume_wrapper._rbd_volume) |
Given the following code snippet before the placeholder: <|code_start|>
def setUp(self):
super(RBDVolumeIOWrapperTestCase, self).setUp()
self.mock_volume = mock.Mock()
self.mock_volume_wrapper = \
linuxrbd.RBDVolumeIOWrapper(self.mock_volume)
self.data_length = 1024
self.full_data = 'abcd' * 256
def test_init(self):
self.assertEqual(self.mock_volume,
self.mock_volume_wrapper._rbd_volume)
self.assertEqual(0, self.mock_volume_wrapper._offset)
def test_inc_offset(self):
self.mock_volume_wrapper._inc_offset(10)
self.mock_volume_wrapper._inc_offset(10)
self.assertEqual(20, self.mock_volume_wrapper._offset)
def test_read(self):
def mock_read(offset, length):
return self.full_data[offset:length]
self.mock_volume.image.read.side_effect = mock_read
self.mock_volume.image.size.return_value = self.data_length
data = self.mock_volume_wrapper.read()
self.assertEqual(self.full_data, data)
<|code_end|>
, predict the next line using imports from the current file:
from unittest import mock
from os_brick import exception
from os_brick.initiator import linuxrbd
from os_brick.tests import base
from os_brick import utils
and context including class names, function names, and sometimes code from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/linuxrbd.py
# LOG = logging.getLogger(__name__)
# class RBDClient(object):
# class RBDVolume(object):
# class RBDImageMetadata(object):
# class RBDVolumeIOWrapper(io.RawIOBase):
# def __init__(self, user, pool, *args, **kwargs):
# def __enter__(self):
# def __exit__(self, type_, value, traceback):
# def connect(self):
# def disconnect(self):
# def __init__(self, client, name, snapshot=None, read_only=False):
# def close(self):
# def __enter__(self):
# def __exit__(self, type_, value, traceback):
# def __getattr__(self, attrib):
# def __init__(self, image, pool, user, conf):
# def __init__(self, rbd_volume):
# def _inc_offset(self, length):
# def rbd_image(self):
# def rbd_user(self):
# def rbd_pool(self):
# def rbd_conf(self):
# def read(self, length=None):
# def write(self, data):
# def seekable(self):
# def seek(self, offset, whence=0):
# def tell(self):
# def flush(self):
# def fileno(self):
# def close(self):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | data = self.mock_volume_wrapper.read() |
Continue the code snippet: <|code_start|>
self.assertEqual(1, mock_rados.Rados.return_value.shutdown.call_count)
@mock.patch.object(MockRados.Rados, 'connect', side_effect=MockRados.Error)
def test_with_client_error(self, _):
linuxrbd.rados = MockRados
linuxrbd.rados.Error = MockRados.Error
def test():
with linuxrbd.RBDClient('test_user', 'test_pool'):
pass
self.assertRaises(exception.BrickException, test)
class RBDVolumeIOWrapperTestCase(base.TestCase):
def setUp(self):
super(RBDVolumeIOWrapperTestCase, self).setUp()
self.mock_volume = mock.Mock()
self.mock_volume_wrapper = \
linuxrbd.RBDVolumeIOWrapper(self.mock_volume)
self.data_length = 1024
self.full_data = 'abcd' * 256
def test_init(self):
self.assertEqual(self.mock_volume,
self.mock_volume_wrapper._rbd_volume)
self.assertEqual(0, self.mock_volume_wrapper._offset)
<|code_end|>
. Use current file imports:
from unittest import mock
from os_brick import exception
from os_brick.initiator import linuxrbd
from os_brick.tests import base
from os_brick import utils
and context (classes, functions, or code) from other files:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/linuxrbd.py
# LOG = logging.getLogger(__name__)
# class RBDClient(object):
# class RBDVolume(object):
# class RBDImageMetadata(object):
# class RBDVolumeIOWrapper(io.RawIOBase):
# def __init__(self, user, pool, *args, **kwargs):
# def __enter__(self):
# def __exit__(self, type_, value, traceback):
# def connect(self):
# def disconnect(self):
# def __init__(self, client, name, snapshot=None, read_only=False):
# def close(self):
# def __enter__(self):
# def __exit__(self, type_, value, traceback):
# def __getattr__(self, attrib):
# def __init__(self, image, pool, user, conf):
# def __init__(self, rbd_volume):
# def _inc_offset(self, length):
# def rbd_image(self):
# def rbd_user(self):
# def rbd_pool(self):
# def rbd_conf(self):
# def read(self, length=None):
# def write(self, data):
# def seekable(self):
# def seek(self, offset, whence=0):
# def tell(self):
# def flush(self):
# def fileno(self):
# def close(self):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | def test_inc_offset(self): |
Using the snippet: <|code_start|>
def __exit__(self, *args, **kwargs):
return False
def close(self, *args, **kwargs):
pass
class Rados(object):
def __init__(self, *args, **kwargs):
pass
def __enter__(self, *args, **kwargs):
return self
def __exit__(self, *args, **kwargs):
return False
def connect(self, *args, **kwargs):
pass
def open_ioctx(self, *args, **kwargs):
return MockRados.ioctx()
def shutdown(self, *args, **kwargs):
pass
class RBDClientTestCase(base.TestCase):
<|code_end|>
, determine the next line of code. You have imports:
from unittest import mock
from os_brick import exception
from os_brick.initiator import linuxrbd
from os_brick.tests import base
from os_brick import utils
and context (class names, function names, or code) available:
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
# def __init__(self, message=None, **kwargs):
# def __init__(self, *args, **kwargs):
# def __repr__(self):
# def __nonzero__(self) -> bool:
# def add_exception(self, exc_type, exc_val, exc_tb) -> None:
# def context(self,
# catch_exception: bool,
# msg: str = '',
# *msg_args: Iterable):
# def __enter__(self):
# def __exit__(self, exc_type, exc_val, exc_tb):
#
# Path: os_brick/initiator/linuxrbd.py
# LOG = logging.getLogger(__name__)
# class RBDClient(object):
# class RBDVolume(object):
# class RBDImageMetadata(object):
# class RBDVolumeIOWrapper(io.RawIOBase):
# def __init__(self, user, pool, *args, **kwargs):
# def __enter__(self):
# def __exit__(self, type_, value, traceback):
# def connect(self):
# def disconnect(self):
# def __init__(self, client, name, snapshot=None, read_only=False):
# def close(self):
# def __enter__(self):
# def __exit__(self, type_, value, traceback):
# def __getattr__(self, attrib):
# def __init__(self, image, pool, user, conf):
# def __init__(self, rbd_volume):
# def _inc_offset(self, length):
# def rbd_image(self):
# def rbd_user(self):
# def rbd_pool(self):
# def rbd_conf(self):
# def read(self, length=None):
# def write(self, data):
# def seekable(self):
# def seek(self, offset, whence=0):
# def tell(self):
# def flush(self):
# def fileno(self):
# def close(self):
#
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
# SENTINEL = object()
# def setUp(self):
# def _common_cleanup(self):
# def log_level(self, level):
# def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
# def patch(self, path, *args, **kwargs):
#
# Path: os_brick/utils.py
# def _sleep(secs: float) -> None:
# def __init__(self, codes: Union[int, Tuple[int, ...]]):
# def _check_exit_code(self, exc: Type[Exception]) -> bool:
# def retry(retry_param: Union[None,
# Type[Exception],
# Tuple[Type[Exception], ...],
# int,
# Tuple[int, ...]],
# interval: float = 1,
# retries: int = 3,
# backoff_rate: float = 2,
# retry: Callable = tenacity.retry_if_exception_type) -> Callable:
# def _decorator(f):
# def _wrapper(*args, **kwargs):
# def platform_matches(current_platform: str, connector_platform: str) -> bool:
# def os_matches(current_os: str, connector_os: str) -> bool:
# def merge_dict(dict1: dict, dict2: dict) -> dict:
# def trace(f: Callable) -> Callable:
# def trace_logging_wrapper(*args, **kwargs):
# def convert_str(text: Union[bytes, str]) -> str:
# def get_host_nqn():
# LOG = logging.getLogger(__name__)
# class retry_if_exit_code(tenacity.retry_if_exception):
. Output only the next line. | def setUp(self): |
Next line prediction: <|code_start|>
def test_buffer():
instance = buffers.Buffer()
assert instance.requirements == []
expected = dict(a=1, b=2, c=3)
instance.input(expected)
instance.set_output_label('any')
assert instance.output() == expected
def test_detlayed_buffer():
delay = 2.5
instance = buffers.DelayedBuffer(seconds=delay)
assert instance.requirements == ['seconds']
expected = dict(a=1, b=2, c=3)
instance.input(expected)
instance.set_output_label('any')
start_time = time.time()
result = instance.output()
end_time = time.time()
<|code_end|>
. Use current file imports:
(import time
from robograph.datamodel.nodes.lib import buffers)
and context including class names, function names, or small code snippets from other files:
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
. Output only the next line. | assert result == expected |
Predict the next line after this snippet: <|code_start|>
def test_requirements():
expected = ['message']
instance = printer.ConsolePrinter()
assert instance.requirements == expected
def test_input():
msg = 'Hello world'
instance = printer.ConsolePrinter()
instance.input(dict(message=msg))
instance.set_output_label('any')
assert instance.output() == msg
def test_output():
<|code_end|>
using the current file's imports:
from robograph.datamodel.nodes.lib import printer
and any relevant context from other files:
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
. Output only the next line. | msg = 'Hello world' |
Given the code snippet: <|code_start|>
def test_requirements():
expected = ['value']
instance = value.Value()
assert instance.requirements == expected
<|code_end|>
, generate the next line using the imports in this file:
from robograph.datamodel.nodes.lib import value
and context (functions, classes, or occasionally code) from other files:
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
. Output only the next line. | def test_input(): |
Given the code snippet: <|code_start|># Given an IP address, geolocate it and send the result over via e-mail
def email_geolocated_ip(recipients_list, smtp_server_params, ip_addr):
subject = value.Value(value='Test mail')
smtp_server_params['sender'] = 'test@test.com'
smtp_server_params['mime_type'] = 'text/html'
smtp_server_params['recipients_list'] = recipients_list
sendmail = email.SmtpEmail(**smtp_server_params)
http_params = dict(url='https://api.ip2country.info/ip?'+ip_addr,
mime_type='application/json')
geolocate = http.Get(**http_params)
g = graph.Graph('email_geolocated_ip', [subject, geolocate, sendmail])
g.connect(sendmail, geolocate, 'body')
g.connect(sendmail, subject, 'subject')
<|code_end|>
, generate the next line using the imports in this file:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import value, http, email
and context (functions, classes, or occasionally code) from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/http.py
# class HttpClient(node.Node):
# class StatusCode(node.Node):
# class StatusCodeOk(node.Node):
# class RawGet(HttpClient):
# class Get(RawGet):
# class RawPost(HttpClient):
# class Post(RawPost):
# class RawPut(HttpClient):
# class Put(RawPut):
# class RawDelete(HttpClient):
# class Delete(RawDelete):
# DEFAULT_TIMEOUT_SECS = 3
# def _encode_payload(self, response, mime_type):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/email.py
# class SmtpClient:
# class SmtpEmail(node.Node):
# def __init__(self, server_hostname, server_port, username, password,
# use_tls=True):
# def send(self, subject, body, recipients_list, sender, mime='html'):
# def output(self):
. Output only the next line. | return g |
Given the following code snippet before the placeholder: <|code_start|># Given an IP address, geolocate it and send the result over via e-mail
def email_geolocated_ip(recipients_list, smtp_server_params, ip_addr):
subject = value.Value(value='Test mail')
smtp_server_params['sender'] = 'test@test.com'
smtp_server_params['mime_type'] = 'text/html'
smtp_server_params['recipients_list'] = recipients_list
sendmail = email.SmtpEmail(**smtp_server_params)
<|code_end|>
, predict the next line using imports from the current file:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import value, http, email
and context including class names, function names, and sometimes code from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/http.py
# class HttpClient(node.Node):
# class StatusCode(node.Node):
# class StatusCodeOk(node.Node):
# class RawGet(HttpClient):
# class Get(RawGet):
# class RawPost(HttpClient):
# class Post(RawPost):
# class RawPut(HttpClient):
# class Put(RawPut):
# class RawDelete(HttpClient):
# class Delete(RawDelete):
# DEFAULT_TIMEOUT_SECS = 3
# def _encode_payload(self, response, mime_type):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/email.py
# class SmtpClient:
# class SmtpEmail(node.Node):
# def __init__(self, server_hostname, server_port, username, password,
# use_tls=True):
# def send(self, subject, body, recipients_list, sender, mime='html'):
# def output(self):
. Output only the next line. | http_params = dict(url='https://api.ip2country.info/ip?'+ip_addr, |
Here is a snippet: <|code_start|># Given an IP address, geolocate it and send the result over via e-mail
def email_geolocated_ip(recipients_list, smtp_server_params, ip_addr):
subject = value.Value(value='Test mail')
smtp_server_params['sender'] = 'test@test.com'
smtp_server_params['mime_type'] = 'text/html'
smtp_server_params['recipients_list'] = recipients_list
sendmail = email.SmtpEmail(**smtp_server_params)
http_params = dict(url='https://api.ip2country.info/ip?'+ip_addr,
mime_type='application/json')
geolocate = http.Get(**http_params)
g = graph.Graph('email_geolocated_ip', [subject, geolocate, sendmail])
g.connect(sendmail, geolocate, 'body')
<|code_end|>
. Write the next line using the current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import value, http, email
and context from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/http.py
# class HttpClient(node.Node):
# class StatusCode(node.Node):
# class StatusCodeOk(node.Node):
# class RawGet(HttpClient):
# class Get(RawGet):
# class RawPost(HttpClient):
# class Post(RawPost):
# class RawPut(HttpClient):
# class Put(RawPut):
# class RawDelete(HttpClient):
# class Delete(RawDelete):
# DEFAULT_TIMEOUT_SECS = 3
# def _encode_payload(self, response, mime_type):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/email.py
# class SmtpClient:
# class SmtpEmail(node.Node):
# def __init__(self, server_hostname, server_port, username, password,
# use_tls=True):
# def send(self, subject, body, recipients_list, sender, mime='html'):
# def output(self):
, which may include functions, classes, or code. Output only the next line. | g.connect(sendmail, subject, 'subject') |
Based on the snippet: <|code_start|># Given an IP address, geolocate it and send the result over via e-mail
def email_geolocated_ip(recipients_list, smtp_server_params, ip_addr):
subject = value.Value(value='Test mail')
smtp_server_params['sender'] = 'test@test.com'
smtp_server_params['mime_type'] = 'text/html'
smtp_server_params['recipients_list'] = recipients_list
sendmail = email.SmtpEmail(**smtp_server_params)
http_params = dict(url='https://api.ip2country.info/ip?'+ip_addr,
mime_type='application/json')
geolocate = http.Get(**http_params)
g = graph.Graph('email_geolocated_ip', [subject, geolocate, sendmail])
g.connect(sendmail, geolocate, 'body')
g.connect(sendmail, subject, 'subject')
<|code_end|>
, predict the immediate next line with the help of imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import value, http, email
and context (classes, functions, sometimes code) from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/http.py
# class HttpClient(node.Node):
# class StatusCode(node.Node):
# class StatusCodeOk(node.Node):
# class RawGet(HttpClient):
# class Get(RawGet):
# class RawPost(HttpClient):
# class Post(RawPost):
# class RawPut(HttpClient):
# class Put(RawPut):
# class RawDelete(HttpClient):
# class Delete(RawDelete):
# DEFAULT_TIMEOUT_SECS = 3
# def _encode_payload(self, response, mime_type):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/email.py
# class SmtpClient:
# class SmtpEmail(node.Node):
# def __init__(self, server_hostname, server_port, username, password,
# use_tls=True):
# def send(self, subject, body, recipients_list, sender, mime='html'):
# def output(self):
. Output only the next line. | return g |
Given snippet: <|code_start|>
DATA = dict(x=[1, 2, 3])
EXPECTED = '{"x": [1, 2, 3]}'
def test_requirements():
expected = ['data']
instance = transcoders.ToJSON()
assert instance.requirements == expected
def test_input():
instance = transcoders.ToJSON()
instance.input(dict(data=DATA))
instance.set_output_label('any')
assert instance.output() == EXPECTED
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from robograph.datamodel.nodes.lib import transcoders
and context:
# Path: robograph/datamodel/nodes/lib/transcoders.py
# class ToJSON(node.Node):
# class ToCSV(node.Node):
# def output(self):
# def output(self):
which might include code, classes, or functions. Output only the next line. | def test_output(): |
Predict the next line after this snippet: <|code_start|>
def test_templated_string():
expected_requirements = ['template', 'parameters']
expected_output = 'After 1 comes 2 but then there is three'
instance = strings.TemplatedString(
template='After {p1} comes {p2} but then there is {p3}')
instance.input(dict(parameters=dict(p1=1, p2=2, p3='three')))
<|code_end|>
using the current file's imports:
from robograph.datamodel.nodes.lib import strings
and any relevant context from other files:
# Path: robograph/datamodel/nodes/lib/strings.py
# class TemplatedString(node.Node):
# def output(self):
. Output only the next line. | assert instance.requirements == expected_requirements |
Continue the code snippet: <|code_start|> s = maths.Sum(name='sum')
m = maths.Product(name='product')
b = buffers.Buffer(name='buffer')
p = printer.ConsolePrinter(name='printer')
g = graph.Graph('sum_and_product', [v1, v2, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum of v1')
g.connect(b, m, 'product of v2')
g.connect(s, v1, 'argument')
g.connect(m, v2, 'argument')
plotter.show_plot(g)
def plot_to_file(outputfile):
v1 = value.Value(value=[9, -3, 8.7], name='v1')
v2 = value.Value(value=[86, -0.43], name='v2')
s = maths.Sum(name='sum')
m = maths.Product(name='product')
b = buffers.Buffer(name='buffer')
p = printer.ConsolePrinter(name='printer')
g = graph.Graph('sum_and_product', [v1, v2, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum of v1')
g.connect(b, m, 'product of v2')
g.connect(s, v1, 'argument')
<|code_end|>
. Use current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes import plotter
from robograph.datamodel.nodes.lib import value, printer, buffers, maths
and context (classes, functions, or code) from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/plotter.py
# def prepare_plot(graph):
# def show_plot(graph):
# def save_plot(graph, outputfile):
# G = graph.nxgraph
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/maths.py
# class Pi(value.Value):
# class E(value.Value):
# class Sum(apply.Apply):
# class Product(apply.Apply):
# class Floor(apply.Apply):
# class Ceil(apply.Apply):
# class Sqrt(apply.Apply):
# class Max(apply.Apply):
# class Min(apply.Apply):
# class Sin(apply.Apply):
# class Cos(apply.Apply):
# class Abs(apply.Apply):
# class Exp(apply.Apply):
# class Power(Node):
# class Log(apply.Apply):
# class Log10(apply.Apply):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def output(self):
# def __init__(self, **args):
# def __init__(self, **args):
. Output only the next line. | g.connect(m, v2, 'argument') |
Continue the code snippet: <|code_start|>
def plot():
v1 = value.Value(value=[9, -3, 8.7], name='v1')
v2 = value.Value(value=[86, -0.43], name='v2')
s = maths.Sum(name='sum')
m = maths.Product(name='product')
b = buffers.Buffer(name='buffer')
p = printer.ConsolePrinter(name='printer')
g = graph.Graph('sum_and_product', [v1, v2, s, m, p, b])
<|code_end|>
. Use current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes import plotter
from robograph.datamodel.nodes.lib import value, printer, buffers, maths
and context (classes, functions, or code) from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/plotter.py
# def prepare_plot(graph):
# def show_plot(graph):
# def save_plot(graph, outputfile):
# G = graph.nxgraph
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/maths.py
# class Pi(value.Value):
# class E(value.Value):
# class Sum(apply.Apply):
# class Product(apply.Apply):
# class Floor(apply.Apply):
# class Ceil(apply.Apply):
# class Sqrt(apply.Apply):
# class Max(apply.Apply):
# class Min(apply.Apply):
# class Sin(apply.Apply):
# class Cos(apply.Apply):
# class Abs(apply.Apply):
# class Exp(apply.Apply):
# class Power(Node):
# class Log(apply.Apply):
# class Log10(apply.Apply):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def output(self):
# def __init__(self, **args):
# def __init__(self, **args):
. Output only the next line. | g.connect(p, b, 'message') |
Here is a snippet: <|code_start|>
def plot():
v1 = value.Value(value=[9, -3, 8.7], name='v1')
v2 = value.Value(value=[86, -0.43], name='v2')
s = maths.Sum(name='sum')
m = maths.Product(name='product')
b = buffers.Buffer(name='buffer')
p = printer.ConsolePrinter(name='printer')
g = graph.Graph('sum_and_product', [v1, v2, s, m, p, b])
g.connect(p, b, 'message')
<|code_end|>
. Write the next line using the current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes import plotter
from robograph.datamodel.nodes.lib import value, printer, buffers, maths
and context from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/plotter.py
# def prepare_plot(graph):
# def show_plot(graph):
# def save_plot(graph, outputfile):
# G = graph.nxgraph
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/maths.py
# class Pi(value.Value):
# class E(value.Value):
# class Sum(apply.Apply):
# class Product(apply.Apply):
# class Floor(apply.Apply):
# class Ceil(apply.Apply):
# class Sqrt(apply.Apply):
# class Max(apply.Apply):
# class Min(apply.Apply):
# class Sin(apply.Apply):
# class Cos(apply.Apply):
# class Abs(apply.Apply):
# class Exp(apply.Apply):
# class Power(Node):
# class Log(apply.Apply):
# class Log10(apply.Apply):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def output(self):
# def __init__(self, **args):
# def __init__(self, **args):
, which may include functions, classes, or code. Output only the next line. | g.connect(b, s, 'sum of v1') |
Given snippet: <|code_start|> v1 = value.Value(value=[9, -3, 8.7], name='v1')
v2 = value.Value(value=[86, -0.43], name='v2')
s = maths.Sum(name='sum')
m = maths.Product(name='product')
b = buffers.Buffer(name='buffer')
p = printer.ConsolePrinter(name='printer')
g = graph.Graph('sum_and_product', [v1, v2, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum of v1')
g.connect(b, m, 'product of v2')
g.connect(s, v1, 'argument')
g.connect(m, v2, 'argument')
plotter.show_plot(g)
def plot_to_file(outputfile):
v1 = value.Value(value=[9, -3, 8.7], name='v1')
v2 = value.Value(value=[86, -0.43], name='v2')
s = maths.Sum(name='sum')
m = maths.Product(name='product')
b = buffers.Buffer(name='buffer')
p = printer.ConsolePrinter(name='printer')
g = graph.Graph('sum_and_product', [v1, v2, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum of v1')
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes import plotter
from robograph.datamodel.nodes.lib import value, printer, buffers, maths
and context:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/plotter.py
# def prepare_plot(graph):
# def show_plot(graph):
# def save_plot(graph, outputfile):
# G = graph.nxgraph
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/maths.py
# class Pi(value.Value):
# class E(value.Value):
# class Sum(apply.Apply):
# class Product(apply.Apply):
# class Floor(apply.Apply):
# class Ceil(apply.Apply):
# class Sqrt(apply.Apply):
# class Max(apply.Apply):
# class Min(apply.Apply):
# class Sin(apply.Apply):
# class Cos(apply.Apply):
# class Abs(apply.Apply):
# class Exp(apply.Apply):
# class Power(Node):
# class Log(apply.Apply):
# class Log10(apply.Apply):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def output(self):
# def __init__(self, **args):
# def __init__(self, **args):
which might include code, classes, or functions. Output only the next line. | g.connect(b, m, 'product of v2') |
Based on the snippet: <|code_start|> s = maths.Sum(name='sum')
m = maths.Product(name='product')
b = buffers.Buffer(name='buffer')
p = printer.ConsolePrinter(name='printer')
g = graph.Graph('sum_and_product', [v1, v2, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum of v1')
g.connect(b, m, 'product of v2')
g.connect(s, v1, 'argument')
g.connect(m, v2, 'argument')
plotter.show_plot(g)
def plot_to_file(outputfile):
v1 = value.Value(value=[9, -3, 8.7], name='v1')
v2 = value.Value(value=[86, -0.43], name='v2')
s = maths.Sum(name='sum')
m = maths.Product(name='product')
b = buffers.Buffer(name='buffer')
p = printer.ConsolePrinter(name='printer')
g = graph.Graph('sum_and_product', [v1, v2, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum of v1')
g.connect(b, m, 'product of v2')
g.connect(s, v1, 'argument')
<|code_end|>
, predict the immediate next line with the help of imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes import plotter
from robograph.datamodel.nodes.lib import value, printer, buffers, maths
and context (classes, functions, sometimes code) from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/plotter.py
# def prepare_plot(graph):
# def show_plot(graph):
# def save_plot(graph, outputfile):
# G = graph.nxgraph
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/maths.py
# class Pi(value.Value):
# class E(value.Value):
# class Sum(apply.Apply):
# class Product(apply.Apply):
# class Floor(apply.Apply):
# class Ceil(apply.Apply):
# class Sqrt(apply.Apply):
# class Max(apply.Apply):
# class Min(apply.Apply):
# class Sin(apply.Apply):
# class Cos(apply.Apply):
# class Abs(apply.Apply):
# class Exp(apply.Apply):
# class Power(Node):
# class Log(apply.Apply):
# class Log10(apply.Apply):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def __init__(self, **args):
# def output(self):
# def __init__(self, **args):
# def __init__(self, **args):
. Output only the next line. | g.connect(m, v2, 'argument') |
Predict the next line for this snippet: <|code_start|>
FILEPATH = os.path.abspath('robograph/datamodel/tests/file.txt')
def test_requirements():
expected = ['filepath', 'encoding']
instance = files.TextFileReader()
assert instance.requirements == expected
def test_input():
expected = 'one\ntwo\nthree'
instance = files.TextFileReader()
instance.input(dict(filepath=FILEPATH, encoding='UTF-8'))
<|code_end|>
with the help of current file imports:
import os
from robograph.datamodel.nodes.lib import files
and context from other files:
# Path: robograph/datamodel/nodes/lib/files.py
# class File(node.Node):
# class TextFile(File):
# class TextFileReader(TextFile):
# class BinaryFileReader(File):
# class TextFileWriter(TextFile):
# class BinaryFileWriter(File):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
, which may contain function names, class names, or code. Output only the next line. | instance.set_output_label('any') |
Based on the snippet: <|code_start|># Long delay
def delayed_sum_and_product(list_of_numbers, delay):
val = value.Value(value=list_of_numbers)
summer = apply.Apply(function=sum)
multiplier = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
delayed_value_buffer = buffers.DelayedBuffer(seconds=delay)
printout = printer.ConsolePrinter()
g = graph.Graph('sum_and_product', [val, summer, multiplier,
printout, delayed_value_buffer,
delayed_value_buffer])
g.connect(printout, delayed_value_buffer, 'message')
g.connect(delayed_value_buffer, summer, 'sum value')
g.connect(delayed_value_buffer, multiplier, 'product value')
<|code_end|>
, predict the immediate next line with the help of imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, buffers, apply
and context (classes, functions, sometimes code) from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
# def output(self):
. Output only the next line. | g.connect(summer, val, 'argument') |
Here is a snippet: <|code_start|># Long delay
def delayed_sum_and_product(list_of_numbers, delay):
val = value.Value(value=list_of_numbers)
summer = apply.Apply(function=sum)
multiplier = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
delayed_value_buffer = buffers.DelayedBuffer(seconds=delay)
printout = printer.ConsolePrinter()
g = graph.Graph('sum_and_product', [val, summer, multiplier,
<|code_end|>
. Write the next line using the current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, buffers, apply
and context from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
# def output(self):
, which may include functions, classes, or code. Output only the next line. | printout, delayed_value_buffer, |
Given the code snippet: <|code_start|># Long delay
def delayed_sum_and_product(list_of_numbers, delay):
val = value.Value(value=list_of_numbers)
summer = apply.Apply(function=sum)
multiplier = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
delayed_value_buffer = buffers.DelayedBuffer(seconds=delay)
printout = printer.ConsolePrinter()
g = graph.Graph('sum_and_product', [val, summer, multiplier,
printout, delayed_value_buffer,
delayed_value_buffer])
g.connect(printout, delayed_value_buffer, 'message')
g.connect(delayed_value_buffer, summer, 'sum value')
g.connect(delayed_value_buffer, multiplier, 'product value')
g.connect(summer, val, 'argument')
g.connect(multiplier, val, 'argument')
<|code_end|>
, generate the next line using the imports in this file:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, buffers, apply
and context (functions, classes, or occasionally code) from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
# def output(self):
. Output only the next line. | return g |
Predict the next line for this snippet: <|code_start|># Long delay
def delayed_sum_and_product(list_of_numbers, delay):
val = value.Value(value=list_of_numbers)
summer = apply.Apply(function=sum)
multiplier = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
delayed_value_buffer = buffers.DelayedBuffer(seconds=delay)
printout = printer.ConsolePrinter()
g = graph.Graph('sum_and_product', [val, summer, multiplier,
printout, delayed_value_buffer,
delayed_value_buffer])
g.connect(printout, delayed_value_buffer, 'message')
g.connect(delayed_value_buffer, summer, 'sum value')
<|code_end|>
with the help of current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, buffers, apply
and context from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
# def output(self):
, which may contain function names, class names, or code. Output only the next line. | g.connect(delayed_value_buffer, multiplier, 'product value') |
Given the following code snippet before the placeholder: <|code_start|>
DATA_MATRIX = [[1,2,3],[4,5,6],[7,8,9]]
HEADER = ['one', 'two', 'three']
DELIMITER = ','
LINESEP = '\n'
EXPECTED = 'one,two,three\n1,2,3\n4,5,6\n7,8,9'
def test_requirements():
expected = ['data_matrix', 'header_list', 'delimiter', 'linesep']
instance = transcoders.ToCSV()
assert instance.requirements == expected
def test_input():
instance = transcoders.ToCSV()
instance.input(dict(data_matrix=DATA_MATRIX,
<|code_end|>
, predict the next line using imports from the current file:
from robograph.datamodel.nodes.lib import transcoders
and context including class names, function names, and sometimes code from other files:
# Path: robograph/datamodel/nodes/lib/transcoders.py
# class ToJSON(node.Node):
# class ToCSV(node.Node):
# def output(self):
# def output(self):
. Output only the next line. | header_list=HEADER, |
Given the code snippet: <|code_start|>
log_level = logging.INFO
logging.basicConfig(level=log_level)
logger = logging.getLogger(__name__)
def test_requirements():
expected = ['message', 'logger', 'loglevel']
instance = printer.LogPrinter()
instance.set_output_label('any')
assert instance.requirements == expected
def test_input():
msg = 'Hello world'
instance = printer.LogPrinter()
<|code_end|>
, generate the next line using the imports in this file:
import logging
from robograph.datamodel.nodes.lib import printer
and context (functions, classes, or occasionally code) from other files:
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
. Output only the next line. | instance.input(dict(message=msg, logger=logger, loglevel=log_level)) |
Given the code snippet: <|code_start|>
class Date(node.Node):
_reqs = []
DEFAULT_DATE_FORMAT = '%Y-%m-%d'
<|code_end|>
, generate the next line using the imports in this file:
import datetime
from robograph.datamodel.base import node
and context (functions, classes, or occasionally code) from other files:
# Path: robograph/datamodel/base/node.py
# class Node:
# def __init__(self, **args):
# def name(self):
# def requirements(self):
# def parameters(self):
# def output_label(self):
# def input(self, context):
# def set_output_label(self, output_label):
# def output(self):
# def execute(self):
# def reset(self):
# def __repr__(self):
. Output only the next line. | def output(self): |
Predict the next line for this snippet: <|code_start|>
instance = http.Post(url=url, mime_type=MIME_TYPE,
headers=HEADERS, verify_ssl=False,
post_data=FORM_DATA)
assert instance.requirements == expected_reqs
result = instance.output()
assert result['form'] == FORM_DATA
assert len(result['files']) == 0
assert result['url'] == url
assert ('X-Custom', 'value') in result['headers'].items()
def test_put():
url = u'https://httpbin.org/put'
expected_reqs = ['url', 'headers', 'auth', 'timeout_secs', 'verify_ssl',
'put_data', 'mime_type']
instance = http.Put(url=url, mime_type=MIME_TYPE,
headers=HEADERS, verify_ssl=False,
put_data=FORM_DATA)
assert instance.requirements == expected_reqs
result = instance.output()
assert result['form'] == FORM_DATA
assert result['url'] == url
assert ('X-Custom', 'value') in result['headers'].items()
def test_delete():
url = u'https://httpbin.org/put'
<|code_end|>
with the help of current file imports:
from robograph.datamodel.nodes.lib import http
and context from other files:
# Path: robograph/datamodel/nodes/lib/http.py
# class HttpClient(node.Node):
# class StatusCode(node.Node):
# class StatusCodeOk(node.Node):
# class RawGet(HttpClient):
# class Get(RawGet):
# class RawPost(HttpClient):
# class Post(RawPost):
# class RawPut(HttpClient):
# class Put(RawPut):
# class RawDelete(HttpClient):
# class Delete(RawDelete):
# DEFAULT_TIMEOUT_SECS = 3
# def _encode_payload(self, response, mime_type):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
, which may contain function names, class names, or code. Output only the next line. | expected_reqs = ['url', 'headers', 'auth', 'timeout_secs', 'verify_ssl', |
Continue the code snippet: <|code_start|># Given a text, replace occurrences of the word "hello" with "ciao" - if any.
# If no occurrence is found, replace all whitespaces with "_" instead
def replace_word(text):
t = value.Value(value=text, name="text")
s = branching.IfThenApply(condition=lambda x: "hello" in x,
function_true=lambda x: x.replace("hello", "ciao"),
function_false=lambda x: x.replace(" ", "_"),
name="if")
p = printer.ConsolePrinter()
g = graph.Graph('replace_word', [t, s, p])
g.connect(p, s, 'message')
g.connect(s, t, 'data')
<|code_end|>
. Use current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, branching
and context (classes, functions, or code) from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/branching.py
# class IfThenApply(node.Node):
# class IfThenReturn(node.Node):
# def output(self):
# def output(self):
. Output only the next line. | return g |
Predict the next line for this snippet: <|code_start|># Given a text, replace occurrences of the word "hello" with "ciao" - if any.
# If no occurrence is found, replace all whitespaces with "_" instead
def replace_word(text):
t = value.Value(value=text, name="text")
s = branching.IfThenApply(condition=lambda x: "hello" in x,
function_true=lambda x: x.replace("hello", "ciao"),
function_false=lambda x: x.replace(" ", "_"),
name="if")
p = printer.ConsolePrinter()
g = graph.Graph('replace_word', [t, s, p])
<|code_end|>
with the help of current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, branching
and context from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/branching.py
# class IfThenApply(node.Node):
# class IfThenReturn(node.Node):
# def output(self):
# def output(self):
, which may contain function names, class names, or code. Output only the next line. | g.connect(p, s, 'message') |
Predict the next line for this snippet: <|code_start|># Given a text, replace occurrences of the word "hello" with "ciao" - if any.
# If no occurrence is found, replace all whitespaces with "_" instead
def replace_word(text):
t = value.Value(value=text, name="text")
s = branching.IfThenApply(condition=lambda x: "hello" in x,
<|code_end|>
with the help of current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, branching
and context from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/branching.py
# class IfThenApply(node.Node):
# class IfThenReturn(node.Node):
# def output(self):
# def output(self):
, which may contain function names, class names, or code. Output only the next line. | function_true=lambda x: x.replace("hello", "ciao"), |
Next line prediction: <|code_start|>
def test_node_serializer():
instance = apply.Apply(function=lambda x: x + 2, argument=3, name='test')
serialized = serializer.NodeSerializer.serialize(instance)
deserialized = serializer.NodeSerializer.deserialize(serialized)
assert instance.name == deserialized.name
<|code_end|>
. Use current file imports:
(from robograph.datamodel.base import graph
from robograph.datamodel.nodes import serializer
from robograph.datamodel.nodes.lib import value, buffers, apply)
and context including class names, function names, or small code snippets from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/serializer.py
# class NodeDeserializationException(Exception):
# class NodeSerializer:
# class GraphDeserializationException(Exception):
# class GraphSerializer:
# def to_dict(cls, node):
# def from_dict(cls, node_dict):
# def serialize(cls, node):
# def deserialize(cls, json_string):
# def to_dict(cls, graph):
# def _get_id(seq, node):
# def serialize(cls, graph):
# def deserialize(cls, json_string):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
# def output(self):
. Output only the next line. | assert instance.output_label == deserialized.output_label |
Here is a snippet: <|code_start|>
def test_node_serializer():
instance = apply.Apply(function=lambda x: x + 2, argument=3, name='test')
serialized = serializer.NodeSerializer.serialize(instance)
deserialized = serializer.NodeSerializer.deserialize(serialized)
<|code_end|>
. Write the next line using the current file imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes import serializer
from robograph.datamodel.nodes.lib import value, buffers, apply
and context from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/serializer.py
# class NodeDeserializationException(Exception):
# class NodeSerializer:
# class GraphDeserializationException(Exception):
# class GraphSerializer:
# def to_dict(cls, node):
# def from_dict(cls, node_dict):
# def serialize(cls, node):
# def deserialize(cls, json_string):
# def to_dict(cls, graph):
# def _get_id(seq, node):
# def serialize(cls, graph):
# def deserialize(cls, json_string):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
# def output(self):
, which may include functions, classes, or code. Output only the next line. | assert instance.name == deserialized.name |
Next line prediction: <|code_start|>
def test_node_serializer():
instance = apply.Apply(function=lambda x: x + 2, argument=3, name='test')
serialized = serializer.NodeSerializer.serialize(instance)
deserialized = serializer.NodeSerializer.deserialize(serialized)
assert instance.name == deserialized.name
assert instance.output_label == deserialized.output_label
assert instance.output() == deserialized.output()
<|code_end|>
. Use current file imports:
(from robograph.datamodel.base import graph
from robograph.datamodel.nodes import serializer
from robograph.datamodel.nodes.lib import value, buffers, apply)
and context including class names, function names, or small code snippets from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/serializer.py
# class NodeDeserializationException(Exception):
# class NodeSerializer:
# class GraphDeserializationException(Exception):
# class GraphSerializer:
# def to_dict(cls, node):
# def from_dict(cls, node_dict):
# def serialize(cls, node):
# def deserialize(cls, json_string):
# def to_dict(cls, graph):
# def _get_id(seq, node):
# def serialize(cls, graph):
# def deserialize(cls, json_string):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
# def output(self):
. Output only the next line. | def test_graph_serializer(): |
Given the code snippet: <|code_start|>
def test_node_serializer():
instance = apply.Apply(function=lambda x: x + 2, argument=3, name='test')
serialized = serializer.NodeSerializer.serialize(instance)
deserialized = serializer.NodeSerializer.deserialize(serialized)
<|code_end|>
, generate the next line using the imports in this file:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes import serializer
from robograph.datamodel.nodes.lib import value, buffers, apply
and context (functions, classes, or occasionally code) from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/serializer.py
# class NodeDeserializationException(Exception):
# class NodeSerializer:
# class GraphDeserializationException(Exception):
# class GraphSerializer:
# def to_dict(cls, node):
# def from_dict(cls, node_dict):
# def serialize(cls, node):
# def deserialize(cls, json_string):
# def to_dict(cls, graph):
# def _get_id(seq, node):
# def serialize(cls, graph):
# def deserialize(cls, json_string):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
# def output(self):
. Output only the next line. | assert instance.name == deserialized.name |
Predict the next line after this snippet: <|code_start|>
def test_node_serializer():
instance = apply.Apply(function=lambda x: x + 2, argument=3, name='test')
serialized = serializer.NodeSerializer.serialize(instance)
deserialized = serializer.NodeSerializer.deserialize(serialized)
assert instance.name == deserialized.name
assert instance.output_label == deserialized.output_label
<|code_end|>
using the current file's imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes import serializer
from robograph.datamodel.nodes.lib import value, buffers, apply
and any relevant context from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/serializer.py
# class NodeDeserializationException(Exception):
# class NodeSerializer:
# class GraphDeserializationException(Exception):
# class GraphSerializer:
# def to_dict(cls, node):
# def from_dict(cls, node_dict):
# def serialize(cls, node):
# def deserialize(cls, json_string):
# def to_dict(cls, graph):
# def _get_id(seq, node):
# def serialize(cls, graph):
# def deserialize(cls, json_string):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/buffers.py
# class Buffer(node.Node):
# class DelayedBuffer(Buffer):
# def __init__(self, **args):
# def input(self, context):
# def output(self):
# def reset(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
# def output(self):
. Output only the next line. | assert instance.output() == deserialized.output() |
Predict the next line for this snippet: <|code_start|>
def test_requirements():
expected = ['data', 'condition', 'function_true', 'function_false']
instance = branching.IfThenReturn()
assert instance.requirements == expected
def test_input():
data = 7
condition = lambda x: x >= 0
function_true = lambda x: math.sqrt(x)
function_false = lambda x: 0
instance = branching.IfThenReturn()
instance.input(dict(data=data,
condition=condition,
function_true=function_true,
function_false=function_false))
instance.set_output_label('any')
# case: true
assert instance.output() == function_true
# case: false
data = -34
instance.reset()
instance.input(dict(data=data,
condition=condition,
<|code_end|>
with the help of current file imports:
import math
from robograph.datamodel.nodes.lib import branching
and context from other files:
# Path: robograph/datamodel/nodes/lib/branching.py
# class IfThenApply(node.Node):
# class IfThenReturn(node.Node):
# def output(self):
# def output(self):
, which may contain function names, class names, or code. Output only the next line. | function_true=function_true, |
Continue the code snippet: <|code_start|> assert instance.requirements == expected
def test_input():
data = 7
condition = lambda x: x >= 0
function_true = lambda x: math.sqrt(x)
function_false = lambda x: 0
instance = branching.IfThenApply()
instance.input(dict(data=data,
condition=condition,
function_true=function_true,
function_false=function_false))
instance.set_output_label('any')
# case: true
assert instance.output() == math.sqrt(data)
# case: false
data = -34
instance.reset()
instance.input(dict(data=data,
condition=condition,
function_true=function_true,
function_false=function_false))
instance.set_output_label('any')
assert instance.output() == 0
def test_output():
data = 7
<|code_end|>
. Use current file imports:
import math
from robograph.datamodel.nodes.lib import branching
and context (classes, functions, or code) from other files:
# Path: robograph/datamodel/nodes/lib/branching.py
# class IfThenApply(node.Node):
# class IfThenReturn(node.Node):
# def output(self):
# def output(self):
. Output only the next line. | condition = lambda x: x >= 0 |
Given the following code snippet before the placeholder: <|code_start|> verify_ssl=False)
v = value.Value(value=url)
h = http.Get(**http_params)
p = printer.ConsolePrinter()
g = graph.Graph('test_get_graph', [v, h, p])
g.connect(p, h, 'message')
g.connect(h, v, 'url')
return g
def test_post_graph(url, post_data):
http_params = dict(url=url, mime_type='application/json', verify_ssl=False)
v = value.Value(value=url)
post_data = value.Value(value=post_data)
h = http.Post(**http_params)
p = printer.ConsolePrinter()
g = graph.Graph('test_post_graph', [v, post_data, h, p])
g.connect(p, h, 'message')
g.connect(h, v, 'url')
g.connect(h, post_data, 'post_data')
return g
def test_put_graph(url, put_data):
<|code_end|>
, predict the next line using imports from the current file:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, http
and context including class names, function names, and sometimes code from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/http.py
# class HttpClient(node.Node):
# class StatusCode(node.Node):
# class StatusCodeOk(node.Node):
# class RawGet(HttpClient):
# class Get(RawGet):
# class RawPost(HttpClient):
# class Post(RawPost):
# class RawPut(HttpClient):
# class Put(RawPut):
# class RawDelete(HttpClient):
# class Delete(RawDelete):
# DEFAULT_TIMEOUT_SECS = 3
# def _encode_payload(self, response, mime_type):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
. Output only the next line. | http_params = dict(url=url, post_data=put_data, mime_type='application/json', |
Predict the next line after this snippet: <|code_start|># Various HTTP calls against HTTPBin
def test_get_graph(url, query_params):
http_params = dict(url=url, query=query_params, mime_type='application/json',
verify_ssl=False)
v = value.Value(value=url)
h = http.Get(**http_params)
p = printer.ConsolePrinter()
g = graph.Graph('test_get_graph', [v, h, p])
g.connect(p, h, 'message')
g.connect(h, v, 'url')
return g
def test_post_graph(url, post_data):
http_params = dict(url=url, mime_type='application/json', verify_ssl=False)
v = value.Value(value=url)
post_data = value.Value(value=post_data)
h = http.Post(**http_params)
p = printer.ConsolePrinter()
g = graph.Graph('test_post_graph', [v, post_data, h, p])
g.connect(p, h, 'message')
<|code_end|>
using the current file's imports:
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, http
and any relevant context from other files:
# Path: robograph/datamodel/base/graph.py
# class Graph:
# def __init__(self, name, nodes=None):
# def root_node(self):
# def nodes(self):
# def edges(self):
# def nxgraph(self):
# def name(self):
# def add_node(self, node):
# def add_nodes(self, sequence_of_nodes):
# def remove_node(self, node):
# def remove_nodes(self, sequence_of_nodes):
# def connect(self, node_from, node_to, output_label):
# def has_isles(self):
# def execute(self, result_label="result"):
# def reset(self):
# def __repr__(self):
# def __len__(self):
#
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
# def output(self):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
# def output(self):
#
# Path: robograph/datamodel/nodes/lib/http.py
# class HttpClient(node.Node):
# class StatusCode(node.Node):
# class StatusCodeOk(node.Node):
# class RawGet(HttpClient):
# class Get(RawGet):
# class RawPost(HttpClient):
# class Post(RawPost):
# class RawPut(HttpClient):
# class Put(RawPut):
# class RawDelete(HttpClient):
# class Delete(RawDelete):
# DEFAULT_TIMEOUT_SECS = 3
# def _encode_payload(self, response, mime_type):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
# def output(self):
. Output only the next line. | g.connect(h, v, 'url') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.