コード例 #1
0
CONFIG = ConfigParser()
CONFIG.read(INI_CONF)

# DB parameters
URL = CONFIG.get('api', 'ipaddress')
USERAPI = CONFIG.get('api', 'user')
PASSWORD = CONFIG.get('api', 'passwd')
NODE = CONFIG.get('api', 'node')

disable_warnings(InsecureRequestWarning)

INIT_AUTHENT = ProxAuth(URL, USERAPI, PASSWORD)

PROXMOX_EXEC = PyProxmox(INIT_AUTHENT)

NEXT_ID = PROXMOX_EXEC.get_cluster_vm_next_id()
NEXT_ID = json.loads(NEXT_ID)
NEXT_ID = NEXT_ID["data"]

STORAGE = 'Stockage1'
FILENAME = "vm-{}-disk-0.qcow2".format(NEXT_ID)
SIZE = '32G'

POST_DATA = {
    'vmid': NEXT_ID,
    'cores': '2',
    'sockets': 1,
    'description': 'test kvm',
    'name': 'test.example.org',
    'memory': '2048',
    'virtio0': '{}:{}/{},size={}'.format(STORAGE, NEXT_ID, FILENAME, SIZE),
コード例 #2
0
ファイル: clone_vm.py プロジェクト: gizmo15/pyproxmox3
    sys.exit(1)

CONFIG = ConfigParser()
CONFIG.read(INI_CONF)

# DB parameters
URL = CONFIG.get('api', 'ipaddress')
USERAPI = CONFIG.get('api', 'user')
PASSWORD = CONFIG.get('api', 'passwd')
NODE = CONFIG.get('api', 'node')

disable_warnings(InsecureRequestWarning)

INIT_AUTHENT = ProxAuth(URL, USERAPI, PASSWORD)

PROXMOX_EXEC = PyProxmox(INIT_AUTHENT)

STATUS_NEXTID = PROXMOX_EXEC.get_cluster_vm_next_id()
RESULT_STATUS_NEXTID = json.loads(STATUS_NEXTID)
NEXTID = RESULT_STATUS_NEXTID["data"]

VMID = '102'
POST_DATA = {'newid': NEXTID, 'node': NODE, 'vmid': VMID}

print("New VMID : {}".format(NEXTID))
STATUS = PROXMOX_EXEC.clone_virtual_machine(NODE, VMID, POST_DATA)
print(STATUS)
RESULT_STATUS = json.loads(STATUS)
print(RESULT_STATUS["data"])
print(RESULT_STATUS["status"]["code"])
コード例 #3
0
ファイル: get_next_id.py プロジェクト: gizmo15/pyproxmox3
from urllib3.exceptions import InsecureRequestWarning
from proxmox import ProxAuth, PyProxmox

# Read conf.ini
INI_CONF = "./proxmox_api.ini"

if not pathlib.Path(INI_CONF).exists():
    print("Config file not found!")
    print("Need the config file in {}".format(INI_CONF))
    sys.exit(1)

CONFIG = ConfigParser()
CONFIG.read(INI_CONF)

# DB parameters
URL = CONFIG.get('api', 'ipaddress')
USERAPI = CONFIG.get('api', 'user')
PASSWORD = CONFIG.get('api', 'passwd')
NODE = CONFIG.get('api', 'node')

disable_warnings(InsecureRequestWarning)

INIT_AUTHENT = ProxAuth(URL, USERAPI, PASSWORD)

PROXMOX_EXEC = PyProxmox(INIT_AUTHENT)

STATUS = PROXMOX_EXEC.get_cluster_vm_next_id()
RESULT_STATUS = json.loads(STATUS)
print(RESULT_STATUS["data"])
print(RESULT_STATUS["status"]["code"])