当前位置: 首页>>代码示例>>PHP>>正文


PHP user::set_user方法代码示例

本文整理汇总了PHP中user::set_user方法的典型用法代码示例。如果您正苦于以下问题:PHP user::set_user方法的具体用法?PHP user::set_user怎么用?PHP user::set_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user的用法示例。


在下文中一共展示了user::set_user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: openqrm_dhcpd_resource

function openqrm_dhcpd_resource($cmd, $resource_fields)
{
    global $event;
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    $resource_id = $resource_fields["resource_id"];
    $resource_ip = $resource_fields["resource_ip"];
    $resource_mac = $resource_fields["resource_mac"];
    if (isset($resource_fields["resource_subnet"])) {
        $resource_subnet = $resource_fields["resource_subnet"];
    } else {
        $resource_subnet = "0.0.0.0";
    }
    $openqrm_admin_user = new user("openqrm");
    $openqrm_admin_user->set_user();
    $openqrm_server = new openqrm_server();
    $event->log("openqrm_new_resource", $_SERVER['REQUEST_TIME'], 5, "openqrm-dhcpd-resource-hook.php", "Handling {$cmd} event {$resource_id}/{$resource_ip}/{$resource_subnet}/{$resource_mac}", "", "", 0, 0, $resource_id);
    switch ($cmd) {
        case "add":
            $openqrm_server->send_command($OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/dhcpd/bin/openqrm-dhcpd-manager add -d " . $resource_id . " -m " . $resource_mac . " -i " . $resource_ip . " -s " . $resource_subnet . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " --openqrm-cmd-mode background");
            break;
        case "remove":
            $openqrm_server->send_command("{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/dhcpd/bin/openqrm-dhcpd-manager remove -d " . $resource_id . " -m " . $resource_mac . " -i " . $resource_ip . " -s " . $resource_subnet . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " --openqrm-cmd-mode background");
            break;
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:27,代码来源:openqrm-dhcpd-resource-hook.php

示例2: create_kvm_vm

function create_kvm_vm($host_resource_id, $name, $mac, $memory, $cpu, $swap, $additional_nic_str, $vm_type, $vncpassword)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $RESOURCE_INFO_TABLE;
    global $event;
    $event->log("create_kvm_vm_local", $_SERVER['REQUEST_TIME'], 5, "kvm-cloud-hook", "Creating KVM VM {$name} on Host resource {$host_resource_id}", "", "", 0, 0, 0);
    // start the vm on the host
    $host_resource = new resource();
    $host_resource->get_instance_by_id($host_resource_id);
    // we need to have an openQRM server object too since some of the
    // virtualization commands are sent from openQRM directly
    $openqrm = new openqrm_server();
    $openqrm_admin_user = new user("openqrm");
    $openqrm_admin_user->set_user();
    $vncpassword_parameter = "";
    if ($vncpassword != '') {
        $vncpassword_parameter = " -v " . $vncpassword;
    }
    // send command to create vm
    $vm_create_cmd = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/kvm/bin/openqrm-kvm-vm create -n " . $name . " -y " . $vm_type . " -m " . $mac . " -r " . $memory . " -c " . $cpu . " -b local " . $additional_nic_str . " " . $vncpassword_parameter . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password;
    $host_resource->send_command($host_resource->ip, $vm_create_cmd);
    $event->log("create_kvm_vm_local", $_SERVER['REQUEST_TIME'], 5, "kvm-cloud-hook", "Running {$vm_create_cmd}", "", "", 0, 0, 0);
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:25,代码来源:openqrm-kvm-cloud-hook.php

示例3: set_env

function set_env()
{
    // auth user
    if (isset($_SERVER['PHP_AUTH_USER'])) {
        $OPENQRM_USER = new user($_SERVER['PHP_AUTH_USER']);
        if ($OPENQRM_USER->check_user_exists()) {
            $OPENQRM_USER->set_user();
            $GLOBALS['OPENQRM_USER'] = $OPENQRM_USER;
            define('OPENQRM_USER_NAME', $OPENQRM_USER->name);
            define('OPENQRM_USER_ROLE_NAME', $OPENQRM_USER->role);
        }
    }
    // admin user for running commands
    $OPENQRM_ADMIN = new user('openqrm');
    $OPENQRM_ADMIN->set_user();
    $GLOBALS['OPENQRM_ADMIN'] = $OPENQRM_ADMIN;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:17,代码来源:user.inc.php

示例4: user

 function __construct()
 {
     // handle timezone needed since php 5.3
     if (function_exists('ini_get')) {
         if (ini_get('date.timezone') === '') {
             date_default_timezone_set('Europe/Berlin');
         }
     }
     $this->rootdir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base';
     $this->tpldir = $this->rootdir . '/tpl';
     require_once $this->rootdir . '/class/file.handler.class.php';
     $file = new file_handler();
     require_once $this->rootdir . '/class/htmlobjects/htmlobject.class.php';
     require_once $this->rootdir . '/class/openqrm.htmlobjects.class.php';
     $html = new openqrm_htmlobject();
     // if openQRM is unconfigured, set openqrm empty
     if ($file->exists($this->rootdir . '/unconfigured')) {
         $this->openqrm = '';
         $this->webdir = $this->rootdir;
         $this->baseurl = $html->thisurl;
     } else {
         require_once $this->rootdir . '/class/user.class.php';
         $user = new user($_SERVER['PHP_AUTH_USER']);
         $user->set_user();
         require_once $this->rootdir . '/class/openqrm.class.php';
         $this->openqrm = new openqrm($file, $user, $html->response());
         $this->webdir = $this->openqrm->get('webdir');
         $this->baseurl = $this->openqrm->get('baseurl');
     }
     // only translate if openqrm is not empty (configure mode)
     if ($this->openqrm !== '') {
         $html->lang = $user->translate($html->lang, $this->rootdir . "/lang", 'htmlobjects.ini');
         $file->lang = $user->translate($file->lang, $this->rootdir . "/lang", 'file.handler.ini');
         $this->lang = $user->translate($this->lang, $this->rootdir . "/lang", 'openqrm.controller.ini');
     }
     require_once $this->rootdir . '/include/requestfilter.inc.php';
     $request = $html->request();
     $request->filter = $requestfilter;
     $this->response = $html->response();
     $this->request = $this->response->html->request();
     $this->file = $file;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:42,代码来源:openqrm.controller.class.php

示例5: storage_auth_function

function storage_auth_function($cmd, $appliance_id)
{
    global $event;
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $IMAGE_AUTHENTICATION_TABLE;
    global $openqrm_server;
    global $RootDir;
    $appliance = new appliance();
    $appliance->get_instance_by_id($appliance_id);
    $image = new image();
    $image->get_instance_by_id($appliance->imageid);
    $image_name = $image->name;
    $image_rootdevice = $image->rootdevice;
    $storage = new storage();
    $storage->get_instance_by_id($image->storageid);
    $storage_resource = new resource();
    $storage_resource->get_instance_by_id($storage->resource_id);
    $storage_ip = $storage_resource->ip;
    $deployment = new deployment();
    $deployment->get_instance_by_type($image->type);
    $deployment_type = $deployment->type;
    $deployment_plugin_name = $deployment->storagetype;
    $resource = new resource();
    $resource->get_instance_by_id($appliance->resources);
    $resource_mac = $resource->mac;
    $resource_ip = $resource->ip;
    // For kvm vms we assume that the image is located on the vm-host
    // so we send the auth command to the vm-host instead of the image storage.
    // This enables using a SAN backend with dedicated volumes per vm-host which all
    // contain all "golden-images" which are used for snapshotting.
    // We do this to overcome the current lvm limitation of not supporting cluster-wide snapshots
    $vm_host_resource = new resource();
    $vm_host_resource->get_instance_by_id($resource->vhostid);
    if ($vm_host_resource->id != $storage_resource->id) {
        $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-lvm-deployment-auth-hook.php", "Appliance " . $appliance_id . " image IS NOT available on this kvm host, " . $storage_resource->id . " not equal " . $vm_host_resource->id . " !! Assuming SAN Backend", "", "", 0, 0, $appliance_id);
    } else {
        $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-lvm-deployment-auth-hook.php", "Appliance " . $appliance_id . " image IS available on this kvm host, " . $storage_resource->id . " equal " . $vm_host_resource->id . ".", "", "", 0, 0, $appliance_id);
    }
    switch ($cmd) {
        case "start":
            // authenticate the rootfs / needs openqrm user + pass
            $openqrm_admin_user = new user("openqrm");
            $openqrm_admin_user->set_user();
            // generate a password for the image
            $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-lvm-deployment-auth-hook.php", "Authenticating " . $image_name . " / " . $image_rootdevice . " to resource " . $resource_mac . ".", "", "", 0, 0, $appliance_id);
            $auth_start_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/" . $deployment_plugin_name . "/bin/openqrm-" . $deployment_plugin_name . " auth -n " . $image_name . " -r " . $image_rootdevice . " -i " . $image_name . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " -t " . $deployment->type . " --openqrm-cmd-mode background";
            $resource->send_command($vm_host_resource->ip, $auth_start_cmd);
            break;
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:52,代码来源:openqrm-kvm-lvm-deployment-auth-hook.php

示例6: delete

 function delete()
 {
     $response = $this->get_response('delete');
     $folders = $response->html->request()->get($this->identifier_name);
     $form = $response->form;
     if ($folders !== '') {
         $i = 0;
         foreach ($folders as $folder) {
             $d['param_f' . $i]['label'] = $folder;
             $d['param_f' . $i]['object']['type'] = 'htmlobject_input';
             $d['param_f' . $i]['object']['attrib']['type'] = 'checkbox';
             $d['param_f' . $i]['object']['attrib']['name'] = $this->identifier_name . '[]';
             $d['param_f' . $i]['object']['attrib']['value'] = $folder;
             $d['param_f' . $i]['object']['attrib']['checked'] = true;
             $i++;
         }
         $form->add($d);
         if (!$form->get_errors() && $response->submit()) {
             $errors = array();
             $message = array();
             foreach ($folders as $key => $user) {
                 // protect user openqrm
                 if ($user !== 'openqrm') {
                     $del = new user($user);
                     $del->set_user();
                     $error = $del->query_delete();
                     if (is_array($error) && count($error) > 1) {
                         $errors[] = $error;
                     } else {
                         $form->remove($this->identifier_name . '[' . $key . ']');
                         $message[] = sprintf($this->lang['msg_deleted'], $user);
                     }
                 } else {
                     if ($user === 'openqrm') {
                         $form->remove($this->identifier_name . '[' . $key . ']');
                     }
                 }
             }
             if (count($errors) === 0) {
                 $response->msg = join('<br>', $message);
             } else {
                 $msg = array_merge($errors, $message);
                 $response->error = join('<br>', $msg);
             }
         }
         if ($form->get_errors()) {
             $response->error = join('<br>', $form->get_errors());
         }
     } else {
         $response->msg = '';
     }
     return $response;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:53,代码来源:user.users.class.php

示例7: switch

 function check_user($mode, $username, $password)
 {
     global $RootDir;
     global $event;
     switch ($mode) {
         case 'admin':
             $OPENQRM_USER = new user($username);
             if ($OPENQRM_USER->check_user_exists()) {
                 $OPENQRM_USER->set_user();
                 if (!strcmp($OPENQRM_USER->password, $password)) {
                     return true;
                 } else {
                     $event->log("cloudsoap->check_user", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Got a wrong password from openQRM User name {$username}!", "", "", 0, 0, 0);
                     return false;
                 }
             } else {
                 $event->log("cloudsoap->check_user", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "User name {$username} does not exists in openQRM !", "", "", 0, 0, 0);
                 return false;
             }
             break;
         case 'user':
             $cl_user = new clouduser();
             // check that the user exists
             if ($cl_user->is_name_free($username)) {
                 $event->log("cloudsoap->check_user", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud User name {$username} does not exists in the Cloud!", "", "", 0, 0, 0);
                 return false;
             }
             // check users password, only if ldap is not enabled
             if (!file_exists($RootDir . "/plugins/ldap/.running")) {
                 $cl_user->get_instance_by_name($username);
                 if (strcmp($cl_user->password, $password)) {
                     $event->log("cloudsoap->check_user", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Got a wrong password from Cloud User name {$username}!", "", "", 0, 0, 0);
                     return false;
                 }
             }
             return true;
             break;
         default:
             return false;
             break;
     }
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:42,代码来源:cloudsoap.class.php

示例8: sync

 function sync($ct_id, $insert_into_failed)
 {
     $openqrm_server = new openqrm_server();
     $OPENQRM_SERVER_IP_ADDRESS = $openqrm_server->get_ip_address();
     $this->get_instance_by_id($ct_id);
     // get cloud user
     $local_transaction_cloud_user = new clouduser();
     $local_transaction_cloud_user->get_instance_by_id($this->cu_id);
     // get cloud-zones config parameters from main config
     $cz_conf = new cloudconfig();
     $cloud_zones_master_ip = $cz_conf->get_value(36);
     // 36 is cloud_zones_master_ip
     // check if cloud_external_ip is set
     $cloud_external_ip = $cz_conf->get_value(37);
     // 37 is cloud_external_ip
     if (!strlen($cloud_external_ip)) {
         $cloud_external_ip = $openqrm_server->get_ip_address();
     }
     // get the admin user, the zone master will automatically authenticate against this user
     $openqrm_admin_user = new user("openqrm");
     $openqrm_admin_user->set_user();
     // url for the wdsl
     $url = "https://" . $cloud_zones_master_ip . "/openqrm/boot-service/cloud-zones-soap.wsdl";
     // turn off the WSDL cache
     ini_set("soap.wsdl_cache_enabled", "0");
     // create the soap-client
     $client = new SoapClient($url, array('soap_version' => SOAP_1_2, 'trace' => 1, 'login' => $openqrm_admin_user->name, 'password' => $openqrm_admin_user->password));
     //			var_dump($client->__getFunctions());
     try {
         $send_transaction_parameters = $openqrm_admin_user->name . "," . $openqrm_admin_user->password . "," . $cloud_external_ip . "," . $local_transaction_cloud_user->name . "," . $this->id . "," . $this->time . "," . $this->cr_id . "," . $this->ccu_charge . "," . $this->reason . "," . $this->comment;
         $new_local_ccu_value = $client->CloudZonesSync($send_transaction_parameters);
         // update users ccus values with return from master
         $local_transaction_cloud_user->set_users_ccunits($this->cu_id, $new_local_ccu_value);
         $this->_event->log("push", $_SERVER['REQUEST_TIME'], 5, "cloudtransaction.class.php", "Synced transaction! User:" . $this->cu_id . "/CR:" . $this->cr_id . "/Global CCU:" . $new_local_ccu_value, "", "", 0, 0, 0);
         return true;
     } catch (Exception $e) {
         $soap_error_msg = $e->getMessage();
         $this->_event->log("push", $_SERVER['REQUEST_TIME'], 2, "cloudtransaction.class.php", "Could not sync transaction! User:" . $this->cu_id . "/CR:" . $this->cr_id . "/Charge:" . $this->ccu_charge . "/" . $soap_error_msg, "", "", 0, 0, 0);
         if ($insert_into_failed) {
             // add to failed transactions
             $cloudtransactionfailed = new cloudtransactionfailed();
             $failed_transaction_fields['tf_id'] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
             $failed_transaction_fields['tf_ct_id'] = $ct_id;
             $cloudtransactionfailed->add($failed_transaction_fields);
         }
         return false;
     }
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:48,代码来源:cloudtransaction.class.php

示例9: create_private_kvm_gluster_deployment

function create_private_kvm_gluster_deployment($cloud_image_id, $private_disk, $private_image_name)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $RESOURCE_INFO_TABLE;
    global $event;
    $cloudimage = new cloudimage();
    $cloudimage->get_instance_by_id($cloud_image_id);
    $event->log("create_private_kvm_gluster_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-gluster-deployment-cloud-hook.php", "Creating private image " . $cloudimage->image_id . " on storage.", "", "", 0, 0, 0);
    // get image
    $image = new image();
    $image->get_instance_by_id($cloudimage->image_id);
    $image_id = $image->id;
    $image_name = $image->name;
    $image_type = $image->type;
    $image_version = $image->version;
    $image_rootdevice = $image->rootdevice;
    $image_rootfstype = $image->rootfstype;
    $imageid = $image->storageid;
    $image_isshared = $image->isshared;
    $image_comment = $image->comment;
    $image_capabilities = $image->capabilities;
    $image_deployment_parameter = $image->deployment_parameter;
    // get image storage
    $storage = new storage();
    $storage->get_instance_by_id($imageid);
    $storage_resource_id = $storage->resource_id;
    // get deployment type
    $deployment = new deployment();
    $deployment->get_instance_by_id($storage->type);
    // get storage resource
    $resource = new resource();
    $resource->get_instance_by_id($storage_resource_id);
    $resource_id = $resource->id;
    $resource_ip = $resource->ip;
    // create an admin user to post when cloning has finished
    $openqrm_admin_user = new user("openqrm");
    $openqrm_admin_user->set_user();
    $gluster_uri_arr = parse_url($image_rootdevice);
    // origin image volume name
    $origin_volume_name = basename($gluster_uri_arr['path']);
    // location of the volume (path)
    $image_location_name = str_replace('/', '', dirname($gluster_uri_arr['path']));
    $image_clone_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/kvm/bin/openqrm-kvm clone -n " . $origin_volume_name . " -s " . $private_image_name . " -v " . $image_location_name . " -m " . $private_disk . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " -t " . $deployment->type . " --openqrm-cmd-mode background";
    $event->log("create_private_kvm_gluster_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-gluster-deployment-cloud-hook.php", "Running : {$image_resize_cmd}", "", "", 0, 0, 0);
    $resource->send_command($resource->ip, $image_clone_cmd);
    // set the storage specific image root_device parameter
    $new_rootdevice = "gluster:" . $resource->ip . "//" . $image_location_name . "/" . $private_image_name;
    return $new_rootdevice;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:51,代码来源:openqrm-kvm-gluster-deployment-cloud-hook.php

示例10: openqrm_kvm_appliance

function openqrm_kvm_appliance($cmd, $appliance_fields)
{
    global $event;
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    $appliance_id = $appliance_fields["appliance_id"];
    $appliance_name = $appliance_fields["appliance_name"];
    $resource = new resource();
    $resource->get_instance_by_id($appliance_fields["appliance_resources"]);
    $appliance_ip = $resource->ip;
    $appliance = new appliance();
    $appliance->get_instance_by_id($appliance_id);
    // check appliance values, maybe we are in update and they are incomplete
    if ($appliance->imageid == 1) {
        return;
    }
    if ($resource->id == "-1" || $resource->id == "" || !isset($resource->vtype)) {
        return;
    }
    $openqrm_admin_user = new user("openqrm");
    $openqrm_admin_user->set_user();
    $event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "Handling {$cmd} event {$appliance_id}/{$appliance_name}/{$appliance_ip}", "", "", 0, 0, $appliance_id);
    switch ($cmd) {
        case "start":
            // send command to assign image and start vm
            // NOTICE : please enable this hook only if you are using the ip-mgmt plugin with vlans
            // check if resource type -> kvm-vm-net
            //			$virtualization = new virtualization();
            //			$virtualization->get_instance_by_type("kvm-vm-net");
            //			$kvm_host_resource = new resource();
            //			$kvm_host_resource->get_instance_by_id($resource->vhostid);
            //			if ($resource->vtype != $virtualization->id) {
            //				$kvm_command="$OPENQRM_SERVER_BASE_DIR/openqrm/plugins/kvm/bin/openqrm-kvm-vm reset_vlans_by_mac -b start -m $resource->mac";
            //				$kvm_host_resource->send_command($kvm_host_resource->ip, $kvm_command);
            //				return;
            //			}
            // check resource type -> kvm-vm-local
            $virtualization = new virtualization();
            $virtualization->get_instance_by_type("kvm-vm-local");
            if ($resource->vtype != $virtualization->id) {
                $event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "{$appliance_id} is not from type kvm-vm, skipping .. {$appliance_name}/{$appliance_ip}", "", "", 0, 0, $appliance_id);
                return;
            }
            // check image is on the same storage server
            // get the kvm host resource
            $kvm_host_resource = new resource();
            $kvm_host_resource->get_instance_by_id($resource->vhostid);
            // get the kvm resource
            $image = new image();
            $image->get_instance_by_id($appliance->imageid);
            $storage = new storage();
            $storage->get_instance_by_id($image->storageid);
            $kvm_resource = new resource();
            $kvm_resource->get_instance_by_id($storage->resource_id);
            if ($kvm_host_resource->id != $kvm_resource->id) {
                $event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "Appliance {$appliance_id} image is not available on this kvm host. Assuming SAN-Backend", "", "", 0, 0, $appliance_id);
            }
            $kvm_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/kvm/bin/openqrm-kvm-vm start_by_mac -m " . $resource->mac . " -d " . $image->rootdevice . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password;
            $kvm_host_resource->send_command($kvm_host_resource->ip, $kvm_command);
            break;
        case "stop":
            // send command to stop the vm and deassign image
            // NOTICE : please enable this hook only if you are using the ip-mgmt plugin with vlans
            // check if resource type -> kvm-vm-net
            //			$virtualization = new virtualization();
            //			$virtualization->get_instance_by_type("kvm-vm-net");
            //			$kvm_host_resource = new resource();
            //			$kvm_host_resource->get_instance_by_id($resource->vhostid);
            //			if ($resource->vtype != $virtualization->id) {
            //				$kvm_command="$OPENQRM_SERVER_BASE_DIR/openqrm/plugins/kvm/bin/openqrm-kvm reset_vlans_by_mac -b stop -m $resource->mac";
            //				$kvm_host_resource->send_command($kvm_host_resource->ip, $kvm_command);
            //				return;
            //			}
            // check resource type -> kvm-vm-local
            $virtualization = new virtualization();
            $virtualization->get_instance_by_type("kvm-vm-local");
            if ($resource->vtype != $virtualization->id) {
                $event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "{$appliance_id} is not from type kvm-vm, skipping .. {$appliance_name}/{$appliance_ip}", "", "", 0, 0, $appliance_id);
                return;
            }
            // check image is on the same storage server
            // get the kvm host resource
            $kvm_host_resource = new resource();
            $kvm_host_resource->get_instance_by_id($resource->vhostid);
            // get the kvm resource
            $image = new image();
            $image->get_instance_by_id($appliance->imageid);
            $storage = new storage();
            $storage->get_instance_by_id($image->storageid);
            $kvm_resource = new resource();
            $kvm_resource->get_instance_by_id($storage->resource_id);
            if ($kvm_host_resource->id != $kvm_resource->id) {
                $event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "Appliance {$appliance_id} image is not available on this kvm host. Assuming SAN-Backend", "", "", 0, 0, $appliance_id);
            }
            $kvm_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/kvm/bin/openqrm-kvm-vm restart_by_mac -m " . $resource->mac . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " --openqrm-cmd-mode background";
            $kvm_host_resource->send_command($kvm_host_resource->ip, $kvm_command);
            break;
        case "update":
            // check if the appliance was set to a kvm Host, if yes, auto-create the storage objects
//.........这里部分代码省略.........
开发者ID:kelubo,项目名称:OpenQRM,代码行数:101,代码来源:openqrm-kvm-appliance-hook.php

示例11: storage_auth_function

function storage_auth_function($cmd, $appliance_id)
{
    global $event;
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $IMAGE_AUTHENTICATION_TABLE;
    global $openqrm_server;
    global $RootDir;
    $appliance = new appliance();
    $appliance->get_instance_by_id($appliance_id);
    $image = new image();
    $image->get_instance_by_id($appliance->imageid);
    $image_name = $image->name;
    $image_rootdevice = $image->rootdevice;
    $storage = new storage();
    $storage->get_instance_by_id($image->storageid);
    $storage_resource = new resource();
    $storage_resource->get_instance_by_id($storage->resource_id);
    $storage_ip = $storage_resource->ip;
    $deployment = new deployment();
    $deployment->get_instance_by_type($image->type);
    $deployment_type = $deployment->type;
    $deployment_plugin_name = $deployment->storagetype;
    $resource = new resource();
    $resource->get_instance_by_id($appliance->resources);
    $resource_mac = $resource->mac;
    $resource_ip = $resource->ip;
    $vm_host_resource = new resource();
    $vm_host_resource->get_instance_by_id($resource->vhostid);
    switch ($cmd) {
        case "start":
            // authenticate the rootfs / needs openqrm user + pass
            $openqrm_admin_user = new user("openqrm");
            $openqrm_admin_user->set_user();
            // generate a password for the image
            $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-lvm-deployment-auth-hook.php", "Authenticating " . $image_name . " / " . $image_rootdevice . " to resource " . $resource_mac . ".", "", "", 0, 0, $appliance_id);
            $auth_start_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/" . $deployment_plugin_name . "/bin/openqrm-" . $deployment_plugin_name . " auth -n " . $image_name . " -r " . $image_rootdevice . " -i " . $image_name . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " -t " . $deployment->type . " --openqrm-cmd-mode background";
            $resource->send_command($storage_resource->ip, $auth_start_cmd);
            break;
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:42,代码来源:openqrm-kvm-gluster-deployment-auth-hook.php

示例12: storage_auth_function

function storage_auth_function($cmd, $appliance_id)
{
    global $event;
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $IMAGE_AUTHENTICATION_TABLE;
    global $openqrm_server;
    $appliance = new appliance();
    $appliance->get_instance_by_id($appliance_id);
    $image = new image();
    $image->get_instance_by_id($appliance->imageid);
    $image_name = $image->name;
    $image_rootdevice = $image->rootdevice;
    $storage = new storage();
    $storage->get_instance_by_id($image->storageid);
    $storage_resource = new resource();
    $storage_resource->get_instance_by_id($storage->resource_id);
    $storage_ip = $storage_resource->ip;
    $deployment = new deployment();
    $deployment->get_instance_by_type($image->type);
    $deployment_type = $deployment->type;
    $deployment_plugin_name = $deployment->storagetype;
    $resource = new resource();
    $resource->get_instance_by_id($appliance->resources);
    $resource_mac = $resource->mac;
    $resource_ip = $resource->ip;
    switch ($cmd) {
        case "start":
            // authenticate the rootfs / needs openqrm user + pass
            $openqrm_admin_user = new user("openqrm");
            $openqrm_admin_user->set_user();
            // generate a password for the image
            $image_password = $image->generatePassword(12);
            $image_deployment_parameter = $image->deployment_parameter;
            $image->set_deployment_parameters("IMAGE_ISCSI_AUTH", $image_password);
            $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-iscsi-deployment-auth-hook.php", "Authenticating {$image_name} / {$image_rootdevice} to resource {$resource_mac} with password {$image_password}", "", "", 0, 0, $appliance_id);
            $auth_start_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/" . $deployment_plugin_name . "/bin/openqrm-" . $deployment_plugin_name . " auth -n " . $image_name . " -r " . $image_rootdevice . " -i " . $image_password . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " --openqrm-cmd-mode background";
            $resource->send_command($storage_ip, $auth_start_cmd);
            // authenticate the install-from-nfs export
            $run_disable_deployment_export = 0;
            $install_from_nfs_param = trim($image->get_deployment_parameter("IMAGE_INSTALL_FROM_NFS"));
            if (strlen($install_from_nfs_param)) {
                // storage -> resource -> auth
                $ip_storage_id = $deployment->parse_deployment_parameter("id", $install_from_nfs_param);
                $ip_storage_ip = $deployment->parse_deployment_parameter("ip", $install_from_nfs_param);
                $ip_image_rootdevice = $deployment->parse_deployment_parameter("path", $install_from_nfs_param);
                $ip_storage = new storage();
                $ip_storage->get_instance_by_id($ip_storage_id);
                $ip_storage_resource = new resource();
                $ip_storage_resource->get_instance_by_id($ip_storage->resource_id);
                $op_storage_ip = $ip_storage_resource->ip;
                $ip_deployment = new deployment();
                $ip_deployment->get_instance_by_id($ip_storage->type);
                $ip_deployment_type = $ip_deployment->type;
                $ip_deployment_plugin_name = $ip_deployment->storagetype;
                $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-iscsi-deployment-auth-hook.php", "Install-from-NFS: Authenticating {$resource_ip} on storage id {$ip_storage_id}:{$ip_storage_ip}:{$ip_image_rootdevice}", "", "", 0, 0, $appliance_id);
                $auth_install_from_nfs_start_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/" . $ip_deployment_plugin_name . "/bin/openqrm-" . $ip_deployment_plugin_name . " auth -r " . $ip_image_rootdevice . " -i " . $resource_ip . " -t " . $ip_deployment_type . " --openqrm-cmd-mode background";
                $resource->send_command($ip_storage_ip, $auth_install_from_nfs_start_cmd);
                $run_disable_deployment_export = 1;
            }
            // authenticate the transfer-to-nfs export
            $transfer_from_nfs_param = trim($image->get_deployment_parameter("IMAGE_TRANSFER_TO_NFS"));
            if (strlen($transfer_from_nfs_param)) {
                // storage -> resource -> auth
                $tp_storage_id = $deployment->parse_deployment_parameter("id", $transfer_from_nfs_param);
                $tp_storage_ip = $deployment->parse_deployment_parameter("ip", $transfer_from_nfs_param);
                $tp_image_rootdevice = $deployment->parse_deployment_parameter("path", $transfer_from_nfs_param);
                $tp_storage = new storage();
                $tp_storage->get_instance_by_id($tp_storage_id);
                $tp_storage_resource = new resource();
                $tp_storage_resource->get_instance_by_id($tp_storage->resource_id);
                $op_storage_ip = $tp_storage_resource->ip;
                $tp_deployment = new deployment();
                $tp_deployment->get_instance_by_id($tp_storage->type);
                $tp_deployment_type = $tp_deployment->type;
                $tp_deployment_plugin_name = $tp_deployment->storagetype;
                $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-iscsi-deployment-auth-hook.php", "Transfer-to-NFS: Authenticating {$resource_ip} on storage id {$tp_storage_id}:{$tp_storage_ip}:{$tp_image_rootdevice}", "", "", 0, 0, $appliance_id);
                $auth_install_from_nfs_start_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/" . $tp_deployment_plugin_name . "/bin/openqrm-" . $tp_deployment_plugin_name . " auth -r " . $tp_image_rootdevice . " -i " . $resource_ip . " -t " . $tp_deployment_type . " --openqrm-cmd-mode background";
                $resource->send_command($tp_storage_ip, $auth_install_from_nfs_start_cmd);
                $run_disable_deployment_export = 1;
            }
            // do we need to disable the install-from/transfer-to-nfs exports ?
            if ($run_disable_deployment_export == 1) {
                $image_authentication = new image_authentication();
                $ia_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
                $image_auth_ar = array('ia_id' => $ia_id, 'ia_image_id' => $appliance->imageid, 'ia_resource_id' => $appliance->resources, 'ia_auth_type' => 1);
                $image_authentication->add($image_auth_ar);
                $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-iscsi-deployment-auth-hook.php", "Registered image {$appliance->imageid} for de-authentication the deployment exports when resource {$appliance->resources} is fully up.", "", "", 0, 0, $appliance_id);
            }
            break;
        case "stop":
            $image_authentication = new image_authentication();
            $ia_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
            $image_auth_ar = array('ia_id' => $ia_id, 'ia_image_id' => $appliance->imageid, 'ia_resource_id' => $appliance->resources, 'ia_auth_type' => 0);
            $image_authentication->add($image_auth_ar);
            $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-iscsi-deployment-auth-hook.php", "Registered image {$appliance->imageid} for de-authentication the root-fs exports when resource {$appliance->resources} is idle again.", "", "", 0, 0, $appliance_id);
            break;
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:100,代码来源:openqrm-iscsi-deployment-auth-hook.php

示例13: create_private_kvm_bf_deployment

function create_private_kvm_bf_deployment($cloud_image_id, $private_disk, $private_image_name)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $RESOURCE_INFO_TABLE;
    global $event;
    $cloudimage = new cloudimage();
    $cloudimage->get_instance_by_id($cloud_image_id);
    $event->log("create_private_kvm_bf_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-bf-deployment-cloud-hook.php", "Creating private image " . $cloudimage->image_id . " on storage.", "", "", 0, 0, 0);
    // get image
    $image = new image();
    $image->get_instance_by_id($cloudimage->image_id);
    $image_id = $image->id;
    $image_name = $image->name;
    $image_type = $image->type;
    $image_version = $image->version;
    $image_rootdevice = $image->rootdevice;
    $image_rootfstype = $image->rootfstype;
    $imageid = $image->storageid;
    $image_isshared = $image->isshared;
    $image_comment = $image->comment;
    $image_capabilities = $image->capabilities;
    $image_deployment_parameter = $image->deployment_parameter;
    // get image storage
    $storage = new storage();
    $storage->get_instance_by_id($imageid);
    $storage_resource_id = $storage->resource_id;
    // get deployment type
    $deployment = new deployment();
    $deployment->get_instance_by_id($storage->type);
    // get storage resource
    $resource = new resource();
    $resource->get_instance_by_id($storage_resource_id);
    $resource_id = $resource->id;
    $resource_ip = $resource->ip;
    // create an admin user to post when cloning has finished
    $openqrm_admin_user = new user("openqrm");
    $openqrm_admin_user->set_user();
    // parse the identifiers
    // origin image volume name
    $origin_volume_name = basename($image_rootdevice);
    // location of the volume (path)
    $image_location_name = dirname($image_rootdevice);
    // For kvm vms we assume that the image is located on the vm-host
    // so we send the auth command to the vm-host instead of the image storage.
    // This enables using a NAS/Glusterfs backend with all volumes accessible for all hosts
    //
    // Still we need to send the remove command to the storage resource since the
    // create-phase automatically adapted the image->storageid, we cannot use the vm-resource here
    // because cloudimage->resource_id will be set to -1 when the cloudapp is in paused/resize/private state
    //
    if ($cloudimage->resource_id > 0) {
        // try to get the vm resource
        $vm_resource = new resource();
        $vm_resource->get_instance_by_id($cloudimage->resource_id);
        // get the lxc host
        $vm_host_resource = new resource();
        $vm_host_resource->get_instance_by_id($vm_resource->vhostid);
        // san backend ?
        if ($vm_host_resource->id != $resource->id) {
            $event->log("create_private_kvm_bf_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-bf-deployment-cloud-hook.php", "Image " . $image_id . " IS NOT available on this kvm host, " . $resource->id . " not equal " . $vm_host_resource->id . " !! Assuming SAN Backend", "", "", 0, 0, 0);
        } else {
            $event->log("create_private_kvm_bf_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-bf-deployment-cloud-hook.php", "Image " . $image_id . " IS available on this kvm host, " . $resource->id . " equal " . $vm_host_resource->id . ".", "", "", 0, 0, 0);
        }
    }
    $image_resize_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/kvm/bin/openqrm-kvm clone -n " . $origin_volume_name . " -s " . $private_image_name . " -v " . $image_location_name . " -m " . $private_disk . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " -t " . $deployment->type . " --openqrm-cmd-mode background";
    $event->log("create_private_kvm_bf_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-bf-deployment-cloud-hook.php", "Running : {$image_resize_cmd}", "", "", 0, 0, 0);
    $resource->send_command($resource_ip, $image_resize_cmd);
    // set the storage specific image root_device parameter
    $new_rootdevice = str_replace($origin_volume_name, $private_image_name, $image->rootdevice);
    return $new_rootdevice;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:73,代码来源:openqrm-kvm-bf-deployment-cloud-hook.php

示例14: content

/*
    openQRM Enterprise developed by openQRM Enterprise GmbH.

    All source code and content (c) Copyright 2014, openQRM Enterprise GmbH unless specifically noted otherwise.

    This source code is released under the GNU General Public License version 2, unless otherwise agreed with openQRM Enterprise GmbH.
    The latest version of this license can be found here: src/doc/LICENSE.txt

    By using this software, you acknowledge having read this license and agree to be bound thereby.

                http://openqrm-enterprise.com

    Copyright 2014, openQRM Enterprise GmbH <info@openqrm-enterprise.com>
*/
$RootDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/';
require_once $RootDir . "/include/user.inc.php";
require_once $RootDir . "/class/openqrm.class.php";
require_once $RootDir . "/plugins/hybrid-cloud/class/hybrid-cloud.controller.class.php";
require_once $RootDir . "/class/htmlobjects/htmlobject.class.php";
$html = new htmlobject($RootDir . "/class/htmlobjects/");
$response = $html->response();
require_once $RootDir . '/class/file.handler.class.php';
$file = new file_handler();
require_once $RootDir . '/class/user.class.php';
$user = new user($_SERVER['PHP_AUTH_USER']);
$user->set_user();
$openqrm = new openqrm($file, $user);
$openqrm->init();
$controller = new hybrid_cloud_controller($openqrm, $response);
$controller->api();
开发者ID:kelubo,项目名称:OpenQRM,代码行数:30,代码来源:api.php

示例15: create_private_template_deployment

function create_private_template_deployment($cloud_image_id, $private_disk, $private_image_name)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $RESOURCE_INFO_TABLE;
    global $event;
    $event->log("create_private_template_deployment", $_SERVER['REQUEST_TIME'], 5, "template_deployment-cloud-hook", "Creating private image on storage", "", "", 0, 0, 0);
    // we got the cloudimage id here, get the image out of it
    $cloudimage = new cloudimage();
    $cloudimage->get_instance_by_id($cloud_image_id);
    // get image
    $image = new image();
    $image->get_instance_by_id($cloudimage->image_id);
    $image_id = $image->id;
    $image_name = $image->name;
    $image_type = $image->type;
    $image_version = $image->version;
    $image_rootdevice = $image->rootdevice;
    $image_rootfstype = $image->rootfstype;
    $image_storageid = $image->storageid;
    $image_isshared = $image->isshared;
    $image_comment = $image->comment;
    $image_capabilities = $image->capabilities;
    $image_deployment_parameter = $image->deployment_parameter;
    // get image storage
    $storage = new storage();
    $storage->get_instance_by_id($image_storageid);
    $storage_resource_id = $storage->resource_id;
    // get storage resource
    $resource = new resource();
    $resource->get_instance_by_id($storage_resource_id);
    $resource_id = $resource->id;
    $resource_ip = $resource->ip;
    // create an admin user to post when cloning has finished
    $openqrm_admin_user = new user("openqrm");
    $openqrm_admin_user->set_user();
    // parse the volume group info in the identifier
    $volume_group_location = dirname($image_rootdevice);
    $volume_group = basename($volume_group_location);
    $image_location_name = basename($image_rootdevice);
    // For template vms we assume that the image is located on the vm-host
    // so we send the auth command to the vm-host instead of the image storage.
    // This enables using a SAN backend with dedicated volumes per vm-host which all
    // contain all "golden-images" which are used for snapshotting.
    // We do this to overcome the current lvm limitation of not supporting cluster-wide snapshots
    //
    // Still we need to send the remove command to the storage resource since the
    // create-phase automatically adapted the image->storageid, we cannot use the vm-resource here
    // because cloudimage->resource_id will be set to -1 when the cloudapp is in paused/resize/private state
    //
    if ($cloudimage->resource_id > 0) {
        $vm_resource = new resource();
        $vm_resource->get_instance_by_id($cloudimage->resource_id);
        // get the openvz host
        $vm_host_resource = new resource();
        $vm_host_resource->get_instance_by_id($vm_resource->vhostid);
        // san backend ?
        if ($vm_host_resource->id != $resource->id) {
            $event->log("create_private_template_deployment", $_SERVER['REQUEST_TIME'], 5, "template_deployment-cloud-hook", "Image {$image_id} IS NOT available on this template host, {$resource->id} not equal {$vm_host_resource->id} !! Assuming SAN Backend", "", "", 0, 0, $appliance_id);
        } else {
            $event->log("create_private_template_deployment", $_SERVER['REQUEST_TIME'], 5, "template_deployment-cloud-hook", "Image {$image_id} IS available on this template host, {$resource->id} equal {$vm_host_resource->id}", "", "", 0, 0, $appliance_id);
        }
    }
    $image_resize_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/template/bin/openqrm-template clone -n " . $image_location_name . " -s " . $private_image_name . " -v " . $volume_group . " -m " . $private_disk . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " --openqrm-cmd-mode background";
    $event->log("create_private_template_deployment", $_SERVER['REQUEST_TIME'], 5, "template_deployment-cloud-hook", "Running : {$image_resize_cmd}", "", "", 0, 0, 0);
    $resource->send_command($resource_ip, $image_resize_cmd);
    // set the storage specific image root_device parameter
    $new_rootdevice = str_replace($image_location_name, $private_image_name, $image->rootdevice);
    return $new_rootdevice;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:71,代码来源:openqrm-template-deployment-cloud-hook.php


注:本文中的user::set_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。