Commit d0dd1fa5 by Szeberényi Imre

Linux fix+refactor

parent 8428689a
...@@ -6,7 +6,6 @@ import logging ...@@ -6,7 +6,6 @@ import logging
import platform import platform
import subprocess import subprocess
import sys import sys
from utils import copy_file
logging.basicConfig( logging.basicConfig(
format="[%(asctime)s] %(levelname)s [agent %(process)d/%(thread)d] %(module)s.%(funcName)s:%(lineno)d] %(message)s", format="[%(asctime)s] %(levelname)s [agent %(process)d/%(thread)d] %(module)s.%(funcName)s:%(lineno)d] %(message)s",
...@@ -24,6 +23,7 @@ if system == "Linux" or system == "FreeBSD": # noqa ...@@ -24,6 +23,7 @@ if system == "Linux" or system == "FreeBSD": # noqa
try: # noqa try: # noqa
chdir(sys.path[0]) # noqa chdir(sys.path[0]) # noqa
subprocess.call(('pip', 'install', '-r', 'requirements/linux.txt')) # noqa subprocess.call(('pip', 'install', '-r', 'requirements/linux.txt')) # noqa
from utils import copy_file
copy_file("misc/vm_renewal", "/usr/bin/vm_renewal", mode=0o755) copy_file("misc/vm_renewal", "/usr/bin/vm_renewal", mode=0o755)
if copy_file("misc/agent.service", "/etc/systemd/system/agent.service"): if copy_file("misc/agent.service", "/etc/systemd/system/agent.service"):
subprocess.call(('systemctl', 'enable', 'agent')) subprocess.call(('systemctl', 'enable', 'agent'))
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
""" """
import logging import logging
import platform import platform
import re
logger = logging.getLogger() logger = logging.getLogger()
...@@ -15,7 +16,7 @@ def _get_virtio_device(): ...@@ -15,7 +16,7 @@ def _get_virtio_device():
# Search Virtio-Serial by name TODO: search by class_guid # Search Virtio-Serial by name TODO: search by class_guid
for i in dm.all_devices: for i in dm.all_devices:
if i.has_property("description"): if i.has_property("description"):
if "virtio-serial".upper() in i.description.upper(): if re.search("virtio.*serial", i.description, re.IGNORECASE):
path = ("\\\\?\\" + path = ("\\\\?\\" +
i.children[0].instance_id.lower().replace('\\', '#') + i.children[0].instance_id.lower().replace('\\', '#') +
"#" + GUID.lower() "#" + GUID.lower()
...@@ -24,7 +25,6 @@ def _get_virtio_device(): ...@@ -24,7 +25,6 @@ def _get_virtio_device():
logger.debug("DEV found: %s", path) logger.debug("DEV found: %s", path)
return path return path
def get_context(): def get_context():
system = platform.system() system = platform.system()
if system == "Windows": if system == "Windows":
......
#!/bin/bash #!/bin/bash
sudo bash -c "source /root/.virtualenvs/agent/bin/activate; source /root/.virtualenvs/agent/bin/postactivate; /root/agent/vm_renewal" sudo bash -c "cd /root/agent; . /root/.virtualenvs/agent/bin/activate; . /root/.virtualenvs/agent/bin/postactivate; python vm_renewal.py"
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment