Compare commits
1 commit
master
...
develop/4.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
88aa066c30 |
11 changed files with 41 additions and 32 deletions
5
.rsyncignore
Normal file
5
.rsyncignore
Normal file
|
@ -0,0 +1,5 @@
|
|||
.venv
|
||||
.git
|
||||
__pycache__/
|
||||
*.egg-info/
|
||||
venv
|
4
Makefile
Normal file
4
Makefile
Normal file
|
@ -0,0 +1,4 @@
|
|||
DEST:=/opt/nativecloud-agent
|
||||
|
||||
sync:
|
||||
rsync -rvz --exclude-from .rsyncignore --delete ./ root@192.168.11.11:/opt/nativecloud-agent/
|
|
@ -4,6 +4,14 @@ Version: 1.0
|
|||
|
||||
## Install
|
||||
|
||||
### rockylinux 9
|
||||
|
||||
```shell
|
||||
dnf install -y python3-netaddr python3-libvirt python3-requests
|
||||
```
|
||||
|
||||
### ubuntu (old)
|
||||
|
||||
```
|
||||
$ apt-get install sqlite3
|
||||
$ apt-get install lxc
|
||||
|
@ -14,7 +22,6 @@ $ pip install pyparsing
|
|||
$ apt-get install dnsmasq
|
||||
```
|
||||
|
||||
|
||||
## Setting DNSMASQ
|
||||
|
||||
Uncomment string in file `/etc/dnsmasq.conf`:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# coding: utf-8
|
||||
|
||||
from SWSCloudNode.settings import settings
|
||||
from SWSCloudNode.compute.lxc import LXC
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import time
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
|
@ -30,7 +29,7 @@ class Common:
|
|||
"""
|
||||
if code == 1:
|
||||
message = "Invalid JSON-RPC. Unknown RPC version"
|
||||
print self.time() + " - " + message
|
||||
print(time.time() + " - " + message)
|
||||
return {"error": {"code": code, "message": message}}
|
||||
|
||||
def settings_node(self):
|
||||
|
@ -41,7 +40,7 @@ class Common:
|
|||
with open('/etc/gocloud/node/node.json') as nodesettings_file:
|
||||
conf = json.load(nodesettings_file)
|
||||
else:
|
||||
print "[Errno 2] No such file or directory: '/etc/gocloud/node/node.json'"
|
||||
print("[Errno 2] No such file or directory: '/etc/gocloud/node/node.json'")
|
||||
sys.exit(2)
|
||||
|
||||
return conf
|
||||
|
@ -54,7 +53,7 @@ class Common:
|
|||
with open('/etc/gocloud/node/vmsettings.json') as vmsettings_file:
|
||||
conf = json.load(vmsettings_file)
|
||||
else:
|
||||
print "[Errno 2] No such file or directory: '/etc/gocloud/node/vmsettings.json'"
|
||||
print("[Errno 2] No such file or directory: '/etc/gocloud/node/vmsettings.json'")
|
||||
sys.exit(2)
|
||||
|
||||
return conf
|
||||
|
|
|
@ -248,12 +248,12 @@ class LXC(object):
|
|||
if template_options:
|
||||
command.append(' -- %s' % template_options)
|
||||
|
||||
print " ".join(command)
|
||||
print(" ".join(command))
|
||||
print
|
||||
# create = subprocess.check_call(command, shell=True)
|
||||
create = subprocess.check_call(" ".join(command), shell=True)
|
||||
print
|
||||
print create
|
||||
print(create)
|
||||
print
|
||||
|
||||
# if create == 0:
|
||||
|
|
|
@ -83,7 +83,7 @@ class Qemu:
|
|||
try:
|
||||
action.create()
|
||||
except:
|
||||
print conn.virConnGetLastError()
|
||||
print(conn.virConnGetLastError())
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -99,7 +99,7 @@ class Qemu:
|
|||
try:
|
||||
action.destroy()
|
||||
except:
|
||||
print conn.virConnGetLastError()
|
||||
print(conn.virConnGetLastError())
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
import sys
|
||||
import os
|
||||
import ConfigParser
|
||||
from configparser import ConfigParser
|
||||
from .logger import logging
|
||||
|
||||
default_file = '/etc/sws/cloud/node.ini'
|
||||
default_file = '/etc/nativecloud/agent.ini'
|
||||
|
||||
settings_file = os.getenv('CLOUD_SETTINGS_FILE', default_file)
|
||||
settings_file = os.getenv('CONFIG', default_file)
|
||||
|
||||
# setting file read
|
||||
settings = ConfigParser.ConfigParser()
|
||||
settings = ConfigParser()
|
||||
if os.path.exists(settings_file):
|
||||
settings.read(settings_file)
|
||||
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
import os
|
||||
import subprocess
|
||||
import commands
|
||||
# import commands
|
||||
import requests
|
||||
from SWSCloudNode.logger import logging
|
||||
from SWSCloudNode.settings import settings
|
||||
from SWSCloudNode.logger import logging
|
||||
|
||||
|
||||
ALLOWED_TASKS = [
|
||||
|
@ -34,9 +33,12 @@ class Tasks:
|
|||
logging.error('no connection with %s' % self.endpoint)
|
||||
return None
|
||||
else:
|
||||
if response.status_code == 204:
|
||||
logging.info(f"Status code: {response.status_code}, {response.text}")
|
||||
return None
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
logging.error("Unexpected status code: %d" % response.status_code)
|
||||
logging.error(f"Unexpected status code: {response.status_code}, {response.text}")
|
||||
return None
|
||||
|
||||
def interface2ip(self):
|
||||
|
@ -66,8 +68,8 @@ class Tasks:
|
|||
|
||||
def container_start(self, task):
|
||||
logging.debug("container_start")
|
||||
print "================ "
|
||||
print task
|
||||
print("================ ")
|
||||
print(task)
|
||||
lxc.lxc().start(task['parameters']['hostname'])
|
||||
# TODO: check status
|
||||
return True
|
||||
|
@ -189,7 +191,7 @@ class Tasks:
|
|||
# todo: held job if status not 0
|
||||
|
||||
print
|
||||
print task
|
||||
print(task)
|
||||
|
||||
nginx.Nginx().vhost_delete(task['parameters']['container_ip'], task['parameters']['vhost_id'])
|
||||
nginx.Service().reload()
|
||||
|
@ -236,8 +238,8 @@ class Tasks:
|
|||
|
||||
else:
|
||||
if task['status'] == 4:
|
||||
print "auth fail"
|
||||
print("auth fail")
|
||||
else:
|
||||
print "structure version not supported"
|
||||
print("structure version not supported")
|
||||
|
||||
return None
|
||||
|
|
5
setup.py
5
setup.py
|
@ -1,10 +1,9 @@
|
|||
# coding: utf-8
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='SWSCloudNode',
|
||||
version='3.3.2',
|
||||
version='4.0.1',
|
||||
author='Vyacheslav Anzhiganov',
|
||||
author_email='vanzhiganov@ya.ru',
|
||||
packages=[
|
||||
|
@ -19,7 +18,7 @@ setup(
|
|||
],
|
||||
install_requires=[
|
||||
'requests',
|
||||
'netaddr==0.7.18',
|
||||
'netaddr>=0.7.18',
|
||||
'libvirt-python>=1.3.1',
|
||||
],
|
||||
)
|
||||
|
|
6
test.py
6
test.py
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
from SWSCloudNode.qemu import QEMU
|
||||
|
||||
print QEMU().list()
|
Loading…
Add table
Reference in a new issue