Esempio n. 1
0
 def test_ssl_vs(self):
     papi = ApiSession('10.10.25.42',
                       'admin',
                       'avi123',
                       verify=False,
                       api_version="17.2.1")
     ssl_vs_cfg = gSAMPLE_CONFIG["SSL-VS"]
     vs_obj = ssl_vs_cfg["vs_obj"]
     pool_name = gSAMPLE_CONFIG["SSL-VS"]["pool_obj"]["name"]
     resp = papi.post('pool', data=gSAMPLE_CONFIG["SSL-VS"]["pool_obj"])
     assert resp.status_code == 201
     pool_ref = papi.get_obj_ref(resp.json())
     cert, key, _, _ = get_sample_ssl_params(folder_path='../samples/')
     api_utils = ApiUtils(papi)
     try:
         resp = api_utils.import_ssl_certificate("ssl-vs-kc", key, cert)
         print resp.text
         ssl_kc = resp.json()
     except:
         ssl_kc = api.get_object_by_name('sslkeyandcertificate',
                                         'ssl-vs-kc')
     ssl_key_and_cert_ref = [papi.get_obj_ref(ssl_kc)]
     vs_obj["pool_ref"] = pool_ref
     vs_obj["ssl_key_and_certificate_refs"] = ssl_key_and_cert_ref
     resp = papi.post('virtualservice', data=json.dumps(vs_obj))
     print resp, resp.text
     assert resp.status_code < 300
     resp = papi.delete_by_name('virtualservice', vs_obj['name'])
     assert resp.status_code in (200, 204)
     resp = papi.delete_by_name("pool", pool_name)
     assert resp.status_code in (200, 204)
     resp = api.delete_by_name('sslkeyandcertificate', 'ssl-vs-kc')
     assert resp.status_code in (200, 204)
Esempio n. 2
0
 def test_ssl_vs(self):
     papi = ApiSession(api.controller_ip, api.username, api.password,
                       verify=False)
     ssl_vs_cfg = gSAMPLE_CONFIG["SSL-VS"]
     vs_obj = ssl_vs_cfg["vs_obj"]
     pool_name = gSAMPLE_CONFIG["SSL-VS"]["pool_obj"]["name"]
     resp = papi.post('pool', data=json.dumps(ssl_vs_cfg["pool_obj"]))
     pool_ref = papi.get_obj_ref(resp.json())
     cert, key, _, _ = get_sample_ssl_params(folder_path='../samples/')
     api_utils = ApiUtils(papi)
     try:
         resp = api_utils.import_ssl_certificate("ssl-vs-kc", key, cert)
         ssl_kc = resp.json()
     except:
         ssl_kc = api.get_object_by_name('sslkeyandcertificate',
                                         'ssl-vs-kc')
     ssl_key_and_cert_ref = [papi.get_obj_ref(ssl_kc)]
     vs_obj["pool_ref"] = pool_ref
     vs_obj["ssl_key_and_certificate_refs"] = ssl_key_and_cert_ref
     resp = papi.post('virtualservice', data=json.dumps(vs_obj))
     assert resp.status_code < 300
     resp = papi.delete_by_name('virtualservice', vs_obj['name'])
     assert resp.status_code in (200, 204)
     resp = papi.delete_by_name("pool", pool_name)
     assert resp.status_code in (200, 204)
     resp = api.delete_by_name('sslkeyandcertificate', 'ssl-vs-kc')
     assert resp.status_code in (200, 204)
Esempio n. 3
0
 def setupApiSession(self):
     self.api = None
     api = ApiSession.get_session(self.controller_ip, self.user, self.password,
                            tenant=self.tenant)
     server_cert, server_key, _, _ = get_sample_ssl_params()
     ApiUtils(api).import_ssl_certificate('MyCert', server_key, server_cert)
     self.api = api
     return api
Esempio n. 4
0
 def setupApiSession(self):
     self.api = None
     api = ApiSession.get_session(self.controller_ip,
                                  self.user,
                                  self.password,
                                  tenant=self.tenant)
     server_cert, server_key, _, _ = get_sample_ssl_params()
     ApiUtils(api).import_ssl_certificate('MyCert', server_key, server_cert)
     self.api = api
     return api
 def upload_ssl_certs(self, ssl_cert_name, ssl_cert_file_path=''):
     '''
     '''
     cert, key, _, _ = get_sample_ssl_params()
     # upload the key and cert to the controller with name ssl_cert_name
     resp = self.api_utils.import_ssl_certificate(ssl_cert_name, key, cert)
     if resp.status_code not in xrange(200, 299):
         print 'Error in uploading certs : %s' % resp.text
         exit(0)
     ssl_kc_ref = self.api.get_obj_ref(resp)
     return ssl_kc_ref
 def upload_ssl_certs(self, ssl_cert_name, ssl_cert_file_path=''):
     '''
     '''
     cert, key, _, _ = get_sample_ssl_params()
     # upload the key and cert to the controller with name ssl_cert_name
     resp = self.api_utils.import_ssl_certificate(ssl_cert_name, key, cert)
     if resp.status_code not in range(200, 299):
         print('Error in uploading certs : %s' % resp.text)
         exit(0)
     ssl_kc_ref = self.api.get_obj_ref(resp)
     return ssl_kc_ref