Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
python3-dmapi / usr / lib / python3 / dist-packages / dmapi / cmd / __pycache__ / status.cpython-35.pyc
Size: Mime:


çáþ\Vsã@scdZddlmZddlZddlZddlZddlZddlZddlZddl	m
Zddlm
Z
ddlmZddlZddlZddlmZddlmZmZmZmZdd	lmZdd
lmZddlZddlm Z ddlm!Z"dd
l#m$Z%ddl&m'Z'ddl(m)Z*ddl(m+Z+ddlm,Z,ddlm-Z-ej.j/Z/dZ0Gdd„dej1ƒZ2e2j3e'dƒe2j4e'dƒe2j5e'dƒiZ6Gdd„de7ƒZ8Gdd„de7ƒZ9de9iZ:ej;ej<de:ƒZ<e
j=dd d!d"d#d$e<ƒZ>d%d&„Z?dS)'z)
CLI interface for nova status commands.
é)Úprint_functionN)Ú
exceptions)Úcfg)Ú	jsonutils)Úfunc)ÚMetaDataÚTableÚand_Úselect)Úfalse)Úcommon)Úconfig)Úcontext)Úapi)Ú_)Úcell_mapping)Úfields)Úutils)Úversionz:https://docs.openstack.org/nova/latest/user/placement.htmlc@s(eZdZdZdZdZdZdS)ÚUpgradeCheckCodezjThese are the status codes for the nova-status upgrade check command
    and internal check commands.
    rééN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚSUCCESSÚWARNINGÚFAILURE©rrú2/usr/lib/python3/dist-packages/dmapi/cmd/status.pyr,srZSuccessÚWarningZFailurecs+eZdZdZd‡fdd†Z‡S)ÚUpgradeCheckResultaTClass used for 'nova-status upgrade check' results.

    The 'code' attribute is an UpgradeCheckCode enum.
    The 'details' attribute is a translated message generally only used for
    checks that result in a warning or failure code. The details should provide
    information on what issue was discovered along with any remediation.
    Ncs)tt|ƒjƒ||_||_dS)N)Úsuperr"Ú__init__ÚcodeÚdetails)Úselfr%r&)Ú	__class__rr r$Ns	zUpgradeCheckResult.__init__)rrrrr$rr)r(r r"Esr"c@seZdZdZddd„Zdd„Zedd„ƒZd	d
„Zedd„ƒZ	ed
d„ƒZ
dd„Zedd„ƒZdd„Z
dd„Zdd„Zedƒefedƒefedƒefedƒe
fedƒeffZdd„Zd d!„ZdS)"ÚUpgradeCommandsaCommands related to upgrades.

    The subcommands here must not rely on the nova object model since they
    should be able to run on n-1 data. Any queries to the database should be
    done through the sqlalchemy query language directly like the database
    schema migrations.
    NcCsRtdtjd|ƒƒ}td|ddƒ}ttjƒgƒj|ƒjƒS)z9Returns the number of compute nodes in the cell database.ÚbindrÚ
compute_nodesÚautoloadT)	rÚ
db_sessionÚ
get_enginerr
ÚsqlfuncÚcountÚselect_fromÚscalar)r'rÚmetar+rrr Ú_count_compute_nodes]sz$UpgradeCommands._count_compute_nodescCs‚tƒ}tjƒ|_td|ddƒ}ttjƒgƒj|ƒj	ƒ}|dkryt
dƒ}ttj
|ƒSttjƒgƒj|ƒj|jjtjjkƒj	ƒ}|dkràt
dƒ}ttj
|ƒStd|ddƒ}ttjƒgƒj|ƒj	ƒ}|d	kru|jƒ}|d	krYt
d
ƒ}ttj
|ƒSt
dƒ}ttj|ƒSttjƒS)aDChecks to see if cells v2 has been setup.

        These are the same checks performed in the 030_require_cell_setup API
        DB migration except we expect this to be run AFTER the
        nova-manage cell_v2 simple_cell_setup command, which would create the
        cell and host mappings and sync the cell0 database schema, so we don't
        check for flavors at all because you could create those after doing
        this on an initial install. This also has to be careful about checking
        for compute nodes if there are no host mappings on a fresh install.
        Ú
cell_mappingsr,TrzœThere needs to be at least two cell mappings, one for cell0 and one for your first cell. Run command 'nova-manage cell_v2 simple_cell_setup' and then retry.rz[No cell0 mapping found. Run command 'nova-manage cell_v2 simple_cell_setup' and then retry.Ú
host_mappingsrzwNo host mappings found but there are compute nodes. Run command 'nova-manage cell_v2 simple_cell_setup' and then retry.zNo host mappings or compute nodes were found. Remember to run command 'nova-manage cell_v2 discover_hosts' when new compute hosts are deployed.)rr-Úget_api_enginer*rr
r/r0r1r2rr"rrÚwhereÚcÚuuidÚcell_mapping_objÚCellMappingÚ
CELL0_UUIDr4r)r'r3r5r0Úmsgr6Únum_computesrrr Ú_check_cellsv2rs.	$	$zUpgradeCommands._check_cellsv2cCs"tjdƒ}|j|ƒjƒS)z“Do an HTTP get call against placement engine.

        This is in a dedicated method to make it easier for unit
        testing purposes.

        Z	placement)rZget_ksa_adapterÚgetÚjson)ÚpathÚclientrrr Ú_placement_get©szUpgradeCommands._placement_getcCsvyu|jdƒ}tj|dddƒ}tjdƒ}||krttdƒd|d|i}ttj|ƒSWnñtjk
r¨td	ƒ}ttj|ƒSYnÁtj	k
rØtd
ƒ}ttj|ƒSYn‘tj
k
rtdƒ}ttj|ƒSYnatjk
r8tdƒ}ttj|ƒSYn1tjk
rhtd
ƒ}ttj|ƒSYnXttj
ƒS)zÑChecks to see if the placement API is ready for scheduling.

        Checks to see that the placement API service is registered in the
        service catalog and that we can make requests against it.
        ú/ÚversionsrÚmax_versionz1.17z>Placement API version %(needed)s needed, you have %(current)s.ÚneededÚcurrentz8No credentials specified for placement API in nova.conf.z*Placement service credentials do not work.z!Placement API endpoint not found.z'Discovery for placement API URI failed.z*Placement API does not seem to be running.)rEÚ
pkg_resourcesÚ
parse_versionrr"rrÚks_excZMissingAuthPluginÚUnauthorizedZEndpointNotFoundZDiscoveryFailureZNotFoundr)r'rGrHZ
needs_versionr>rrr Ú_check_placement´s2	z UpgradeCommands._check_placementcCs|tjjjtjjƒ}tdtjƒƒ}td|ddƒ}t	t
jƒgƒj|ƒj
|jj|kƒjƒS)a/Returns the number of compute resource providers in the API database

        The resource provider count is filtered based on resource providers
        which have inventories records for the VCPU resource class, which is
        assumed to only come from the ResourceTracker in compute nodes.
        r*Úinventoriesr,T)rZ
ResourceClassZSTANDARDÚindexZVCPUrr-r7rr
r/r0r1r8r9Zresource_class_idr2)Z
vcpu_rc_idr3rPrrr Ú!_count_compute_resource_providersÛs	z1UpgradeCommands._count_compute_resource_providerscCs[tdtjƒƒ}td|ddƒ}|jƒj|jjtj	j
kƒjƒjƒS)z5Queries the API database for non-cell0 cell mappings.r*r5r,T)
rr-r7rr
r8r9r:r;r<r=ÚexecuteÚfetchall)r3r5rrr Ú_get_non_cell0_mappingsôs
	z'UpgradeCommands._get_non_cell0_mappingscCs/|jƒ}|jƒ}tjƒ}d}xI|D]5}tj||ƒ}||j|ƒ7}WdQRXq1W|jƒ}|dkrà|dkrºtdƒd|dti}tt	j
|ƒStdƒdti}tt	j|ƒS||krtdƒd|d	|dti}tt	j
|ƒStt	jƒSdS)
aFChecks the status of resource provider reporting.

        This check relies on the cells v2 check passing because it queries the
        cells for compute nodes using cell mappings.

        This check relies on the placement service running because if it's not
        then there won't be any resource providers for the filter scheduler to
        use during instance build and move requests.

        Note that in Ocata, the filter scheduler will only use placement if
        the minimum nova-compute service version in the deployment is >= 16
        which signals when nova-compute will fail to start if placement is not
        configured on the compute. Otherwise the scheduler will fallback
        to pulling compute nodes from the database directly as it has always
        done. That fallback will be removed in Pike.
        rNaThere are no compute resource providers in the Placement service but there are %(num_computes)s compute nodes in the deployment. This means no compute nodes are reporting into the Placement service and need to be upgraded and/or fixed. See %(placement_docs_link)s for more details.r?Zplacement_docs_linkzéThere are no compute resource providers in the Placement service nor are there compute nodes in the database. Remember to configure new compute nodes to report into the Placement service. See %(placement_docs_link)s for more details.a4There are %(num_resource_providers)s compute resource providers and %(num_compute_nodes)s compute nodes in the deployment. Ideally the number of compute resource providers should equal the number of enabled compute nodes otherwise the cloud may be underutilized. See %(placement_docs_link)s for more details.Znum_resource_providersZnum_compute_nodes)rRrUÚnova_contextÚget_admin_contextÚtarget_cellr4rÚPLACEMENT_DOCS_LINKr"rrr)r'Znum_rpsr5Úctxtr?rÚcctxtr>rrr Ú_check_resource_providersýs0
	
	
	
z)UpgradeCommands._check_resource_providerscCs|jƒj|jj|dkƒjƒjƒ}tj|dƒdd}d|krb|dni}x!|D]}|jdƒrodSqoWdS)	Nr:ÚflavorÚcurznova_object.dataZextra_specszresources:CUSTOM_TF)	r
r8r9Z
instance_uuidrSÚfirstrÚloadsÚ
startswith)ÚextrasÚinstÚextrar]ÚspecsZspec_keyrrr Ú_is_ironic_instance_migratedSs1
z,UpgradeCommands._is_ironic_instance_migratedcs|jƒ}tjƒ}tjtƒ‰x^|D]V}tj||ƒ;}tdtj	d|ƒƒ}t
d|ddƒ}|jƒjt
|jjdk|jjdkƒƒjƒjƒ}|r}t
d|ddƒ}t
d	|ddƒ}	x|D]‡}
|
d
}|jƒjt
|jj|k|jjdkƒƒjƒjƒ}x2|D]*}
|j|	|
ƒsKˆ|dd7<qKWqòWWd
QRXq.W|sªtdƒ}ttj|ƒSˆrøtdƒdj‡fdd†tˆjƒƒDƒƒ}ttj|ƒSttjƒS)aEIn Pike, ironic instances and flavors need to be migrated to use
        custom resource classes. In ironic, the node.resource_class should be
        set to some custom resource class value which should match a
        "resources:<custom resource class name>" flavor extra spec on baremetal
        flavors. Existing ironic instances will have their embedded
        instance.flavor.extra_specs migrated to use the matching ironic
        node.resource_class value in the nova-compute service, or they can
        be forcefully migrated using "nova-manage db ironic_flavor_migration".

        In this check, we look for all ironic compute nodes in all non-cell0
        cells, and from those ironic compute nodes, we look for an instance
        that has a "resources:CUSTOM_*" key in it's embedded flavor extra
        specs.
        r*rr+r,TZironicrÚ	instancesZinstance_extraZhypervisor_hostnamer:rNzBUnable to determine ironic flavor migration without cell mappings.z~There are (cell=x) number of unmigrated instances in each cell: %s. Run 'nova-manage db ironic_flavor_migration' on each cell.ú c3s#|]}d|ˆ|fVqdS)z(%s=%s)Nr)Ú.0Zcell_id)Ú!unmigrated_instance_count_by_cellrr ú	<genexpr>§szAUpgradeCommands._check_ironic_flavor_migration.<locals>.<genexpr>)rUrVrWÚcollectionsÚdefaultdictÚintrXrr-r.rr
r8r	r9Zhypervisor_typeÚdeletedrSrTÚnoderfrr"rrÚjoinÚsortedÚkeysrr)r'r5rZrr[r3r+Zironic_nodesrgrbrpÚnodenameZironic_instancesrcr>r)rjr Ú_check_ironic_flavor_migrationcs@
$

$
"	z.UpgradeCommands._check_ironic_flavor_migrationcCs—tdtjd|ƒƒ}td|ddƒ}ttj|jjƒgƒj	|ƒj
t|jj|k|jj
dk|jjtƒkƒƒjƒS)Nr*rÚservicesr,Tr)rr-r.rr
r/Úminr9rr1r8r	ÚbinaryroZforced_downrr2)r'rrxr3rvrrr Ú_get_min_service_version±sz(UpgradeCommands._get_min_service_versionc
Cs3tjjrttjƒStdtjƒƒ}t	d|ddƒ}|j
ƒjƒjƒ}|s}t
dƒ}ttj|ƒStjƒ}g}xe|D]]}tj||ƒB}|j|dƒ}	|	dk	rì|	dkrì|j|d	ƒWdQRXq–W|r&t
d
ƒdj|ƒ}ttj|ƒSttjƒS)aûChecks nova-osapi_compute service versions across cells.

        For non-cellsv1 deployments, based on how the [database]/connection
        is configured for the nova-api service, the nova-osapi_compute service
        versions before 15 will only attempt to lookup instances from the
        local database configured for the nova-api service directly.

        This can cause issues if there are newer API service versions in cell1
        after the upgrade to Ocata, but lingering older API service versions
        in an older database.

        This check will scan all cells looking for a minimum nova-osapi_compute
        service version less than 15 and if found, emit a warning that those
        service entries likely need to be cleaned up.
        r*r5r,Tz?Unable to determine API service versions without cell mappings.znova-osapi_computeNér:aWThe following cells have 'nova-osapi_compute' services with version < 15 which may cause issues when querying instances from the API: %s. Depending on how nova-api is configured, this may not be a problem, but is worth investigating and potentially cleaning up those older records. See https://bugs.launchpad.net/nova/+bug/1759316 for details.z, )ÚCONFÚcellsÚenabler"rrrr-r7rr
rSrTrrrVrWrXryÚappendrq)
r'r3r5Zmappingsr>rZZcells_with_old_api_servicesÚmappingr[Úmin_versionrrr Ú_check_api_service_versionºs*

	z*UpgradeCommands._check_api_service_versionzCells v2z
Placement APIzResource ProviderszIronic Flavor MigrationzAPI Service VersioncCs5|jdk	r1djtj|jdddƒƒSdS)NÚ
é<Úsubsequent_indentz  )r&rqÚtextwrapÚwrap)r'Zupgrade_check_resultrrr Ú_get_details	szUpgradeCommands._get_detailsc	Csñtj}g}xN|jD]C\}}||ƒ}|j||fƒ|j|kr|j}qWtjtdƒgdtjƒ}d|_	xV|D]N\}}tdƒd|dt
|jd|j|ƒi}|j|gƒq‘Wt
|ƒ|S)aPerforms checks to see if the deployment is ready for upgrade.

        These checks are expected to be run BEFORE services are restarted with
        new code. These checks also require access to potentially all of the
        Nova databases (nova, nova_api, nova_api_cell0) and external services
        such as the placement API service.

        :returns: UpgradeCheckCode
        zUpgrade Check ResultsZhrulesÚlz7Check: %(name)s
Result: %(result)s
Details: %(details)sÚnameÚresultr&)rrÚ_upgrade_checksr~r%ÚprettytableZPrettyTablerZALLZalignÚUPGRADE_CHECK_MSG_MAPr‡Zadd_rowÚprint)r'Zreturn_codeZ
check_resultsr‰rrŠÚtÚcellrrr Úchecks$
	
		

zUpgradeCommands.check)rrrrr4r@ÚstaticmethodrErOrRrUr\rfruryrrr‹r‡r‘rrrr r)Ts&7'	VN	Dr)ÚupgradeÚ
categoriesÚcategoryÚtitlezCommand categoriesÚhelpzAvailable categoriesÚhandlercCsÉtjtƒtjtjƒtjjdkrCt	t
jƒƒdStjjdkrftj
tƒdSy,tjƒ\}}}|||Ž}|SWn0tk
rÄt	tdƒtjƒƒdSYnXdS)z4Parse options and call the appropriate class/method.rrzbash-completionz	Error:
%séÿN)r{Zregister_cli_optÚcategory_optr
Ú
parse_argsÚsysÚargvr•r‰rŽrZversion_string_with_packageÚ
cmd_commonZprint_bash_completionÚ
CATEGORIESZ
get_action_fnÚ	ExceptionrÚ	tracebackÚ
format_exc)ÚfnZfn_argsZ	fn_kwargsÚretrrr ÚmainTs


r¥)@rÚ
__future__rrlÚenumÚ	functoolsrœr…r¡Z
keystoneauth1rrMZoslo_configrZoslo_serializationrrKrŒZ
sqlalchemyrr/rrr	r
Zsqlalchemy.sqlrZnova.cmdrržZ	nova.confZnovar
rrVZnova.db.sqlalchemyrr-Z	nova.i18nrZnova.objectsrr;rrrÚconfr{rYÚIntEnumrrrrrÚobjectr"r)rŸÚpartialZadd_command_parsersZ
SubCommandOptršr¥rrrr Ú<module>sT"ÿó