Package backend :: Package server :: Package action :: Module image
[hide private]
[frames] | no frames]

Source Code for Module backend.server.action.image

 1  # -*- coding: utf-8 -*- 
 2  # 
 3  # Copyright (c) 2011 SUSE LLC 
 4  # 
 5  # This software is licensed to you under the GNU General Public License, 
 6  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 7  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 8  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 9  # along with this software; if not, see 
10  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
11  # 
12   
13  from spacewalk.common.rhnLog import log_debug 
14  from spacewalk.server import rhnSQL 
15  from spacewalk.server.rhnLib import InvalidAction 
16   
17  # the "exposed" functions 
18  __rhnexport__ = ['deploy'] 
19   
20  # returns the values for deploying a virtual machine with an image 
21  # 
22  # file_name, checksum, mem_kb, vcpus, imageType 
23  # 
24   
25   
26 -def deploy(serverId, actionId, dry_run=0):
27 log_debug(3) 28 statement = """ 29 select aid.mem_kb, aid.vcpus, aid.bridge_device,aid.download_url, 30 aid.proxy_server, aid.proxy_user, aid.proxy_pass 31 from rhnActionImageDeploy aid 32 where aid.action_id = :action_id""" 33 h = rhnSQL.prepare(statement) 34 h.execute(action_id=actionId) 35 row = h.fetchone_dict() 36 if not row: 37 # No image for this action 38 raise InvalidAction("image.deploy: No image found for action id " 39 "%s and server %s" % (actionId, serverId)) 40 41 for key in ['download_url', 'proxy_server', 'proxy_user', 'proxy_pass', 'bridge_device']: 42 if row[key] is None: 43 row[key] = "" 44 45 params = { 46 "downloadURL": row['download_url'], 47 "proxySettings": {"proxyURL": row['proxy_server'], "proxyUser": row['proxy_user'], "proxyPass": row['proxy_pass']}, 48 "memKB": row['mem_kb'], 49 "vCPUs": row['vcpus'], 50 "domainName": "", 51 "virtBridge": row['bridge_device']} 52 return (params)
53