def nx_get_protection_domains(VIP, PD_name): SUB_URL = 'api/nutanix/v2.0/protection_domains/' payload = {"annotations": ["Made v.i.a. REST-API"], "value": PD_name} r = requests.Response() r = nx_rest_api.rest_api(VIP, SUB_URL, payload, 'post') return r
def nx_get_storage_container_by_uuid(VIP, UUID): SUB_URL = "https://172.16.8.109:9440/api/nutanix/v2.0/storage_containers/" + UUID payload = {} r = requests.Response() r = nx_rest_api.rest_api(VIP, SUB_URL, payload, 'get') return r
def nx_get_images(VIP): SUB_URL = 'PrismGateway/services/rest/v2.0/images/' payload = {} r = requests.Response() r = nx_rest_api.rest_api(VIP, SUB_URL, payload, 'get') return r
def nx_get_storage_containers(VIP): SUB_URL = "/api/nutanix/v2.0/storage_containers/" payload = {} r = requests.Response() r = nx_rest_api.rest_api(VIP, SUB_URL, payload, 'get') return r
def nx_get_networks(VIP): # SUB_URL = 'PrismGateway/services/rest/v2.0/networks/' SUB_URL = 'api/nutanix/v2.0/networks/' payload = {} r = requests.Response() r = nx_rest_api.rest_api(VIP, SUB_URL, payload, 'get') return r
def nx_get_vms(VIP): # SUB_URL = 'PrismGateway/services/rest/v2.0/images/' SUB_URL = 'api/nutanix/v2.0/vms/?include_vm_disk_config=true&include_vm_nic_config=true' payload = {} r = requests.Response() r = nx_rest_api.rest_api(VIP, SUB_URL, payload, 'get') return r
def nx_delete_image(VIP, IMAGE_NAME): SUB_URL = "PrismGateway/services/rest/v2.0/images" SUB_URL_UUID = '' body = '{}' # e.x. image_uuid = '90a0068f-238a-452d-8b79-dd69743d9603' JSON = r.json() image_uuid_list = nx_get_image_uuid.get_image_uuid(JSON, IMAGE_NAME) print >> sys.stderr, "UUID_LIST: %s" % image_uuid_list n = len(image_uuid_list) # i=1 for uuid in image_uuid_list: print >> sys.stderr, "UUID:%s is going to be deleted!!" % uuid SUB_URL_UUID = SUB_URL + '/' + uuid # print >> sys.stderr, "SUB_URL_UUID: %s" % SUB_URL_UUID nx_rest_api.rest_api(VIP, SUB_URL_UUID, body, 'delete') # i+=1 return n
def nx_create_image_url(VIP, IMG_NAME, IOS_URL, STORAGE_CONTAINER): sub_url = "/PrismGateway/services/rest/v2.0/images/" body = { "name": IMG_NAME, "Imagne_type": "ISO_IMAGE", "image_import_spec": { "url": ISO_URL, "storage_container_name": STORAGE_CONTAINER } } print body r = nx_rest_api.rest_api(VIP, sub_url, body, 'post') return r
def nx_create_pd(VIP, PD_NAME): # VIP = '172.16.11.109:9440' SUB_URL = '/PrismGateway/services/rest/v2.0/protection_domains/' # body template for URL POST #{ # "annotations": [ # "PD made by REST-API" # ], # "value": "TestPD002" #} payload = {"annotations": ["PD made by REST-API"], "value": PD_NAME} r = requests.Response() r = nx_rest_api.rest_api(VIP, SUB_URL, payload, 'post') return r