Exemplo n.º 1
0
    def test_output_types(self):
        swc_io.OutputConfig(name='str', type='String').as_dict()
        swc_io.OutputConfig(name='num', type='Number').as_dict()
        swc_io.OutputConfig(name='list', type='CommaDelimitedList').as_dict()
        swc_io.OutputConfig(name='json', type='Json').as_dict()
        swc_io.OutputConfig(name='bool', type='Boolean').as_dict()

        self.assertRaises(ValueError, swc_io.OutputConfig,
                          name='bogus', type='BogusType')
Exemplo n.º 2
0
 def test_output_config_empty(self):
     name = 'foo'
     outp = swc_io.OutputConfig(name=name)
     self.assertEqual(name, outp.name())
     self.assertEqual({'name': name, 'type': 'String',
                       'error_output': False},
                      outp.as_dict())
Exemplo n.º 3
0
 def test_output_config(self):
     name = 'bar'
     outp = swc_io.OutputConfig(name=name, description='test',
                                type='Json', error_output=True)
     self.assertEqual(name, outp.name())
     self.assertIs(True, outp.error_output())
     self.assertEqual({'name': name, 'type': 'Json',
                       'description': 'test', 'error_output': True},
                      outp.as_dict())
Exemplo n.º 4
0
    def _load_config(self):
        if self.properties.get(self.CONFIG):
            config = self.rpc_client().show_software_config(
                self.context, self.properties.get(self.CONFIG))
        else:
            config = {}

        config[rpc_api.SOFTWARE_CONFIG_INPUTS] = [
            swc_io.InputConfig(**i)
            for i in config.get(rpc_api.SOFTWARE_CONFIG_INPUTS, [])
        ]
        config[rpc_api.SOFTWARE_CONFIG_OUTPUTS] = [
            swc_io.OutputConfig(**o)
            for o in config.get(rpc_api.SOFTWARE_CONFIG_OUTPUTS, [])
        ]

        return config
Exemplo n.º 5
0
    def create_software_config(self, cnxt, group, name, config,
                               inputs, outputs, options):

        swc_io.check_io_schema_list(inputs)
        in_conf = [swc_io.InputConfig(**i).as_dict() for i in inputs]
        swc_io.check_io_schema_list(outputs)
        out_conf = [swc_io.OutputConfig(**o).as_dict() for o in outputs]

        sc = software_config_object.SoftwareConfig.create(cnxt, {
            'group': group,
            'name': name,
            'config': {
                rpc_api.SOFTWARE_CONFIG_INPUTS: in_conf,
                rpc_api.SOFTWARE_CONFIG_OUTPUTS: out_conf,
                rpc_api.SOFTWARE_CONFIG_OPTIONS: options,
                rpc_api.SOFTWARE_CONFIG_CONFIG: config
            },
            'tenant': cnxt.tenant_id})
        return api.format_software_config(sc)