~therve/landscape-client/sysinfo-network-disks

« back to all changes in this revision

Viewing changes to landscape/manager/eucalyptus.py

  • Committer: Jamu Kakar
  • Date: 2010-02-04 01:07:35 UTC
  • mto: This revision was merged to the branch mainline in revision 204.
  • Revision ID: jkakar@kakar.ca-20100204010735-umhonk79bk29gmgj
- Added (an untested) remove method to PluginRegistry.
- Added some initial tests for the plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
import logging
 
3
 
1
4
from landscape.manager.manager import ManagerPlugin
2
5
 
3
6
 
15
18
    def get_storage_controller_info(self):
16
19
        return self._tools._runTool("euca_conf", ["--list-scs"])
17
20
 
 
21
    def get_node_info(self):
 
22
        return self._tools._runTool("euca_conf", ["--list-nodes"])
 
23
 
18
24
 
19
25
class EucalyptusCloudManager(ManagerPlugin):
20
26
    """A management plugin for a Eucalyptus cloud."""
21
27
 
 
28
    plugin_name = "eucalyptus-manager"
22
29
    message_type = "eucalyptus-info"
23
30
    run_interval = 3600
24
31
 
25
 
    def __init__(self):
26
 
        pass
27
 
 
28
32
    def run(self):
29
33
        """Run the plugin.
30
34
 
31
35
        A C{ServiceHub} runs services that provide information about
32
36
        Eucalyptus.  If a service hub can't be created the plugin assumes that
33
 
        Eucalyptus is not installed.  In such cases, this method is
34
 
        effectively a no-op.
 
37
        Eucalyptus is not installed.  In such cases a message is written to
 
38
        the log and the plugin is disabled.
35
39
 
36
 
        @return: A C{Deferred} that will fire when credentials
 
40
        @return: A C{Deferred} that will fire when the plugin has finished
 
41
            running.
37
42
        """
38
43
        try:
39
44
            service_hub = self._start_service_hub()
40
45
        except:
41
 
            logging.info(
42
 
                "Couldn't start service hub.  '%s' plugin is disabled." % (
43
 
                    self.message_type,))
 
46
            self.registry.remove(self)
 
47
            logging.info("Couldn't start service hub.  '%s' plugin has been "
 
48
                         "disabled." % self.message_type)
44
49
        else:
45
50
            deferred = service_hub.addTask(GetEucaInfo("admin"))
46
51
            deferred.addCallback(self._get_message)
66
71
        service_hub.start()
67
72
        return service_hub
68
73
 
69
 
    def _get_message(credentials):
 
74
    def _get_message(self, credentials):
70
75
        """Create a message with information about a Eucalyptus cloud.
71
76
 
72
77
        @param credentials: A C{EucaInfo} instance containing credentials for
93
98
                "cluster_controller_info": cluster_controller_info,
94
99
                "storage_controller_info": storage_controller_info}
95
100
 
96
 
    def _get_error_message(failure):
 
101
    def _get_error_message(self, failure):
97
102
        """Create an error message.
98
103
 
99
104
        @param failure: A C{Failure} instance containing information about an