コード例 #1
0
ファイル: mc_vm.py プロジェクト: mattmb/spoke
# TODO Implement access to vm power via vm host modify (e.g. vm.modify(vm_name, power=on).
from spoke.lib.vm_storage import SpokeVMStorageXen

config_file = '/usr/local/pkg/spoke/etc/spoke.conf'
config = config.setup(config_file)
    
if __name__ == '__main__':
    log = logger.setup('main', verbose=False, quiet=True)
    mc = mc.MCollectiveAction()
    request = mc.request()
    try:
        hv_uri = config.get('VM', 'hv_uri')
        mc.info('Connecting to hypervisor URI %s' % hv_uri)
        vm = SpokeVMStorageXen(hv_uri)
    except error.SpokeError, e:
        mc.fail(e.msg, e.exit_code)
            
    if request['action'] == 'create':
        vm_name             = request['data']['hostname']
        vm_uuid             = request['data']['uuid']
        vm_mem              = request['data']['mem']
        vm_cpu              = request['data']['cpu']
        vm_family           = request['data']['family']
        vm_storage_layout   = request['data']['storage_layout']
        vm_network_layout   = request['data']['network_layout']
        try:
            vm_install = request['data']['install']
        except KeyError:
            vm_install = None
        try:
            mc.data = vm.create(vm_name, vm_uuid, vm_mem, vm_cpu, vm_family,
コード例 #2
0
ファイル: mc_dhcp.py プロジェクト: KrisSaxton/spoke
import spoke.lib.mc_helper as mc
from spoke.lib.dhcp import SpokeDHCPHost, SpokeDHCPAttr
        
config_file = '/usr/local/pkg/spoke/etc/spoke.conf'
config = config.setup(config_file)
    
if __name__ == '__main__':
    log = logger.setup('main', verbose=False, quiet=True)
    mc = mc.MCollectiveAction()
    request = mc.request()
    try:
        server = config.get('DHCP', 'dhcp_def_server')
        group   = config.get('DHCP', 'dhcp_def_group')
        host = SpokeDHCPHost(server, group)
    except Exception as e:
        mc.fail(e)

    if request['action'] != 'search':
        try:
            hostname = request['data']['hostname']
        except KeyError:
            mc.fail("Missing input hostname", 2)
            
    if request['action'] == 'create':
        try:
            mac = request['data']['mac']
            ip = request['data']['ip']
            try:
                mc.info('Creating host %s' % hostname)
                host.create(hostname)
            except error.AlreadyExists:
コード例 #3
0
import spoke.lib.mc_helper as mc
from spoke.lib.dhcp import SpokeDHCPHost, SpokeDHCPAttr

config_file = '/usr/local/pkg/spoke/etc/spoke.conf'
config = config.setup(config_file)

if __name__ == '__main__':
    log = logger.setup('main', verbose=False, quiet=True)
    mc = mc.MCollectiveAction()
    request = mc.request()
    try:
        server = config.get('DHCP', 'dhcp_def_server')
        group = config.get('DHCP', 'dhcp_def_group')
        host = SpokeDHCPHost(server, group)
    except Exception as e:
        mc.fail(e)

    if request['action'] != 'search':
        try:
            hostname = request['data']['hostname']
        except KeyError:
            mc.fail("Missing input hostname", 2)

    if request['action'] == 'create':
        try:
            mac = request['data']['mac']
            ip = request['data']['ip']
            try:
                mc.info('Creating host %s' % hostname)
                host.create(hostname)
            except error.AlreadyExists:
コード例 #4
0
ファイル: mc_lvm.py プロジェクト: mattmb/spoke
import spoke.lib.config as config
import spoke.lib.logger as logger
import spoke.lib.mc_helper as mc
from spoke.lib.lvm import SpokeLVM

config_file = '/usr/local/pkg/spoke/etc/spoke.conf'
config = config.setup(config_file)
    
if __name__ == '__main__':
    mc = mc.MCollectiveAction()
    log = logger.setup('main', verbose=False, quiet=True)
    request = mc.request()
    try:
        vg_name = config.get('LVM', 'lv_def_vg_name')
    except error.SpokeError:
        mc.fail("Failed to retrieve lv_def_vg_name value from config", 2)

    if request['action'] == 'create':
        lv_name = request['data']['lv_name']
        lv_size = request['data']['lv_size']
        try:
            mc.data = SpokeLVM(vg_name).create(lv_name, lv_size)
        except error.SpokeError as e:
            mc.fail(e.msg, e.exit_code)
    elif request['action'] == 'search':
        try:
            lv_name = request['data']['lv_name']
        except KeyError:
            lv_name = None
        try:
            mc.data = SpokeLVM(vg_name).get(lv_name)