[openstack-dev] [Horizon] How to conditionally modify attributes in CreateNetwork class.

Timur Sufiev tsufiev at mirantis.com
Tue Jun 3 11:22:20 UTC 2014


Hello, Nader!

As for `contributes` attribute, you could override `contribute(self,
data, context)` method in your descendant of `workflows.Step` which by
default simply iterates over all keys in `contributes`.

Either you could use even more flexible approach (which also fits for
`default_steps`): define in your `workflows.Step` descendants methods
`contributes(self)` and `default_steps(self)` (with the conditional
logic you need) and then decorate them with @property.

On Fri, May 30, 2014 at 10:15 AM, Nader Lahouti <nader.lahouti at gmail.com> wrote:
> Hi All,
>
> Currently in the
> horizon/openstack_dashboard/dashboards/project/networks/workflows.py in
> classes such as CreateNetwork, CreateNetworkInfo and CreateSubnetInfo, the
> contributes or default_steps as shown below are fixed. Is it possible to add
> entries to those attributes conditionally?
>
> 156class CreateSubnetInfo(workflows.Step):
> 157    action_class = CreateSubnetInfoAction
> 158    contributes = ("with_subnet", "subnet_name", "cidr",
> 159                   "ip_version", "gateway_ip", "no_gateway")
> 160
>
> 262class CreateNetwork(workflows.Workflow):
> 263    slug = "create_network"
> 264    name = _("Create Network")
> 265    finalize_button_name = _("Create")
> 266    success_message = _('Created network "%s".')
> 267    failure_message = _('Unable to create network "%s".')
> 268    default_steps = (CreateNetworkInfo,
> 269                     CreateSubnetInfo,
> 270                     CreateSubnetDetail)
>
> Thanks for your input.
>
> Nader.
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>



-- 
Timur Sufiev



More information about the OpenStack-dev mailing list