Beispiel #1
0
    def test_cpio_non_default_args_set(self):
        '''Test copying a list of directories and files succeeds'''
        # Copy all the directories and files from /etc/X11 and /etc/zones
        # to /rpool/cpio_test_dir using a list for the contents

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        args = Args({"cpio_args": "-n -d -pdum"})
        self.tr_node.insert_children([args])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        self.TEST_CONTENTS_LIST.append("bin/xclock")
        self.TEST_CONTENTS_LIST.append("bin/pv.sh")

        # The CPIO values that are specified
        self.TEST_CONTENTS_LIST.append("etc/X11")
        self.TEST_CONTENTS_LIST.append("etc/zones")
        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_CONTENTS_LIST

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
Beispiel #2
0
    def test_valid_transfer_action(self):
        '''Test valid input with dry run.
        '''
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "uninstall"
        self.tr_node2.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])
        args2 = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node2.insert_children([args2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2"]

        self.tr_node3 = SVR4Spec()
        self.tr_node3.action = "transform"
        self.tr_node3.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node3])

        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
Beispiel #3
0
    def test_dry_run_transfer(self):
        '''Test with accurate input dry run succeeds
        '''
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "install"
        self.tr_node2.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])
        args2 = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node2.insert_children([args2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2"]

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
Beispiel #4
0
    def test_install_uninstall_dry_run(self):
        '''Test an install followed by an uninstall'''
        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2", "SUNWpkg3"]
        args = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node.insert_children([args])
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "uninstall"
        self.tr_node2.contents = ["SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
Beispiel #5
0
    def test_single_args_instance(self):
        '''Test pass when single instance of args provided
        '''
        mysrc = "srcdir"
        mydest = "destfile"
        args = Args({"svr4_args": "-n -d %s -R %s" % (mysrc, mydest)})
        self.tr_node.insert_children([args])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1"]

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
Beispiel #6
0
 def test_image_args(self):
     '''Test that setting Args for the image works'''
     image_args = Args(arg_dict={"force": True})
     self.ips_image.insert_children([image_args])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Beispiel #7
0
 def test_install_args(self):
     '''Test that setting Args for the install works'''
     install_args = Args(arg_dict={"refresh_catalogs": False})
     self.tr_node.insert_children([install_args])
     self.tr_node.action = "install"
     self.tr_node.contents = ["SUNWcs"]
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Beispiel #8
0
    def test_multiple_args_declared(self):
        '''Test having multiple args fails'''
        args = Args({"svr4_args": "-n -d"})
        self.tr_node.insert_children([args])
        args2 = Args({"svr4_args": "-n -d, mi"})
        self.tr_node.insert_children([args2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1"]

        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
Beispiel #9
0
    def test_invalid_args(self):
        '''Ensure error raised when repo components are set as args'''
        image_args = Args(arg_dict={"prefix": "prefix string"})
        self.ips_image.insert_children([image_args])
        self.assertRaises(ValueError, self.tr_ips.execute, dry_run=DRY_RUN)

        # Test repo_uri fails
        self.ips_image.delete_children()
        image_args = Args(arg_dict={"repo_uri": "url string"})
        self.ips_image.insert_children([image_args])
        self.assertRaises(Exception, self.tr_ips.execute, dry_run=DRY_RUN)

        # Test origins fails
        self.ips_image.delete_children()
        image_args = Args(arg_dict={"origins": "origin string"})
        self.ips_image.insert_children([image_args])
        self.assertRaises(Exception, self.tr_ips.execute, dry_run=DRY_RUN)

        # Test mirrors fails
        self.ips_image.delete_children()
        image_args = Args(arg_dict={"mirrors": "mirror string"})
        self.ips_image.insert_children([image_args])
        self.assertRaises(Exception, self.tr_ips.execute, dry_run=DRY_RUN)
Beispiel #10
0
 def test_unavoid_with_args(self):
     '''Test that an IPS package can be rejected with args'''
     install_args = Args(arg_dict={"update_index": False})
     self.tr_node.action = "unavoid"
     self.tr_node.contents = ["solaris-large-server"]
     self.tr_node.insert_children([install_args])
     self.tr_node2 = IPSSpec()
     self.tr_node2.action = "unavoid"
     self.tr_node2.contents = ["system/library/svm-rcm"]
     self.soft_node.insert_children([self.tr_node2])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Beispiel #11
0
 def test_uninstall_args(self):
     '''Test that setting Args for the uninstall works'''
     uninstall_args = Args(arg_dict={"update_index": False})
     self.tr_node.action = "install"
     self.tr_node.contents = ["SUNWcs", "system/library/svm-rcm"]
     self.tr_node2 = IPSSpec()
     self.tr_node2.action = "uninstall"
     self.tr_node2.contents = ["system/library/svm-rcm"]
     self.tr_node2.insert_children([uninstall_args])
     self.soft_node.insert_children([self.tr_node2])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Beispiel #12
0
    def test_uninstall_bad_args(self):
        '''Test transfer uninstall fails with bad args
        '''
        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        args = Args({"svr4_args": "-q -r -s -t"})
        self.tr_node.insert_children([args])
        self.tr_node.action = "uninstall"
        self.tr_node.contents = ["SUNWpkg1"]
        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=False)
Beispiel #13
0
 def test_args(self):
     '''Test that setting the ips arguments works'''
     soft_node = Software("transfer test 4")
     tr_node = IPSSpec()
     ips_args_node = Args({"force": True, "set-something": 12})
     tr_node.insert_children([ips_args_node])
     soft_node.insert_children([tr_node])
     self.doc.insert_children([soft_node])
     soft_list = self.doc.get_children("transfer test 4", Software)
     for soft in soft_list:
         tr_list = soft.get_children(class_type=IPSSpec)
         for tr in tr_list:
             ips_args = tr.get_children("args", Args)
             for args in ips_args:
                 for key in args.arg_dict:
                     if key is not "force" or key is not "set-something":
                         self.assertTrue(True)
                     if key is "force":
                         self.assertEqual(args.arg_dict[key], True)
                     if key is "set-something":
                         self.assertEqual(args.arg_dict[key], 12)
Beispiel #14
0
 def test_ssl_cert_in_image_args(self):
     '''Test that setting ssl_cert in image_args produces an error'''
     image_args = Args(arg_dict={"ssl_cert": "aaa"})
     self.ips_image.insert_children([image_args])
     self.assertRaises(Exception, self.tr_ips.execute, dry_run=DRY_RUN)
Beispiel #15
0
    def test_info(self):
        '''Test that all the arguments get into the node correctly'''
        soft_node = Software("SVR4 transfer test 1")
        svr4_node = SVR4Spec()

        dst = Destination()
        path = Dir("/a")
        dst.insert_children([path])

        src = Source()
        path = Dir("/bin")
        src.insert_children([path])

        # first check src and dst
        soft_node.insert_children([dst, src, svr4_node])
        self.doc.insert_children([soft_node])
        soft_list = self.doc.get_children("SVR4 transfer test 1", Software)

        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", SVR4Spec)
            for tr in tr_list:
                try:
                    args = tr.get_children("args", Args)[0]
                except:
                    self.assertTrue(True)
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(tr.action, None)
                self.assertEqual(tr.contents, None)

        # set cpio args
        args = Args({"svr4_args": "-n -d"})
        svr4_node.insert_children([args])

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", SVR4Spec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["svr4_args"], "-n -d")
                self.assertEqual(tr.action, None)
                self.assertEqual(tr.contents, None)

        # set install package content
        svr4_node.action = "install"
        svr4_node.contents = ["SUNWcsr", "SUNWcsu"]

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", SVR4Spec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["svr4_args"], "-n -d")
                self.assertEqual(tr.action, "install")
                self.assertEqual(tr.contents, ["SUNWcsr", "SUNWcsu"])

        # set uninstall package content
        svr4_node.action = "uninstall"
        svr4_node.contents = ["SUNWlxml", "SUNWzfs"]

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", SVR4Spec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["svr4_args"], "-n -d")
                self.assertEqual(tr.action, "uninstall")
                self.assertEqual(tr.contents, ["SUNWlxml", "SUNWzfs"])
Beispiel #16
0
    def test_info(self):
        '''Test that all the arguments get into the node correctly'''
        soft_node = Software("CPIO transfer test 1")
        cpio_node = CPIOSpec()

        dst = Destination()
        path = Dir("/a")
        dst.insert_children([path])

        src = Source()
        path = Dir("/bin")
        src.insert_children([path])

        # first check src and dst
        soft_node.insert_children([dst, src, cpio_node])
        self.doc.insert_children([soft_node])
        soft_list = self.doc.get_children("CPIO transfer test 1", Software)
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", CPIOSpec)
            for tr in tr_list:
                try:
                    args = tr.get_children("args", Args)[0]
                except:
                    self.assertTrue(True)
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(tr.action, None)
                self.assertEqual(tr.contents, None)

        # set cpio args
        args = Args({"cpio_args": "-pdm"})
        cpio_node.insert_children([args])

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", CPIOSpec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["cpio_args"], "-pdm")
                self.assertEqual(tr.action, None)
                self.assertEqual(tr.contents, None)

        # set file_list content
        cpio_node.action = "install"
        cpio_node.type = "FILE"
        cpio_node.contents = "/usr/share/tr_file_list"

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", CPIOSpec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["cpio_args"], "-pdm")
                self.assertEqual(tr.action, "install")
                self.assertEqual(tr.contents, "/usr/share/tr_file_list")

        # set dir_list
        cpio_node.action = "install"
        cpio_node.type = "DIR"
        cpio_node.contents = "/usr/share/tr_dir_list"

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", CPIOSpec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["cpio_args"], "-pdm")
                self.assertEqual(tr.action, "install")
                self.assertEqual(tr.contents, "/usr/share/tr_dir_list")

        # set skip_file_list
        cpio_node.action = "uninstall"
        cpio_node.type = "FILE"
        cpio_node.contents = "/usr/share/tr_skip_file_list"

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", CPIOSpec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["cpio_args"], "-pdm")
                self.assertEqual(tr.action, "uninstall")
                self.assertEqual(tr.contents, "/usr/share/tr_skip_file_list")

        # set dir_excl_list
        cpio_node.action = "uninstall"
        cpio_node.type = "DIR"
        cpio_node.contents = "/usr/share/tr_dir_excl_list"

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", CPIOSpec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["cpio_args"], "-pdm")
                self.assertEqual(tr.action, "uninstall")
                self.assertEqual(tr.contents, "/usr/share/tr_dir_excl_list")

        # set media transform
        cpio_node.action = "transform"
        cpio_node.type = "None"
        cpio_node.contents = "/usr/share/media_transform"

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", CPIOSpec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["cpio_args"], "-pdm")
                self.assertEqual(tr.action, "transform")
                self.assertEqual(tr.contents, "/usr/share/media_transform")