python--第二十四天总结
CMDB介绍
CMDB --Configuration Management Database 配置管理数据库, CMDB存储与管理企业IT架构中设备的各种配置信息,它与所有服务支持和服务交付流程都紧密相联,支持这些流程的运转、发挥配置信息 的价值,同时依赖于相关流程保证数据的准确性。
- 整合是指能够充分利用来自其他数据源的信息,对CMDB中包含的记录源属性进行存取,将多个数据源合并至一个视图中,生成连同来自CMDB和其他数据源信息在内的报告;
- 调和能力是指通过对来自每个数据源的匹配字段进行对比,保证CMDB中的记录在多个数据源中没有重复现象,维持CMDB中每个配置项目数据源的完整性;自动调整流程使得初始实施、数据库管理员的手动运作和现场维护支持工作降至最低;
- 同步指确保CMDB中的信息能够反映联合数据源的更新情况,在联合数据源更新频率的基础上确定CMDB更新日程,按照经过批准的变更来更新 CMDB,找出未被批准的变更;
- 应用映射与可视化,说明应用间的关系并反应应用和其他组件之间的依存关系,了解变更造成的影响并帮助诊断问题。
CMDB 资产管理部分实现
需求
- •存储所有IT资产信息
- •数据可手动添加
- •硬件信息可自动收集
- •硬件信息可自动变更
- •可对其它系统灵活开放API
- •API接口安全认证
立业之本:定义表结构
- 各种硬件都能存
- 资产变更有纪录
- 资产ID永不变
- 资产要有状态机
重中之重:接口设计好
- 可对内外灵活开放接口
- 接口定义要标准化
- 一定要提供排错依据
- 数据返回要标准
- 要能增删改查
- 所有异常要抓住
- 接口安全要注意
CMDB资产数据自动汇报及更新流程图
https://www.processon.com/view/link/571b4b2ce4b049474cc87feb
自定义用户认证
https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#django.contrib.auth.models.PermissionsMixin.has_perms
user_models.py
#!/usr/bin/env python
#_*_ coding:utf-8 _*_ from django.db import models
from django.contrib.auth.models import (
BaseUserManager, AbstractBaseUser
) class UserProfileManager(BaseUserManager):
def create_user(self, email, name, password=None):
"""
Creates and saves a User with the given email, date of
birth and password.
"""
if not email:
raise ValueError('Users must have an email address') user = self.model(
email=self.normalize_email(email),
name=name,
) user.set_password(password)
user.save(using=self._db)
return user def create_superuser(self, email, name, password):
"""
Creates and saves a superuser with the given email, date of
birth and password.
"""
user = self.create_user(email,
password=password,
name=name
)
user.is_admin = True
user.save(using=self._db)
return user class UserProfile(AbstractBaseUser):
email = models.EmailField(
verbose_name='email address',
max_length=255,
unique=True,
)
name = models.CharField(u'名字',max_length=32)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False) objects = UserProfileManager() USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['name'] def get_full_name(self):
# The user is identified by their email address
return self.email def get_short_name(self):
# The user is identified by their email address
return self.email def __str__(self): # __unicode__ on Python 2
return self.email def has_perm(self, perm, obj=None):
"Does the user have a specific permission?"
# Simplest possible answer: Yes, always
return True def has_module_perms(self, app_label):
"Does the user have permissions to view the app `app_label`?"
# Simplest possible answer: Yes, always
return True @property
def is_staff(self):
"Is the user a member of staff?"
# Simplest possible answer: All admins are staff
return self.is_admin
class Meta:
verbose_name = u'用户信息'
verbose_name_plural = u"用户信息"
def __unicode__(self):
return self.name ----------------------------------
user_admin_models.py #!/usr/bin/env python
#_*_ coding:utf-8 _*_ from django import forms
from django.contrib import admin
from django.contrib.auth.models import Group
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.forms import ReadOnlyPasswordHashField from assets.user_models import UserProfile class UserCreationForm(forms.ModelForm):
"""A form for creating new users. Includes all the required
fields, plus a repeated password."""
password1 = forms.CharField(label='Password', widget=forms.PasswordInput)
password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput) class Meta:
model = UserProfile
fields = ('email', 'name') def clean_password2(self):
# Check that the two password entries match
password1 = self.cleaned_data.get("password1")
password2 = self.cleaned_data.get("password2")
if password1 and password2 and password1 != password2:
raise forms.ValidationError("Passwords don't match")
return password2 def save(self, commit=True):
# Save the provided password in hashed format
user = super(UserCreationForm, self).save(commit=False)
user.set_password(self.cleaned_data["password1"])
if commit:
user.save()
return user class UserChangeForm(forms.ModelForm):
"""A form for updating users. Includes all the fields on
the user, but replaces the password field with admin's
password hash display field.
"""
password = ReadOnlyPasswordHashField() class Meta:
model = UserProfile
fields = ('email', 'password', 'name', 'is_active', 'is_admin') def clean_password(self):
# Regardless of what the user provides, return the initial value.
# This is done here, rather than on the field, because the
# field does not have access to the initial value
return self.initial["password"] class UserAdmin(BaseUserAdmin):
# The forms to add and change user instances
form = UserChangeForm
add_form = UserCreationForm # The fields to be used in displaying the User model.
# These override the definitions on the base UserAdmin
# that reference specific fields on auth.User.
list_display = ('email', 'name', 'is_admin')
list_filter = ('is_admin',)
fieldsets = (
(None, {'fields': ('email', 'password')}),
('Personal info', {'fields': ('name',)}),
('Permissions', {'fields': ('is_admin',)}),
)
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
# overrides get_fieldsets to use this attribute when creating a user.
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('email', 'name', 'password1', 'password2')}
),
)
search_fields = ('email',)
ordering = ('email',)
filter_horizontal = ()
浅谈Restful API
理解RESTful架构 :http://www.ruanyifeng.com/blog/2011/09/restful
RESTful API 设计指南:http://www.ruanyifeng.com/blog/2014/05/restful_api.html
如何实现安全的WEB API 接口认证?
MadKing开源CMDB源码
https://github.com/triaquae/MadKing
python--第二十四天总结的更多相关文章
- Python第二十四天 binascii模块
Python第二十四天 binascii模块 binascii用来进行进制和字符串之间的转换 import binascii s = 'abcde' h = binascii.b2a_hex(s) # ...
- 孤荷凌寒自学python第二十四天python类中隐藏的私有方法探秘
孤荷凌寒自学python第二十四天python类中隐藏的私有方法探秘 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 今天发现了python的类中隐藏着一些特殊的私有方法. 这些私有方法不管我 ...
- python第二十四天-----作业终于完成啦
作业 1, ATM:模拟实现一个ATM + 购物商城程序 额度 15000或自定义实现购物商城,买东西加入 购物车,调用信用卡接口结账可以提现,手续费5%支持多账户登录支持账户间转账记录每月日常消费流 ...
- python第二十四课——set中的函数
集合中常用的一些函数: 1.add(obj):追加一个obj元素到集合中 pop():从集合中随机弹出一个元素 remove(obj):删除集合中和obj匹配的元素 clear():清空集合 s1={ ...
- 初学 Python(十四)——生成器
初学 Python(十四)--生成器 初学 Python,主要整理一些学习到的知识点,这次是生成器. # -*- coding:utf-8 -*- ''''' 生成式的作用: 减少内存占有,不用一次性 ...
- Python第十四天 序列化 pickle模块 cPickle模块 JSON模块 API的两种格式
Python第十四天 序列化 pickle模块 cPickle模块 JSON模块 API的两种格式 目录 Pycharm使用技巧(转载) Python第一天 安装 shell 文件 Py ...
- 孤荷凌寒自学python第二十五天初识python的time模块
孤荷凌寒自学python第二十五天python的time模块 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 通过对time模块添加引用,就可以使用python的time模块来进行相关的时间操 ...
- 孤荷凌寒自学python第十四天python代码的书写规范与条件语句及判断条件式
孤荷凌寒自学python第十四天python代码的书写规范与条件语句及判断条件式 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 在我学习过的所有语言中,对VB系的语言比较喜欢,而对C系和J系 ...
- NeHe OpenGL教程 第二十四课:扩展
转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...
- javaSE第二十四天
第二十四天 363 1:多线程(理解) 363 (1)JDK5以后的Lock锁 363 A:定义 363 B:方法: 364 C:具体应用(以售票程序为例) 364 ...
随机推荐
- js 去除左右空格
/*****************************************************Method1*************************************** ...
- react-redux笔记
用vuex来对比来说明 分类 vuex redux react-redux 写state commit mutation (mutable state) dispatch reducer (immut ...
- mvcmovie sample 在window10 下的部署问题(HTTP Error 500.19 - Internal Server Error)
mvcmovie sample 在window10 下的部署问题 使用VS2018配置好了mvcmovie sample,发布到IIS后,打开报错: HTTP Error 500.19 - Inter ...
- mongoDB工具类以及测试类【java】
java操作mongo工具类 package Utils; import com.mongodb.MongoClient; import com.mongodb.MongoCredential; im ...
- 我的第一个flutter程序
环境搭建好了之后,终于可以开始flutter的学习,废话少说先开始‘Hello World’. 创建好flutter项目之后,打开设备模拟器 打开之后 准备ok,开始编码 -------------- ...
- Oracle两个数据库联合查询,使用Oracle DBLink
创建dblink -- Create database link create shared database link COPYCITY_BZTOMY connect to db_A identif ...
- iOS如何转换十三位的时间戳
//将十三位的时间戳转换为日期 - (NSString *)getDate:(NSString *)jsonDate { //jsonDate类似这种/Date(1447659630000)/ NSA ...
- java Page分页显示
//entity层实体类 import java.util.List; //分页展示 //相关属性:当前页,页大小(每页显示的条数),总页数,总条数,数据 //select * from t_user ...
- Linux 系统状态检测命令
介绍快速查看Linux系统运行状态的能力(网络网卡.系统内核.系统负载.内存使用情况.启用终端数量.历史登录记录.命令执行记录.救援诊断)等命令使用方法 1.ifconfig 用于获取网卡配置和网络 ...
- MapReduce时mapping内存不足
17/11/07 16:53:50 INFO mapreduce.Job: Job job_1510042506570_0007 failed with state KILLED due to: MA ...