How to get order username and provisionDate for all SoftLayer machines using Ruby?
Please see the following provisioning steps, below is a little flow to consider:
1. Order a Server
Result:
* An orderId is assigned to the server
* The createDate has a new value
* activeTransaction value is = Null
* provisionDate value is = Null
2. The order is approved
Result:
* activeTransaction value is <> Null
* provisionDate value = Null
3. Server is already provisioned
Result:
* activeTransaction value is = Null
* provisionDate value has a New value
* billingItem property has a new value
To see if your machines have still ”activeTransaction”
, please execute:
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Hardware_Server/[server_id]/getActiveTransaction
Method: GET
Now, after reviewing your example response, this server had some problems when completing the provisioning; for that reason this step was completed manually but the provisionDate
was not set for any reason(please open a ticket if you want that the provisionDate can be set) . This is a special case. I can see that another server has a similar behavior. But the other servers that don’t have provisionDate
, have still ”activeTransaction<>null”
(it means that these server are not provisioned yet).
EDIT:
Other property can help you to know that your machine has been already provisioned although other kind of transaction is being executed, is “hardwareStatus”
, it should have “ACTIVE” value.
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Account/getHardware?objectMask=mask[id, hostname, fullyQualifiedDomainName, provisionDate,hardwareStatus]
Method: GET
The response should be something like this:
{
"fullyQualifiedDomainName": "myhostname.softlayer.com"
"hostname": " myhostname"
"id": 1234567
"provisionDate": "2015-06-29T00:21:39-05:00"
"hardwareStatus": {
"id": 5
"status": "ACTIVE"
}
Retrieving user metadata about a provisioned SoftLayer server comes back null
They are missing that data because you did not added.
you can create the user data at moment to order a new server or VSI, you just have to send the data in your order request either using the createObject method or the placeOrder method. see http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject
e.g.
{
"userData": [
{
"value": "someValue"
}
]
}
or you can set it after the server has been provisioned using these methods
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/setUserMetadata
http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/setUserMetadata
Basically the usermetadata are useful if you are going to use a post install script. The usermetadata value is not required to order a new server
take a look this article for examples:
http://sldn.softlayer.com/blog/jarteche/getting-started-user-data-and-post-provisioning-scripts
SoftLayer API: - How to get the ID of a bare metal server on create
you can use the goblal identifier instead the ID in your request
e.g.
Get https://api.softlayer.com/rest/v3.1/SoftLayer_Hardware/$GloblalIdentifier/getObject
Note: replace the $GloblalIdentifier
The reason why the id is not displayed is because the server was not created yet, your order has to be approved and when the provisioning is ended the id will show up, meanwhile you can use the global identifier when the provisioning ends you will be able to see the id
regards
SoftLayer API retrieve total network devices from Hardware
when you call the getHardware method returns all bare metal servers, the reason why you are seeing several "Vyatta" servers is because they are bare metal servers as well,but with a "Vyatta" operating system.
you can use the http://sldn.softlayer.com/reference/services/SoftLayer_Search/advancedSearch method to get and filter your data, that is the method that the portal uses.
here some examples:
List hardwares:
# Get Hardware list using SoftLayer_Search::advancedSearch
#
# Important manual pages:
# see http://sldn.softlayer.com/reference/services/SoftLayer_Search/advancedSearch
#
# license <http://sldn.softlayer.com/article/License>
# author SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'rubygems'
require 'softlayer_api'
# Your SoftLayer API username.
SL_API_USERNAME = 'set me'
# Your SoftLayer API key.
SL_API_KEY = 'set me'
# Softlayer API public endpoint
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3.1/'
softlayer_client = SoftLayer::Client.new(username: SL_API_USERNAME,
api_key: SL_API_KEY,
endpoint_url: API_PUBLIC_ENDPOINT)
search_service = softlayer_client.service_named('SoftLayer_Search')
filter_data = 'networkGatewayMemberFlag:0 _objectType:SoftLayer_Hardware'
begin
# Display Hardware items same as Portal > Device List
result = search_service.advancedSearch(filter_data)
puts 'Process finished successfully'
p result
rescue StandardError => e
raise e
end
List gateway members:
# Get Gateway Member list using SoftLayer_Search::advancedSearch
#
# Important manual pages:
# see http://sldn.softlayer.com/reference/services/SoftLayer_Search/advancedSearch
#
# license <http://sldn.softlayer.com/article/License>
# author SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'rubygems'
require 'softlayer_api'
# Your SoftLayer API username.
SL_API_USERNAME = 'set me'
# Your SoftLayer API key.
SL_API_KEY = 'set me'
# Softlayer API public endpoint
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3.1/'
softlayer_client = SoftLayer::Client.new(username: SL_API_USERNAME,
api_key: SL_API_KEY,
endpoint_url: API_PUBLIC_ENDPOINT)
search_service = softlayer_client.service_named('SoftLayer_Search')
filter_data = 'networkGatewayMemberFlag:1 _objectType:SoftLayer_Hardware'
begin
# Display Gateway Member items same as Portal > Device List
result = search_service.advancedSearch(filter_data)
puts 'Process finished successfully'
p result
rescue StandardError => e
raise e
end
List netscalers:
# Get Netscaler list using SoftLayer_Search::advancedSearch
#
# Important manual pages:
# see http://sldn.softlayer.com/reference/services/SoftLayer_Search/advancedSearch
#
# license <http://sldn.softlayer.com/article/License>
# author SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'rubygems'
require 'softlayer_api'
# Your SoftLayer API username.
SL_API_USERNAME = 'set me'
# Your SoftLayer API key.
SL_API_KEY = 'set me'
# Softlayer API public endpoint
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3.1/'
softlayer_client = SoftLayer::Client.new(username: SL_API_USERNAME,
api_key: SL_API_KEY,
endpoint_url: API_PUBLIC_ENDPOINT)
search_service = softlayer_client.service_named('SoftLayer_Search')
filter_data = '_objectType:SoftLayer_Network_Application_Delivery_Controller'
begin
# Display Netscaler items same as Portal > Device List
result = search_service.advancedSearch(filter_data)
puts 'Process finished successfully'
p result
rescue StandardError => e
raise e
end
List Firewalls:
# Get Firewall list using SoftLayer_Search::advancedSearch
#
# Important manual pages:
# see http://sldn.softlayer.com/reference/services/SoftLayer_Search/advancedSearch
#
# license <http://sldn.softlayer.com/article/License>
# author SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'rubygems'
require 'softlayer_api'
# Your SoftLayer API username.
SL_API_USERNAME = 'set me'
# Your SoftLayer API key.
SL_API_KEY = 'set me'
# Softlayer API public endpoint
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3.1/'
softlayer_client = SoftLayer::Client.new(username: SL_API_USERNAME,
api_key: SL_API_KEY,
endpoint_url: API_PUBLIC_ENDPOINT)
search_service = softlayer_client.service_named('SoftLayer_Search')
filter_data = '_objectType:SoftLayer_Network_Vlan_Firewall'
begin
# Display Firewall items same as Portal > Device List
result = search_service.advancedSearch(filter_data)
puts 'Process finished successfully'
p result
rescue StandardError => e
raise e
end
List all devices:
# Get all items from Device list.
#
# Important manual pages:
#
# see http://sldn.softlayer.com/reference/services/SoftLayer_Search/advancedSearch
# license <http://sldn.softlayer.com/article/License>
# author SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'rubygems'
require 'softlayer_api'
# Your SoftLayer API username.
SL_API_USERNAME = 'set me'
# Your SoftLayer API key.
SL_API_KEY = 'set me'
# Softlayer API public endpoint
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3.1/'
softlayer_client = SoftLayer::Client.new(username: SL_API_USERNAME,
api_key: SL_API_KEY,
endpoint_url: API_PUBLIC_ENDPOINT)
search_service = softlayer_client.service_named('SoftLayer_Search')
# The items with the following Device types should be displayed
# using the below filter:
# Bare Metal Server, Virtual Server, Firewall, Gateway Member, Netscaler,KVM/IP
filter_data = '_objectType:SoftLayer_Hardware,'\
'SoftLayer_Virtual_Guest,SoftLayer_Network_Vlan_Firewall,'\
'SoftLayer_Network_Application_Delivery_Controller '
begin
# Display all items same as Portal > Device List
result = search_service.advancedSearch(filter_data)
puts 'Process finished successfully'
p result
rescue StandardError => e
raise e
end
Multiple lines of text in UILabel
Set the line break mode to word-wrapping and the number of lines to 0
:
// Swift
textLabel.lineBreakMode = .byWordWrapping
textLabel.numberOfLines = 0
// Objective-C
textLabel.lineBreakMode = NSLineBreakByWordWrapping;
textLabel.numberOfLines = 0;
// C# (Xamarin.iOS)
textLabel.LineBreakMode = UILineBreakMode.WordWrap;
textLabel.Lines = 0;
Restored old answer (for reference and devs willing to support iOS below 6.0):
textLabel.lineBreakMode = UILineBreakModeWordWrap;
textLabel.numberOfLines = 0;
On the side: both enum values yield to 0
anyway.
Related Topics
How to Find the Average of 3 Date in Ruby on Rails or Ruby
Installed Memcached via Homebrew, How to Start and Stop Server
How to Return the Number of Devise Users Currently Logged In
Differencebetween Def Func(Var) and Def Func=(Var)
When Passing a Ruby Array as an Argument, Why Does '<<' Append While '+=' Does Not
Perfect Way to Write a Gsub for a Regex Match
Accessing Values Through Ajax Calls and Partials in Rails
How to Properly Install Bootsnap on Windows
How to Run Code After Ruby Kernel.Exec
How to Set an Expectancy on Should_Receive and Have It Execute the Original Code
How to Use Local or Instance Variable in Ruby Code in Coffeescript in Haml Template