Each element of the ACS-driven infrastructure is represented as a Moose-sugared Perl object, has attributes and executes methods. All kinds of elements consume (inherit) the same Moose role (MonkeyMan::CloudStack::API::Roles::Element) which makes that class an element.
Elements getting to know what they shall do to perform some work, are looking up the element’s vocabulary (MonkeyMan::CloudStack::API::Vocabulary;), the vocabulary configures the element like DNA. 🙂
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
our %vocabulary_tree = ( type => 'Account', name => 'account', entity_node => 'account', actions => { list => { request => { command => 'listAccounts', async => 0, paged => 1, parameters => { all => { required => 0, command_parameters => { 'listall' => 'true' }, }, accounttype => { required => 0, command_parameters => { 'accounttype' => '<%VALUE%>' }, }, filter_by_id => { required => 0, command_parameters => { 'id' => '<%VALUE%>' }, }, filter_by_name => { required => 0, command_parameters => { 'name' => '<%VALUE%>' }, }, filter_by_domainid => { required => 0, command_parameters => { 'domainid' => '<%VALUE%>' } } } }, response => { response_node => 'listaccountsresponse', results => { element => { return_as => [ qw( dom element id ) ], queries => [ '/<%OUR_RESPONSE_NODE%>/<%OUR_ENTITY_NODE%>' ], required => 0, multiple => 1 }, id => { return_as => [ qw( value ) ], queries => [ '/<%OUR_RESPONSE_NODE%>/<%OUR_ENTITY_NODE%>/id' ], required => 0, multiple => 1 }, } } }, create => { request => { command => 'createAccount', async => 0, paged => 0, parameters => { type => { required => 1, command_parameters => { 'accounttype' => '<%VALUE%>' }, }, name => { required => 1, command_parameters => { 'username' => '<%VALUE%>' }, }, email => { required => 1, command_parameters => { 'email' => '<%VALUE%>' }, }, first_name => { required => 1, command_parameters => { 'firstname' => '<%VALUE%>' }, }, last_name => { required => 1, command_parameters => { 'lastname' => '<%VALUE%>' }, }, password => { required => 1, command_parameters => { 'password' => '<%VALUE%>' }, }, account => { required => 0, command_parameters => { 'account' => '<%VALUE%>' }, }, domain => { required => 0, command_parameters => { 'domainid' => '<%VALUE%>' }, }, time_zone => { required => 0, command_parameters => { 'timezone' => '<%VALUE%>' }, }, network_domain => { required => 0, command_parameters => { 'networkdomain' => '<%VALUE%>' }, } } }, response => { response_node => 'createaccountresponse', results => { element => { return_as => [ qw( dom element id ) ], queries => [ '/<%OUR_RESPONSE_NODE%>/<%OUR_ENTITY_NODE%>' ], required => 0, multiple => 1 }, id => { return_as => [ qw( value ) ], queries => [ '/<%OUR_RESPONSE_NODE%>/<%OUR_ENTITY_NODE%>/id' ], required => 0, multiple => 1 } } } } } ); # Yes, I'd definitely would translate it yo YAML, but I'd like it to stay Perl-executable |
See MonkeyMan::CloudStack::API::Element::Domain.
Yes, that’s what MonkeyMan knows about the Domain infrastructure element in the ACS-driven cloud. And when I needed to teach it how to handle with another infrastructure element – an account, I’d just added it as a separate vocabulary:
See MonkeyMan::CloudStack::API::Element::Account.
MonkeyMan is a good student, it’s such a joy to teach him feww new tricks 🙂