audiolize / vagrant-softlayer

This is a Vagrant plugin that adds a SoftLayer provider to Vagrant, allowing Vagrant to control and provision SoftLayer CCI instances.
MIT License
42 stars 15 forks source link

local_disk flag seemingly does nothing #63

Open ghost opened 8 years ago

ghost commented 8 years ago

I think I may have a bug. When setting "local_disk = false" and ordering second & third SAN disks with advertised capacities (1000GB, 75GB, etc) The api reports it cannot find price info for the disks, and provisioning fails.

Maybe I am just misunderstanding this flag? I checked what occurs when setting it to false & a single 100GB disk, and the resulting VSI still shows a local disk type for the primary 100gb.

ghost commented 8 years ago

@ju2wheels Hey Julio, any advice?

poflynn commented 8 years ago

I have seen this many times too but it's not consistent. I always assume it's some SoftLayer flakiness. I was getting it a lot last week and had to give up. I find the smaller the drive you request the less likely you are to get this error. If you log a bug with SL they won't do anything unless you give them the full API calls/debug trace.

ju2wheels commented 8 years ago

This would be a bug in the SoftLayer API upstream. We arent querying for prices directly because the advanced ordering for virtual servers hasnt been implemented and we are doing simplified ordering through SoftLayer_Virtual_Gust::createobject. With this we only tell it whether the disk should be local vs SAN and then the sizes of the disks.

One thing to note is that the disks/sizes available may vary (by DC I think IIRC and sometimes machine type) so you have to use the sl-cli tool to look at what is available as well.

If you still hit this bug, please post the error message you get but the only thing I can do is help push the bug upstream most likely.

@SLsthompson, @underscorephil

underscorephil commented 8 years ago

I will test to see if we can recreate.

allmightyspiff commented 8 years ago

So, theres a few tricky things with ordering through createObject.

The FIRST disk can only be 25G or 100G. For both local and SAN.

http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getCreateObjectOptions/

in the section for disks, you'll see those are the only ones with "device = 0"'

Second, make sure you are using the literal FALSE. not "false" or anything else like that. That value is getting parsed by PHP, so you'll run into its boolean problems if you don't specify the correct FALSE. http://php.net/manual/en/language.types.boolean.php

If that doesn't fix your problem let me know.

If this helps, heres how you would order a Virtual_Guest with 2 SAN disks.


        client = SoftLayer.Client()
        guest = {}
        guest['startCpus'] = 1
        guest['maxMemory'] = 1024
        guest['localDiskFlag'] = False
        guest['hostname'] = 'partition-test'
        guest['domain'] = 'softlayer.com'
        guest['hourlyBillingFlag'] = True
        guest['datacenter'] = {}
        guest['datacenter']['name'] = 'sjc01'
        guest['operatingSystemReferenceCode'] = 'UBUNTU_LATEST'
        guest['blockDevices'] = [{
            'device' : 0, 
            'diskImage' : { 'capacity' : 100}
        },{
            'device' : 2, 
            'diskImage' : { 'capacity' : 75}
        }] 
        result = client['SoftLayer_Virtual_Guest'].createObject(guest)
ghost commented 8 years ago

Works:

+ params='{
    "hostname": "ordertest2",
    "domain": "test.com",
    "datacenter" : { "name" : "dal06" },
    "startCpus": 2,
    "maxMemory": 2048,
    "hourlyBillingFlag": true,
    "localDiskFlag": false,
    "blockDevices": [{"device": "0", "diskImage": {"capacity": 100}},
                     {"device": "2", "diskImage": {"capacity": 1000}},
                     {"device": "3", "diskImage": {"capacity": 40}}],
    "networkComponents": [{"maxSpeed": 1000}],
    "operatingSystemReferenceCode": "CENTOS_6_64" }'
+ echo '{"parameters":[{' '"hostname":' '"ordertest2",' '"domain":' '"test.com",' '"datacenter"' : '{' '"name"' : '"sjc01"' '},' '"startCpus":' 2, '"maxMemory":' 2048, '"hourlyBillingFlag":' true, '"localDiskFlag":' false, '"blockDevices":' '[{"device":' '"0",' '"diskImage":' '{"capacity":' '100}},' '{"device":' '"2",' '"diskImage":' '{"capacity":' '1000}},' '{"device":' '"3",' '"diskImage":' '{"capacity":' '40}}],' '"networkComponents":' '[{"maxSpeed":' '1000}],' '"operatingSystemReferenceCode":' '"CENTOS_6_64"' '}]}'
+ curl -X POST -d @- https://OMIT:OMIT@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest.json

resp:

{"accountId":OMIT,"createDate":"OMIT","domain":"test.com","fullyQualifiedDomainName":"ordertest2.test.com","hostname":"ordertest2","id":OMIT,"lastPowerStateId":null,"lastVerifiedDate":null,"maxCpu":2,"maxCpuUnits":"CORE","maxMemory":2048,"metricPollDate":null,"modifyDate":null,"provisionDate":null,"startCpus":2,"statusId":1001,"uuid":"OMIT","globalIdentifier":"OMIT"}

Does not work:

# cat Vagrantfile

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'softlayer'
Vagrant.configure("2") do |config|
  config.vm.provider :softlayer do |sl|
    sl.api_key  = "OMIT"
    sl.username = "OMIT"
    sl.datacenter   = "dal06"
    sl.dedicated = false
    sl.local_disk = false
    sl.disk_capacity = { 0 => 100, 2 => 1000, 3 => 40 }
    sl.domain = "test.com"
    sl.force_private_ip = false
    sl.hostname = "ordertest3"
    sl.hourly_billing = true
    sl.local_disk = true
    sl.max_memory = 2048
    sl.network_speed = 1000
    sl.image_guid = nil
    sl.operating_system = "CENTOS_6_64"
    sl.private_only = false
    sl.ssh_key = "OMIT"
    sl.start_cpus = 2
    sl.provision_timeout = 3600
  end
  config.vm.define 'ordertest3' do |node_config|
    node_config.vm.box = 'softlayer-dummy'
    node_config.vm.hostname = 'ordertest3'
    node_config.nfs.functional = false
    node_config.ssh.username = "root"
    node_config.ssh.private_key_path = "id_rsa"
    node_config.ssh.pty = true
    node_config.vm.synced_folder "synced_folder", "/vagrant", disabled: true
  end
end

vagrant up
Bringing machine '-ordertest3' up with 'softlayer' provider...
==> ordertest3: Creating a new SoftLayer instance...
Vagrant returned an exception while calling the SoftLayer API.

Exception class: XMLRPC::FaultException
Exception message: Unable to find a price for block device 2.