~dpb/charms/precise/landscape-client/1273788-change-relation-interface

« back to all changes in this revision

Viewing changes to hooks/common.py

  • Committer: Marco Ceppi
  • Date: 2013-05-29 22:01:20 UTC
  • mfrom: (19.3.11 landscape-client)
  • Revision ID: marco@ceppi.net-20130529220120-5attgp6hl5e6i60j
add-landscape-relation

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        stop_client_and_disable_init_script()
48
48
        self.exit_code = exit_code
49
49
 
50
 
 
 
50
def clear_registration():
 
51
    """
 
52
    Do steps necessary to clear the client registration, so that next time
 
53
    it will re-register
 
54
    """
 
55
    stop_client_and_disable_init_script()
51
56
 
52
57
def try_to_register():
53
58
    """Try to register the client if needed.
58
63
    which means that it's expected that the configuration will be broken
59
64
    at that point.
60
65
 
 
66
    The following keys need to be set for an attempt to be made:
 
67
     - account_name, computer_title
 
68
 
61
69
    If an error is encountered, the client will be disabled and the hook
62
70
    calling this function will exit with an error code.
63
71
    """
68
76
    config = LandscapeSetupConfiguration()
69
77
    config.load([])
70
78
    config.silent = True
71
 
    if configured or not config.get("computer_title"):
 
79
    if configured:
 
80
        print "Client already registered, skipping"
 
81
        return 0
 
82
    if not config.get("account_name") or not config.get("computer_title"):
 
83
        print "Need account-name and computer-title to proceed, skipping"
72
84
        return 0
73
85
    try:
74
86
        setup(config)