def rem_floating_ip(self, floating_ip, server_id, fip_id): """ Disassociate a IP from a VM and elease the floating IP @param floating_ip: The floating IP @param server_id: the VM id where the floating id is associated @param fip_id: the floating ip id @return: The flaoting ip if all OK or a mgs error on failure """ the_url = "%s/%s/%s/%s" % (self.url_openstack, "servers", server_id, "action") payload = '{ "removeFloatingIp": {"address": "' + floating_ip + '" } }' loggers.set_info_log(the_url) loggers.set_info_log(payload) response = http.post(the_url, self.header, payload) loggers.set_info_log(response.status) if response.status != 202: msg = "Error: Cannot un-assign the floating IP" return None, msg the_url = "%s/%s/%s" % (self.url_openstack, "os-floating-ips", fip_id) response = http.delete(the_url, self.header) loggers.set_info_log("Deleted the floating IP") if response.status != 202: msg = "Error deleting the floating IP" return None, msg return floating_ip, None
def rem_floating_ip(self, floating_ip, server_id, fip_id): """ Disassociate a IP from a VM and elease the floating IP @param floating_ip: The floating IP @param server_id: the VM id where the floating id is associated @param fip_id: the floating ip id @return: The flaoting ip if all OK or a mgs error on failure """ the_url = "%s/%s/%s/%s" % ( self.url_openstack, "servers", server_id, "action") payload = '{ "removeFloatingIp": {"address": "' + floating_ip + '" } }' loggers.set_info_log(the_url) loggers.set_info_log(payload) response = http.post(the_url, self.header, payload) loggers.set_info_log(response.status) if response.status != 202: msg = "Error: Cannot un-assign the floating IP" return None, msg the_url = "%s/%s/%s" % (self.url_openstack, "os-floating-ips", fip_id) response = http.delete(the_url, self.header) loggers.set_info_log("Deleted the floating IP") if response.status != 202: msg = "Error deleting the floating IP" return None, msg return floating_ip, None
def delete_vm(self, vm_id): """ Delete a VM from its id @param vm_id: the id of the VM @return: None if all OK or an error on failure """ the_url = "%s/%s/%s" % (self.url_openstack, "servers", vm_id) response = http.delete(the_url, self.header) if response.status != 204: return 'error deleting vm' + str(response.status) + response.reason else: loggers.set_info_log('Deleting VM ........') return None
def delete_product_release(self, product_name, version): """ Delete a release of a product @param product_name: the name of the product @param version: the version of the product @return: None if all OK or an error on failure """ my_url = "%s/%s/%s/%s/%s" % (self.sdc_url, "catalog/product", product_name, "release", version) response = http.delete(my_url, self.header) if response.status() is not 200 and response.status() is not 204: error = "error to delete the product release " \ + product_name + ' ' + str(response.status()) return error return None
def delete_node_client(self): """ Delete the node from chef-server or puppet-master @return: None if all OK or an error on failure """ puppet_master_url = models.Data.objects.get(key="puppet_master_url") uri = '%s/%s/%s' % (puppet_master_url, 'delete/node', self.name) loggers.set_info_log("delete node: puppet_master url: " + uri) response = http.delete(uri, self.headers) if response.status() != 200: msg = "Error deleting node from puppet" loggers.set_error_log(str(response.status) + ": " + msg + ": " + response.read()) return "Error" return None
def delete_node_client(self): """ Delete the node from chef-server or puppet-master @return: None if all OK or an error on failure """ puppet_master_url = models.Data.objects.get(key="puppet_master_url") uri = '%s/%s/%s' % (puppet_master_url, 'delete/node', self.name) loggers.set_info_log("delete node: puppet_master url: " + uri) response = http.delete(uri, self.headers) if response.status() != 200: msg = "Error deleting node from puppet" loggers.set_error_log( str(response.status) + ": " + msg + ": " + response.read()) return "Error" return None
def delete_product_release(self, product_name, version): """ Delete a release of a product @param product_name: the name of the product @param version: the version of the product @return: None if all OK or an error on failure """ my_url = "%s/%s/%s/%s/%s" % ( self.sdc_url, "catalog/product", product_name, "release", version) response = http.delete(my_url, self.header) if response.status() is not 200 and response.status() is not 204: error = "error to delete the product release " \ + product_name + ' ' + str(response.status()) return error return None
def delete_product(self, product_name): """ Delete a product @param product_name: the name of the product @return: None if all OK or an error on failure """ prr = ProductReleaseRequest(self.token, self.tenant) version = prr.get_product_release(product_name) if version is not None: prr.delete_product_release(product_name, version) my_url = "%s/%s" % (self.sdc_url, "catalog/product/" + product_name) response = http.delete(my_url, self.header) if response.status() is not 200 and response.status() is not 204: error = 'error deleting the product ' + product_name + ' ' + str( response.status()) return error return None
def remove_master_server(self): """ Remove the software from puppet-master or chef-server @return: None if all OK or an error on failure """ puppet_master_url = models.Data.objects.get(key="puppet_master_url") uri = u'{0:s}/{1:s}/{2:s}'.format(puppet_master_url, 'delete/module', self.name) response = http.delete(uri, self.headers) if response.status() != 200: msg = "Error deleting the puppet module from the puppet master" loggers.set_error_log(str(response.status) + ": " + msg + ": " + response.read()) return msg loggers.set_info_log( str(response.status) + ": Correctly deleting the module from the " "puppet master") return None
def remove_master_server(self): """ Remove the software from puppet-master or chef-server @return: None if all OK or an error on failure """ puppet_master_url = models.Data.objects.get(key="puppet_master_url") uri = u'{0:s}/{1:s}/{2:s}'.format(puppet_master_url, 'delete/module', self.name) response = http.delete(uri, self.headers) if response.status() != 200: msg = "Error deleting the puppet module from the puppet master" loggers.set_error_log( str(response.status) + ": " + msg + ": " + response.read()) return msg loggers.set_info_log( str(response.status) + ": Correctly deleting the module from the " "puppet master") return None