def __init__(self, config_path=None, name=None): self.log = logger.getlogger() self.cfg = Config(config_path) self.cont_package_path = gen.get_container_package_path() self.cont_id_file = gen.get_container_id_file() self.cont_venv_path = gen.get_container_venv_path() self.cont_scripts_path = gen.get_container_scripts_path() self.cont_python_path = gen.get_container_python_path() self.cont_os_images_path = gen.get_container_os_images_path() self.cont_playbooks_path = gen.get_container_playbooks_path() self.depl_package_path = gen.get_package_path() self.depl_python_path = gen.get_python_path() self.depl_playbooks_path = gen.get_playbooks_path() if name is True or name is None: for vlan in self.cfg.yield_depl_netw_client_vlan('pxe'): break self.name = '{}-pxe{}'.format(self.DEFAULT_CONTAINER_NAME, vlan) else: self.name = name self.client = docker.from_env() try: self.image = self.client.images.get('power-up') except docker.errors.ImageNotFound: self.image = None try: self.cont = self.client.containers.get(self.name) except docker.errors.NotFound: self.cont = None
def _download_os_images(self): from lib.container import Container try: download_os_images.download_os_images(self.config_file_path) except UserException as exc: print('Fail:', exc.message, file=sys.stderr) sys.exit(1) cont = Container(self.config_file_path) local_os_images = gen.get_os_images_path() cont_os_images = gen.get_container_os_images_path() try: cont.copy_dir_to_container(local_os_images, cont_os_images) except UserException as exc: print('Fail:', exc.message, file=sys.stderr) sys.exit(1) print('Success: OS images downloaded and copied into container')
def _download_os_images(self): from lib.container import Container try: download_os_images.download_os_images(self.config_file_path) except UserException as exc: print('Fail:', str(exc), file=sys.stderr) sys.exit(1) cont = Container(self.config_file_path) local_os_images = gen.get_os_images_path() cont_os_images = gen.get_container_os_images_path() for item in os.listdir(local_os_images): try: cont.copy(os.path.join(local_os_images, item), os.path.join(cont_os_images, item)) except UserException as exc: print('Fail:', str(exc), file=sys.stderr) sys.exit(1) print('Success: OS images downloaded and copied into container')
def __init__(self, config_path=None, name=None): self.log = logger.getlogger() self.cfg = Config(config_path) self.cont_package_path = gen.get_container_package_path() self.cont_id_file = gen.get_container_id_file() self.cont_venv_path = gen.get_container_venv_path() self.cont_scripts_path = gen.get_container_scripts_path() self.cont_python_path = gen.get_container_python_path() self.cont_os_images_path = gen.get_container_os_images_path() self.cont_playbooks_path = gen.get_container_playbooks_path() self.depl_package_path = gen.get_package_path() self.depl_python_path = gen.get_python_path() self.depl_playbooks_path = gen.get_playbooks_path() self.cont_ini = os.path.join(self.depl_package_path, 'container.ini') self.rootfs = self.ROOTFS # Check if architecture is supported arch = platform.machine() if arch not in self.ARCHITECTURE.keys(): msg = "Unsupported architecture '{}'".format(arch) self.log.error(msg) raise UserException(msg) self.rootfs.arch = self.ARCHITECTURE[arch] if name is True or name is None: for vlan in self.cfg.yield_depl_netw_client_vlan('pxe'): break self.name = '{}-pxe{}'.format(self.DEFAULT_CONTAINER_NAME, vlan) else: self.name = name self.cont = lxc.Container(self.name) # Get a file descriptor for stdout self.fd = open(os.path.join(gen.GEN_LOGS_PATH, self.name + '.stdout.log'), 'w')
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import xmlrpc.client import lib.logger as logger import lib.utilities as util import lib.genesis as gen OS_IMAGES_DIR = gen.get_container_os_images_path() + '/' OS_CONFIG_DIR = OS_IMAGES_DIR + 'config/' APACHE2_HTML_DIR = '/var/www/html/' KICKSTARTS_DIR = '/var/lib/cobbler/kickstarts/' SNIPPETS_DIR = '/var/lib/cobbler/snippets/' COBBLER_USER = gen.get_cobbler_user() COBBLER_PASS = gen.get_cobbler_pass() def extract_iso_images(path, html_dir): """Extract ISO images into webserver directory Args: path (str): Directory path containing ISOs or path to single ISO file