Exemplo n.º 1
0
 def listEntryInsertModify(self, value, entry, description, position=1, insert=None):
     """
         listIDInsert will insert a list entry with value, description at the position:1 unless specified.
     :param value: listID
     :param entry: List Entry
     :param description: List Description
     :param position: List Entry Position.
     :return: Status response of the post.
     """
     i = '''<entry xmlns="http://www.w3org/2011/Atom">
                 <content type="application/xml">
                     <listEntry>
                         <entry>{}</entry>
                         <description>{}</description>
                     </listEntry>
                 </content> 
             </entry>'''
     if insert == "insert":
         u = self.listURL(value=value, entry=position, insert=insert)
         i = i.format(entry, description)
         r = self.auth.post(u, data=i, headers={'Content-Type': 'application/xml'})
         return parseData(r.text)
     else:
         u = self.listURL(value=value, entry=position)
         i = i.format(entry, description)
         r = self.auth.put(u, data=i, headers={'Content-Type': 'application/xml'})
         return parseData(r.text)
Exemplo n.º 2
0
 def retrievsetting(self):
     """
     Retrieve settings from an appliance.
     """
     _url = self.validate.createAppendURL(string="setting")
     _response = self.auth.get(_url)
     return parseData(_response.text)
Exemplo n.º 3
0
 def listEntryDelete(self, value, position):
     """
         listEntryDelete will delete a list entry with value, description at the position:1 unless specified.
     :return: status response of the post
     """
     u = self.listURL(value=value, entry=position)
     r = self.auth.delete(u, headers={'Content-Type': 'application/xml'})
     return parseData(r.text)
Exemplo n.º 4
0
 def downloadsystemfile(self, uuid, name):
     """
         Download system file will get the data of the file.
         :return status of operation.
     """
     _url = self.validate.createAppendURL(
         string="appliances/{}/system/{}".format(uuid, name))
     _response = self.auth.get(_url)
     return parseData(_response.text)
Exemplo n.º 5
0
 def listRetrive(self,value):
     """
         listRetrive will grep the existing list based on the listID
     :param value: listID value
     :return: response status
     """
     u = self.listURL(value=value)
     r = self.auth.get(u, headers={'Content-Type': 'application/xml'})
     return parseData(r.text)
Exemplo n.º 6
0
 def listDelete(self, value):
     """
         listDelete will delete an entire list.
     :param value: listID value
     :return: response status.
     """
     u = self.listURL(value=value)
     r = self.auth.delete(u, headers={'Content-Type': 'application/xml'})
     return parseData(r.text)
Exemplo n.º 7
0
 def modifysystemfile(self, uuid, name, data):
     """
     Modify system file will push an api with the modified system file.
     :return status of operation.
     """
     _url = self.validate.createAppendURL(
         string="appliances/{}/system/{}".format(uuid, name))
     _response = self.auth.put(_url, params=data)
     return parseData(_response.text)
Exemplo n.º 8
0
 def listID(self, value):
     """
         listID will generate specific list details from the server.
     :param value: listID of the list
     :return: full list information.
     """
     r = self.auth.get(self.listURL(value=value))
     p = process(data=parseData(r.text))
     return p.processListID()
Exemplo n.º 9
0
 def retrievsystemfile(self, uuid):
     """
     method will get the system file from a specific appliance as needed.
     :return status of operation
     """
     _url = self.validate.createAppendURL(
         string="appliances/{}/system".format(uuid))
     _response = self.auth.get(_url)
     return parseData(_response.text)
Exemplo n.º 10
0
 def fileDelete(self, filename, uuid):
     """
         fileDelete will delete specific file from the appliance, if it exists.
     :param filename: Name of existing file to delete.
     :return: status of operation.
     """
     _url = self.validate.createAppendURL(
         string='appliances/{}/files/{}'.format(uuid, filename))
     _response = self.auth.delete(_url)
     return parseData(_response.text)
Exemplo n.º 11
0
 def listCreate(self, type, name):
     """
         listCreate will create a new list.
     :param type: List Type is value that defines what type of list must be created, from the documentation available
                 types are category, ip, iprange, mediatype, number, regex, string and Default is None.
     :param name: type = string, Name of new list.
     :return: response status
     """
     u = self.listURL(type=type, name=name)
     r = self.auth.post(u, headers={'Content-Type': 'application/xml'})
     return parseData(r.text)
Exemplo n.º 12
0
 def fileUpload(self, name, filedata, uuid):
     """
         fileUpload will upload all a file with filename and filedata provided.
     :param filename: name of the file.
     :param filedata: new file data
     :return: status of the operation
     """
     _url = self.validate.createAppendURL(
         string='appliances/{}/files/{}'.format(uuid, name))
     _response = self.auth.put(_url,
                               data=filedata.read(),
                               headers={'Content-Type': 'application/xml'})
     return parseData(_response.text)
Exemplo n.º 13
0
 def listAppliances(self, pagesize=10, page=1):
     """
         listAppliances method will generate a full list of appliances available depending on the primary cluster
     logged-in
     :return Full List of Appliances.
     """
     _url = self.reference.createAppendURL(string='appliances')
     _response = self.auth.get(_url,
                               params={
                                   'pageSize': pagesize,
                                   'page': page
                               })
     return parseData(_response.text)
Exemplo n.º 14
0
    def listData(self, pagesize=100, page=1):
        """
        listData will pull all the lists based on the listID, depending on the size of lists pagesize is used to
        iterate through all pages.
        :param pagesize:  Max Page Size
        :param page: initial page
        :return: All lists based on the pagesize..
        """

        r = self.auth.get(self.listURL(), params={'pageSize': pagesize})
        p = process(data=parseData(r.text))
        data = p.processList()
        pages = p.processPages()
        if len(pages) is not 1:
            data = [data]
            for page in pages:
                r = self.auth.get(self.listURL(), params={'pageSize': pagesize, 'page': page})
                p = process(data=parseData(r.text))
                data.append(p.processList())
            p = process(data=data)
            data = p.processListCombine()
        return data
Exemplo n.º 15
0
 def listAppliancesList(self, name=None, ltype=None):
     """
         listAppliancesList will generate the full list of appliances available in the cluster.
     :param name:
     :param ltype:
     :return: Full list of appliances in the active cluster.
     """
     _url = self.reference.createAppendURL(string='appliances')
     data = {}
     if ltype is not None:
         data['type'] = ltype
     if name is not None:
         data['name'] = name
     _response = self.auth.get(_url, params=data)
     return parseData(_response.text)
Exemplo n.º 16
0
 def retrieveclusterconfig(self):
     _url = self.validate.createAppendURL(string="cluster/configuration")
     _response = self.auth.get(_url)
     return parseData(_response.text)
Exemplo n.º 17
0
 def retrieveapplianceconfig(self, uuid):
     _url = self.validate.createAppendURL(
         string="appliances/{}/configuration".format(uuid))
     _response = self.auth.get(_url)
     return parseData(_response.text)