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

Michael DeHaan mdehaan at redhat.com
Wed Jul 25 16:01:22 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  37946fc431bc3fc9979db27a272a1208a67fe4a3 (commit)
       via  03a3ce0f77c3849ee41eb0b861a1ecbc1e9e6ce5 (commit)
       via  5a5a0b70450efdd1d493cef0fec35f5bbff729ac (commit)
      from  5488e0183ea21295973828cba81ca15e946e38f5 (commit)

- Log -----------------------------------------------------------------
commit 37946fc431bc3fc9979db27a272a1208a67fe4a3
Author: Michael DeHaan <mdehaan at mdehaan.rdu.redhat.com>
Date:   Wed Jul 25 12:02:46 2007 -0400

    Disable SQL echo.

commit 03a3ce0f77c3849ee41eb0b861a1ecbc1e9e6ce5
Merge: 5a5a0b7... 5488e01...
Author: Michael DeHaan <mdehaan at mdehaan.rdu.redhat.com>
Date:   Wed Jul 25 12:00:13 2007 -0400

    Merge branch 'master' of git+ssh://g-mdehaan@et.redhat.com/git/virt-factory

commit 5a5a0b70450efdd1d493cef0fec35f5bbff729ac
Author: Michael DeHaan <mdehaan at mdehaan.rdu.redhat.com>
Date:   Tue Jul 24 15:03:05 2007 -0400

    Working on fixing node status and making it use libvirt.
-----------------------------------------------------------------------

Diffstat:
 nodes/modules/virt.py                            |   88 +++++++++++-----------
 service/modules/deployment.py                    |   27 ++++++-
 service/server/db.py                             |    5 +-
 wui/src/app/controllers/deployment_controller.rb |    2 +-
 wui/src/app/models/deployment.rb                 |    8 +-
 wui/src/app/views/deployment/edit.rhtml          |    5 +-
 6 files changed, 82 insertions(+), 53 deletions(-)

diff --git a/nodes/modules/virt.py b/nodes/modules/virt.py
index 8ffc769..f902160 100755
--- a/nodes/modules/virt.py
+++ b/nodes/modules/virt.py
@@ -105,7 +105,7 @@ class Virt(web_svc.WebSvc):
         # name we use
         needle = mac_address.replace(":","_").upper()
 
-        ids = conn.listDomainsID()
+        ids = self.xen_conn.listDomainsID()
         for domain in ids:
             try:
                 domain = self.xen_conn.lookupByID(domain)
@@ -125,7 +125,7 @@ class Virt(web_svc.WebSvc):
         Whatever that takes.
         """
         self.find_vm(mac_address).shutdown()
-        return True        
+        return success()        
 
     #=======================================================================
    
@@ -135,7 +135,7 @@ class Virt(web_svc.WebSvc):
         Pause the machine with the given mac_address.
         """
         self.find_vm(mac_address).suspend()
-        return True
+        return success()
 
     #=======================================================================
    
@@ -146,7 +146,7 @@ class Virt(web_svc.WebSvc):
         """
 
         self.find_vm(mac_address).resume()
-        return True
+        return success()
 
     #=======================================================================
 
@@ -156,7 +156,7 @@ class Virt(web_svc.WebSvc):
         Start the machine via the given mac address. 
         """
         self.find_vm(mac_address).create()
-        return True  
+        return success()
  
     # ======================================================================
 
@@ -167,7 +167,7 @@ class Virt(web_svc.WebSvc):
         time to virtually shut down.
         """
         self.find_vm(mac_address).destroy()
-        return True
+        return success()
 
 
     #=======================================================================
@@ -180,7 +180,7 @@ class Virt(web_svc.WebSvc):
         """
 
         self.find_vm(mac_address).undefine()
-        return True
+        return success()
 
     #=======================================================================
 
@@ -195,47 +195,47 @@ class Virt(web_svc.WebSvc):
         #  STATE  = [0]
 
         state = self.find_vm(mac_address).info()[1]
-        return success("STATE=%s" % VIRT_NAME_STATE_MAP.get(state,"unknown"))
+        return success("state=%s" % VIRT_STATE_NAME_MAP.get(state,"unknown"))
 
 
     #=======================================================================
 
-    def __get_xm_state(self, mac_address):
-
-        """
-
-        Run xm to get the state portion out of the output.
-        This will be a width 5 string that may contain:
-        
-           p       -- paused
-           r       -- running
-           b       -- blocked  (basically running though)
-           "-----" -- no state (basically running though)
-        
-        if not found at all, the domain doesn't at all exist, or it's off.
-        since we'll know if virtfactory deleted it, assume off.  if needed,
-        we can later comb the Xen directories to see if a file is still around.
-
-        """  
-
-        cmd_mac = mac_address.replace(":","_").upper()
-        output = self.__run_xm("list", None, True)
-        lines = output.split("\n")
-        if len(lines) == 1:
-            print "state --> off"
-            return "off"
-        for line in lines[1:]:
-            try:
-                (name, id, mem, cpus, state, time) = line.split(None)
-                if name == cmd_mac:
-                    print "state --> %s" % state
-                    return state       
-            except:
-                pass
-        print "state --> off"      
-        return "off"
-
-    #=======================================================================
+#    #def __get_xm_state(self, mac_address):
+#
+#        """
+#
+#        Run xm to get the state portion out of the output.
+#        This will be a width 5 string that may contain:
+#        
+#           p       -- paused
+#           r       -- running
+#           b       -- blocked  (basically running though)
+#           "-----" -- no state (basically running though)
+#        
+#        if not found at all, the domain doesn't at all exist, or it's off.
+#        since we'll know if virtfactory deleted it, assume off.  if needed,
+#        we can later comb the Xen directories to see if a file is still around.
+#
+#        """  
+#
+#        cmd_mac = mac_address.replace(":","_").upper()
+#        output = self.__run_xm("list", None, True)
+#        lines = output.split("\n")
+#        if len(lines) == 1:
+#            print "state --> off"
+#            return "off"
+#        for line in lines[1:]:
+#            try:
+#                (name, id, mem, cpus, state, time) = line.split(None)
+#                if name == cmd_mac:
+#                    print "state --> %s" % state
+#                    return state       
+#            except:
+#                pass
+#        print "state --> off"      
+#        return "off"
+#
+#    #=======================================================================
 
 
 methods = Virt()
diff --git a/service/modules/deployment.py b/service/modules/deployment.py
index a63a7a8..349afd1 100755
--- a/service/modules/deployment.py
+++ b/service/modules/deployment.py
@@ -323,6 +323,12 @@ class Deployment(web_svc.AuthWebSvc):
         @rtype: [dict,]
         @raise SQLException: On database error
         """
+
+        # it is going to be expensive to query all of the list results
+        # for an update.  so right now, we're doing it only for 1-item
+        # gets, with the thought that nodes should be sending async
+        # updates, or that we are periodically polling them for status
+
         session = db.open_session()
         try:
             result = []
@@ -432,15 +438,16 @@ class Deployment(web_svc.AuthWebSvc):
             session.close()
 
 
-    def refresh(self, token, args):
+    def refresh(self, token, get_results):
          """
          Most all node actions are out of band (scheduled) but we need
          the current state when loading the edit page
          """
 
-         dargs = self.get(token, { "id" : args["id"] }).data
+         dargs = get_results
+
+         self.logger.info("refresh request for: %s" % get_results)
 
-         self.logger.info("running refresh code")
          cmd = [
             "/usr/bin/vf_nodecomm",
             socket.gethostname(),
@@ -479,12 +486,26 @@ class Deployment(web_svc.AuthWebSvc):
         @raise SQLException: On database error
         @raise NoSuchObjectException: On object not found.
         """
+
+
         required = ('id',)
         FieldValidator(args).verify_required(required)
         session = db.open_session()
         try:
             deployment = db.Deployment.get(session, args['id'])
+            results = self.expand(deployment)
+
+            self.logger.info("your deployment is: %s" % results)
+ 
+            # we want the state "now" so we must contact the node
+            # to update it!
+            self.refresh(token, results)
+
+            # now re-get the updated record which will have an
+            # accurate state.
+            deployment = db.Deployment.get(session, args['id'])
             return success(self.expand(deployment))
+
         finally:
             session.close()
 
diff --git a/service/server/db.py b/service/server/db.py
index 1aef23f..94c87f0 100644
--- a/service/server/db.py
+++ b/service/server/db.py
@@ -347,7 +347,10 @@ class Database:
 
         if not Database.has_loaded:
 
-            global_connect(interpolate_url_password(url), echo=True)
+            # FIXME: this echo causes output for every query to go to stdout
+            # Should always be False in version control. May want to
+            # parameterize it.
+            global_connect(interpolate_url_password(url), echo=False)
             Database.has_loaded = True       
  
 
diff --git a/wui/src/app/controllers/deployment_controller.rb b/wui/src/app/controllers/deployment_controller.rb
index 85324e0..0eedb3f 100755
--- a/wui/src/app/controllers/deployment_controller.rb
+++ b/wui/src/app/controllers/deployment_controller.rb
@@ -14,7 +14,7 @@ class DeploymentController < AbstractObjectController
        # current state is, and update it.
        if !params[:id].nil?
            obj = ManagedObject.retrieve(Deployment, get_login, params[:id])
-           obj.refresh()
+           # obj.refresh() -- do not call this from WUI (at least for now)
        end
 
        # do the regular get stuff here.
diff --git a/wui/src/app/models/deployment.rb b/wui/src/app/models/deployment.rb
index 2f898be..ed0b52e 100755
--- a/wui/src/app/models/deployment.rb
+++ b/wui/src/app/models/deployment.rb
@@ -61,9 +61,11 @@ class Deployment < ManagedObject
         __virt_call(self.id, "deployment_shutdown")
     end
 
-    def refresh
-        __virt_call(self.id, "deployment_refresh")
-    end
+    # should not be called from WUI anymore unless things
+    # happen to change a lot.
+    #def refresh
+    #    __virt_call(self.id, "deployment_refresh")
+    #end
 
 end
 
diff --git a/wui/src/app/views/deployment/edit.rhtml b/wui/src/app/views/deployment/edit.rhtml
index 59818f0..eeb2554 100755
--- a/wui/src/app/views/deployment/edit.rhtml
+++ b/wui/src/app/views/deployment/edit.rhtml
@@ -37,7 +37,10 @@
          </TR>
          <TR>
             <TD><%= _("Current State") %></TD>
-            <TD><%= @item.state %> <%= link_to "(reload)", :controller => "deployment", :action=>"edit", :id => @item.id %></TD>
+            <TD><%= @item.state %> 
+                <!-- this should update automatically 
+                    <%= link_to "(reload)", :controller => "deployment", :action=>"edit", :id => @item.id %></TD>
+                -->
          </TR>
          <% end %>
          <TR>

hooks/update
---
Git Source Code Management System
hooks/update refs/heads/master \
  5488e0183ea21295973828cba81ca15e946e38f5 \
  37946fc431bc3fc9979db27a272a1208a67fe4a3




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