说明:
1) FSP 中heat对每种资源的校验方法会通过entry_points.txt(如/usr/lib64/python2.6/site-packages/heat-2014.2-py2.6.egg-info/entry_points.txt)配置;
配置内容节选:
[heat.constraints]
nova.flavor = heat.engine.resources.server:FlavorConstraint
nova.keypair = heat.engine.resources.nova_keypair:KeypairConstraint
cinder.volume = heat.engine.clients.os.cinder:VolumeConstraint
iso_8601 = heat.engine.resources.iso_8601:ISO8601Constraint
neutron.network = heat.engine.clients.os.neutron:NetworkConstraint
neutron.port = heat.engine.clients.os.neutron:PortConstraint
neutron.router = heat.engine.clients.os.neutron:RouterConstraint
cinder.vtype = heat.engine.clients.os.cinder:VolumeTypeConstraint
neutron.subnet = heat.engine.clients.os.neutron:SubnetConstraint
glance.image = heat.engine.clients.os.glance:ImageConstraint
cinder.snapshot = heat.engine.clients.os.cinder:VolumeSnapshotConstraint
2) 在server(虚拟机)资源类BDM参数校验或是volume(卷)资源类中都会配置校验方法引用key为cinder.volume; 配置文件中并配置cinder.volume 为heat.engine.clients.os.cinder的VolumeContstrait方法
server BDM参数代码节选(heat/engine/resources/server.py):
BLOCK_DEVICE_MAPPING_VOLUMEID: properties.Schema(
properties.Schema.STRING,
('The ID of the volume to boot from. Only one '
'of volume_id or snapshot_id should be '
'provided.'),
constraints=[
constraints.CustomConstraint('cinder.volume')
]
)
Volume 资源代码节选(heat/engine/resources/volume.py):
SOURCEVOLID: properties.Schema(
properties.Schema.STRING,
('If specified, the volume to use as source.'),
constraints=[
constraints.CustomConstraint('cinder.volume')
]
)
3) 在heat/engine/clients/os/cinder 中没有VolumeConstraint校验方法;而在开源版本中已加入;即配置文件中配置的方法在代码中不存在
3.一致性组查询时,fsp 把一致性组关联的volume type 在api返回时处理掉了;开源版本有
Fsp 查询一致性组后信息返回处理方法(cinder.api.views.consistencygroups.py):
def detail(self, request, consistencygroup):
"""Detailed view of a single consistency group."""
return {
'consistencygroup': {
'id': consistencygroup.get('id'),
'status': consistencygroup.get('status'),
'availability_zone': consistencygroup.get('availability_zone'),
'created_at': consistencygroup.get('created_at'),
'name': consistencygroup.get('name'),
'description': consistencygroup.get('description')
}
}
源生openstack代码(cinder.api.views.consistencygroups.py):
def detail(self, request, consistencygroup):
"""Detailed view of a single consistency group."""
if consistencygroup.volume_type_id:
volume_types = consistencygroup.volume_type_id.split(",")
volume_types = [type_id for type_id in volume_types if type_id]
else:
volume_types = []
novaclient v1_1/servers create方法镜像参数是对象,heat调用时传递的是string: 修改novaclient/v1_1/servers.py 中的if image分支: 改为: if image: if isinstance(image, six.string_types): uuid = image else: uuid = image.id
说明: 1) FSP 中heat对每种资源的校验方法会通过entry_points.txt(如/usr/lib64/python2.6/site-packages/heat-2014.2-py2.6.egg-info/entry_points.txt)配置; 配置内容节选: [heat.constraints] nova.flavor = heat.engine.resources.server:FlavorConstraint nova.keypair = heat.engine.resources.nova_keypair:KeypairConstraint cinder.volume = heat.engine.clients.os.cinder:VolumeConstraint iso_8601 = heat.engine.resources.iso_8601:ISO8601Constraint neutron.network = heat.engine.clients.os.neutron:NetworkConstraint neutron.port = heat.engine.clients.os.neutron:PortConstraint neutron.router = heat.engine.clients.os.neutron:RouterConstraint cinder.vtype = heat.engine.clients.os.cinder:VolumeTypeConstraint neutron.subnet = heat.engine.clients.os.neutron:SubnetConstraint glance.image = heat.engine.clients.os.glance:ImageConstraint cinder.snapshot = heat.engine.clients.os.cinder:VolumeSnapshotConstraint 2) 在server(虚拟机)资源类BDM参数校验或是volume(卷)资源类中都会配置校验方法引用key为cinder.volume; 配置文件中并配置cinder.volume 为heat.engine.clients.os.cinder的VolumeContstrait方法 server BDM参数代码节选(heat/engine/resources/server.py): BLOCK_DEVICE_MAPPING_VOLUMEID: properties.Schema( properties.Schema.STRING, ('The ID of the volume to boot from. Only one ' 'of volume_id or snapshot_id should be ' 'provided.'), constraints=[ constraints.CustomConstraint('cinder.volume') ] )
Volume 资源代码节选(heat/engine/resources/volume.py): SOURCEVOLID: properties.Schema( properties.Schema.STRING, ('If specified, the volume to use as source.'), constraints=[ constraints.CustomConstraint('cinder.volume') ] ) 3) 在heat/engine/clients/os/cinder 中没有VolumeConstraint校验方法;而在开源版本中已加入;即配置文件中配置的方法在代码中不存在
3.一致性组查询时,fsp 把一致性组关联的volume type 在api返回时处理掉了;开源版本有 Fsp 查询一致性组后信息返回处理方法(cinder.api.views.consistencygroups.py): def detail(self, request, consistencygroup): """Detailed view of a single consistency group.""" return { 'consistencygroup': { 'id': consistencygroup.get('id'), 'status': consistencygroup.get('status'), 'availability_zone': consistencygroup.get('availability_zone'), 'created_at': consistencygroup.get('created_at'), 'name': consistencygroup.get('name'), 'description': consistencygroup.get('description') } } 源生openstack代码(cinder.api.views.consistencygroups.py): def detail(self, request, consistencygroup): """Detailed view of a single consistency group.""" if consistencygroup.volume_type_id: volume_types = consistencygroup.volume_type_id.split(",") volume_types = [type_id for type_id in volume_types if type_id] else: volume_types = []
源生openstack查询type详细信息时,可以获取关联的qos ID(见qos_specs_id) curl -g -i -X GET http://162.3.140.132:8776/v2/90a30fdd68684a9daf89d5048ef142eb/types/902ff375-8fc9-402a-a9d5-daa3068003cd -H "User-Agent: python-cinderclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}38df46a9df0a1400d25d22fbde61927c2ae5ab77" RESP BODY: {"volume_type": {"name": "type-test", "qos_specs_id": "dbdcefdf-d8e5-4fd8-b059-98d8a261c0d4", "extra_specs": {}, "os-volume-type-access:is_public": true, "is_public": true, "id": "902ff375-8fc9-402a-a9d5-daa3068003cd", "description": null}}
代码对比: Fsp 代码: Cinder/api/views/types show方法 :
源生openstack: Cinder/api/v2/views/types show方法: def show(self, request, volume_type, brief=False): """Trim away extraneous volume type attributes.""" context = request.environ['cinder.context'] trimmed = dict(id=volume_type.get('id'), name=volume_type.get('name'), is_public=volume_type.get('is_public'), description=volume_type.get('description')) if context.is_admin: trimmed['qos_specs_id'] = volume_type.get('qos_specs_id') trimmed['extra_specs'] = volume_type.get('extra_specs') return trimmed if brief else dict(volume_type=trimmed)