Exemplo n.º 1
0
    def test_instance_details_metadata(self):
        server = self.servers.first()

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.volume_instance_list(IsA(http.HttpRequest),
                               server.id).AndReturn([])
        api.flavor_get(IsA(http.HttpRequest),
                       server.flavor['id']).AndReturn(self.flavors.first())
        api.server_security_groups(IsA(http.HttpRequest),
                       server.id).AndReturn(self.security_groups.list())

        self.mox.ReplayAll()

        url = reverse('horizon:nova:instances:detail',
                      args=[server.id])
        tg = InstanceDetailTabs(self.request, instance=server)
        qs = "?%s=%s" % (tg.param_name, tg.get_tab("overview").get_id())
        res = self.client.get(url + qs)

        self.assertContains(res, "<dd>keyName</dd>", 1)
        self.assertContains(res, "<dt>someMetaLabel</dt>", 1)
        self.assertContains(res, "<dd>someMetaData</dd>", 1)
        self.assertContains(res, "<dt>some&lt;b&gt;html&lt;/b&gt;label</dt>",
                            1)
        self.assertContains(res, "<dd>&lt;!--</dd>", 1)
        self.assertContains(res, "<dt>empty</dt>", 1)
        self.assertContains(res, "<dd><em>N/A</em></dd>", 1)
Exemplo n.º 2
0
    def test_instance_details_volumes(self):
        server = self.servers.first()
        volumes = deepcopy(self.volumes.list())
        volumes[0].device = "/dev/hdk"
        second_vol = deepcopy(volumes[0])
        second_vol.id = 2
        second_vol.device = "/dev/hdb"
        volumes.append(second_vol)

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.volume_instance_list(IsA(http.HttpRequest),
                               server.id).AndReturn(volumes)
        api.flavor_get(IsA(http.HttpRequest),
                       server.flavor['id']).AndReturn(self.flavors.first())
        api.server_security_groups(IsA(http.HttpRequest),
                       server.id).AndReturn(self.security_groups.first())

        self.mox.ReplayAll()

        url = reverse('horizon:nova:instances_and_volumes:instances:detail',
                      args=[server.id])
        res = self.client.get(url)
        self.assertItemsEqual(res.context['instance'].volumes, volumes)
        # Test device ordering
        self.assertEquals(res.context['instance'].volumes[0].device,
                          "/dev/hdb")
        self.assertEquals(res.context['instance'].volumes[1].device,
                          "/dev/hdk")
Exemplo n.º 3
0
    def test_instance_details_volumes(self):
        server = self.servers.first()
        volumes = deepcopy(self.volumes.list())
        volumes[0].device = "/dev/hdk"
        second_vol = deepcopy(volumes[0])
        second_vol.id = 2
        second_vol.device = "/dev/hdb"
        volumes.append(second_vol)

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.volume_instance_list(IsA(http.HttpRequest),
                                 server.id).AndReturn(volumes)
        api.flavor_get(IsA(http.HttpRequest),
                       server.flavor['id']).AndReturn(self.flavors.first())
        api.server_security_groups(IsA(http.HttpRequest), server.id).AndReturn(
            self.security_groups.first())

        self.mox.ReplayAll()

        url = reverse('horizon:nova:instances_and_volumes:instances:detail',
                      args=[server.id])
        res = self.client.get(url)
        self.assertItemsEqual(res.context['instance'].volumes, volumes)
        # Test device ordering
        self.assertEquals(res.context['instance'].volumes[0].device,
                          "/dev/hdb")
        self.assertEquals(res.context['instance'].volumes[1].device,
                          "/dev/hdk")
Exemplo n.º 4
0
    def test_instance_details_volumes(self):
        server = self.servers.first()
        volumes = [self.volumes.list()[1]]

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.volume_instance_list(IsA(http.HttpRequest), server.id).AndReturn(volumes)
        api.flavor_get(IsA(http.HttpRequest), server.flavor["id"]).AndReturn(self.flavors.first())
        api.server_security_groups(IsA(http.HttpRequest), server.id).AndReturn(self.security_groups.first())

        self.mox.ReplayAll()

        url = reverse("horizon:project:instances:detail", args=[server.id])
        res = self.client.get(url)

        self.assertItemsEqual(res.context["instance"].volumes, volumes)
Exemplo n.º 5
0
    def test_instance_details_volumes(self):
        server = self.servers.first()
        volumes = [self.volumes.list()[1]]

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.volume_instance_list(IsA(http.HttpRequest),
                               server.id).AndReturn(volumes)
        api.flavor_get(IsA(http.HttpRequest),
                       server.flavor['id']).AndReturn(self.flavors.first())
        api.server_security_groups(IsA(http.HttpRequest),
                       server.id).AndReturn(self.security_groups.first())

        self.mox.ReplayAll()

        url = reverse('horizon:nova:instances:detail',
                      args=[server.id])
        res = self.client.get(url)

        self.assertItemsEqual(res.context['instance'].volumes, volumes)
Exemplo n.º 6
0
    def test_instance_details_volume_sorting(self):
        server = self.servers.first()
        volumes = self.volumes.list()[1:3]

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.volume_instance_list(IsA(http.HttpRequest),
                               server.id).AndReturn(volumes)
        api.flavor_get(IsA(http.HttpRequest),
                       server.flavor['id']).AndReturn(self.flavors.first())
        api.server_security_groups(IsA(http.HttpRequest),
                       server.id).AndReturn(self.security_groups.first())

        self.mox.ReplayAll()

        url = reverse('horizon:nova:instances:detail',
                      args=[server.id])
        res = self.client.get(url)

        self.assertItemsEqual(res.context['instance'].volumes, volumes)
        self.assertEquals(res.context['instance'].volumes[0].device,
                          "/dev/hda")
        self.assertEquals(res.context['instance'].volumes[1].device,
                          "/dev/hdk")
Exemplo n.º 7
0
 def get_data(self):
     if not hasattr(self, "_instance"):
         try:
             instance_id = self.kwargs['instance_id']
             instance = api.server_get(self.request, instance_id)
             instance.volumes = api.volume_instance_list(self.request,
                                                         instance_id)
             instance.full_flavor = api.flavor_get(self.request,
                                                   instance.flavor["id"])
             instance.security_groups = api.server_security_groups(
                                        self.request, instance_id)
         except:
             redirect = reverse('horizon:nova:instances_and_volumes:index')
             exceptions.handle(self.request,
                               _('Unable to retrieve details for '
                                 'instance "%s".') % instance_id,
                                 redirect=redirect)
         self._instance = instance
     return self._instance
 def get_data(self):
     if not hasattr(self, "_instance"):
         try:
             instance_id = self.kwargs['instance_id']
             instance = api.server_get(self.request, instance_id)
             instance.volumes = api.volume_instance_list(self.request,
                                                         instance_id)
             instance.full_flavor = api.flavor_get(self.request,
                                                   instance.flavor["id"])
             instance.security_groups = api.server_security_groups(
                                        self.request, instance_id)
         except:
             redirect = reverse('horizon:nova:instances_and_volumes:index')
             exceptions.handle(self.request,
                               _('Unable to retrieve details for '
                                 'instance "%s".') % instance_id,
                                 redirect=redirect)
         self._instance = instance
     return self._instance
Exemplo n.º 9
0
 def get_data(self):
     if not hasattr(self, "_instance"):
         try:
             instance_id = self.kwargs['instance_id']
             instance = api.server_get(self.request, instance_id)
             instance.volumes = api.volume_instance_list(self.request,
                                                         instance_id)
             # Gather our flavors and images and correlate our instances to
             # them. Exception handling happens in the parent class.
             flavors = api.flavor_list(self.request)
             full_flavors = SortedDict([(str(flavor.id), flavor) for \
                                         flavor in flavors])
             instance.full_flavor = full_flavors[instance.flavor["id"]]
             instance.security_groups = api.server_security_groups(
                                        self.request, instance_id)
         except:
             redirect = reverse('horizon:nova:instances_and_volumes:index')
             exceptions.handle(self.request,
                               _('Unable to retrieve details for '
                                 'instance "%s".') % instance_id,
                                 redirect=redirect)
         self._instance = instance
     return self._instance
Exemplo n.º 10
0
 def get_data(self):
     if not hasattr(self, "_instance"):
         try:
             instance_id = self.kwargs['instance_id']
             instance = api.server_get(self.request, instance_id)
             with open('/tmp/srik2.out', 'w+') as f:
                 f.write(str(instance.id))
                 f.close()
             instance.volumes = api.volume_instance_list(self.request,
                                                         instance_id)
             # Sort by device name
             instance.volumes.sort(key=lambda vol: vol.device)
             instance.full_flavor = api.flavor_get(self.request,
                                                   instance.flavor["id"])
             instance.security_groups = api.server_security_groups(
                                        self.request, instance_id)
         except:
             redirect = reverse('horizon:nova:instances:index')
             exceptions.handle(self.request,
                               _('Unable to retrieve details for '
                                 'instance "%s".') % instance_id,
                                 redirect=redirect)
         self._instance = instance
     return self._instance