当我运行以下代码时,出现错误 SoftLayer_Exception_InvalidValue:为“blockDevices.device”提供的值无效。必须为所有 block 设备提供设备号。 (HTTP 200)
我初始化 block 设备的方式有什么问题?
我看到了 Virtual_Disk_Image 类型的字段 Id 和 Uuid,但没有数字。从描述来看,这些值听起来像是在创建后设置的。
https://github.com/softlayer/softlayer-go/blob/master/datatypes/virtual.go#L91
func verifyOrderTest(c Creds) (string, error) {
sess := session.New(*c.user, *c.key)
service := services.GetVirtualGuestService(sess)
guestTpl := getGuestTplTest()
guest, err := service.GenerateOrderTemplate(&guestTpl)
if err != nil {
return "", err
}
productOrderInstance := services.GetProductOrderService(sess)
_, err = productOrderInstance.VerifyOrder(guest)
if err != nil {
return "", err
}
return "success", nil
}
func getGuestTplTest() (datatypes.Virtual_Guest) {
blockDevices := make([]datatypes.Virtual_Guest_Block_Device, 2)
blockDevices[0] = datatypes.Virtual_Guest_Block_Device{
DiskImage: &datatypes.Virtual_Disk_Image{
Capacity: sl.Int(100),
LocalDiskFlag: sl.Bool(true),
},
}
blockDevices[1] = datatypes.Virtual_Guest_Block_Device{
DiskImage: &datatypes.Virtual_Disk_Image{
Capacity: sl.Int(100),
LocalDiskFlag: sl.Bool(true),
},
}
guestTpl := datatypes.Virtual_Guest{
BandwidthAllocation: sl.Float(10),
BlockDevices: blockDevices,
Datacenter: &datatypes.Location{Name: sl.String("dal13")},
DedicatedAccountHostOnlyFlag: sl.Bool(true),
Domain: sl.String("website.com"),
Hostname: sl.String("hostname"),
OperatingSystemReferenceCode: sl.String("UBUNTU_16_64"),
LocalDiskFlag: sl.Bool(true),
MaxMemory: sl.Int(32768),
StartCpus: sl.Int(16),
}
return guestTpl
}
最佳答案
您只需为每个 Virtual_Guest_Block_Device 对象添加属性“Device”,并且“LocalDiskFlag”属性必须添加一次,而不是为每个 Virtual_Guest_Block_Device 添加一次。
与本例相同:
blockDevices := make([]datatypes.Virtual_Guest_Block_Device, 2)
blockDevices[0] = datatypes.Virtual_Guest_Block_Device{
Device: sl.String("0"),
DiskImage: &datatypes.Virtual_Disk_Image{
Capacity: sl.Int(100),
},
}
blockDevices[1] = datatypes.Virtual_Guest_Block_Device{
Device: sl.String("2"),
DiskImage: &datatypes.Virtual_Disk_Image{
Capacity: sl.Int(100),
},
}
之后,您必须将符号 ¨&¨ 添加到方法中的参数 ¨ guest ¨ 没有这个的 VerifyOrder 代码将不会运行。
result, err := productOrderInstance.VerifyOrder(&guest)
关于go - 尝试验证虚拟机订单时收到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50123606/
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..
我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我希望我的UserPrice模型的属性在它们为空或不验证数值时默认为0。这些属性是tax_rate、shipping_cost和price。classCreateUserPrices8,:scale=>2t.decimal:tax_rate,:precision=>8,:scale=>2t.decimal:shipping_cost,:precision=>8,:scale=>2endendend起初,我将所有3列的:default=>0放在表格中,但我不想要这样,因为它已经填充了字段,我想使用占位符。这是我的UserPrice模型:classUserPrice回答before_val
我有一个表单,其中有很多字段取自数组(而不是模型或对象)。我如何验证这些字段的存在?solve_problem_pathdo|f|%>... 最佳答案 创建一个简单的类来包装请求参数并使用ActiveModel::Validations。#definedsomewhere,atthesimplest:require'ostruct'classSolvetrue#youcouldevencheckthesolutionwithavalidatorvalidatedoerrors.add(:base,"WRONG!!!")unlesss
我有一些非常大的模型,我必须将它们迁移到最新版本的Rails。这些模型有相当多的验证(User有大约50个验证)。是否可以将所有这些验证移动到另一个文件中?说app/models/validations/user_validations.rb。如果可以,有人可以提供示例吗? 最佳答案 您可以为此使用关注点:#app/models/validations/user_validations.rbrequire'active_support/concern'moduleUserValidationsextendActiveSupport:
当我的预订模型通过rake任务在状态机上转换时,我试图找出如何跳过对ActiveRecord对象的特定实例的验证。我想在reservation.close时跳过所有验证!叫做。希望调用reservation.close!(:validate=>false)之类的东西。仅供引用,我们正在使用https://github.com/pluginaweek/state_machine用于状态机。这是我的预订模型的示例。classReservation["requested","negotiating","approved"])}state_machine:initial=>'requested
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我有一个服务模型/表及其注册表。在表单中,我几乎拥有服务的所有字段,但我想在验证服务对象之前自动设置其中一些值。示例:--服务Controller#创建Action:defcreate@service=Service.new@service_form=ServiceFormObject.new(@service)@service_form.validate(params[:service_form_object])and@service_form.saverespond_with(@service_form,location:admin_services_path)end在验证@ser