You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by pritisarap12 <gi...@git.apache.org> on 2015/05/21 12:02:13 UTC

[GitHub] cloudstack pull request: CLOUDSTACK-8476-Disable enable host:

GitHub user pritisarap12 opened a pull request:

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

    CLOUDSTACK-8476-Disable enable host:

            --Test cases for testing the behaviour of resources running on
                host and admin/non-admin user after disabling the Host

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

    $ git pull https://github.com/pritisarap12/cloudstack Disable-Enable-Host

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

    https://github.com/apache/cloudstack/pull/278.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 #278
    
----
commit d84b03c2c37d39e221a79433ee41cdae607f4ffb
Author: pritisarap12 <pr...@clogeny.com>
Date:   2015-05-21T09:59:14Z

    CLOUDSTACK-8476-Disable enable host:
    
            --Test cases for testing the behaviour of resources running on
                host and admin/non-admin user after disabling the Host

----


---
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-8476-Disable enable host:

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

    https://github.com/apache/cloudstack/pull/278#issuecomment-104519494
  
    Can this test class be included in the same test suite that has been previously added? (related to disabling zones etc)


---
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-8476-Disable enable host:

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

    https://github.com/apache/cloudstack/pull/278#discussion_r30870576
  
    --- Diff: test/integration/component/maint/testpath_disable_enable_host.py ---
    @@ -0,0 +1,309 @@
    +# 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.
    +""" Test cases for Disable enable Host Test Path
    +"""
    +
    +from nose.plugins.attrib import attr
    +from marvin.cloudstackTestCase import cloudstackTestCase
    +from marvin.lib.utils import (cleanup_resources)
    +from marvin.lib.base import (Account,
    +                             Host,
    +                             Cluster,
    +                             VirtualMachine,
    +                             ServiceOffering,
    +                             Snapshot,
    +                             DiskOffering,
    +                             )
    +from marvin.lib.common import (get_domain,
    +                               get_zone,
    +                               get_template,
    +                               get_pod,
    +                               list_volumes,
    +                               )
    +
    +from marvin.cloudstackAPI import (updateHost,
    +                                  reconnectHost
    +                                  )
    +import time
    +
    +
    +class TestDisableEnableZone(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +        testClient = super(TestDisableEnableZone, cls).getClsTestClient()
    +        cls.apiclient = testClient.getApiClient()
    +        cls.testdata = testClient.getParsedTestDataConfig()
    +        cls.hypervisor = cls.testClient.getHypervisorInfo()
    +
    +        # Get Zone, Domain and templates
    +        cls.domain = get_domain(cls.apiclient)
    +        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
    +        cls.pod = get_pod(
    +            cls.apiclient,
    +            zone_id=cls.zone.id)
    +
    +        hostList = Host.list(cls.apiclient, zoneid=cls.zone.id, type="routing")
    +        clusterList = Cluster.list(cls.apiclient, id=hostList[0].clusterid)
    +        cls.host = Host(hostList[0].__dict__)
    +        cls.cluster = Cluster(clusterList[0].__dict__)
    +
    +        cls.template = get_template(
    +            cls.apiclient,
    +            cls.zone.id,
    +            cls.testdata["ostype"])
    +
    +        cls._cleanup = []
    +
    +        try:
    +            cls.service_offering = ServiceOffering.create(
    +                cls.apiclient,
    +                cls.testdata["service_offering"],
    +            )
    +            cls._cleanup.append(cls.service_offering)
    +
    +            cls.disk_offering = DiskOffering.create(
    +                cls.apiclient,
    +                cls.testdata["disk_offering"],
    +            )
    +            cls._cleanup.append(cls.disk_offering)
    +
    +            # Create an account
    +            cls.account = Account.create(
    +                cls.apiclient,
    +                cls.testdata["account"],
    +                domainid=cls.domain.id
    +            )
    +            cls._cleanup.append(cls.account)
    +
    +            # Create user api client of the account
    +            cls.userapiclient = testClient.getUserApiClient(
    +                UserName=cls.account.name,
    +                DomainName=cls.account.domain
    +            )
    +
    +        except Exception as e:
    +            cls.tearDownClass()
    +            raise e
    +        return
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            pass
    +            cleanup_resources(cls.apiclient, cls._cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +
    +    def setUp(self):
    +        self.apiclient = self.testClient.getApiClient()
    +        self.dbclient = self.testClient.getDbConnection()
    +        self.cleanup = []
    +
    +    def tearDown(self):
    +        try:
    +            cleanup_resources(self.apiclient, self.cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +
    +    @attr(tags=["advanced", "basic"], required_hardware="true")
    +    def test_01_disable_enable_host(self):
    +        """disable enable host
    +            1. Disable host and verify following things:
    +                For admin user:
    +                    1. Should be create to start/stop exsiting vms
    +                    2. Should be create to deploy new vm,
    +                    snapshot on the same host
    +                For Non-admin user:
    +                    1. Should be create to start/stop exsiting vms
    +                    2. Should not be create to deploy new vm,
    +                    snapshot on the same host
    +            2. Enable the above disabled host and verify that:
    +                -All users should be create to deploy new vm,
    +                snapshot on the same host
    +            3. Try to reconnect the host :
    +                -Host should get reconnected successfully
    +        """
    +        # Step 1
    +        vm_root = VirtualMachine.create(
    +            self.apiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +        )
    +        hostid = vm_root.hostid
    +
    +        vm_user = VirtualMachine.create(
    +            self.userapiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +        )
    +
    +        cmd = updateHost.updateHostCmd()
    +        cmd.id = hostid
    +        cmd.resourcestate = "Disabled"
    +        cmd.allocationstate = "Disable"
    +        self.apiclient.updateHost(cmd)
    +        hostList = Host.list(self.apiclient, id=hostid)
    +
    +        self.assertEqual(hostList[0].resourcestate,
    +                         "Disabled",
    +                         "Check if the host is in disabled state"
    +                         )
    +        # Verify the exsisting vms should be running
    +        self.assertEqual(vm_user.state,
    +                         "Running",
    +                         "Verify that the user vm is running")
    +
    +        self.assertEqual(vm_root.state,
    +                         "Running",
    +                         "Verify that the root vm is running")
    +
    +        vm_root.stop(self.apiclient)
    +        vm_user.stop(self.apiclient)
    +        root_state = self.dbclient.execute(
    +            "select state from vm_instance where name='%s'" %
    +            vm_root.name)[0][0]
    +        user_state = self.dbclient.execute(
    +            "select state from vm_instance where name='%s'" %
    +            vm_user.name)[0][0]
    +
    +        self.assertEqual(root_state,
    +                         "Stopped",
    +                         "verify that vm should stop")
    +
    +        self.assertEqual(user_state,
    +                         "Stopped",
    +                         "verify that vm should stop")
    +
    +        VirtualMachine.create(
    +            self.apiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +            hostid=hostid)
    +
    +        root_volume = list_volumes(
    +            self.apiclient,
    +            virtualmachineid=vm_root.id,
    +            type='ROOT',
    +            listall=True
    +        )
    +
    +        snap = Snapshot.create(
    +            self.apiclient,
    +            root_volume[0].id)
    +
    +        self.assertNotEqual(snap,
    +                            None,
    +                            "Verify that admin should be \
    +                                    able to create snapshot")
    +
    +        # non-admin user should fail to create vm, snap, temp etc
    +
    +        with self.assertRaises(Exception):
    +            snap = Snapshot.create(
    +                self.userapiclient,
    +                root_volume[0].id)
    +
    +        # Step 2
    +        cmd.resourcestate = "Enabled"
    +        cmd.allocationstate = "Enable"
    +        self.apiclient.updateHost(cmd)
    +
    +        hostList = Host.list(self.apiclient, id=hostid)
    +
    +        self.assertEqual(hostList[0].resourcestate,
    +                         "Enabled",
    +                         "Check if the host is in enabled state"
    +                         )
    +        # After enabling the zone all users should be able to add new VM,
    +        # volume, templatee and iso
    +
    +        root_vm_new = VirtualMachine.create(
    +            self.apiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +            hostid=hostid)
    +
    +        self.assertNotEqual(root_vm_new,
    --- End diff --
    
    Assert not needed


---
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-8476-Disable enable host:

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

    https://github.com/apache/cloudstack/pull/278#discussion_r30870172
  
    --- Diff: test/integration/component/maint/testpath_disable_enable_host.py ---
    @@ -0,0 +1,309 @@
    +# 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.
    +""" Test cases for Disable enable Host Test Path
    +"""
    +
    +from nose.plugins.attrib import attr
    +from marvin.cloudstackTestCase import cloudstackTestCase
    +from marvin.lib.utils import (cleanup_resources)
    +from marvin.lib.base import (Account,
    +                             Host,
    +                             Cluster,
    +                             VirtualMachine,
    +                             ServiceOffering,
    +                             Snapshot,
    +                             DiskOffering,
    +                             )
    +from marvin.lib.common import (get_domain,
    +                               get_zone,
    +                               get_template,
    +                               get_pod,
    +                               list_volumes,
    +                               )
    +
    +from marvin.cloudstackAPI import (updateHost,
    +                                  reconnectHost
    +                                  )
    +import time
    +
    +
    +class TestDisableEnableZone(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +        testClient = super(TestDisableEnableZone, cls).getClsTestClient()
    +        cls.apiclient = testClient.getApiClient()
    +        cls.testdata = testClient.getParsedTestDataConfig()
    +        cls.hypervisor = cls.testClient.getHypervisorInfo()
    +
    +        # Get Zone, Domain and templates
    +        cls.domain = get_domain(cls.apiclient)
    +        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
    +        cls.pod = get_pod(
    +            cls.apiclient,
    +            zone_id=cls.zone.id)
    +
    +        hostList = Host.list(cls.apiclient, zoneid=cls.zone.id, type="routing")
    +        clusterList = Cluster.list(cls.apiclient, id=hostList[0].clusterid)
    +        cls.host = Host(hostList[0].__dict__)
    +        cls.cluster = Cluster(clusterList[0].__dict__)
    +
    +        cls.template = get_template(
    +            cls.apiclient,
    +            cls.zone.id,
    +            cls.testdata["ostype"])
    +
    +        cls._cleanup = []
    +
    +        try:
    +            cls.service_offering = ServiceOffering.create(
    +                cls.apiclient,
    +                cls.testdata["service_offering"],
    +            )
    +            cls._cleanup.append(cls.service_offering)
    +
    +            cls.disk_offering = DiskOffering.create(
    +                cls.apiclient,
    +                cls.testdata["disk_offering"],
    +            )
    +            cls._cleanup.append(cls.disk_offering)
    +
    +            # Create an account
    +            cls.account = Account.create(
    +                cls.apiclient,
    +                cls.testdata["account"],
    +                domainid=cls.domain.id
    +            )
    +            cls._cleanup.append(cls.account)
    +
    +            # Create user api client of the account
    +            cls.userapiclient = testClient.getUserApiClient(
    +                UserName=cls.account.name,
    +                DomainName=cls.account.domain
    +            )
    +
    +        except Exception as e:
    +            cls.tearDownClass()
    +            raise e
    +        return
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            pass
    +            cleanup_resources(cls.apiclient, cls._cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +
    +    def setUp(self):
    +        self.apiclient = self.testClient.getApiClient()
    +        self.dbclient = self.testClient.getDbConnection()
    +        self.cleanup = []
    +
    +    def tearDown(self):
    +        try:
    +            cleanup_resources(self.apiclient, self.cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +
    +    @attr(tags=["advanced", "basic"], required_hardware="true")
    +    def test_01_disable_enable_host(self):
    +        """disable enable host
    +            1. Disable host and verify following things:
    +                For admin user:
    +                    1. Should be create to start/stop exsiting vms
    +                    2. Should be create to deploy new vm,
    +                    snapshot on the same host
    +                For Non-admin user:
    +                    1. Should be create to start/stop exsiting vms
    +                    2. Should not be create to deploy new vm,
    +                    snapshot on the same host
    +            2. Enable the above disabled host and verify that:
    +                -All users should be create to deploy new vm,
    +                snapshot on the same host
    +            3. Try to reconnect the host :
    +                -Host should get reconnected successfully
    +        """
    +        # Step 1
    +        vm_root = VirtualMachine.create(
    +            self.apiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +        )
    +        hostid = vm_root.hostid
    +
    +        vm_user = VirtualMachine.create(
    +            self.userapiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +        )
    +
    +        cmd = updateHost.updateHostCmd()
    +        cmd.id = hostid
    +        cmd.resourcestate = "Disabled"
    +        cmd.allocationstate = "Disable"
    +        self.apiclient.updateHost(cmd)
    +        hostList = Host.list(self.apiclient, id=hostid)
    +
    +        self.assertEqual(hostList[0].resourcestate,
    +                         "Disabled",
    +                         "Check if the host is in disabled state"
    +                         )
    +        # Verify the exsisting vms should be running
    +        self.assertEqual(vm_user.state,
    +                         "Running",
    --- End diff --
    
    Use constant string from codes.py and also compare string by converting both to lowercase. Change everywhere applicable


---
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-8476-Disable enable host:

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

    https://github.com/apache/cloudstack/pull/278#discussion_r30870155
  
    --- Diff: test/integration/component/maint/testpath_disable_enable_host.py ---
    @@ -0,0 +1,309 @@
    +# 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.
    +""" Test cases for Disable enable Host Test Path
    +"""
    +
    +from nose.plugins.attrib import attr
    +from marvin.cloudstackTestCase import cloudstackTestCase
    +from marvin.lib.utils import (cleanup_resources)
    +from marvin.lib.base import (Account,
    +                             Host,
    +                             Cluster,
    +                             VirtualMachine,
    +                             ServiceOffering,
    +                             Snapshot,
    +                             DiskOffering,
    +                             )
    +from marvin.lib.common import (get_domain,
    +                               get_zone,
    +                               get_template,
    +                               get_pod,
    +                               list_volumes,
    +                               )
    +
    +from marvin.cloudstackAPI import (updateHost,
    +                                  reconnectHost
    +                                  )
    +import time
    +
    +
    +class TestDisableEnableZone(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +        testClient = super(TestDisableEnableZone, cls).getClsTestClient()
    +        cls.apiclient = testClient.getApiClient()
    +        cls.testdata = testClient.getParsedTestDataConfig()
    +        cls.hypervisor = cls.testClient.getHypervisorInfo()
    +
    +        # Get Zone, Domain and templates
    +        cls.domain = get_domain(cls.apiclient)
    +        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
    +        cls.pod = get_pod(
    +            cls.apiclient,
    +            zone_id=cls.zone.id)
    +
    +        hostList = Host.list(cls.apiclient, zoneid=cls.zone.id, type="routing")
    +        clusterList = Cluster.list(cls.apiclient, id=hostList[0].clusterid)
    +        cls.host = Host(hostList[0].__dict__)
    +        cls.cluster = Cluster(clusterList[0].__dict__)
    +
    +        cls.template = get_template(
    +            cls.apiclient,
    +            cls.zone.id,
    +            cls.testdata["ostype"])
    +
    +        cls._cleanup = []
    +
    +        try:
    +            cls.service_offering = ServiceOffering.create(
    +                cls.apiclient,
    +                cls.testdata["service_offering"],
    +            )
    +            cls._cleanup.append(cls.service_offering)
    +
    +            cls.disk_offering = DiskOffering.create(
    +                cls.apiclient,
    +                cls.testdata["disk_offering"],
    +            )
    +            cls._cleanup.append(cls.disk_offering)
    +
    +            # Create an account
    +            cls.account = Account.create(
    +                cls.apiclient,
    +                cls.testdata["account"],
    +                domainid=cls.domain.id
    +            )
    +            cls._cleanup.append(cls.account)
    +
    +            # Create user api client of the account
    +            cls.userapiclient = testClient.getUserApiClient(
    +                UserName=cls.account.name,
    +                DomainName=cls.account.domain
    +            )
    +
    +        except Exception as e:
    +            cls.tearDownClass()
    +            raise e
    +        return
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            pass
    +            cleanup_resources(cls.apiclient, cls._cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +
    +    def setUp(self):
    +        self.apiclient = self.testClient.getApiClient()
    +        self.dbclient = self.testClient.getDbConnection()
    +        self.cleanup = []
    +
    +    def tearDown(self):
    +        try:
    +            cleanup_resources(self.apiclient, self.cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +
    +    @attr(tags=["advanced", "basic"], required_hardware="true")
    +    def test_01_disable_enable_host(self):
    +        """disable enable host
    +            1. Disable host and verify following things:
    +                For admin user:
    +                    1. Should be create to start/stop exsiting vms
    +                    2. Should be create to deploy new vm,
    +                    snapshot on the same host
    +                For Non-admin user:
    +                    1. Should be create to start/stop exsiting vms
    +                    2. Should not be create to deploy new vm,
    +                    snapshot on the same host
    +            2. Enable the above disabled host and verify that:
    +                -All users should be create to deploy new vm,
    +                snapshot on the same host
    +            3. Try to reconnect the host :
    +                -Host should get reconnected successfully
    +        """
    +        # Step 1
    +        vm_root = VirtualMachine.create(
    +            self.apiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +        )
    +        hostid = vm_root.hostid
    +
    +        vm_user = VirtualMachine.create(
    +            self.userapiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +        )
    +
    +        cmd = updateHost.updateHostCmd()
    +        cmd.id = hostid
    +        cmd.resourcestate = "Disabled"
    --- End diff --
    
    Move Disabled to codes.py file as constant string


---
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-8476-Disable enable host:

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

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


---
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-8476-Disable enable host:

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

    https://github.com/apache/cloudstack/pull/278#discussion_r30870199
  
    --- Diff: test/integration/component/maint/testpath_disable_enable_host.py ---
    @@ -0,0 +1,309 @@
    +# 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.
    +""" Test cases for Disable enable Host Test Path
    +"""
    +
    +from nose.plugins.attrib import attr
    +from marvin.cloudstackTestCase import cloudstackTestCase
    +from marvin.lib.utils import (cleanup_resources)
    +from marvin.lib.base import (Account,
    +                             Host,
    +                             Cluster,
    +                             VirtualMachine,
    +                             ServiceOffering,
    +                             Snapshot,
    +                             DiskOffering,
    +                             )
    +from marvin.lib.common import (get_domain,
    +                               get_zone,
    +                               get_template,
    +                               get_pod,
    +                               list_volumes,
    +                               )
    +
    +from marvin.cloudstackAPI import (updateHost,
    +                                  reconnectHost
    +                                  )
    +import time
    +
    +
    +class TestDisableEnableZone(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +        testClient = super(TestDisableEnableZone, cls).getClsTestClient()
    +        cls.apiclient = testClient.getApiClient()
    +        cls.testdata = testClient.getParsedTestDataConfig()
    +        cls.hypervisor = cls.testClient.getHypervisorInfo()
    +
    +        # Get Zone, Domain and templates
    +        cls.domain = get_domain(cls.apiclient)
    +        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
    +        cls.pod = get_pod(
    +            cls.apiclient,
    +            zone_id=cls.zone.id)
    +
    +        hostList = Host.list(cls.apiclient, zoneid=cls.zone.id, type="routing")
    +        clusterList = Cluster.list(cls.apiclient, id=hostList[0].clusterid)
    +        cls.host = Host(hostList[0].__dict__)
    +        cls.cluster = Cluster(clusterList[0].__dict__)
    +
    +        cls.template = get_template(
    +            cls.apiclient,
    +            cls.zone.id,
    +            cls.testdata["ostype"])
    +
    +        cls._cleanup = []
    +
    +        try:
    +            cls.service_offering = ServiceOffering.create(
    +                cls.apiclient,
    +                cls.testdata["service_offering"],
    +            )
    +            cls._cleanup.append(cls.service_offering)
    +
    +            cls.disk_offering = DiskOffering.create(
    +                cls.apiclient,
    +                cls.testdata["disk_offering"],
    +            )
    +            cls._cleanup.append(cls.disk_offering)
    +
    +            # Create an account
    +            cls.account = Account.create(
    +                cls.apiclient,
    +                cls.testdata["account"],
    +                domainid=cls.domain.id
    +            )
    +            cls._cleanup.append(cls.account)
    +
    +            # Create user api client of the account
    +            cls.userapiclient = testClient.getUserApiClient(
    +                UserName=cls.account.name,
    +                DomainName=cls.account.domain
    +            )
    +
    +        except Exception as e:
    +            cls.tearDownClass()
    +            raise e
    +        return
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            pass
    +            cleanup_resources(cls.apiclient, cls._cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +
    +    def setUp(self):
    +        self.apiclient = self.testClient.getApiClient()
    +        self.dbclient = self.testClient.getDbConnection()
    +        self.cleanup = []
    +
    +    def tearDown(self):
    +        try:
    +            cleanup_resources(self.apiclient, self.cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +
    +    @attr(tags=["advanced", "basic"], required_hardware="true")
    +    def test_01_disable_enable_host(self):
    +        """disable enable host
    +            1. Disable host and verify following things:
    +                For admin user:
    +                    1. Should be create to start/stop exsiting vms
    +                    2. Should be create to deploy new vm,
    +                    snapshot on the same host
    +                For Non-admin user:
    +                    1. Should be create to start/stop exsiting vms
    +                    2. Should not be create to deploy new vm,
    +                    snapshot on the same host
    +            2. Enable the above disabled host and verify that:
    +                -All users should be create to deploy new vm,
    +                snapshot on the same host
    +            3. Try to reconnect the host :
    +                -Host should get reconnected successfully
    +        """
    +        # Step 1
    +        vm_root = VirtualMachine.create(
    +            self.apiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +        )
    +        hostid = vm_root.hostid
    +
    +        vm_user = VirtualMachine.create(
    +            self.userapiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +        )
    +
    +        cmd = updateHost.updateHostCmd()
    +        cmd.id = hostid
    +        cmd.resourcestate = "Disabled"
    +        cmd.allocationstate = "Disable"
    +        self.apiclient.updateHost(cmd)
    +        hostList = Host.list(self.apiclient, id=hostid)
    +
    +        self.assertEqual(hostList[0].resourcestate,
    +                         "Disabled",
    +                         "Check if the host is in disabled state"
    +                         )
    +        # Verify the exsisting vms should be running
    +        self.assertEqual(vm_user.state,
    +                         "Running",
    +                         "Verify that the user vm is running")
    +
    +        self.assertEqual(vm_root.state,
    +                         "Running",
    +                         "Verify that the root vm is running")
    +
    +        vm_root.stop(self.apiclient)
    +        vm_user.stop(self.apiclient)
    +        root_state = self.dbclient.execute(
    +            "select state from vm_instance where name='%s'" %
    +            vm_root.name)[0][0]
    +        user_state = self.dbclient.execute(
    +            "select state from vm_instance where name='%s'" %
    +            vm_user.name)[0][0]
    +
    +        self.assertEqual(root_state,
    +                         "Stopped",
    +                         "verify that vm should stop")
    +
    +        self.assertEqual(user_state,
    +                         "Stopped",
    +                         "verify that vm should stop")
    +
    +        VirtualMachine.create(
    +            self.apiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +            hostid=hostid)
    +
    +        root_volume = list_volumes(
    +            self.apiclient,
    +            virtualmachineid=vm_root.id,
    +            type='ROOT',
    +            listall=True
    +        )
    +
    +        snap = Snapshot.create(
    +            self.apiclient,
    +            root_volume[0].id)
    +
    +        self.assertNotEqual(snap,
    --- End diff --
    
    No need of this assert. When snapshot creation fails, base.py won't return None, it will throw exception directly


---
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-8476-Disable enable host:

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

    https://github.com/apache/cloudstack/pull/278#discussion_r30870128
  
    --- Diff: test/integration/component/maint/testpath_disable_enable_host.py ---
    @@ -0,0 +1,309 @@
    +# 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.
    +""" Test cases for Disable enable Host Test Path
    +"""
    +
    +from nose.plugins.attrib import attr
    +from marvin.cloudstackTestCase import cloudstackTestCase
    +from marvin.lib.utils import (cleanup_resources)
    +from marvin.lib.base import (Account,
    +                             Host,
    +                             Cluster,
    +                             VirtualMachine,
    +                             ServiceOffering,
    +                             Snapshot,
    +                             DiskOffering,
    +                             )
    +from marvin.lib.common import (get_domain,
    +                               get_zone,
    +                               get_template,
    +                               get_pod,
    +                               list_volumes,
    +                               )
    +
    +from marvin.cloudstackAPI import (updateHost,
    +                                  reconnectHost
    +                                  )
    +import time
    +
    +
    +class TestDisableEnableZone(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +        testClient = super(TestDisableEnableZone, cls).getClsTestClient()
    +        cls.apiclient = testClient.getApiClient()
    +        cls.testdata = testClient.getParsedTestDataConfig()
    +        cls.hypervisor = cls.testClient.getHypervisorInfo()
    +
    +        # Get Zone, Domain and templates
    +        cls.domain = get_domain(cls.apiclient)
    +        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
    +        cls.pod = get_pod(
    +            cls.apiclient,
    +            zone_id=cls.zone.id)
    +
    +        hostList = Host.list(cls.apiclient, zoneid=cls.zone.id, type="routing")
    +        clusterList = Cluster.list(cls.apiclient, id=hostList[0].clusterid)
    +        cls.host = Host(hostList[0].__dict__)
    +        cls.cluster = Cluster(clusterList[0].__dict__)
    +
    +        cls.template = get_template(
    +            cls.apiclient,
    +            cls.zone.id,
    +            cls.testdata["ostype"])
    +
    +        cls._cleanup = []
    +
    +        try:
    +            cls.service_offering = ServiceOffering.create(
    +                cls.apiclient,
    +                cls.testdata["service_offering"],
    +            )
    +            cls._cleanup.append(cls.service_offering)
    +
    +            cls.disk_offering = DiskOffering.create(
    +                cls.apiclient,
    +                cls.testdata["disk_offering"],
    +            )
    +            cls._cleanup.append(cls.disk_offering)
    +
    +            # Create an account
    +            cls.account = Account.create(
    +                cls.apiclient,
    +                cls.testdata["account"],
    +                domainid=cls.domain.id
    +            )
    +            cls._cleanup.append(cls.account)
    +
    +            # Create user api client of the account
    +            cls.userapiclient = testClient.getUserApiClient(
    +                UserName=cls.account.name,
    +                DomainName=cls.account.domain
    +            )
    +
    +        except Exception as e:
    +            cls.tearDownClass()
    +            raise e
    +        return
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            pass
    --- End diff --
    
    why pass?


---
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.
---