I'm using this code repo for registering newly provisioned vm's with infoblox providing the next available ip address.
What i want to achieve now, is to get also dynamically the domain-name of the used infoblox network.
I tried to copy list_infoblox_networks.rb into a modified "list_infoblox_domain.rb" with the following code below:
if networks_array.blank?
# get an array of networks from infoblox
network_search_filter = "network?network_view=#{network_view}"
# specify fields to return in payload
return_fields = "&_return_fields=network_view,network,netmask,ipv4addr,extattrs,comment,options"
networks_array = call_infoblox(:get, "#{network_search_filter}" + "#{return_fields}")
$evm.log(:info, "Inspecting networks_array: #{networks_array.inspect}")
networks_array.each do |net|
comment = "#{net['comment']}#" if net['comment']
display_string = "#{comment}#{net['options'][0]},#{net['network_view']}"
dialog_hash[net['options'][0]] = display_string
end
end
The expected result should return:
testlab.local from network 192.168.254.0/24, actual result displays the whole hash with all options. dropdown of available infoblox domains
A call to infoblox gives me the following hash back:
<AEMethod list_infoblox_domain> Inspecting networks_array: [{"_ref"=>"network/ZG5zLm5ldHdvcmskMTAuMC4yMC4wLzI0LzA:10.0.20.0/24/default", "comment"=>"test-netz", "extattrs"=>{}, "ipv4addr"=>"10.0.20.0", "netmask"=>24, "network"=>"10.0.20.0/24", "network_view"=>"default", "options"=>[{"name"=>"dhcp-lease-time", "num"=>51, "use_option"=>false, "value"=>"43200", "vendor_class"=>"DHCP"}]}, {"_ref"=>"network/ZG5zLm5ldHdvcmskMTAuMC4zMC4wLzI0LzA:10.0.30.0/24/default", "comment"=>"zweites test-netz", "extattrs"=>{}, "ipv4addr"=>"10.0.30.0", "netmask"=>24, "network"=>"10.0.30.0/24", "network_view"=>"default", "options"=>[{"name"=>"dhcp-lease-time", "num"=>51, "use_option"=>false, "value"=>"43200", "vendor_class"=>"DHCP"}]}, {"_ref"=>"network/ZG5zLm5ldHdvcmskMTkyLjE2OC4yNTQuMC8yNC8w:192.168.254.0/24/default", "comment"=>"prod netz", "extattrs"=>{}, "ipv4addr"=>"192.168.254.0", "netmask"=>24, "network"=>"192.168.254.0/24", "network_view"=>"default", "options"=>[{"name"=>"broadcast-address", "num"=>28, "use_option"=>true, "value"=>"192.168.254.255", "vendor_class"=>"DHCP"}, {"name"=>"dhcp-lease-time", "num"=>51, "use_option"=>false, "value"=>"43200", "vendor_class"=>"DHCP"}, {"name"=>"domain-name-servers", "num"=>6, "use_option"=>true, "value"=>"192.168.254.10", "vendor_class"=>"DHCP"}, {"name"=>"domain-name", "num"=>15, "use_option"=>true, "value"=>"testlab.local", "vendor_class"=>"DHCP"}, {"name"=>"routers", "num"=>3, "use_option"=>true, "value"=>"192.168.254.1", "vendor_class"=>"DHCP"}]}]
it would be great, if somebody could help me to get this flying!
Related
My website is mostly to display results, so the admin enters the results and they are rendered nicely for the users/clients. Currently, in my main_controller.rb and other controllers I have functions for the main index page...
def index
#next_tournament = helpers.next_tournament()
#last_tournament = helpers.last_tournament()
#last_tournament_date_display = helpers.last_tournament_date_display(#last_tournament)
#next_tournament_date_display = helpers.next_tournament_date_display(#next_tournament)
#current_season = #last_tournament.season_year
#aoys = helpers.display_aoy(#last_tournament.id)
#aoy_diff = helpers.aoy_point_diff(#aoys)
#individual_winners = helpers.individual_winners(#last_tournament.id)
#team_winners = helpers.team_winners(#last_tournament.id)
#big_bass_winners = helpers.big_bass_winners(#last_tournament.id)
#total_club_stats = helpers.total_club_stats()
#annual_club_stats = helpers.annual_club_stats(#current_season )
...
end
Does this mean, that for every person that navigates to my main index page the server will re-run these functions and spit out the result?
I'm trying to understand what happens on the server side. Would this be a problem? Most of these functions would only change when a new result is entered. Is it best practice to do something in the code, so that the function is only re-ran when any of the variables in the equation change, and otherwise static?
So, I have to work with this JSON (from URL):
{'player': {'racing': 25260.154000000017, 'player': 259114.57700000296}, 'farming': {'fishing': 33783.390999999414, 'mining': 29048.60500000002, 'farming': 25334.504000000023}, 'piloting': {'piloting': 25570.18800000001, 'cargos': 3080.713000000036, 'heli': 10433.977000000004}, 'physical': {'strength': 198358.86700000675}, 'business': {'business': 50922.88500000005}, 'trucking': {'mechanic': 2724.5620000000004, 'garbage': 755.642999999997, 'trucking': 223784.99700000713, 'postop': 1411.4190000000006}, 'train': {'bus': 669.1940000000001, 'train': 1363.805999999999}, 'ems': {'fire': 25449.43400000001, 'ems': 13844.628000000012}, 'hunting': {'skill': 4179.033000000316}, 'casino': {'casino': 18545.526000000027}}
It is indeed one line. I am trying to make it so that for example, I can get racing, which is the first one you see. For this, you need go into Player first, and then you can get to Racing. How do I do this?
My current code:
def allthethings():
# Grab all the skills
geturl = ("http://server.tycoon.community:30120/status/data/" + str(setting_playerid))
print(geturl)
a = requests.get(geturl,headers={"X-Tycoon-Key":setting_apikeyTT}).json()
jsonconverted = (a["data"]["gaptitudes_v"])
print(jsonconverted)
# Convert JSON into many, many variables
Raw_RACR = jsonconverted['player.racing']
print(Raw_RACR)
I believe this is all the code that is needed.
Also, this is the error:
KeyError: 'player.racing'
Do you know how I can set UNB in EDIFACT?
I have a CSV input file:
VRD1;100;200;0;0;L
And the output should be:
UNA:+.? '
UNB+UNOA:2+100:14+200:14+200305:0704+00000000000000++AAA'
UNH+1+INVRPT:D:96A:UN:EAN005'
BGM+10::9+20200305070403+9
I have to map the second and third fields to UNB.
I appreciate any help in this regard. Thank you in advance.
You should be able to do this using the EdiOverride message context properties. You can find them in the Microsoft.BizTalk.Edi.BaseArtifacts assembly found in the BizTalk Server installation folder.
For instance, in an orchestration, you can do this:
EdifactMessage(EdiOverride.OverrideEDIHeader) = true;
EdifactMessage(EdiOverride.UNB2_1) = xpath(CsvMessage, ...); // 100
EdifactMessage(EdiOverride.UNB3_1) = xpath(CsvMessage, ...); // 200
Add a correlation set with the same properties to your send shape.
If you want to set them in a pipeline, use the property namespace http://schemas.microsoft.com/BizTalk/2006/edi-properties.
Today I woke up and want to run my code (which was working fine) but I got several errors - Undefined offset errors while looping through the json response obtained after a request containing several origins and destinations has been sent:
$request = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?origins=$OriginUrl&destinations=$DestinationUrl&mode=driving");
$resultdistance = json_decode($request, true);
for($i=0;$i<count($LocationDetails);$i++){
$distanceM = $resultdistance['rows'][$i]['elements'][$i]['distance']['value'];
$distanceKM = $distanceM / 1000;
$TravelDistance = round($distanceKM,1); // Distance from Act 1 and Act 2
$DistanceText = $resultdistance['rows'][$i]['elements'][$i]['distance']['text'];
$TimeToTravelSec = $resultdistance['rows'][$i]['elements'][$i]['duration']['value'];
$TimeToTravelText = $resultdistance['rows'][$i]['elements'][$i]['duration']['text'];
}
I then enter the http request manually in the address bar with several origins and notice that the request has been sent with only one origin:
https://maps.googleapis.com/maps/api/distancematrix/json?origins=Hilton+Mauritius+Resort+&+Spa,+Coastal+Road,+Flic+en+Flac,+Mauritius|LAventure+du+Sucre,+B18,+Pamplemousses,+Mauritius&destinations=Cascavelle,+Riviere+Noire+District|Mauritius+Aquarium,+B38,+Camp+Bestel,+Pamplemousses+District,+Mauritius|Blue+Safari+Submarines,+B36,+Trou-aux-Biches,+Mauritius|&mode=driving
Two origins has been sent:
1. Hilton+Mauritius+Resort+&+Spa,+Coastal+Road,+Flic+en+Flac,+Mauritius
2.LAventure+du+Sucre,+B18,+Pamplemousses,+Mauritius
but only the first one has been taken into consideration (see image above or click on the link to send request and see the result) ! A few days ago I was using about 5 origins and it was working Please Help !
I remove the '&' in :
Hilton+Mauritius+Resort+&+Spa,+Coastal+Road,+Flic+en+Flac,+Mauritius
and it works fine.There should not be any '& in the origin's name and destination's names because the parameters are already using the '&' sign and this might cause some problems.
I'm new to PowerShell, so I'm still getting used to the way variables and for loops are used, but I'd just like to have someone double check my script. I haven't run it yet, as it uses a set command and I'd rather be doubly sure the code works before testing. Once I get some input I'll run a very small number of users through it. The code is for assigning users intercall numbers.
I'm using an excel file that has 4 columns. The columns are labled "userprofilename", "RPTF", "RPTOLL", and "RPConfCode", same as the variables. Here is my code:
$accounts = ipcsv 'C:\Powershell-dest\intercall-numbers.csv'
$accounts | % {
$userprofilename = $_.userprofilename
$RPTF = $_.RPTF
$RPTOLL = $_.RPTOLL
$RPConfCode = $_.RPConfCode
Set-CsUserAcp -Identity $userprofilename -Name "InterCall" -Domain example.com -TollNumber $RPTOLL -TollFreeNumbers $RPTF -ParticipantPasscode $RPConfCode -Url http://www.intercall.com/l/dial-in-number-lookup.php}
I'll of course change "example.com" to the actual domain when I run it. Am I declaring/using the variables correctly?