def upgrade_plugin(self): try: obj = models.VcenterConfiguration.objects.latest('id') ip=str(obj.vc_ip) username = str(obj.vc_username) password = str(obj.vc_password) port = str(obj.vc_port) manage_ip = str(obj.vc_management_ip) status_flag = self.validate_vcp_param(ip,port,username,password,True) if status_flag == True: status_flag=utils.update_plugin_zipfile(ip,username,password,port,'UPGRADE',utils.get_plugin_version()) if status_flag == True: sys_guiprotocol = self.get_sys_protocol() plug=plugin.PluginManager() status_flag=plug.upgrade_vCenter_plugin(ip,username,password,port,manage_ip,sys_guiprotocol) if status_flag == True : self.vcp_is_update_available = False obj.vc_version = utils.get_plugin_version() obj.save() return True else: self.vcp_status = 'Upgrade failed. Please contact support.' return False else: self.vcp_status = 'Upgrade failed. Please contact support.' return False else: self.vcp_status = status_flag return False except Exception as ex: self.vcp_status = 'Upgrade failed. Please contact support.' return False
def install_plugin(self): try: ip = str(self.cleaned_data['vc_ip']) port = str(self.cleaned_data['vc_port']) manage_ip = str(self.cleaned_data['vc_management_ip']) password = str(self.cleaned_data['vc_password']) username = str(self.cleaned_data['vc_username']) status_flag = self.validate_vcp_param(ip,port,username,password,False) if status_flag == True: status_flag = utils.update_plugin_zipfile(ip,username,password,port,'NEW',utils.get_plugin_version()) if status_flag == True: sys_guiprotocol = self.get_sys_protocol() plug=plugin.PluginManager() status_flag = plug.install_vCenter_plugin(ip,username,password,port,manage_ip,sys_guiprotocol) if status_flag == True : self.vcp_is_installed = True self.vcp_is_update_available = False models.VcenterConfiguration.objects.all().delete()# Just for cleaning purpose return True elif 'permission' in status_flag: self.vcp_status = status_flag return False else : self.vcp_status = 'Installation failed. Please contact support.' return False else : self.vcp_status = 'Installation failed. Please contact support.' return False else: self.vcp_status = status_flag return False except Exception as ex: self.vcp_status = 'Installation failed. Please contact support.' return False