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    
dmapi / usr / lib / python2.7 / dist-packages / dmapi / cmd / status.pyc
Size: Mime:
ó
ªÿ^c@sddZddlmZddlZddlZddlZddlZddlZddlZddl	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/dZ0dej1fd„ƒYZ2ie'dƒe2j36e'dƒe2j46e'dƒe2j56Z6de7fd„ƒYZ8de7fd„ƒYZ9ie9d6Z:ej;ej<de:ƒZ<e
j=dd d!d"d#d$e<ƒZ>d%„Z?dS(&s)
CLI interface for nova status commands.
iÿÿÿÿ(tprint_functionN(t
exceptions(tcfg(t	jsonutils(tfunc(tMetaDatatTabletand_tselect(tfalse(tcommon(tconfig(tcontext(tapi(t_(tcell_mapping(tfields(tutils(tversions:https://docs.openstack.org/nova/latest/user/placement.htmltUpgradeCheckCodecBs eZdZdZdZdZRS(sjThese are the status codes for the nova-status upgrade check command
    and internal check commands.
    iii(t__name__t
__module__t__doc__tSUCCESStWARNINGtFAILURE(((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyR,stSuccesstWarningtFailuretUpgradeCheckResultcBseZdZdd„ZRS(sTClass 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.
    cCs)tt|ƒjƒ||_||_dS(N(tsuperRt__init__tcodetdetails(tselfR R!((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyRNs	N(RRRtNoneR(((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyREstUpgradeCommandscBsïeZdZdd„Zd„Zed„ƒZd„Zed„ƒZ	ed„ƒZ
d„Zed„ƒZd	„Z
d
„Zd„Zedƒefed
ƒefedƒefedƒe
fedƒeffZd„Zd„ZRS(sCommands 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.
    cCsRtdtjd|ƒƒ}td|dtƒ}ttjƒgƒj|ƒj	ƒS(s9Returns the number of compute nodes in the cell database.tbindRt
compute_nodestautoload(
Rt
db_sessiont
get_engineRtTrueRtsqlfunctcounttselect_fromtscalar(R"RtmetaR&((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_count_compute_nodes]scCs‚tƒ}tjƒ|_td|dtƒ}ttjƒgƒj	|ƒj
ƒ}|dkrytdƒ}tt
j|ƒSttjƒgƒj	|ƒj|jjtjjkƒj
ƒ}|dkràtdƒ}tt
j|ƒStd|dtƒ}ttjƒgƒj	|ƒj
ƒ}|dkru|jƒ}|dkrYtd	ƒ}tt
j|ƒStd
ƒ}tt
j|ƒStt
jƒS(sDChecks 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.
        t
cell_mappingsR'isœ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.is[No cell0 mapping found. Run command 'nova-manage cell_v2 simple_cell_setup' and then retry.t
host_mappingsiswNo host mappings found but there are compute nodes. Run command 'nova-manage cell_v2 simple_cell_setup' and then retry.s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(tget_api_engineR%RR*RR+R,R-R.RRRRtwheretctuuidtcell_mapping_objtCellMappingt
CELL0_UUIDR0R(R"R/R1R,tmsgR2tnum_computes((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_check_cellsv2rs.	$	$cCs"tjdƒ}|j|ƒjƒS(s“Do an HTTP get call against placement engine.

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

        t	placement(Rtget_ksa_adaptertgettjson(tpathtclient((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_placement_get©scCsdyw|jdƒ}tj|dddƒ}tjdƒ}||krvtdƒi|d6|d6}ttj|ƒSWnÝtjk
r¦td	ƒ}ttj|ƒStj	k
rÒtd
ƒ}ttj|ƒStj
k
rþtdƒ}ttj|ƒStjk
r*tdƒ}ttj|ƒStjk
rVtd
ƒ}ttj|ƒSXttj
ƒS(sÑ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.
        t/tversionsitmax_versions1.17s>Placement API version %(needed)s needed, you have %(current)s.tneededtcurrents8No credentials specified for placement API in nova.conf.s*Placement service credentials do not work.s!Placement API endpoint not found.s'Discovery for placement API URI failed.s*Placement API does not seem to be running.(RCt
pkg_resourcest
parse_versionRRRRtks_exctMissingAuthPlugintUnauthorizedtEndpointNotFoundtDiscoveryFailuretNotFoundR(R"RERFt
needs_versionR:((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_check_placement´s2	cCs|tjjjtjjƒ}tdtjƒƒ}td|dt	ƒ}t
tjƒgƒj
|ƒj|jj|kƒjƒS(s/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%tinventoriesR'(Rt
ResourceClasstSTANDARDtindextVCPURR(R3RR*RR+R,R-R4R5tresource_class_idR.(t
vcpu_rc_idR/RS((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt!_count_compute_resource_providersÛs	cCs[tdtjƒƒ}td|dtƒ}|jƒj|jjt	j
jkƒjƒj
ƒS(s5Queries the API database for non-cell0 cell mappings.R%R1R'(RR(R3RR*RR4R5R6R7R8R9texecutetfetchall(R/R1((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_get_non_cell0_mappingsôs
	cCs4|jƒ}|jƒ}tjƒ}d}xH|D]4}tj||ƒ}||j|ƒ7}WdQXq1W|jƒ}|dkrâ|dkr»tdƒi|d6td6}tt	j
|ƒStdƒitd6}tt	j|ƒS||kr#tdƒi|d6|d	6td6}tt	j
|ƒStt	jƒSdS(
sFChecks 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.
        iNsThere 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;tplacement_docs_linksé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.s4There 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.tnum_resource_providerstnum_compute_nodes(RZR]tnova_contexttget_admin_contextttarget_cellR0RtPLACEMENT_DOCS_LINKRRRR(R"tnum_rpsR1tctxtR;RtcctxtR:((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_check_resource_providersýs0
	
		
cCs|jƒj|jj|dkƒjƒjƒ}tj|dƒdd}d|krb|dni}x!|D]}|jdƒrot	SqoWt
S(NR6tflavortcursnova_object.datatextra_specssresources:CUSTOM_(RR4R5t
instance_uuidR[tfirstRtloadst
startswithR*tFalse(textrastinsttextraRitspecstspec_key((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_is_ironic_instance_migratedSs1
cs	|jƒ}tjƒ}tjtƒ‰xe|D]]}tj||ƒC}tdtj	d|ƒƒ}t
d|dtƒ}|jƒj
t|jjdk|jjdkƒƒjƒjƒ}|r…t
d|dtƒ}t
d|dtƒ}	x—|D]Œ}
|
d	}|jƒj
t|jj|k|jjdkƒƒjƒjƒ}x7|D]/}
|j|	|
ƒsKˆ|d
cd7<qKqKWqòWnWdQXq.W|s±td
ƒ}ttj|ƒSˆrütdƒdj‡fd†tˆjƒƒDƒƒ}ttj|ƒSttjƒS(sEIn 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%RR&R'tironicit	instancestinstance_extrathypervisor_hostnameR6iNsBUnable to determine ironic flavor migration without cell mappings.s~There are (cell=x) number of unmigrated instances in each cell: %s. Run 'nova-manage db ironic_flavor_migration' on each cell.t c3s#|]}d|ˆ|fVqdS(s(%s=%s)N((t.0tcell_id(t!unmigrated_instance_count_by_cell(s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pys	<genexpr>§s(R]RaRbtcollectionstdefaultdicttintRcRR(R)RR*RR4RR5thypervisor_typetdeletedR[R\tnodeRvRRRRtjointsortedtkeysRR(R"R1RfRRgR/R&tironic_nodesRxRqR„tnodenametironic_instancesRrR:((R~s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_check_ironic_flavor_migrationcs@
$

$
)	cCs—tdtjd|ƒƒ}td|dtƒ}ttj|jj	ƒgƒj
|ƒjt|jj
|k|jjdk|jjtƒkƒƒjƒS(NR%RtservicesR'i(RR(R)RR*RR+tminR5RR-R4RtbinaryRƒtforced_downR	R.(R"RRŽR/RŒ((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_get_min_service_version±sc
Cs5tjjrttjƒStdtjƒƒ}t	d|dt
ƒ}|jƒjƒj
ƒ}|s}tdƒ}ttj|ƒStjƒ}g}xg|D]_}tj||ƒE}|j|dƒ}	|	dk	rï|	dkrï|j|dƒnWdQXq–W|r(td	ƒd
j|ƒ}ttj|ƒSttjƒS(sû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%R1R's?Unable to determine API service versions without cell mappings.snova-osapi_computeiR6NsWThe 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.s, (tCONFtcellstenableRRRRR(R3RR*RR[R\RRRaRbRcRR#tappendR…(
R"R/R1tmappingsR:Rftcells_with_old_api_servicestmappingRgtmin_version((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_check_api_service_versionºs*

	sCells v2s
Placement APIsResource ProviderssIronic Flavor MigrationsAPI Service VersioncCs5|jdk	r1djtj|jdddƒƒSdS(Ns
i<tsubsequent_indents  (R!R#R…ttextwraptwrap(R"tupgrade_check_result((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt_get_details	scCs÷tj}g}xQ|jD]F\}}||ƒ}|j||fƒ|j|kr|j}qqWtjtdƒgdtjƒ}d|_	xY|D]Q\}}tdƒi|d6t
|jd6|j|ƒd6}|j|gƒq”Wt
|ƒ|S(s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
        sUpgrade Check Resultsthrulestls7Check: %(name)s
Result: %(result)s
Details: %(details)stnametresultR!(RRt_upgrade_checksR”R tprettytabletPrettyTableRtALLtaligntUPGRADE_CHECK_MSG_MAPRžtadd_rowtprint(R"treturn_codet
check_resultsR¡RR¢tttcell((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pytchecks&
			
N(RRRR#R0R<tstaticmethodRCRRRZR]RhRvR‹RR™RR£RžR¯(((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyR$Ts&	7	'		V	N			D	tupgradet
categoriestcategoryttitlesCommand categoriesthelpsAvailable categoriesthandlercCsÅtjtƒtjtjƒtjjdkrCt	t
jƒƒdStjjdkrftj
tƒdSy,tjƒ\}}}|||Ž}|SWn,tk
rÀt	tdƒtjƒƒdSXdS(s4Parse options and call the appropriate class/method.Risbash-completions	Error:
%siÿN(R‘tregister_cli_opttcategory_optRt
parse_argstsystargvR³R¡RªRtversion_string_with_packaget
cmd_commontprint_bash_completiont
CATEGORIESt
get_action_fnt	ExceptionRt	tracebackt
format_exc(tfntfn_argst	fn_kwargstret((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pytmainTs


(@Rt
__future__RRtenumt	functoolsRºR›RÂt
keystoneauth1RRKtoslo_configRtoslo_serializationRRIR¤t
sqlalchemyRR+RRRRtsqlalchemy.sqlR	tnova.cmdR
R½t	nova.conftnovaRRRatnova.db.sqlalchemyR
R(t	nova.i18nRtnova.objectsRR7RRRtconfR‘RdtIntEnumRRRRR¨tobjectRR$R¿tpartialtadd_command_parserst
SubCommandOptR¸RÈ(((s4/usr/lib/python2.7/dist-packages/dmapi/cmd/status.pyt<module>sX"ÿò