def get_context_data(self, **kwargs): context = super(DetailServiceView, self).get_context_data(**kwargs) context["service"] = self.get_data() context["service_name"] = getattr(self.service, 'name', '-') env = api.environment_get(self.request, self.environment_id) context["environment_name"] = env.name return context
def load_tab_data(self): if self._data is None: environment_id = tables.get_scheduler_id() env = api.environment_get(self.request, environment_id) self._data = {} self._data['env'] = env self._data['services'] = api.services_list(self.request, environment_id, env)
def get_context_data(self, **kwargs): context = super(EnvironmentDetails, self).get_context_data(**kwargs) try: self.environment_id = self.kwargs['environment_id'] env = api.environment_get(self.request, self.environment_id) context['environment_name'] = env.name except Exception: msg = _("Sorry, this environment doesn't exist anymore") redirect = self.get_redirect_url() exceptions.handle(self.request, msg, redirect=redirect) return context context['tenant_id'] = self.request.session['token'].tenant['id'] context["url"] = self.get_redirect_url() table = env_tables.EnvironmentsTable(self.request) # record the origin row_action for EnvironmentsTable Meta ori_row_actions = table._meta.row_actions # remove the duplicate 'Manage Components' and 'DeployEnvironment' # actions that have already in Environment Details page # from table.render_row_actions, so the action render to the detail # page will exclude those two actions. table._meta.row_actions = filter( lambda x: x.name not in ('show', 'deploy'), table._meta.row_actions) context["actions"] = table.render_row_actions(env) # recover the origin row_action for EnvironmentsTable Meta table._meta.row_actions = ori_row_actions context['poll_interval'] = conf.HORIZON_CONFIG['ajax_poll_interval'] return context
def load_tab_data(self): if self._data is None: environment_id = self.kwargs['environment_id'] env = api.environment_get(self.request, environment_id) self._data = {} self._data['env'] = env self._data['services'] = api.services_list(self.request, environment_id, env)
def get_object(self): environment_id = self.kwargs['environment_id'] try: return api.environment_get(self.request, environment_id) except Exception: redirect = reverse("horizon:murano:environments:index") msg = _('Unable to retrieve environment details.') exceptions.handle(self.request, msg, redirect=redirect)
def creation_allowed(self, request, environment): environment_id = self.table.kwargs['environment_id'] env = api.environment_get(request, environment_id) status = getattr(env, 'status', None) if status not in [STATUS_ID_DEPLOYING]: return True return False
def get_context_data(self, **kwargs): context = super(DeploymentDetailsView, self).get_context_data(**kwargs) context["environment_id"] = self.environment_id env = api.environment_get(self.request, self.environment_id) context["environment_name"] = env.name context["deployment_start_time"] = api.get_deployment_start( self.request, self.environment_id, self.deployment_id ) return context
def allowed(self, request, environment): if environment: environment = api.environment_get(request, environment.id) if environment.status == STATUS_ID_DEPLOYING: deployment = api.deployments_list(request, environment.id)[0] last_action = timeutils.parse_strtime( deployment.started.replace(' ', 'T'), timeutils._ISO8601_TIME_FORMAT) return timeutils.is_older_than(last_action, 15 * 60) return True
def get_context_data(self, **kwargs): context = super(DeploymentDetailsView, self).get_context_data(**kwargs) context["environment_id"] = self.environment_id env = api.environment_get(self.request, self.environment_id) context["environment_name"] = env.name context["deployment_start_time"] = \ api.get_deployment_start(self.request, self.environment_id, self.deployment_id) return context
def get_object(self, *args, **kwargs): if not hasattr(self, "_object"): environment_id = self.kwargs['environment_id'] try: self._object = \ api.environment_get(self.request, environment_id) except Exception: redirect = reverse("horizon:murano:environments:index") msg = _('Unable to retrieve environment details.') exceptions.handle(self.request, msg, redirect=redirect) return self._object
def get_data(self, request, environment_id): try: return api.environment_get(request, environment_id) except exc.HTTPNotFound: # returning 404 to the ajax call removes the # row from the table on the ui raise django_http.Http404 except Exception: # let our unified handler take care of errors here with api_utils.handled_exceptions(request): raise
def allowed(self, request, service): environment_id = self.table.kwargs['environment_id'] env = api.environment_get(request, environment_id) status = getattr(env, 'status', None) version = getattr(env, 'version', None) if status == STATUS_ID_DEPLOYING: return False services = self.table.data if version == 0 and not services: return False return True
def get_context_data(self, **kwargs): context = super(DetailServiceView, self).get_context_data(**kwargs) service = self.get_data() context["service"] = service context["service_name"] = getattr(self.service, 'name', '-') env = api.environment_get(self.request, self.environment_id) context["environment_name"] = env.name breadcrumb = [(context["environment_name"], reverse("horizon:app-catalog:environments:services", args=[self.environment_id])), (_('Applications'), None)] context["custom_breadcrumb"] = breadcrumb return context
def get_context_data(self, **kwargs): context = super(EnvironmentDetails, self).get_context_data(**kwargs) try: self.environment_id = self.kwargs['environment_id'] env = api.environment_get(self.request, self.environment_id) context['environment_name'] = env.name except Exception: msg = _("Sorry, this environment doesn't exist anymore") redirect = reverse("horizon:murano:environments:index") exceptions.handle(self.request, msg, redirect=redirect) return context
def get_context_data(self, **kwargs): context = super(DetailServiceView, self).get_context_data(**kwargs) service = self.get_data() context["service"] = service context["service_name"] = getattr(self.service, 'name', '-') env = api.environment_get(self.request, self.environment_id) context["environment_name"] = env.name breadcrumb = [ (context["environment_name"], reverse("horizon:app-catalog:environments:services", args=[self.environment_id])), (_('Applications'), None)] context["custom_breadcrumb"] = breadcrumb return context
def get_context_data(self, **kwargs): context = super(EnvironmentDetails, self).get_context_data(**kwargs) try: self.environment_id = self.kwargs['environment_id'] env = api.environment_get(self.request, self.environment_id) context['environment_name'] = env.name except Exception: msg = _("Sorry, this environment doesn't exist anymore") redirect = reverse("horizon:murano:environments:index") exceptions.handle(self.request, msg, redirect=redirect) context['tenant_id'] = self.request.session['token'].tenant['id'] return context
def get_context_data(self, **kwargs): context = super(DetailServiceView, self).get_context_data(**kwargs) service = self.get_data() context["service"] = service context["service_name"] = getattr(self.service, "name", "-") env = api.environment_get(self.request, self.environment_id) context["environment_name"] = env.name breadcrumb = [ (_("Environments"), EnvironmentDetails.get_redirect_url()), (context["environment_name"], reverse("horizon:murano:environments:services", args=[self.environment_id])), (_("Applications"),), ] context["custom_breadcrumb"] = breadcrumb return context
def get_context_data(self, **kwargs): context = super(DeploymentDetailsView, self).get_context_data(**kwargs) context["environment_id"] = self.environment_id env = api.environment_get(self.request, self.environment_id) context["environment_name"] = env.name context["deployment_start_time"] = api.get_deployment_start( self.request, self.environment_id, self.deployment_id ) breadcrumb = [ (_("Environments"), EnvironmentDetails.get_redirect_url()), (context["environment_name"], reverse("horizon:murano:environments:services", args=[self.environment_id])), (_("Deployments"),), ] context["custom_breadcrumb"] = breadcrumb return context
def get_context_data(self, **kwargs): context = super(EnvironmentDetails, self).get_context_data(**kwargs) try: self.environment_id = self.kwargs["environment_id"] env = api.environment_get(self.request, self.environment_id) context["environment_name"] = env.name except Exception: msg = _("Sorry, this environment doesn't exist anymore") redirect = self.get_redirect_url() exceptions.handle(self.request, msg, redirect=redirect) context["tenant_id"] = self.request.session["token"].tenant["id"] context["url"] = self.get_redirect_url() return context
def get_context_data(self, **kwargs): context = super(DeploymentDetailsView, self).get_context_data(**kwargs) context["environment_id"] = self.environment_id env = api.environment_get(self.request, self.environment_id) context["environment_name"] = env.name context["deployment_start_time"] = \ api.get_deployment_start(self.request, self.environment_id, self.deployment_id) breadcrumb = [ (context["environment_name"], reverse("horizon:app-catalog:environments:services", args=[self.environment_id])), (_('Deployments'), None)] context["custom_breadcrumb"] = breadcrumb return context
def update_network_params(self, request, environment_id): env = env_api.environment_get(request, environment_id) self.existing_subnet = env.networking.get('cidr') self.network_topology = env.networking.get('topology')
def _get_environment_status_and_version(request, table): environment_id = table.kwargs.get('environment_id') env = api.environment_get(request, environment_id) status = getattr(env, 'status', None) version = getattr(env, 'version', None) return status, version
def get_data(self, request, environment_id): return api.environment_get(request, environment_id)
def allowed(self, request, service=None): environment_id = self.table.kwargs.get('environment_id') env = api.environment_get(request, environment_id) status = getattr(env, 'status', None) return False if status == STATUS_ID_DEPLOYING else True