AttributeError: module 'salt.modules' has no attribute 'cp' - salt-stack

The CP command from the terminal is working as expected via
salt "*" cp_push .... works as expected from the master terminal. However using the command in an execution module fails with:
AttributeError: module 'salt.modules' has no attribute 'cp'
Salt is imported in the execution module via:
import salt
The function is being called as:
salt.modules.cp.push(path=str(latest_report))

Not an answer but a work around.
used:
salt.modules.cmdmod.run("salt-call cp.push *desired path*, shell="powershell")
Using powershell solved a plethora of other errors in default Command Prompt

Related

Openstack placement-status upgrade check giving not initialized error

I am trying to install openstack Wallaby on Ubuntu 20.04. I already installed Keystone and Glance and they work as expected. But after I installed Placement and tried to verify it using 'placement-status upgrade check' I constantly get the same error.
Error:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/oslo_upgradecheck/upgradecheck.py", line 196, in run
return conf.command.action_fn()
File "/usr/lib/python3/dist-packages/oslo_upgradecheck/upgradecheck.py", line 104, in check
result = func_name(self, **kwargs)
File "/usr/lib/python3/dist-packages/oslo_upgradecheck/common_checks.py", line 41, in check_policy_json
policy_path = conf.find_file(conf.oslo_policy.policy_file)
File "/usr/lib/python3/dist-packages/oslo_config/cfg.py", line 2543, in find_file
raise NotInitializedError()
oslo_config.cfg.NotInitializedError: call expression on parser has not been invoked
Is this normal at this stage or am I doing something wrong here?
I already checked the database connections (user and password work and database is made). And I also checked the username, password and url options in keystone_authtoken in placement.conf but I can't find what's wrong.
I also encountered this problem with Wallaby on Ubuntu 20.04. I solved it with installing Placement from PyPI instead of Ubuntu package manager so far. You should consider how implement starting Placement automatically if you install Placement from this instruction.
Install and configure Placement from PyPI
https://docs.openstack.org/placement/wallaby/install/from-pypi.html
I had the same problem so changed to Victoria, same issue. Digging about in the docs though I found the issue. The command that populate the database looks similar for Keystone, Glance and Placement but for placement the command should be 'su -s /bin/sh -c "placement-manage db sync" placement'. Notice that for placement it is 'db sync' not 'db_sync' as it is for the others. I created scripts, well actuall am using ansible and just cut and pasted between them and my guess is you have done the same. Basically as it does not run the database is empty hence the error.
Guy

Getting jsonpath error when executing any commands in zsh

error: error executing jsonpath "{.contexts[?(#.name==\"\")].context.namespace}": Error executing template: <nil> is not array or slice and cannot be filtered. Printing more information for debugging the template:
template was:
{.contexts[?(#.name=="")].context.namespace}
object given to jsonpath engine was:
map[string]interface {}{"apiVersion":"v1", "clusters":interface {}(nil), "contexts":interface {}(nil), "current-context":"", "kind":"Config", "preferences":map[string]interface {}{}, "users":interface {}(nil)}
I also had this issue. It started after I upgraded my kubectl to a newer version.
In my case In my zsh I have a custom prompt using POWERLEVEL_9K plugin which displays the current k8s cluster/namespace.
This prompt config in my ~/.zshrc looks like
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator command_execution_time kubecontext background_jobs history time)
Remove kubecontext from there and here you go.
If you'd like to remain k8s info in your prompt, the template in the theme needs to be fixed. I was using POWERLEVEL9K and switching to POWERLEVEL10K did a trick for me.

Use Mypy with Ruamel.yaml

I am attempting to use MyPy with modules that use ruamel.yaml and Mypy cannot find ruamel.yaml even though Python has no problem finding it. I am puzzled because I can't find a module called YAML.py or class called YAML either, even though these statements work in Python:
from ruamel.yaml import YAML
yaml = YAML()
x = yaml.load()
What do I need to do to get MyPy to recognize ruamel.yaml?
A workaround is to run without the incremental logic of mypy:
python -m mypy --no-incremental myfile.py
Background
There is a known issue in mypy, see here.
In summary:
Something is not working with the incremental logic of mypy when it is encountering ruamel.
When you run it once, all goes ok. This is the command:
python -m mypy myfile.py
Then, when you run it again, you get an error:
error: Skipping analyzing 'ruamel': found module but no type hints or library stubs [import]
Then, when you run it again, it all goes ok
etc.
You should not be looking for a file YAML.py. The YAML in
yaml = YAML()
is a class that is defined in ruamel/yaml/main.py and that gets imported into ruamel/yaml/__init__.py (both under site-packages). That is why you do:
from ruamel.yaml import YAML
(the alternative would be that there is a file yaml.py under the directory ruamel, but the loader/dumper is a bit too much to put in one file).
What might work if the above knowledge doesn't help you resolve things, is explicitly set the global flag mypy_path or the environment variable MYPYPATH. This has to include the directory in which the directory ruamel is located.
( I could not find it mentioned in the documentation, but from the source ( mypy/build.py:mypy_path() ) you can see that this is supposed to be a string that gets split on os.pathsep (which is the colon (:) on my Linux based system))
I have the same issue.
Even after setting MYPYPATH=./.venv/lib/python3.7/site-packages
A temporary 'solution' is ignoring the missing import exception
mypy --ignore-missing-imports

XQuery process:execute how to execute external programm?

I am running exist-db on windows and would like to execute an external windows program.
This works inside the normal windows shell:
C:\path\to\webGLRtiMaker.exe C:\path\to\ImageFile.rti -q 90
And I would like to execute the same program from my xquery script (I have uploaded all the needed files according to my specified paths to my exist-db):
xquery version '3.1';
import module namespace process="http://exist-db.org/xquery/process" at "java:org.exist.xquery.modules.process.ProcessModule";
declare variable $options := '<options>
<workingDir>/db/apps/test-project/images</workingDir>
<stdin><line>/db/apps/execute-test/images/image1.rti -q 90</line></stdin>
</options>';
(:process:execute($webRtiMaker, <options/>):)
process:execute('/db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe', $options)
Even if I only execute the program without parameters (if I execute it inside windows I get the parameters as overview inside the command prompt so I should also receive some kind of output):
process:execute('/db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe', <options/>)
But I get the error:
exerr:ERROR An IO error occurred while executing the process /db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe: Cannot run program "/db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe": CreateProcess error=2, The System cannot find the file ...
I used this as reference: Execute External Process
What am I doing wrong?
I have not tried this recently, but try the following:
import module namespace process="http://exist-db.org/xquery/process" at "java:org.exist.xquery.modules.process.ProcessModule";
let $cmd := 'C:\path\to\webGLRtiMaker.exe C:\path\to\ImageFile.rti -q 90'
return
<results>{process:execute($cmd, <options/>)}</results>
There is an article at the XQuery WikiBook about it.
Unfortunately it is not possible to start an executable that is stored inside the database. The java API requires direct access to a file on the filesystem, and the '/db/....' path is not.

GOBJECT_INTROSPECTION_CHECK syntax error on configure

On "./configure" of an open source project I get:
user agent OS = Linux
./configure: line 13957: syntax error near unexpected token 0.9.3'
./configure: line 13957: GOBJECT_INTROSPECTION_CHECK(0.9.3)'
make: *** [config.status] Error 2
Ubuntu 12.04 package "gobject-introspection" and "libgirepository1.0-dev" are present. Removing the GOBJECT_INTROSPECTION_CHECK line allows configure to complete, but the project fails a dependency later.
How can I get past this configure step cleanly? Googling for this issue shows bugs filed against numerous OS projects for this same blocking issue, but the usual answer is "install gobject-introspection".
As the OP discovered on his own he had to install the gobject-introspection package to get the m4 macros that were being used.
The error message has the raw macro in it, as configure scripts are generated from configure.in/configure.ac files via m4/etc the fact that the raw macro is in the output file indicates that the macro did not get translated at generation time.
The gobject-introspection m4 files were apparently installed after autogen.sh (or equivalent) was run to generate the configure script. Re-running the autogen.sh script should regenerate the configure script and run the macro correctly.

Resources