text:
Czerwone Bagno – wieś w powiecie suwalskim.
 Rezerwat przyrody Czerwone Bagno – część Biebrzańskiego Parku Narodowego, miejsce schronienia uczestników powstań narodowych i partyzantki z okresu II wojny światowej.


text:
Nationals seats won $100m in grants after Coalition ignored advice
Tom McIlroyPolitical reporter
More than $100 million extra in regional grants went to Nationals' electorates as a result of the former Morrison government ignoring merit-based recommendations from bureaucrats, a scathing audit report has found.
Auditor-General Grant Hehir said administration of the $1.38 billion Building Better Regions Fund (BBRF) was only partly consistent with federal government grant rules and poor transparency existed around criteria for successful applications and the panel awarding funding.
Former Liberal and Nationals' leaders Barnaby Joyce, Michael McCormack and Scott Morrison Alex Ellinghausen
Labor has accused the Coalition of politicising the BBRF to boost its re-election prospects, the latest in a series of alleged pork barrelling revelations directed at the Liberals and Nationals.
The report said about 65 per cent of infrastructure projects receiving a share of $1.1 billion in funding were not assessed by department officials as being the most meritorious, seeing $104 million extra, or 29 per cent of the available funding, go to Nationals electorates.
The report said electorates held by other parties were awarded less than if merit assessments were relied on.
It highlighted deficiencies including a lack of transparency around a list of "other factors" used by ministers to override the merit assessment process.
In the fifth round of the BBRF, lax rules meant none of the $761.4 million in grant funding had to be reported to the Finance Minister after department advice was ignored, the report said.
"The basis for the funding decisions has not been appropriately documented, particularly in the three most recently completed rounds.
"It was common in the infrastructure projects stream ... for the approved applications to not be those assessed as best meeting the published criteria and for applications assessed as highly meritorious against the published criteria to not be awarded funding."
The report said there were inadequate records of "the inputs to the decision-making process" and approvals for the fund.
Nearly 180 decisions to award funding were not properly documented.
Infrastructure Minister Catherine King has blamed former Nationals leader Barnaby Joyce for leaving behind "a substantial mess" on grant allocations during the Coalition's nine years in power, and has announced plans to redesign how regional funding is awarded under Labor.
In a statement, she said the former government "actively ignored grant guidelines and, in the process, dudded hard-working regional Australians."
"Former Coalition ministers made decisions on the basis of 'choose-your-own-adventure' criteria that weren't fully explained to those applying for grants.
"They did not keep proper records of decisions."
She said regional Australians and taxpayers deserved better.
The Coalition announced major regional spending as part of a 2021 deal between Mr Joyce and former prime minister Scott Morrison to secure support for a net-zero 2050 carbon emissions pledge.
Ahead of the 2021 federal budget, Mr Morrison and then deputy prime minister Michael McCormack rolled out more than $1.2 billion on three separate measures in one day, including $250 million for the BBRF.
The Coalition was severely criticised for politicisation of a range of infrastructure and community grant programs, including a $660 million for carparks at suburban train stations.
In June 2021, the Australian National Audit Office found the carparks program was "not effective" and projects were "not demonstrably merit-based". Instead, nearly all the locations funded were in Coalition-held or targeted seats for the 2019 election.
Nationals senator Bridget McKenzie quit cabinet in February 2020 over the so-called "sports rorts" saga, in which the Auditor-General found sporting grants favoured Coalition and marginal seats, based on colour-coded spreadsheets.
Tom McIlroy reports from the federal press gallery at Parliament House. Connect with Tom on Twitter. Email Tom at thomas.mcilroy@afr.com
Barnaby Joyce
Catherine King

redpajama_set_name: RedPajamaCommonCrawl


text:
Saint-Barthélemy è un affluente di sinistra della Dora Baltea. Percorre in tutta la sua lunghezza l'omonimo vallone, situato in Valle d'Aosta.

Percorso

Il torrente nasce dal piccolo Lago di Luseney (2.575 m), situato in una conca compresa tra la Becca di Luseney e la Cima di Livourneyaz.
Scende in direzione sud-est fino a quota 2.180 dove, ingrossato da alcuni affluenti, ruota di 90° dirigendosi verso sud-ovest.
Il vallone si allarga nel pianoro a valle dell'Alpe Ollière e scende ospitando il piccolo santuario di Champlaisant. Il torrente prosegue con percorso tortuoso e si incassando progressivamente mantenendo un generale andamento verso sud-ovest.
Ricevuto da destra l'apporto dei torrenti Chavalary, Chaléby e Dèche il Saint-Barthélemy si getta infine nella Dora Baltea poco ad est del capoluogo comunale di Nus attorno a quota 520.

Regime idrografico
La portata del torrente è fortemente influenzata dallo scioglimento primaverile delle nevi e/o dagli eventi meteorici violenti che possono verificarsi nella stagione estiva o autunnale. Anche nel pieno dell'estate il corso d'acqua conserva una buona portata perché viene alimentato dallo scioglimento dei nevai presenti ad alta quota alla testata dei valloni che ne compongono il bacino idrografico.
Non sono invece presenti aree glaciali di dimensioni rilevanti.

Affluenti
La forma asimmetrica del Vallone di Saint-Barthélemy fa in modo che gli apporti idrici al torrente provengano quasi totalmente dalla destra idrografica, lato sul quale si sviluppano anche i principali affluenti. Questi sono:

 Torrent Chavalary: lungo circa 3 km è orientato in senso nord-ovest/sud-est e confluisce nel Saint-Barthélemy a quota 1500 circa. Il suo bacino idrografico ha una superficie di 3,6 km² e un orientamento nord-ovest/sud-est;
 Torrent Chaléby: il suo bacino ha una superficie di 14 km² e culmina con il Monte Faroma (3.072 m); l'asta torrentizia è lunga quasi 6 km e confluisce nel Saint-Barthélemy a quota 1070 m. La parte sinistra del bacino è poco acclive mentre sulla sua destra le pendenze sono assai più elevate; il torrente presenta per la maggior parte del suo corso una pendenza moderata e nel suo tratto terminale si incassa nella roccia creando una profonda gola;
 Torrent d'Èche: è l'ultimo affluente rilevante del Saint-Barthélemy, nel quale confluisce a circa 800 m di quota. Lungo 6,7 km ha un bacino di 15,7 km² nel quale prevalgono i boschi e le aree pascolive.

Energia
La centrale di Nus, nel comune omonimo, è in gestione alla CVA e sfrutta le acque dei torrenti Saint-Barthélemy, Chaléby e Comba Dèche per produrre energia idroelettrica.

Note

Fiumi della Valle d'Aosta
Affluenti della Dora Baltea

redpajama_set_name: RedPajamaWikipedia


text:
HOME > NEW WAVE FILM ENCYCLOPEDIA > FILMS > A Bout De Souffle (Breathless)
[US ] [UK ] [FR] [Criterion ]
Producer Georges de Beauregard
Screenplay Jean-Luc Godard
Cinematographer Raoul Coutard
Editor Cecile Decugis
Composer Martial Solal
Michel Poiccard Jean-Paul Belmondo
Patricia Franchini Jean Seberg
Police Inspector Vital Daniel Boulanger
Parvulesco
Antonio Berruti Henri-Jacques Huet
Liliane Liliana Robin
Cal Zombach Roger Hanin
An Informer Jean-Luc Godard
Synopsis - Review - Video Clip - Poster Gallery
English Title Breathless
Director Jean-Luc Godard
Year / Length 1960 || 90 mins
Michel (Jean-Paul Belmondo) is a young hoodlum who models himself after Humphrey Bogart. After stealing a car in Marseille, he heads for Paris, gunning down a cop on the way. Once in the capital he meets up with American student Patricia (Jean Seberg), an aspiring journalist who sells copies of the New York Herald Tribune on the Champs-Elysee. Patricia agrees to hide him while he tries to trace a former associate who owes him money so that he can evade the police dragnet and make a break for Italy. But as the authorities close in, she betrays him, leading to a final shoot out in the street.
Top 10 Godard Movies || Jean-Luc Godard Profile|| French New Wave History || French New Wave Film Guide
get this poster
...or see the complete poster gallery
"To make a film all you need is a girl and a gun." Jean-Luc Godard's oft-quoted line might have come from the mouth of any tough-talking, American movie director from Hollywood's classic era. The fact that it was spoken by a 29-year-old Franco-Swiss intellectual from Paris says much about the cross-cultural pollination that was so crucial to birth of the New Wave and to what is often considered its flagship film: À bout de souffle. Indeed the film's simple story resembles a classic American film noir, such as those made by Monogram Studios, to whom the film is dedicated. But Godard approached the story in ways that departed radically from past genre archetypes. His years as a critic, his immersion in both high and low culture, his philosophical explorations, all impacted on his debut feature film. As he said in an interview, the film was the result of "a decade's worth of making movies in my head." The fact that he was relatively inexperienced and had little knowledge of the practical aspects of filmmaking proved unimportant. What he did have were an accumulation of original ideas, which he applied fearlessly to the aesthetic and technical elements of the film. The results were nothing less than a cinematic revolution.
It was Francois Truffaut who, several years earlier, first sketched out the outline for what would become À bout de souffle. He had been inspired by a true story that had fascinated tabloid France in 1952, when a man named Michel Portail, a petty criminal who had stolen a car, shot a motorcycle policeman who pulled him over, and then hid out for almost two weeks until he was found in a canoe docked in the centre of Paris. One aspect of the story that had appealed to Truffaut was the fact that Portail had an American journalist girlfriend who he had tried to convince to run away with him. Instead she turned him into the police. Truffaut had collaborated with both Claude Chabrol and Godard on the story but had failed to interest any producers. By 1959, Godard, now desperate to catch up with his Cahiers colleagues and make a first feature film, asked if he might revive the project. Truffaut, buoyant with success after the ecstatic reception of Les Quatre cents coups at Cannes, not only agreed, but also helped to convince Georges de Beauregard to produce the film.
With a low budget of 510,000 francs (a third of the average cost of a French film at that time), Godard set about casting for the film. He suggested to Beauregard that they hire Jean Seberg, the young actress who had made an uncertain start in pictures on Otto Preminger's Saint Joan and Bonjour Tristesse, as the American woman. Although most critics had disparaged both films, Godard had written admiringly about Seberg in the pages of Cahiers du cinema. Unimpressed by the director at their first meeting, describing him as "an incredibly introverted, messy-looking young man with glasses, who didn't look her in the eye when she talked," she was, nevertheless, encouraged by her husband, a French attorney with directing ambitions of his own, to accept the role. Persuading Columbia Studios to lend her out for the film was less easy, but again her husband stepped in and managed to convince the studio to accept a small cash payment for her participation. As for Jean-Paul Belmondo, Godard had already promised him the lead role in his first film. Belmondo, who was beginning to get lucrative offers from the mainstream film industry, ignored the warning words of his agent who told him, "you're making the biggest mistake of your life," and accepted the part.
With his cast in place, Godard set about knocking Truffaut's story outline into a screenplay. His original plan had been to use the outline as it was and merely add dialogue to it. Instead he rewrote the entire story, shifting the emphasis away from Truffaut's portrayal of an anguished young man who turns to crime out of despair, to that of a young hoodlum with an existential indifference to common morality and the rule of law. Crucially, in the new version, the American woman Patricia comes into the narrative near the beginning and their love story dominates the film.
Filming took place over the summer of 1959. Behind the camera was Raoul Coutard, originally a documentary cameraman for the French army's information service in Indochina during the war. Coutard's background suited Godard who wanted the film to be shot, as much as possible, like a documentary, with a handheld camera and the minimum of lighting. This decision was taken for both aesthetic reasons – making the film look like a newsreel – and practical reasons – saving the time setting up lights and tripod. Flexibility was very important to Godard, who wanted the freedom to improvise and shoot whenever and wherever he wanted without too many technical constraints. He and Coutard devised ways – such as using a wheelchair for tracking shots and shooting with specialist lowlight filmstock for nighttime scenes – to make this possible. Godard's method of directing A bout de souffle was even more radical than his technical innovations. Much to the producer Beauregard's disapproval, he often only filmed for a couple of hours a day. Sometimes, when lacking the necessary inspiration, he would cancel the day's filming altogether. Early on in the shoot, he discarded the screenplay he had written and decided to write the dialogue day by day as the production went along. The actors found this procedure strange and sometimes forgot their lines, however, since the soundtrack was to be post-synchronized later, when the actor's were lost for words, Godard would call out their lines to them from behind the camera. For Godard the act of making a film was as much a part of its meaning as its content and style. Like "action painting" he felt a film reflected the conditions under which it was made, and that a director's technique was the method by which a film could be made personal.
Godard's unorthodox methods continued in the editing suite. His first cut of À bout de souffle was two-and-a-half hours long but Beauregard had required he deliver a ninety-minute film. Rather than cutting out whole scenes, he decided to cut within scenes, even within shots. This use of deliberate jump cuts was unheard of in professional filmmaking where edits were designed to be as seamless as possible. He also cut between shots from intentionally disorienting angles that broke all the traditional rules of continuity. By deliberately appearing amateurish Godard drew attention to the conventions of classic cinema, revealing them for what they were, merely conventions.
It wasn't only in the montage of images that Godard expressed his personality, but also through the rich depth of references to cinema, literature, and art. À bout de souffle abounds with quotations of movies by directors such as Samuel Fuller, Joseph H. Lewis, Otto Preminger and any number of classic film noirs. There are also quotations and references to writers such as Faulkner, Dylan Thomas, and Louis Aragon, as well as painters like Picasso, Renoir and Klee. Reflecting the film's cultural heritage, American iconography and influence is everywhere: in the cars (Cadillacs and Oldsmobiles), Michel's obsession with Humphrey Bogart, and the jaunty, improvised jazz score (played by French pianist Martial Solal). Godard also included his friends in the film. He asked Jean-Pierre Melville to play the celebrated novelist who Patricia interviews at Orly Airport (the other journalists were all played by friends such as André S. Labarthe and Jean Douchet), and Jacques Rivette had a cameo role as a man run over in the street. Godard himself played the informer who recognizes Michel in the street and turns him in.
On a deeper level, Godard used the film's framework to explore some of the themes which preoccupied him, and which he would continue to explore for years to come. Some of the key ideas of existentialism, such as stressing the individual's importance over society's rules and the evident absurdity of life, lie at the core of the narrative. Death is an everyday event and generally treated with indifference. The impossibility of love, another central Godardian theme, is played out in the relationship between Michel and Patricia. In the long hotel room scene, which takes up nearly a third of the screen time, the two lovers talk, joke, argue and fool about, but frequently fail to completely understand each other. Michel's use of slang is often lost on Patricia. That she fails to even understand his dying words sums up the flawed nature of their relationship.
Although Godard was the last of his Cahiers du cinema colleagues to make a film – Truffaut, Chabrol, Rohmer and Rivette had all completed or at least shot their debuts before À bout de souffle went into production – it was A bout de souffle that became the cornerstone of the New Wave, and is still the film that defines the movement in the public mind. Sight and Sound magazine called it "the group's intellectual manifesto" and it, more than any other film of the time, captured the New Wave revolt against traditional cinematic form. It also had a youthful exuberance and a pair of leading actors whose style and attitude seemed to epitomize a new generation of youth. In one fell swoop, Godard had succeeded in making the movement representative of the times, defined cinema as the artform of the moment, and personally become one of its most important figures.
A bout de souffle was an immediate success. In January 1960, just before the film's release it won the annual Jean Vigo Prize, given to films made with an independent spirit. The critics were unanimous in their praise, recognizing the film as the greatest accomplishment yet to come out of the New Wave. One wrote: "The terms 'old cinema' and 'new cinema' now have meaning… with À bout de souffle, the generation gap can suddenly be felt." Celebrated British critic Penelope Gilliat commented that: "Jean-Luc Godard makes a film as though no one had ever made one before." When it opened in four commercial cinemas in Paris, it immediately drew large crowds. In the end its profits were estimated to be fifty times the original investment. More importantly, it inspired a generation of filmmakers – for whom Godard had become the embodiment of the New Wave and the archetypal cinematic intellectual – to emulate what he had done. Now, 50 years after its release, the film's impact and its popularity with critics and the public has not diminished. It continues to influence both directors and the wider culture, and every few years a new generation discovers and falls in love with its unique charm all over again.


text:
Keighley 4°c
Weddings E-magazine
District Sport
Arts & Entertainment News
Walking the literary landscape around Haworth
Brontë fans can follow in the footsteps of their heroines thanks to a new walks book.
Walking The Literary Land-scape takes people from Haworth on to the moors past the Brontë waterfalls.
Walkers visit Top Withens, the ruined farmhouse reputed to be the inspiration for Emily Brontë's Wuthering Heights, then back to Haworth via Stanbury.
The Brontë sisters are among famous writers featured in the glossy paperback, written by Ian Hamilton and Diane Roberts.
Each of the 20 walks takes in a location linked to the life or works of a well-known writer. They include poets like William Wordsworth and Ted Hughes and novelists like Jane Austen and Charles Dickens, together with children's writers Beatrix Potter and Lewis Carroll.
The authors tell how the Brontës are still inextricably linked to Haworth and describe the Parsonage Museum as "superb".
They add: "Our walk follows in the footsteps of the sisters, who demonstrated in their writing a remarkable sympathy for nature in the raw and an ability to withstand a fair amount of hardship."
Walking The Literary Land-scape costs £12.95. Visit v-publishing.co.uk for details.


Alcohol 52% Free Edition is a developed by Alcohol Soft. This site is not affiliated with Alcohol Soft in any way. Read more.
Emulation software allowing users to play CDs & DVDs without the need for the physical disc. Notebook users and PC Game players would benifit the most from Alcohol 52% Supports 25 plus languages Can handle up to 31 virtual CD & DVD-ROM drives, all at once. The reading speed of a virtual CD-ROM is 200X. This means you can play a CD from the virtual CD-ROM with 200X reading speed. Supports normal CD & DVD and CD RAW sub-channel reading methods: RAW reading method enables to emulate all CDs. CD formats supported: CD-DA, CD+G, CD-ROM, CD-XA, Video CD, Photo CD, Mixed Mode, Multi-session CD DVD formats supported: DVD-ROM, DVD-Video, DVD-Audio Support for all current (ATAPI & SCSI) drives: CD-R, CD-RW, DVD-RAM, DVD-R, DVD-RW, DVD+RW Full support for IEEE-1394 (Firewire) and USB protocols.
This software is only for the purpose of legal use of duplication under the current copyright laws. Any duplication without permission by copyright owners is illegal under the current copyright laws. Users are liable for criminal and civil penalty under the current copyright law for illegal duplication. The software developers and publishers shall have no responsibility or obligation for any misuse of illegal duplication by users of this software.
Alcohol 52% Free Edition is a developed by Alcohol Soft. This site is not affiliated with Alcohol Soft in any way. SafestDownloads is a platform that helps you find the software you've been searching for. SafestDownloads not only offers a vast catalog of thousands of free programs to choose from, but makes it easy to download them.


text:
Mónica De La Cruz (nacida el 11 de noviembre de 1974) es una política, empresaria y agente de seguros estadounidense del estado de Texas. Ha representado al 15.º distrito congresional de Texas en la Cámara de Representantes de los Estados Unidos desde 2023. De La Cruz es el primer republicano en representar al distrito 15 del congreso de Texas desde su creación en 1903.

Desde enero de 2023, De La Cruz fue seleccionada para trabajar en el Comité de la Cámara de Servicios Financieros de los Estados Unidos.

Biografía
De La Cruz se graduó de la escuela secundaria James Pace Early College en Brownsville, Texas, y de la Universidad de Texas en San Antonio, donde estudió marketing. Después asistió a la Universidad Nacional Autónoma de México en la Ciudad de México, donde estudió español. Hizo una pasantía para Turner Entertainment antes de trabajar para Cartoon Network Latinoamérica. Es agente de seguros, empresaria y residente en el Valle del Río Grande, donde creció.

Cámara de Representantes de los Estados Unidos
En 2020, De La Cruz se postuló al 15.º distrito congresional de Texas y perdió ante el demócrata titular Vicente González por tres puntos porcentuales.

Respaldada por Donald Trump y el líder de la minoría de la Cámara Kevin McCarthy, De La Cruz se postuló nuevamente en el distrito 15 en las elecciones de la Cámara de Representantes de los Estados Unidos de 2022. De La Cruz derrotó a la candidata demócrata Michelle Vallejo en las elecciones generales.

Referencias

Republicanos de Texas
Miembros de la Cámara de Representantes de Estados Unidos por Texas
Episcopalianos de Estados Unidos
Políticos de Estados Unidos
Empresarios de Estados Unidos


text:
import copy
import uuid

import mock
from neutronclient.v2_0 import client as neutronclient
import six

from heat.common import exception
from heat.common import template_format
from heat.engine.clients.os import cinder
from heat.engine.clients.os import glance
from heat.engine.clients.os import neutron
from heat.engine.clients.os import nova
from heat.engine.clients import progress
from heat.engine import environment
from heat.engine import resource
from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine.resources import scheduler_hints as sh
from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template
from heat.tests import common
from heat.tests.openstack.nova import fakes as fakes_nova
from heat.tests import utils

wp_template = '''
{
  "AWSTemplateFormatVersion" : "2010-09-09",
  "Description" : "WordPress",
  "Parameters" : {
    "KeyName" : {
      "Description" : "KeyName",
      "Type" : "String",
      "Default" : "test"
    }
  },
  "Resources" : {
    "WebServer": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
        "ImageId" : "F17-x86_64-gold",
        "InstanceType"   : "m1.large",
        "KeyName"        : "test",
        "NovaSchedulerHints" : [{"Key": "foo", "Value": "spam"},
                                {"Key": "bar", "Value": "eggs"},
                                {"Key": "foo", "Value": "ham"},
                                {"Key": "foo", "Value": "baz"}],
        "UserData"       : "wordpress",
        "BlockDeviceMappings": [
            {
                "DeviceName": "vdb",
                "Ebs": {"SnapshotId": "9ef5496e-7426-446a-bbc8-01f84d9c9972",
                        "DeleteOnTermination": "True"}
            }],
        "Volumes" : [
            {
                "Device": "/dev/vdc",
                "VolumeId": "cccc"
            },
            {
                "Device": "/dev/vdd",
                "VolumeId": "dddd"
            }]
      }
    }
  }
}
'''

class InstancesTest(common.HeatTestCase):
    def setUp(self):
        super(InstancesTest, self).setUp()
        self.fc = fakes_nova.FakeClient()

    def _setup_test_stack(self, stack_name):
        t = template_format.parse(wp_template)
        tmpl = template.Template(
            t, env=environment.Environment({'KeyName': 'test'}))
        stack = parser.Stack(utils.dummy_context(), stack_name, tmpl,
                             stack_id=str(uuid.uuid4()))
        return (tmpl, stack)

    def _mock_get_image_id_success(self, imageId_input, imageId):
        self.patchobject(glance.GlanceClientPlugin,
                         'find_image_by_name_or_id',
                         return_value=imageId)

    def _mock_get_image_id_fail(self, image_id, exp):
        self.patchobject(glance.GlanceClientPlugin,
                         'find_image_by_name_or_id',
                         side_effect=exp)

    def _get_test_template(self, stack_name, image_id=None, volumes=False):
        (tmpl, stack) = self._setup_test_stack(stack_name)

        tmpl.t['Resources']['WebServer']['Properties'][
            'ImageId'] = image_id or 'CentOS 5.2'
        tmpl.t['Resources']['WebServer']['Properties'][
            'InstanceType'] = '256 MB Server'
        if not volumes:
            tmpl.t['Resources']['WebServer']['Properties']['Volumes'] = []

        return tmpl, stack

    def _setup_test_instance(self, return_server, name, image_id=None,
                             volumes=False):
        stack_name = '%s_s' % name
        tmpl, self.stack = self._get_test_template(stack_name, image_id,
                                                   volumes=volumes)
        self.instance_props = tmpl.t['Resources']['WebServer']['Properties']
        resource_defns = tmpl.resource_definitions(self.stack)
        instance = instances.Instance(name, resource_defns['WebServer'],
                                      self.stack)

        self._mock_get_image_id_success(image_id or 'CentOS 5.2', 1)

        self.patchobject(nova.NovaClientPlugin, 'client', return_value=self.fc)
        self.stub_SnapshotConstraint_validate()

        self.mock_create = mock.Mock(return_value=return_server)
        self.fc.servers.create = self.mock_create

        return instance

    def _create_test_instance(self, return_server, name):
        instance = self._setup_test_instance(return_server, name)
        bdm = {"vdb": "9ef5496e-7426-446a-bbc8-01f84d9c9972:snap::True"}

        mock_get = mock.Mock(return_value=return_server)
        with mock.patch.object(self.fc.servers, 'get', mock_get):
            scheduler.TaskRunner(instance.create)()

        self.mock_create.assert_called_once_with(
            image=1, flavor=1, key_name='test',
            name=utils.PhysName(
                self.stack.name,
                instance.name,
                limit=instance.physical_resource_name_limit),
            security_groups=None,
            userdata=mock.ANY,
            scheduler_hints={'foo': ['spam', 'ham', 'baz'],
                             'bar': 'eggs'},
            meta=None, nics=None, availability_zone=None,
            block_device_mapping=bdm)
        mock_get.assert_called_with(return_server.id)

        return instance

    def _stub_glance_for_update(self, image_id=None):
        self._mock_get_image_id_success(image_id or 'CentOS 5.2', 1)

    def test_instance_create(self):
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'in_create')
        # this makes sure the auto increment worked on instance creation
        self.assertGreater(instance.id, 0)

        expected_ip = return_server.networks['public'][0]
        expected_az = getattr(return_server, 'OS-EXT-AZ:availability_zone')

        self.assertEqual(expected_ip, instance.FnGetAtt('PublicIp'))
        self.assertEqual(expected_ip, instance.FnGetAtt('PrivateIp'))
        self.assertEqual(expected_ip, instance.FnGetAtt('PublicDnsName'))
        self.assertEqual(expected_ip, instance.FnGetAtt('PrivateDnsName'))
        self.assertEqual(expected_az, instance.FnGetAtt('AvailabilityZone'))

    def test_instance_create_with_BlockDeviceMappings(self):
        return_server = self.fc.servers.list()[4]
        instance = self._create_test_instance(return_server,
                                              'create_with_bdm')
        # this makes sure the auto increment worked on instance creation
        self.assertGreater(instance.id, 0)

        expected_ip = return_server.networks['public'][0]
        expected_az = getattr(return_server, 'OS-EXT-AZ:availability_zone')

        self.assertEqual(expected_ip, instance.FnGetAtt('PublicIp'))
        self.assertEqual(expected_ip, instance.FnGetAtt('PrivateIp'))
        self.assertEqual(expected_ip, instance.FnGetAtt('PublicDnsName'))
        self.assertEqual(expected_ip, instance.FnGetAtt('PrivateDnsName'))
        self.assertEqual(expected_az, instance.FnGetAtt('AvailabilityZone'))

    def test_build_block_device_mapping(self):
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'test_build_bdm')
        self.assertIsNone(instance._build_block_device_mapping([]))
        self.assertIsNone(instance._build_block_device_mapping(None))

        self.assertEqual({
            'vdb': '1234:snap:',
            'vdc': '5678:snap::False',
        }, instance._build_block_device_mapping([
            {'DeviceName': 'vdb', 'Ebs': {'SnapshotId': '1234'}},
            {'DeviceName': 'vdc', 'Ebs': {'SnapshotId': '5678',
                                          'DeleteOnTermination': False}},
        ]))

        self.assertEqual({
            'vdb': '1234:snap:1',
            'vdc': '5678:snap:2:True',
        }, instance._build_block_device_mapping([
            {'DeviceName': 'vdb', 'Ebs': {'SnapshotId': '1234',
                                          'VolumeSize': '1'}},
            {'DeviceName': 'vdc', 'Ebs': {'SnapshotId': '5678',
                                          'VolumeSize': '2',
                                          'DeleteOnTermination': True}},
        ]))

    def test_validate_Volumes_property(self):
        stack_name = 'validate_volumes'
        tmpl, stack = self._setup_test_stack(stack_name)
        volumes = [{'Device': 'vdb', 'VolumeId': '1234'}]
        wsp = tmpl.t['Resources']['WebServer']['Properties']
        wsp['Volumes'] = volumes
        resource_defns = tmpl.resource_definitions(stack)
        instance = instances.Instance('validate_volumes',
                                      resource_defns['WebServer'], stack)
        self.stub_ImageConstraint_validate()
        self.stub_SnapshotConstraint_validate()
        self.stub_FlavorConstraint_validate()
        self.stub_KeypairConstraint_validate()
        ex = exception.EntityNotFound(entity='Volume', name='1234')
        mock_get_vol = self.patchobject(cinder.CinderClientPlugin,
                                        'get_volume',
                                        side_effect=ex)

        exc = self.assertRaises(exception.StackValidationFailed,
                                instance.validate)
        self.assertIn("WebServer.Properties.Volumes[0].VolumeId: "
                      "Error validating value '1234': The Volume "
                      "(1234) could not be found.",
                      six.text_type(exc))

        mock_get_vol.assert_called_once_with('1234')

    def test_validate_BlockDeviceMappings_VolumeSize_valid_str(self):
        stack_name = 'val_VolumeSize_valid'
        tmpl, stack = self._setup_test_stack(stack_name)
        bdm = [{'DeviceName': 'vdb',
                'Ebs': {'SnapshotId': '1234',
                        'VolumeSize': '1'}}]
        wsp = tmpl.t['Resources']['WebServer']['Properties']
        wsp['BlockDeviceMappings'] = bdm
        resource_defns = tmpl.resource_definitions(stack)
        instance = instances.Instance('validate_volume_size',
                                      resource_defns['WebServer'], stack)

        self._mock_get_image_id_success('F17-x86_64-gold', 1)
        self.stub_SnapshotConstraint_validate()
        self.stub_VolumeConstraint_validate()
        self.patchobject(nova.NovaClientPlugin, 'client', return_value=self.fc)

        self.assertIsNone(instance.validate())

    def test_validate_BlockDeviceMappings_without_Ebs_property(self):
        stack_name = 'without_Ebs'
        tmpl, stack = self._setup_test_stack(stack_name)
        bdm = [{'DeviceName': 'vdb'}]
        wsp = tmpl.t['Resources']['WebServer']['Properties']
        wsp['BlockDeviceMappings'] = bdm
        wsp['Volumes'] = []
        resource_defns = tmpl.resource_definitions(stack)
        instance = instances.Instance('validate_without_Ebs',
                                      resource_defns['WebServer'], stack)

        self._mock_get_image_id_success('F17-x86_64-gold', 1)
        self.patchobject(nova.NovaClientPlugin, 'client', return_value=self.fc)

        exc = self.assertRaises(exception.StackValidationFailed,
                                instance.validate)
        self.assertIn("Ebs is missing, this is required",
                      six.text_type(exc))

    def test_validate_BlockDeviceMappings_without_SnapshotId_property(self):
        stack_name = 'without_SnapshotId'
        tmpl, stack = self._setup_test_stack(stack_name)
        bdm = [{'DeviceName': 'vdb',
                'Ebs': {'VolumeSize': '1'}}]
        wsp = tmpl.t['Resources']['WebServer']['Properties']
        wsp['BlockDeviceMappings'] = bdm
        wsp['Volumes'] = []
        resource_defns = tmpl.resource_definitions(stack)
        instance = instances.Instance('validate_without_SnapshotId',
                                      resource_defns['WebServer'], stack)

        self._mock_get_image_id_success('F17-x86_64-gold', 1)
        self.patchobject(nova.NovaClientPlugin, 'client', return_value=self.fc)

        exc = self.assertRaises(exception.StackValidationFailed,
                                instance.validate)
        self.assertIn("SnapshotId is missing, this is required",
                      six.text_type(exc))

    def test_validate_BlockDeviceMappings_without_DeviceName_property(self):
        stack_name = 'without_DeviceName'
        tmpl, stack = self._setup_test_stack(stack_name)
        bdm = [{'Ebs': {'SnapshotId': '1234',
                        'VolumeSize': '1'}}]
        wsp = tmpl.t['Resources']['WebServer']['Properties']
        wsp['BlockDeviceMappings'] = bdm
        resource_defns = tmpl.resource_definitions(stack)
        instance = instances.Instance('validate_without_DeviceName',
                                      resource_defns['WebServer'], stack)

        self.stub_VolumeConstraint_validate()
        self.stub_SnapshotConstraint_validate()
        self.stub_ImageConstraint_validate()
        self.stub_KeypairConstraint_validate()
        self.stub_FlavorConstraint_validate()

        exc = self.assertRaises(exception.StackValidationFailed,
                                instance.validate)
        excepted_error = (
            'Property error: '
            'Resources.WebServer.Properties.BlockDeviceMappings[0]: '
            'Property DeviceName not assigned')
        self.assertIn(excepted_error, six.text_type(exc))

    def test_instance_create_with_image_id(self):
        return_server = self.fc.servers.list()[1]
        instance = self._setup_test_instance(return_server,
                                             'in_create_imgid',
                                             image_id='1')

        scheduler.TaskRunner(instance.create)()

        # this makes sure the auto increment worked on instance creation
        self.assertGreater(instance.id, 0)

        expected_ip = return_server.networks['public'][0]
        expected_az = getattr(return_server, 'OS-EXT-AZ:availability_zone')

        self.assertEqual(expected_ip, instance.FnGetAtt('PublicIp'))
        self.assertEqual(expected_ip, instance.FnGetAtt('PrivateIp'))
        self.assertEqual(expected_ip, instance.FnGetAtt('PublicDnsName'))
        self.assertEqual(expected_ip, instance.FnGetAtt('PrivateDnsName'))
        self.assertEqual(expected_az, instance.FnGetAtt('AvailabilityZone'))

    def test_instance_create_resolve_az_attribute(self):
        return_server = self.fc.servers.list()[1]
        instance = self._setup_test_instance(return_server,
                                             'create_resolve_az_attribute')
        scheduler.TaskRunner(instance.create)()
        expected_az = getattr(return_server, 'OS-EXT-AZ:availability_zone')
        actual_az = instance._availability_zone()

        self.assertEqual(expected_az, actual_az)

    def test_instance_create_resolve_az_attribute_nova_az_ext_disabled(self):
        return_server = self.fc.servers.list()[1]
        delattr(return_server, 'OS-EXT-AZ:availability_zone')
        instance = self._setup_test_instance(return_server,
                                             'create_resolve_az_attribute')
        self.patchobject(self.fc.servers, 'get',
                         return_value=return_server)
        scheduler.TaskRunner(instance.create)()

        self.assertIsNone(instance._availability_zone())

    def test_instance_create_image_name_err(self):
        stack_name = 'test_instance_create_image_name_err_stack'
        (tmpl, stack) = self._setup_test_stack(stack_name)

        # create an instance with non exist image name
        tmpl.t['Resources']['WebServer']['Properties']['ImageId'] = 'Slackware'
        resource_defns = tmpl.resource_definitions(stack)
        instance = instances.Instance('instance_create_image_err',
                                      resource_defns['WebServer'], stack)
        self._mock_get_image_id_fail(
            'Slackware',
            glance.client_exception.EntityMatchNotFound(
                entity='image', args='Slackware'))
        self.stub_VolumeConstraint_validate()
        self.stub_FlavorConstraint_validate()
        self.stub_KeypairConstraint_validate()
        self.stub_SnapshotConstraint_validate()

        create = scheduler.TaskRunner(instance.create)
        error = self.assertRaises(exception.ResourceFailure, create)
        self.assertEqual(
            "StackValidationFailed: resources.instance_create_image_err: "
            "Property error: WebServer.Properties.ImageId: "
            "Error validating value 'Slackware': No image matching Slackware.",
            six.text_type(error))

    def test_instance_create_duplicate_image_name_err(self):
        stack_name = 'test_instance_create_image_name_err_stack'
        (tmpl, stack) = self._setup_test_stack(stack_name)

        # create an instance with a non unique image name
        wsp = tmpl.t['Resources']['WebServer']['Properties']
        wsp['ImageId'] = 'CentOS 5.2'
        resource_defns = tmpl.resource_definitions(stack)
        instance = instances.Instance('instance_create_image_err',
                                      resource_defns['WebServer'], stack)

        self._mock_get_image_id_fail(
            'CentOS 5.2',
            glance.client_exception.EntityUniqueMatchNotFound(
                entity='image', args='CentOS 5.2'))

        self.stub_KeypairConstraint_validate()
        self.stub_SnapshotConstraint_validate()
        self.stub_VolumeConstraint_validate()
        self.stub_FlavorConstraint_validate()

        create = scheduler.TaskRunner(instance.create)
        error = self.assertRaises(exception.ResourceFailure, create)
        self.assertEqual(
            "StackValidationFailed: resources.instance_create_image_err: "
            "Property error: WebServer.Properties.ImageId: "
            "Error validating value 'CentOS 5.2': No image unique match "
            "found for CentOS 5.2.",
            six.text_type(error))

    def test_instance_create_image_id_err(self):
        stack_name = 'test_instance_create_image_id_err_stack'
        (tmpl, stack) = self._setup_test_stack(stack_name)

        # create an instance with non exist image Id
        tmpl.t['Resources']['WebServer']['Properties']['ImageId'] = '1'
        resource_defns = tmpl.resource_definitions(stack)
        instance = instances.Instance('instance_create_image_err',
                                      resource_defns['WebServer'], stack)

        self._mock_get_image_id_fail(
            '1', glance.client_exception.EntityMatchNotFound(entity='image',
                                                             args='1'))

        self.stub_VolumeConstraint_validate()
        self.stub_FlavorConstraint_validate()
        self.stub_KeypairConstraint_validate()
        self.stub_SnapshotConstraint_validate()

        create = scheduler.TaskRunner(instance.create)
        error = self.assertRaises(exception.ResourceFailure, create)
        self.assertEqual(
            "StackValidationFailed: resources.instance_create_image_err: "
            "Property error: WebServer.Properties.ImageId: "
            "Error validating value '1': No image matching 1.",
            six.text_type(error))

    def test_handle_check(self):
        (tmpl, stack) = self._setup_test_stack('test_instance_check_active')
        res_definitions = tmpl.resource_definitions(stack)

        instance = instances.Instance('instance_create_image',
                                      res_definitions['WebServer'], stack)
        instance.client = mock.Mock()
        self.patchobject(nova.NovaClientPlugin, '_check_active',
                         return_value=True)

        self.assertIsNone(instance.handle_check())

    def test_handle_check_raises_exception_if_instance_not_active(self):
        (tmpl, stack) = self._setup_test_stack('test_instance_check_inactive')
        res_definitions = tmpl.resource_definitions(stack)

        instance = instances.Instance('instance_create_image',
                                      res_definitions['WebServer'], stack)
        instance.client = mock.Mock()
        instance.client.return_value.servers.get.return_value.status = 'foo'
        self.patchobject(nova.NovaClientPlugin, '_check_active',
                         return_value=False)

        exc = self.assertRaises(exception.Error, instance.handle_check)
        self.assertIn('foo', six.text_type(exc))

    def test_instance_create_unexpected_status(self):
        # checking via check_create_complete only so not to mock
        # all retry logic on resource creation
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'test_instance_create')

        creator = progress.ServerCreateProgress(instance.resource_id)
        self.fc.servers.get = mock.Mock(return_value=return_server)
        return_server.status = 'BOGUS'

        e = self.assertRaises(exception.ResourceUnknownStatus,
                              instance.check_create_complete,
                              (creator, None))
        self.assertEqual('Instance is not active - Unknown status BOGUS '
                         'due to "Unknown"', six.text_type(e))

        self.fc.servers.get.assert_called_once_with(instance.resource_id)

    def test_instance_create_error_status(self):
        # checking via check_create_complete only so not to mock
        # all retry logic on resource creation
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'test_instance_create')
        creator = progress.ServerCreateProgress(instance.resource_id)
        return_server.status = 'ERROR'
        return_server.fault = {
            'message': 'NoValidHost',
            'code': 500,
            'created': '2013-08-14T03:12:10Z'
        }
        self.fc.servers.get = mock.Mock(return_value=return_server)

        e = self.assertRaises(exception.ResourceInError,
                              instance.check_create_complete,
                              (creator, None))
        self.assertEqual(
            'Went to status ERROR due to "Message: NoValidHost, Code: 500"',
            six.text_type(e))

        self.fc.servers.get.assert_called_once_with(instance.resource_id)

    def test_instance_create_error_no_fault(self):
        # checking via check_create_complete only so not to mock
        # all retry logic on resource creation
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'in_create')
        creator = progress.ServerCreateProgress(instance.resource_id)
        return_server.status = 'ERROR'

        self.fc.servers.get = mock.Mock(return_value=return_server)

        e = self.assertRaises(
            exception.ResourceInError, instance.check_create_complete,
            (creator, None))
        self.assertEqual(
            'Went to status ERROR due to "Message: Unknown, Code: Unknown"',
            six.text_type(e))

        self.fc.servers.get.assert_called_once_with(instance.resource_id)

    def test_instance_create_with_stack_scheduler_hints(self):
        return_server = self.fc.servers.list()[1]
        sh.cfg.CONF.set_override('stack_scheduler_hints', True)
        # Unroll _create_test_instance, to enable check
        # for addition of heat ids (stack id, resource name)
        stack_name = 'test_instance_create_with_stack_scheduler_hints'
        (t, stack) = self._get_test_template(stack_name)
        resource_defns = t.resource_definitions(stack)
        instance = instances.Instance('in_create_with_sched_hints',
                                      resource_defns['WebServer'], stack)
        bdm = {"vdb": "9ef5496e-7426-446a-bbc8-01f84d9c9972:snap::True"}
        self._mock_get_image_id_success('CentOS 5.2', 1)

        # instance.uuid is only available once the resource has been added.
        stack.add_resource(instance)
        self.assertIsNotNone(instance.uuid)

        self.patchobject(nova.NovaClientPlugin, 'client', return_value=self.fc)
        self.stub_SnapshotConstraint_validate()
        self.fc.servers.create = mock.Mock(return_value=return_server)

        scheduler.TaskRunner(instance.create)()
        self.assertGreater(instance.id, 0)

        shm = sh.SchedulerHintsMixin
        self.fc.servers.create.assert_called_once_with(
            image=1, flavor=1, key_name='test',
            name=utils.PhysName(
                stack_name,
                instance.name,
                limit=instance.physical_resource_name_limit),
            security_groups=None,
            userdata=mock.ANY,
            scheduler_hints={shm.HEAT_ROOT_STACK_ID: stack.root_stack_id(),
                             shm.HEAT_STACK_ID: stack.id,
                             shm.HEAT_STACK_NAME: stack.name,
                             shm.HEAT_PATH_IN_STACK: [stack.name],
                             shm.HEAT_RESOURCE_NAME: instance.name,
                             shm.HEAT_RESOURCE_UUID: instance.uuid,
                             'foo': ['spam', 'ham', 'baz'], 'bar': 'eggs'},
            meta=None, nics=None, availability_zone=None,
            block_device_mapping=bdm)

    def test_instance_validate(self):
        stack_name = 'test_instance_validate_stack'
        (tmpl, stack) = self._setup_test_stack(stack_name)

        tmpl.t['Resources']['WebServer']['Properties']['ImageId'] = '1'
        resource_defns = tmpl.resource_definitions(stack)
        instance = instances.Instance('instance_create_image',
                                      resource_defns['WebServer'], stack)

        self.patchobject(nova.NovaClientPlugin, 'client', return_value=self.fc)

        self._mock_get_image_id_success('1', 1)
        self.stub_VolumeConstraint_validate()
        self.stub_SnapshotConstraint_validate()

        self.assertIsNone(instance.validate())

    def _test_instance_create_delete(self, vm_status='ACTIVE',
                                     vm_delete_status='NotFound'):
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'in_cr_del')
        instance.resource_id = '1234'
        instance.status = vm_status

        # this makes sure the auto increment worked on instance creation
        self.assertGreater(instance.id, 0)

        d1 = {'server': self.fc.client.get_servers_detail()[1]['servers'][0]}
        d1['server']['status'] = vm_status

        mock_get = mock.Mock()
        self.fc.client.get_servers_1234 = mock_get

        d2 = copy.deepcopy(d1)
        if vm_delete_status == 'DELETED':
            d2['server']['status'] = vm_delete_status
            mock_get.side_effect = [(200, d1), (200, d2)]
        else:
            mock_get.side_effect = [(200, d1), fakes_nova.fake_exception()]

        scheduler.TaskRunner(instance.delete)()
        self.assertEqual((instance.DELETE, instance.COMPLETE), instance.state)

        self.assertEqual(2, mock_get.call_count)

    def test_instance_create_delete_notfound(self):
        self._test_instance_create_delete()

    def test_instance_create_delete(self):
        self._test_instance_create_delete(vm_delete_status='DELETED')

    def test_instance_create_notfound_on_delete(self):
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'in_cr_del')
        instance.resource_id = '1234'

        # this makes sure the auto increment worked on instance creation
        self.assertGreater(instance.id, 0)

        self.fc.client.delete_servers_1234 = mock.Mock(
            side_effect=fakes_nova.fake_exception())

        scheduler.TaskRunner(instance.delete)()
        self.assertEqual((instance.DELETE, instance.COMPLETE), instance.state)
        self.fc.client.delete_servers_1234.assert_called_once()

    def test_instance_update_metadata(self):
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'ud_md')

        self._stub_glance_for_update()
        ud_tmpl = self._get_test_template('update_stack')[0]
        ud_tmpl.t['Resources']['WebServer']['Metadata'] = {'test': 123}
        resource_defns = ud_tmpl.resource_definitions(instance.stack)
        scheduler.TaskRunner(instance.update, resource_defns['WebServer'])()
        self.assertEqual({'test': 123}, instance.metadata_get())

    def test_instance_update_instance_type(self):
        """Test case for updating InstanceType.

        Instance.handle_update supports changing the InstanceType, and makes
        the change making a resize API call against Nova.
        """
        return_server = self.fc.servers.list()[1]
        return_server.id = '1234'
        instance = self._create_test_instance(return_server,
                                              'ud_type')

        update_props = self.instance_props.copy()
        update_props['InstanceType'] = 'm1.small'
        update_template = instance.t.freeze(properties=update_props)

        def side_effect(*args):
            return 2 if args[0] == 'm1.small' else 1

        self.patchobject(nova.NovaClientPlugin, 'find_flavor_by_name_or_id',
                         side_effect=side_effect)
        self.patchobject(glance.GlanceClientPlugin, 'find_image_by_name_or_id',
                         return_value=1)

        statuses = iter([
            'ACTIVE',
            'RESIZE',
            'VERIFY_RESIZE',
            'VERIFY_RESIZE',
            'ACTIVE'
        ])

        def get_with_status(*args):
            return_server.status = next(statuses)
            return return_server

        self.fc.servers.get = mock.Mock(side_effect=get_with_status)
        self.fc.client.post_servers_1234_action = mock.Mock(
            return_value=(202, None))

        scheduler.TaskRunner(instance.update, update_template)()
        self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)

        self.fc.servers.get.assert_called_with('1234')
        self.assertEqual(5, self.fc.servers.get.call_count)
        self.fc.client.post_servers_1234_action.assert_has_calls([
            mock.call(body={'resize': {'flavorRef': 2}}),
            mock.call(body={'confirmResize': None}),
        ])
        self.assertEqual(2,
                         self.fc.client.post_servers_1234_action.call_count)

    def test_instance_update_instance_type_failed(self):
        """Test case for raising exception due to resize call failed.

        If the status after a resize is not VERIFY_RESIZE, it means the resize
        call failed, so we raise an explicit error.
        """
        return_server = self.fc.servers.list()[1]
        return_server.id = '1234'
        instance = self._create_test_instance(return_server,
                                              'ud_type_f')

        def side_effect(*args):
            return 2 if args[0] == 'm1.small' else 1

        self.patchobject(nova.NovaClientPlugin, 'find_flavor_by_name_or_id',
                         side_effect=side_effect)
        self.patchobject(glance.GlanceClientPlugin, 'find_image_by_name_or_id',
                         return_value=1)

        update_props = self.instance_props.copy()
        update_props['InstanceType'] = 'm1.small'
        update_template = instance.t.freeze(properties=update_props)

        statuses = iter([
            return_server.status,
            'RESIZE',
            'ERROR',
        ])

        def get_with_status(*args):
            return_server.status = next(statuses)
            return return_server

        self.fc.servers.get = mock.Mock(side_effect=get_with_status)
        self.fc.client.post_servers_1234_action = mock.Mock(
            return_value=(202, None))

        updater = scheduler.TaskRunner(instance.update, update_template)
        error = self.assertRaises(exception.ResourceFailure, updater)
        self.assertEqual(
            "Error: resources.ud_type_f: "
            "Resizing to '2' failed, status 'ERROR'",
            six.text_type(error))
        self.assertEqual((instance.UPDATE, instance.FAILED), instance.state)

        self.fc.servers.get.assert_called_with('1234')
        self.assertEqual(3, self.fc.servers.get.call_count)
        self.fc.client.post_servers_1234_action.assert_called_once_with(
            body={'resize': {'flavorRef': 2}})

    def create_fake_iface(self, port, net, ip):
        class fake_interface(object):
            def __init__(self, port_id, net_id, fixed_ip):
                self.port_id = port_id
                self.net_id = net_id
                self.fixed_ips = [{'ip_address': fixed_ip}]

        return fake_interface(port, net, ip)

    def test_instance_update_network_interfaces(self):
        """Test case for updating NetworkInterfaces.

        Instance.handle_update supports changing the NetworkInterfaces,
        and makes the change making a resize API call against Nova.
        """
        return_server = self.fc.servers.list()[1]
        return_server.id = '1234'
        instance = self._create_test_instance(return_server,
                                              'ud_network_interfaces')
        self._stub_glance_for_update()
        # if new overlaps with old, detach the different ones in old, and
        # attach the different ones in new
        old_interfaces = [
            {'NetworkInterfaceId': 'ea29f957-cd35-4364-98fb-57ce9732c10d',
             'DeviceIndex': '2'},
            {'NetworkInterfaceId': 'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46',
             'DeviceIndex': '1'}]
        new_interfaces = [
            {'NetworkInterfaceId': 'ea29f957-cd35-4364-98fb-57ce9732c10d',
             'DeviceIndex': '2'},
            {'NetworkInterfaceId': '34b752ec-14de-416a-8722-9531015e04a5',
             'DeviceIndex': '3'}]

        before_props = self.instance_props.copy()
        before_props['NetworkInterfaces'] = old_interfaces
        update_props = self.instance_props.copy()
        update_props['NetworkInterfaces'] = new_interfaces
        after = instance.t.freeze(properties=update_props)
        before = instance.t.freeze(properties=before_props)

        self.fc.servers.get = mock.Mock(return_value=return_server)
        return_server.interface_detach = mock.Mock(return_value=None)
        return_server.interface_attach = mock.Mock(return_value=None)

        scheduler.TaskRunner(instance.update, after, before)()
        self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)

        self.fc.servers.get.assert_called_with('1234')
        return_server.interface_detach.assert_called_once_with(
            'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46')
        return_server.interface_attach.assert_called_once_with(
            '34b752ec-14de-416a-8722-9531015e04a5', None, None)

    def test_instance_update_network_interfaces_old_include_new(self):
        """Test case for updating NetworkInterfaces when old prop includes new.

        Instance.handle_update supports changing the NetworkInterfaces,
        and makes the change making a resize API call against Nova.
        """
        return_server = self.fc.servers.list()[1]
        return_server.id = '1234'
        instance = self._create_test_instance(return_server,
                                              'ud_network_interfaces')
        self._stub_glance_for_update()
        # if old include new, just detach the different ones in old
        old_interfaces = [
            {'NetworkInterfaceId': 'ea29f957-cd35-4364-98fb-57ce9732c10d',
             'DeviceIndex': '2'},
            {'NetworkInterfaceId': 'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46',
             'DeviceIndex': '1'}]
        new_interfaces = [
            {'NetworkInterfaceId': 'ea29f957-cd35-4364-98fb-57ce9732c10d',
             'DeviceIndex': '2'}]

        before_props = self.instance_props.copy()
        before_props['NetworkInterfaces'] = old_interfaces
        update_props = self.instance_props.copy()
        update_props['NetworkInterfaces'] = new_interfaces
        after = instance.t.freeze(properties=update_props)
        before = instance.t.freeze(properties=before_props)

        self.fc.servers.get = mock.Mock(return_value=return_server)
        return_server.interface_detach = mock.Mock(return_value=None)

        scheduler.TaskRunner(instance.update, after, before)()
        self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)

        self.fc.servers.get.assert_called_with('1234')
        return_server.interface_detach.assert_called_once_with(
            'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46')

    def test_instance_update_network_interfaces_new_include_old(self):
        """Test case for updating NetworkInterfaces when new prop includes old.

        Instance.handle_update supports changing the NetworkInterfaces,
        and makes the change making a resize API call against Nova.
        """
        return_server = self.fc.servers.list()[1]
        return_server.id = '1234'
        instance = self._create_test_instance(return_server,
                                              'ud_network_interfaces')
        self._stub_glance_for_update()
        # if new include old, just attach the different ones in new
        old_interfaces = [
            {'NetworkInterfaceId': 'ea29f957-cd35-4364-98fb-57ce9732c10d',
             'DeviceIndex': '2'}]
        new_interfaces = [
            {'NetworkInterfaceId': 'ea29f957-cd35-4364-98fb-57ce9732c10d',
             'DeviceIndex': '2'},
            {'NetworkInterfaceId': 'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46',
             'DeviceIndex': '1'}]

        before_props = self.instance_props.copy()
        before_props['NetworkInterfaces'] = old_interfaces
        update_props = self.instance_props.copy()
        update_props['NetworkInterfaces'] = new_interfaces
        after = instance.t.freeze(properties=update_props)
        before = instance.t.freeze(properties=before_props)

        self.fc.servers.get = mock.Mock(return_value=return_server)
        return_server.interface_attach = mock.Mock(return_value=None)

        scheduler.TaskRunner(instance.update, after, before)()
        self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)

        self.fc.servers.get.assert_called_with('1234')
        return_server.interface_attach.assert_called_once_with(
            'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46', None, None)

    def test_instance_update_network_interfaces_new_old_all_different(self):
        """Tests updating NetworkInterfaces when new and old are different.

        Instance.handle_update supports changing the NetworkInterfaces,
        and makes the change making a resize API call against Nova.
        """
        return_server = self.fc.servers.list()[1]
        return_server.id = '1234'
        instance = self._create_test_instance(return_server,
                                              'ud_network_interfaces')
        self._stub_glance_for_update()
        # if different, detach the old ones and attach the new ones
        old_interfaces = [
            {'NetworkInterfaceId': 'ea29f957-cd35-4364-98fb-57ce9732c10d',
             'DeviceIndex': '2'}]
        new_interfaces = [
            {'NetworkInterfaceId': '34b752ec-14de-416a-8722-9531015e04a5',
             'DeviceIndex': '3'},
            {'NetworkInterfaceId': 'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46',
             'DeviceIndex': '1'}]

        before_props = self.instance_props.copy()
        before_props['NetworkInterfaces'] = old_interfaces
        update_props = self.instance_props.copy()
        update_props['NetworkInterfaces'] = new_interfaces
        after = instance.t.freeze(properties=update_props)
        before = instance.t.freeze(properties=before_props)

        self.fc.servers.get = mock.Mock(return_value=return_server)
        return_server.interface_detach = mock.Mock(return_value=None)
        return_server.interface_attach = mock.Mock(return_value=None)

        scheduler.TaskRunner(instance.update, after, before)()
        self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)

        self.fc.servers.get.assert_called_with('1234')
        return_server.interface_detach.assert_called_once_with(
            'ea29f957-cd35-4364-98fb-57ce9732c10d')
        return_server.interface_attach.assert_has_calls([
            mock.call('d1e9c73c-04fe-4e9e-983c-d5ef94cd1a46', None, None),
            mock.call('34b752ec-14de-416a-8722-9531015e04a5', None, None),
        ], any_order=True)
        self.assertEqual(2, return_server.interface_attach.call_count)

    def test_instance_update_network_interfaces_no_old(self):
        """Test case for updating NetworkInterfaces when there's no old prop.

        Instance.handle_update supports changing the NetworkInterfaces,
        and makes the change making a resize API call against Nova.
        """
        return_server = self.fc.servers.list()[1]
        return_server.id = '1234'
        instance = self._create_test_instance(return_server,
                                              'ud_network_interfaces')
        self._stub_glance_for_update()
        new_interfaces = [
            {'NetworkInterfaceId': 'ea29f957-cd35-4364-98fb-57ce9732c10d',
             'DeviceIndex': '2'},
            {'NetworkInterfaceId': '34b752ec-14de-416a-8722-9531015e04a5',
             'DeviceIndex': '3'}]
        iface = self.create_fake_iface('d1e9c73c-04fe-4e9e-983c-d5ef94cd1a46',
                                       'c4485ba1-283a-4f5f-8868-0cd46cdda52f',
                                       '10.0.0.4')

        update_props = self.instance_props.copy()
        update_props['NetworkInterfaces'] = new_interfaces
        update_template = instance.t.freeze(properties=update_props)

        self.fc.servers.get = mock.Mock(return_value=return_server)
        return_server.interface_list = mock.Mock(return_value=[iface])
        return_server.interface_detach = mock.Mock(return_value=None)
        return_server.interface_attach = mock.Mock(return_value=None)

        scheduler.TaskRunner(instance.update, update_template)()
        self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)

        self.fc.servers.get.assert_called_with('1234')
        return_server.interface_list.assert_called_once_with()
        return_server.interface_detach.assert_called_once_with(
            'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46')
        return_server.interface_attach.assert_has_calls([
            mock.call('ea29f957-cd35-4364-98fb-57ce9732c10d', None, None),
            mock.call('34b752ec-14de-416a-8722-9531015e04a5', None, None),
        ])
        self.assertEqual(2, return_server.interface_attach.call_count)

    def test_instance_update_network_interfaces_no_old_empty_new(self):
        """Test case for updating NetworkInterfaces when no old, no new prop.

        Instance.handle_update supports changing the NetworkInterfaces.
        """
        return_server = self.fc.servers.list()[1]
        return_server.id = '1234'
        instance = self._create_test_instance(return_server,
                                              'ud_network_interfaces')
        self._stub_glance_for_update()
        iface = self.create_fake_iface('d1e9c73c-04fe-4e9e-983c-d5ef94cd1a46',
                                       'c4485ba1-283a-4f5f-8868-0cd46cdda52f',
                                       '10.0.0.4')

        update_props = self.instance_props.copy()
        update_props['NetworkInterfaces'] = []
        update_template = instance.t.freeze(properties=update_props)

        self.fc.servers.get = mock.Mock(return_value=return_server)
        return_server.interface_list = mock.Mock(return_value=[iface])
        return_server.interface_detach = mock.Mock(return_value=None)
        return_server.interface_attach = mock.Mock(return_value=None)

        scheduler.TaskRunner(instance.update, update_template)()
        self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)

        self.fc.servers.get.assert_called_with('1234')
        return_server.interface_list.assert_called_once_with()
        return_server.interface_detach.assert_called_once_with(
            'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46')
        return_server.interface_attach.assert_called_once_with(None,
                                                               None, None)

    def _test_instance_update_with_subnet(self, stack_name,
                                          new_interfaces=None,
                                          old_interfaces=None,
                                          need_update=True,
                                          multiple_get=True):
        return_server = self.fc.servers.list()[1]
        return_server.id = '1234'
        instance = self._create_test_instance(return_server, stack_name)
        self._stub_glance_for_update()
        iface = self.create_fake_iface('d1e9c73c-04fe-4e9e-983c-d5ef94cd1a46',
                                       'c4485ba1-283a-4f5f-8868-0cd46cdda52f',
                                       '10.0.0.4')
        subnet_id = '8c1aaddf-e49e-4f28-93ea-ca9f0b3c6240'
        nics = [{'port-id': 'ea29f957-cd35-4364-98fb-57ce9732c10d'}]

        before_props = self.instance_props.copy()
        if old_interfaces is not None:
            before_props['NetworkInterfaces'] = old_interfaces
        update_props = copy.deepcopy(before_props)

        if new_interfaces is not None:
            update_props['NetworkInterfaces'] = new_interfaces
        update_props['SubnetId'] = subnet_id

        after = instance.t.freeze(properties=update_props)
        before = instance.t.freeze(properties=before_props)

        instance.reparse()

        self.fc.servers.get = mock.Mock(return_value=return_server)
        if need_update:
            return_server.interface_list = mock.Mock(return_value=[iface])
            return_server.interface_detach = mock.Mock(return_value=None)
            instance._build_nics = mock.Mock(return_value=nics)
            return_server.interface_attach = mock.Mock(return_value=None)

        scheduler.TaskRunner(instance.update, after, before)()
        self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)

        if need_update:
            self.fc.servers.get.assert_called_with('1234')
            if not multiple_get:
                self.fc.servers.get.assert_called_once()
            return_server.interface_list.assert_called_once_with()
            return_server.interface_detach.assert_called_once_with(
                'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46')
            instance._build_nics.assert_called_once_with(new_interfaces,
                                                         security_groups=None,
                                                         subnet_id=subnet_id)
            return_server.interface_attach.assert_called_once_with(
                'ea29f957-cd35-4364-98fb-57ce9732c10d', None, None)
        else:
            self.fc.servers.get.assert_not_called()

    def test_instance_update_network_interfaces_empty_new_with_subnet(self):
        """Test update NetworkInterfaces to empty, and update with subnet."""
        stack_name = 'ud_network_interfaces_empty_with_subnet'
        self._test_instance_update_with_subnet(
            stack_name, new_interfaces=[])

    def test_instance_update_no_old_no_new_with_subnet(self):
        stack_name = 'ud_only_with_subnet'
        self._test_instance_update_with_subnet(stack_name)

    def test_instance_update_old_no_change_with_subnet(self):
        # Test if there is old network interface and no change of
        # it, will do nothing when updating.
        old_interfaces = [
            {'NetworkInterfaceId': 'd1e9c73c-04fe-4e9e-983c-d5ef94cd1a46',
             'DeviceIndex': '2'}]
        stack_name = 'ud_old_no_change_only_with_subnet'
        self._test_instance_update_with_subnet(stack_name,
                                               old_interfaces=old_interfaces,
                                               need_update=False,
                                               multiple_get=False)

    def test_instance_update_properties(self):
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'in_update2')

        self.stub_ImageConstraint_validate()

        update_props = self.instance_props.copy()
        update_props['ImageId'] = 'mustreplace'
        update_template = instance.t.freeze(properties=update_props)
        updater = scheduler.TaskRunner(instance.update, update_template)
        self.assertRaises(resource.UpdateReplace, updater)

    def test_instance_status_build(self):
        return_server = self.fc.servers.list()[0]
        instance = self._setup_test_instance(return_server,
                                             'in_sts_build')
        instance.resource_id = '1234'

        # Bind fake get method which Instance.check_create_complete will call
        def status_active(*args):
            return_server.status = 'ACTIVE'
            return return_server

        self.fc.servers.get = mock.Mock(side_effect=status_active)

        scheduler.TaskRunner(instance.create)()
        self.assertEqual((instance.CREATE, instance.COMPLETE), instance.state)

        self.fc.servers.get.assert_called_with(instance.resource_id)

    def _test_instance_status_suspend(self, name,
                                      state=('CREATE', 'COMPLETE')):
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server, name)

        instance.resource_id = '1234'
        instance.state_set(state[0], state[1])

        d1 = {'server': self.fc.client.get_servers_detail()[1]['servers'][0]}
        d2 = copy.deepcopy(d1)
        d1['server']['status'] = 'ACTIVE'
        d2['server']['status'] = 'SUSPENDED'
        self.fc.client.get_servers_1234 = mock.Mock(
            side_effect=[(200, d1), (200, d1), (200, d2)])

        scheduler.TaskRunner(instance.suspend)()
        self.assertEqual((instance.SUSPEND, instance.COMPLETE), instance.state)

        self.assertEqual(3, self.fc.client.get_servers_1234.call_count)

    def test_instance_suspend_in_create_complete(self):
        self._test_instance_status_suspend(
            name='test_suspend_in_create_complete')

    def test_instance_suspend_in_suspend_failed(self):
        self._test_instance_status_suspend(
            name='test_suspend_in_suspend_failed',
            state=('SUSPEND', 'FAILED'))

    def test_instance_suspend_in_suspend_complete(self):
        self._test_instance_status_suspend(
            name='test_suspend_in_suspend_complete',
            state=('SUSPEND', 'COMPLETE'))

    def _test_instance_status_resume(self, name,
                                     state=('SUSPEND', 'COMPLETE')):
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server, name)

        instance.resource_id = '1234'
        instance.state_set(state[0], state[1])

        d1 = {'server': self.fc.client.get_servers_detail()[1]['servers'][0]}
        d2 = copy.deepcopy(d1)
        d1['server']['status'] = 'SUSPENDED'
        d2['server']['status'] = 'ACTIVE'
        self.fc.client.get_servers_1234 = mock.Mock(
            side_effect=[(200, d1), (200, d1), (200, d2)])

        instance.state_set(instance.SUSPEND, instance.COMPLETE)

        scheduler.TaskRunner(instance.resume)()
        self.assertEqual((instance.RESUME, instance.COMPLETE), instance.state)

        self.assertEqual(3, self.fc.client.get_servers_1234.call_count)

    def test_instance_resume_in_suspend_complete(self):
        self._test_instance_status_resume(
            name='test_resume_in_suspend_complete')

    def test_instance_resume_in_resume_failed(self):
        self._test_instance_status_resume(
            name='test_resume_in_resume_failed',
            state=('RESUME', 'FAILED'))

    def test_instance_resume_in_resume_complete(self):
        self._test_instance_status_resume(
            name='test_resume_in_resume_complete',
            state=('RESUME', 'COMPLETE'))

    def test_instance_resume_other_exception(self):
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'in_resume_wait')

        instance.resource_id = '1234'

        self.fc.client.get_servers_1234 = mock.Mock(
            side_effect=fakes_nova.fake_exception(status_code=500,
                                                  message='VIKINGS!'))

        instance.state_set(instance.SUSPEND, instance.COMPLETE)

        resumer = scheduler.TaskRunner(instance.resume)
        ex = self.assertRaises(exception.ResourceFailure, resumer)
        self.assertIn('VIKINGS!', ex.message)

        self.fc.client.get_servers_1234.assert_called()

    def test_instance_status_build_spawning(self):
        self._test_instance_status_not_build_active('BUILD(SPAWNING)')

    def test_instance_status_hard_reboot(self):
        self._test_instance_status_not_build_active('HARD_REBOOT')

    def test_instance_status_password(self):
        self._test_instance_status_not_build_active('PASSWORD')

    def test_instance_status_reboot(self):
        self._test_instance_status_not_build_active('REBOOT')

    def test_instance_status_rescue(self):
        self._test_instance_status_not_build_active('RESCUE')

    def test_instance_status_resize(self):
        self._test_instance_status_not_build_active('RESIZE')

    def test_instance_status_revert_resize(self):
        self._test_instance_status_not_build_active('REVERT_RESIZE')

    def test_instance_status_shutoff(self):
        self._test_instance_status_not_build_active('SHUTOFF')

    def test_instance_status_suspended(self):
        self._test_instance_status_not_build_active('SUSPENDED')

    def test_instance_status_verify_resize(self):
        self._test_instance_status_not_build_active('VERIFY_RESIZE')

    def _test_instance_status_not_build_active(self, uncommon_status):
        return_server = self.fc.servers.list()[0]
        instance = self._setup_test_instance(return_server,
                                             'in_sts_bld')
        instance.resource_id = '1234'

        status_calls = []

        # Bind fake get method which Instance.check_create_complete will call
        def get_with_status(*args):
            if not status_calls:
                return_server.status = uncommon_status
            else:
                return_server.status = 'ACTIVE'
            status_calls.append(None)
            return return_server

        self.fc.servers.get = mock.Mock(side_effect=get_with_status)

        scheduler.TaskRunner(instance.create)()
        self.assertEqual((instance.CREATE, instance.COMPLETE), instance.state)

        self.assertGreaterEqual(self.fc.servers.get.call_count, 2)

    def test_build_nics(self):
        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'build_nics')

        self.assertIsNone(instance._build_nics([]))
        self.assertIsNone(instance._build_nics(None))
        self.assertEqual([
            {'port-id': 'id3'}, {'port-id': 'id1'}, {'port-id': 'id2'}],
            instance._build_nics([
                'id3', 'id1', 'id2']))
        self.assertEqual(
            [{'port-id': 'id1'},
             {'port-id': 'id2'},
             {'port-id': 'id3'}],
            instance._build_nics([
                {'NetworkInterfaceId': 'id3', 'DeviceIndex': '3'},
                {'NetworkInterfaceId': 'id1', 'DeviceIndex': '1'},
                {'NetworkInterfaceId': 'id2', 'DeviceIndex': 2},
            ]))
        self.assertEqual(
            [{'port-id': 'id1'},
             {'port-id': 'id2'},
             {'port-id': 'id3'},
             {'port-id': 'id4'},
             {'port-id': 'id5'}],
            instance._build_nics([
                {'NetworkInterfaceId': 'id3', 'DeviceIndex': '3'},
                {'NetworkInterfaceId': 'id1', 'DeviceIndex': '1'},
                {'NetworkInterfaceId': 'id2', 'DeviceIndex': 2},
                'id4',
                'id5']
            ))

    def test_build_nics_with_security_groups(self):
        """Test the security groups can be associated to a new created port.

        Test the security groups defined in heat template can be associated to
        a new created port.
        """
        self.nclient = mock.Mock(spec=neutronclient.Client)
        self.patchobject(neutronclient, 'Client', return_value=self.nclient)

        return_server = self.fc.servers.list()[1]
        instance = self._create_test_instance(return_server,
                                              'build_nics2')

        security_groups = ['security_group_1']
        self._test_security_groups(instance, security_groups)

        security_groups = ['0389f747-7785-4757-b7bb-2ab07e4b09c3']
        self._test_security_groups(instance, security_groups, all_uuids=True)

        security_groups = ['0389f747-7785-4757-b7bb-2ab07e4b09c3',
                           '384ccd91-447c-4d83-832c-06974a7d3d05']
        self._test_security_groups(instance, security_groups,
                                   sg='two', all_uuids=True)

        security_groups = ['security_group_1',
                           '384ccd91-447c-4d83-832c-06974a7d3d05']
        self._test_security_groups(instance, security_groups, sg='two')

        security_groups = ['wrong_group_name']
        self._test_security_groups(
            instance,
            security_groups,
            sg='zero',
            get_secgroup_raises=exception.EntityNotFound)

        security_groups = ['wrong_group_name',
                           '0389f747-7785-4757-b7bb-2ab07e4b09c3']
        self._test_security_groups(
            instance,
            security_groups,
            get_secgroup_raises=exception.EntityNotFound)

        security_groups = ['wrong_group_name', 'security_group_1']
        self._test_security_groups(
            instance,
            security_groups,
            get_secgroup_raises=exception.EntityNotFound)

        security_groups = ['duplicate_group_name', 'security_group_1']
        self._test_security_groups(
            instance,
            security_groups,
            get_secgroup_raises=exception.PhysicalResourceNameAmbiguity)

    def _test_security_groups(self, instance, security_groups, sg='one',
                              all_uuids=False, get_secgroup_raises=None):
        fake_groups_list, props = self._get_fake_properties(sg)

        if not all_uuids:
            # list_security_groups only gets called when none of the requested
            # groups look like UUIDs.
            self.nclient.list_security_groups = mock.Mock(
                return_value=fake_groups_list)
        self.patchobject(neutron.NeutronClientPlugin,
                         'network_id_from_subnet_id',
                         return_value='fake_network_id')

        if get_secgroup_raises:
            self.assertRaises(get_secgroup_raises, instance._build_nics, None,
                              security_groups=security_groups,
                              subnet_id='fake_subnet_id')
        else:
            self.nclient.create_port = mock.Mock(
                return_value={'port': {'id': 'fake_port_id'}})
            self.stub_keystoneclient()

            self.assertEqual(
                [{'port-id': 'fake_port_id'}],
                instance._build_nics(None,
                                     security_groups=security_groups,
                                     subnet_id='fake_subnet_id'))

            self.nclient.create_port.assert_called_with({'port': props})
        if not all_uuids:
            self.nclient.list_security_groups.assert_called_once_with()

    def _get_fake_properties(self, sg='one'):
        fake_groups_list = {
            'security_groups': [
                {
                    'tenant_id': 'test_tenant_id',
                    'id': '0389f747-7785-4757-b7bb-2ab07e4b09c3',
                    'name': 'security_group_1',
                    'security_group_rules': [],
                    'description': 'no protocol'
                },
                {
                    'tenant_id': 'test_tenant_id',
                    'id': '384ccd91-447c-4d83-832c-06974a7d3d05',
                    'name': 'security_group_2',
                    'security_group_rules': [],
                    'description': 'no protocol'
                },
                {
                    'tenant_id': 'test_tenant_id',
                    'id': 'e91a0007-06a6-4a4a-8edb-1d91315eb0ef',
                    'name': 'duplicate_group_name',
                    'security_group_rules': [],
                    'description': 'no protocol'
                },
                {
                    'tenant_id': 'test_tenant_id',
                    'id': '8be37f3c-176d-4826-aa17-77d1d9df7b2e',
                    'name': 'duplicate_group_name',
                    'security_group_rules': [],
                    'description': 'no protocol'
                }
            ]
        }

        fixed_ip = {'subnet_id': 'fake_subnet_id'}
        props = {
            'admin_state_up': True,
            'network_id': 'fake_network_id',
            'fixed_ips': [fixed_ip],
            'security_groups': ['0389f747-7785-4757-b7bb-2ab07e4b09c3']
        }

        if sg == 'zero':
            props['security_groups'] = []
        elif sg == 'one':
            props['security_groups'] = ['0389f747-7785-4757-b7bb-2ab07e4b09c3']
        elif sg == 'two':
            props['security_groups'] = ['0389f747-7785-4757-b7bb-2ab07e4b09c3',
                                        '384ccd91-447c-4d83-832c-06974a7d3d05']

        return fake_groups_list, props

    def test_instance_without_ip_address(self):
        return_server = self.fc.servers.list()[3]
        instance = self._create_test_instance(return_server,
                                              'wo_ipaddr')

        self.assertEqual('0.0.0.0', instance.FnGetAtt('PrivateIp'))

    def test_default_instance_user(self):
        """CFN instances automatically create the `ec2-user` admin user."""
        return_server = self.fc.servers.list()[1]
        instance = self._setup_test_instance(return_server, 'default_user')
        metadata = instance.metadata_get()
        self.patchobject(nova.NovaClientPlugin, 'build_userdata',
                         return_value=None)

        scheduler.TaskRunner(instance.create)()

        nova.NovaClientPlugin.build_userdata.assert_called_once_with(
            metadata, 'wordpress', 'ec2-user')

    def test_instance_create_with_volumes(self):
        return_server = self.fc.servers.list()[1]
        self.stub_VolumeConstraint_validate()
        instance = self._setup_test_instance(return_server,
                                             'with_volumes',
                                             volumes=True)
        self.fc.servers.get = mock.Mock(return_value=return_server)
        attach_mock = self.patchobject(nova.NovaClientPlugin, 'attach_volume',
                                       side_effect=['cccc', 'dddd'])
        check_attach_mock = self.patchobject(cinder.CinderClientPlugin,
                                             'check_attach_volume_complete',
                                             side_effect=[False, True,
                                                          False, True])

        scheduler.TaskRunner(instance.create)()
        self.assertEqual((instance.CREATE, instance.COMPLETE), instance.state)
        self.assertEqual(2, attach_mock.call_count)
        attach_mock.assert_has_calls([mock.call(instance.resource_id,
                                                'cccc', '/dev/vdc'),
                                      mock.call(instance.resource_id,
                                                'dddd', '/dev/vdd')])
        self.assertEqual(4, check_attach_mock.call_count)
        check_attach_mock.assert_has_calls([mock.call('cccc'),
                                            mock.call('cccc'),
                                            mock.call('dddd'),
                                            mock.call('dddd')])
        bdm = {"vdb": "9ef5496e-7426-446a-bbc8-01f84d9c9972:snap::True"}
        self.mock_create.assert_called_once_with(
            image=1, flavor=1, key_name='test',
            name=utils.PhysName(
                self.stack.name,
                instance.name,
                limit=instance.physical_resource_name_limit),
            security_groups=None,
            userdata=mock.ANY,
            scheduler_hints={'foo': ['spam', 'ham', 'baz'], 'bar': 'eggs'},
            meta=None, nics=None, availability_zone=None,
            block_device_mapping=bdm)
        self.fc.servers.get.assert_called_with(return_server.id)

redpajama_set_name: RedPajamaGithub


text:
Classic Corner: Cairo Station
Jan 7th, 2022 Sean Burns
Netflix isn't exactly known as a treasure trove of international art cinema history – in fact, it can be tough sometimes to find much at all from the previous century streaming on the service – which is why I was quite surprised to happen upon a dozen titles from Egyptian director Youssef Chahine, the boundary-breaking, bisexual provocateur whose career spanned more than 40 films from his 1950 debut to his death in 2004. The current collection includes Chahine's 1954 breakthrough hit The Blazing Sun, which featured the first starring role for a handsome young actor named Omar Sharif, as well as the first three installments of the filmmaker's autobiographical tetralogy, 1978's Alexandria… Why?, 1982's An Egyptian Story, and 1989's Alexandria Again and Forever.
The best place to jump in is probably Chahine's still-controversial 1958 masterpiece, Cairo Station. An electrifying mix of tortured expressionism and street-level neorealism, the film depicts the title destination as an unstable collision of uptight traditions and present-day decadence, throbbing along with the main character's psychosis in a manner presaging films like Peeping Tom, Psycho and Taxi Driver. The director himself stars as Kenawi, an addled young street urchin with a bum leg taken in by a kindly old newsstand owner and given a job hawking papers at the bustling depot. It's a chaotic, discombobulated place, with deafeningly loud locomotives chugging to and fro, amid all the hustlers, pickpockets and a crew of sexy, scantily clad gals dashing in and out of train cars, illegally selling soft drinks while evading the police.
The exploited station workers are attempting to unionize, led by heroic, barrel-chested Abu Serih (Farid Shawqi), much to the consternation of the local brass. These frames are as packed as in any Robert Altman picture, with groups like "Women Against Marriage" protesting in the background and crowded cabins full of musicians holding impromptu jams. A day at the station provides a panoramic view of an old civilization on the brink of a brave new world, but these newspapers being peddled are full of murder and other dismaying dangers. A trio of cranky clerics loudly bemoan what their country has become. "Curse be these modern idiocies," they harumph. "All these new-fangled ideas lead straight to hell."
They're not entirely wrong, especially not in the case of Kenawi, who has plastered the shack in which he sleeps with bikini model cut-outs from girly magazines, frustrated and fixated on the station's soft drink sellers. (He might be modern movies' original incel. Eat your heart out, Joker.) Kenawi's all hung up on Hanuma, an incorrigible flirt played by the absurdly attractive Hind Rostom, the Marilyn Monroe of Egyptian cinema. She's engaged to the strapping Abu Serih, but sees Kenawi as a friendly plaything, teasing him and taking advantage of his eager assistance whenever convenient. There's nothing overtly cruel about how Hanuma treats him. She's actually quite fond of the little fellow, but even as he ardently proposes marriage the disabled boy's attentions just don't register to her that way. Nor does she notice the twitching behind his tiny, ferret eyes, even when Kenawi starts decapitating his paper cut-out girls.
The premiere of Cairo Station purportedly ended with an audience member spitting in the filmmaker's face, and the picture wound up banned in Egypt for 20 years before being re-discovered by cinephiles in 1978. It remains a strikingly modern movie, keyed into the sick side-effects of repression and all the ways in which young men are conditioned to see women as possessions, like the magazine cut-outs in Kenawi's collection. The cinematography switches between beautifully choreographed wide shots of clamoring crowds and our disturbed protagonist's POV, In which tantalizing glimpses of fleshy thighs cut to close-ups of his beady, angsty eyes. At a pivotal moment Chahine allows Kenawi's gaze to linger on the creaking of a worn-out railroad tie buckling under the pressure of an overloaded engine, the sight symbolizing his shaky psyche.
The movie comes to an ugly end with a train car grinding to a halt in front of a bloody altercation, the forces of forward progress literally stopped in their tracks by a culture's psychosexual dysfunction. There's nothing quaint or reassuring about Cairo Station. In fact, what's maybe most disturbing is that it hasn't aged a day.
"Cairo Station" is streaming on Netflix.
Sean Burns
Craig Lindsey
Harvey's Hellhole: Next Stop, Wonderland
Audrey Fox
The Refugees and Displaced Actors of Casablanca
May 17th 5:00 AM
Saoirse Ronan and Innocence Lost, From Atonement to On Chesil Beach
Oct 23rd 6:00 AM
1970s Made-for-TV Movies That Ignited an Occult Obsession


text:
Glendale's 100,000 Armenians
Glendale's 100,000 Armenians 07/10/2003
Should Get Fair Share of City Jobs
In recent years, as tens of thousands of Armenian immigrants from several
Middle Eastern countries and Armenia moved to Glendale, there were
unavoidable tensions from time to time between these newcomers and old-time
Glendalians.
Most of the misunderstandings occurred due to the immigrants not knowing any
English and not complying with the behavior expected from them by their
mostly WASP (White, Anglo-Saxon, Protestant) neighbors. The native
inhabitants were resentful that their Jewel City was being over-run by a
large number of foreigners. They accused the newcomers of committing such
"outrageous crimes" as speaking Armenian in the streets of Glendale and
playing loud music at late hours!
The immigrants, having escaped from the repressive regimes of their
homelands, were shocked to encounter such resentment and prejudice in the
"land of the free."
In time, however, the majority of the newcomers overcame their myriad
difficulties and became successful bankers, lawyers, doctors, engineers, and
businessmen. The election of George Deukmejian as two-term Governor of
California, and Larry Zarian, an immigrant himself, to four terms on the
Glendale City Council and four-time Mayor, encouraged some of the newcomers
to run for public office. Several Armenian immigrants have been recently
elected to various Glendale city positions. Rafi Manoukian and Bob
Yousefian, currently serve on Glendale's five-member City Council. Greg
Krikorian is on the Glendale Unified School Board, while Ara Najarian and
Dr. Armine Hacopian are members of the Glendale College Board of Trustees.
One would think that now that Armenians have achieved a large degree of
success in various fields, they are no longer discriminated against in
Glendale. Unfortunately, that is not the case. Ironically, they are now
resented for being too successful! As the Glendale Armenian community is
getting more organized and becoming politically more active, it is getting
in the way of those who had a monopoly for a long time on running this city.
To get a more accurate picture of the number of Armenians residing in
Glendale, councilman Yousefian recently asked the city staff for a count of
Armenian families that receive electricity bills from the city of Glendale.
The results were astounding. Out of a total of 76,900 families that receive
such bills, 34,500 have Armenian surnames. In other words, there are close
to 100,000 Armenians or 45% of Glendale's population of 200,000. Despite
this large percentage, there are hardly any Armenians in the Glendale Fire
and Police Departments, and only a handful hold other city positions. In
fact, there is not a single Armenian firefighter and only six police
officers of Armenian background out of a force of approximately 300. In
general, out of 1,700 full-time city employees, only 75 (4%) are Armenian.
For some reason, Yousefian's request did not sit well with Dave Weaver, a
member of the city council who has never missed an opportunity to criticize,
object to and vote against just about every Armenian-related initiative. In
a lengthy commentary headlined, "Machinations at City Hall almost too much
to bear," published in the Glendale News Press on July 5, Weaver criticizes
the rest of the Council for going "against the ethics and values that I was
raised and schooled on by my parents." He accuses his fellow council
members of striking "back room deals."
After casting such generalized aspersions, Weaver specifically attacks
Yousefian for wanting to know the number of Armenians in Glendale. "What's
he up to now?" Weaver asks. He accuses Yousefian of bringing up "the race
card" and making "inflammatory ethnic statements," while presenting himself
as someone who is "promoting racial harmony."
Weaver's latest t irade against Yousefian revolves around the request for a
conditional-use permit for the newly-built Renaissance Restaurant in
Glendale which is owned by several Armenians. Yousefian and Manoukian voted
to grant the permit, while the other three council members turned it down,
even though the owners were willing to comply with all city council
Armenians have contributed tremendously to the prosperity of this city in
recent years. The large and politically active Armenian community should
stand up for its rights and not allow itself to be bullied by closet
racists. Since Armenians are almost the majority in Glendale, they should be
entitled to their fair share of the city's jobs and services. It would be in
Glendale's best interest to have qualified Armenians represented
proportionately to their numbers in the Fire and Police Departments as well
as in other city staff positions. Glendale Armenians are not asking for any
special privileges -- just their fair share!


Full Hd romantic movie in Hindi Dubbed.
Subscribe to our channel for more hollywood latest movies.
Top 5 Hollywood Romantic film.
Watch latest movie Masterpiece dubbed in hindi with subtitles, starring KGF Star Yash, Shanvi Srivastava, Chikkanna, Suhasini Maniratnam , P. Ravi shankar.
2017 aswarya rai New Latest hollywood Hindi Dubbed Movie Magic Fantasy Movie Legin please subscribe my channel for More video please.