def setUp(self):
        """setup logging and a doc object
        """
        # Init engine, if not already done.
        if self.engine is not None:
            reset_engine(self.engine)

        self.engine = get_new_engine_instance()
        self.doc = self.engine.data_object_cache

        d = {"pkg_img_path": "/tmp", "ba_build": "/tmp"}
        dc_dict = DataObjectDict("DC specific", d, generate_xml=False)
        self.doc.volatile.insert_children(dc_dict)

        self.custom_script = CustomScript("Custom Script", "echo Hello")

        self.dict_parent = SimpleDataObject("dicts")

        dd = DataObjectDict("TestDict", dict())
        dd.data_dict['key'] = 1
        self.dict_parent.insert_children(dd)

        dd = DataObjectDict("TestDict2", dict())
        dd.data_dict['key'] = 2
        self.dict_parent.insert_children(dd)

        self.doc.volatile.insert_children(self.dict_parent)
Esempio n. 2
0
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        engine_test_utils.get_new_engine_instance()
        self.pi_filelist = [
            "etc/passwd", "etc/shadow", "etc/system", "etc/default/dhcpagent",
            "etc/inet/hosts", "usr/lib/"
        ]
        self.ppim = PrePkgImgMod("Test PPIM")
        self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
        self.ppim.save_path = os.path.join(self.ppim.pkg_img_path, "save")

        # copy /usr/lib/libc.so and /usr/lib/libc.so.1 to the pkg_img_path
        shutil.copy2("/usr/lib/libc.so",
                     os.path.join(self.ppim.pkg_img_path, "usr/lib/libc.so"))

        shutil.copy2("/usr/lib/libc.so.1",
                     os.path.join(self.ppim.pkg_img_path, "usr/lib/libc.so.1"))

        # copy /etc/passwd and shadow to the pkg_img_path
        shutil.copy2("/etc/passwd",
                     os.path.join(self.ppim.pkg_img_path, "etc/passwd"))
        shutil.copy2("/etc/shadow",
                     os.path.join(self.ppim.pkg_img_path, "etc/shadow"))

        # write a simplified line to the dhcpagent file
        with open(
                os.path.join(self.ppim.pkg_img_path, "etc/default/dhcpagent"),
                "w") as fh:
            fh.write("PARAM_REQUEST_LIST=1,3,6,12,15,28,43\n")
Esempio n. 3
0
    def setUp(self):
        engine_test_utils.get_new_engine_instance()
        self.ppim = LiveCDPrePkgImgMod("Test PPIM")
        self.pi_filelist = [
            "/etc/svc/", "/lib/svc/manifest/system/",
            "/var/svc/manifest/system/", "/lib/", "/usr/lib/", "/usr/sbin/",
            "/dev/", "/bin/", "/usr/bin/", "etc/gconf/schemas/",
            "/lib/svc/bin/"
        ]
        self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)

        # copy some binaries into the pkg_image path
        bins = [
            "/usr/sbin/svccfg", "/usr/bin/bash", "/usr/bin/echo",
            "/usr/bin/fc-cache", "/lib/svc/bin/svc.configd"
        ]
        for entry in bins:
            shutil.copy2(
                entry, os.path.join(self.ppim.pkg_img_path, entry.lstrip("/")))
            os.chmod(os.path.join(self.ppim.pkg_img_path, entry), 0755)

        # bash needs a ton of libraries to work
        libs = [
            "/lib/libsocket.so.1", "/lib/libresolv.so.2", "/lib/libnsl.so.1",
            "/lib/libgen.so.1", "/lib/libc.so.1", "/lib/libcurses.so.1",
            "/lib/libmd.so.1", "/lib/libmp.so.2", "/lib/libm.so.2",
            "/lib/ld.so.1", "/usr/lib/libfontconfig.so.1"
        ]
        for entry in libs:
            shutil.copy2(
                entry, os.path.join(self.ppim.pkg_img_path, entry.lstrip("/")))
            os.chmod(os.path.join(self.ppim.pkg_img_path, entry), 0755)
    def setUp(self):
        engine_test_utils.get_new_engine_instance()
        self.ppim = LiveCDPrePkgImgMod("Test PPIM")
        self.pi_filelist = ["/etc/svc/", "/lib/svc/manifest/system/",
                            "/var/svc/manifest/system/", "/lib/", "/usr/lib/",
                            "/usr/sbin/", "/dev/", "/bin/", "/usr/bin/",
                            "etc/gconf/schemas/", "/lib/svc/bin/"]
        self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)

        # copy some binaries into the pkg_image path
        bins = ["/usr/sbin/svccfg", "/usr/bin/bash", "/usr/bin/echo",
                "/usr/bin/fc-cache", "/lib/svc/bin/svc.configd"]
        for entry in bins:
            shutil.copy2(entry, os.path.join(self.ppim.pkg_img_path,
                                             entry.lstrip("/")))
            os.chmod(os.path.join(self.ppim.pkg_img_path, entry), 0755)

        # bash needs a ton of libraries to work
        libs = ["/lib/libsocket.so.1", "/lib/libresolv.so.2",
                "/lib/libnsl.so.1", "/lib/libgen.so.1", "/lib/libc.so.1",
                "/lib/libcurses.so.1", "/lib/libmd.so.1", "/lib/libmp.so.2",
                "/lib/libm.so.2", "/lib/ld.so.1",
                "/usr/lib/libfontconfig.so.1"]
        for entry in libs:
            shutil.copy2(entry, os.path.join(self.ppim.pkg_img_path,
                                             entry.lstrip("/")))
            os.chmod(os.path.join(self.ppim.pkg_img_path, entry), 0755)
Esempio n. 5
0
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     engine_test_utils.get_new_engine_instance()
     self.ppim = AIPrePkgImgMod("Test PPIM")
     self.pi_filelist = ["/usr/bin/vim", "/usr/has/bin/vi"]
     self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     engine_test_utils.get_new_engine_instance()
     self.ppim = AIPrePkgImgMod("Test PPIM")
     self.pi_filelist = ["/usr/bin/vim", "/usr/has/bin/vi"]
     self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
Esempio n. 7
0
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        engine_test_utils.get_new_engine_instance()
        self.ppim = LiveCDPrePkgImgMod("Test PPIM")
        self.pi_filelist = [
            "etc/shadow", "etc/system", "etc/default/dhcpagent",
            "etc/inet/hosts", "usr/share/dbus-1/services/",
            "etc/gconf/schemas/", "usr/share/gnome/autostart/",
            "etc/xdg/autostart/",
            "etc/xdg/autostart/updatemanagernotifier.desktop",
            "usr/share/dbus-1/services/gnome-power-manager.service",
            "usr/share/gnome/autostart/gnome-power-manager.desktop",
            "usr/share/gnome/autostart/vp-sysmon.desktop",
            "etc/gconf/schemas/panel-default-setup.entries"
        ]
        self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
        self.ppim.save_path = os.path.join(self.ppim.pkg_img_path, "save")

        # copy /usr/lib/libc.so and /usr/lib/libc.so.1 to the pkg_img_path
        os.makedirs(os.path.join(self.ppim.pkg_img_path, "usr/lib"))
        shutil.copy2("/usr/lib/libc.so",
                     os.path.join(self.ppim.pkg_img_path, "usr/lib/"))

        shutil.copy2("/usr/lib/libc.so.1",
                     os.path.join(self.ppim.pkg_img_path, "usr/lib/"))

        # copy /etc/passwd and shadow to the pkg_img_path
        shutil.copy2("/etc/passwd",
                     os.path.join(self.ppim.pkg_img_path, "etc/passwd"))
        shutil.copy2("/etc/shadow",
                     os.path.join(self.ppim.pkg_img_path, "etc/shadow"))
Esempio n. 8
0
 def setUp(self):
     # create a dummy filesystem with some files created in the
     # proper location
     engine_test_utils.get_new_engine_instance()
     self.filelist = ["/usr/",
                      "/usr/file1/file2/icon-theme.cache"]
     self.pim = LiveCDPkgImgMod("Test LiveCDPkgImgMod")
     self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
 def setUp(self):
     # create a dummy filesystem with some files created in the
     # proper location
     engine_test_utils.get_new_engine_instance()
     self.filelist = ["/usr/",
                      "/usr/file1/file2/icon-theme.cache"]
     self.pim = LiveCDPkgImgMod("Test LiveCDPkgImgMod")
     self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
    def setUp(self):
        engine_test_utils.get_new_engine_instance()

        # create a temporary file
        (self.fd, self.path) = tempfile.mkstemp()

        # immediately remove it for testing
        os.remove(self.path)
    def setUp(self):
        engine_test_utils.get_new_engine_instance()

        # create a dummy filesystem with some files
        filelist = ["/fake/directory/"]
        self.tdir = testlib.create_filesystem(*filelist)

        self.baa = BootArchiveArchive("Test BAA")
    def setUp(self):
        engine_test_utils.get_new_engine_instance()

        # create a dummy filesystem with some files
        filelist = ["/fake/directory/"]
        self.tdir = testlib.create_filesystem(*filelist)

        self.baa = BootArchiveArchive("Test BAA")
Esempio n. 13
0
    def setUp(self):
        engine_test_utils.get_new_engine_instance()

        # create a temporary file
        (self.fd, self.path) = tempfile.mkstemp()

        # immediately remove it for testing
        os.remove(self.path)
Esempio n. 14
0
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     engine_test_utils.get_new_engine_instance()
     self.ppim = PrePkgImgMod("Test PPIM")
     self.pi_filelist = ["/etc/system"]
     self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
     self.ppim.img_info_path = os.path.join(self.ppim.pkg_img_path,
                                            ".image_info")
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     engine_test_utils.get_new_engine_instance()
     self.ppim = PrePkgImgMod("Test PPIM")
     self.pi_filelist = ["/etc/system"]
     self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
     self.ppim.img_info_path = os.path.join(self.ppim.pkg_img_path,
                                            ".image_info")
Esempio n. 16
0
 def setUp(self):
     engine_test_utils.get_new_engine_instance()
     self.media_filelist = ["a.iso"]
     self.c_iso = CreateISO("Test Create ISO")
     self.c_iso.media_dir = testlib.create_filesystem(*self.media_filelist)
     self.c_iso.distro_name = "a"
     self.c_iso.dist_iso = os.path.join(self.c_iso.media_dir, "a.iso")
     self.c_iso.partial_distro_name = "foo"
     self.incr_iso = os.path.join(self.c_iso.media_dir,
                                  self.c_iso.partial_distro_name) + ".iso"
Esempio n. 17
0
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     engine_test_utils.get_new_engine_instance()
     self.filelist = ["/usr/lib",
                      "/usr/sbin/lofiadm",
                      "/usr/file1/file2",
                      "/usr/file2/file3/file4",
                      "/usr/file3/file3/file4/file5",
                      "/usr/file4/file5/file6/file7/file8"]
     self.pim = PkgImgMod("Test PkgImgMod")
     self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
    def setUp(self):
        # create a dummy filesystem with some files created in the
        # proper location
        engine_test_utils.get_new_engine_instance()
        self.filelist = ["/platform/",
                         "/platform/dir1/dir2/unix",
                         "/platform/dir1/dir2/file",
                         "/platform/dir2/dir3/boot_archive",
                         "/platform/dir2/dir3/file2"]

        self.pim = LiveCDPkgImgMod("Test LiveCDPkgImgMod")
        self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
Esempio n. 19
0
    def setUp(self):
        # create a dummy filesystem with some files created in the
        # proper location
        engine_test_utils.get_new_engine_instance()
        self.filelist = ["/platform/",
                         "/platform/dir1/dir2/unix",
                         "/platform/dir1/dir2/file",
                         "/platform/dir2/dir3/boot_archive",
                         "/platform/dir2/dir3/file2"]

        self.pim = LiveCDPkgImgMod("Test LiveCDPkgImgMod")
        self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     engine_test_utils.get_new_engine_instance()
     self.filelist = ["/etc/.pwd.lock",
                      "/sbin/bar/baz",
                      "/kernel/foo",
                      "/lib/"]
     self.ba_filelist = ["/.volsetid"]
     self.pim = PkgImgMod("Test PkgImgMod")
     self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
     self.pim.ba_build = testlib.create_filesystem(*self.ba_filelist)
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     engine_test_utils.get_new_engine_instance()
     self.filelist = ["/usr/lib",
                      "/usr/sbin/lofiadm",
                      "/usr/file1/file2",
                      "/usr/file2/file3/file4",
                      "/usr/file3/file3/file4/file5",
                      "/usr/file4/file5/file6/file7/file8"]
     self.pim = PkgImgMod("Test PkgImgMod")
     self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
Esempio n. 22
0
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     engine_test_utils.get_new_engine_instance()
     self.filelist = ["/etc/.pwd.lock",
                      "/sbin/bar/baz",
                      "/kernel/foo",
                      "/lib/"]
     self.ba_filelist = ["/.volsetid"]
     self.pim = PkgImgMod("Test PkgImgMod")
     self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
     self.pim.ba_build = testlib.create_filesystem(*self.ba_filelist)
Esempio n. 23
0
 def setUp(self):
     engine_test_utils.get_new_engine_instance()
     self.ba_filelist = [".volsetid"]
     self.pi_filelist = ["a", "b"]
     self.c_iso = CreateISO("Test Create ISO")
     self.c_iso.distro_name = "distro name"
     self.c_iso.partial_distro_name = self.c_iso.distro_name
     self.c_iso.dist_iso = "/var/tmp/dist.iso"
     self.c_iso.bios_eltorito = "boot/grub/stage2_eltorito"
     self.c_iso.ba_build = testlib.create_filesystem(*self.ba_filelist)
     self.c_iso.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
     self.c_iso.arch = "i386"
     self.c_iso.media_dir = "/var/tmp/missing"
    def setUp(self):
        engine_test_utils.get_new_engine_instance()

        # create a dummy filesystem with some files
        self.pi_filelist = ["/platform/i86pc/", "/platform/sun4u/lib/fs/ufs/",
                            "/usr/platform/sun4u/lib/fs/ufs/",
                            "/etc/system", "/platform/i86pc/amd64/",
                            "/boot/solaris/filelist.ramdisk",
                            "/platform/sun4v/"]
        self.baa = BootArchiveArchive("Test BAA")
        self.baa.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
        self.baa.ba_build = self.baa.pkg_img_path
        self.baa.tmp_dir = tempfile.mkdtemp(dir="/var/tmp", prefix="baa_tmp_")
Esempio n. 25
0
    def setUp(self):
        # create a dummy filesystem with some files created in the
        # proper location
        engine_test_utils.get_new_engine_instance()
        self.filelist = ["/platform/",
                         "/platform/sun4u/boot_archive",
                         "/platform/sun4v/archive_cache",
                         "/platform/file/wanboot",
                         "/platform/kernel/unix",
                         "/platform/kernel/genunix",
                         "/boot/"]

        self.pim = AIPkgImgMod("Test AIPkgImgMod")
        self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
    def setUp(self):
        # create a dummy filesystem with some files created in the
        # proper location
        engine_test_utils.get_new_engine_instance()
        self.filelist = ["/platform/",
                         "/platform/sun4u/boot_archive",
                         "/platform/sun4v/archive_cache",
                         "/platform/file/wanboot",
                         "/platform/kernel/unix",
                         "/platform/kernel/genunix",
                         "/boot/"]

        self.pim = AIPkgImgMod("Test AIPkgImgMod")
        self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
Esempio n. 27
0
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        engine_test_utils.get_new_engine_instance()
        self.ppim = PrePkgImgMod("Test PPIM")
        self.pi_filelist = [
            "/etc/svc/", "/lib/svc/manifest/system/",
            "/var/svc/manifest/system/", "/lib/", "/usr/lib/", "/usr/sbin/",
            "/etc/inet/hosts", "/lib/svc/bin/", "/usr/share/lib/xml/dtd/",
            "lib/svc/manifest/milestone/", "lib/svc/manifest/network/",
            "lib/svc/manifest/milestone/config.xml",
            "lib/svc/manifest/network/network-physical.xml",
            "lib/svc/manifest/network/network-install.xml"
        ]

        self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
        self.ppim.save_path = os.path.join(self.ppim.pkg_img_path, "save")

        # create two manifests in the pkg_image area
        testlib.create_smf_xml_file(
            "manifest", "varstub",
            os.path.join(self.ppim.pkg_img_path,
                         "var/svc/manifest/system/var_stub.xml"))
        testlib.create_smf_xml_file(
            "manifest", "libstub",
            os.path.join(self.ppim.pkg_img_path,
                         "lib/svc/manifest/system/lib_stub.xml"))

        # create a profile to apply
        (_none, path) = tempfile.mkstemp(dir="/var/tmp", prefix="smf_profile_")
        testlib.create_smf_xml_file("profile", "profilestub", path)

        # save the profile path in a list
        self.ppim.svc_profiles = [path]

        # copy /usr/sbin/svccfg, /lib/svc/bin/svc.configd, and
        # /usr/share/lib/xml/dtd/servcie_bundle.dtd.1 to the pkg_image path
        shutil.copy2("/usr/sbin/svccfg",
                     os.path.join(self.ppim.pkg_img_path, "usr/sbin/svccfg"))
        os.chmod(os.path.join(self.ppim.pkg_img_path, "usr/sbin/svccfg"), 0755)
        shutil.copy2(
            "/lib/svc/bin/svc.configd",
            os.path.join(self.ppim.pkg_img_path, "lib/svc/bin/svc.configd"))
        os.chmod(
            os.path.join(self.ppim.pkg_img_path, "lib/svc/bin/svc.configd"),
            0555)
        shutil.copy2(
            "/usr/share/lib/xml/dtd/service_bundle.dtd.1",
            os.path.join(self.ppim.pkg_img_path,
                         "usr/share/lib/xml/dtd/service_bundle.dtd.1"))
    def setUp(self):
        engine_test_utils.get_new_engine_instance()

        # create a dummy filesystem with some files
        self.pi_filelist = [
            "/platform/i86pc/", "/platform/sun4u/lib/fs/ufs/",
            "/usr/platform/sun4u/lib/fs/ufs/", "/etc/system",
            "/platform/i86pc/amd64/", "/boot/solaris/filelist.ramdisk",
            "/platform/sun4v/"
        ]
        self.baa = BootArchiveArchive("Test BAA")
        self.baa.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
        self.baa.ba_build = self.baa.pkg_img_path
        self.baa.tmp_dir = tempfile.mkdtemp(dir="/var/tmp", prefix="baa_tmp_")
Esempio n. 29
0
    def setUp(self):
        # create a basic manifest
        self.fh, self.path = tempfile.mkstemp(suffix=".xml")

        # create a simple, valid manifest for DC
        self.root = etree.Element("dc")
        distro = etree.SubElement(self.root, "distro")
        distro.set("name", "test")
        distro.set("add_timestamp", "false")

        # distro_spec section
        ds = etree.SubElement(distro, "distro_spec")
        ip = etree.SubElement(ds, "img_params")
        etree.SubElement(ip, "media_im")

        # target section
        target = etree.SubElement(distro, "target")
        zp = etree.SubElement(target, "zpool")
        zp.set("action", "use_existing")
        zp.set("name", "rpool")
        fs = etree.SubElement(zp, "filesystem")
        fs.set("name", "rpool/test")
        fs.set("action", "preserve")

        # execution section.  Create 1 checkpoint
        execution = etree.SubElement(distro, "execution")
        execution.set("stop_on_error", "true")
        cp = etree.SubElement(execution, "checkpoint")
        cp.set("name", "checkpoint")
        cp.set("desc", "test checkpoint")
        cp.set("mod_path", "unittest")
        cp.set("checkpoint_class", "TestCase")

        # instantiate the engine
        self.eng = engine_test_utils.get_new_engine_instance()
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     engine_test_utils.get_new_engine_instance()
     self.ppim = LiveCDPrePkgImgMod("Test PPIM")
     self.pi_filelist = [
         "usr/share/dbus-1/services/", "etc/gconf/schemas/",
         "usr/share/gnome/autostart/", "etc/xdg/autostart/",
         "etc/xdg/autostart/updatemanagernotifier.desktop",
         "usr/share/dbus-1/services/gnome-power-manager.service",
         "usr/share/gnome/autostart/gnome-power-manager.desktop",
         "usr/share/gnome/autostart/vp-sysmon.desktop",
         "etc/gconf/schemas/panel-default-setup.entries"
     ]
     self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
     self.ppim.save_path = os.path.join(self.ppim.pkg_img_path, "save")
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        self.engine = engine_test_utils.get_new_engine_instance()
        self.doc = self.engine.data_object_cache
        self.doc.persistent.insert_children(Software(TRANSFER_ROOT))

        self.ba_filelist = ["/etc/inet/hosts", "/etc/nodename", "/etc/svc/",
                            "/usr/bin/"]
        args = {"image_type": "test"}
        self.bac = BootArchiveConfigure(name="Test BAC", arg=args)
        self.bac.doc = self.doc
        self.bac.ba_build = testlib.create_filesystem(*self.ba_filelist)
        self.bac.pkg_img_path = tempfile.mkdtemp(dir="/var/tmp",
                                                 prefix="bac_conf_system_")
        self.bac.file_defaults = os.path.join(os.path.dirname(
            os.path.abspath(bac.__file__)), "defaultfiles")

        # write some info to etc/inet/hosts
        self.hosts_file = os.path.join(self.bac.ba_build, "etc/inet/hosts")
        with open(self.hosts_file, "w+") as fh:
            fh.write("127.0.0.1\thostname\n")

        # touch the smf repo
        os.makedirs(os.path.join(self.bac.pkg_img_path, "etc/svc"))
        self.smf_repo = os.path.join(self.bac.pkg_img_path,
                                     "etc/svc/repository.db")
        with open(self.smf_repo, "w+") as fh:
            pass
Esempio n. 32
0
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        self.engine = engine_test_utils.get_new_engine_instance()
        self.doc = self.engine.data_object_cache
        self.doc.persistent.insert_children(Software(TRANSFER_ROOT))

        self.ba_filelist = [
            "/etc/inet/hosts", "/etc/nodename", "/etc/svc/", "/usr/bin/"
        ]
        args = {"image_type": "test"}
        self.bac = BootArchiveConfigure(name="Test BAC", arg=args)
        self.bac.doc = self.doc
        self.bac.ba_build = testlib.create_filesystem(*self.ba_filelist)
        self.bac.pkg_img_path = tempfile.mkdtemp(dir="/var/tmp",
                                                 prefix="bac_conf_system_")
        self.bac.file_defaults = os.path.join(
            os.path.dirname(os.path.abspath(bac.__file__)), "defaultfiles")

        # write some info to etc/inet/hosts
        self.hosts_file = os.path.join(self.bac.ba_build, "etc/inet/hosts")
        with open(self.hosts_file, "w+") as fh:
            fh.write("127.0.0.1\thostname\n")

        # touch the smf repo
        os.makedirs(os.path.join(self.bac.pkg_img_path, "etc/svc"))
        self.smf_repo = os.path.join(self.bac.pkg_img_path,
                                     "etc/svc/repository.db")
        with open(self.smf_repo, "w+") as fh:
            pass
Esempio n. 33
0
 def setUp(self):
     """ Common unit test setup method for all subclasses
     """
     self.engine = get_new_engine_instance()
     self.doc = InstallEngine.get_instance().data_object_cache
     if not os.path.exists(TMP_TEST_DIR):
         os.makedirs(TMP_TEST_DIR)
    def setUp(self):
        # create a basic manifest
        self.fh, self.path = tempfile.mkstemp(suffix=".xml")

        # create a simple, valid manifest for DC
        self.root = etree.Element("dc")
        distro = etree.SubElement(self.root, "distro")
        distro.set("name", "test")
        distro.set("add_timestamp", "false")

        # distro_spec section
        ds = etree.SubElement(distro, "distro_spec")
        ip = etree.SubElement(ds, "img_params")
        etree.SubElement(ip, "media_im")

        # target section
        target = etree.SubElement(distro, "target")
        zp = etree.SubElement(target, "zpool")
        zp.set("action", "use_existing")
        zp.set("name", "rpool")
        fs = etree.SubElement(zp, "filesystem")
        fs.set("name", "rpool/test")
        fs.set("action", "preserve")

        # execution section.  Create 1 checkpoint
        execution = etree.SubElement(distro, "execution")
        execution.set("stop_on_error", "true")
        cp = etree.SubElement(execution, "checkpoint")
        cp.set("name", "checkpoint")
        cp.set("desc", "test checkpoint")
        cp.set("mod_path", "unittest")
        cp.set("checkpoint_class", "TestCase")

        # instantiate the engine
        self.eng = engine_test_utils.get_new_engine_instance()
Esempio n. 35
0
    def setUp(self):
        """setup logging and a doc object
        """
        # Init engine, if not already done.
        if self.engine is not None:
            reset_engine(self.engine)

        self.engine = get_new_engine_instance()
        self.doc = self.engine.data_object_cache

        d = {"pkg_img_path": "/tmp", "ba_build": "/tmp"}
        dc_dict = DataObjectDict("DC specific", d, generate_xml=False)
        self.doc.volatile.insert_children(dc_dict)

        self.custom_script = CustomScript("Custom Script", "echo Hello")

        self.dict_parent = SimpleDataObject("dicts")

        dd = DataObjectDict("TestDict", dict())
        dd.data_dict['key'] = 1
        self.dict_parent.insert_children(dd)

        dd = DataObjectDict("TestDict2", dict())
        dd.data_dict['key'] = 2
        self.dict_parent.insert_children(dd)

        self.doc.volatile.insert_children(self.dict_parent)
Esempio n. 36
0
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     engine_test_utils.get_new_engine_instance()
     self.ppim = LiveCDPrePkgImgMod("Test PPIM")
     self.pi_filelist = [
         "usr/share/dbus-1/services/", "etc/gconf/schemas/",
         "usr/share/gnome/autostart/", "etc/xdg/autostart/",
         "etc/xdg/autostart/updatemanagernotifier.desktop",
         "usr/share/dbus-1/services/gnome-power-manager.service",
         "usr/share/gnome/autostart/gnome-power-manager.desktop",
         "usr/share/gnome/autostart/vp-sysmon.desktop",
         "etc/gconf/schemas/panel-default-setup.entries"
     ]
     self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
     self.ppim.save_path = os.path.join(self.ppim.pkg_img_path, "save")
    def setUp(self):
        # instantiate the engine
        self.eng = engine_test_utils.get_new_engine_instance()
        self.doc = self.eng.data_object_cache

        # create a Target DataObjects for later insertion
        self.target = Target("target")
        self.logical = Logical("logical")
        self.target.insert_children(self.logical)
    def setUp(self):
        self.engine = engine_test_utils.get_new_engine_instance()
        self.doc = self.engine.data_object_cache.volatile

        # create DOC objects
        self.target = Target(Target.DESIRED)
        self.doc.insert_children(self.target)

        self.logical = Logical("logical")
    def setUp(self):
        self.eng = engine_test_utils.get_new_engine_instance()
        self.doc = self.eng.data_object_cache

        self.distro = dc_spec.Distro("distro")
        self.logger = logging.getLogger(INSTALL_LOGGER_NAME)

        # ensure there's no proxy left over
        clear_proxy()
Esempio n. 40
0
    def setUp(self):
        self.eng = engine_test_utils.get_new_engine_instance()
        self.doc = self.eng.data_object_cache

        self.distro = dc_spec.Distro("distro")
        self.logger = logging.getLogger(INSTALL_LOGGER_NAME)

        # ensure there's no proxy left over
        clear_proxy()
Esempio n. 41
0
    def setUp(self):
        # instantiate the engine
        self.eng = engine_test_utils.get_new_engine_instance()
        self.doc = self.eng.data_object_cache

        # create a Target DataObjects for later insertion
        self.target = Target("target")
        self.logical = Logical("logical")
        self.target.insert_children(self.logical)
    def setUp(self):
        self.engine = engine_test_utils.get_new_engine_instance()
        self.doc = self.engine.data_object_cache.volatile

        # create DOC objects
        self.target = Target(Target.DESIRED)
        self.doc.insert_children(self.target)

        self.logical = Logical("logical")
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        engine_test_utils.get_new_engine_instance()
        self.ppim = PrePkgImgMod("Test PPIM")
        self.pi_filelist = ["/etc/svc/", "/lib/svc/manifest/system/",
                            "/var/svc/manifest/system/", "/lib/", "/usr/lib/",
                            "/usr/sbin/", "/etc/inet/hosts", "/lib/svc/bin/",
                            "/usr/share/lib/xml/dtd/",
                            "lib/svc/manifest/milestone/",
                            "lib/svc/manifest/network/",
                            "lib/svc/manifest/network/network-physical.xml",
                            "lib/svc/manifest/network/network-install.xml"]

        self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
        self.ppim.save_path = os.path.join(self.ppim.pkg_img_path, "save")

        # create two manifests in the pkg_image area
        testlib.create_smf_xml_file("manifest", "varstub", os.path.join(
            self.ppim.pkg_img_path, "var/svc/manifest/system/var_stub.xml"))
        testlib.create_smf_xml_file("manifest", "libstub", os.path.join(
            self.ppim.pkg_img_path, "lib/svc/manifest/system/lib_stub.xml"))

        # create a profile to apply
        (_none, path) = tempfile.mkstemp(dir="/var/tmp", prefix="smf_profile_")
        testlib.create_smf_xml_file("profile", "profilestub", path)

        # save the profile path in a list
        self.ppim.svc_profiles = [path]

        # copy /usr/sbin/svccfg, /lib/svc/bin/svc.configd, and
        # /usr/share/lib/xml/dtd/servcie_bundle.dtd.1 to the pkg_image path
        shutil.copy2("/usr/sbin/svccfg", os.path.join(self.ppim.pkg_img_path,
                                                      "usr/sbin/svccfg"))
        os.chmod(os.path.join(self.ppim.pkg_img_path, "usr/sbin/svccfg"), 0755)
        shutil.copy2("/lib/svc/bin/svc.configd",
            os.path.join(self.ppim.pkg_img_path, "lib/svc/bin/svc.configd"))
        os.chmod(os.path.join(self.ppim.pkg_img_path,
                              "lib/svc/bin/svc.configd"), 0555)
        shutil.copy2("/usr/share/lib/xml/dtd/service_bundle.dtd.1",
            os.path.join(self.ppim.pkg_img_path,
                         "usr/share/lib/xml/dtd/service_bundle.dtd.1"))
    def setUp(self):
        eng = engine_test_utils.get_new_engine_instance()
        self.ppim = AIPrePkgImgMod("Test PPIM")
        self.ppim.pkg_img_path = "/"
        (fd, path) = tempfile.mkstemp(dir="/var/tmp", prefix="test_pkg_ver_")
        self.outfile = path
        os.chmod(self.outfile, 0777)

        # create a dummy DOC entry for the DC_LABEL
        self.ppim.doc = eng.data_object_cache
        self.ppim.doc.volatile.insert_children(DataObjectDict(DC_LABEL, {}))
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        engine_test_utils.get_new_engine_instance()
        self.pi_filelist = ["/etc/passwd", "/etc/shadow", "/usr/lib/"]
        self.ppim = PrePkgImgMod("Test PPIM")
        self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)

        # copy /usr/lib/libc.so and /usr/lib/libc.so.1 to the pkg_img_path
        shutil.copy2("/usr/lib/libc.so",
                     os.path.join(self.ppim.pkg_img_path, "usr/lib/libc.so"))

        shutil.copy2("/usr/lib/libc.so.1",
                     os.path.join(self.ppim.pkg_img_path, "usr/lib/libc.so.1"))

        # copy /etc/passwd and shadow to the pkg_img_path
        shutil.copy2("/etc/passwd", os.path.join(self.ppim.pkg_img_path,
                                                 "etc/passwd"))
        shutil.copy2("/etc/shadow", os.path.join(self.ppim.pkg_img_path,
                                                 "etc/shadow"))
Esempio n. 46
0
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        self.engine = engine_test_utils.get_new_engine_instance()

        args = {"image_type": "test"}
        self.bac = LiveCDBootArchiveConfigure(name="Test BAC", arg=args)
        self.ba_filelist = ["/etc/sudoers"]
        self.pi_filelist = ["/save/"]
        self.bac.ba_build = testlib.create_filesystem(*self.ba_filelist)
        self.bac.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        self.engine = engine_test_utils.get_new_engine_instance()

        args = {"image_type": "test"}
        self.bac = LiveCDBootArchiveConfigure(name="Test BAC", arg=args)
        self.ba_filelist = ["/etc/sudoers"]
        self.pi_filelist = ["/save/"]
        self.bac.ba_build = testlib.create_filesystem(*self.ba_filelist)
        self.bac.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
Esempio n. 48
0
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        engine_test_utils.get_new_engine_instance()
        self.pi_filelist = ["/etc/passwd", "/etc/shadow", "/usr/lib/"]
        self.ppim = PrePkgImgMod("Test PPIM")
        self.ppim.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)

        # copy /usr/lib/libc.so and /usr/lib/libc.so.1 to the pkg_img_path
        shutil.copy2("/usr/lib/libc.so",
                     os.path.join(self.ppim.pkg_img_path, "usr/lib/libc.so"))

        shutil.copy2("/usr/lib/libc.so.1",
                     os.path.join(self.ppim.pkg_img_path, "usr/lib/libc.so.1"))

        # copy /etc/passwd and shadow to the pkg_img_path
        shutil.copy2("/etc/passwd",
                     os.path.join(self.ppim.pkg_img_path, "etc/passwd"))
        shutil.copy2("/etc/shadow",
                     os.path.join(self.ppim.pkg_img_path, "etc/shadow"))
Esempio n. 49
0
    def setUp(self):
        eng = engine_test_utils.get_new_engine_instance()
        self.ppim = AIPrePkgImgMod("Test PPIM")
        self.ppim.pkg_img_path = "/"
        (fd, path) = tempfile.mkstemp(dir="/var/tmp", prefix="test_pkg_ver_")
        self.outfile = path
        os.chmod(self.outfile, 0777)

        # create a dummy DOC entry for the DC_LABEL
        self.ppim.doc = eng.data_object_cache
        self.ppim.doc.volatile.insert_children(DataObjectDict(DC_LABEL, {}))
Esempio n. 50
0
    def setUp(self):
        '''
        Set up enough of an environment to run in.  Set up files.
        '''

        if os.path.exists(self.LOGFILE):
            os.unlink(self.LOGFILE)

        self.engine = engine_test_utils.get_new_engine_instance()
        self.logger = logging.getLogger()
        self.logger.addHandler(logging.StreamHandler())
        self.file_handler = logging.FileHandler(self.LOGFILE)
        self.logger.addHandler(self.file_handler)

        # Assume the manifest used has separate sibling sections for
        # add_drivers, software and target, and no others.
        # Create three files, each with one of the sections.

        # Read in base manifest, and write it out, stripping whitespace lines.
        self.tree = etree.parse(self.BASE_MANIFEST)

        # Generate the three files with subsections.
        self.prune(self.ADD_DRIVER_SUBTREE)
        self.prune(self.SOFTWARE_SUBTREE)
        self.tree.write(self.TARGET_XML, pretty_print=True)

        self.tree = etree.parse(self.BASE_MANIFEST)
        self.prune(self.ADD_DRIVER_SUBTREE)
        self.prune(self.TARGET_SUBTREE)
        self.tree.write(self.SOFTWARE_XML, pretty_print=True)

        self.tree = etree.parse(self.BASE_MANIFEST)
        self.prune(self.TARGET_SUBTREE)
        self.prune(self.SOFTWARE_SUBTREE)
        self.tree.write(self.ADD_DRIVER_XML, pretty_print=True)

        # Create a script to run inside the DMM.
        # Note that when the script runs, the first load will overwrite any
        # existing manifest.
        with open(self.SCRIPT, "w") as script:
            script.write("#!/bin/ksh93\n")
            script.write("\n")
            script.write("${ROOT}/usr/bin/aimanifest load %s\n" %
                         self.SOFTWARE_XML)
            script.write("${ROOT}/usr/bin/aimanifest load -i %s\n" %
                         self.ADD_DRIVER_XML)
            script.write("${ROOT}/usr/bin/aimanifest load -i %s\n" %
                         self.TARGET_XML)
            script.write("${ROOT}/usr/bin/aimanifest validate\n")
            script.write("print \"Validated manifest is "
                         "at $AIM_MANIFEST !!!\"\n")
        os.chmod(self.SCRIPT, 0555)
Esempio n. 51
0
    def setUp(self):
        '''
        Set up enough of an environment to run in, and create script.
        '''

        if os.path.exists(self.LOGFILE):
            os.unlink(self.LOGFILE)

        self.engine = engine_test_utils.get_new_engine_instance()
        self.logger = logging.getLogger()
        self.logger.addHandler(logging.StreamHandler())
        self.file_handler = logging.FileHandler(self.LOGFILE)
        self.logger.addHandler(self.file_handler)

        self.create_script_file()
Esempio n. 52
0
    def setUp(self):
        # Set up the Target directory
        self.test_target = tempfile.mkdtemp(dir="/tmp", prefix="ict_test_")
        os.chmod(self.test_target, 0777)
        os.mkdir(os.path.join(self.test_target, "etc"))

        self.engine = get_new_engine_instance()
        self.doc = self.engine.data_object_cache

        self.populate_doc()

        # Instantiate the checkpoint
        self.setup_swap = SetupSwap("setup_swap")

        # Create a test file name
        self.test_file = os.path.join(self.test_target, 'etc/vfstab')
    def setUp(self):
        self.engine = engine_test_utils.get_new_engine_instance()
        self.doc = self.engine.data_object_cache.volatile

        # create some DOC objects
        self.target = Target(Target.DESIRED)
        self.doc.insert_children(self.target)

        self.disk = Disk("disk")
        self.disk.ctd = "c8t1d0"
        self.disk.disk_prop = DiskProp()
        self.disk.disk_prop.dev_size = Size(str(200) + Size.gb_units)
        self.disk.disk_prop.blocksize = BLOCKSIZE
        self.disk.disk_prop.cylsize = CYLSIZE
        self.disk.disk_geometry = DiskGeometry()
        self.target.insert_children(self.disk)
 def setUp(self):
     # create a dummy filesystem with some files created in the proper
     # location
     self.engine = engine_test_utils.get_new_engine_instance()
     self.filelist = ["/opt/",
                      "/opt/lib",
                      "/etc/",
                      "/etc/sbin/lofiadm",
                      "/etc/file1/file2",
                      "/var/",
                      "/var/file2/file3/file4",
                      "/var/file3/file3/file4/file5",
                      "/var/file4/file5/file6/file7/file8"]
     self.pim = PkgImgMod("Test PkgImgMod")
     self.pim.pkg_img_path = testlib.create_filesystem(*self.filelist)
     self.pim.doc = self.engine.data_object_cache
    def setUp(self):
        # Set up the Target directory
        self.test_target = tempfile.mkdtemp(dir="/tmp",
                                            prefix="ict_test_")
        os.chmod(self.test_target, 0777)
        os.mkdir(os.path.join(self.test_target, "etc"))

        self.engine = get_new_engine_instance()
        self.doc = self.engine.data_object_cache

        self.populate_doc()

        # Instantiate the checkpoint
        self.setup_swap = SetupSwap("setup_swap")

        # Create a test file name
        self.test_file = os.path.join(self.test_target, 'etc/vfstab')
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        self.engine = engine_test_utils.get_new_engine_instance()
        self.doc = self.engine.data_object_cache
        self.doc.persistent.insert_children(Software(TRANSFER_ROOT))

        self.pi_filelist = ["/etc/zones/index", "/etc/mime.types",
                            "/var/adm/wtmpx", "/var/adm/spellhist",
                            "/var/lib/gdm/", "/var/log/gdm/",
                            "/var/fake1/fake2/fake3/fake4/fake5/fakefile"]
        self.ba_filelist = ["/etc/zones/index", "/var/adm/wtmpx",
                            "/var/adm/spellhist"]
        args = {"image_type": "test"}
        self.bac = BootArchiveConfigure(name="Test BAC", arg=args)
        self.bac.doc = self.doc
        self.bac.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)
        self.bac.ba_build = testlib.create_filesystem(*self.ba_filelist)
    def setUp(self):
        '''
        Set up enough of an environment to run in, and create script.
        '''

        if os.path.exists(self.LOGFILE):
            os.unlink(self.LOGFILE)

        self.engine = engine_test_utils.get_new_engine_instance()
        self.logger = logging.getLogger()
        self.logger.addHandler(logging.StreamHandler())
        self.file_handler = logging.FileHandler(self.LOGFILE)
        self.logger.addHandler(self.file_handler)

        self.create_script_file()

        if os.path.exists(self.MANIFEST):
            os.unlink(self.MANIFEST)
    def setUp(self):
        self.eng = engine_test_utils.get_new_engine_instance()
        self.doc = self.eng.data_object_cache

        # create DOC objects with 2 checkpoints
        self.distro = dc_spec.Distro("distro")
        self.execution = dc_exec.Execution("execution")
        self.execution.stop_on_error = "True"

        # set the 'checkpoints' to use the unittest module and TestCase class
        self.cp1 = dc_exec.Checkpoint("checkpoint 1")
        self.cp1.mod_path = "unittest"
        self.cp1.checkpoint_class = "TestCase"
        self.cp2 = dc_exec.Checkpoint("checkpoint 2")
        self.cp2.mod_path = "unittest"
        self.cp2.checkpoint_class = "TestCase"

        # create a logger
        self.logger = logging.getLogger(INSTALL_LOGGER_NAME)
    def setUp(self):
        # create a dummy filesystem with some files created in the proper
        # location
        self.engine = engine_test_utils.get_new_engine_instance()

        self.pi_filelist = ["/etc/gdm/", "/save/", "/jack/",
                            "/etc/gdm/custom.conf"]
        self.ba_filelist = ["/etc/gdm/custom.conf"]
        args = {"image_type": "test"}
        self.bac = LiveCDBootArchiveConfigure(name="Test BAC", arg=args)
        self.bac.ba_build = testlib.create_filesystem(*self.ba_filelist)
        self.bac.pkg_img_path = testlib.create_filesystem(*self.pi_filelist)

        self.gdm_conf = os.path.join(self.bac.pkg_img_path,
                                     "etc/gdm/custom.conf")
        with open(self.gdm_conf, "w+") as fh:
            fh.write("# GDM configuration storage\n\n")
            fh.write("[daemon]\n\n")
            fh.write("[security]\n\n")