Run the inline script commands, one by one :**kwargs: catch all other things we may get but don't actually need/use
(
host,
name=None,
port=22,
timeout=900,
username="root",
key_filename=None,
inline_script=None,
ssh_timeout=15,
display_ssh_output=True,
parallel=False,
sudo_password=None,
sudo=False,
password=None,
tty=None,
opts=None,
tmp_dir="/tmp/.saltcloud-inline_script",
**kwargs,
)
| 1934 | |
| 1935 | |
| 1936 | def run_inline_script( |
| 1937 | host, |
| 1938 | name=None, |
| 1939 | port=22, |
| 1940 | timeout=900, |
| 1941 | username="root", |
| 1942 | key_filename=None, |
| 1943 | inline_script=None, |
| 1944 | ssh_timeout=15, |
| 1945 | display_ssh_output=True, |
| 1946 | parallel=False, |
| 1947 | sudo_password=None, |
| 1948 | sudo=False, |
| 1949 | password=None, |
| 1950 | tty=None, |
| 1951 | opts=None, |
| 1952 | tmp_dir="/tmp/.saltcloud-inline_script", |
| 1953 | **kwargs, |
| 1954 | ): |
| 1955 | """ |
| 1956 | Run the inline script commands, one by one |
| 1957 | :**kwargs: catch all other things we may get but don't actually need/use |
| 1958 | """ |
| 1959 | |
| 1960 | gateway = None |
| 1961 | if "gateway" in kwargs: |
| 1962 | gateway = kwargs["gateway"] |
| 1963 | |
| 1964 | starttime = time.mktime(time.localtime()) |
| 1965 | log.debug("Deploying %s at %s", host, starttime) |
| 1966 | |
| 1967 | known_hosts_file = kwargs.get("known_hosts_file", "/dev/null") |
| 1968 | |
| 1969 | if wait_for_port(host=host, port=port, gateway=gateway): |
| 1970 | log.debug("SSH port %s on %s is available", port, host) |
| 1971 | newtimeout = timeout - (time.mktime(time.localtime()) - starttime) |
| 1972 | if wait_for_passwd( |
| 1973 | host, |
| 1974 | port=port, |
| 1975 | username=username, |
| 1976 | password=password, |
| 1977 | key_filename=key_filename, |
| 1978 | ssh_timeout=ssh_timeout, |
| 1979 | display_ssh_output=display_ssh_output, |
| 1980 | gateway=gateway, |
| 1981 | known_hosts_file=known_hosts_file, |
| 1982 | ): |
| 1983 | |
| 1984 | log.debug("Logging into %s:%s as %s", host, port, username) |
| 1985 | newtimeout = timeout - (time.mktime(time.localtime()) - starttime) |
| 1986 | ssh_kwargs = { |
| 1987 | "hostname": host, |
| 1988 | "port": port, |
| 1989 | "username": username, |
| 1990 | "timeout": ssh_timeout, |
| 1991 | "display_ssh_output": display_ssh_output, |
| 1992 | "sudo_password": sudo_password, |
| 1993 | "sftp": opts.get("use_sftp", False), |
no test coverage detected