openstack - stack.sh fails on syntax errors - openstack

I am trying to install Devstack as non-root user, but getting errors.
The log directory contains only broken symbolic links stack.sh.log and stack.sh.log.summary (pointing to nonexistent files).
I've used the sample local.conf - the only change is that I defined the $DEST.
OS: RHEL 6.6
STDOUT/ERR:
/home/john/scripts/openstack/devstack/functions-common: line 68: conditional binary operator expected
/home/john/scripts/openstack/devstack/functions-common: line 68: syntax error near `"$1"'
/home/john/scripts/openstack/devstack/functions-common: line 68: ` [[ -v "$1" ]]'
./stack.sh: line 119: GetDistro: command not found
/home/john/scripts/openstack/devstack/functions-common: line 68: conditional binary operator expected
/home/john/scripts/openstack/devstack/functions-common: line 68: syntax error near `"$1"'
/home/john/scripts/openstack/devstack/functions-common: line 68: ` [[ -v "$1" ]]'
/home/john/scripts/openstack/devstack/stackrc: line 48: isset: command not found
/home/john/scripts/openstack/devstack/.localrc.auto: line 84: enable_service: command not found
/home/john/scripts/openstack/devstack/stackrc: line 498: is_package_installed: command not found
/home/john/scripts/openstack/devstack/stackrc: line 666: get_default_host_ip: command not found
/home/john/scripts/openstack/devstack/stackrc: line 668: die: command not found
WARNING: this script has not been tested on
./stack.sh: line 179: die: command not found
./stack.sh: line 197: export_proxy_variables: command not found
./stack.sh: line 202: disable_negated_services: command not found
./stack.sh: line 209: is_package_installed: command not found
./stack.sh: line 209: install_package: command not found
[sudo] password for john:
./stack.sh: line 231: is_ubuntu: command not found
./stack.sh: line 238: is_fedora: command not found
./stack.sh: line 301: safe_chown: command not found
./stack.sh: line 302: safe_chmod: command not found
./stack.sh: line 310: safe_chown: command not found
Traceback (most recent call last):
File "/home/john/scripts/openstack/devstack/tools/outfilter.py", line 24, in <module>
import argparse
ImportError: No module named argparse

First, fix the missing module by using yum:
yum install python-argparse.noarch
Also you will need to run ./unstack.sh to clear the logs.
I had still faced this issue, so further debugging lead me to an issue when both python-zaqarclient and python-openstackclient were installed. As a quick solution I removed python-zaqarclient:
sudo pip uninstall python-zaqarclient
Then
- apt-get upgrade
- apt-get dist-upgrade
- ./stack.sh
Hope this helps!

Related

Unexpected "\n" while trying to exec command in paramiko

Okay, so I tried to remove files on remote machine with paramiko. But I'm stuck on this error:
"bash: -c: line 1: syntax error near unexpected token `('\n",
"bash: -c: line 1: `rm -rf /home/server/audio(23).mp3'\n".
Code:
self.ssh = paramiko.SSHClient()
self.ssh.load_system_host_keys()
# here is code with establishing ssh connection
# ...
# connection established
path = '/home/server/audio(23).mp3'
com = f"rm {path}"
stdin, stdout, stderr = self.ssh.exec_command(com)
print(stderr.readlines()) # here I see the error
I tried to check is com variable has such substring "\n" but got false as answer so it's not my fault I guess:
print("\n" in com) # returns false each time
I've reformatted your error message a little bit, and the problem should be clearer now:
"bash: -c: line 1: syntax error near unexpected token `('\n",
"bash: -c: line 1: `rm -rf /home/server/audio(23).mp3'\n".
As you can see, the \n doesn't have anything to do with the error message itself, it's simply just part of the output of the command as returned by paramiko. It's telling you that the unexpected token is (, not \n. When you interpret the error message as an array of python strings, this gets even clearer:
bash: -c: line 1: syntax error near unexpected token `('
bash: -c: line 1: `rm -rf /home/server/audio(23).mp3'
The correct fix is to use the shlex.quote function from the Python standard library to escape your file's path before you execute it:
from shlex import quote
path = '/home/server/audio(23).mp3'
com = f"rm {quote(path)}"
stdin, stdout, stderr = self.ssh.exec_command(com)
From the docs:
Return a shell-escaped version of the string s. The returned value is a string that can safely be used as one token in a shell command line, for cases where you cannot use a list.
Using shlex.quote should prevent the shell on the other end (bash, in this case) from getting tripped up by any special characters that may be present in the path (like spaces, parentheses, quotation marks—you name it). Note that shlex only works on Unix shells. If you want to use paramiko to connect to a Windows server over SSH, you'll need a different library. This depends on the server that you're connecting to: it doesn't matter where you run the Python code, it only matters where self.ssh ends up pointing to.

How to prevent R system command syntax error

I am trying to run a command similar to
> system("cat <(echo $PATH)")
which fails when run from within R or Rstudio with the following error message:
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `cat <(echo $PATH)'
However, if I run this on the command line it works fine:
$ cat <(echo $PATH)
[...]/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
I checked that the shell I am using is bash using system("echo $SHELL"). Can anyone help me solving this?
This syntax works in bash but not sh. The $SHELL environment variable doesn't necessarily mean that is the shell being used. echo $0 will show your shell.
system("echo $0")
#> sh
You could force bash to be used like this
system("bash -c 'cat <(echo $PATH)'")
#> /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

oh-my-zsh Command Not Found: ^M

I am trying to install oh-my-zsh on Ubuntu 15. After running the installation script
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
I have the following error which never occur before
/home/li-xinyang/.zshrc:3: command not found: ^M
/home/li-xinyang/.zshrc:9: command not found: ^M
/home/li-xinyang/.zshrc:12: command not found: ^M
/home/li-xinyang/.zshrc:16: command not found: ^M
/home/li-xinyang/.zshrc:19: command not found: ^M
/home/li-xinyang/.zshrc:22: command not found: ^M
/home/li-xinyang/.zshrc:25: command not found: ^M
/home/li-xinyang/.zshrc:28: command not found: ^M
/home/li-xinyang/.zshrc:31: command not found: ^M
/home/li-xinyang/.zshrc:34: command not found: ^M
/home/li-xinyang/.zshrc:39: command not found: ^M
/home/li-xinyang/.zshrc:44: command not found: ^M
/home/li-xinyang/.zshrc:47: command not found: ^M
/home/li-xinyang/.zshrc:52: command not found: ^M
/home/li-xinyang/.zshrc:53: command not found: ^M
/home/li-xinyang/.zshrc:55: command not found: ^M
/home/li-xinyang/.zshrc:58: command not found: ^M
/home/li-xinyang/.zshrc:source:59: no such file or directory: /home/li-xinyang/.oh-my-zsh/oh-my-zsh.sh^M
/home/li-xinyang/.zshrc:60: command not found: ^M
/home/li-xinyang/.zshrc:63: command not found: ^M
/home/li-xinyang/.zshrc:70: command not found: ^M
/home/li-xinyang/.zshrc:73: command not found: ^M
/home/li-xinyang/.zshrc:76: command not found: ^M
How can I remove ^M?
In my Mac ran dos2unix for all files installed by Oh-My-Zsh. In summary it was something like below. I kept rerunning source ~/.zshrc to check if the installation was OK, without any errors, until I have converted all files, including binary files.
brew install dos2unix
cd /Users/<your user>/.oh-my-zsh
find . -name " *.sh" | xargs dos2unix -f
find . -name " *.zsh" | xargs dos2unix -f
dos2unix -f themes/robbyrussel.zsh-theme
cd
dos2unix -f .zshrc
source ~/.zshrc
The solution is to set autocrlf=true to autocrlf=false use the command below,
git config --global core.autocrlf true
^M is carriage return (CR), Windows-style text line ending make.
I could resolve this error in Ubuntu by saving the file ~/.zshrc in LF mode.
I had the same issue, and autocrlf=true did not resolve the issue.
After I disabled the git plugin in ~/.zshrc by commenting it out, and removed & replaced the file which has the problem ^M, it was resolved. It seems git plugin on oh-my-zsh makes a conflict.
#plugins=(git)

Hadoop 2.6 start-dfs.sh errors on Centos 6.7

I use this tutorial to install Hadoop 2.6 on Centos 6.7 with Java 1.8.0_72 and everything goes well before execution of start-dfs.sh from Hadoop-home/sbin/srart-dfs.sh. Below is the output:
[hadoop#10 sbin]$ start-dfs.sh
16/02/26 21:47:40 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [localhost]
localhost: /etc/bashrc: line 65: id: command not found
localhost: /etc/bashrc: line 65: id: command not found
localhost: /usr/bin/env: bash: No such file or directory
localhost: /etc/bashrc: line 65: id: command not found
localhost: /etc/bashrc: line 65: id: command not found
localhost: /usr/bin/env: bash: No such file or directory
Starting secondary namenodes [0.0.0.0]
0.0.0.0: /etc/bashrc: line 65: id: command not found
0.0.0.0: /etc/bashrc: line 65: id: command not found
0.0.0.0: /usr/bin/env: bash: No such file or directory
16/02/26 21:47:46 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
It seems there is something wrong with /etv/bashrc # line 65. But, I checked and there is nothing I modified.
I run CentOS 6.7 final releas using Parallel VM manager of my Mac which is a 64-bit machine.
Thanks in advance
Edit your core-site.xml and add this part:
<property>
<name>hadoop.tmp.dir</name>
<value>/app/hadoop/tmp</value>
<description>A base for other temporary directories.</description>
</property>
Then create the folder accordingly, example command:
mkdir -p /app/hadoop/tmp
chown yourHadoopUsername:yourHadoopGroupName /app/hadoop/tmp
chmod 777 /app/hadoop/tmp
Format your datanode:
hdfs namenode -format
Start your hadoop:
start-dfs.sh
start-yarn.sh

How to run a Symfony command from Heroku's Scheduler

I've configured Heroku's Scheduler to run a Symfony 2 command:
bash app/console myapp:send:confirmations --verbose
And set it to be run each 10 minutes.
But, in the logs I see those messages:
2015-09-10T13:01:25.313711+00:00 heroku[api]: Starting process with command `bash app/console myapp:send:confirmations` by scheduler#addons.heroku.com
2015-09-10T13:01:44.151426+00:00 heroku[scheduler.7629]: Starting process with command `bash app/console myapp:send:confirmations --verbose`
2015-09-10T13:01:44.811500+00:00 heroku[scheduler.7629]: State changed from starting to up
2015-09-10T13:01:45.565021+00:00 app[scheduler.7629]: app/console: line 2: ?php: No such file or directory
2015-09-10T13:01:45.565093+00:00 app[scheduler.7629]: app/console: line 19: unexpected EOF while looking for matching `''
2015-09-10T13:01:45.565096+00:00 app[scheduler.7629]: app/console: line 28: syntax error: unexpected end of file
2015-09-10T13:01:46.291606+00:00 heroku[scheduler.7629]: State changed from up to complete
2015-09-10T13:01:46.278800+00:00 heroku[scheduler.7629]: Process exited with status 2
Those are the three relevant that are confusing me:
2015-09-10T13:01:45.565021+00:00 app[scheduler.7629]: app/console: line 2: ?php: No such file or directory
2015-09-10T13:01:45.565093+00:00 app[scheduler.7629]: app/console: line 19: unexpected EOF while looking for matching `''
2015-09-10T13:01:45.565096+00:00 app[scheduler.7629]: app/console: line 28: syntax error: unexpected end of file
I'm a bit confused: the file app/console seems not exist, but then the script encounters an unexpected EOF (but the file doesn't exist o.O) and then an unexpected end of file (isn't this the same thing as the message immediatley before?
What am I doing wrong?
Use php instead of bash to launch the console:
php app/console myapp:send:confirmations --verbose
I have the same behaviour (crash) on Ubuntu 15.04:
$ bash app/console
app/console: line 2: ?php: No such file or directory
app/console: line 18: unexpected EOF while looking for matching `''
app/console: line 23: syntax error: unexpected end of file
$ php app/console -v
Symfony version 2.7.4 - app/prod
...
It seems that the shebang from the start of app/console is ignored and the PHP interpreter is not called:
#!/usr/bin/env php
<?php
....
Here are explanations from Aaron Copley:
It's not executable
Run the binary with absolute or relative path
So if you mark the file as executable and launch the script with relative path, the PHP interpreter will be called:
$ chmod +x app/console
$ ./app/console -v
Symfony version 2.7.4 - app/prod

Resources