Exemplo n.º 1
0
    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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
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
Exemplo n.º 6
0
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
Exemplo n.º 7
0
Arquivo: host.py Projeto: 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
Exemplo n.º 8
0
Arquivo: host.py Projeto: 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
Exemplo n.º 9
0
 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:
         host_extra_opts = None
     try:
         mc.data = host.create(host_name, host_uuid, host_mem, host_cpu,
                               host_family, host_type, host_storage_layout,
                               host_network_layout, host_extra_opts)
     except error.SpokeError, e:
         mc.fail(e.msg, e.exit_code)
 elif request['action'] == 'search':
     try:
         host_name = request['data']['hostname']
     except KeyError:
         host_name = None
     try:
         mc.data = host.get(host_name)
     except error.SpokeError, e:
         mc.fail(e.msg, e.exit_code)
 elif request['action'] == 'delete':
     host_name = request['data']['hostname']
     try:
Exemplo n.º 10
0
 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:
         host_extra_opts = None
     try:
         mc.data = host.create(host_name, host_uuid, host_mem, host_cpu, 
                               host_family, host_type, host_storage_layout,
                               host_network_layout, host_extra_opts)
     except error.SpokeError, e:
         mc.fail(e.msg, e.exit_code)
 elif request['action'] == 'search':
     try:
         host_name = request['data']['hostname']
     except KeyError:
         host_name = None
     try:
         mc.data = host.get(host_name)
     except error.SpokeError, e:
         mc.fail(e.msg, e.exit_code)
 elif request['action'] == 'delete':
     host_name = request['data']['hostname']
     try: