2 #############################################################################
3 #Copyright 2017 Parker Berberian and others #
5 #Licensed under the Apache License, Version 2.0 (the "License"); #
6 #you may not use this file except in compliance with the License. #
7 #You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 #Unless required by applicable law or agreed to in writing, software #
12 #distributed under the License is distributed on an "AS IS" BASIS, #
13 #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 #See the License for the specific language governing permissions and #
15 #limitations under the License. #
16 #############################################################################
20 from api.libvirt_api import Libvirt
23 class Deployment_Manager:
25 This class manages the deployment of OPNFV on a booked host
26 if it was requested. If no OPNFV installer was requested, this class will
27 create the virtual machines and networks in the config files and exit.
29 def __init__(self, installerType, scenario, utility):
33 # installerType will either be the constructor for an installer or None
34 self.installer = installerType
37 net_conf=utility.conf['hypervisor_config']['networks'],
38 dom_conf=utility.conf['hypervisor_config']['vms']
40 self.host = utility.host
45 checks if any of the domains expect an ISO file to exist
54 path = isoDom.iso['location']
55 url = isoDom.iso['URL']
56 self.util.sshExec(['wget', '-q', '-O', path, url])
60 assigns the 'macs' instance variable to the domains
61 so that they know the mac addresses of their interfaces.
64 dom.macs = self.virt.getMacs(dom.name)
68 Creates the qcow2 disk files the domains expect on the remote host.
72 disks.append(dom.disk)
73 self.util.execRemoteScript("mkDisks.sh", disks)
78 creates virtual machines/networks and either passes control to the
79 OPNFV installer, or finishes up if an installer was not requested.
81 log = logging.getLogger(self.util.hostname)
82 self.virt.setLogger(log)
83 log.info("%s", "Connecting to the host hypervisor")
84 self.virt.openConnection()
85 domains, networks = self.virt.go()
86 log.info("%s", "Created all networks and VM's on host")
89 if self.installer is None:
90 log.warning("%s", "No installer requested. Finishing deployment")
91 self.util.finishDeployment()
93 log.info("%s", "retrieving ISO")
96 self.util.copyScripts()
98 log.info("%s", "Beginning installation of OPNFV")
100 installer = self.installer(
108 log.exception('%s', "failed to install OPNFV")