예제 #1
0
파일: host.py 프로젝트: KrisSaxton/spoke
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
예제 #2
0
파일: host.py 프로젝트: KrisSaxton/spoke
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
예제 #3
0
파일: host.py 프로젝트: KrisSaxton/spoke
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
예제 #4
0
파일: host.py 프로젝트: KrisSaxton/spoke
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
예제 #5
0
파일: host.py 프로젝트: 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
예제 #6
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()
예제 #7
0
파일: host.py 프로젝트: 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
예제 #8
0
파일: host.py 프로젝트: KrisSaxton/spoke
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
예제 #9
0
파일: host.py 프로젝트: 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
예제 #10
0
파일: host.py 프로젝트: KrisSaxton/spoke
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
예제 #11
0
 def test_increment_and_get_multiple_next_free_uuid_and_mac(self):
     """Get next 4 free uuids and macs; return uuids as list of integers."""
     next_uuid = SpokeHostUUID()
     result = next_uuid.modify(4, get_mac=True)
     expected_data = ([1, 2, 3, 4], [
         '02:00:00:01:00:00', '02:00:00:02:00:00', '02:00:00:03:00:00',
         '02:00:00:04:00:00'
     ])
     self.assertEquals(result['data'], expected_data)
예제 #12
0
파일: host.py 프로젝트: KrisSaxton/spoke
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
예제 #13
0
파일: host.py 프로젝트: 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
예제 #14
0
파일: host.py 프로젝트: 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
예제 #15
0
파일: host.py 프로젝트: 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
예제 #16
0
파일: host.py 프로젝트: KrisSaxton/spoke
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
예제 #17
0
파일: host.py 프로젝트: mattmb/spoke
def uuid_search(get_mac=False):

    print get_mac
    print type(get_mac)
    try:
        from spoke.lib.host import SpokeHostUUID
        uuid = SpokeHostUUID()
        result = uuid.get(get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result  
예제 #18
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)
예제 #19
0
파일: host.py 프로젝트: mattmb/spoke
def uuid_search(get_mac=False):

    print get_mac
    print type(get_mac)
    try:
        from spoke.lib.host import SpokeHostUUID

        uuid = SpokeHostUUID()
        result = uuid.get(get_mac)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
예제 #20
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_get_missing_next_free_uuid(self):
     """Retrieve missing next free uuid; raise NotFound"""
     next_uuid = SpokeHostUUID()
     next_uuid.delete()
     next_uuid.__init__()
     self.assertRaises(error.NotFound, next_uuid.get)
     next_uuid.create(self.next_uuid_start)
예제 #21
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_create_next_free_uuid_non_integer(self):
     """Create next free uuid with non integer; raise InputError."""
     next_uuid = SpokeHostUUID()
     next_uuid.delete()
     # Re init so it detects the delete
     next_uuid.__init__()
     next_uuid_start = 'three'
     self.assertRaises(error.InputError, next_uuid.create, next_uuid_start)
     next_uuid.create(self.next_uuid_start)
예제 #22
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_create_next_free_uuid_mac(self):
     """Create next free uuid + mac; return as tuple."""
     next_uuid = SpokeHostUUID()
     next_uuid.delete()
     # Re init so it detects the delete
     next_uuid.__init__()
     result = next_uuid.create(self.next_uuid_start, get_mac=True)
     expected_data = (1, '02:00:00:01:00:00')
     self.assertEqual(result['data'], expected_data)
예제 #23
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_create_next_free_uuid(self):
     """Create next free uuid; return uuid as list."""
     next_uuid = SpokeHostUUID()
     next_uuid.delete()
     # Re init so it detects the delete
     next_uuid.__init__()
     result = next_uuid.create(self.next_uuid_start)
     expected_data = [1]
     self.assertEqual(result['data'], expected_data)
예제 #24
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_update_next_free_uuid_with_string(self):
     """Increment next free UUID with string; raise InputError."""
     next_uuid = SpokeHostUUID()
     self.assertRaises(error.InputError, next_uuid.modify, 'four')
예제 #25
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_increment_and_get_multiple_next_free_uuid_and_mac(self):
     """Get next 4 free uuids and macs; return uuids as list of integers."""
     next_uuid = SpokeHostUUID()
     result = next_uuid.modify(4, get_mac=True)
     expected_data = ([1, 2, 3, 4], ['02:00:00:01:00:00', '02:00:00:02:00:00', '02:00:00:03:00:00', '02:00:00:04:00:00'])
     self.assertEquals(result['data'], expected_data)
예제 #26
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_increment_and_get_multiple_next_free_uuid(self):
     """Get next 4 free uuids; return uuids as list of integers."""
     next_uuid = SpokeHostUUID()
     result = next_uuid.modify(4)
     expected_data = [1, 2, 3, 4]
     self.assertEquals(result['data'], expected_data)
예제 #27
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_get_next_free_uuid(self):
     """Retrieve next free uuid; return uuid as list."""
     next_uuid = SpokeHostUUID()
     result = next_uuid.get()
     expected_data = [1]
     self.assertEquals(result['data'], expected_data)
예제 #28
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_update_and_get_next_free_uuid_mac(self):
     """Get next free uuid and mac; return as tuple."""
     next_uuid = SpokeHostUUID()
     result = next_uuid.modify(get_mac=True)
     expected_data = ([1], ['02:00:00:01:00:00'])
     self.assertEquals(result['data'], expected_data)
예제 #29
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_update_and_get_next_free_uuid(self):
     """Get next free uuid; return uuid as list."""
     next_uuid = SpokeHostUUID()
     result = next_uuid.modify()
     expected_data = [1]
     self.assertEquals(result['data'], expected_data)
예제 #30
0
파일: test_host.py 프로젝트: mattmb/spoke
 def test_create_existing_free_uuid(self):
     """Create existing next free uuid; raise AlreadyExists."""
     next_uuid = SpokeHostUUID()
     self.assertRaises(error.AlreadyExists, next_uuid.create, 
                       self.next_uuid_start)
예제 #31
0
if __name__ == '__main__':
    log = logger.setup('main', verbose=False, quiet=True)
    mc = mc.MCollectiveAction()
    request = mc.request()
    try:
        uuid_start = request['data']['uuid_start']
    except KeyError:
        uuid_start = None
    try:
        qty = request['data']['qty']
    except KeyError:
        qty = 1
    if request['action'] == 'create':
        try:
            mc.data = SpokeHostUUID().create(uuid_start)['data']
        except Exception as e:
            mc.fail(e.msg, e.exit_code)
    elif request['action'] == 'get':
        try:
            mc.data = SpokeHostUUID().get()['data']
        except Exception as e:
            mc.fail(e.msg, e.exit_code)
    elif request['action'] == 'delete':
        try:
            mc.data = SpokeHostUUID().delete()['data']
        except Exception as e:
            mc.fail(e.msg, e.exit_code)
    elif request['action'] == 'reserve':
        try:
            mc.data = SpokeHostUUID().modify(increment=qty)['data']