Ejemplo n.º 1
0
 def test_scaledown(self, mock_get_template_contents, mock_env_files):
     mock_get_template_contents.return_value = ({}, 'template_body')
     mock_env_files.return_value = ({}, {})
     self.heatclient.stacks.get.return_value = mock_stack()
     manager = scale.ScaleManager(heatclient=self.heatclient,
                                  stack_id='stack',
                                  tht_dir='/tmp/')
     manager.scaledown(['resource_id'])
     env = {
         'resource_registry': {
             'resources': {
                 '*': {
                     '*': {
                         'UpdateDeployment': {
                             'hooks': []
                         }
                     }
                 }
             }
         }
     }
     self.heatclient.stacks.update.assert_called_once_with(
         stack_id='stack',
         template='template_body',
         environment=env,
         existing=True,
         files={},
         timeout_mins=240,
         parameters={
             'ComputeCount': '0',
             'ComputeRemovalPolicies': [{
                 'resource_list': ['node0']
             }]
         })
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)
        clients = self.app.client_manager

        scale_manager = scale.ScaleManager(
            heatclient=clients.orchestration,
            stack_id=parsed_args.stack,
            tht_dir=parsed_args.templates,
            environment_files=parsed_args.environment_files)
        print("deleting nodes {0} from stack {1}".format(
            parsed_args.nodes, parsed_args.stack))
        scale_manager.scaledown(parsed_args.nodes)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)
        osc_plugin = self.app.client_manager.rdomanager_oscplugin
        if parsed_args.templates:
            management = None
        else:
            management = osc_plugin.management()

        orchestration = osc_plugin.orchestration()
        scale_manager = scale.ScaleManager(
            tuskarclient=management,
            heatclient=orchestration,
            plan_id=parsed_args.plan,
            stack_id=parsed_args.stack,
            tht_dir=parsed_args.templates,
            environment_files=parsed_args.environment_files)
        print("deleting nodes {0} from stack {1}".format(
            parsed_args.nodes, parsed_args.plan))
        scale_manager.scaledown(parsed_args.nodes)
Ejemplo n.º 4
0
 def test_invalid_scaledown(self):
     manager = scale.ScaleManager(heatclient=self.heatclient,
                                  stack_id='stack')
     self.assertRaises(ValueError, manager.scaledown, 'invalid_resource_id')