Ejemplo n.º 1
0
 def get_context_data(self, **kwargs):
   context = super(IndexView, self).get_context_data(**kwargs)
   hardwares_detail=trinity.hardwares_detail(self.request)
   hardwares={'hardwares':hardwares_detail}
   context.update(hardwares)
   version=trinity.version(self.request)
   version_dict={"version":version}
   context.update(version_dict)
   return context
Ejemplo n.º 2
0
  def  __init__(self,request, context,*args, **kwargs):
    super(AllocateAction,self).__init__(request, context,*args, **kwargs) 
    hardwares=trinity.hardwares_list(request)
    cluster=self.initial['cluster']
    field        = forms.CharField   (label=_("Name of the cluster"),
                         required=True, initial=cluster)
    self.fields.update({'name':field})
    cluster_hardware=trinity.cluster_hardware(request,cluster)
    hardwares_detail=trinity.hardwares_detail(request)
    for hardware in hardwares:
      for datum in hardwares_detail:
        if datum["hardware"]==hardware:
          max_value=datum["total"]-datum["used"]
          break

      initial_nodes=0
      for datum in cluster_hardware:
        if datum.type==hardware:
          initial_nodes=datum.amount
          max_value=max_value+initial_nodes
          break
      field =  forms.IntegerField(label=_("Number of "+hardware+" nodes"),
                         min_value=0,max_value=max_value,initial=initial_nodes)
      self.fields.update({hardware:field})
Ejemplo n.º 3
0
    def __init__(self, request, context, *args, **kwargs):
        super(AllocateAction, self).__init__(request, context, *args, **kwargs)
        hardwares = trinity.hardwares_list(request)
        cluster = self.initial["cluster"]
        field = forms.CharField(label=_("Name of the cluster"), required=True, initial=cluster)
        self.fields.update({"name": field})
        cluster_hardware = trinity.cluster_hardware(request, cluster)
        hardwares_detail = trinity.hardwares_detail(request)
        for hardware in hardwares:
            for datum in hardwares_detail:
                if datum["hardware"] == hardware:
                    max_value = datum["total"] - datum["used"]
                    break

            initial_nodes = 0
            for datum in cluster_hardware:
                if datum.type == hardware:
                    initial_nodes = datum.amount
                    max_value = max_value + initial_nodes
                    break
            field = forms.IntegerField(
                label=_("Number of " + hardware + " nodes"), min_value=0, max_value=max_value, initial=initial_nodes
            )
            self.fields.update({hardware: field})