You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by shwetaag <gi...@git.apache.org> on 2015/10/30 13:22:49 UTC

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

GitHub user shwetaag opened a pull request:

    https://github.com/apache/cloudstack/pull/1011

    CLOUDSTACK-9012 :automation of cores feature test path

    https://issues.apache.org/jira/browse/CLOUDSTACK-9012
    Automated a full scenario of coreos guest OS support:
    it includes registering coreos templates present at http://dl.openvm.eu/cloudstack/coreos/x86_64/
    1. based on hypervisor types of zone
    2. creating ssh key pair
    3. creating a sample user data
    4. creating a coreos virtual machine using this ssh keypair and userdata
    5. verifying ssh access to coreo os machine using keypair and core username
    6. verifying userdata is applied on virtual machine and the service asked in sample data is actually running
    7. Verifying userdata in router vm as well

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/shwetaag/cloudstack coreos

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cloudstack/pull/1011.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1011
    
----
commit 95355960746fbe1bdc649a483bff250b115ee7e7
Author: shweta agarwal <sh...@citrix.com>
Date:   2015-10-30T11:24:16Z

    automation of cores feature test path
    
    corrected some entires in test data

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cloudstack/pull/1011


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Re: [GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by Sanjeev N <sa...@apache.org>.
LGTM !!

test1_coreos_VM_creation
(integration.component.test_coreos.TestDeployVmWithCoreosTemplate) ... ===
TestName: test1_coreos_VM_creation | Status : SUCCESS ===
ok

----------------------------------------------------------------------
Ran 1 test in 754.205s

OK

On Thu, Feb 4, 2016 at 4:29 PM, shwetaag <gi...@git.apache.org> wrote:

> Github user shwetaag commented on a diff in the pull request:
>
>     https://github.com/apache/cloudstack/pull/1011#discussion_r51857877
>
>     --- Diff: test/integration/component/test_coreos.py ---
>     @@ -0,0 +1,291 @@
>     +# Licensed to the Apache Software Foundation (ASF) under one
>     +# or more contributor license agreements.  See the NOTICE file
>     +# distributed with this work for additional information
>     +# regarding copyright ownership.  The ASF licenses this file
>     +# to you under the Apache License, Version 2.0 (the
>     +# "License"); you may not use this file except in compliance
>     +# with the License.  You may obtain a copy of the License at
>     +#
>     +# http://www.apache.org/licenses/LICENSE-2.0
>     +#
>     +# Unless required by applicable law or agreed to in writing,
>     +# software distributed under the License is distributed on an
>     +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>     +# KIND, either express or implied.  See the License for the
>     +# specific language governing permissions and limitations
>     +# under the License.
>     +
>     +""" P1 tests for coreos template and vm
>     +"""
>     +
>     +from marvin.lib.base import (
>     +    VirtualMachine,
>     +    ServiceOffering,
>     +    Account,
>     +    SSHKeyPair,
>     +    Host, Template)
>     +from marvin.lib.common import (
>     +    get_zone,
>     +    get_template,
>     +    list_routers)
>     +from marvin.lib.utils import (
>     +    cleanup_resources,
>     +    get_hypervisor_type,
>     +    get_process_status)
>     +from marvin.cloudstackTestCase import cloudstackTestCase
>     +# Import System modules
>     +import tempfile
>     +import time
>     +import os
>     +import base64
>     +from nose.plugins.attrib import attr
>     +from marvin.sshClient import SshClient
>     +
>     +
>     +class TestDeployVmWithCoreosTemplate(cloudstackTestCase):
>     +    """Tests for deploying VM  using coreos template
>     +    """
>     +
>     +    @classmethod
>     +    def setUpClass(cls):
>     +        cls._cleanup = []
>     +        cls.testClient = super(
>     +            TestDeployVmWithCoreosTemplate,
>     +            cls).getClsTestClient()
>     +        cls.api_client = cls.testClient.getApiClient()
>     +        cls.services = cls.testClient.getParsedTestDataConfig()
>     +        cls.zone = get_zone(cls.api_client,
> cls.testClient.getZoneForTests())
>     +        cls.service_offering = ServiceOffering.create(
>     +            cls.api_client,
> services=cls.services["service_offerings"]["medium"])
>     +        cls.account = Account.create(
>     +            cls.api_client, services=cls.services["account"])
>     +        cls.cleanup = [cls.account]
>     +        cls.template = get_template(
>     +            cls.api_client,
>     +            cls.zone.id,
>     +            cls.services["ostype"]
>     +        )
>     +        cls.services["coreos"][
>     +            "hypervisor"] = cls.testClient.getHypervisorInfo()
>     +        cls.userdata = '#cloud-config\n\ncoreos:\n  units:\n    -
> name: docker.service\n      command: start\n    ' \
>     +                       '- name: web.service\n      command: start\n
>     content: |\n        [Unit]\n        ' \
>     +                       'After=docker.service\n
> Requires=docker.service\n        Description=Starts web server ' \
>     +                       'container\n        [Service]\n
> TimeoutStartSec=0\n        ' \
>     +                       'ExecStartPre=/usr/bin/docker pull
> httpd:2.4\n        ' \
>     +                       'ExecStart=/usr/bin/docker run -d -p 8000:80
> httpd:2.4'
>     +        cls.services["virtual_machine"]["userdata"] = cls.userdata
>     +
>     +        cls.keypair = SSHKeyPair.create(
>     +            cls.api_client,
>     +            name="coreos",
>     +            account=cls.account.name,
>     +            domainid=cls.account.domainid
>     +        )
>     +        cls.debug("Created a new keypair with name: %s" %
> cls.keypair.name)
>     +
>     +        cls.debug("Writing the private key to local file")
>     +        cls.keyPairFilePath = tempfile.gettempdir() + os.sep +
> cls.keypair.name
>     +        # Clenaup at end of execution
>     +        cls.cleanup.append(cls.keyPairFilePath)
>     +
>     +        cls.debug("File path: %s" % cls.keyPairFilePath)
>     +
>     +        f = open(cls.keyPairFilePath, "w+")
>     +        f.write(cls.keypair.privatekey)
>     +        f.close()
>     +        os.system("chmod 400 " + cls.keyPairFilePath)
>     +        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
>     +        return
>     +
>     +    def setUp(self):
>     +        self.api_client = self.testClient.getApiClient()
>     +        return
>     +
>     +    def tearDown(self):
>     +        # Clean up, terminate the created volumes
>     +        cleanup_resources(self.api_client, self.cleanup)
>     +        return
>     +
>     +    @classmethod
>     +    def tearDownClass(cls):
>     +        try:
>     +            cleanup_resources(cls.api_client, cls._cleanup)
>     +        except Exception as e:
>     +            raise Exception("Warning: Exception during cleanup : %s"
> % e)
>     +        return
>     +
>     +    @attr(tags=["advanced"], required_hardware="true")
>     +    def test1_coreos_VM_creation(self):
>     +
>     +        self.hypervisor =
> str(get_hypervisor_type(self.api_client)).lower()
>     +        self.services["virtual_machine"][
>     +            "hypervisor"] = self.hypervisor.upper()
>     +        if self.hypervisor == "vmware":
>     +            self.services["coreos"][
>     +                "url"] = self.services["coreos"]["urlvmware"]
>     +            self.services["coreos"]["format"] = "OVA"
>     +        elif self.hypervisor == "xenserver":
>     +            self.services["coreos"][
>     +                "url"] = self.services["coreos"]["urlxen"]
>     +            self.services["coreos"]["format"] = "VHD"
>     +        elif self.hypervisor == "kvm":
>     +            self.services["coreos"][
>     +                "url"] = self.services["coreos"]["urlkvm"]
>     +            self.services["coreos"]["format"] = "QCOW2"
>     +        elif self.hypervisor == "hyperv":
>     +            self.services["coreos"][
>     +                "url"] = self.services["coreos"]["urlxen"]
>     +            self.services["coreos"]["format"] = "VHD"
>     +
>     +        template_created = Template.register(
>     +            self.api_client,
>     +            self.services["coreos"],
>     +            self.zone.id,
>     +            account=self.account.name,
>     +            domainid=self.account.domainid)
>     +        self.assertIsNotNone(template_created, "Template creation
> failed")
>     +        # Wait for template to download
>     +        template_created.download(self.api_client)
>     +        self.cleanup.append(template_created)
>     +        # Wait for template status to be changed across
>     +        time.sleep(self.services["sleep"])
>     +
>     +        self.debug("Deploying instance in the account: %s" %
> self.account.name)
>     +
>     +        virtual_machine = VirtualMachine.create(
>     +            self.api_client,
>     +            self.services["virtual_machine"],
>     +            templateid=template_created.id,
>     +            accountid=self.account.name,
>     +            domainid=self.account.domainid,
>     +            zoneid=self.zone.id,
>     +            serviceofferingid=self.service_offering.id,
>     +            keypair=self.keypair.name,
>     +            hypervisor=self.hypervisor,
>     +            mode=self.zone.networktype,
>     +            method="POST"
>     +
>     +        )
>     +
>     +        self.debug("Check if the VM is properly deployed or not?")
>     +        vms = VirtualMachine.list(
>     +            self.api_client,
>     +            id=virtual_machine.id,
>     +            listall=True
>     +        )
>     +        self.assertEqual(
>     +            isinstance(vms, list),
>     +            True,
>     +            "List VMs should return the valid list"
>     +        )
>     +        vm = vms[0]
>     +        self.assertEqual(
>     +            vm.state,
>     +            "Running",
>     +            "VM state should be running after deployment"
>     +        )
>     +        virtual_machine.stop(self.api_client)
>     +        virtual_machine.update(
>     +            self.api_client,
>     +            userdata=base64.b64encode(
>     +                self.userdata))
>     +        virtual_machine.start(self.api_client)
>     +        self.assertEqual(
>     +            vm.state,
>     +            "Running",
>     +            "VM state should be running"
>     +        )
>     +        # Wait for docker service to start
>     +        time.sleep(300)
>     +
>     +        # Should be able to SSH VM
>     +        try:
>     +
>     +            self.debug("SSH into VM: %s" % virtual_machine.ssh_ip)
>     +            cmd = "docker ps"
>     +            ssh = SshClient(virtual_machine.ssh_ip, 22, "core",
>     +                            "", keyPairFiles=self.keyPairFilePath)
>     +            result = ssh.execute(cmd)
>     +
>     +        except Exception as e:
>     +            self.fail(
>     +                "SSH Access failed for %s: %s" %
>     +                (virtual_machine.ssh_ip, e)
>     +            )
>     +
>     +        res = str(result)
>     +        self.assertEqual(
>     +            res.__contains__("httpd"),
>     +            True,
>     +            "docker web service not started in coreos vm ")
>     +
>     +        if self.zone.networktype == "Basic":
>     +            list_router_response = list_routers(
>     +                self.api_client,
>     +                listall="true"
>     +            )
>     +        else:
>     +            list_router_response = list_routers(
>     +                self.api_Client,
>     --- End diff --
>
>     Will make these changes and send a new PR
>
>
> ---
> If your project is set up for it, you can reply to this email and have your
> reply appear on GitHub as well. If your project does not have this feature
> enabled and wishes so, or if the feature is enabled but not working, please
> contact infrastructure at infrastructure@apache.org or file a JIRA ticket
> with INFRA.
> ---
>

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by shwetaag <gi...@git.apache.org>.
Github user shwetaag commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1011#discussion_r51857877
  
    --- Diff: test/integration/component/test_coreos.py ---
    @@ -0,0 +1,291 @@
    +# Licensed to the Apache Software Foundation (ASF) under one
    +# or more contributor license agreements.  See the NOTICE file
    +# distributed with this work for additional information
    +# regarding copyright ownership.  The ASF licenses this file
    +# to you under the Apache License, Version 2.0 (the
    +# "License"); you may not use this file except in compliance
    +# with the License.  You may obtain a copy of the License at
    +#
    +# http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing,
    +# software distributed under the License is distributed on an
    +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +# KIND, either express or implied.  See the License for the
    +# specific language governing permissions and limitations
    +# under the License.
    +
    +""" P1 tests for coreos template and vm
    +"""
    +
    +from marvin.lib.base import (
    +    VirtualMachine,
    +    ServiceOffering,
    +    Account,
    +    SSHKeyPair,
    +    Host, Template)
    +from marvin.lib.common import (
    +    get_zone,
    +    get_template,
    +    list_routers)
    +from marvin.lib.utils import (
    +    cleanup_resources,
    +    get_hypervisor_type,
    +    get_process_status)
    +from marvin.cloudstackTestCase import cloudstackTestCase
    +# Import System modules
    +import tempfile
    +import time
    +import os
    +import base64
    +from nose.plugins.attrib import attr
    +from marvin.sshClient import SshClient
    +
    +
    +class TestDeployVmWithCoreosTemplate(cloudstackTestCase):
    +    """Tests for deploying VM  using coreos template
    +    """
    +
    +    @classmethod
    +    def setUpClass(cls):
    +        cls._cleanup = []
    +        cls.testClient = super(
    +            TestDeployVmWithCoreosTemplate,
    +            cls).getClsTestClient()
    +        cls.api_client = cls.testClient.getApiClient()
    +        cls.services = cls.testClient.getParsedTestDataConfig()
    +        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
    +        cls.service_offering = ServiceOffering.create(
    +            cls.api_client, services=cls.services["service_offerings"]["medium"])
    +        cls.account = Account.create(
    +            cls.api_client, services=cls.services["account"])
    +        cls.cleanup = [cls.account]
    +        cls.template = get_template(
    +            cls.api_client,
    +            cls.zone.id,
    +            cls.services["ostype"]
    +        )
    +        cls.services["coreos"][
    +            "hypervisor"] = cls.testClient.getHypervisorInfo()
    +        cls.userdata = '#cloud-config\n\ncoreos:\n  units:\n    - name: docker.service\n      command: start\n    ' \
    +                       '- name: web.service\n      command: start\n      content: |\n        [Unit]\n        ' \
    +                       'After=docker.service\n        Requires=docker.service\n        Description=Starts web server ' \
    +                       'container\n        [Service]\n        TimeoutStartSec=0\n        ' \
    +                       'ExecStartPre=/usr/bin/docker pull httpd:2.4\n        ' \
    +                       'ExecStart=/usr/bin/docker run -d -p 8000:80 httpd:2.4'
    +        cls.services["virtual_machine"]["userdata"] = cls.userdata
    +
    +        cls.keypair = SSHKeyPair.create(
    +            cls.api_client,
    +            name="coreos",
    +            account=cls.account.name,
    +            domainid=cls.account.domainid
    +        )
    +        cls.debug("Created a new keypair with name: %s" % cls.keypair.name)
    +
    +        cls.debug("Writing the private key to local file")
    +        cls.keyPairFilePath = tempfile.gettempdir() + os.sep + cls.keypair.name
    +        # Clenaup at end of execution
    +        cls.cleanup.append(cls.keyPairFilePath)
    +
    +        cls.debug("File path: %s" % cls.keyPairFilePath)
    +
    +        f = open(cls.keyPairFilePath, "w+")
    +        f.write(cls.keypair.privatekey)
    +        f.close()
    +        os.system("chmod 400 " + cls.keyPairFilePath)
    +        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
    +        return
    +
    +    def setUp(self):
    +        self.api_client = self.testClient.getApiClient()
    +        return
    +
    +    def tearDown(self):
    +        # Clean up, terminate the created volumes
    +        cleanup_resources(self.api_client, self.cleanup)
    +        return
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            cleanup_resources(cls.api_client, cls._cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +
    +    @attr(tags=["advanced"], required_hardware="true")
    +    def test1_coreos_VM_creation(self):
    +
    +        self.hypervisor = str(get_hypervisor_type(self.api_client)).lower()
    +        self.services["virtual_machine"][
    +            "hypervisor"] = self.hypervisor.upper()
    +        if self.hypervisor == "vmware":
    +            self.services["coreos"][
    +                "url"] = self.services["coreos"]["urlvmware"]
    +            self.services["coreos"]["format"] = "OVA"
    +        elif self.hypervisor == "xenserver":
    +            self.services["coreos"][
    +                "url"] = self.services["coreos"]["urlxen"]
    +            self.services["coreos"]["format"] = "VHD"
    +        elif self.hypervisor == "kvm":
    +            self.services["coreos"][
    +                "url"] = self.services["coreos"]["urlkvm"]
    +            self.services["coreos"]["format"] = "QCOW2"
    +        elif self.hypervisor == "hyperv":
    +            self.services["coreos"][
    +                "url"] = self.services["coreos"]["urlxen"]
    +            self.services["coreos"]["format"] = "VHD"
    +
    +        template_created = Template.register(
    +            self.api_client,
    +            self.services["coreos"],
    +            self.zone.id,
    +            account=self.account.name,
    +            domainid=self.account.domainid)
    +        self.assertIsNotNone(template_created, "Template creation failed")
    +        # Wait for template to download
    +        template_created.download(self.api_client)
    +        self.cleanup.append(template_created)
    +        # Wait for template status to be changed across
    +        time.sleep(self.services["sleep"])
    +
    +        self.debug("Deploying instance in the account: %s" % self.account.name)
    +
    +        virtual_machine = VirtualMachine.create(
    +            self.api_client,
    +            self.services["virtual_machine"],
    +            templateid=template_created.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            zoneid=self.zone.id,
    +            serviceofferingid=self.service_offering.id,
    +            keypair=self.keypair.name,
    +            hypervisor=self.hypervisor,
    +            mode=self.zone.networktype,
    +            method="POST"
    +
    +        )
    +
    +        self.debug("Check if the VM is properly deployed or not?")
    +        vms = VirtualMachine.list(
    +            self.api_client,
    +            id=virtual_machine.id,
    +            listall=True
    +        )
    +        self.assertEqual(
    +            isinstance(vms, list),
    +            True,
    +            "List VMs should return the valid list"
    +        )
    +        vm = vms[0]
    +        self.assertEqual(
    +            vm.state,
    +            "Running",
    +            "VM state should be running after deployment"
    +        )
    +        virtual_machine.stop(self.api_client)
    +        virtual_machine.update(
    +            self.api_client,
    +            userdata=base64.b64encode(
    +                self.userdata))
    +        virtual_machine.start(self.api_client)
    +        self.assertEqual(
    +            vm.state,
    +            "Running",
    +            "VM state should be running"
    +        )
    +        # Wait for docker service to start
    +        time.sleep(300)
    +
    +        # Should be able to SSH VM
    +        try:
    +
    +            self.debug("SSH into VM: %s" % virtual_machine.ssh_ip)
    +            cmd = "docker ps"
    +            ssh = SshClient(virtual_machine.ssh_ip, 22, "core",
    +                            "", keyPairFiles=self.keyPairFilePath)
    +            result = ssh.execute(cmd)
    +
    +        except Exception as e:
    +            self.fail(
    +                "SSH Access failed for %s: %s" %
    +                (virtual_machine.ssh_ip, e)
    +            )
    +
    +        res = str(result)
    +        self.assertEqual(
    +            res.__contains__("httpd"),
    +            True,
    +            "docker web service not started in coreos vm ")
    +
    +        if self.zone.networktype == "Basic":
    +            list_router_response = list_routers(
    +                self.api_client,
    +                listall="true"
    +            )
    +        else:
    +            list_router_response = list_routers(
    +                self.api_Client,
    --- End diff --
    
    Will make these changes and send a new PR


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by bhaisaab <gi...@git.apache.org>.
Github user bhaisaab commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1011#discussion_r52429712
  
    --- Diff: tools/marvin/marvin/config/test_data.py ---
    @@ -784,6 +784,18 @@
             "format": "OVA",
             "ispublic": "true"
         },
    +    "coreos": {
    +        "displaytext": "coreos",
    +        "name": "coreos",
    +        "passwordenabled": False,
    +        "ostype": "Coreos",
    +        "urlvmware":"http://10.147.28.7/templates/coreos/coreos_production_vmware.ova",
    --- End diff --
    
    Thanks @runseb for catching this.
    @sanjeevneelarapu the IP is not available for us, please host this file publicly somewhere.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by bhaisaab <gi...@git.apache.org>.
Github user bhaisaab commented on the pull request:

    https://github.com/apache/cloudstack/pull/1011#issuecomment-153681911
  
    LGTM (not tested, just reviewed code)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by runseb <gi...@git.apache.org>.
Github user runseb commented on the pull request:

    https://github.com/apache/cloudstack/pull/1011#issuecomment-182255888
  
    Please revert asap, there is an IP in there that should not be there.
    
    -1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by sanju1010 <gi...@git.apache.org>.
Github user sanju1010 commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1011#discussion_r51857735
  
    --- Diff: test/integration/component/test_coreos.py ---
    @@ -0,0 +1,291 @@
    +# Licensed to the Apache Software Foundation (ASF) under one
    +# or more contributor license agreements.  See the NOTICE file
    +# distributed with this work for additional information
    +# regarding copyright ownership.  The ASF licenses this file
    +# to you under the Apache License, Version 2.0 (the
    +# "License"); you may not use this file except in compliance
    +# with the License.  You may obtain a copy of the License at
    +#
    +# http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing,
    +# software distributed under the License is distributed on an
    +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +# KIND, either express or implied.  See the License for the
    +# specific language governing permissions and limitations
    +# under the License.
    +
    +""" P1 tests for coreos template and vm
    +"""
    +
    +from marvin.lib.base import (
    +    VirtualMachine,
    +    ServiceOffering,
    +    Account,
    +    SSHKeyPair,
    +    Host, Template)
    +from marvin.lib.common import (
    +    get_zone,
    +    get_template,
    +    list_routers)
    +from marvin.lib.utils import (
    +    cleanup_resources,
    +    get_hypervisor_type,
    +    get_process_status)
    +from marvin.cloudstackTestCase import cloudstackTestCase
    +# Import System modules
    +import tempfile
    +import time
    +import os
    +import base64
    +from nose.plugins.attrib import attr
    +from marvin.sshClient import SshClient
    +
    +
    +class TestDeployVmWithCoreosTemplate(cloudstackTestCase):
    +    """Tests for deploying VM  using coreos template
    +    """
    +
    +    @classmethod
    +    def setUpClass(cls):
    +        cls._cleanup = []
    +        cls.testClient = super(
    +            TestDeployVmWithCoreosTemplate,
    +            cls).getClsTestClient()
    +        cls.api_client = cls.testClient.getApiClient()
    +        cls.services = cls.testClient.getParsedTestDataConfig()
    +        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
    +        cls.service_offering = ServiceOffering.create(
    +            cls.api_client, services=cls.services["service_offerings"]["medium"])
    +        cls.account = Account.create(
    +            cls.api_client, services=cls.services["account"])
    +        cls.cleanup = [cls.account]
    +        cls.template = get_template(
    +            cls.api_client,
    +            cls.zone.id,
    +            cls.services["ostype"]
    +        )
    +        cls.services["coreos"][
    +            "hypervisor"] = cls.testClient.getHypervisorInfo()
    +        cls.userdata = '#cloud-config\n\ncoreos:\n  units:\n    - name: docker.service\n      command: start\n    ' \
    +                       '- name: web.service\n      command: start\n      content: |\n        [Unit]\n        ' \
    +                       'After=docker.service\n        Requires=docker.service\n        Description=Starts web server ' \
    +                       'container\n        [Service]\n        TimeoutStartSec=0\n        ' \
    +                       'ExecStartPre=/usr/bin/docker pull httpd:2.4\n        ' \
    +                       'ExecStart=/usr/bin/docker run -d -p 8000:80 httpd:2.4'
    +        cls.services["virtual_machine"]["userdata"] = cls.userdata
    +
    +        cls.keypair = SSHKeyPair.create(
    +            cls.api_client,
    +            name="coreos",
    +            account=cls.account.name,
    +            domainid=cls.account.domainid
    +        )
    +        cls.debug("Created a new keypair with name: %s" % cls.keypair.name)
    +
    +        cls.debug("Writing the private key to local file")
    +        cls.keyPairFilePath = tempfile.gettempdir() + os.sep + cls.keypair.name
    +        # Clenaup at end of execution
    +        cls.cleanup.append(cls.keyPairFilePath)
    +
    +        cls.debug("File path: %s" % cls.keyPairFilePath)
    +
    +        f = open(cls.keyPairFilePath, "w+")
    +        f.write(cls.keypair.privatekey)
    +        f.close()
    +        os.system("chmod 400 " + cls.keyPairFilePath)
    +        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
    +        return
    +
    +    def setUp(self):
    +        self.api_client = self.testClient.getApiClient()
    +        return
    +
    +    def tearDown(self):
    +        # Clean up, terminate the created volumes
    +        cleanup_resources(self.api_client, self.cleanup)
    +        return
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            cleanup_resources(cls.api_client, cls._cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +
    +    @attr(tags=["advanced"], required_hardware="true")
    +    def test1_coreos_VM_creation(self):
    +
    +        self.hypervisor = str(get_hypervisor_type(self.api_client)).lower()
    +        self.services["virtual_machine"][
    +            "hypervisor"] = self.hypervisor.upper()
    +        if self.hypervisor == "vmware":
    +            self.services["coreos"][
    +                "url"] = self.services["coreos"]["urlvmware"]
    +            self.services["coreos"]["format"] = "OVA"
    +        elif self.hypervisor == "xenserver":
    +            self.services["coreos"][
    +                "url"] = self.services["coreos"]["urlxen"]
    +            self.services["coreos"]["format"] = "VHD"
    +        elif self.hypervisor == "kvm":
    +            self.services["coreos"][
    +                "url"] = self.services["coreos"]["urlkvm"]
    +            self.services["coreos"]["format"] = "QCOW2"
    +        elif self.hypervisor == "hyperv":
    +            self.services["coreos"][
    +                "url"] = self.services["coreos"]["urlxen"]
    +            self.services["coreos"]["format"] = "VHD"
    +
    +        template_created = Template.register(
    +            self.api_client,
    +            self.services["coreos"],
    +            self.zone.id,
    +            account=self.account.name,
    +            domainid=self.account.domainid)
    +        self.assertIsNotNone(template_created, "Template creation failed")
    +        # Wait for template to download
    +        template_created.download(self.api_client)
    +        self.cleanup.append(template_created)
    +        # Wait for template status to be changed across
    +        time.sleep(self.services["sleep"])
    +
    +        self.debug("Deploying instance in the account: %s" % self.account.name)
    +
    +        virtual_machine = VirtualMachine.create(
    +            self.api_client,
    +            self.services["virtual_machine"],
    +            templateid=template_created.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            zoneid=self.zone.id,
    +            serviceofferingid=self.service_offering.id,
    +            keypair=self.keypair.name,
    +            hypervisor=self.hypervisor,
    +            mode=self.zone.networktype,
    +            method="POST"
    +
    +        )
    +
    +        self.debug("Check if the VM is properly deployed or not?")
    +        vms = VirtualMachine.list(
    +            self.api_client,
    +            id=virtual_machine.id,
    +            listall=True
    +        )
    +        self.assertEqual(
    +            isinstance(vms, list),
    +            True,
    +            "List VMs should return the valid list"
    +        )
    +        vm = vms[0]
    +        self.assertEqual(
    +            vm.state,
    +            "Running",
    +            "VM state should be running after deployment"
    +        )
    +        virtual_machine.stop(self.api_client)
    +        virtual_machine.update(
    +            self.api_client,
    +            userdata=base64.b64encode(
    +                self.userdata))
    +        virtual_machine.start(self.api_client)
    +        self.assertEqual(
    +            vm.state,
    +            "Running",
    +            "VM state should be running"
    +        )
    +        # Wait for docker service to start
    +        time.sleep(300)
    +
    +        # Should be able to SSH VM
    +        try:
    +
    +            self.debug("SSH into VM: %s" % virtual_machine.ssh_ip)
    +            cmd = "docker ps"
    +            ssh = SshClient(virtual_machine.ssh_ip, 22, "core",
    +                            "", keyPairFiles=self.keyPairFilePath)
    +            result = ssh.execute(cmd)
    +
    +        except Exception as e:
    +            self.fail(
    +                "SSH Access failed for %s: %s" %
    +                (virtual_machine.ssh_ip, e)
    +            )
    +
    +        res = str(result)
    +        self.assertEqual(
    +            res.__contains__("httpd"),
    +            True,
    +            "docker web service not started in coreos vm ")
    +
    +        if self.zone.networktype == "Basic":
    +            list_router_response = list_routers(
    +                self.api_client,
    +                listall="true"
    +            )
    +        else:
    +            list_router_response = list_routers(
    +                self.api_Client,
    --- End diff --
    
    Replace self.api_Client with self.api_client


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by remibergsma <gi...@git.apache.org>.
Github user remibergsma commented on the pull request:

    https://github.com/apache/cloudstack/pull/1011#issuecomment-182276612
  
    @runseb Totally agree, reverted merge.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by bhaisaab <gi...@git.apache.org>.
Github user bhaisaab commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1011#discussion_r52429775
  
    --- Diff: tools/marvin/marvin/config/test_data.py ---
    @@ -784,6 +784,18 @@
             "format": "OVA",
             "ispublic": "true"
         },
    +    "coreos": {
    +        "displaytext": "coreos",
    +        "name": "coreos",
    +        "passwordenabled": False,
    +        "ostype": "Coreos",
    +        "urlvmware":"http://10.147.28.7/templates/coreos/coreos_production_vmware.ova",
    --- End diff --
    
    cc @NuxRo I think the openvm hosted files for vmware are in wrong format (need ova instead of vmdk) which is why a local file has been used here


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by NuxRo <gi...@git.apache.org>.
Github user NuxRo commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1011#discussion_r52766006
  
    --- Diff: tools/marvin/marvin/config/test_data.py ---
    @@ -784,6 +784,18 @@
             "format": "OVA",
             "ispublic": "true"
         },
    +    "coreos": {
    +        "displaytext": "coreos",
    +        "name": "coreos",
    +        "passwordenabled": False,
    +        "ostype": "Coreos",
    +        "urlvmware":"http://10.147.28.7/templates/coreos/coreos_production_vmware.ova",
    --- End diff --
    
    I am now building OVA files for my templates, CoreOS is done, soon the other OSes as well.
    
    Thanks for the help with the conversion script.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by sanju1010 <gi...@git.apache.org>.
Github user sanju1010 commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1011#discussion_r51857784
  
    --- Diff: tools/marvin/marvin/config/test_data.py ---
    @@ -784,6 +784,19 @@
             "format": "OVA",
             "ispublic": "true"
         },
    +    "coreos": {
    +        "displaytext": "coreos",
    +        "name": "coreos",
    +        "passwordenabled": False,
    +        "ostype": "Coreos",
    +        "urlvmware":"http://dl.openvm.eu/cloudstack/coreos/x86_64/" \
    +                         "coreos_production_cloudstack_image-vmware.vmdk.bz2",
    --- End diff --
    
    Replace the URL with .ova file


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by bhaisaab <gi...@git.apache.org>.
Github user bhaisaab commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1011#discussion_r52769282
  
    --- Diff: tools/marvin/marvin/config/test_data.py ---
    @@ -784,6 +784,18 @@
             "format": "OVA",
             "ispublic": "true"
         },
    +    "coreos": {
    +        "displaytext": "coreos",
    +        "name": "coreos",
    +        "passwordenabled": False,
    +        "ostype": "Coreos",
    +        "urlvmware":"http://10.147.28.7/templates/coreos/coreos_production_vmware.ova",
    --- End diff --
    
    Great, thanks @NuxRo 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-9012 :automation of cores feat...

Posted by shwetaag <gi...@git.apache.org>.
Github user shwetaag commented on the pull request:

    https://github.com/apache/cloudstack/pull/1011#issuecomment-152510674
  
    pasting result.txt
    
    test1_coreos_VM_creation (integration.component.test_coreos.TestDeployVmWithCoreosTemplate) ... === TestName: test1_coreos_VM_creation | Status : SUCCESS ===
    ok
    
    ----------------------------------------------------------------------
    Ran 1 test in 838.303s
    
    OK



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---