1 # Copyright 2015 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.
26 def __init__(self, memory, cpus,
27 monitor_path, shared_path_host,
28 shared_path_guest, guest_prompt):
30 Initialization method.
32 Purpose of this method is to initialize all
33 common Vnf data, no services should be started by
34 this call (use ``start`` method instead).
36 :param memory: Virtual RAM size in megabytes.
37 :param cpus: Number of Processors.
38 :param monitor_path: Configure monitor to given path.
39 :param shared_path_host: HOST path to shared location.
40 :param shared_path_guest: GUEST path to shared location.
41 :param guest_prompt: preconfigured command prompt which is used
42 in execute_and_wait & wait methods
43 to detect if particular call is finished.
45 raise NotImplementedError()
51 raise NotImplementedError()
57 raise NotImplementedError()
59 def execute(self, command, delay=30):
61 execute ``command`` with given ``delay``.
63 This method makes asynchronous call to guest system
64 and waits given ``delay`` before returning. Can be
65 used with ``wait`` method to create synchronous call.
67 :param command: Command to execute on guest system.
68 :param delay: Delay (in seconds) to wait after sending
69 command before returning. Please note that
70 this value can be floating point which
71 allows to pass milliseconds.
75 raise NotImplementedError()
77 def wait(self, guest_prompt, timeout=30):
79 wait for ``guest_prompt`` on guest system for given ``timeout``.
81 This method ends based on two conditions:
82 * ``guest_prompt`` has been detected
83 * ``timeout`` has been reached.
85 :param guest_prompt: method end condition. If ``guest_prompt``
86 won't be detected during given timeout,
87 method will return False.
88 :param timeout: Time to wait for prompt (in seconds).
89 Please note that this value can be floating
90 point which allows to pass milliseconds.
92 :returns: True if result_cmd has been detected before
93 timeout has been reached, False otherwise.
95 raise NotImplementedError()
97 def execute_and_wait(self, command, timeout=30, guest_prompt=None):
99 execute ``command`` with given ``timeout``.
101 This method makes synchronous call to guest system
102 and waits till ``command`` execution is finished
103 (based on ``guest_prompt value) or ''timeout'' has
106 :param command: Command to execute on guest system.
107 :param timeout: Timeout till the end of execution is not
109 :param guest_prompt: method end condition. If ``guest_prompt``
110 won't be detected during given timeout,
111 method will return False. If no argument
112 or None value will be passed, default
113 ``guest_prompt`` passed in __init__
116 :returns: True if end of execution has been detected
117 before timeout has been reached, False otherwise.
119 raise NotImplementedError()