Using the
with
(Press space to proceed, or use your arrow keys.)
This is how a course author invokes the hastexo XBlock XML in the courseware:
<vertical url_name="lab_introduction"> <hastexo url_name="lab_introduction" stack_template_path="hot_lab.yaml" instructions_path="markdown_lab.md" stack_user_name="training" os_auth_url="https://ops.elastx.net:5000/v2.0" os_tenant_name="example.com" os_username="demo@example.com" os_password="foobarfoobarfoofoo" /> </vertical>
The XBlock supports standard OpenStack authentication variables, including Keystone v3:
The uploaded Heat template (stack_template_path) defines the lab environment itself. It is a regular Heat Template, but it needs to meet the following criteria...
The template must assign a public IP address to one node in the environment, and provide it as a template output named public_ip:
resources: deploy_floating_ip: type: OS::Neutron::FloatingIP properties: floating_network_id: { get_param: public_net_id } port_id: { get_resource: deploy_management_port } fixed_ip_address: 192.168.122.100 output: public_ip: description: Floating IP address of deploy in public network value: { get_attr: [ deploy_floating_ip, floating_ip_address ] }
The template must also create a private SSH key identified by the stack's own name, and provide it as a private_key output:
resources: training_key: type: OS::Nova::KeyPair properties: name: { get_param: 'OS::stack_name' } save_private_key: true outputs: private_key: description: Training private key value: { get_attr: [ training_key, private_key ] }
The training key must be usable to access not only the public node, but all others. To do so, a specific system user can be defined using the Heat CloudConfig resource, and the private and public keys deployed as such:
resources: cloud_config: type: OS::Heat::CloudConfig properties: cloud_config: users: - name: training gecos: Training User groups: users,adm ssh-authorized-keys: - { get_attr: [ training_key, public_key ] } write_files: - path: /home/training/.ssh/id_rsa permissions: '0600' content: { get_attr: [ training_key, private_key ] }
Lab instructions are written in markdown, one file per lab (also uploaded to the course content store), and will be rendered as HTML immediately above the terminal window.
Labs can be graded by defining tests in any available scripting language . A return value of 0 means the student was successful. Anything else means failure:
<hastexo> <test> #!/bin/bash -e for i in daisy eric frank; do ssh $i dpkg -l ceph done </test> <test> #!/bin/bash -e # Check if directory is present. ls -l /etc/ceph </test> </hastexo>
This is what the student sees, in practice:
http://arbrandes.github.io/hastexo-xblock-openstack-integration
https://github.com/arbrandes/hastexo-xblock-openstack-integration
This presentation, like most hastexo slide decks, is under the CC-BY-SA 3.0 license. So please feel free to peruse these slides as a basis for your own presentations, as you see fit.