/** * Startups load balancer * * @global array $_ALIASES menu page aliases * @param integer balancer Id * @return void */ private function startup($id) { global $_ALIASES; onapp_debug(__METHOD__); onapp_debug('id => ' . $id); onapp_permission(array('load_balancers', 'load_balancing_clusters', 'load_balancing_clusters.read', 'load_balancing_clusters.read.own')); $onapp = $this->get_factory(); $load_balancer = $onapp->factory('LoadBalancer', ONAPP_WRAPPER_LOG_REPORT_ENABLE); $load_balancer->_id = $id; $load_balancer->startup(); if (is_null($load_balancer->error)) { onapp_event_exec('load_balancer_startup', array($load_balancer->_obj, $this->load('User', array($load_balancer->_obj->_user_id)))); $_SESSION['message'] = 'BALANCER_STARTUP_HAS_BEEN_QUEUED'; onapp_redirect(ONAPP_BASE_URL . '/' . $_ALIASES['load_balancers'] . '?action=details&id=' . $id); } else { onapp_event_exec('load_balancer_startup_failed', array($load_balancer->_obj, $this->load('User', array($load_balancer->_obj->_user_id)))); trigger_error(print_r($load_balancer->error, true)); $this->show_template_view($load_balancer->error); } }
/** * Migrate VM to other Hypervisor * * @global array $_ALIASES menu page aliases * @param interger virtual machine id * @return void */ private function migrate($id) { global $_ALIASES; onapp_debug(__CLASS__ . ' :: ' . __FUNCTION__); onapp_debug('id => ' . $id); onapp_permission(array('virtual_machines', 'virtual_machines.migrate', 'virtual_machines.migrate.own')); $virtual_machine = onapp_get_arg('virtual_machine'); if (!$virtual_machine) { $this->show_template_migrate($id); } else { $onapp = $this->get_factory(); $vm = $onapp->factory('VirtualMachine', ONAPP_WRAPPER_LOG_REPORT_ENABLE); $vm->migrate($id, $virtual_machine['_destination_id']); // print('<pre>');print_r($vm);die(); onapp_debug('vm => ' . print_r($vm, true)); if (is_null($vm->error)) { onapp_event_exec('vm_migrate', array($vm->_obj)); $_SESSION['message'] = 'VIRTUAL_MACHINE_MIGRATE_HAS_BEEN_QUEUED'; onapp_redirect(ONAPP_BASE_URL . '/' . $_ALIASES['virtual_machines'] . '?action=details&id=' . $id); } else { onapp_event_exec('vm_migrate_failed', array($vm->_obj)); trigger_error(print_r($vm->error, true)); $this->show_template_details($id, $vm->error); } } }
/** * Edits user group * * @global array $_ALIASES menu page aliases * @param integer user group id * @return void */ private function group_edit($id) { global $_ALIASES; onapp_debug(__CLASS__ . ' :: ' . __FUNCTION__); onapp_debug('id => ' . $id); onapp_permission(array('groups', 'groups.update')); $group = onapp_get_arg('group'); if (is_null($group)) { $this->show_template_group_edit($id); } else { $onapp = $this->get_factory(); $group_obj = $onapp->factory('UserGroup', ONAPP_WRAPPER_LOG_REPORT_ENABLE); foreach ($group as $key => $value) { $group_obj->{$key} = $value; } $group_obj->_id = $id; //TODO delete this when fixed Ticket #2511 $group_obj->_tagRoot = 'pack'; //***************************** $group_obj->save(); onapp_debug('group_obj =>' . print_r($group_obj, true)); if (is_null($group_obj->error)) { onapp_event_exec('group_edit', array($group_obj->_obj)); $_SESSION['message'] = 'GROUP_HAS_BEEN_UPDATED_SUCCESSFULLY'; onapp_redirect(ONAPP_BASE_URL . '/' . $_ALIASES['users_and_groups'] . '?action=groups'); } else { onapp_event_exec('group_edit_failed', array($group_obj->_obj)); trigger_error(print_r($group_obj->error, true)); $this->show_template_groups($group_obj->error); } } }
/** * Edits hypervisor's params * * @global array $_ALIASES menu page aliases * @param integer hypervisor id * @return void */ private function edit($id) { global $_ALIASES; onapp_debug(__METHOD__); onapp_debug('id => ' . $id); $hypervisor = onapp_get_arg('hypervisor'); onapp_permission(array('hypervisors.update', 'hypervisors')); if (is_null($hypervisor)) { $this->show_template_edit($id); } else { $onapp = $this->get_factory(); $id = onapp_get_arg('id'); $hypervisor_obj = $onapp->factory('Hypervisor', ONAPP_WRAPPER_LOG_REPORT_ENABLE); foreach ($hypervisor as $key => $value) { $hypervisor_obj->{$key} = $value; } $hypervisor_obj->_id = $id; $hypervisor_obj->save(); onapp_debug('hypervisor_obj =>' . print_r($hypervisor_obj, true)); if (is_null($hypervisor_obj->error)) { onapp_event_exec('hypervisor_edit', array($hypervisor_obj->_obj)); $_SESSION['message'] = 'HYPERVISOR_HAS_BEEN_UPDATED_SUCCESSFULLY'; onapp_redirect(ONAPP_BASE_URL . '/' . $_ALIASES['hypervisors']); } else { onapp_event_exec('hypervisor_edit_failed', array($hypervisor_obj->_obj)); trigger_error(print_r($hypervisor_obj->error, true)); $this->show_template_view($hypervisor_obj->error); } } }