Exemple #1
0
    def setUp(self):
        """
      Sets up Cobbler API connection and logs in
      """

        self.url_api = utils.local_get_cobbler_api_url()
        self.url_xmlrpc = utils.local_get_cobbler_xmlrpc_url()
        self.remote = xmlrpclib.Server(self.url_api)
        self.shared_secret = utils.get_shared_secret()

        self.token = self.remote.login("", self.shared_secret)
        if not self.token:
            self.server.stop()
            sys.exit(1)

        # Create temp dir
        self.topdir = "/tmp/cobbler_test"
        try:
            os.makedirs(self.topdir)
        except:
            pass

        self.fk_initrd = os.path.join(self.topdir, FAKE_INITRD)
        self.fk_initrd2 = os.path.join(self.topdir, FAKE_INITRD2)
        self.fk_initrd3 = os.path.join(self.topdir, FAKE_INITRD3)

        self.fk_kernel = os.path.join(self.topdir, FAKE_KERNEL)
        self.fk_kernel2 = os.path.join(self.topdir, FAKE_KERNEL2)
        self.fk_kernel3 = os.path.join(self.topdir, FAKE_KERNEL3)

        create = [self.fk_initrd, self.fk_initrd2, self.fk_initrd3, self.fk_kernel, self.fk_kernel2, self.fk_kernel3]
        for fn in create:
            f = open(fn, "w+")
            f.close()
Exemple #2
0
def test_local_get_cobbler_xmlrpc_url():
    # Arrange

    # Act
    result = utils.local_get_cobbler_xmlrpc_url()

    # Assert
    assert result == "http://127.0.0.1:25151"
Exemple #3
0
    def __init__(self):
        # Load server ip and ports from local config
        self.url_cobbler_api = utils.local_get_cobbler_api_url()
        self.url_cobbler_xmlrpc = utils.local_get_cobbler_xmlrpc_url()

        # FIXME: allow specifying other endpoints, and user+pass
        self.parser = optparse.OptionParser()
        self.remote = xmlrpc.client.Server(self.url_cobbler_api)
        self.shared_secret = utils.get_shared_secret()
Exemple #4
0
    def __init__(self):
        # Load server ip and ports from local config
        self.url_cobbler_api = utils.local_get_cobbler_api_url()
        self.url_cobbler_xmlrpc = utils.local_get_cobbler_xmlrpc_url()

        # FIXME: allow specifying other endpoints, and user+pass
        self.parser = optparse.OptionParser()
        self.remote = xmlrpc.client.Server(self.url_cobbler_api)
        self.shared_secret = utils.get_shared_secret()
Exemple #5
0
    def setUp(self):
        """
      Sets up Cobbler API connection and logs in
      """

        self.url_api = utils.local_get_cobbler_api_url()
        self.url_xmlrpc = utils.local_get_cobbler_xmlrpc_url()
        self.remote = xmlrpclib.Server(self.url_api)
        self.shared_secret = utils.get_shared_secret()

        self.token = self.remote.login("", self.shared_secret)
        if not self.token:
            self.server.stop()
            sys.exit(1)

        # Create temp dir
        self.topdir = "/tmp/cobbler_test"
        try:
            os.makedirs(self.topdir)
        except:
            pass

        self.fk_initrd = os.path.join(self.topdir, FAKE_INITRD)
        self.fk_initrd2 = os.path.join(self.topdir, FAKE_INITRD2)
        self.fk_initrd3 = os.path.join(self.topdir, FAKE_INITRD3)

        self.fk_kernel = os.path.join(self.topdir, FAKE_KERNEL)
        self.fk_kernel2 = os.path.join(self.topdir, FAKE_KERNEL2)
        self.fk_kernel3 = os.path.join(self.topdir, FAKE_KERNEL3)

        create = [
            self.fk_initrd,
            self.fk_initrd2,
            self.fk_initrd3,
            self.fk_kernel,
            self.fk_kernel2,
            self.fk_kernel3,
        ]
        for fn in create:
            f = open(fn, "w+")
            f.close()
   def setUp(self):
      """
      Sets up Cobbler API connection and logs in
      """

      logging.basicConfig( stream=sys.stderr )
      self.logger = logging.getLogger( self.__class__.__name__ )
      self.logger.setLevel( logging.DEBUG )

      self.url_api = utils.local_get_cobbler_api_url()
      self.url_xmlrpc = utils.local_get_cobbler_xmlrpc_url()
      self.remote = xmlrpclib.Server(self.url_api)
      self.shared_secret = utils.get_shared_secret()

      self.token  = self.remote.login("", self.shared_secret)
      if not self.token:
         self.server.stop()
         sys.exit(1)

      # Create temp dir
      self.topdir = "/tmp/cobbler_test"
      try:
         os.makedirs(self.topdir)
      except:
         pass

      self.fk_initrd = os.path.join(self.topdir,  FAKE_INITRD)
      self.fk_initrd2 = os.path.join(self.topdir, FAKE_INITRD2)
      self.fk_initrd3 = os.path.join(self.topdir, FAKE_INITRD3)

      self.fk_kernel = os.path.join(self.topdir,  FAKE_KERNEL)
      self.fk_kernel2 = os.path.join(self.topdir, FAKE_KERNEL2)
      self.fk_kernel3 = os.path.join(self.topdir, FAKE_KERNEL3)

      self.redhat_kickstart = os.path.join(self.topdir, "test.ks")
      self.ubuntu_preseed = os.path.join(self.topdir, "test.seed")

      create = [ 
         self.fk_initrd, self.fk_initrd2, self.fk_initrd3,
         self.fk_kernel, self.fk_kernel2, self.fk_kernel3, 
         self.redhat_kickstart, self.ubuntu_preseed,
      ]
      for fn in create:
         f = open(fn,"w+")
         f.close()

      self.distro_fields = [
        # TODO: fetchable files, boot files, etc.
        # field_name, good value(s), bad value(s)
        # ["",["",],["",]],
        ["name",["testdistro0",],[]],
        ["kernel",[self.fk_kernel,],["",]],
        ["initrd",[self.fk_initrd,],["",]],
        ["breed",["generic",],["badversion",]],
        ["os_version",["generic26",],["bados",]],
        ["arch",["i386","x86_64","ppc","ppc64"],["badarch",]],
        ["comment",["test comment",],[]],
        ["owners",["user1 user2 user3",],[]],
        ["kernel_options",["a=1 b=2 c=3 c=4 c=5 d e",],[]],
        ["kernel_options_post",["a=1 b=2 c=3 c=4 c=5 d e",],[]],
        ["ks_meta",["a=1 b=2 c=3 c=4 c=5 d e",],[]],
        ["mgmt_classes",["one two three",],[]],
        ["redhat_management_key",["abcd1234",],[]],
        ["redhat_management_server",["1.1.1.1",],[]],
      ]

      self.profile_fields = [
        # TODO: fetchable files, boot files, etc.
        #       repos, which have to exist
        # field_name, good value(s), bad value(s)
        # ["",["",],["",]],
        ["name",["testprofile0",],[]],
        ["distro",["testdistro0",],["baddistro",]],
        ["enable_gpxe",["yes","YES","1","0","no"],[]],
        ["enable_menu",["yes","YES","1","0","no"],[]],
        ["comment",["test comment",],[]],
        ["owners",["user1 user2 user3",],[]],
        ["kernel_options",["a=1 b=2 c=3 c=4 c=5 d e",],[]],
        ["kernel_options_post",["a=1 b=2 c=3 c=4 c=5 d e",],[]],
        ["ks_meta",["a=1 b=2 c=3 c=4 c=5 d e",],[]],
        ["kickstart",[self.redhat_kickstart,self.ubuntu_preseed],["/path/to/bad/kickstart",]],
        ["proxy",["testproxy",],[]],
        ["virt_auto_boot",["1","0"],["yes","no"]],
        ["virt_cpus",["<<inherit>>","1","2"],["a",]],
        ["virt_file_size",["<<inherit>>","5","10"],["a",]],
        ["virt_disk_driver",["<<inherit>>","raw","qcow2","vmdk"],[]],
        ["virt_ram",["<<inherit>>","256","1024"],["a",]],
        ["virt_type",["<<inherit>>","xenpv","xenfv","qemu","kvm","vmware","openvz"],["bad",]],
        ["virt_bridge",["<<inherit>>","br0","virbr0","xenbr0"],[]],
        ["virt_path",["<<inherit>>","/path/to/test",],[]],
        ["dhcp_tag",["","foo"],[]],
        ["server",["1.1.1.1",],[]],
        ["name_servers",["1.1.1.1 1.1.1.2 1.1.1.3",],[]],
        ["name_servers_search",["example.com foo.bar.com",],[]],
        ["mgmt_classes",["one two three",],[]],
        ["mgmt_parameters",["<<inherit>>",],["badyaml",]], # needs more test cases that are valid yaml
        ["redhat_management_key",["abcd1234",],[]],
        ["redhat_management_server",["1.1.1.1",],[]],
        ["template_remote_kickstarts",["yes","YES","1","0","no"],[]],
      ]