Namespaces:
  =: io.murano.apps.example.plugin
  std: io.murano
  res: io.murano.resources
  sys: io.murano.system


Name: DemoApp

Extends: std:Application

Properties:
  name:
    Contract: $.string().notNull()

  instance:
    Contract: $.class(res:Instance).notNull()

Methods:
  initialize:
    Body:
      - $._environment: $.find(std:Environment).require()

  deploy:
    Body:
      - If: not $.getAttr(deployed, false)
        Then:
          - $._environment.reporter.report($this, 'Creating VM ')
          - $securityGroupIngress:
              - ToPort: 22
                FromPort: 22
                IpProtocol: tcp
                External: true
          - $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
          - $.instance.deploy()
          - $resources: new(sys:Resources)
          - $._environment.reporter.report($this, 'Test VM is installed')
          - $.host: $.instance.ipAddresses[0]
          - $.user: 'root'
          - $.setAttr(deployed, true)
