1 # Copyright (c) 2016-2017 Intel Corporation
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 from six.moves import StringIO
20 from yardstick.network_services import constants
21 from yardstick.ssh import AutoConnectSSH
23 LOG = logging.getLogger(__name__)
26 class VnfSshHelper(AutoConnectSSH):
28 def __init__(self, node, bin_path, wait=None):
30 kwargs = self.args_from_node(self.node)
32 # if wait is defined here we want to override
35 super(VnfSshHelper, self).__init__(**kwargs)
36 self.bin_path = bin_path
40 # must return static class name, anything else refers to the calling class
41 # i.e. the subclass, not the superclass
45 # this copy constructor is different from SSH classes, since it uses node
46 return self.get_class()(self.node, self.bin_path)
48 def upload_config_file(self, prefix, content):
49 cfg_file = os.path.join(constants.REMOTE_TMP, prefix)
51 file_obj = StringIO(content)
52 self.put_file_obj(file_obj, cfg_file)
55 def join_bin_path(self, *args):
56 return os.path.join(self.bin_path, *args)
58 def provision_tool(self, tool_path=None, tool_file=None):
60 tool_path = self.bin_path
61 return super(VnfSshHelper, self).provision_tool(tool_path, tool_file)