def take_action(self, parsed_args):
        self.log.debug('take_action(%s)', parsed_args)

        client = self.app.client_manager.orchestration

        config = {}
        if parsed_args.config:
            try:
                config = client.software_configs.get(parsed_args.config)
            except heat_exc.HTTPNotFound:
                msg = (_('Software configuration not found: %s') %
                       parsed_args.config)
                raise exc.CommandError(msg)

        derived_params = deployment_utils.build_derived_config_params(
            parsed_args.action,
            config,
            parsed_args.name,
            heat_utils.format_parameters(parsed_args.input_value, False),
            parsed_args.server,
            parsed_args.signal_transport,
            signal_id=deployment_utils.build_signal_id(client, parsed_args))
        derived_config = client.software_configs.create(**derived_params)

        sd = client.software_deployments.create(config_id=derived_config.id,
                                                server_id=parsed_args.server,
                                                action=parsed_args.action,
                                                status='IN_PROGRESS')

        return zip(*sorted(sd.to_dict().items()))
    def take_action(self, parsed_args):
        self.log.debug('take_action(%s)', parsed_args)

        client = self.app.client_manager.orchestration

        config = {}
        if parsed_args.config:
            try:
                config = client.software_configs.get(parsed_args.config)
            except heat_exc.HTTPNotFound:
                msg = (_('Software configuration not found: %s') %
                       parsed_args.config)
                raise exc.CommandError(msg)

        derived_params = deployment_utils.build_derived_config_params(
            parsed_args.action,
            config,
            parsed_args.name,
            heat_utils.format_parameters(parsed_args.input_value, False),
            parsed_args.server,
            parsed_args.signal_transport,
            signal_id=deployment_utils.build_signal_id(client, parsed_args)
        )
        derived_config = client.software_configs.create(**derived_params)

        sd = client.software_deployments.create(
            config_id=derived_config.id,
            server_id=parsed_args.server,
            action=parsed_args.action,
            status='IN_PROGRESS'
        )

        return zip(*sorted(sd.to_dict().items()))
Exemplo n.º 3
0
def do_deployment_create(hc, args):
    try:
        config = hc.software_configs.get(config_id=args.config)
    except exc.HTTPNotFound:
        raise exc.CommandError(_('Configuration not found: %s') % args.id)

    derrived_params = deployment_utils.build_derived_config_params(
        action=args.action,
        source=config,
        name=args.name,
        input_values=utils.format_parameters(args.input_value, False),
        server_id=args.server,
        signal_transport=args.signal_transport,
        signal_id=deployment_utils.build_signal_id(hc, args)
    )
    derived_config = hc.software_configs.create(**derrived_params)

    sd = hc.software_deployments.create(
        tenant_id='asdf',
        config_id=derived_config.id,
        server_id=args.server,
        action=args.action,
        status='IN_PROGRESS'
    )
    print(jsonutils.dumps(sd.to_dict(), indent=2))
    def test_build_signal_id(self, csc, ctu):
        hc = mock.MagicMock()
        args = mock.MagicMock()
        args.name = 'foo'
        args.timeout = 60
        args.os_no_client_auth = False
        args.signal_transport = 'TEMP_URL_SIGNAL'
        csc.return_value = mock.MagicMock()
        temp_url = ('http://fake-host.com:8080/v1/AUTH_demo/foo/'
                    'a81a74d5-c395-4269-9670-ddd0824fd696'
                    '?temp_url_sig=6a68371d602c7a14aaaa9e3b3a63b8b85bd9a503'
                    '&temp_url_expires=1425270977')
        ctu.return_value = temp_url

        self.assertEqual(temp_url, deployment_utils.build_signal_id(hc, args))
        self.assertEqual(
            mock.call(hc.http_client.auth, hc.http_client.session, args),
            csc.call_args)
        self.assertEqual(mock.call(csc.return_value, 'foo', 60), ctu.call_args)
    def test_build_signal_id(self, csc, ctu):
        hc = mock.MagicMock()
        args = mock.MagicMock()
        args.name = 'foo'
        args.timeout = 60
        args.os_no_client_auth = False
        args.signal_transport = 'TEMP_URL_SIGNAL'
        csc.return_value = mock.MagicMock()
        temp_url = (
            'http://fake-host.com:8080/v1/AUTH_demo/foo/'
            'a81a74d5-c395-4269-9670-ddd0824fd696'
            '?temp_url_sig=6a68371d602c7a14aaaa9e3b3a63b8b85bd9a503'
            '&temp_url_expires=1425270977')
        ctu.return_value = temp_url

        self.assertEqual(
            temp_url, deployment_utils.build_signal_id(hc, args))
        self.assertEqual(
            mock.call(hc.http_client.auth, hc.http_client.session, args),
            csc.call_args)
        self.assertEqual(
            mock.call(csc.return_value, 'foo', 60),
            ctu.call_args)
 def test_build_signal_id_no_signal(self):
     hc = mock.MagicMock()
     args = mock.MagicMock()
     args.signal_transport = 'NO_SIGNAL'
     self.assertIsNone(deployment_utils.build_signal_id(hc, args))
 def test_build_signal_id_no_signal(self):
     hc = mock.MagicMock()
     args = mock.MagicMock()
     args.signal_transport = 'NO_SIGNAL'
     self.assertIsNone(deployment_utils.build_signal_id(hc, args))