def Deploy(self, app, ver, nodeNames): """Deploy the new application""" nodes = [ci.entities[x] for x in nodeNames] # Convert names to objects appFile = appDb.apps[app].version[ver] (sgList, (errors, notes)) = appdeploy.deploy(appFile.dir, appFile.cfg, nodes, abortIfCantAccess=True, copy=True, deploy=True) return ([x.name for x in sgList], errors, notes)
def do_GET(self): try: parsed_path = urlparse.urlparse(self.path) # Show the Node->Service Unit->Component tree if self.path == "/": message = "Cluster:\n" for node in ci.nodeList: message += " Node: " + node.name + " Slot: " + str( node.slot) + "\n" for su in node.su: message += " Service Unit: " + su.name + " Role: " + su.haRole( ) + "\n" for comp in su.comp: if comp.isRunning(): status = "running" else: status = "stopped" message += " Component: " + comp.name + " Status: " + status + " Executable: " + comp.command( ) + "\n" # Show the list of nodes elif self.path == "/nodes": message = [x.name for x in ci.nodeList] # Show a list of Service Units elif self.path == "/serviceUnits": message = [x.name for x in ci.suList] # Show a list of Service Groups elif self.path == "/serviceGroups": message = [x.name for x in ci.sgList] # Show a list of applications elif self.path == "/apps": message = "Applications:\n" for app in appDb.apps.values(): message += app.name + "\n" for ver in app.version.keys(): message += " " + ver + "\n" # Add a new application into the system: /newapp/<filename> For example: /newapp/home/stone/myApp.tgz # Note that the new application bundle file must exist on the system. # The expectation is that it has been uploaded using some standard interface like scp or ftp. # However, you can always extend this protocol to add file transfer... elif self.path.startswith("/newapp"): newfile = self.path[7:] # Get everything after /newapp af = appDb.NewAppFile(newfile) message = "Application Bundle file %s registered: Application Name: %s Version: %s" % ( af.archive, af.appName, af.version) # Deploy the new application: /deploy/<app>/<ver>/<nodes> For example: /deploy/virtualIp/1.4.0.0/ctrlI0 elif "deploy" in self.path: components = self.path.split("/") if len(components) != 5: message = "Improper format: %s. Length is %d" % ( components, len(components)) else: app = components[2] ver = components[3] nodeNames = components[4].split("_") nodes = [ci.entities[x] for x in nodeNames] # Convert names to objects appFile = appDb.apps[app].version[ver] (sgList, (errors, notes)) = appdeploy.deploy(appFile.dir, appFile.cfg, nodes, abortIfCantAccess=True, copy=True, deploy=True) message = "Executed Deploy %s %s %s.\nResult: SG: %s Errors: %s Notes:%s" % ( app, ver, nodeNames, [x.name for x in sgList], errors, notes) # Upgrade an service group: /upgrade/<servicegroup>/<new version> For example: /upgrade/virtualIpi0/1.4.0.1 elif "upgrade" in self.path: # /upgrade/sg/ver ci.load() components = self.path.split("/") if len(components) != 4: message = "Improper format: %s. Length is %d" % ( components, len(components)) else: sg = ci.entities[components[2]] app = sg.app ver = components[3] appFile = app.version[ver] print sg, appFile umgr.add(sg) upSg = umgr.entities[sg.name] upSg.Upgrade(appFile) message = "Executed Upgrade of %s to application %s version %s.\nResult: %s" % ( sg.name, app.name, ver, upSg.upStatus) else: message = "Request '%s' not understood." % self.path except Exception, e: message = "Problem: %s" % str(e) self.end_headers() self.wfile.write(message) raise
# Deploy the application: # Tweak the configuration for just this deployment # If I didn't copy the configuration, I would be modifying it in RAM # which would affect other deployments I do within this Python session. import copy newCfg = copy.deepcopy(appFile.cfg) # For example, set failback parameter to True: newCfg.virtualIp.modifiers.failBack = True # Really Deploy import appdeploy (sgList, (errors, notes)) = appdeploy.deploy(appFile.dir, newCfg, liveNodes, abortIfCantAccess=True, copy=True, deploy=True) # Did you get a pexpect exception? You probably forgot to specify the node # intracluster access data as shown above. Or you may have specified # incorrect information. myNewSg = sgList[0] mySgName = myNewSg.name print "Deployed application and created SG %s" % mySgName # Reload the AMF information model ci.load() # Reaccess via ci global to get refreshed data. mySg = ci.entities[mySgName]
print "Name: ", appFile.name, "Located At: ", appFile.dir, "Version: ", appFile.version # print appFile.cfg # Deploy the application: # Tweak the configuration for just this deployment # If I didn't copy the configuration, I would be modifying it in RAM # which would affect other deployments I do within this Python session. import copy newCfg = copy.deepcopy(appFile.cfg) # For example, set failback parameter to True: newCfg.virtualIp.modifiers.failBack = True # Really Deploy import appdeploy (sgList,(errors,notes)) = appdeploy.deploy(appFile.dir,newCfg,liveNodes,abortIfCantAccess=True,copy=True,deploy=True) # Did you get a pexpect exception? You probably forgot to specify the node # intracluster access data as shown above. Or you may have specified # incorrect information. myNewSg = sgList[0] mySgName = myNewSg.name print "Deployed application and created SG %s" % mySgName # Reload the AMF information model ci.load() # Reaccess via ci global to get refreshed data. mySg = ci.entities[mySgName] # Let's start it up
def do_GET(self): try: parsed_path = urlparse.urlparse(self.path) # Show the Node->Service Unit->Component tree if self.path == "/": message = "Cluster:\n" for node in ci.nodeList: message += " Node: " + node.name + " Slot: " + str(node.slot) + "\n" for su in node.su: message += " Service Unit: " + su.name + " Role: " + su.haRole() + "\n" for comp in su.comp: if comp.isRunning(): status = "running" else: status = "stopped" message += " Component: " + comp.name + " Status: " + status + " Executable: " + comp.command() + "\n" # Show the list of nodes elif self.path == "/nodes": message = [x.name for x in ci.nodeList] # Show a list of Service Units elif self.path == "/serviceUnits": message = [x.name for x in ci.suList] # Show a list of Service Groups elif self.path == "/serviceGroups": message = [x.name for x in ci.sgList] # Show a list of applications elif self.path == "/apps": message = "Applications:\n" for app in appDb.apps.values(): message += app.name + "\n" for ver in app.version.keys(): message += " " + ver + "\n" # Add a new application into the system: /newapp/<filename> For example: /newapp/home/stone/myApp.tgz # Note that the new application bundle file must exist on the system. # The expectation is that it has been uploaded using some standard interface like scp or ftp. # However, you can always extend this protocol to add file transfer... elif self.path.startswith("/newapp"): newfile = self.path[7:] # Get everything after /newapp af = appDb.NewAppFile(newfile) message = "Application Bundle file %s registered: Application Name: %s Version: %s" % (af.archive, af.appName, af.version) # Deploy the new application: /deploy/<app>/<ver>/<nodes> For example: /deploy/virtualIp/1.4.0.0/ctrlI0 elif "deploy" in self.path: components = self.path.split("/") if len(components) != 5: message = "Improper format: %s. Length is %d" % (components,len(components)) else: app = components[2] ver = components[3] nodeNames = components[4].split("_") nodes = [ci.entities[x] for x in nodeNames] # Convert names to objects appFile = appDb.apps[app].version[ver] (sgList,(errors,notes)) = appdeploy.deploy(appFile.dir,appFile.cfg,nodes,abortIfCantAccess=True,copy=True,deploy=True) message = "Executed Deploy %s %s %s.\nResult: SG: %s Errors: %s Notes:%s" % (app, ver, nodeNames, [x.name for x in sgList], errors, notes) # Upgrade an service group: /upgrade/<servicegroup>/<new version> For example: /upgrade/virtualIpi0/1.4.0.1 elif "upgrade" in self.path: # /upgrade/sg/ver ci.load() components = self.path.split("/") if len(components) != 4: message = "Improper format: %s. Length is %d" % (components,len(components)) else: sg = ci.entities[components[2]] app = sg.app ver = components[3] appFile = app.version[ver] print sg, appFile umgr.add(sg) upSg = umgr.entities[sg.name] upSg.Upgrade(appFile) message = "Executed Upgrade of %s to application %s version %s.\nResult: %s" % (sg.name, app.name, ver, upSg.upStatus) else: message = "Request '%s' not understood." % self.path except Exception, e: message = "Problem: %s" % str(e) self.end_headers() self.wfile.write(message) raise
def Deploy(self,app,ver,nodeNames): """Deploy the new application""" nodes = [ci.entities[x] for x in nodeNames] # Convert names to objects appFile = appDb.apps[app].version[ver] (sgList,(errors,notes)) = appdeploy.deploy(appFile.dir,appFile.cfg,nodes,abortIfCantAccess=True,copy=True,deploy=True) return ([x.name for x in sgList], errors, notes)