Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/broker/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/broker/registration.pyc

ó
ÍÿŠTc@sædZddlZddlmZddlmZddlmZddlm	Z	ddl
mZmZddl
mZd	efd
„ƒYZd„Zd„Zd
efd„ƒYZdefd„ƒYZdefd„ƒYZdS(sÍ
Handle client registration against the server.

When the service is started for the first time it connects to the server
as a new client without providing any identification credentials, and the
server replies with the available registration mechanisms. At this point
the machinery in this module will notice that we have no identification
credentials yet and that the server accepts registration messages, so it
will craft an appropriate one and send it out.
iÿÿÿÿN(tDeferred(t
get_juju_info(tis_valid_tag_list(tget_fqdn(tget_vm_infotget_container_info(tis_version_highertInvalidCredentialsErrorcBseZdZRS(sx
    Raised when an invalid account title and/or registration key
    is used with L{RegistrationManager.register}.
    (t__name__t
__module__t__doc__(((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyRscs+‡fd†}‡fd†}t||ƒS(Ncs|jjˆƒS(N(t_persisttget(tself(tname(sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyRscs|jjˆ|ƒdS(N(Rtset(R
tvalue(R(sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR"s(tproperty(RRR((RsA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pytpersist_propertyscs‡fd†}t|ƒS(Ncst|jˆƒS(N(tgetattrt_config(R
(R(sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR*s(R(RR((RsA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pytconfig_property(stIdentitycBskeZdZedƒZedƒZedƒZedƒZedƒZ	edƒZ
edƒZd„ZRS(	sfMaintains details about the identity of this Landscape client.

    @ivar secure_id: A server-provided ID for secure message exchange.
    @ivar insecure_id: Non-secure server-provided ID, mainly used with
        the ping server.
    @ivar computer_title: See L{BrokerConfiguration}.
    @ivar account_name: See L{BrokerConfiguration}.
    @ivar registration_password: See L{BrokerConfiguration}.
    @ivar tags: See L{BrokerConfiguration}

    @param config: A L{BrokerConfiguration} object, used to set the
        C{computer_title}, C{account_name} and C{registration_password}
        instance variables.
    s	secure-idsinsecure-idtcomputer_titletaccount_nametregistration_keyttagstaccess_groupcCs||_|jdƒ|_dS(Ntregistration(Rtroot_atR(R
tconfigtpersist((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyt__init__Is	(
RR	R
Rt	secure_idtinsecure_idRRRRRRR (((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR0stRegistrationHandlercBsbeZdZd
d„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d„Zd	„ZRS(sÉ
    An object from which registration can be requested of the server,
    and which will handle forced ID changes from the server.

    L{register} should be used to perform initial registration.
    cCsâ||_||_||_||_||_||_|jjd|jƒ|jjd|jƒ|jjd|j	ƒ|jj
d|jƒ|jj
d|jƒ|jj
d|j
ƒd|_||_d|_d|_dS(Ntrunspre-exchanges
exchange-donesset-ids
unknown-idR(Rt	_identityt_reactort	_exchanget_pingert_message_storetcall_ont_get_juju_datat_handle_pre_exchanget_handle_exchange_donetregister_messaget_handle_set_idt_handle_unknown_idt_handle_registrationtNonet_should_registert_fetch_asynct	_ec2_datat
_juju_data(R
Rtidentitytreactortexchangetpingert
message_storetfetch_async((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR Vs"						
			cCs>|j}|jrtSt|jo:|jo:|jjdƒƒS(Ntregister(R%R!tFalsetboolRRR)taccepts(R
tid((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pytshould_registerjs
		cCs;d|j_d|j_t|jƒj}|jjƒ|S(sô
        Attempt to register with the Landscape server.

        @return: A L{Deferred} which will either be fired with None if
            registration was successful or will fail with an
            L{InvalidCredentialsError} if not.
        N(	R2R%R!R"tRegistrationResponseR&tdeferredR'R9(R
tresult((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR=rs

cCs,t|jƒ}|dkrdS||_dS(sLoad Juju information.N(RRR2R6(R
t	juju_info((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR+€scCs*|jƒr&|jr&|jjƒndS(sMRegistered handler for the C{"exchange-done"} event.

        If we are not registered yet, schedule another message exchange.

        The first exchange made us accept the message type "register", so
        the next "pre-exchange" event will make L{_handle_pre_exchange}
        queue a registration message for delivery.
        N(RBR3R'R9(R
((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR-‡s	cCsÅ|jƒ|_|jsdS|j}|j}|sH|jjdƒdS|j}|j}|j}|j	j
ƒt|ƒs’d}t
jdƒnidd6tƒd6|d6|jd6|jd	6|d
6tƒd6tƒd6}|rò||d
<n|j	jƒ}|jrPt|dƒrPi|jdd6|jdd6|jdd6|d<nt|ƒrbdnd}|rxd|nd}	|rŽd|nd}
t
jd||
|	|fƒ|jj|ƒdS(sÈ
        An exchange is about to happen.  If we don't have a secure id already
        set, and we have the needed information available, queue a registration
        message with the server.
        Nsregistration-faileds'Invalid tags provided for registration.R=ttypethostnameRRtregistration_passwordRscontainer-infosvm-infoRs3.3senvironment-uuids
api-addressess
machine-ids	juju-infotwithtwithoutsand tags %s tsin access group '%s' u?Queueing message to register with account %r %s%s%s a password.(RBR3R%RR&tfireRRRR)tdelete_all_messagesRR2tloggingterrorRRRRtget_server_apiR6RR?tinfoR'tsend(R
R7RRtgroupRtmessaget
server_apit	with_wordt	with_tagst
with_group((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR,“sL						







cCs¡|j}|jr)tjd|jƒn|jdƒ|_|jdƒ|_tjd|jd|jƒtjd|jƒ|jj	dƒ|jj	dƒd	S(
s×Registered handler for the C{"set-id"} event.

        Record and start using the secure and insecure IDs from the given
        message.

        Fire C{"registration-done"} and C{"resynchronize-clients"}.
        sOverwriting secure_id with '%s'RAsinsecure-ids2Using new secure-id ending with %s for account %s.iöÿÿÿsUsing new secure-id: %ssregistration-donesresynchronize-clientsN(
R%R!RORRRR"RtdebugR&RM(R
RURA((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR/Øs			cCs'|ddkr#|jjdƒndS(NRRsunknown-accountsregistration-failed(R&RM(R
RU((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR1ìscCs©|j}|jdƒ}|dkr;tjd|jƒnXtjd|ƒ||jjkrqd|jj}nd|jj|f}||j_d|_d|_	dS(Nsclone-ofs,Client has unknown secure-id for account %s.sClient is clone of computer %ss
%s (clone)s%s (clone of %s)(
R%RR2RORRRRRR!R"(R
RURAtclonettitle((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR0ðs		
	N(
RR	R
R2R RBR=R+R-R,R/R1R0(((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR#Ns					E		RCcBs2eZdZd„Zd„Zd„Zd„ZRS(sµA helper for dealing with the response of a single registration request.

    @ivar deferred: The L{Deferred} that will be fired as per
        L{RegistrationHandler.register}.
    cCsI||_|jd|jƒ|_|jd|jƒ|_tƒ|_dS(Nsregistration-donesregistration-failed(R&R*t_donet_done_idt_failedt
_failed_idRRD(R
R8((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR 
s	cCs*|jj|jƒ|jj|jƒdS(N(R&tcancel_callR^R`(R
((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyt
_cancel_callsscCs|jjdƒ|jƒdS(N(RDtcallbackR2Rb(R
((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR]scCs!|jjtƒƒ|jƒdS(N(RDterrbackRRb(R
((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyR_s(RR	R
R RbR]R_(((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyRCs
			(R
ROttwisted.internet.deferRtlandscape.lib.jujuRtlandscape.lib.tagRtlandscape.lib.networkRtlandscape.lib.vm_infoRRtlandscape.lib.versioningRt	ExceptionRRRtobjectRR#RC(((sA/usr/lib/python2.7/dist-packages/landscape/broker/registration.pyt<module>
s		¸