VM lifecycle in Service Manager with Orchestrator magic

A couple of weeks ago I was speaking at a System Center 2012 event in Stockholm/Sweden. My session was around Orchestrator and Service Manager integration. On stage I created and demo a scenario where Service Manager, Virtual Machine Manager and Orchestrator was used to administrate lifecycle of virtual machines and virtual services. My laptop only hosted Orchestrator and Service Manager so in many of the example runbooks I only create a computer object in Service Manager. But as you realize you could re-place that with any kind of Virtual Machine Manager activity. In this post I will share with you the demo files, runbooks and management packs I used.

The demo scenario was that someone could order a virtual machine or a service (service template) from the self service portal in Service Manager. Orchestrator and Virtual Machine Manager then created the machines and so on. When you order a new virtual machine you needed to input a expire date, for how long will you need the virtual machine. You also need to input a cost center, to know who should approve and how will pay for it. When a virtual machine is close to the expire date it is picked up by a runbook that notify the owner. The owner can use the portal to extend the date or simple don’t. If the machine pass the expire date Orchestrator will shut it down. When it has been shut down for some months it is deleted. The demo also showed how to generate reports to follow up which how much each cost center should pay. When the order is complete the user can see the result in the Service Manager portal

 

The cool thing about this demo is not only that we can create any kind of virtual environment with Virtual Machine Manager 2012, instead of just deploying machines we can follow up on who order, who approved and we can also see how much each cost center is using.

The solution is divided into multiple steps

  1. Extend the Windows Computer CI class in Service Manager with a couple of extra properties, like order date, cost center, owner, expire date, approver and cost. (MP attached)
  2. Create a new CI class in Service Manager to store cost information (MP attached)
  3. Create a runbook that creates computer objects (export file attached)
  4. Publish a service in the self-service portal in service manager (not included in this post, ping me if you need step by step guide)
  5. Create a report to follow up number of orders and total cost per cost center
  6. Create runbooks to administrate removal of expired objects (export file attached)

Extend the Windows Computer Class

To add extra attributes to all Windows Computer CI objects in Service Manager we need to extend the Windows Computer class. We can do that with the Service Manager Authoring Tool, download here. (http://www.microsoft.com/en-us/download/details.aspx?id=28726). When the Authoring Tool is installed follow these steps to extend the Windows Computer class

  1. We need to seal the management pack we will create in the Authoring Tool. If we don’t seal it we cant use it with Orchestrator or the data warehouse. To seal it we need a keyfile. SN.EXE (.NET Framework Strong Name Utility) is a tool that we can use to generate that key file. Open a command prompt and navigate to C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\bin
  2. To generate a key pair run, SN.EXE -k C:\temp\snKey.snk
  3. Start Service Manager Authoring Tool
  4. From the File menu choose New
  5. New Management Pack, save the new management pack in a suitable folder, for example C:\TEMP\Contoso.WinCompExt
  6. Use the Class Browser to find the Windows Computer class, right-click it and select View
  7. In the Management Pack Explorer pane, note all the default properties. Right-click on the Windows Computer class and select Extend Class
  8. Target Management Pack, select Contoso.WinCompExt to save the extension in the management pack
  9. Click Create Property and add the following properties. Edit each property in the Details pane
    Internal NameNameData TypeNote
    ContosoOrderDateOrder DateDate Time
    ContosoCostCenterCost CenterString
    ContosoOwnerOwnerString
    ContosoExpireDateExpire DateDate Time
    ContosoApproverApproverString
    ContosoCostCostInteger
  10. Save your management pack
  11. In the Management Pack Explorer pane, right-click Contoso.WinCompExt and select Seal Management Pack
  12. Seal Management Pack,
    Output Directory: C:\TEMP
    Key File: C:\temp\snKey.snk
    Company: Contoso
    Click Seal and then Close
  13. Start Service Manager Console and import the sealed Contoso.WinCompExt management pack from C:\temp\Contoso.WinCompExt.mp (make sure to select the .MP management pack, MP=Sealed XML=Unsealed)
  14. Close the Service Manager Console and open it again, this will re-load class information
  15. Navigate to Configuration Items/Computers/All Windows Computers and open a computer. Note all the new properties that are shown on the Extensions tab. We have now extended the Windows Computer class with the properties we need for the computer lifecycle demo.
.

The pricelist

One of the properties we extended the Windows Computer class with is Cost. My idea is to use this field to show the monthly price of the configuration item, the computer. We could input that price manual but we can also build a price list inside of Service Manager. To do that we can use the Authoring Tool to create a new CI class, Contoso Price List.

  1. Start Service Manager Authoring Tool
  2. From the File menu create a new management pack, for example C:\TEMP\ContosoCost
  3. In the Management Pack Explorer pane, right-click Classes and select Create Configuration Item Class
  4. Create Class, input ContosoCostItem as internal class name
  5. In the Details pane change the Name to Cost Item
  6. Delete default Property_4
  7. Add two properties, AvailabilityLevel and Cost. Change AvailabilityLevel name to Availability Level. Change data type to Integer for the Cost property. Change Key to TRUE on the Availability Level property
  8. Save the managemente pack
  9. Seal the management pack the same way we did with the first management pack
  10. Import the management pack into Service Manager. Remember to import the sealed version, MP file.
  11. Restart the Service Manager Console
  12. Navigate to Configuration Items
  13. Create a new folder, name it Price List. Create a new management pack, for example Contoso, and store the folder in it
  14. Select the Price List folder and click Create View in the Tasks pane
  15. Create View
    Name: All Items
    Criteria: All objects of the ContosoCost Item class, where object status does not equals Pending Delete
    Display: Availability Level and Cost
  16. Select the new All Items view and click Create Contoso Cost Item from the Tasks pane
    DisplayName: Gold
    Availability Level: Gold
    Cost: 100
  17. Click Create Contoso Cost Item from the Tasks pane
    Contoso Cost Item Properties
    DisplayName: Silver
    Availability Level: Silver
    Cost: 70
  18. Click Create Contoso Cost Item from the Tasks pane
    Contoso Cost Item Properties
    DisplayName: Bronze
    Availability Level: Bronze
    Cost: 40
  19. Click OK
We have now created a new CI class and 3 instances of it. Next step is to create a runbook that creates computer accounts in Active Directory. This runbook will be syncronized to Service Manager and used as a runbook activity. The runbook will read the price for each computer that is order from the new CI class we just created.

Runbooks

This example use a number of runbooks, all included in the export file attached to this blogpost. I will explain each one of them and you can import them and look at the in the Orchestrator Runbook Designer

  •  700.10 Cost. This runbook will get the correct price for the new computer based on the price list in Service Manager
  • 700.11 Count Machines. This runbook counts existing machines to figure out a suitable computer name for the new machine
  • 700.2 Update Approver. This runbook updates the approver step in the service request template based on the cost center. The runbook attach approver to the manual approval step
  • 700.3 Create VM (picture) creates the new computer
  • 700.4 Update Service Request, updated the Description attribute on the Service Request. This is used when the machine is create to communicate the new computer name to the user. The user will see this in the self-service portal
  • 700.5 This one will find all VMs that are close to expire date (2 months or less) and send a e-mail to the owner of the machine. Also flag the virtual machine that e-mail has been sent
  • 700.6 Get Cost Center. This runbook gets approver for each cost center. This could be done with a external database or any other way
  • 700.7 When a VM have passed expire date it is shut down in Virtual Machine Manager
  • 700.8 Deleted expired VM, when the VM has been shutdown for 2 months it is deleted
  • 700.9 Update expire date, if the user order a new expire date for the computer in the portal, this runbook will update the virtual machine with the new expire date
  • 500.1-500.3, these runbooks are used to generate the HTML based report. One master runbook and then one runbook for each cost center

 

Report

Reporting have changed a lot with Service Manager 2012. We now have cubes to analyze the data and we use Excel to easy drag and drop fields to build table. The first image below show a table with everything that cost center 2 is running right now. If you want to sum everything into a one cell, total cost, it is a bit more difficult now when we are running cubes. We need to extend the cube to include that field. If you don’t know how to do that you could solve it with SQL reports or using Orchestrator. In the second image below you can see a HTML based report generated by a couple of runbooks in Orchestrator.

 

Runbooks, SC12day_demo_wolf
Management packs SC12 day MPs

 

Please note that this is provided “as is” with no warranties at all.

13 thoughts on “VM lifecycle in Service Manager with Orchestrator magic

  1. Thanks for this post, i have a little query ..when i am importing the runbook its saying UNKNOWN ACTIVITY , i have only imported VMM integration pack . do i need to also import service manager integration pack ? or something else

    can you please help me

  2. Can you please explain steps involved to create the service offering in service manager “SM portal”

  3. 4.Publish a service in the self-service portal in service manager (not included in this post, ping me if you need step by step guide)…

    Can you please share step by step guide for publishing this in SM self service portal…

  4. Hi, in the runbook automation activity I have map object/ID to that parameter. So every time I use that runbook activity in a service request I map the current runbook automation activity instance ID to that parameter in Initialize data.

  5. Great post.
    I’m interesting on how you build the service request template in service manager to be published in the web portal.
    In your RB 700.3, in initialize data you call the SRID and the get runbook automation get the RBID. Does it mean that the RB template for the RB 700.3 should the maping of the SRID to be linked to the runbook automation activity workitem id ?
    Regards,

  6. Hi, thanks for reading my blog. Your service request need to included a activity that create these VMs. You can create a runbook in Orchestrator, syncronize it to Service Manager and then use it as a runbook activity in the service request template.

  7. Hi Anders ,

    Do you have any idea of via Service portal submit the service request to deploy the multi-tier VM from service template which made in VMM ,is that service request must included the runbook activity in order to accomplish this ?

    Many Thanks & Appreciate

    Talmud Rabbi

Leave a Reply

Your email address will not be published. Required fields are marked *