Question

I've been playing around with UML

My primary background is that of a sysadmin, not as a programmer.

In order to get a better understanding of class models I've been trying to do map out the xmdomain.cfg file the xen hypervisor in UML (you can find the man page at http://linux.die.net/man/5/xmdomain.cfg)

So after working it out i get a basic start like this (note, this is attributes only, not actions)

xenDomU:[
    - kernelImage
    - initialRamdisk
    - allocatedMemory
    - rootDevice
    - nicAmount
    - domuName
]

The following situation has been a real pain in the ass

"disk" and "vif" can both occur multiple times in a domu config file. ("disk" can occur 1 to infinite times and "vif" 0 to infinite times) essentially they are classes themselves

disk:[
    - backendDevice
    - frontendDevice
    - deviceAccessMode
]

virtualNetworkInterface:[
    - networkBridgeDevice
    - interfaceIP
    - macAddress
    - interfaceName
]

In addition, "domain shutdown options" are really 3 values but it's actually best summorized as a single attribute, but then you get the same situation as above.

shutdownOptions{
    - onShutdown
    - onReboot
    - onCrash
}

So after that, you end up with something that really doesn't seem like valid UML to me.

xenDomU:[
    kernelImage
    initialRamdisk
    allocatedMemory
    rootDevice
    nicAmount
    disk:[
        backendDevice
        frontendDevice
        deviceAccessMode
    ]
    domuName
    virtualNetworkInterface:[
        networkBridgeDevice
        interfaceIP
        macAddress
        interfaceName
    ]
    shutdownOptions{
        onShutdown
        onReboot
        onCrash
    }
]

I'm sure there are "better" ways to do this, but this is what seems like the most natural to me.

Could someone please enlighten me and show the right way to do this.

Was it helpful?

Solution

For the shutdownOptions, you want to make it an enumeration, instead of a class. You need to declare an attribute of that type in the class for objects that will have one of those options.

Even though classes do allow nested classifiers (UML 2.3, 9.3.1), I agree with Gabriel that Disk and VIF should be standalone classes in the same package, with your main class declaring aggregations of Disks and VIFs. Nested classes are interesting when you want to hide that nested classifier from the outside world, which is rarely the case.

alt text

Or in the TextUML notation (which generated the diagram above):

package xen;

class XenDomU
    attribute domuName : String;
    attribute kernelImage : any;
    attribute initialRamdisk : any;
    attribute allocatedMemory : any;
    attribute rootDevice : any;
    attribute nicAmount : any;
    attribute shutdownMode : ShutdownOptions;
    composition disks : Disk[*];
    composition interfaces : VirtualNetworkInterface[*];
end;

class Disk
    attribute backendDevice : any;
    attribute frontendDevice : any;
    attribute deviceAccessMode : any;
end;

class VirtualNetworkInterface
    attribute networkBridgeDevice : any;
    attribute interfaceIP : any;
    attribute macAddress : any;
    attribute interfaceName : any;
end;

enumeration ShutdownOptions
         onShutdown,
         onReboot,
         onCrash
end;

end.

OTHER TIPS

I didn't understand why couldn't you have Disk and VIF as regular classes and create associations. As far as I know, UML doesn't support nested classes. However in some cases you can associate package with classes you wanted to be nested with the class you want to nest into.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top