--1 . Complementary assets acquired
- 2 .api checksum
# ## Recap:
- CMDB Configuration Management Database Asset Acquisition
- Vision: Automated operation and maintenance of the platform
- you encountered any kind of problems in development? Deeper impression?
- Path Navigation
- Home sector list sectors add [] {ID: {}}
- [{} URL title, URL title {}, {} title URL]
- foreign key parent (autocorrelation)
- dictionary into the session, for json serialization, then the dictionary is a digital key, the serialized into a string.
# ## in the CMDB technical points:
-. 1 .sys.path
- 2 . Open closed principle
- on the source code of
- configuration Open
- + 3 supports three modes scalable
- Agent
- SSH
- Salt
- ansible
- ...
- + importlib.import_module + arranged reflected
--4 class constraints.
- Constraint Subclasses implement some methods
- abc.ABCMeta + abstract class abstract methods abc.abstractmethod
- Inherited + thrown raise NotImplementedError ( '' )
--5 acquisition hardware information pluggable design
- configuration + importlib.import_module + reflective
- 6 . win support and linux command
7-- different assets at nowhere Run mode acquisition mode.
- Agent the subprocess
- SSH paramiko
- Salt salt.client
- 8 .debug debugging
- 9
RET . api to send information requests through the module
Python `` `= Requests.post (
URL = settings.ASSET_API,
Data = json.dumps (info) .encode ( ' UTF-. 8 ' ),
headers = { ' Content-type ' : ' file application / JSON ' }
)
`` `
- RET .text text
- ret.json () deserialization
--10 . thread pool
- from concurrent.futures Import the ThreadPoolExecutor
-. 11 .csrf_exempt csrf not check (the FBV)
- from django.views.decorators.csrfImport csrf_exempt
- 12 is only applied to the dispatch (the CBV)
`` `Python
from django.utils.decorators Import method_decorator
@method_decorator (csrf_exempt, name = ' dispatch ' )
class AssetView (View):
` ``
- 13 is written recommendation api the CBV
- djangorestframework installation
- rest_framework use
`` `Python
from rest_framework.views Import APIView
from rest_framework.response Import Response
` ``
- data submitted request.data
- request._request is the original Request
# ## uniquely identifies
- a physical machine:
- sn No. The only physical machine
- Physical + Virtual machine
- sn + No. tone Interface
- Host name
- the host name of the only
- keep the host name in a file
- not originally files, reporting after acquisition is complete, the host name of the API returns, the host name is written to a file c1.com
- second acquisition, the host name of the file is read c1.com
- determining whether a host name change:
- changing operation to modify the host name + information updating hardware
- no change to update the hardware operation information
# ## hard disk data structure analysis
`` `Python
data = { ' 0 ': {'slot': '0', 'pd_type': 'SAS', 'capacity': '279.396', 'model': 'SEAGATE ST300MM0006 LS08S0K2B5NV'},
'1': {'slot': '1', 'pd_type': '','SAScapacity': '279.396', 'model': 'SEAGATE ST300MM0006 LS08S0K2B5AH'},
'2': {'slot': '2', 'pd_type': 'SATA', 'capacity': '476.939',
'model': 'S1SZNSAFA01085L Samsung SSD 850 PRO 512GB EXM01B6Q'},
'3': {'slot': '3', 'pd_type': 'SATA', 'capacity': '476.939',
'model': 'S1AXNSAF912433K Samsung SSD 840 PRO Series DXM06B0Q'},
'4': {'slot': '4', 'pd_type': 'SATA', 'capacity': '476.939',
'model': 'S1AXNSAF303909M Samsung SSD 840 PRO Series DXM05B0Q'},
'5': {'slot': '5', 'pd_type': 'SATA', 'capacity': '476.939',
'model': 'S1AXNSAFB00549A Samsung SSD 840 PRO Series DXM06B0Q'}}
db_data = [
{'id': 1, 'slot': '0', 'model': 'SEAGATE ST300MM0006 LS08S0K2B5NV', 'capacity': 999.396, 'pd_type': 'SAS',
'server_id': 1},
{'id': 2, 'slot': '1', 'model': 'SEAGATE ST300MM0006 LS08S0K2B5AH', 'capacity': 800.396, 'pd_type': 'SAS',
'server_id': 1},
{'id': 3, 'slot': '2', 'model': 'S1SZNSAFA01085L Samsung SSD 850 PRO 512GB EXM01B6Q',
'capacity': 476.939, 'pd_type': 'SATA', 'server_id': 1},
{'id': 9, 'slot': '6', 'model': 'S1AXNSAFB00549A Samsung SSD 840 PRO Series DXM06B0Q',
'capacity': 476.939, 'pd_type': 'SATA', 'server_id': 1}]
data_set = set(data)
print(data_set)
db_data_set = {i['slot'] for i in db_data}
print(db_data_set)
add_slot_set = data_set - db_data_set
del_slot_set = db_data_set - data_set
update_slot_set = db_data_set & data_set
print(add_slot_set)
Print (del_slot_set)
Print (update_slot_set)
`` `
# ## update hardware information
- hard drive
- the new hard disk
- remove the hard disk
- update hard disk
# ## API check
--1 carry on .url key parameters
- determine key are the same
- disadvantages:
- Key not dynamic
- 2.key | time md5 encryption
- key = time = & encryption Key ctime
- rsa encryption:
- https://www.cnblogs.com/maple-shaw/articles/7196631 .html