[Et-mgmt-commits-list] [SCM] virt-factory branch, master now at v0.0.3-318-g4a2affa

Scott Seago sseago at redhat.com
Tue Oct 9 13:29:09 UTC 2007


Hello,

This is an automated email from the git hooks/update script, it was
generated because a ref change was pushed to the repository.

Updating branch, master,
       via  4a2affa99a42ddc9bf65828c09601223451fd980 (commit)
      from  e481f8e2fdf9fbbd00f5fe446bd5d1b700fd1d9e (commit)

- Log -----------------------------------------------------------------
commit 4a2affa99a42ddc9bf65828c09601223451fd980
Author: Scott Seago <sseago at redhat.com>
Date:   Tue Oct 9 09:28:34 2007 -0400

    fixed some tag bugs -- added the tag add/edit/delete api/wui
-----------------------------------------------------------------------

Diffstat:
 service/modules/deployment.py             |   89 +++++++++++++++----
 service/modules/machine.py                |   48 ++++++++++-
 service/modules/tag.py                    |  136 +++++++++++++++++++++++++++-
 wui/src/app/controllers/tag_controller.rb |   35 ++++++++
 wui/src/app/helpers/application_helper.rb |    1 +
 wui/src/app/models/deployment.rb          |    4 +
 wui/src/app/models/machine.rb             |    7 ++
 wui/src/app/models/managed_object.rb      |   18 +++-
 wui/src/app/models/tag.rb                 |   10 ++-
 wui/src/app/views/tag/edit.rhtml          |  108 +++++++++++++++++++++++
 wui/src/app/views/tag/list.rhtml          |    2 +
 11 files changed, 426 insertions(+), 32 deletions(-)

diff --git a/service/modules/deployment.py b/service/modules/deployment.py
index 06785cd..e8cfbd0 100755
--- a/service/modules/deployment.py
+++ b/service/modules/deployment.py
@@ -50,7 +50,9 @@ class Deployment(web_svc.AuthWebSvc):
                         "deployment_get": self.get,
 			"deployment_get_by_mac_address": self.get_by_mac_address,
 			"deployment_get_by_hostname": self.get_by_hostname,
-                        "deployment_get_by_tag": self.get_by_tag}
+                        "deployment_get_by_tag": self.get_by_tag,
+                        "deployment_add_tag": self.add_tag,
+                        "deployment_remove_tag": self.remove_tag}
 
         web_svc.AuthWebSvc.__init__(self)
 
@@ -210,28 +212,37 @@ class Deployment(web_svc.AuthWebSvc):
         validator = FieldValidator(args)
         validator.verify_required(required)
         validator.verify_printable('puppet_node_diff', 'tags')
-         
-        try:
-            machine_obj = machine.Machine()
-            result = machine_obj.get(token, { "id" : args["machine_id"]})
-            mac = result.data["mac_address"]
-        except VirtFactoryException:
-            raise InvalidArgumentsException(invalid_fields={"machine_id":REASON_ID})
 
-        try:
-            profile_obj = profile.Profile()
-            result = profile_obj.get(token, { "id" : args["profile_id"] })
-            profilename = result.data["name"]
-        except VirtFactoryException:
-            raise InvalidArgumentsException(invalid_fields={"machine_id":REASON_ID})
+        if args.has_key("machine_id"):
+            try:
+                machine_obj = machine.Machine()
+                result = machine_obj.get(token, { "id" : args["machine_id"]})
+                mac = result.data["mac_address"]
+            except VirtFactoryException:
+                raise InvalidArgumentsException(invalid_fields={"machine_id":REASON_ID})
+
+        if args.has_key("profile_id"):
+            try:
+                profile_obj = profile.Profile()
+                result = profile_obj.get(token, { "id" : args["profile_id"] })
+                profilename = result.data["name"]
+            except VirtFactoryException:
+                raise InvalidArgumentsException(invalid_fields={"machine_id":REASON_ID})
 
-        display_name = mac + "/" + profilename
-        args["display_name"] = display_name
         args["netboot_enabled"] = 0 # never PXE's
 
         session = db.open_session()
         try:
             deployment = db.Deployment.get(session, args['id'])
+            if args.has_key("machine_id") or args.has_key("profile_id"):
+                if not args.has_key("machine_id"):
+                    mac = deployment["machine"]["mac_address"]
+                if not args.has_key("profile_id"):
+                    profilename=deployment["profile"]["name"]
+                display_name = mac + "/" + profilename
+                args["display_name"] = display_name
+                
+                
             deployment.update(args, filter)
             session.save(deployment)
             session.flush()
@@ -406,6 +417,50 @@ class Deployment(web_svc.AuthWebSvc):
 
 
 
+    def add_tag(self, token, args):
+        """
+        Given  deployment id and tag string, apply the tag to the deployment
+        @param token: A security token.
+        @type token: string
+        @param args: A dictionary of deployment attributes.
+            - id
+            - tag
+        @type args: dict
+        @raise SQLException: On database error
+        @raise NoSuchObjectException: On object not found.
+        """
+        required = ('id', 'tag',)
+        FieldValidator(args).verify_required(required)
+        deployment = self.get(token, {"id": args["id"]}).data
+        tag = args["tag"]
+        tags = deployment["tags"]
+        if not tag in tags:
+            tags.append(tag)
+            self.edit(token, {"id": args["id"], "tags": tags})
+        return success()
+
+    def remove_tag(self, token, args):
+        """
+        Given  deployment id and tag string, remove the tag from the deployment
+        @param token: A security token.
+        @type token: string
+        @param args: A dictionary of deployment attributes.
+            - id
+            - tag
+        @type args: dict
+        @raise SQLException: On database error
+        @raise NoSuchObjectException: On object not found.
+        """
+        required = ('id', 'tag',)
+        FieldValidator(args).verify_required(required)
+        deployment = self.get(token, {"id": args["id"]}).data
+        tag = args["tag"]
+        tags = deployment["tags"]
+        if tag in tags:
+            tags.remove(tag)
+            self.edit(token, {"id": args["id"], "tags": tags})
+        return success()
+
     def get_by_mac_address(self, token, args):
         """
         """
@@ -580,7 +635,7 @@ class Deployment(web_svc.AuthWebSvc):
                     if in_tag.strip() == tag.strip():
                         result.append(deployment)
                         break
-        return codes.success(result)
+        return success(result)
 
     def expand(self, deployment):
         result = deployment.get_hash()
diff --git a/service/modules/machine.py b/service/modules/machine.py
index 77aeea3..0ddd706 100755
--- a/service/modules/machine.py
+++ b/service/modules/machine.py
@@ -40,7 +40,9 @@ class Machine(web_svc.AuthWebSvc):
 			"machine_get_by_hostname": self.get_by_hostname,
 			"machine_get_by_mac_address": self.get_by_mac_address,
                         "machine_get_profile_choices": self.get_profile_choices,
-                        "machine_get_by_tag": self.get_by_tag
+                        "machine_get_by_tag": self.get_by_tag,
+                        "machine_add_tag": self.add_tag,
+                        "machine_remove_tag": self.remove_tag
         }
         web_svc.AuthWebSvc.__init__(self)
 
@@ -287,6 +289,50 @@ class Machine(web_svc.AuthWebSvc):
         finally:
             session.close()
 
+    def add_tag(self, token, args):
+        """
+        Given  machine id and tag string, apply the tag to the machine
+        @param token: A security token.
+        @type token: string
+        @param args: A dictionary of machine attributes.
+            - id
+            - tag
+        @type args: dict
+        @raise SQLException: On database error
+        @raise NoSuchObjectException: On object not found.
+        """
+        required = ('id', 'tag',)
+        FieldValidator(args).verify_required(required)
+        machine = self.get(token, {"id": args["id"]}).data
+        tag = args["tag"]
+        tags = machine["tags"]
+        if not tag in tags:
+            tags.append(tag)
+            self.edit(token, {"id": args["id"], "tags": tags})
+        return codes.success()
+
+    def remove_tag(self, token, args):
+        """
+        Given  machine id and tag string, remove the tag from the machine
+        @param token: A security token.
+        @type token: string
+        @param args: A dictionary of machine attributes.
+            - id
+            - tag
+        @type args: dict
+        @raise SQLException: On database error
+        @raise NoSuchObjectException: On object not found.
+        """
+        required = ('id', 'tag',)
+        FieldValidator(args).verify_required(required)
+        machine = self.get(token, {"id": args["id"]}).data
+        tag = args["tag"]
+        tags = machine["tags"]
+        if tag in tags:
+            tags.remove(tag)
+            self.edit(token, {"id": args["id"], "tags": tags})
+        return codes.success()
+
     def get_by_regtoken(self, token, args):
         # FIXME: this code is currently non-operational in VF 0.0.3 and later
         # this code can be pruned if regtoken functional is needed and
diff --git a/service/modules/tag.py b/service/modules/tag.py
index 3d04965..0fa4715 100644
--- a/service/modules/tag.py
+++ b/service/modules/tag.py
@@ -14,6 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 """
 
 from server.codes import *
+from fieldvalidator import FieldValidator
 
 from datetime import *
 import os
@@ -27,10 +28,13 @@ class Tag(web_svc.AuthWebSvc):
     def __init__(self):
         self.methods = {"tag_list": self.list,
                         "tag_get_names": self.get_tag_names,
-                        "tag_get": self.get}
+                        "tag_get": self.get,
+                        "tag_add": self.add,
+                        "tag_edit": self.edit,
+                        "tag_delete": self.delete}
         web_svc.AuthWebSvc.__init__(self)
 
-    def get_tags_internal(self, module_obj, module_key, tag_dict):
+    def get_tags_internal(self, module_obj, module_key, id_key, tag_dict):
         item_list = module_obj.list(None, {})
         for item in item_list.data:
             tags = item["tags"]
@@ -39,13 +43,16 @@ class Tag(web_svc.AuthWebSvc):
                     tag_dict[tag_name]={"id": tag_name,
                                         "name": tag_name,
                                         "machines": [],
-                                        "deployments": [] }
+                                        "machine_ids": [],
+                                        "deployments": [],
+                                        "deployment_ids": [] }
                 tag_dict[tag_name][module_key].append(item)
+                tag_dict[tag_name][id_key].append(item["id"])
         return tag_dict
 
     def get_tag_dict(self):
-        tag_dict = self.get_tags_internal(machine.Machine(), "machines", {})
-        tag_dict = self.get_tags_internal(deployment.Deployment(), "deployments", tag_dict)
+        tag_dict = self.get_tags_internal(machine.Machine(), "machines", "machine_ids", {})
+        tag_dict = self.get_tags_internal(deployment.Deployment(), "deployments", "deployment_ids", tag_dict)
         return tag_dict
         
     def get(self, token, args={}):
@@ -54,6 +61,7 @@ class Tag(web_svc.AuthWebSvc):
         @param token: A security token.
         @type token: string
         @param args: A dictionary of tag attributes.
+            - id
             - name
         @type args: dict
         @return A tag
@@ -65,6 +73,9 @@ class Tag(web_svc.AuthWebSvc):
             args["name"]=args["id"]
         required = ('name',)
         FieldValidator(args).verify_required(required)
+        tag_dict = self.get_tag_dict()
+        if not tag_dict.has_key(args["name"]):
+            raise NoSuchObjectException(comment='tag %s not found' % args["name"])
         return success(self.get_tag_dict()[args["name"]])
         
     def list(self, token, args={}):
@@ -76,6 +87,121 @@ class Tag(web_svc.AuthWebSvc):
     def get_tag_names(self, token, args={}):
         return success(self.get_tag_dict().keys())
         
+    def add(self, token, args):
+        """
+        Create a tag
+        @param token: A security token.
+        @type token: string
+        @param args: A dictionary of tag attributes.
+        @type args: dict
+            - id
+            - name
+            - machine_ids
+            - deployment_ids
+        @raise SQLException: On database error
+        """
+        # also accept id for name to make WUI happy
+        if args.has_key('id') and (not args.has_key('name')):
+            args["name"]=args["id"]
+        required = ('name',)
+        optional = ('machine_ids', 'deployment_ids')
+        FieldValidator(args).verify_required(required)
+        name = args["name"]
+        machine_ids = []
+        deployment_ids = []
+        if args.has_key('machine_ids'):
+            machine_ids = args['machine_ids']
+        if args.has_key('deployment_ids'):
+            deployment_ids = args['deployment_ids']
+        if name in self.get_tag_names(token).data:
+            raise InvalidArgumentsException(comment='tag %s already exists' % name)
+        machine_obj = machine.Machine()
+        deployment_obj = deployment.Deployment()
+        for machine_id in machine_ids:
+            machine_obj.add_tag(token, {"id": machine_id, "tag": name})
+        for deployment_id in deployment_ids:
+            deployment_obj.add_tag(token, {"id": deployment_id, "tag": name})
+        return success()
+         
+    def edit(self, token, args):
+        """
+        Edit a tag
+        @param token: A security token.
+        @type token: string
+        @param args: A dictionary of tag attributes.
+        @type args: dict
+            - id
+            - name
+            - machine_ids
+            - deployment_ids
+        @raise SQLException: On database error
+        @raise NoSuchObjectException: On object not found.
+        """
+        # also accept id for name to make WUI happy
+        if args.has_key('id') and (not args.has_key('name')):
+            args["name"]=args["id"]
+        required = ('name',)
+        optional = ('machine_ids', 'deployment_ids')
+        FieldValidator(args).verify_required(required)
+        name = args["name"]
+        machine_ids = []
+        deployment_ids = []
+        db_machine_ids = []
+        db_deployment_ids = []
+        if args.has_key('machine_ids'):
+            machine_ids = args['machine_ids']
+        if args.has_key('deployment_ids'):
+            deployment_ids = args['deployment_ids']
+        tag_in_db = self.get(token, {"name":  name}).data
+        machine_obj = machine.Machine()
+        deployment_obj = deployment.Deployment()
+
+        # loop through current machines for this tag -- remove
+        # any that are not in the new list
+        for db_machine in tag_in_db["machines"]:
+            this_id = db_machine["id"]
+            db_machine_ids.append(this_id)
+            if this_id not in machine_ids:
+                machine_obj.remove_tag(token, {"id": this_id, "tag": name})
+
+        # loop through current deployments for this tag -- remove
+        # any that are not in the new list
+        for db_deployment in tag_in_db["deployments"]:
+            this_id = db_deployment["id"]
+            db_deployment_ids.append(this_id)
+            if this_id not in deployment_ids:
+                deployment_obj.remove_tag(token, {"id": this_id, "tag": name})
+            
+        # loop through new machines for this tag -- add
+        # any that are not in the current list
+        for machine_id in machine_ids:
+            if machine_id not in db_machine_ids:
+                machine_obj.add_tag(token, {"id": machine_id, "tag": name})
+
+        # loop through new deployments for this tag -- add
+        # any that are not in the current list
+        for deployment_id in deployment_ids:
+            if deployment_id not in db_deployment_ids:
+                deployment_obj.add_tag(token, {"id": deployment_id, "tag": name})
+                
+        return success()
+         
+    def delete(self, token, args):
+        """
+        Deletes a tag.
+        @param token: A security token.
+        @type token: string
+        @param args: A dictionary of user attributes.
+            - id
+        @type args: dict
+        @raise SQLException: On database error
+        @raise NoSuchObjectException: On object not found.
+        """
+        if args.has_key('id') and (not args.has_key('name')):
+            args["name"]=args["id"]
+        return self.edit(token, {"name": args["name"], "deployment_ids": [], "machine_ids": []})
+
+
 
 methods = Tag()
 register_rpc = methods.register_rpc
diff --git a/wui/src/app/controllers/tag_controller.rb b/wui/src/app/controllers/tag_controller.rb
index 31d8aaf..c411136 100644
--- a/wui/src/app/controllers/tag_controller.rb
+++ b/wui/src/app/controllers/tag_controller.rb
@@ -24,4 +24,39 @@ class TagController < AbstractObjectController
        Tag
    end
 
+   def edit
+        super
+        @machines = ManagedObject.retrieve_all(Machine, get_login)
+        @deployments = ManagedObject.retrieve_all(Deployment, get_login)
+    end
+
+    def edit_submit
+        machine_ids = params["form"]["machine_ids"]
+        machine_ids = [] if machine_ids.nil?
+        deployment_ids = params["form"]["deployment_ids"]
+        deployment_ids = [] if deployment_ids.nil?
+        super
+    end
+
+    def remove_machine
+        args = { "id" => params[:machine_id], "tag" => params[:id]}
+        begin
+            ManagedObject.call_server("machine_remove_tag", get_login, args)
+        rescue XMLRPCClientException => ex
+            set_flash_on_exception(ex)
+        end
+        redirect_to :action=> "edit", :id => params[:id]
+    end
+
+    def remove_deployment
+        args = { "id" => params[:deployment_id], "tag" => params[:id]}
+        begin
+            ManagedObject.call_server("deployment_remove_tag", get_login, args)
+        rescue XMLRPCClientException => ex
+            set_flash_on_exception(ex)
+        end
+        redirect_to :action=> "edit", :id => params[:id]
+    end
+
+
 end
diff --git a/wui/src/app/helpers/application_helper.rb b/wui/src/app/helpers/application_helper.rb
index dc1dfa4..4deb16b 100644
--- a/wui/src/app/helpers/application_helper.rb
+++ b/wui/src/app/helpers/application_helper.rb
@@ -43,6 +43,7 @@ module ApplicationHelper
        <li><strong><%= _("Tags") %></strong>
            <ul>
            <li><A HREF="#{app_root}/tag/list"><%= _("View Tags") %></A></li>
+           <li><A HREF="#{app_root}/tag/edit"><%= _("Add a Tag") %></A></li>
            </ul>
        </li>
        <li><strong><%= _("Users") %></strong>
diff --git a/wui/src/app/models/deployment.rb b/wui/src/app/models/deployment.rb
index 8fcdecd..9ccf7b7 100755
--- a/wui/src/app/models/deployment.rb
+++ b/wui/src/app/models/deployment.rb
@@ -39,6 +39,10 @@ class Deployment < ManagedObject
         (machine.nil? ? "no machine" : machine.hostname) + ": " + (profile.nil? ? "no profile" : profile.name)
     end
 
+    def label
+        "#{self.hostname} (#{self.mac_address})"
+    end
+
     def __virt_call(id, op)
         ManagedObject.call_server(op, self.login, { "id" => id }, id.to_s)
     end
diff --git a/wui/src/app/models/machine.rb b/wui/src/app/models/machine.rb
index 14a0f4b..c9e5ac3 100755
--- a/wui/src/app/models/machine.rb
+++ b/wui/src/app/models/machine.rb
@@ -46,6 +46,13 @@ class Machine < ManagedObject
         super
     end
 
+    def label
+        "#{self.hostname} (#{self.mac_address})"
+    end
+    def id_str
+        "#{self.id}"
+    end
+
     def get_profile_choices
         ManagedObject.call_server("machine_get_profile_choices", 
                                   self.login, { "id" => id }, id.to_s)
diff --git a/wui/src/app/models/managed_object.rb b/wui/src/app/models/managed_object.rb
index 954f078..92c8b26 100755
--- a/wui/src/app/models/managed_object.rb
+++ b/wui/src/app/models/managed_object.rb
@@ -51,11 +51,19 @@ class ManagedObject
                    
                     if !instance_variable_get(attr_symbol)
                         id = instance_variable_get(id_symbol) 
-                        if (!id.nil? && id >= 0)
-                           object = ManagedObject.retrieve(metadata[:type], self.login, id) 
-                           instance_variable_set(attr_symbol, object)
+			if id.is_a?(Array)
+                            object = []
+			    id.each do |one_id|
+                               object << ManagedObject.retrieve(metadata[:type], self.login, one_id) 
+                            end
+                            instance_variable_set(attr_symbol, object)
+                        else
+                            if (!id.nil? && id >= 0)
+                               object = ManagedObject.retrieve(metadata[:type], self.login, id) 
+                               instance_variable_set(attr_symbol, object)
+                            end
                         end
-                    end
+                     end
                     return instance_variable_get(attr_symbol)
 
                 end # define_method
@@ -72,7 +80,7 @@ class ManagedObject
     # the backend will ignore the ones it doesn't need or can't change.
 
     def save
-        operation = (@id.nil? ||  @id < 0) ? "add" : "edit"
+        operation = (@id.nil? || (@id.is_a?(Integer) && (@id < 0)) || (@id.is_a?(String) && @id.empty?)) ? "add" : "edit"
         ManagedObject.call_server("#{self.class::METHOD_PREFIX}_#{operation}", 
                                        self.login, self.to_hash, objname)
     end
diff --git a/wui/src/app/models/tag.rb b/wui/src/app/models/tag.rb
index 908853e..3397bf2 100644
--- a/wui/src/app/models/tag.rb
+++ b/wui/src/app/models/tag.rb
@@ -5,10 +5,12 @@ class Tag < ManagedObject
     # corresponds to what's in the DB schema
  
     ATTR_LIST = { 
-        :id          => {:type => String}, 
-        :name        => {:type => String}, 
-        :machines    => {:type => [Array, Machine]},
-        :deployments => {:type => [Array, Deployment]}
+        :id             => {:type => String}, 
+        :name           => {:type => String}, 
+        :machines       => {:type => [Array, Machine], :id_attr => :machine_ids},
+        :machine_ids    => {:type => [Array, Integer]},
+        :deployments    => {:type => [Array, Deployment], :id_attr => :deployment_ids},
+        :deployment_ids => {:type => [Array, Integer]}
     }
     self.set_attrs(ATTR_LIST)
 
diff --git a/wui/src/app/views/tag/edit.rhtml b/wui/src/app/views/tag/edit.rhtml
new file mode 100755
index 0000000..fc39688
--- /dev/null
+++ b/wui/src/app/views/tag/edit.rhtml
@@ -0,0 +1,108 @@
+      <% @page_title = @operation.capitalize() + " A Tag" %>
+	<% @primary =  "tag" %>
+	<% @seconardy = "edit" %> 
+
+      <div id="content-main">
+      <% if @operation == "edit" %>
+        <h2> Hosts tagged with <%=@item.name %></h2>
+        <% if @item.machines.length > 0 %>
+          <table class='listing'>
+            <thead>
+              <th><%= _("Hostname") %></th>
+              <th><%= _("Profile") %></th>
+              <th><%= _("Mac Address") %></th>
+              <th colspan="2"><%= _("Actions") %></th>
+            </thead>
+          <% @item.machines.each do |item| %>
+            <% if item.is_locked == 1 %>
+              <TR BGCOLOR="#555555">
+            <% else %>
+              <TR class="<%= cycle('odd','even') %>">
+            <% end %>
+             
+                <TD> <%= item.hostname ? item.hostname : _("(Pending)") %> </TD>
+                <TD> <%= (link_to item.profile.name, :controller => "profile", :action=> "view", :id=> item.profile.id) if item.profile %></TD>
+                <TD> <%= item.mac_address %> </TD>
+                <TD> <%= item.state       %> </TD>
+                <% if item.is_locked == 1 %>
+                  <TD COLSPAN="2"><%= _("(Locked)") %></TD>
+                <% else %>
+                  <TD> <%= link_to "[edit]", :controller => "machine", :action=> "edit", :id=> item.id %></TD>
+                  <TD> <%= link_to "[remove tag]", :controller => "tag", :action=> "remove_machine", :id=>@item.id, :machine_id=> item.id %></TD>
+                <% end %>
+            </TR>
+          <% end %>
+        </TABLE>
+        <% else %>
+          <%= _("No hosts are tagged with #{@item.name}.") %>
+        <% end %>
+      
+
+
+        <h2> Guests tagged with <%=@item.name %></h2>
+        <% if @item.deployments.length > 0 %>
+          <table class='listing'>
+            <thead>
+              <th><%= _("Host Machine") %></th>
+              <th><%= _("Virtual Hostname") %></th>
+              <th><%= _("IP") %></th>
+              <th><%= _("Mac Address") %></th>
+              <th><%= _("Profile") %></th>
+              <th><%= _("State") %></th>
+              <th colspan="2"><%= _("Actions") %></th>
+            </thead>
+          <% @item.deployments.each do |item| %>
+           <TR class="<%= cycle('odd','even') %>">
+             <TD> <%= link_to item.machine.hostname, :controller => "machine", :action=> "edit", :id=> item.machine.id %></TD>
+             <TD> <%= item.hostname ? item.hostname : "(Unknown)" %> </TD>
+             <TD> <%= item.ip_address ? item.ip_address : "(Unknown)" %> </TD>
+             <TD> <%= item.mac_address ? item.mac_address : "(Unknown)" %> </TD>
+             <TD> <%= link_to item.profile.name, :controller => "profile", :action=> "view", :id=> item.profile.id %></TD>
+             <TD> <%= item.state %> </TD>
+             <TD> <%= link_to "[edit]", :controller => "deployment", :action=> "edit", :id=> item.id %></TD>
+             <TD> <%= link_to "[remove tag]", :controller => "tag", :action=> "remove_deployment", :id=>@item.id, :deployment_id=> item.id %></TD>
+           </TR>
+          <% end %>
+          </TABLE>
+        <% else %>
+          <%= _("No guests are tagged with #{@item.name}.") %>
+        <% end %>
+      <h2> <%= _("Modify this tag") %></h2>
+      <% end %>
+      <br/>
+      <% form_for :form, @item, :url => { :action => "edit_submit" } do |f| %>
+      <%= f.hidden_field :id %>
+      <%= f.hidden_field :name if @operation == "edit" %>
+      <table class='details'>
+         <TR>
+            <TD><%= _("Name") %></TD>
+            <TD><%= if @operation == "add"
+	                f.text_field :name
+	            else
+ 	                @item.name
+                    end %>
+             </TD>
+         </TR>
+         <% if @operation == "edit" %>
+         <% end %>
+         <TR>
+            <TD><%= _("Add/Remove Hosts") %></TD>
+            <TD>
+                <%= f.collection_select(:machine_ids,  @machines, :id, :label,
+                    {},"multiple"=>'multiple',"size"=>10) %></td>
+            </TD>
+         </TR>
+         <TR>
+            <TD><%= _("Add/Remove Guests") %></TD>
+            <TD>
+                <%= f.collection_select(:deployment_ids,  @deployments, :id, :label,
+                    {},"multiple"=>'multiple',"size"=>10) %></td>
+            </TD>
+         </TR>
+         <TR>
+            <TD COLSPAN="2"><input type="submit" value="<%= @operation=="edit" ?  _("Edit") : _("Add") %>"></TD>
+         </TR>
+      </TABLE>
+      <% end %>
+      </div>
+
diff --git a/wui/src/app/views/tag/list.rhtml b/wui/src/app/views/tag/list.rhtml
index 83e9e65..a62b3d2 100755
--- a/wui/src/app/views/tag/list.rhtml
+++ b/wui/src/app/views/tag/list.rhtml
@@ -26,6 +26,8 @@
                      <%= deployment.hostname %> (<%= deployment.mac_address %>)<br/>
                  <% end %>
              </TD>
+             <TD> <%= link_to "[edit]", :controller => "tag", :action=> "edit", :id=> item.id %></TD>
+             <TD> <%= link_to "[delete]", :controller => "tag", :action=> "delete", :id=> item.id %></TD>
          </TR>
       <% end %>
       </TABLE>

hooks/update
---
Git Source Code Management System
hooks/update refs/heads/master \
  e481f8e2fdf9fbbd00f5fe446bd5d1b700fd1d9e \
  4a2affa99a42ddc9bf65828c09601223451fd980




More information about the Et-mgmt-commits-list mailing list