def _handle_repos(self, root):
        """Handle repo configuration."""
        ElementTree.SubElement(root, "key").text = "repos"
        repos_array = ElementTree.SubElement(root, "array")

        # Make a temporary jss object to try to pull repo information.
        jss_server = JSS(url=self.url, user=self.user, password=self.password,
                         ssl_verify=self.verify, suppress_warnings=True)
        print "Fetching distribution point info..."
        try:
            dpts = jss_server.DistributionPoint()
        except JSSGetError:
            print ("Fetching distribution point info failed. If you want to "
                   "configure distribution points, ensure that your API user "
                   "has read permissions for distribution points, and that "
                   "the URL, username, and password are correct.")
            dpts = None

        if dpts:
            print ("There are file share distribution points configured on "
                   "your JSS. Most of the configuration can be automated "
                   "from the information on the JSS, with the exception of "
                   "the password for the R/W user.\n")

            for dpt in dpts:
                repo_dict = ElementTree.SubElement(repos_array, "dict")

                repo_name_key = ElementTree.SubElement(repo_dict, "key")
                repo_name_key.text = "name"
                repo_name_string = ElementTree.SubElement(repo_dict, "string")
                repo_name_string.text = dpt.get("name")

                repo_pass_key = ElementTree.SubElement(repo_dict, "key")
                repo_pass_key.text = "password"
                repo_pass_string = ElementTree.SubElement(repo_dict, "string")
                repo_pass_string.text = getpass.getpass(
                    "Please enter the R/W user's password for distribution "
                    "point: %s: " % dpt.get("name", "<NO NAME CONFIGURED>"))

        _handle_dist_server("JDS", repos_array)
        _handle_dist_server("CDP", repos_array)
def _handle_repos ( self , root ) : ElementTree . SubElement ( root , "key" ) . text = "repos" repos_array = ElementTree . SubElement ( root , "array" ) jss_server = JSS ( url = self . url , user = self . user , password = self . password , ssl_verify = self . verify , suppress_warnings = True ) print "Fetching distribution point info..." try : dpts = jss_server . DistributionPoint ( ) except JSSGetError : print ( "Fetching distribution point info failed. If you want to " "configure distribution points, ensure that your API user " "has read permissions for distribution points, and that " "the URL, username, and password are correct." ) dpts = None if dpts : print ( "There are file share distribution points configured on " "your JSS. Most of the configuration can be automated " "from the information on the JSS, with the exception of " "the password for the R/W user.\n" ) for dpt in dpts : repo_dict = ElementTree . SubElement ( repos_array , "dict" ) repo_name_key = ElementTree . SubElement ( repo_dict , "key" ) repo_name_key . text = "name" repo_name_string = ElementTree . SubElement ( repo_dict , "string" ) repo_name_string . text = dpt . get ( "name" ) repo_pass_key = ElementTree . SubElement ( repo_dict , "key" ) repo_pass_key . text = "password" repo_pass_string = ElementTree . SubElement ( repo_dict , "string" ) repo_pass_string . text = getpass . getpass ( "Please enter the R/W user's password for distribution " "point: %s: " % dpt . get ( "name" , "<NO NAME CONFIGURED>" ) ) _handle_dist_server ( "JDS" , repos_array ) _handle_dist_server ( "CDP" , repos_array )
Handle repo configuration.