예제 #1
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_get_missing_host(self):
     """Retrieve a missing host account; return empty list."""
     host_name = 'missinghost'
     host = SpokeHost(self.org_name)
     result = host.get(host_name)
     expected_data = []
     self.assertEquals(result['data'], expected_data)
예제 #2
0
파일: host.py 프로젝트: 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
예제 #3
0
파일: host.py 프로젝트: KrisSaxton/spoke
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
예제 #4
0
파일: test_host.py 프로젝트: mattmb/spoke
 def tearDown(self):
     """Delete test organisation and host"""
     host = SpokeHost(self.org_name)
     host.delete(self.host_name)
     org = SpokeOrg()
     org.delete(self.org_name, self.org_children)
     next_uuid = SpokeHostUUID()
     next_uuid.delete()
예제 #5
0
파일: host.py 프로젝트: KrisSaxton/spoke
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
예제 #6
0
파일: host.py 프로젝트: 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
예제 #7
0
 def test_delete_host(self):
     """Delete host; return an empty search result."""
     host = SpokeHost(self.org_name)
     host_name = 'testhostdelete'
     host.create(host_name, self.host_uuid, self.host_mem, self.host_cpu,
                 self.host_family, self.host_type, self.host_storage_layout,
                 self.host_network_layout, self.host_extra_opts)
     expected_data = []
     result = host.delete(host_name)
     self.assertEquals(result['data'], expected_data)
예제 #8
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_delete_host(self):
     """Delete host; return an empty search result."""
     host = SpokeHost(self.org_name)
     host_name = 'testhostdelete'
     host.create(host_name, self.host_uuid, self.host_mem, self.host_cpu,  
                       self.host_family, self.host_type, 
                       self.host_storage_layout, self.host_network_layout,  
                       self.host_extra_opts)
     expected_data = []
     result = host.delete(host_name)
     self.assertEquals(result['data'], expected_data)
예제 #9
0
파일: host.py 프로젝트: KrisSaxton/spoke
def host_search(org_name, host_name=None):
    try:
        conf = _spoke_config(_salt_config('config'))
        host = SpokeHost(org_name)
        if host_name is None:
            result = host.get()
        else:
            result = host.get(host_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
예제 #10
0
파일: host.py 프로젝트: mattmb/spoke
def host_search(org_name, host_name=None):
    from spoke.lib.host import SpokeHost
    try:
        host = SpokeHost(org_name)
        if host_name is None:
            result = host.get()
        else:
            result = host.get(host_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
예제 #11
0
파일: test_host.py 프로젝트: mattmb/spoke
 def setUp(self):
     """Create test organisation and host."""
     org = SpokeOrg()
     org.create(self.org_name, self.org_children)
     next_uuid = SpokeHostUUID()
     next_uuid.create(self.next_uuid_start)
     host = SpokeHost(self.org_name)
     host.create(self.host_name, self.host_uuid, self.host_mem, 
                 self.host_cpu,  self.host_family, self.host_type,
                 self.host_storage_layout,self.host_network_layout,  
                 self.host_extra_opts)
예제 #12
0
파일: host.py 프로젝트: KrisSaxton/spoke
def host_search(org_name, host_name=None):
    try:
        conf = _spoke_config(_salt_config('config'))
        host = SpokeHost(org_name)
        if host_name is None:
            result = host.get()
        else:
            result = host.get(host_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
예제 #13
0
파일: host.py 프로젝트: mattmb/spoke
def host_create(org_name, host_name, host_uuid, host_mem, host_cpu, 
                                 host_family, host_type, 
                                 host_storage_layout, host_network_layout):
    from spoke.lib.host import SpokeHost
    try:
        host = SpokeHost(org_name)
        result = host.create(host_name, host_uuid, host_mem, host_cpu, 
                                 host_family, host_type, 
                                 host_storage_layout, host_network_layout)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
예제 #14
0
파일: host.py 프로젝트: KrisSaxton/spoke
def host_create(org_name, host_name, host_uuid, host_mem, host_cpu,
                host_family, host_type,
                host_storage_layout, host_network_layout):
    try:
        conf = _spoke_config(_salt_config('config'))
        host = SpokeHost(org_name)
        result = host.create(host_name, host_uuid, host_mem, host_cpu,
                             host_family, host_type,
                             host_storage_layout, host_network_layout)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
예제 #15
0
파일: host.py 프로젝트: KrisSaxton/spoke
def host_create(org_name, host_name, host_uuid, host_mem, host_cpu,
                host_family, host_type, host_storage_layout,
                host_network_layout):
    try:
        conf = _spoke_config(_salt_config('config'))
        host = SpokeHost(org_name)
        result = host.create(host_name, host_uuid, host_mem, host_cpu,
                             host_family, host_type, host_storage_layout,
                             host_network_layout)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
예제 #16
0
파일: host.py 프로젝트: mattmb/spoke
def host_search(org_name, host_name=None):
    from spoke.lib.host import SpokeHost

    try:
        host = SpokeHost(org_name)
        if host_name is None:
            result = host.get()
        else:
            result = host.get(host_name)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
예제 #17
0
파일: host.py 프로젝트: mattmb/spoke
def host_create(
    org_name, host_name, host_uuid, host_mem, host_cpu, host_family, host_type, host_storage_layout, host_network_layout
):
    from spoke.lib.host import SpokeHost

    try:
        host = SpokeHost(org_name)
        result = host.create(
            host_name, host_uuid, host_mem, host_cpu, host_family, host_type, host_storage_layout, host_network_layout
        )
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
예제 #18
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_create_host_twice(self):
     """Create a host that already exists; raise AlreadyExists."""
     host = SpokeHost(self.org_name)
     self.assertRaises(error.AlreadyExists, host.create, self.host_name, 
                       self.host_uuid, self.host_mem, self.host_cpu,  
                       self.host_family, self.host_type,
                       self.host_storage_layout, self.host_network_layout,
                       self.host_extra_opts)
예제 #19
0
파일: test_host.py 프로젝트: mattmb/spoke
    def test_get_all_hosts(self):
        """Retrieve all hosts; return list of hosts objects."""
        host_name = 'testhost2'

        expected_data = []
        for h in (self.host_name, host_name):
            rdn = '%s=%s' % (self.host_key, h)
            dn = '%s,%s' % (rdn, self.host_container_dn)
            dn_info = {
                   'objectClass': ['top', self.host_class],
                   self.host_cpu_attr: [self.host_cpu],
                   self.host_extra_opts_attr: [self.host_extra_opts],
                   self.host_family_attr: [self.host_family],
                   self.host_mem_attr: [self.host_mem_kb],
                   self.host_name_attr: [h],
                   self.host_network_layout_attr: [self.host_network_layout],
                   self.host_storage_layout_attr: [self.host_storage_layout],
                   self.host_type_attr: [self.host_type],
                   self.host_uuid_attr: [self.host_uuid],
                   self.host_key: [h]
                   }
            append_this = (dn, dn_info)
            expected_data.append(append_this)
        host = SpokeHost(self.org_name)
        host.create(host_name, self.host_uuid, self.host_mem, self.host_cpu, 
                    self.host_family, self.host_type, self.host_storage_layout, 
                    self.host_network_layout, self.host_extra_opts)
        result = host.get()
        self.assertEquals(result['data'], expected_data)
        host.delete(host_name)
예제 #20
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_create_host_with_invalid_family(self):
     """Create a host with an invalid family value; raise InputError."""
     host = SpokeHost(self.org_name)
     host_name = 'validhost'
     host_family = 'virtualbox'
     self.assertRaises(error.InputError, host.create, host_name, 
                       self.host_uuid, self.host_mem, self.host_cpu,  
                       host_family, self.host_type, self.host_storage_layout, 
                       self.host_network_layout, self.host_extra_opts)
예제 #21
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_create_host_with_unkown_storage_layout(self):
     """Create a host with an unknown storage layout; raise InputError."""
     host = SpokeHost(self.org_name)
     host_name = 'validhost'
     host_storage_layout = 'supermagicsan'
     self.assertRaises(error.InputError, host.create, host_name, 
                       self.host_uuid, self.host_mem, self.host_cpu,  
                       self.host_family, self.host_type, host_storage_layout, 
                       self.host_network_layout, self.host_extra_opts)
예제 #22
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_get_host(self):
     """Retrieve host; return a host object."""
    
     rdn = '%s=%s' % (self.host_key, self.host_name)
     dn = '%s,%s' % (rdn, self.host_container_dn)
     dn_info = {
                'objectClass': ['top', self.host_class],
                self.host_cpu_attr: [self.host_cpu],
                self.host_extra_opts_attr: [self.host_extra_opts],
                self.host_family_attr: [self.host_family],
                self.host_mem_attr: [self.host_mem_kb],
                self.host_name_attr: [self.host_name],
                self.host_network_layout_attr: [self.host_network_layout],
                self.host_storage_layout_attr: [self.host_storage_layout],
                self.host_type_attr: [self.host_type],
                self.host_uuid_attr: [self.host_uuid],
                self.host_key: [self.host_name]
                }
     expected_data = [(dn, dn_info)]
     host = SpokeHost(self.org_name)
     result = host.get(self.host_name)
     self.assertEquals(result['data'], expected_data)
예제 #23
0
파일: mc_host.py 프로젝트: KrisSaxton/spoke
import spoke.lib.error as error
import spoke.lib.config as config
import spoke.lib.logger as logger
import spoke.lib.mc_helper as mc
from spoke.lib.host import SpokeHost

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()
    org_name = request['data']['org']
    try:
        host = SpokeHost(org_name)
    except error.SpokeError, e:
        mc.fail(e.msg, e.exit_code)

    if request['action'] == 'create':
        host_name = request['data']['hostname']
        host_uuid = request['data']['uuid']
        host_mem = request['data']['mem']
        host_cpu = request['data']['cpu']
        host_family = request['data']['family']
        host_type  = request['data']['vm_type']
        host_storage_layout = request['data']['storage_layout']
        host_network_layout = request['data']['network_layout']
        try:
            host_extra_opts = request['data']['extra_opts']
        except KeyError:
예제 #24
0
파일: mc_host.py 프로젝트: mattmb/spoke
import spoke.lib.error as error
import spoke.lib.config as config
import spoke.lib.logger as logger
import spoke.lib.mc_helper as mc
from spoke.lib.host import SpokeHost

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()
    org_name = request['data']['org']
    try:
        host = SpokeHost(org_name)
    except error.SpokeError, e:
        mc.fail(e.msg, e.exit_code)

    if request['action'] == 'create':
        host_name = request['data']['hostname']
        host_uuid = request['data']['uuid']
        host_mem = request['data']['mem']
        host_cpu = request['data']['cpu']
        host_family = request['data']['family']
        host_type = request['data']['vm_type']
        host_storage_layout = request['data']['storage_layout']
        host_network_layout = request['data']['network_layout']
        try:
            host_extra_opts = request['data']['extra_opts']
        except KeyError:
예제 #25
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_delete_non_existant_host(self):
     """Delete non-existent host; raise MissingHost."""
     host = SpokeHost(self.org_name)
     host_name = 'testhostdeletemissing'
     self.assertRaises(error.NotFound, host.delete, host_name)