測(cè)試環(huán)境:3個(gè)計(jì)算節(jié)點(diǎn),分別屬于3個(gè)zone
為丹徒等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及丹徒網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都做網(wǎng)站、網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、丹徒網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專(zhuān)業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)![root@controller2 ~(keystone_admin)]# nova availability-zone-list
+-----------------------+----------------------------------------+
| Name | Status |
+-----------------------+----------------------------------------+
| internal | available |
| |- controller2 | |
| | |- nova-conductor | enabled :-) 2016-08-20T14:57:07.000000 |
| | |- nova-scheduler | enabled :-) 2016-08-20T14:57:06.000000 |
| | |- nova-consoleauth | enabled :-) 2016-08-20T14:57:08.000000 |
| | |- nova-cert | enabled :-) 2016-08-20T14:57:07.000000 |
| nova | available |
| |- controller3 | |
| | |- nova-compute | enabled :-) 2016-08-20T14:57:04.000000 |
| ag1 | available |
| |- controller1 | |
| | |- nova-compute | enabled :-) 2016-08-19T23:41:45.000000 |
| ag2 | available |
| |- controller2 | |
| | |- nova-compute | enabled :-) 2016-08-20T14:57:06.000000 |
+-----------------------+----------------------------------------+
測(cè)試方式: 啟動(dòng)虛擬機(jī)的時(shí)候選擇Booting from p_w_picpath(creates a new volume)測(cè)試
產(chǎn)生的原因: cinder無(wú)法識(shí)別nova的多zone,cinder能獲取的zone信息有:
1、cinder-volume所在的zone
2、cinder.conf配置文件中的兩個(gè)參數(shù)storage_availability_zone = nova和default_availability_zone = nova
大致過(guò)下代碼調(diào)用過(guò)程:(從nova那邊調(diào)用cinder那部分開(kāi)始)
1、nova/virt/block_device.py -> class DriverImageBlockDevice def attach vol = volume_api.create
2、nova/volume/cinder.py -> class API def create item = client.volumes.create
3、cinder/api/v2/volumes.py -> class VolumeController def create new_volume = self.volume_api.create
4、cinder/volume/api.py -> class API def create flow_engine = create_volume.get_flow
在create函數(shù)中cinder獲取能獲得到的zone的信息:
raw_zones = self.list_availability_zones(enable_cache=True)
availability_zones = set([az['name'] for az in raw_zones])
if CONF.storage_availability_zone:
availability_zones.add(CONF.storage_availability_zone)
def list_availability_zones services = objects.ServiceList.get_all_by_topic ->
cinder/objects/service.py(def get_all_by_topic) db.service_get_all_by_topic ->
cinder/db/api.py(def service_get_all_by_topic) IMPL.service_get_all_by_topic ->
cinder/db/sqlalchemy/api.py(def service_get_all_by_topic)
@require_admin_context def service_get_all_by_topic(context, topic, disabled=None): query = model_query( context, models.Service, read_deleted="no").\ # models在這里cinder/db/sqlalchemy/models.py filter_by(topic=topic) # topic默認(rèn)傳過(guò)來(lái)的是cinder-volume if disabled is not None: query = query.filter_by(disabled=disabled) return query.all()
查詢數(shù)據(jù)庫(kù)找出cinder-volume所在的zone
5、cinder/volume/flows/api/create_volume.py -> def get_flow
# 這里是taskflow,只需關(guān)注add方法里面的東東 def get_flow(db_api, p_w_picpath_service_api, availability_zones, create_what, scheduler_rpcapi=None, volume_rpcapi=None): """Constructs and returns the api entrypoint flow. This flow will do the following: 1. Inject keys & values for dependent tasks. 2. Extracts and validates the input keys & values. 3. Reserves the quota (reverts quota on any failures). 4. Creates the database entry. 5. Commits the quota. 6. Casts to volume manager or scheduler for further processing. """ flow_name = ACTION.replace(":", "_") + "_api" api_flow = linear_flow.Flow(flow_name) api_flow.add(ExtractVolumeRequestTask( p_w_picpath_service_api, availability_zones, rebind={'size': 'raw_size', 'availability_zone': 'raw_availability_zone', 'volume_type': 'raw_volume_type'})) api_flow.add(QuotaReserveTask(), EntryCreateTask(db_api), QuotaCommitTask()) if scheduler_rpcapi and volume_rpcapi: # This will cast it out to either the scheduler or volume manager via # the rpc apis provided. api_flow.add(VolumeCastTask(scheduler_rpcapi, volume_rpcapi, db_api)) # Now load (but do not run) the flow using the provided initial data. return taskflow.engines.load(api_flow, store=create_what)
我們關(guān)心的在class ExtractVolumeRequestTask里
先看下入口execute方法,為什么看execute方法,你翻下taskflow怎么用的,就懂了
def execute(self, context, size, snapshot, p_w_picpath_id, source_volume, availability_zone, volume_type, metadata, key_manager, source_replica, consistencygroup, cgsnapshot): utils.check_exclusive_options(snapshot=snapshot, p_w_picpathRef=p_w_picpath_id, source_volume=source_volume) policy.enforce_action(context, ACTION) # TODO(harlowja): what guarantee is there that the snapshot or source # volume will remain available after we do this initial verification?? snapshot_id = self._extract_snapshot(snapshot) source_volid = self._extract_source_volume(source_volume) source_replicaid = self._extract_source_replica(source_replica) size = self._extract_size(size, source_volume, snapshot) consistencygroup_id = self._extract_consistencygroup(consistencygroup) cgsnapshot_id = self._extract_cgsnapshot(cgsnapshot) self._check_p_w_picpath_metadata(context, p_w_picpath_id, size) availability_zone = self._extract_availability_zone(availability_zone, # 關(guān)心的在這里 snapshot, source_volume) # _extract_availability_zone函數(shù) def _extract_availability_zone(self, availability_zone, snapshot, source_volume): """Extracts and returns a validated availability zone. This function will extract the availability zone (if not provided) from the snapshot or source_volume and then performs a set of validation checks on the provided or extracted availability zone and then returns the validated availability zone. """ # Try to extract the availability zone from the corresponding snapshot # or source volume if either is valid so that we can be in the same # availability zone as the source. if availability_zone is None: if snapshot: try: availability_zone = snapshot['volume']['availability_zone'] except (TypeError, KeyError): pass if source_volume and availability_zone is None: try: availability_zone = source_volume['availability_zone'] except (TypeError, KeyError): pass if availability_zone is None: if CONF.default_availability_zone: # default_availability_zone判斷 availability_zone = CONF.default_availability_zone else: # For backwards compatibility use the storage_availability_zone availability_zone = CONF.storage_availability_zone if availability_zone not in self.availability_zones: # self.availability_zones就是上述cinder-volume的zone外加cinder.conf中兩個(gè)配置參數(shù) if CONF.allow_availability_zone_fallback: # allow_availability_zone_fallback這個(gè)很關(guān)鍵 original_az = availability_zone availability_zone = ( CONF.default_availability_zone or CONF.storage_availability_zone) LOG.warning(_LW("Availability zone '%(s_az)s' " "not found, falling back to " "'%(s_fallback_az)s'."), {'s_az': original_az, 's_fallback_az': availability_zone}) else: msg = _("Availability zone '%(s_az)s' is invalid.") msg = msg % {'s_az': availability_zone} raise exception.InvalidInput(reason=msg) # 沒(méi)啟動(dòng)allow_availability_zone_fallback的話,就拋異常了
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
當(dāng)前文章:novabootfromvolume在多主機(jī)zone下的坑-創(chuàng)新互聯(lián)
當(dāng)前鏈接:http://aaarwkj.com/article10/pjcdo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、企業(yè)建站、網(wǎng)站制作、網(wǎng)站改版、定制開(kāi)發(fā)、全網(wǎng)營(yíng)銷(xiāo)推廣
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容