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


PHP image::set_root_password方法代码示例

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


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

示例1: openqrm_cloud_monitor


//.........这里部分代码省略.........
                            $ip_mgmt_id = $next_free_ip_mgmt_id;
                            // here we have to update the cr with the new ip-mgmt-id
                            $new_cr_ip_mgmt_str = str_replace($nic_id . ":" . $orginal_ip_mgmt_id, $nic_id . ":" . $ip_mgmt_id, $cr->ip_mgmt);
                            $new_cr_ip_mgmt_fields = array();
                            $new_cr_ip_mgmt_fields["cr_ip_mgmt"] = $new_cr_ip_mgmt_str;
                            $cr->update($cr->id, $new_cr_ip_mgmt_fields);
                            $cr->get_instance_by_id($cr->id);
                        }
                    }
                    // here we have a valid ip-mgmt opbject to update
                    $ip_mgmt_fields = array();
                    $ip_mgmt_fields["ip_mgmt_appliance_id"] = $appliance_id;
                    $ip_mgmt_fields["ip_mgmt_nic_id"] = $nic_id;
                    $ip_mgmt_assign->update_ip($ip_mgmt_id, $ip_mgmt_fields);
                    // set resource_external_ip
                    if ($ip_mgmt_assign_loop == 1) {
                        $ip_mgmt_assign_arr = $ip_mgmt_assign->get_config_by_id($ip_mgmt_id_final);
                        $resource_external_ip = $ip_mgmt_assign_arr[0]['ip_mgmt_address'];
                    }
                    $ip_mgmt_assign_loop++;
                }
            }
        }
        // #####################################################################################
        // assign kernel
        $openqrm_server->send_command("openqrm_assign_kernel {$resource->id} {$resource->mac} {$kernel->name}");
        //refresh the object before in case of clone-on-deploy
        $appliance->get_instance_by_id($appliance_id);
        // hybrid-cloud deployment needs image password + application classes set before appliance start
        // get the password to send to the user from the request
        $cr->get_instance_by_id($cr_id);
        $appliance_password = $cr->image_password;
        $image = new image();
        $image->set_root_password($appliance->imageid, $appliance_password);
        $image->get_instance_by_id($appliance->imageid);
        $appliance_login_user = "root";
        if ($image->version == 'Windows') {
            $appliance_login_user = "Administrator";
        }
        // add the user + image_password to the request
        $cr_update_fields = array();
        $cr_update_fields['cr_image_password'] = $appliance_login_user . ":" . $appliance_password . ":" . $resource_external_ip;
        $cr->update($cr_id, $cr_update_fields);
        // ################################## apply application groups ###############################
        // check if application is enabled
        $application_conf = new cloudconfig();
        $show_application_groups = $application_conf->get_value(11);
        // show_puppet_groups
        if (!strcmp($show_application_groups, "true")) {
            // check if we have a application config in the request
            $application_appliance = $appliance->name;
            if (strlen($cr->puppet_groups)) {
                $application_groups_str = $cr->puppet_groups;
                $application_appliance = $appliance->name;
                $application_debug = "Applying {$application_groups_str} to appliance {$application_appliance}";
                $event->log("cloud", $_SERVER['REQUEST_TIME'], 5, "cloud-monitor", $application_debug, "", "", 0, 0, 0);
                $application_group_array = explode(",", $cr->puppet_groups);
                $cloudapplication = new cloudapplication();
                $cloudapplication->set_applications($appliance->name, $application_group_array);
            }
        }
        // update appliance id in request
        $cr->get_instance_by_id($cr->id);
        $cr->setappliance("add", $appliance_id);
        // update request status to starting
        $cr->setstatus($cr_id, "starting");
开发者ID:kelubo,项目名称:OpenQRM,代码行数:67,代码来源:openqrm-cloud-monitor-hook.php

示例2: edit

 function edit()
 {
     $response = $this->get_response();
     $form = $response->form;
     $id = $this->response->html->request()->get('image_id');
     if ($id !== '') {
         // check password
         $pass = $form->get_request('image_password');
         if ($pass !== '' && $pass !== $form->get_request('image_password_2')) {
             $form->set_error('image_password_2', $this->lang['error_password']);
         }
         $image = new image();
         $image->get_instance_by_id($id);
         if (!$form->get_errors() && $this->response->submit()) {
             $image_password = $this->response->html->request()->get('image_password');
             $install_from_local = $this->response->html->request()->get('install_from_local');
             $transfer_to_local = $this->response->html->request()->get('transfer_to_local');
             $install_from_nfs = $this->response->html->request()->get('install_from_nfs');
             $transfer_to_nfs = $this->response->html->request()->get('transfer_to_nfs');
             $install_from_template = $this->response->html->request()->get('install_from_template');
             $image_comment = $this->response->html->request()->get('image_comment');
             $image_version = $this->response->html->request()->get('image_version');
             // update image
             $fields['image_comment'] = $image_comment;
             $fields['image_version'] = $image_version;
             $image->update($id, $fields);
             $image->get_instance_by_id($id);
             # set password if given
             if (strlen($image_password)) {
                 $image->set_root_password($id, $image_password);
             } else {
                 $CMD = "rm -f " . $this->openqrm->get('basedir') . "/web/action/image-auth/iauth." . $id . ".php";
                 exec($CMD);
             }
             // install-from-nfs
             if (strlen($install_from_nfs)) {
                 $install_from_nfs_image = new image();
                 $install_from_nfs_image->get_instance_by_id($install_from_nfs);
                 $install_from_nfs_storage = new storage();
                 $install_from_nfs_storage->get_instance_by_id($install_from_nfs_image->storageid);
                 $install_from_nfs_storage_resource = new resource();
                 $install_from_nfs_storage_resource->get_instance_by_id($install_from_nfs_storage->resource_id);
                 $install_from_nfs_storage_ip = $install_from_nfs_storage_resource->ip;
                 $install_from_nfs_storage_path = $install_from_nfs_image->rootdevice;
                 $install_from_nfs_path = $install_from_nfs_image->storageid . ":" . $install_from_nfs_storage_ip . ":" . $install_from_nfs_storage_path;
                 $image->set_deployment_parameters("IMAGE_INSTALL_FROM_NFS", $install_from_nfs_path);
             } else {
                 $image->set_deployment_parameters("IMAGE_INSTALL_FROM_NFS", "");
             }
             // transfer-to-nfs, we have to refresh the image object here
             $image->get_instance_by_id($id);
             if (strlen($transfer_to_nfs)) {
                 $transfer_to_nfs_image = new image();
                 $transfer_to_nfs_image->get_instance_by_id($transfer_to_nfs);
                 $transfer_to_nfs_storage = new storage();
                 $transfer_to_nfs_storage->get_instance_by_id($transfer_to_nfs_image->storageid);
                 $transfer_to_nfs_storage_resource = new resource();
                 $transfer_to_nfs_storage_resource->get_instance_by_id($transfer_to_nfs_storage->resource_id);
                 $transfer_to_nfs_storage_ip = $transfer_to_nfs_storage_resource->ip;
                 $transfer_to_nfs_storage_path = $transfer_to_nfs_image->rootdevice;
                 $transfer_to_nfs_path = $transfer_to_nfs_image->storageid . ":" . $transfer_to_nfs_storage_ip . ":" . $transfer_to_nfs_storage_path;
                 $image->set_deployment_parameters("IMAGE_TRANSFER_TO_NFS", $transfer_to_nfs_path);
             } else {
                 $image->set_deployment_parameters("IMAGE_TRANSFER_TO_NFS", "");
             }
             // install-from-local, we have to refresh the image object again
             $image->get_instance_by_id($id);
             if (strlen($install_from_local)) {
                 $image->set_deployment_parameters("IMAGE_INSTALL_FROM_LOCAL", $install_from_local);
             } else {
                 $image->set_deployment_parameters("IMAGE_INSTALL_FROM_LOCAL", "");
             }
             // transfer-to-local, we have to refresh the image object again
             $image->get_instance_by_id($id);
             if (strlen($transfer_to_local)) {
                 $image->set_deployment_parameters("IMAGE_TRANSFER_TO_LOCAL", $transfer_to_local);
             } else {
                 $image->set_deployment_parameters("IMAGE_TRANSFER_TO_LOCAL", "");
             }
             // reset deployment parameter INSTALL_CONFIG
             $image->set_deployment_parameters("INSTALL_CONFIG", "");
             if (strlen($install_from_template)) {
                 // redirect to install-from-template step1
                 $response->msg = 'install-from-template';
                 $response->install_from_template = $install_from_template;
             } else {
                 $response->msg = sprintf($this->lang['msg'], $image->name);
             }
             $response->image_id = $id;
         }
         $response->name = $image->name;
     } else {
         $response->msg = '';
     }
     return $response;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:96,代码来源:image.edit.class.php


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