示例#1
0
 def test_node_patch(self):
     """ Verify PATCH:/nodes/:id """
     data = {"name": 'fake_name_test'}
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     codes = []
     for n in nodes:
         if n.get('name') == 'test_compute_node':
             uuid = n.get('id')
             Nodes().api1_1_nodes_identifier_patch(uuid, data)
             rsp = self.__client.last_response
             test_nodes = loads(self.__client.last_response.data)
             assert_equal(test_nodes.get('name'), 'fake_name_test',
                          'Oops patch failed')
             codes.append(rsp)
             LOG.info('Restoring name to "test_compute_node"')
             correct_data = {"name": 'test_compute_node'}
             Nodes().api1_1_nodes_identifier_patch(uuid, correct_data)
             rsp = self.__client.last_response
             restored_nodes = loads(self.__client.last_response.data)
             assert_equal(restored_nodes.get('name'), 'test_compute_node',
                          'Oops restoring failed')
             codes.append(rsp)
     assert_not_equal(0,
                      len(codes),
                      message='Failed to find compute node Ids')
     for c in codes:
         assert_equal(200, c.status, message=c.reason)
     assert_raises(rest.ApiException,
                   Nodes().api1_1_nodes_identifier_patch, 'fooey', data)
示例#2
0
 def test_node_workflows_post(self):
     """Testing node POST:id/workflows"""
     resps = []
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     for n in nodes:
         if n.get('type') == 'compute':
             Nodes().api1_1_nodes_identifier_workflows_post(n.get('id'),name='Graph.Discovery',body={})
             resps.append(self.__client.last_response.data)
     for resp in resps:
         assert_not_equal(0, len(loads(resp)), message='No Workflows found for Node')
     assert_raises(rest.ApiException, Nodes().api1_1_nodes_identifier_workflows_post, 'fooey','Graph.Discovery',{})
示例#3
0
 def test_node_workflows_del_active(self):
     """Testing node DELETE:id/workflows/active"""
     resps = []
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     for n in nodes:
         if n.get('type') == 'compute':
             Nodes().api1_1_nodes_identifier_workflows_active_delete(n.get('id'))
             resps.append(self.__client.last_response.data)
     for resp in resps:
         assert_not_equal(0, len(loads(resp)), message='No active Workflows found for Node')
     assert_raises(rest.ApiException, Nodes().api1_1_nodes_identifier_workflows_active_delete, 'fooey')
示例#4
0
 def test_node_catalogs(self):
     """ Testing GET id:/catalogs """
     resps = []
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     for n in nodes:
         if n.get('type') == 'compute':
             Nodes().api1_1_nodes_identifier_catalogs_get( n.get('id'))
             resps.append(self.__client.last_response.data)
     for resp in resps:
         assert_not_equal(0, len(loads(resp)), message='Node catalog is empty!')
     assert_raises(rest.ApiException, Nodes().api1_1_nodes_identifier_catalogs_get, 'fooey')
示例#5
0
 def test_node_catalogs_bysource(self):
     """ Testing GET id:/catalogs/source """
     resps = []
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     for n in nodes:
         if n.get('type') == 'compute':
             Nodes().api1_1_nodes_identifier_catalogs_source_get( n.get('id'),'bmc')
             resps.append(self.__client.last_response)
     for resp in resps:
         assert_equal(200,resp.status, message=resp.reason)
     assert_raises(rest.ApiException, Nodes().api1_1_nodes_identifier_catalogs_source_get, 'fooey','bmc')
示例#6
0
    def test_whitelist_node_delete(self):
        """ Verify Delete:/nodes/:mac/dhcp/whitelist """
        Nodes().api1_1_nodes_get()
        nodes = loads(self.__client.last_response.data)
        for n in nodes:
            for i in n:
                if i == 'identifiers':
                    if len(n[i]) > 0:
                        macaddress = n[i]

        macaddress_to_delete = macaddress[len(macaddress)-1]
        LOG.info('Deleting macaddress {0}' .format(macaddress_to_delete))
        Nodes().api1_1_nodes_macaddress_dhcp_whitelist_delete(macaddress_to_delete)
        rsp = self.__client.last_response
        assert_equal(204, rsp.status, message=rsp.reason)
示例#7
0
 def test_node_id_obm_identify_create(self):
     """ Testing POST:/nodes/:id/obm/identify """
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     codes = []
     data = {"value": "true"}
     for n in nodes:
         if n.get('type') == 'compute':
             uuid = n.get('id')
             Nodes().api1_1_nodes_identifier_obm_identify_post(uuid, data)
             rsp = self.__client.last_response
             codes.append(rsp)
     for c in codes:
         assert_equal(200, c.status, message=c.reason)
     assert_raises(rest.ApiException, Nodes().api1_1_nodes_identifier_obm_identify_post, 'fooey', data)
示例#8
0
 def test_node_create(self):
     """ Verify POST:/nodes/ """
     for n in self.__test_nodes:
         LOG.info('Creating node (name={0})'.format(n.get('name')))
         Nodes().api1_1_nodes_post(n)
         rsp = self.__client.last_response
         assert_equal(201, rsp.status, message=rsp.reason)
示例#9
0
文件: obm.py 项目: spiegela/RackHD
 def check_nodes(self, service_type, uuid=None):
     retval = []
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     for n in nodes:
         node_type = n.get('type')
         uid = n.get('id')
         if uuid is None or uuid == uid:
             if node_type != 'enclosure':
                 obm_obj = n.get('obmSettings')
                 if (obm_obj is None) or (obm_obj is not None
                                          and len(obm_obj) == 0):
                     LOG.warning(
                         'No OBM settings for node type {0} (id={1})'.
                         format(node_type, uid))
                     retval.append(False)
                 else:
                     for obm in obm_obj:
                         service = obm.get('service')
                         if service_type not in service:
                             LOG.warning(
                                 'No OBM service type {0} (id={1})'.format(
                                     service_type, uid))
                             retval.append(False)
     return retval
示例#10
0
文件: obm.py 项目: spiegela/RackHD
 def setup_nodes(self, service_type, uuid=None):
     err = []
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     for n in nodes:
         node_type = n.get('type')
         uid = n.get('id')
         if uuid is None or uuid == uid:
             if service_type == 'ipmi-obm-service' and node_type == 'compute':
                 if len(self.check_nodes('ipmi-obm-service',
                                         uuid=uuid)) > 0:
                     if self._set_ipmi(uid) == False:
                         err.append(
                             'Error setting IPMI OBM settings for node {0}'.
                             format(uid))
                     else:
                         LOG.info('Setting IPMI OBM settings successful')
             if service_type == 'snmp-obm-service' and node_type != 'enclosure':
                 if len(self.check_nodes('snmp-obm-service',
                                         uuid=uuid)) > 0:
                     if self._set_snmp(uid) == False:
                         err.append(
                             'Error setting SNMP OBM settings for node {0}'.
                             format(uid))
                     else:
                         LOG.info('Setting SNMP OBM settings successful')
     for e in err:
         LOG.error(e)
     return err
示例#11
0
 def test_node_id(self):
     """ Testing GET:/nodes/:id """
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     LOG.debug(nodes,json=True)
     codes = []
     for n in nodes:
         LOG.info(n)
         if n.get('type') == 'compute':
             uuid = n.get('id')
             Nodes().api1_1_nodes_identifier_get(uuid)
             rsp = self.__client.last_response
             codes.append(rsp)
     assert_not_equal(0, len(codes), message='Failed to find compute node Ids')
     for c in codes:
         assert_equal(200, c.status, message=c.reason)
     assert_raises(rest.ApiException, Nodes().api1_1_nodes_identifier_get, 'fooey')
示例#12
0
 def check_compute_count(self):
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     count = 0
     for n in nodes:
         type = n.get('type')
         if type == 'compute':
             count += 1
     return count
示例#13
0
    def test_node_id_obm(self):
        """ Testing GET:/nodes/:id/obm """
        Nodes().api1_1_nodes_get()
        nodes = loads(self.__client.last_response.data)
        LOG.debug(nodes,json=True)
        codes = []
        for n in nodes:
            if n.get('name') == 'test_compute_node':
                uuid = n.get('id')
                Nodes().api1_1_nodes_identifier_obm_get(uuid)
                rsp = self.__client.last_response
                LOG.info('OBM setting for node ID {0} is {1}'.format(uuid, rsp.data))
                codes.append(rsp)

        assert_not_equal(0, len(codes), message='Failed to find compute node Ids')
        for c in codes:
            assert_equal(200, c.status, message=c.reason)
        assert_raises(rest.ApiException, Nodes().api1_1_nodes_identifier_obm_get, 'fooey')
示例#14
0
    def test_whitelist_node_create(self):
        """ Verify POST:/nodes/:mac/dhcp/whitelist """
        Nodes().api1_1_nodes_get()
        nodes = loads(self.__client.last_response.data)
        for n in nodes:
            for i in n:
                if i == 'identifiers':
                    if len(n[i]) > 0:
                        macaddress = n[i]
                        LOG.info('Posting macaddress {0}'.format(macaddress))

        for address in macaddress:
            Nodes().api1_1_nodes_macaddress_dhcp_whitelist_post(address, n)
            rsp = self.__client.last_response
            assert_equal(201, rsp.status, message=rsp.reason)
            macaddress_parsed = loads(rsp.data.replace("-", ":"))
            if macaddress_parsed[len(macaddress_parsed) -
                                 1] == macaddress[len(macaddress) - 1]:
                LOG.info("Verfied the macaddress on whitelist")
示例#15
0
    def test_node_delete(self):
        """ Testing DELETE:/nodes/:id """
        codes = []
        test_names = []
        Nodes().api1_1_nodes_get()
        nodes = loads(self.__client.last_response.data)
        test_names = [t.get('name') for t in self.__test_nodes]
        for n in nodes:
            name = n.get('name')
            if name in test_names:
                uuid = n.get('id')
                LOG.info('Deleting node {0} (name={1})'.format(uuid, name))
                Nodes().api1_1_nodes_identifier_delete(uuid)
                codes.append(self.__client.last_response)

        assert_not_equal(0, len(codes), message='Delete node list empty!')
        for c in codes:
            assert_equal(200, c.status, message=c.reason)
        assert_raises(rest.ApiException, Nodes().api1_1_nodes_identifier_delete, 'fooey')
示例#16
0
文件: obm.py 项目: logtraynor/RackHD
 def _set_ipmi(self, uid):
     user, passwd = get_bmc_cred()
     mac = None
     Nodes().api1_1_nodes_identifier_catalogs_source_get(uid, 'bmc')
     rsp = self.__client.last_response
     bmc = loads(rsp.data)
     if 'data' in bmc:
         mac = bmc['data'].get('MAC Address')
     else:
         Nodes().api1_1_nodes_identifier_catalogs_source_get(uid, 'rmm')
         rsp = self.__client.last_response
         rmm = loads(rsp.data)
         if 'data' in rmm:
             mac = bmc['data'].get('MAC Address')
     if mac is not None:
         LOG.debug('BMC MAC {0} for {1}'.format(mac, uid))
         setting = {
             'obmSettings': [{
                 'service': 'ipmi-obm-service',
                 'config': {
                     'user': user,
                     'password': passwd,
                     'host': mac
                 }
             }]
         }
         LOG.info('Creating ipmi obm-settings for node {0} \n {1}'.format(
             uid, setting))
         try:
             Nodes().api1_1_nodes_identifier_patch(uid, setting)
         except rest.ApiException as e:
             LOG.error(e)
             return False
     else:
         LOG.error(
             'Error finding configurable IPMI MAC address for {0}'.format(
                 uid))
         return False
示例#17
0
 def check_chassis_task(self):
     """ Testing AMQP on.task.ipmi.chassis.result """
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     self.__tasks = []
     for node in nodes:
         id = node.get('id')
         assert_is_not_none(id)
         type = node.get('type')
         assert_is_not_none(type)
         if type == 'compute':
             worker = AMQPWorker(queue=QUEUE_CHASSIS_RESULT, \
                                 callbacks=[self.__handle_result])
             self.__tasks.append(WorkerThread(worker,id))
     tasks = WorkerTasks(tasks=self.__tasks, func=self.__task_thread)
     tasks.run()
     tasks.wait_for_completion()
示例#18
0
 def check_chassis_task(self):
     """ Testing AMQP on.task.ipmi.chassis.result """
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     self.__threadTasks = []
     for node in nodes:
         id = node.get('id')
         assert_not_equal(id,None)
         type = node.get('type')
         assert_not_equal(type,None)
         if type == 'compute':
             worker = Worker(queue=QUEUE_CHASSIS_RESULT, callbacks=[self.handle_result])
             thread = Thread(target=self.amqp_tasker_thread,args=(worker,id,))
             thread.daemon = True
             self.__threadTasks.append(self.ThreadTask(worker,thread,id))
     for t in self.__threadTasks:
         t.thread.start()
         t.state = True
     self.amqp_tasker_loop()
示例#19
0
 def check_lookups_query(self):
     """ Testing GET:/lookups?q=term """
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     assert_not_equal(0, len(nodes), message='Node list was empty!')
     obms = [
         n.get('obmSettings') for n in nodes
         if n.get('obmSettings') is not None
     ]
     hosts = []
     for o in obms:
         for c in o:
             hosts.append(c.get('config').get('host'))
     assert_not_equal(0, len(hosts), message='No OBM hosts were found!')
     for host in hosts:
         Lookups().api1_1_lookups_get(q=host)
         rsp = self.__client.last_response
         assert_equal(200, rsp.status, message=rsp.reason)
         assert_not_equal(0, len(rsp.data))
示例#20
0
    def check_lookup_id(self):
        """ Testing GET:/lookups/:id """
        Nodes().api1_1_nodes_get()
        nodes = loads(self.__client.last_response.data)
        assert_not_equal(0, len(nodes), message='Node list was empty!')
        obms = [
            n.get('obmSettings') for n in nodes
            if n.get('obmSettings') is not None
        ]
        assert_not_equal(0, len(obms), message='No OBM settings found!')
        entries = []
        for obm in obms:
            for cfg in obm:
                host = cfg.get('config').get('host')
                Lookups().api1_1_lookups_get(q=host)
                list = loads(self.__client.last_response.data)
                entries.append(list)

        assert_not_equal(0, len(entries), message='No lookup entries found!')
        for entry in entries:
            for id in entry:
                Lookups().api1_1_lookups_id_get(id.get('id'))
                rsp = self.__client.last_response
                assert_equal(200, rsp.status, message=rsp.reason)
示例#21
0
 def test_nodes(self):
     """ Testing GET:/nodes """
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     LOG.debug(nodes, json=True)
     assert_not_equal(0, len(nodes), message='Node list was empty!')
示例#22
0
 def test_nodes(self):
     """ Testing GET:/nodes """
     Nodes().api1_1_nodes_get()
     nodes = dumps(self.__client.last_response.data)
     assert_equal(200, self.__client.last_response.status)
     assert_not_equal(0, len(nodes), message='Node list was empty!')