- Community Home
- >
- Software
- >
- HPE Morpheus Software
- >
- HPE Morpheus Enterprise Software
- >
- Creating new resourceGroup before the instance
Categories
Company
Local Language
Forums
Discussions
- Integrity Servers
- Server Clustering
- HPE NonStop Compute
- HPE Apollo Systems
- High Performance Computing
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp Software
Knowledge Base
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 03:15 PM
11-24-2023 03:15 PM
Hello,
I’d like to create an Azure Resource Group before creating a new instance in it.
To achieve that goal, I’ve created a Python task which does API calls to create a resource group and refresh the Morpheus cloud.
This task is running in the Config phase of the workflow and works well, as the specified RG is created and we can see it in clouds/resources.
The problem seems to be that the catalog item is not aware of it.
Here is my configuration
"config": {
"createUser": false,
"isEC2": false,
"isVpcSelectable": true,
"noAgent": false,
"azureRegion": "francecentral",
"azuresecurityGroupId": null,
"availabilityOptions": "",
"availabilityZone": 1,
"availabilitySet": "",
"azurefloatingIp": false,
"bootDiagnostics": null,
"osGuestDiagnostics": "off",
"diagnosticsStorageAccount": null,
"resourcePoolId": "<%=results.azcreaterg.id%>",
"poolProviderType": null
},
However, when ordering the catalog, it fails with an error message:
2023-11-24_22:59:56.80483 ''[2023-11-24 22:59:56,806] [appJobHigh-20] INFO c.m.p.AzureProvisionService - runContainer: com.morpheus.Container : 21 [instanceId:21, refId:21, jobType:instanceContainerProvision, instanceProvisionStart:1700866795986, newContainers:[21], newContainerCount:1, containerIndex:0, policyConfig:[success:true, categories:[provision, lifecycle], allowed:true, provision:false, requireApproval:false, results:[[success:true, allowed:true], [success:true, allowed:true], [success:true, allowed:true], [success:true, allowed:true], [success:true, allowed:true], [success:true, allowed:true], [success:true, allowed:true], [success:true, allowed:true], [success:true, allowed:true], [success:true, allowed:true], [success:true, allowed:true], [success:true, allowed:true]], policies:[:]], containerProvisionStart:1700866796328, provisionService:com.morpheus.provision.AzureProvisionService@225c7466, processUser:mlusseaud, processMap:com.morpheus.ProcessService$ProcessDetail@404207a5, processStepMap:com.morpheus.ProcessService$ProcessStepDetails@6b25e5a4, containerService:com.morpheus.ContainerService@2be95a07, callbackService:com.morpheus.ContainerService@2be95a07, callbackType:provision, networkConfig:[primaryInterface:[networkType:dhcp, id:61, subnet:com.morpheus.NetworkSubnet : 19, macAddress:null, network:com.morpheus.Network : 666, vlanId:null, type:null, doStatic:false, doStatic6:false, doDhcp:true, doDhcp6:false, ipv4Enabled:true, ipv6Enabled:false, name:eth0, externalId:/subscriptions/3ff78315-7d97-418e-bced-34d5cafc104a/resourceGroups/rg-dev-frc-dev-poc/providers/Microsoft.Network/virtualNetworks/vnet-bel-d-fr-office, searchDomains:null], extraInterfaces:[], doStatic:false, doDhcp:false, doCustomizations:false, havePool:false, haveDhcpReservation:false, success:true, networkDomain:[domainController:false, domainUsername:null, domainPassword:*******, ouPath:null, dcServer:null, name:localdomain, fqdn:null, guestUsername:null, guestPassword:null]]]
2023-11-24_22:59:56.80673 ''[2023-11-24 22:59:56,807] [appJobHigh-20] DEBUG c.m.p.AzureProvisionService - Container Config [maxMemory:34359738368, maxStorage:34359738368, maxCpu:0, maxCores:8, createUser:false, isEC2:false, isVpcSelectable:true, noAgent:false, azureRegion:francecentral, azuresecurityGroupId:null, availabilityOptions:, availabilityZone:1, availabilitySet:, azurefloatingIp:false, bootDiagnostics:null, osGuestDiagnostics:off, diagnosticsStorageAccount:null, resourcePoolId:<%=results.azcreaterg.id%>, poolProviderType:null, userGroup:[id:], tags:test,vmcreation, name:AZR-DMLUTST9, hostName:azr-dmlutst9, instanceType:[code:null], site:[id:9], environmentPrefix:null, layout:[id:1159, code:d4c96917-03a2-48cd-9710-d9213a5654e6], type:belw2019, instanceContext:d_dev, memoryDisplay:MB, expose:[], azRgName:rg-bel-d-mlutst-010, vm:true, networkInterfaces:[[id:subnet-19, network:[id:null, group:null, subnet:19, dhcpServer:true, name:vnet-bel-d-fr-office - snet-bel-d-fr-office-poc, pool:null], ipAddress:null, networkInterfaceTypeId:null, ipMode:]], volumes:[[rootVolume:true, name:root, maxStorage:34359738368, size:32, volumeCustomizable:true, readonlyName:false, storageType:40, maxIOPS:null, datastoreId:457, id:-1]], storageController:null, azureUsr:null, azurePwd:*******, subnetId:null, securityGroupId:null, floatingIp:null, sizeRef:Standard_B8ms, resourcePool:<%=results.azcreaterg.id%>, templateTypeSelect:null, marketplacePublisher:null, marketplaceOffer:null, marketplaceSku:null, marketplaceVersion:null, publicKeyId:null, taskSetId:3, hosts:[container21:127.0.0.1], evars:[:]]
2023-11-24_22:59:56.80719 ''[2023-11-24 22:59:56,821] [appJobHigh-20] ERROR c.m.p.AzureProvisionService - runContainer error: java.lang.NullPointerException: Cannot get property 'regionCode' on null object
2023-11-24_22:59:56.82153 'java.lang.NullPointerException: Cannot get property 'regionCode' on null object'
2023-11-24_22:59:56.82155 at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60)
<cut>
2023-11-24_22:59:56.82201 at java.base/java.lang.Thread.run(Unknown Source)
2023-11-24_22:59:56.89637 '[2023-11-24 22:59:56,896] [appJobHigh-20] ERROR c.m.ContainerService - Unable to deploy container: Failed to create server: Cannot get property 'regionCode' on null object
2023-11-24_22:59:56.89639 ''[2023-11-24 22:59:56,944] [appJobHigh-20] INFO c.m.ContainerService - provisionContainer runResult.success: false
2023-11-24_22:59:56.94477 ''[2023-11-24 22:59:56,985] [appJobHigh-20] ERROR c.m.ContainerService - Unable to deploy container: null
2023-11-24_22:59:56.98550 ''[2023-11-24 22:59:56,985] [appJobHigh-20] ERROR c.m.InstanceProvisionService - Unable to deploy container: [success:false, inProgress:false, msg:null]
2023-11-24_22:59:56.98575 ''[2023-11-24 22:59:56,991] [appJobHigh-20] WARN c.m.InstanceProvisionService - provision failed
Finally, the code of the Python task is :
import json, requests, urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
configspec = morpheus['spec']
MORPHEUS_VERIFY_SSL_CERT = False
MORPHEUS_HOST = morpheus['morpheus']['applianceHost']
MORPHEUS_TENANT_TOKEN = morpheus['morpheus']['apiAccessToken']
AZURE_VMName = configspec['customOptions']['azRgName']
MORPHEUS_HEADERS = {"Content-Type":"application/json","Accept":"application/json","Authorization": "Bearer " + MORPHEUS_TENANT_TOKEN}
url1 = 'https://%s/api/zones/155/resource-pools' % (MORPHEUS_HOST )
payload = {"resourcePool": {
"defaultPool": False,
"defaultImage": False,
"active": True,
"visibility": "private",
"inventory": True,
"config": {"tenancy": "default"},
"resourcePermissions": {
"all": True,
"allPlans": True
},
"name": AZURE_VMName
}}
#response1 = requests.post(url1, json=payload, headers=MORPHEUS_HEADERS, verify=MORPHEUS_VERIFY_SSL_CERT)
response1 = requests.post(url1, json=payload, headers=MORPHEUS_HEADERS, verify=False)
data1 = response1.json()
resourcePoolId = data1['resourcePool']['id']
print("id=pool-"+str(resourcePoolId))
Do you have an idea where the problem is?
Regards,
Matthieu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 12:58 AM
11-27-2023 12:58 AM
Re: Creating new resourceGroup before the instance
Seems right. I am able to reproduce this as well. Can you log a support case for the same and we will investigate further, please?
Thanks
Deepti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 12:12 AM
11-27-2023 12:12 AM
Re: Creating new resourceGroup before the instance
Hello,
it doesn’t change anything
I realy think the problem comes from the json catalog, because the resource group is created.
regards,
Matthieu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2023 09:07 AM
11-25-2023 09:07 AM
Re: Creating new resourceGroup before the instance
Try passing the "regionCode": "francecentral" in your payload like this:
payload = {"resourcePool": {
"regionCode": "francecentral",
"defaultPool": False,
"defaultImage": False,
"active": True,
"visibility": "private",
"inventory": True,
"config": {"tenancy": "default"},
"resourcePermissions": {
"all": True,
"allPlans": True
},
"name": AZURE_VMName
}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 06:38 AM
11-29-2023 06:38 AM
SolutionI noticed that in your Python task for creating a resource group, you are simply printing the resourcePoolId which is incorrect. You will need to re-expose the config spec and print the update spec to make it available for provisioning. So your task should be like this:
import json, requests, urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
configspec = morpheus['spec']
MORPHEUS_VERIFY_SSL_CERT = False
MORPHEUS_HOST = morpheus['morpheus']['applianceHost']
MORPHEUS_TENANT_TOKEN = morpheus['morpheus']['apiAccessToken']
AZURE_VMName = configspec['customOptions']['azRgName']
MORPHEUS_HEADERS = {"Content-Type":"application/json","Accept":"application/json","Authorization": "Bearer " + MORPHEUS_TENANT_TOKEN}
url1 = 'https://%s/api/zones/155/resource-pools' % (MORPHEUS_HOST)
payload = {"resourcePool": {
"regionCode": "francecentral",
"defaultPool": False,
"defaultImage": False,
"active": True,
"visibility": "private",
"inventory": True,
"config": {"tenancy": "default"},
"resourcePermissions": {
"all": True,
"allPlans": True
},
"name": AZURE_VMName
}}
#response1 = requests.post(url1, json=payload, headers=MORPHEUS_HEADERS, verify=MORPHEUS_VERIFY_SSL_CERT)
response1 = requests.post(url1, json=payload, headers=MORPHEUS_HEADERS, verify=False)
data1 = response1.json()
resourcePoolId = data1['resourcePool']['id']
#print("id=pool-"+str(resourcePoolId))
configspec['config']['resourcePoolId']=resourcePoolId
##### config - print updated spec
newconfigspec = {}
newconfigspec['spec'] = configspec
print(json.dumps(newconfigspec))
I have tested this, and the resource group and the instance creation both worked successfully. This is not a defect.