コード例 #1
0
    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.deployed_charms = [
            CharmNtp, CharmNovaCompute, CharmGlance, CharmMysql
        ]

        self.charm = CharmQueue(ui=self.mock_ui,
                                config=self.mock_config,
                                juju=self.mock_jujuclient,
                                juju_state=self.mock_juju_state,
                                deployed_charms=self.deployed_charms)

        self.expected_relation = [
            ('mysql:shared-db', 'nova-compute:shared-db'),
            ('nova-compute:image-service', 'glance:image-service'),
            ('ntp:juju-info', 'nova-compute:juju-info'),
            ('mysql:shared-db', 'glance:shared-db')
        ]

        self.unexpected_relation = [('nova-compute:nova-ceilometer',
                                     'ceilometer-agent:nova-ceilometer')]
コード例 #2
0
ファイル: core.py プロジェクト: xrobau/openstack-installer
    def enqueue_deployed_charms(self):
        """Send all deployed charms to CharmQueue for relation setting and
        post-proc.
        """

        log.debug("Starting CharmQueue for relation setting and"
                  " post-processing enqueueing {}".format(
                      [c.charm_name for c in self.deployed_charm_classes]))

        charm_q = CharmQueue(ui=self.ui)
        for charm_class in self.deployed_charm_classes:
            charm = charm_class(juju=self.juju, juju_state=self.juju_state,
                                ui=self.ui)
            charm_q.add_relation(charm)
            charm_q.add_post_proc(charm)

        charm_q.watch_relations()
        charm_q.watch_post_proc()
        charm_q.is_running = True

        self.info_message(
            "Services deployed, relationships may still be"
            " pending. Please wait for all services to be checked before"
            " deploying compute nodes")
        self.render_nodes(self.nodes, self.juju_state, self.maas_state)
コード例 #3
0
    def enqueue_deployed_charms(self):
        """Send all deployed charms to CharmQueue for relation setting and
        post-proc.
        """
        charm_q = CharmQueue(ui=self.ui, config=self.config,
                             juju=self.juju, juju_state=self.juju_state,
                             deployed_charms=self.deployed_charm_classes)

        if self.config.getopt('headless'):
            charm_q.watch_relations()
            charm_q.watch_post_proc()
        else:
            charm_q.watch_relations_async()
            charm_q.watch_post_proc_async()
        charm_q.is_running = True

        # Exit cleanly if we've finished all deploys, relations,
        # post processing, and running in headless mode.
        if self.config.getopt('headless'):
            while not self.config.getopt('deploy_complete'):
                self.ui.status_info_message(
                    "Waiting for services to be started.")
                # FIXME: Is this needed?
                # time.sleep(10)
            self.ui.status_info_message(
                "All services deployed, relations set, and started")
            self.loop.exit(0)

        self.ui.status_info_message(
            "Services deployed, relationships may still be"
            " pending. Please wait for all services to be checked before"
            " deploying compute nodes")
        self.ui.render_services_view(self.nodes, self.juju_state,
                                     self.maas_state, self.config)
        self.loop.redraw_screen()
コード例 #4
0
class TestCharmRelations(unittest.TestCase):

    """ Use NovaCompute to determine if certain relations
    are supported as it contains an optional charm relation.

    NovaCompute includes an optional relation for ceilometer, this
    class will test to make sure that relation is dropped
    since that service is unavailable in this test.
    """

    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.deployed_charms = [CharmNtp, CharmNovaCompute, CharmGlance,
                                CharmMysql]

        self.charm = CharmQueue(
            ui=self.mock_ui,
            config=self.mock_config,
            juju=self.mock_jujuclient,
            juju_state=self.mock_juju_state,
            deployed_charms=self.deployed_charms)

        self.expected_relation = [('mysql:shared-db',
                                   'nova-compute:shared-db'),
                                  ('nova-compute:image-service',
                                   'glance:image-service'),
                                  ('ntp:juju-info', 'nova-compute:juju-info'),
                                  ('mysql:shared-db', 'glance:shared-db')]

        self.unexpected_relation = [('nova-compute:nova-ceilometer',
                                     'ceilometer-agent:nova-ceilometer')]

    def test_expected_relations(self):
        """ Test valid relations are provided """
        valid_relations = self.charm.filter_valid_relations()
        self.assertEqual(self.expected_relation, valid_relations)

    def test_unexpected_relations(self):
        """ Test invalid relations are removed """
        valid_relations = self.charm.filter_valid_relations()
        self.assertNotIn(self.unexpected_relation, valid_relations)

    def test_watch_relations_exception(self):
        """ Verifies watch_relations croaks on failed add_relation """
        juju = self.mock_jujuclient

        juju.add_relation.side_effect = Exception('Failed to add relations')

        charm_q = CharmQueue(
            ui=self.mock_ui,
            config=self.mock_config,
            juju=juju,
            juju_state=self.mock_juju_state,
            deployed_charms=self.deployed_charms)
        self.assertRaises(Exception, charm_q.watch_relations)
コード例 #5
0
class TestCharmRelations(unittest.TestCase):
    """ Use NovaCompute to determine if certain relations
    are supported as it contains an optional charm relation.

    NovaCompute includes an optional relation for ceilometer, this
    class will test to make sure that relation is dropped
    since that service is unavailable in this test.
    """
    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.deployed_charms = [
            CharmNtp, CharmNovaCompute, CharmGlance, CharmMysql
        ]

        self.charm = CharmQueue(ui=self.mock_ui,
                                config=self.mock_config,
                                juju=self.mock_jujuclient,
                                juju_state=self.mock_juju_state,
                                deployed_charms=self.deployed_charms)

        self.expected_relation = [
            ('mysql:shared-db', 'nova-compute:shared-db'),
            ('nova-compute:image-service', 'glance:image-service'),
            ('ntp:juju-info', 'nova-compute:juju-info'),
            ('mysql:shared-db', 'glance:shared-db')
        ]

        self.unexpected_relation = [('nova-compute:nova-ceilometer',
                                     'ceilometer-agent:nova-ceilometer')]

    def test_expected_relations(self):
        """ Test valid relations are provided """
        valid_relations = self.charm.filter_valid_relations()
        self.assertEqual(self.expected_relation, valid_relations)

    def test_unexpected_relations(self):
        """ Test invalid relations are removed """
        valid_relations = self.charm.filter_valid_relations()
        self.assertNotIn(self.unexpected_relation, valid_relations)

    def test_watch_relations_exception(self):
        """ Verifies watch_relations croaks on failed add_relation """
        juju = self.mock_jujuclient

        juju.add_relation.side_effect = Exception('Failed to add relations')

        charm_q = CharmQueue(ui=self.mock_ui,
                             config=self.mock_config,
                             juju=juju,
                             juju_state=self.mock_juju_state,
                             deployed_charms=self.deployed_charms)
        self.assertRaises(Exception, charm_q.watch_relations)
コード例 #6
0
    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.deployed_charms = [CharmNovaCloudController, CharmSwift]

        self.charm = CharmQueue(ui=self.mock_ui,
                                config=self.mock_config,
                                juju=self.mock_jujuclient,
                                juju_state=self.mock_juju_state,
                                deployed_charms=self.deployed_charms)
コード例 #7
0
class TestCharmQueuePostProc(unittest.TestCase):

    """ Use CharmNovaCloudController, CharmSwift to process their post_proc()
    via CharmQueue and to make sure it is called by an initialized charm().
    """

    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.deployed_charms = [CharmNovaCloudController, CharmSwift]

        self.charm = CharmQueue(
            ui=self.mock_ui,
            config=self.mock_config,
            juju=self.mock_jujuclient,
            juju_state=self.mock_juju_state,
            deployed_charms=self.deployed_charms)

    def test_can_post_proc(self):
        """ Test that post_proc is available and can be triggered """
        charms = self.charm._charm_classes()
        for c in charms:
            self.assertTrue(isinstance(c, CharmBase))
コード例 #8
0
    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.deployed_charms = [CharmNtp, CharmNovaCompute, CharmGlance,
                                CharmMysql]

        self.charm = CharmQueue(
            ui=self.mock_ui,
            config=self.mock_config,
            juju=self.mock_jujuclient,
            juju_state=self.mock_juju_state,
            deployed_charms=self.deployed_charms)

        self.expected_relation = [('mysql:shared-db',
                                   'nova-compute:shared-db'),
                                  ('nova-compute:image-service',
                                   'glance:image-service'),
                                  ('ntp:juju-info', 'nova-compute:juju-info'),
                                  ('mysql:shared-db', 'glance:shared-db')]

        self.unexpected_relation = [('nova-compute:nova-ceilometer',
                                     'ceilometer-agent:nova-ceilometer')]
コード例 #9
0
    def test_watch_relations_exception(self):
        """ Verifies watch_relations croaks on failed add_relation """
        juju = self.mock_jujuclient

        juju.add_relation.side_effect = Exception('Failed to add relations')

        charm_q = CharmQueue(ui=self.mock_ui,
                             config=self.mock_config,
                             juju=juju,
                             juju_state=self.mock_juju_state,
                             deployed_charms=self.deployed_charms)
        self.assertRaises(Exception, charm_q.watch_relations)
コード例 #10
0
    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.deployed_charms = [CharmNovaCloudController, CharmSwift]

        self.charm = CharmQueue(
            ui=self.mock_ui,
            config=self.mock_config,
            juju=self.mock_jujuclient,
            juju_state=self.mock_juju_state,
            deployed_charms=self.deployed_charms)
コード例 #11
0
ファイル: core.py プロジェクト: sincereuk/openstack-installer
    def enqueue_deployed_charms(self):
        """Send all deployed charms to CharmQueue for relation setting and
        post-proc.
        """
        charm_q = CharmQueue(ui=self.ui, config=self.config,
                             juju=self.juju, juju_state=self.juju_state,
                             deployed_charms=self.deployed_charm_classes)

        if self.config.getopt('headless'):
            charm_q.watch_relations()
            charm_q.watch_post_proc()
        else:
            async.submit(charm_q.watch_relations,
                         self.ui.show_exception_message)
            async.submit(charm_q.watch_post_proc,
                         self.ui.show_exception_message)

        charm_q.is_running = True

        # Exit cleanly if we've finished all deploys, relations,
        # post processing, and running in headless mode.
        if self.config.getopt('headless'):
            while not self.config.getopt('postproc_complete'):
                self.ui.status_info_message(
                    "Waiting for services to be started.")
                # FIXME: Is this needed?
                # time.sleep(10)
            self.ui.status_info_message(
                "All services deployed, relations set, and started")
            self.loop.exit(0)

        session_id = self.config.getopt('session_id')
        if self.config.is_single():
            utils.pollinate(session_id, 'DS')
        elif self.config.is_multi():
            utils.pollinate(session_id, 'DM')

        if charm_q.charm_post_proc_q.empty():
            self.ui.status_info_message("Ready.")

        self.ui.render_services_view(self.nodes, self.juju_state,
                                     self.maas_state, self.config)
        self.loop.redraw_screen()
コード例 #12
0
class TestCharmQueuePostProc(unittest.TestCase):
    """ Use CharmNovaCloudController, CharmSwift to process their post_proc()
    via CharmQueue and to make sure it is called by an initialized charm().
    """
    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.deployed_charms = [CharmNovaCloudController, CharmSwift]

        self.charm = CharmQueue(ui=self.mock_ui,
                                config=self.mock_config,
                                juju=self.mock_jujuclient,
                                juju_state=self.mock_juju_state,
                                deployed_charms=self.deployed_charms)

    def test_can_post_proc(self):
        """ Test that post_proc is available and can be triggered """
        charms = self.charm._charm_classes()
        for c in charms:
            self.assertTrue(isinstance(c, CharmBase))
コード例 #13
0
    def enqueue_deployed_charms(self):
        """Send all deployed charms to CharmQueue for relation setting and
        post-proc.
        """
        charm_q = CharmQueue(ui=self.ui,
                             config=self.config,
                             juju=self.juju,
                             juju_state=self.juju_state,
                             deployed_charms=self.deployed_charm_classes)

        if self.config.getopt('headless'):
            charm_q.watch_relations()
            charm_q.watch_post_proc()
        else:
            async .submit(charm_q.watch_relations,
                          self.ui.show_exception_message)
            async .submit(charm_q.watch_post_proc,
                          self.ui.show_exception_message)

        charm_q.is_running = True

        # Exit cleanly if we've finished all deploys, relations,
        # post processing, and running in headless mode.
        if self.config.getopt('headless'):
            while not self.config.getopt('postproc_complete'):
                self.ui.status_info_message(
                    "Waiting for services to be started.")
                # FIXME: Is this needed?
                # time.sleep(10)
            self.ui.status_info_message(
                "All services deployed, relations set, and started")
            self.loop.exit(0)

        self.ui.status_info_message(
            "Services deployed, relationships still pending."
            " Please wait for all relations to be set before"
            " deploying additional services.")
        self.ui.render_services_view(self.nodes, self.juju_state,
                                     self.maas_state, self.config)
        self.loop.redraw_screen()
コード例 #14
0
ファイル: core.py プロジェクト: xrobau/openstack-installer
    def add_charm(self, count=0, charm=None):
        if not charm:
            self.ui.hide_add_charm_info()
            return
        svc = self.juju_state.service(charm)
        if svc.service:
            self.info_message("Adding {n} units of {charm}".format(
                n=count, charm=charm))
            self.juju.add_unit(charm, num_units=int(count))
        else:
            charm_q = CharmQueue(ui=self.ui)
            charm_sel = get_charm(charm,
                                  self.juju,
                                  self.juju_state,
                                  self.ui)
            log.debug("Add charm: {}".format(charm_sel))
            if not charm_sel.isolate:
                charm_sel.machine_id = 'lxc:{mid}'.format(mid="1")

            self.info_message("Adding {} to environment".format(
                charm_sel))
            charm_q.add_deploy(charm_sel)
            charm_q.add_relation(charm_sel)
            charm_q.add_post_proc(charm_sel)

            # Add charm dependencies
            if len(charm_sel.related) > 0:
                for c in charm_sel.related:
                    svc = self.juju_state.service(charm_sel)
                    if not svc.service:
                        self.info_message("Adding dependent "
                                          "charm {c}".format(c=c))
                        charm_dep = get_charm(c,
                                              self.juju,
                                              self.juju_state,
                                              self.ui)
                        if not charm_dep.isolate:
                            charm_dep.machine_id = 'lxc:{mid}'.format(mid="1")
                        charm_q.add_deploy(charm_dep)
                        charm_q.add_relation(charm_dep)
                        charm_q.add_post_proc(charm_dep)

            if not charm_q.is_running:
                charm_q.watch_deploy()
                charm_q.watch_relations()
                charm_q.watch_post_proc()
                charm_q.is_running = True
        self.ui.hide_add_charm_info()
        return
コード例 #15
0
ファイル: core.py プロジェクト: gitter-badger/cloud-installer
    def add_charm(self, count=0, charm=None):
        if not charm:
            self.ui.hide_add_charm_info()
            return
        svc = self.juju_state.service(charm)
        if svc.service:
            self.info_message("Adding {n} units of {charm}".format(
                n=count, charm=charm))
            self.juju.add_unit(charm, num_units=int(count))
        else:
            charm_q = CharmQueue(ui=self.ui)
            charm_sel = get_charm(charm, self.juju, self.juju_state, self.ui)
            log.debug("Add charm: {}".format(charm_sel))
            if not charm_sel.isolate:
                charm_sel.machine_id = 'lxc:{mid}'.format(mid="1")

            self.info_message("Adding {} to environment".format(charm_sel))
            charm_q.add_setup(charm_sel)
            charm_q.add_relation(charm_sel)
            charm_q.add_post_proc(charm_sel)

            # Add charm dependencies
            if len(charm_sel.related) > 0:
                for c in charm_sel.related:
                    svc = self.juju_state.service(charm_sel)
                    if not svc.service:
                        self.info_message("Adding dependent "
                                          "charm {c}".format(c=c))
                        charm_dep = get_charm(c, self.juju, self.juju_state,
                                              self.ui)
                        if not charm_dep.isolate:
                            charm_dep.machine_id = 'lxc:{mid}'.format(mid="1")
                        charm_q.add_setup(charm_dep)
                        charm_q.add_relation(charm_dep)
                        charm_q.add_post_proc(charm_dep)

            if not charm_q.is_running:
                charm_q.watch_setup()
                charm_q.watch_relations()
                charm_q.watch_post_proc()
                charm_q.is_running = True
        self.ui.hide_add_charm_info()
        return
コード例 #16
0
ファイル: core.py プロジェクト: gitter-badger/cloud-installer
    def enqueue_deployed_charms(self):
        """Send all deployed charms to CharmQueue for relation setting and
        post-proc.
        """

        log.debug("Starting CharmQueue for relation setting and"
                  " post-processing enqueueing {}".format(
                      [c.charm_name for c in self.deployed_charm_classes]))

        charm_q = CharmQueue(ui=self.ui)
        for charm_class in self.deployed_charm_classes:
            charm = charm_class(juju=self.juju,
                                juju_state=self.juju_state,
                                ui=self.ui)
            charm_q.add_relation(charm)
            charm_q.add_post_proc(charm)

        charm_q.watch_relations()
        charm_q.watch_post_proc()
        charm_q.is_running = True

        self.info_message(
            "Services deployed, relationships may still be"
            " pending. Please wait for all services to be checked before"
            " deploying compute nodes.")
        self.render_nodes(self.nodes, self.juju_state, self.maas_state)