Example #1
0
 def test_pass_through(self):
     input_model = ServersModel('my_cloud',
                                'my_control_plane',
                                config=safe_load(device_groups_disk_model),
                                consumes_model=standard_swf_rng_consumes)
     self.assertEqual(
         input_model.server_draining('standard-ccp-c1-m1-mgmt'), True)
     self.assertEqual(
         input_model.server_draining('standard-ccp-c1-m2-mgmt'), False)
     self.assertEqual(
         input_model.server_removing('standard-ccp-c1-m1-mgmt'), True)
     self.assertEqual(
         input_model.server_removing('standard-ccp-c1-m2-mgmt'), False)
     self.assertEqual(input_model.server_draining('junk'), False)
     self.assertEqual(input_model.server_removing('junk'), False)
Example #2
0
    def test_set_weight_removing(self):
        options = DummyInputOptions()
        config_paths = CloudMultiSite(options)
        input_model = ServersModel('standard', 'ccp',
                                   config=safe_load(standard_input_model),
                                   consumes_model=standard_swf_rng_consumes)
        ring_model = RingSpecifications('standard', 'ccp',
                                        model=safe_load(standard_input_model))
        rings = FakeRingBuilder(self.builder_dir,
                                ['account', 'container', 'object-0'],
                                3.0)
        drive_configurations = dummy_osconfig_load(
            standard_drive_configurations)
        delta = RingDelta()
        generate_delta(config_paths, input_model, ring_model, rings,
                       drive_configurations, options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # Set standard-ccp-c1-m3 (92.168.245.2) to removing
        for server in input_model.servers:
            if server.get('ardana_ansible_host') == 'standard-ccp-c1-m3':
                server['pass_through'] = {'swift': {'remove': True}}
        self.assertTrue(input_model.server_removing('standard-ccp-c1-m3'))

        # make a new delta and rebalance
        delta = RingDelta()
        generate_delta(config_paths, input_model, ring_model, rings,
                       drive_configurations, options, delta)
        options.dry_run = True
        cmds = rebalance(delta, rings, options)
        self.assertTrue('account.builder  remove'
                        ' 192.168.245.2/disk0' in ' '.join(cmds))