How to use the horizon.workflows function in horizon

To help you get started, we’ve selected a few horizon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / sahara-dashboard / sahara_dashboard / content / data_processing / jobs / job_templates / workflows / create.py View on Github external
from horizon import workflows

from sahara_dashboard.content.data_processing \
    .utils import helpers
from sahara_dashboard.content.data_processing.utils \
    import acl as acl_utils
import sahara_dashboard.content.data_processing \
    .utils.workflow_helpers as whelpers
from sahara_dashboard.api import sahara as saharaclient


JOB_BINARY_CREATE_URL = ("horizon:project:data_processing.jobs"
                         ":create-job-binary")


class AdditionalLibsAction(workflows.Action):

    lib_binaries = forms.DynamicChoiceField(
        label=_("Choose libraries"),
        required=False,
        add_item_link=JOB_BINARY_CREATE_URL,
        widget=forms.Select(
            attrs={
                'class': 'switched',
                'data-switch-on': 'jobtype',
                'data-jobtype-pig': _("Choose libraries"),
                'data-jobtype-hive': _("Choose libraries"),
                'data-jobtype-shell': _("Choose additional files"),
                'data-jobtype-spark': _("Choose libraries"),
                'data-jobtype-java': _("Choose libraries"),
                'data-jobtype-mapreduce': _("Choose libraries"),
                'data-jobtype-mapreduce.streaming': _("Choose libraries")
github openstack / horizon / openstack_dashboard / dashboards / project / networks / workflows.py View on Github external
msg = _('Host Routes format error: '
                        'Destination CIDR and nexthop must be specified '
                        '(value=%s)') % r
                raise forms.ValidationError(msg)
            self._convert_ip_network(route[0], "host_routes")
            self._convert_ip_address(route[1], "host_routes")

    def clean(self):
        cleaned_data = super(CreateSubnetDetailAction, self).clean()
        self._check_allocation_pools(cleaned_data.get('allocation_pools'))
        self._check_host_routes(cleaned_data.get('host_routes'))
        self._check_dns_nameservers(cleaned_data.get('dns_nameservers'))
        return cleaned_data


class CreateSubnetDetail(workflows.Step):
    action_class = CreateSubnetDetailAction
    contributes = ("enable_dhcp", "ipv6_modes", "allocation_pools",
                   "dns_nameservers", "host_routes")


class CreateNetwork(workflows.Workflow):
    slug = "create_network"
    name = _("Create Network")
    finalize_button_name = _("Create")
    success_message = _('Created network "%s".')
    failure_message = _('Unable to create network "%s".')
    default_steps = (CreateNetworkInfo,
                     CreateSubnetInfo,
                     CreateSubnetDetail)
    wizard = True
github openstack / horizon / openstack_dashboard / dashboards / identity / domains / workflows.py View on Github external
'assignments.'),
                                  redirect=reverse(
                                      constants.DOMAINS_INDEX_URL))

            for user_id in users_roles:
                roles_ids = users_roles[user_id]
                for role_id in roles_ids:
                    field_name = self.get_member_field_name(role_id)
                    self.fields[field_name].initial.append(user_id)

    class Meta(object):
        name = _("Domain Members")
        slug = constants.DOMAIN_USER_MEMBER_SLUG


class UpdateDomainUsers(workflows.UpdateMembersStep):
    action_class = UpdateDomainUsersAction
    available_list_title = _("All Users")
    members_list_title = _("Domain Members")
    no_available_text = _("No users found.")
    no_members_text = _("No users.")

    def contribute(self, data, context):
        context = super(UpdateDomainUsers, self).contribute(data, context)
        if data:
            try:
                roles = api.keystone.role_list(self.workflow.request)
            except Exception:
                exceptions.handle(self.workflow.request,
                                  _('Unable to retrieve role list.'),
                                  redirect=reverse(
                                      constants.DOMAINS_INDEX_URL))
github openstack / horizon / horizon / dashboards / project / networks / views.py View on Github external
def get_data(self):
        try:
            tenant_id = self.request.user.tenant_id
            networks = api.quantum.network_list_for_tenant(self.request,
                                                           tenant_id)
        except:
            networks = []
            msg = _('Network list can not be retrieved.')
            exceptions.handle(self.request, msg)
        for n in networks:
            n.set_id_as_name_if_empty()
        return networks


class CreateView(workflows.WorkflowView):
    workflow_class = CreateNetwork
    template_name = 'project/networks/create.html'

    def get_initial(self):
        pass


class UpdateView(forms.ModalFormView):
    form_class = UpdateNetwork
    template_name = 'project/networks/update.html'
    context_object_name = 'network'
    success_url = reverse_lazy("horizon:project:networks:index")

    def get_context_data(self, **kwargs):
        context = super(UpdateView, self).get_context_data(**kwargs)
        context["network_id"] = self.kwargs['network_id']
github openstack / solum-dashboard / solumdashboard / applications / workflows / launch.py View on Github external
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from django.utils.translation import ugettext_lazy as _
from horizon import forms
from horizon import workflows

from solumdashboard.api.client import client as solumclient


class ConfigAssemblyAction(workflows.Action):
    name = forms.CharField(label=_("Assembly Name"),
                           required=True)
    description = forms.CharField(label=_("Description"),
                                  required=False)

    def __init__(self, request, *args, **kwargs):
        super(ConfigAssemblyAction, self).__init__(request, *args, **kwargs)
        if 'application_id' in request.REQUEST:
            plan_id = request.REQUEST['application_id']
            solum = solumclient(request)
            plan = solum.plans.get(plan_id=plan_id)
            plan_uri = plan.uri
        else:
            plan_uri = request.POST['plan_uri']

        self.fields["plan_uri"] = forms.CharField(
github openstack / python-muranoclient / dashboard / windc / workflows.py View on Github external
class Meta:
        name = _("Data Center")
        help_text_template = ("project/windc/_data_center_help.html")


class ConfigureDC(workflows.Step):
    action_class = ConfigureDCAction
    contibutes = ('name',)

    def contribute(self, data, context):
        if data:
            context['name'] = data.get('name', '')
        return context


class CreateWinDC(workflows.Workflow):
    slug = "create"
    name = _("Create Windows Data Center")
    finalize_button_name = _("Create")
    success_message = _('Created data center "%s".')
    failure_message = _('Unable to create data center "%s".')
    success_url = "horizon:project:windc:index"
    default_steps = (SelectProjectUser,
                     ConfigureDC)

    def format_status_message(self, message):
        name = self.context.get('name', 'noname')
        return message % name

    def handle(self, request, context):
        try:
            datacenter = api.windc.datacenters_create(request, context)
github openstack / sahara-dashboard / saharadashboard / jobs / workflows / launch.py View on Github external
import logging

from django.utils.translation import ugettext as _
from horizon import forms
from horizon import workflows

from saharadashboard.api.client import client as saharaclient
import saharadashboard.cluster_templates.workflows.create as t_flows
import saharadashboard.clusters.workflows.create as c_flow
import saharadashboard.utils.workflow_helpers as whelpers


LOG = logging.getLogger(__name__)


class JobExecutionGeneralConfigAction(workflows.Action):
    job_input = forms.ChoiceField(
        label=_("Input"),
        required=True,
        initial=(None, "None"),
        widget=forms.Select(attrs={"class": "job_input_choice"}))

    job_output = forms.ChoiceField(
        label=_("Output"),
        required=True,
        initial=(None, "None"),
        widget=forms.Select(attrs={"class": "job_output_choice"}))

    def __init__(self, request, *args, **kwargs):
        super(JobExecutionGeneralConfigAction, self).__init__(request,
                                                              *args,
                                                              **kwargs)
github openstack / freezer-web-ui / disaster_recovery / sessions / workflows / attach.py View on Github external
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from django.utils.translation import ugettext_lazy as _
from django.urls import reverse

from horizon import exceptions
from horizon import forms
from horizon import workflows

import disaster_recovery.api.api as freezer_api


class SessionConfigurationAction(workflows.Action):
    session_id = forms.ChoiceField(
        help_text=_("Set a session to attach this job"),
        label=_("Session Name"))

    job_id = forms.CharField(
        widget=forms.HiddenInput())

    def populate_session_id_choices(self, request, context):
        sessions = []
        try:
            sessions = freezer_api.Session(request).list()
        except Exception:
            exceptions.handle(request, _('Error getting session list'))

        sessions = [(s.session_id, s.description) for s in sessions]
        sessions.insert(0, ('', _('Select A Session')))
github openstack / horizon / openstack_dashboard / dashboards / project / instances / workflows / update_instance.py View on Github external
try:
            api.nova.server_update(request,
                                   data['instance_id'],
                                   data['name'])
        except Exception:
            exceptions.handle(request, ignore=True)
            return False
        return True

    class Meta(object):
        name = _("Information")
        slug = 'instance_info'
        help_text = _("Edit the instance details.")


class UpdateInstanceInfo(workflows.Step):
    action_class = UpdateInstanceInfoAction
    depends_on = ("instance_id",)
    contributes = ("name",)


class UpdateInstance(workflows.Workflow):
    slug = "update_instance"
    name = _("Edit Instance")
    finalize_button_name = _("Save")
    success_message = _('Modified instance "%s".')
    failure_message = _('Unable to modify instance "%s".')
    success_url = "horizon:project:instances:index"
    default_steps = (UpdateInstanceInfo,
                     UpdateInstanceSecurityGroups)

    def format_status_message(self, message):
github openstack / horizon / openstack_dashboard / dashboards / project / networks / subnets / workflows.py View on Github external
def clean(self):
        cleaned_data = workflows.Action.clean(self)
        self._check_subnet_data(cleaned_data, is_create=False)
        return cleaned_data