def get_juju_status(application=None, unit=None):
    if application:
        return juju_utils.get_application_status(application=application,
                                                 unit=unit)
    if unit:
        application = unit.split('/')[0]
        return juju_utils.get_application_status(application=application,
                                                 unit=unit)
    return json.loads(juju_utils.get_full_juju_status().to_json())
Пример #2
0
    def test_get_application_status(self):
        self.patch_object(juju_utils, "get_full_juju_status")
        self.get_full_juju_status.return_value = self.juju_status

        # Full status juju object return
        self.assertEqual(juju_utils.get_application_status(), self.juju_status)
        self.get_full_juju_status.assert_called_once()

        # Application only dictionary return
        self.assertEqual(
            juju_utils.get_application_status(application=self.application),
            self.application_data)

        # Unit no application dictionary return
        self.assertEqual(juju_utils.get_application_status(unit=self.unit1),
                         self.unit1_data)
def get_subordinate_applications():
    return [application for application in
            juju_utils.get_full_juju_status().applications.keys()
            if juju_utils.get_application_status(
                application)['subordinate-to']]