Example #1
0
def create(mac=None, template=None, run_id=None):
    '''
    Create a config for a specific MAC from a template
    run_id is optional

    CLI Examples::

        salt '*' tftp.create template='test.template' mac='11:22:33:44:55:66'
        salt '*' tftp.create template='test.template' mac='11:22:33:44:55:66'\\
        run_id=2590
    '''
    if mac is None or template is None:
        return "mac and template must be specified"
    conf = _spoke_config(_salt_config('config'))
    tftproot = conf.get("TFTP", "tftp_root")
    tftp = SpokeTFTP(tftproot)
    if run_id is None:
        try:
            result = tftp.create(mac, template)
        except error.SpokeError as e:
            result = common.handle_error(e)
    else:
        try:
            result = tftp.create(mac, template, run_id)
        except error.SpokeError as e:
            result = common.handle_error(e)
    return result
Example #2
0
File: dhcp.py Project: mattmb/spoke
def subnet_create(dhcp_server, subnet, mask, start_ip=None, stop_ip=None):
    try:
        from spoke.lib.dhcp import SpokeDHCPSubnet
        subnet= SpokeDHCPSubnet(dhcp_server)
        result = subnet.create(subnet, mask, start_ip, stop_ip)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #3
0
def delete(network, mask):
    try:
        from spoke.lib.ip import SpokeSubnet
        subnet = SpokeSubnet(ip=network, mask=mask, dc=None)
        result = subnet.delete()
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #4
0
File: dhcp.py Project: mattmb/spoke
def subnet_search(dhcp_server, subnet):
    try:
        from spoke.lib.dhcp import SpokeDHCPSubnet
        subnet = SpokeDHCPSubnet(dhcp_server)
        result = subnet.get(subnet)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #5
0
def host_delete(org_name, host_name):
    try:
        conf = _spoke_config(_salt_config('config'))
        host = SpokeHost(org_name)
        result = host.delete(host_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #6
0
File: host.py Project: mattmb/spoke
def uuid_create(start_uuid=None, get_mac=False):
    try:       
        from spoke.lib.host import SpokeHostUUID
        uuid = SpokeHostUUID()
        result = uuid.create(start_uuid, get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #7
0
File: host.py Project: mattmb/spoke
def uuid_delete():
    try:
        from spoke.lib.host import SpokeHostUUID
        uuid = SpokeHostUUID()
        result = uuid.delete()
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #8
0
File: host.py Project: mattmb/spoke
def host_delete(org_name, host_name):
    from spoke.lib.host import SpokeHost
    try:
        host = SpokeHost(org_name)
        result = host.delete(host_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #9
0
File: vm.py Project: mattmb/spoke
def power_modify(vm_name, state):
    from spoke.lib.vm_power import SpokeVMPowerXen
    vmp = SpokeVMPowerXen(hv_uri, vm_name)
    try:
        result = vmp.modify(state)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result    
Example #10
0
File: vm.py Project: mattmb/spoke
def power_search(vm_name):
    from spoke.lib.vm_power import SpokeVMPowerXen
    vmp = SpokeVMPowerXen(hv_uri, vm_name)
    try:
        result = vmp.get()
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result    
Example #11
0
File: host.py Project: mattmb/spoke
def uuid_reserve(qty=1, get_mac=False):
    try:
        from spoke.lib.host import SpokeHostUUID
        uuid = SpokeHostUUID()
        result = uuid.modify(qty, get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #12
0
def uuid_create(start_uuid=None, get_mac=False):
    try:
        conf = _spoke_config(_salt_config('config'))
        uuid = SpokeHostUUID()
        result = uuid.create(start_uuid, get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #13
0
def uuid_delete():
    try:
        conf = _spoke_config(_salt_config('config'))
        uuid = SpokeHostUUID()
        result = uuid.delete()
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #14
0
File: dhcp.py Project: mattmb/spoke
def reservation_delete(dhcp_server, dhcp_group, host_name):
    try:
        from spoke.lib.dhcp import SpokeDHCPHost
        host = SpokeDHCPHost(dhcp_server, dhcp_group)
        result = host.delete(host_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #15
0
File: dhcp.py Project: mattmb/spoke
def group_search(dhcp_server, dhcp_group):
    try:
        from spoke.lib.dhcp import SpokeDHCPGroup
        group = SpokeDHCPGroup(dhcp_server)
        result = group.get(dhcp_group)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #16
0
def host_delete(org_name, host_name):
    try:
        conf = _spoke_config(_salt_config('config'))
        host = SpokeHost(org_name)
        result = host.delete(host_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #17
0
def uuid_reserve(qty=1, get_mac=False):
    try:
        conf = _spoke_config(_salt_config('config'))
        uuid = SpokeHostUUID()
        result = uuid.modify(qty, get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #18
0
def uuid_create(start_uuid=None, get_mac=False):
    try:
        conf = _spoke_config(_salt_config('config'))
        uuid = SpokeHostUUID()
        result = uuid.create(start_uuid, get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #19
0
def uuid_delete():
    try:
        conf = _spoke_config(_salt_config('config'))
        uuid = SpokeHostUUID()
        result = uuid.delete()
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #20
0
def delete(network, mask):
    try:
        conf = _spoke_config(_salt_config('config'))
        subnet = SpokeSubnet(ip=network, mask=mask, dc=None)
        result = subnet.delete()
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #21
0
File: dhcp.py Project: mattmb/spoke
def server_search(server):
    try:
        from spoke.lib.dhcp import SpokeDHCPServer
        server = SpokeDHCPServer()
        result = server.get(server)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #22
0
File: dhcp.py Project: mattmb/spoke
def attr_search(dhcp_server, dhcp_group, dhcp_host, attr_type):
    try:
        from spoke.lib.dhcp import SpokeDHCPAttr
        attr = SpokeDHCPAttr(dhcp_server, dhcp_group, dhcp_host)
        result = attr.get(attr_type)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #23
0
File: vm.py Project: mattmb/spoke
def store_delete(vm_name):
    from spoke.lib.vm_storage import SpokeVMStorageXen
    vms = SpokeVMStorageXen(hv_uri)
    try:
        result = vms.delete(vm_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #24
0
File: dhcp.py Project: mattmb/spoke
def host_search(dhcp_server, dhcp_group, dhcp_host):
    try:
        from spoke.lib.dhcp import SpokeDHCPHost
        host = SpokeDHCPHost(dhcp_server, dhcp_group)
        result = host.get(dhcp_host)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #25
0
def uuid_reserve(qty=1, get_mac=False):
    try:
        conf = _spoke_config(_salt_config('config'))
        uuid = SpokeHostUUID()
        result = uuid.modify(qty, get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #26
0
def release(network, mask, ip):
    try:
        from spoke.lib.ip import SpokeSubnet
        subnet = SpokeSubnet(ip=network, mask=mask, dc=None)
        result = subnet.modify(release=ip, reserve=None)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #27
0
File: lvm.py Project: mattmb/spoke
def create(vg_name, lv_name, lv_size):
    from spoke.lib.lvm import SpokeLVM
    lv = SpokeLVM(vg_name)
    try:
        result = lv.create(lv_name, lv_size)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #28
0
def release(network, mask, ip):
    try:
        conf = _spoke_config(_salt_config('config'))
        subnet = SpokeSubnet(ip=network, mask=mask, dc=None)
        result = subnet.modify(release=ip, reserve=None)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #29
0
File: dhcp.py Project: mattmb/spoke
def service_delete(service):
    try:
        from spoke.lib.dhcp import SpokeDHCPService
        service = SpokeDHCPService()
        result = service.delete(service)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #30
0
File: lvm.py Project: mattmb/spoke
def search(vg_name, lv_name=None):
    from spoke.lib.lvm import SpokeLVM
    lv = SpokeLVM(vg_name)
    try:
        result = lv.get(lv_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #31
0
def service_delete(service):
    try:
        from spoke.lib.dhcp import SpokeDHCPService
        service = SpokeDHCPService()
        result = service.delete(service)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #32
0
def subnet_create(dhcp_server, subnet, mask, start_ip=None, stop_ip=None):
    try:
        from spoke.lib.dhcp import SpokeDHCPSubnet
        subnet = SpokeDHCPSubnet(dhcp_server)
        result = subnet.create(subnet, mask, start_ip, stop_ip)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #33
0
def reservation_delete(dhcp_server, dhcp_group, host_name):
    try:
        from spoke.lib.dhcp import SpokeDHCPHost
        host = SpokeDHCPHost(dhcp_server, dhcp_group)
        result = host.delete(host_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #34
0
def server_search(server):
    try:
        from spoke.lib.dhcp import SpokeDHCPServer
        server = SpokeDHCPServer()
        result = server.get(server)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #35
0
def host_search(dhcp_server, dhcp_group, dhcp_host):
    try:
        from spoke.lib.dhcp import SpokeDHCPHost
        host = SpokeDHCPHost(dhcp_server, dhcp_group)
        result = host.get(dhcp_host)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #36
0
def attr_search(dhcp_server, dhcp_group, dhcp_host, attr_type):
    try:
        from spoke.lib.dhcp import SpokeDHCPAttr
        attr = SpokeDHCPAttr(dhcp_server, dhcp_group, dhcp_host)
        result = attr.get(attr_type)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #37
0
def group_search(dhcp_server, dhcp_group):
    try:
        from spoke.lib.dhcp import SpokeDHCPGroup
        group = SpokeDHCPGroup(dhcp_server)
        result = group.get(dhcp_group)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #38
0
def subnet_search(dhcp_server, subnet):
    try:
        from spoke.lib.dhcp import SpokeDHCPSubnet
        subnet = SpokeDHCPSubnet(dhcp_server)
        result = subnet.get(subnet)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #39
0
File: lvm.py Project: mattmb/spoke
def search(vg_name, lv_name=None):
    from spoke.lib.lvm import SpokeLVM
    lv = SpokeLVM(vg_name)
    try:
        result = lv.get(lv_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #40
0
File: lvm.py Project: mattmb/spoke
def create(vg_name, lv_name, lv_size):
    from spoke.lib.lvm import SpokeLVM
    lv = SpokeLVM(vg_name)
    try:
        result = lv.create(lv_name, lv_size)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #41
0
File: host.py Project: mattmb/spoke
def uuid_reserve(qty=1, get_mac=False):
    try:
        from spoke.lib.host import SpokeHostUUID

        uuid = SpokeHostUUID()
        result = uuid.modify(qty, get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #42
0
File: host.py Project: mattmb/spoke
def uuid_create(start_uuid=None, get_mac=False):
    try:
        from spoke.lib.host import SpokeHostUUID

        uuid = SpokeHostUUID()
        result = uuid.create(start_uuid, get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #43
0
def uuid_search(get_mac=False):
    try:
        conf = _spoke_config(_salt_config('config'))
        uuid = SpokeHostUUID()
        print 'My Get_mac is {0}'.format(get_mac)
        result = uuid.get(get_mac=get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #44
0
File: host.py Project: mattmb/spoke
def host_delete(org_name, host_name):
    from spoke.lib.host import SpokeHost

    try:
        host = SpokeHost(org_name)
        result = host.delete(host_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #45
0
File: host.py Project: mattmb/spoke
def uuid_delete():
    try:
        from spoke.lib.host import SpokeHostUUID

        uuid = SpokeHostUUID()
        result = uuid.delete()
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #46
0
def power_modify(vm_name, state):
    try:
        conf = _spoke_config(_salt_config('config'))
        hv_uri = conf.get('VM', 'hv_uri')
        vmp = SpokeVMPowerXen(hv_uri, vm_name)
        result = vmp.modify(state)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #47
0
def store_delete(vm_name):
    try:
        conf = _spoke_config(_salt_config('config'))
        hv_uri = conf.get('VM', 'hv_uri')
        vms = SpokeVMStorageXen(hv_uri)
        result = vms.delete(vm_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #48
0
def uuid_search(get_mac=False):
    try:
        conf = _spoke_config(_salt_config('config'))
        uuid = SpokeHostUUID()
        print 'My Get_mac is {0}'.format(get_mac)
        result = uuid.get(get_mac=get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Example #49
0
def power_delete(vm_name, force=False):
    try:
        conf = _spoke_config(_salt_config('config'))
        hv_uri = conf.get('VM', 'hv_uri')
        vmp = SpokeVMPowerXen(hv_uri, vm_name)
        result = vmp.delete(force=force)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result