<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating new resourceGroup before the instance in HPE Morpheus Enterprise Software</title>
    <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251300#M4474</link>
    <description>&lt;P&gt;I 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:&lt;/P&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;    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))
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have tested this, and the resource group and the instance creation both worked successfully. This is not a defect.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2023 14:38:43 GMT</pubDate>
    <dc:creator>dgaharwar</dc:creator>
    <dc:date>2023-11-29T14:38:43Z</dc:date>
    <item>
      <title>Creating new resourceGroup before the instance</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251296#M4470</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I’d like to create an Azure Resource Group before creating a new instance in it.&lt;BR /&gt;
To achieve that goal, I’ve created a Python task which does API calls to create a resource group and refresh the Morpheus cloud.&lt;BR /&gt;
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.&lt;BR /&gt;
The problem seems to be that the catalog item is not aware of it.&lt;/P&gt;
&lt;P&gt;Here is my configuration&lt;/P&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;  "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": "&amp;lt;%=results.azcreaterg.id%&amp;gt;",
    "poolProviderType": null
  },
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, when ordering the catalog, it fails with an error message:&lt;/P&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;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:&amp;lt;%=results.azcreaterg.id%&amp;gt;, 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:&amp;lt;%=results.azcreaterg.id%&amp;gt;, 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)
&amp;lt;cut&amp;gt;
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

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Finally, the code of the Python task is :&lt;/P&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;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))
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Do you have an idea where the problem is?&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Matthieu&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2023 23:15:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251296#M4470</guid>
      <dc:creator />
      <dc:date>2023-11-24T23:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new resourceGroup before the instance</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251297#M4471</link>
      <description>&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;Thanks&lt;BR /&gt;
Deepti&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2023 08:58:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251297#M4471</guid>
      <dc:creator>dgaharwar</dc:creator>
      <dc:date>2023-11-27T08:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new resourceGroup before the instance</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251298#M4472</link>
      <description>&lt;ASIDE class="quote group-Certified-Engineer" data-username="dgaharwar" data-post="2" data-topic="1597"&gt;
dgaharwar:
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE style="background : #f0f1f2;"&gt;"regionCode": "francecentral",&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/ASIDE&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;it doesn’t change anything&lt;/P&gt;
&lt;P&gt;I realy think the problem comes from the json catalog, because the resource group is created.&lt;/P&gt;
&lt;P&gt;regards,&lt;/P&gt;
&lt;P&gt;Matthieu&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2023 08:12:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251298#M4472</guid>
      <dc:creator />
      <dc:date>2023-11-27T08:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new resourceGroup before the instance</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251299#M4473</link>
      <description>&lt;P&gt;Try passing the &lt;CODE style="background : #f0f1f2;"&gt;"regionCode": "francecentral"&lt;/CODE&gt; in your payload like this:&lt;/P&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;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
    }}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Nov 2023 17:07:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251299#M4473</guid>
      <dc:creator>dgaharwar</dc:creator>
      <dc:date>2023-11-25T17:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new resourceGroup before the instance</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251300#M4474</link>
      <description>&lt;P&gt;I 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:&lt;/P&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;    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))
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have tested this, and the resource group and the instance creation both worked successfully. This is not a defect.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 14:38:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/creating-new-resourcegroup-before-the-instance/m-p/7251300#M4474</guid>
      <dc:creator>dgaharwar</dc:creator>
      <dc:date>2023-11-29T14:38:43Z</dc:date>
    </item>
  </channel>
</rss>

